use of com.baidu.hugegraph.computer.core.network.DataClientManager in project hugegraph-computer by hugegraph.
the class WorkerService method initManagers.
private InetSocketAddress initManagers(ContainerInfo masterInfo) {
// Create managers
WorkerRpcManager rpcManager = new WorkerRpcManager();
this.managers.add(rpcManager);
/*
* NOTE: this init() method will be called twice, will be ignored at
* the 2nd time call.
*/
WorkerRpcManager.updateRpcRemoteServerConfig(this.config, masterInfo.hostname(), masterInfo.rpcPort());
rpcManager.init(this.config);
WorkerAggrManager aggregatorManager = new WorkerAggrManager(this.context);
aggregatorManager.service(rpcManager.aggregateRpcService());
this.managers.add(aggregatorManager);
FileManager fileManager = new FileManager();
this.managers.add(fileManager);
SortManager recvSortManager = new RecvSortManager(this.context);
this.managers.add(recvSortManager);
MessageRecvManager recvManager = new MessageRecvManager(this.context, fileManager, recvSortManager);
this.managers.add(recvManager);
ConnectionManager connManager = new TransportConnectionManager();
DataServerManager serverManager = new DataServerManager(connManager, recvManager);
this.managers.add(serverManager);
DataClientManager clientManager = new DataClientManager(connManager, this.context);
this.managers.add(clientManager);
SortManager sendSortManager = new SendSortManager(this.context);
this.managers.add(sendSortManager);
MessageSendManager sendManager = new MessageSendManager(this.context, sendSortManager, clientManager.sender());
this.managers.add(sendManager);
WorkerInputManager inputManager = new WorkerInputManager(this.context, sendManager);
inputManager.service(rpcManager.inputSplitService());
this.managers.add(inputManager);
// Init all managers
this.managers.initAll(this.config);
InetSocketAddress address = serverManager.address();
LOG.info("{} WorkerService initialized managers with data server " + "address '{}'", this, address);
return address;
}
use of com.baidu.hugegraph.computer.core.network.DataClientManager 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;
}
use of com.baidu.hugegraph.computer.core.network.DataClientManager in project hugegraph-computer by hugegraph.
the class SenderIntegrateTest method slowSendFunc.
private void slowSendFunc(WorkerService service) throws TransportException {
Managers managers = Whitebox.getInternalState(service, "managers");
DataClientManager clientManager = managers.get(DataClientManager.NAME);
ConnectionManager connManager = Whitebox.getInternalState(clientManager, "connManager");
NettyTransportClient client = (NettyTransportClient) connManager.getOrCreateClient("127.0.0.1", 8091);
ClientSession clientSession = Whitebox.invoke(client.getClass(), "clientSession", client);
Function<Message, Future<Void>> sendFuncBak = Whitebox.getInternalState(clientSession, "sendFunction");
Function<Message, Future<Void>> sendFunc = message -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
return sendFuncBak.apply(message);
};
Whitebox.setInternalState(clientSession, "sendFunction", sendFunc);
}
Aggregations