Search in sources :

Example 1 with TimeoutException

use of com.generallycloud.baseio.TimeoutException in project baseio by generallycloud.

the class HttpClient method request.

public synchronized HttpFuture request(HttpFuture future, long timeout) throws IOException {
    Waiter waiter = ioEventHandle.newWaiter();
    session.flush(future);
    if (waiter.await(timeout)) {
        throw new TimeoutException("timeout");
    }
    return (HttpFuture) waiter.getResponse();
}
Also used : Waiter(com.generallycloud.baseio.concurrent.Waiter) HttpFuture(com.generallycloud.baseio.codec.http11.future.HttpFuture) TimeoutException(com.generallycloud.baseio.TimeoutException)

Example 2 with TimeoutException

use of com.generallycloud.baseio.TimeoutException in project baseio by generallycloud.

the class FixedSession method request.

public ParamedProtobaseFuture request(String serviceName, String content, byte[] binary) throws IOException {
    ParamedProtobaseFuture future = new ParamedProtobaseFutureImpl(context, serviceName);
    if (!StringUtil.isNullOrBlank(content)) {
        future.write(content);
    }
    if (binary != null) {
        future.writeBinary(binary);
    }
    WaiterOnFuture onReadFuture = new WaiterOnFuture();
    waiterListen(serviceName, onReadFuture);
    session.flush(future);
    // FIXME 连接丢失时叫醒我
    if (onReadFuture.await(timeout)) {
        CloseUtil.close(session);
        throw new TimeoutException("timeout");
    }
    return (ParamedProtobaseFuture) onReadFuture.getReadFuture();
}
Also used : ParamedProtobaseFutureImpl(com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFutureImpl) ParamedProtobaseFuture(com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFuture) TimeoutException(com.generallycloud.baseio.TimeoutException)

Example 3 with TimeoutException

use of com.generallycloud.baseio.TimeoutException in project baseio by generallycloud.

the class RedisClient method sendCommand.

private synchronized RedisNode sendCommand(byte[] command, byte[]... args) throws IOException {
    RedisFuture future = new RedisCmdFuture(context);
    future.writeCommand(command, args);
    Waiter waiter = ioEventHandle.newWaiter();
    session.flush(future);
    if (waiter.await(timeout)) {
        throw new TimeoutException("timeout");
    }
    return (RedisNode) waiter.getResponse();
}
Also used : Waiter(com.generallycloud.baseio.concurrent.Waiter) TimeoutException(com.generallycloud.baseio.TimeoutException)

Aggregations

TimeoutException (com.generallycloud.baseio.TimeoutException)3 Waiter (com.generallycloud.baseio.concurrent.Waiter)2 HttpFuture (com.generallycloud.baseio.codec.http11.future.HttpFuture)1 ParamedProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFuture)1 ParamedProtobaseFutureImpl (com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFutureImpl)1