com.alibaba.dubbo.remoting.exchange.support.DefaultFuture Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.exchange.support.DefaultFuture. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(HeaderExchangeChannel.this) 
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #2
Source File: HeaderExchangeChannel.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(HeaderExchangeChannel.this) 
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #3
Source File: HeaderExchangeChannel.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(channel)
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #4
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(HeaderExchangeChannel.this) 
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #5
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(HeaderExchangeChannel.this) 
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #6
Source File: HeaderExchangeChannel.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public void close(int timeout) {
    if (closed) {
        return;
    }
    closed = true;
    if (timeout > 0) {
        long start = System.currentTimeMillis();
        while (DefaultFuture.hasFuture(HeaderExchangeChannel.this) 
                && System.currentTimeMillis() - start < timeout) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    close();
}
 
Example #7
Source File: ExchangeCodec.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #8
Source File: HeaderExchangeHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
Example #9
Source File: DeprecatedExchangeCodec.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #10
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
Example #11
Source File: HeaderExchangeServer.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
private boolean isRunning() {
    Collection<Channel> channels = getChannels();
    for (Channel channel : channels) {
        if (DefaultFuture.hasFuture(channel)) {
            return true;
        }
    }
    return false;
}
 
Example #12
Source File: HeaderExchangeHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
Example #13
Source File: ExchangeCodec.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #14
Source File: DeprecatedExchangeCodec.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #15
Source File: HeaderExchangeServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private boolean isRunning() {
    Collection<Channel> channels = getChannels();
    for (Channel channel : channels) {
        if (DefaultFuture.hasFuture(channel)) {
            return true;
        }
    }
    return false;
}
 
Example #16
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
Example #17
Source File: ExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #18
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #19
Source File: HeaderExchangeServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private boolean isRunning() {
    Collection<Channel> channels = getChannels();
    for (Channel channel : channels) {
        if (DefaultFuture.hasFuture(channel)) {
            return true;
        }
    }
    return false;
}
 
Example #20
Source File: HeaderExchangeHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public void disconnected(Channel channel) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.disconnected(exchangeChannel);
    } finally {
        DefaultFuture.closeChannel(channel);
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
Example #21
Source File: HeaderExchangeServer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private boolean isRunning() {
    Collection<Channel> channels = getChannels();
    for (Channel channel : channels) {
        if (DefaultFuture.hasFuture(channel)) {
            return true;
        }
    }
    return false;
}
 
Example #22
Source File: ExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #23
Source File: HeaderExchangeHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                    exception.getMessage(), exception);
        }
    }
}
 
Example #24
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #25
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #26
Source File: ExchangeCodec.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #27
Source File: ExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #28
Source File: HeaderExchangeHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
Example #29
Source File: DeprecatedExchangeCodec.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
protected Object getRequestData(long id) {
    DefaultFuture future = DefaultFuture.getFuture(id);
    if (future == null)
        return null;
    Request req = future.getRequest();
    if (req == null)
        return null;
    return req.getData();
}
 
Example #30
Source File: HeaderExchangeServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private boolean isRunning() {
    Collection<Channel> channels = getChannels();
    for (Channel channel : channels) {
        if (DefaultFuture.hasFuture(channel)) {
            return true;
        }
    }
    return false;
}