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;
}
Aggregations