Search in sources :

Example 1 with ComputeManager

use of com.baidu.hugegraph.computer.core.compute.ComputeManager in project hugegraph-computer by hugegraph.

the class WorkerService method init.

/**
 * Init worker service, create the managers used by worker service.
 */
public void init(Config config) {
    E.checkArgument(!this.inited, "The %s has been initialized", this);
    this.serviceThread = Thread.currentThread();
    this.registerShutdownHook();
    this.config = config;
    this.workerInfo = new ContainerInfo();
    LOG.info("{} Start to initialize worker", this);
    this.bsp4Worker = new Bsp4Worker(this.config, this.workerInfo);
    /*
         * Keep the waitMasterInitDone() called before initManagers(),
         * in order to ensure master init() before worker managers init()
         */
    this.masterInfo = this.bsp4Worker.waitMasterInitDone();
    InetSocketAddress address = this.initManagers(this.masterInfo);
    this.workerInfo.updateAddress(address);
    Computation<?> computation = this.config.createObject(ComputerOptions.WORKER_COMPUTATION_CLASS);
    LOG.info("Loading computation '{}' in category '{}'", computation.name(), computation.category());
    this.combiner = this.config.createObject(ComputerOptions.WORKER_COMBINER_CLASS, false);
    if (this.combiner == null) {
        LOG.info("None combiner is provided for computation '{}'", computation.name());
    } else {
        LOG.info("Combiner '{}' is provided for computation '{}'", this.combiner.name(), computation.name());
    }
    LOG.info("{} register WorkerService", this);
    this.bsp4Worker.workerInitDone();
    List<ContainerInfo> workers = this.bsp4Worker.waitMasterAllInitDone();
    DataClientManager dm = this.managers.get(DataClientManager.NAME);
    for (ContainerInfo worker : workers) {
        this.workers.put(worker.id(), worker);
        dm.connect(worker.id(), worker.hostname(), worker.dataPort());
    }
    this.computeManager = new ComputeManager(this.context, this.managers);
    this.managers.initedAll(this.config);
    LOG.info("{} WorkerService initialized", this);
    this.inited = true;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DataClientManager(com.baidu.hugegraph.computer.core.network.DataClientManager) ContainerInfo(com.baidu.hugegraph.computer.core.common.ContainerInfo) Bsp4Worker(com.baidu.hugegraph.computer.core.bsp.Bsp4Worker) ComputeManager(com.baidu.hugegraph.computer.core.compute.ComputeManager)

Aggregations

Bsp4Worker (com.baidu.hugegraph.computer.core.bsp.Bsp4Worker)1 ContainerInfo (com.baidu.hugegraph.computer.core.common.ContainerInfo)1 ComputeManager (com.baidu.hugegraph.computer.core.compute.ComputeManager)1 DataClientManager (com.baidu.hugegraph.computer.core.network.DataClientManager)1 InetSocketAddress (java.net.InetSocketAddress)1