Search in sources :

Example 6 with ContainerInfo

use of com.baidu.hugegraph.computer.core.common.ContainerInfo in project hugegraph-computer by hugegraph.

the class Bsp4Master method waitWorkersInitDone.

/**
 * Wait workers registered.
 */
public List<ContainerInfo> waitWorkersInitDone() {
    LOG.info("Master is waiting for workers init-done");
    String path = this.constructPath(BspEvent.BSP_WORKER_INIT_DONE);
    List<byte[]> serializedContainers = this.waitOnWorkersEvent(path, this.registerTimeout());
    List<ContainerInfo> containers = new ArrayList<>(this.workerCount());
    for (byte[] serializedContainer : serializedContainers) {
        ContainerInfo container = new ContainerInfo();
        SerializeUtil.fromBytes(serializedContainer, container);
        containers.add(container);
    }
    LOG.info("Master waited all workers init-done, workers: {}", containers);
    this.assignIdForWorkers(containers);
    this.masterAllInitDone(containers);
    return containers;
}
Also used : ContainerInfo(com.baidu.hugegraph.computer.core.common.ContainerInfo) ArrayList(java.util.ArrayList)

Example 7 with ContainerInfo

use of com.baidu.hugegraph.computer.core.common.ContainerInfo in project hugegraph-computer by hugegraph.

the class Bsp4Worker method assignThisWorkerId.

// Note: The workerInfo in Bsp4Worker is the same object in WorkerService.
private void assignThisWorkerId(List<ContainerInfo> workersFromMaster) {
    for (ContainerInfo container : workersFromMaster) {
        if (this.workerInfo.uniqueName().equals(container.uniqueName())) {
            this.workerInfo.id(container.id());
            LOG.info("Worker({}) assigned id {} from master", this.workerInfo.uniqueName(), this.workerInfo.id());
            break;
        }
    }
}
Also used : ContainerInfo(com.baidu.hugegraph.computer.core.common.ContainerInfo)

Aggregations

ContainerInfo (com.baidu.hugegraph.computer.core.common.ContainerInfo)7 InetSocketAddress (java.net.InetSocketAddress)2 Bsp4Master (com.baidu.hugegraph.computer.core.bsp.Bsp4Master)1 Bsp4Worker (com.baidu.hugegraph.computer.core.bsp.Bsp4Worker)1 ComputeManager (com.baidu.hugegraph.computer.core.compute.ComputeManager)1 Config (com.baidu.hugegraph.computer.core.config.Config)1 DataClientManager (com.baidu.hugegraph.computer.core.network.DataClientManager)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1 Test (org.junit.Test)1