Commit 0252b8a4 authored by vicotor's avatar vicotor

add bootup resource map.

parent 605c1eca
......@@ -10,5 +10,6 @@ const (
WORKER_DEVICE_STATUS_PREFIX = "worker_device_status_"
WORKER_USAGE_INFO_PREFIX = "worker_usage_info_"
WORKER_RESOURCE_INFO_PREFIX = "worker_resource_info_"
WORKER_BOOTED_RESOURCE_INFO_PREFIX = "worker_boot_resource_info_"
WORKER_LAST_TASK_TM_PREFIX = "worker_last_task_tm_"
)
......@@ -526,6 +526,7 @@ func (wm *WorkerManager) handleWorkerMsg(worker *Worker) {
}
worker.info.resourceInfo = msg.ResourceMap
wm.UpdateWorkerResourceInfo(worker, msg.ResourceMap.ResourceMap)
wm.UpdateWorkerBootedResourceInfo(worker, msg.ResourceMap.BootupMap)
case *omanager.WorkerMessage_FetchStandardTask:
if worker.info.nodeInfo == nil {
......
......@@ -32,6 +32,12 @@ func (wm *WorkerManager) UpdateWorkerResourceInfo(worker *Worker, resourceInfo [
wm.rdb.Set(context.Background(), workerResourceInfoKey(worker), rstr, 0)
}
func (wm *WorkerManager) UpdateWorkerBootedResourceInfo(worker *Worker, bootedResourceInfo []byte) {
rstr := hex.EncodeToString(bootedResourceInfo)
log.WithField("resourceinfo", rstr).Infof("update resourceinfo")
wm.rdb.Set(context.Background(), workerBootedResourceInfoKey(worker), rstr, 0)
}
func (wm *WorkerManager) UpdateWorkerNonce(worker *Worker, nonce int) error {
return wm.rdb.Set(context.Background(), workerNonceKey(worker), nonce, 0).Err()
}
......@@ -179,6 +185,7 @@ func (wm *WorkerManager) InActiveWorker(worker *Worker) {
wm.rdb.Del(context.Background(), workerUsageInfoKey(worker))
wm.rdb.Del(context.Background(), workerDeviceInfoKey(worker))
wm.rdb.Del(context.Background(), workerResourceInfoKey(worker))
wm.rdb.Del(context.Background(), workerBootedResourceInfoKey(worker))
if worker.info.nodeInfo != nil {
wm.rmWorkerFromSets(worker, worker.info.nodeInfo.BenefitAddress)
}
......@@ -241,6 +248,10 @@ func workerResourceInfoKey(w *Worker) string {
return config.WORKER_RESOURCE_INFO_PREFIX + w.workerAddr
}
func workerBootedResourceInfoKey(w *Worker) string {
return config.WORKER_BOOTED_RESOURCE_INFO_PREFIX + w.workerAddr
}
func workerDeviceInfoKey(w *Worker) string {
return config.WORKER_DEVICE_INFO_PREFIX + w.workerAddr
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment