func NewSuperstep(sc *com.SignalChannel) *Superstep { Log.Print("New") s := &Superstep{ Curstep: 0, slaveState: make(map[uint32]int, 100), runningStep: make(chan int, 1), counter: 0, slaveNum: int32(len(SlaveHosts)), mutex: new(sync.Mutex), } for _, h := range SlaveHosts { s.slaveState[ip.Ip2Int(h)] = -1 } return s }
func (w *WorkerManagement) Start() { for i, workerHost := range SlaveHosts { addr, err := net.ResolveTCPAddr("tcp", workerHost+":"+work.DefaultPort) if err != nil { panic(err) } conn, err := net.DialTCP("tcp", nil, addr) // defer conn.Close() c := rpc.NewClient(conn) // defer c.Close() w.Queue[i] = c w.ip2RPCMap[ip.Ip2Int(workerHost)] = i // println(ip.Ip2Int(workerHost), i) } }