// try to join the cluster, // if there is no cluster,make itself master func initCluster(settings *util.Settings, rpcClient action.RpcClientAnts, node node.Node) { node.Join() isClusterExist := false if len(settings.NodeList) > 0 { for _, nodeInfo := range settings.NodeList { nodeSettings := strings.Split(nodeInfo, ":") ip := nodeSettings[0] port, _ := strconv.Atoi(nodeSettings[1]) if ip == node.GetNodeInfo().Ip && port == node.GetNodeInfo().Port { continue } err := rpcClient.LetMeIn(ip, port) if err == nil { isClusterExist = true } } } else { } if !isClusterExist { node.MakeMasterNode(node.GetNodeInfo().Name) } node.Ready() }