Example #1
0
func pollForMessages(cancelTime time.Time, addresses []string, bs *fnet.BuildServer) {
	done := false
	readyBail := make(map[string]nodeStatus, len(addresses))
	for _, value := range addresses {
		readyBail[value] = nodeStatus{"", false, -1}
	}

	statRequest := new(ctlmsg)
	statRequest.Addresses = addresses
	statRequest.Time = time.Now().Unix()

	statmap := make(map[string]statusMessage, 50)

	for time.Since(cancelTime).Seconds() < 0 && !done {
		ret, _ := bs.PostServer("/status", statRequest)
		json.Unmarshal(ret, &statmap)

		for _, address := range addresses {
			ns := readyBail[address]
			ns.UpdateFromStatus(address, statmap[address])
			readyBail[address] = ns
		}
		done = determineDone(readyBail)
		if done == false {
			time.Sleep(time.Second)
		}
	}
}
Example #2
0
func freeAlloc(alloc int64) (err error) {
	bs := new(fnet.BuildServer)
	allocfree, err := cli.NewClient()
	cli.PrintError("Failed to create a new client", err)
	bs, err = allocfree.SetupClient("heckle")
	cli.PrintError("Falied to setup heckle as a client", err)

	_, err = bs.PostServer("/freeAllocation", alloc)
	if err != nil {
		return
	}

	return
}