Search in sources :

Example 6 with TransportException

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

the class DataClientManager method connect.

public void connect(int workerId, String hostname, int dataPort) {
    try {
        TransportClient client = this.connManager.getOrCreateClient(hostname, dataPort);
        LOG.info("Successfully connect to worker: {}({}:{})", workerId, hostname, dataPort);
        this.sender.addWorkerClient(workerId, client);
    } catch (TransportException e) {
        throw new ComputerException("Failed to connect to worker: %s(%s:%s)", workerId, hostname, dataPort);
    }
}
Also used : TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException)

Example 7 with TransportException

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

the class AbstractNettyHandler method processFailMessage.

protected void processFailMessage(ChannelHandlerContext ctx, Channel channel, FailMessage failMessage) {
    int errorCode = failMessage.errorCode();
    TransportException exception = new TransportException(errorCode, "Remote error from '%s', cause: %s", TransportUtil.remoteAddress(channel), failMessage.message());
    ConnectionId connectionId = TransportUtil.remoteConnectionId(channel);
    this.transportHandler().exceptionCaught(exception, connectionId);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException)

Example 8 with TransportException

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

the class ChannelFutureListenerOnWrite method onFailure.

public void onFailure(Channel channel, Throwable cause) {
    TransportException exception;
    if (cause instanceof TransportException) {
        exception = (TransportException) cause;
    } else {
        exception = new TransportException("Failed to send data to '%s': %s", cause, TransportUtil.remoteAddress(channel), cause.getMessage());
    }
    ConnectionId connectionId = TransportUtil.remoteConnectionId(channel);
    this.handler.exceptionCaught(exception, connectionId);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException)

Example 9 with TransportException

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

the class MessageEncoder method writeMessage.

private void writeMessage(ChannelHandlerContext ctx, Message message, ChannelPromise promise, ByteBufAllocator allocator) throws TransportException {
    ByteBuf bufHeader = null;
    try {
        PromiseCombiner combiner = new PromiseCombiner(ctx.executor());
        bufHeader = allocator.directBuffer(AbstractMessage.HEADER_LENGTH);
        NetworkBuffer bodyBuffer = message.encode(bufHeader);
        ChannelFuture headerWriteFuture = ctx.write(bufHeader);
        /*
             * Released bufHeader after in ctx.write(), set bufHeader = null
             * to not release again
             */
        bufHeader = null;
        combiner.add(headerWriteFuture);
        if (bodyBuffer != null) {
            ByteBuf bodyBuf = bodyBuffer.nettyByteBuf();
            // Will call bodyBuf.release() in ctx.write(), retain() first
            bodyBuffer.retain();
            combiner.add(ctx.write(bodyBuf));
        }
        combiner.finish(promise);
    } catch (Throwable e) {
        throw new TransportException("Failed to encode message, " + "message type: %s", e, message.type());
    } finally {
        if (bufHeader != null) {
            bufHeader.release();
        }
        message.release();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) PromiseCombiner(io.netty.util.concurrent.PromiseCombiner) NetworkBuffer(com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer) ByteBuf(io.netty.buffer.ByteBuf) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException)

Example 10 with TransportException

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

the class ClientSession method start.

public synchronized void start(long timeout) throws TransportException {
    CompletableFuture<Void> startFuture = this.startAsync();
    try {
        startFuture.get(timeout, TimeUnit.MILLISECONDS);
    } catch (Throwable e) {
        this.stateReady();
        if (e instanceof TimeoutException) {
            throw new TransportException("Timeout(%sms) to wait start-response", timeout);
        } else {
            throw new TransportException("Failed to wait start-response", e);
        }
    } finally {
        startFuture.cancel(false);
        this.startedFutureRef.compareAndSet(startFuture, null);
    }
}
Also used : TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TransportException (com.baidu.hugegraph.computer.core.common.exception.TransportException)10 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)3 Config (com.baidu.hugegraph.computer.core.config.Config)2 ConnectionManager (com.baidu.hugegraph.computer.core.network.connection.ConnectionManager)2 ChannelFuture (io.netty.channel.ChannelFuture)2 Test (org.junit.Test)2 PageRankParams (com.baidu.hugegraph.computer.algorithm.centrality.pagerank.PageRankParams)1 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)1 ComputerOptions (com.baidu.hugegraph.computer.core.config.ComputerOptions)1 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)1 Managers (com.baidu.hugegraph.computer.core.manager.Managers)1 MasterService (com.baidu.hugegraph.computer.core.master.MasterService)1 DataClientManager (com.baidu.hugegraph.computer.core.network.DataClientManager)1 NetworkBuffer (com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer)1 TransportConnectionManager (com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager)1 Message (com.baidu.hugegraph.computer.core.network.message.Message)1 NettyTransportClient (com.baidu.hugegraph.computer.core.network.netty.NettyTransportClient)1 ClientSession (com.baidu.hugegraph.computer.core.network.session.ClientSession)1 MessageRecvManager (com.baidu.hugegraph.computer.core.receiver.MessageRecvManager)1 RecvSortManager (com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager)1