Search in sources :

Example 1 with ClientFactory

use of com.baidu.hugegraph.computer.core.network.ClientFactory in project hugegraph-computer by hugegraph.

the class TransportConnectionManager method getOrCreateClient.

@Override
public TransportClient getOrCreateClient(ConnectionId connectionId) throws TransportException {
    E.checkArgument(this.clientFactory != null, "The clientManager has not been initialized yet");
    TransportClient client = this.clients.get(connectionId);
    if (client == null) {
        // Create the client if we don't have it yet.
        ClientFactory clientFactory = this.clientFactory;
        TransportClient newClient = clientFactory.createClient(connectionId, this.clientHandler);
        this.clients.putIfAbsent(connectionId, newClient);
        client = this.clients.get(connectionId);
    }
    return client;
}
Also used : TransportClient(com.baidu.hugegraph.computer.core.network.TransportClient) ClientFactory(com.baidu.hugegraph.computer.core.network.ClientFactory)

Example 2 with ClientFactory

use of com.baidu.hugegraph.computer.core.network.ClientFactory in project hugegraph-computer by hugegraph.

the class TransportConnectionManager method initClientManager.

@Override
public synchronized void initClientManager(Config config, ClientHandler clientHandler) {
    E.checkArgument(this.clientFactory == null, "The clientManager has already been initialized");
    E.checkArgumentNotNull(clientHandler, "The clientHandler parameter can't be null");
    TransportConf conf = TransportConf.wrapConfig(config);
    TransportProvider provider = conf.transportProvider();
    ClientFactory factory = provider.createClientFactory(conf);
    factory.init();
    this.clientFactory = factory;
    this.clientHandler = clientHandler;
}
Also used : ClientFactory(com.baidu.hugegraph.computer.core.network.ClientFactory) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) TransportProvider(com.baidu.hugegraph.computer.core.network.TransportProvider)

Aggregations

ClientFactory (com.baidu.hugegraph.computer.core.network.ClientFactory)2 TransportClient (com.baidu.hugegraph.computer.core.network.TransportClient)1 TransportConf (com.baidu.hugegraph.computer.core.network.TransportConf)1 TransportProvider (com.baidu.hugegraph.computer.core.network.TransportProvider)1