com.alibaba.dubbo.remoting.exchange.ExchangeHandler Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.exchange.ExchangeHandler. 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: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example #2
Source File: FileExchangeGroup.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example #3
Source File: HeaderExchangeHandlerTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_received_request_oneway() throws RemotingException{
    final Channel mchannel = new MockedChannel();
    
    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);
    
    ExchangeHandler exhandler = new MockedExchangeHandler(){
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
Example #4
Source File: FileExchangeGroup.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[]{full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example #5
Source File: HeaderExchangeHandlerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_received_request_oneway() throws RemotingException{
    final Channel mchannel = new MockedChannel();
    
    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);
    
    ExchangeHandler exhandler = new MockedExchangeHandler(){
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
Example #6
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example #7
Source File: HeaderExchangeHandlerTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_received_request_oneway() throws RemotingException {
    final Channel mchannel = new MockedChannel();

    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);

    ExchangeHandler exhandler = new MockedExchangeHandler() {
        @Override
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
Example #8
Source File: HeaderExchangeHandlerTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_received_request_oneway() throws RemotingException{
    final Channel mchannel = new MockedChannel();
    
    final Person requestdata = new Person("charles");
    Request request = new Request();
    request.setTwoWay(false);
    request.setData(requestdata);
    
    ExchangeHandler exhandler = new MockedExchangeHandler(){
        public void received(Channel channel, Object message) throws RemotingException {
            Assert.assertEquals(requestdata, message);
        }
    };
    HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(exhandler);
    hexhandler.received(mchannel, request);
}
 
Example #9
Source File: AbstractExchangeGroup.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangeServer server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Exchangers.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ExchangeServerPeer(server, clients, this);
}
 
Example #10
Source File: AbstractExchangeGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangeServer server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Exchangers.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ExchangeServerPeer(server, clients, this);
}
 
Example #11
Source File: LazyConnectExchangeClient.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
    //lazy connect ,need set send.reconnect = true, to avoid channel bad status. 
    this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
    this.requestHandler = requestHandler;
    this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
    this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);
}
 
Example #12
Source File: LazyConnectExchangeClient.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
    //lazy connect ,need set send.reconnect = true, to avoid channel bad status. 
    this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
    this.requestHandler = requestHandler;
    this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY,Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
    this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);
}
 
Example #13
Source File: LazyConnectExchangeClient.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
    //lazy connect ,need set send.reconnect = true, to avoid channel bad status. 
    this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
    this.requestHandler = requestHandler;
    this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY,Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
    this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);
}
 
Example #14
Source File: LazyConnectExchangeClient.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
    //lazy connect ,need set send.reconnect = true, to avoid channel bad status. 
    this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
    this.requestHandler = requestHandler;
    this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY,Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
    this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);
}
 
Example #15
Source File: LazyConnectExchangeClient.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
    // lazy connect, need set send.reconnect = true, to avoid channel bad status.
    this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
    this.requestHandler = requestHandler;
    this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
    this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);
}
 
Example #16
Source File: AbstractExchangeGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangeServer server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Exchangers.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ExchangeServerPeer(server, clients, this);
}
 
Example #17
Source File: AbstractExchangeGroup.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangeServer server = servers.get(url);
    if (server == null) { // TODO exist concurrent gap
        server = Exchangers.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ExchangeServerPeer(server, clients, this);
}
 
Example #18
Source File: HeaderExchanger.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #19
Source File: HeaderExchanger.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #20
Source File: HeaderExchangeHandler.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public HeaderExchangeHandler(ExchangeHandler handler){
    if (handler == null) {
        throw new IllegalArgumentException("handler == null");
    }
    this.handler = handler;
}
 
Example #21
Source File: HeaderExchangeChannel.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return (ExchangeHandler) channel.getChannelHandler();
}
 
Example #22
Source File: LazyConnectExchangeClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return requestHandler;
}
 
Example #23
Source File: ReferenceCountExchangeClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return client.getExchangeHandler();
}
 
Example #24
Source File: HeartBeatExchangeHandler.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public HeartBeatExchangeHandler( ExchangeHandler handler ) {
    super( handler );
}
 
Example #25
Source File: MockedClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return null;
}
 
Example #26
Source File: HeaderExchangeClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return channel.getExchangeHandler();
}
 
Example #27
Source File: HeaderExchanger.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #28
Source File: MockChannel.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return null;
}
 
Example #29
Source File: AbstractExchangeGroup.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    return join(url, (ExchangeHandler) handler);
}
 
Example #30
Source File: HeaderExchangeClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeHandler getExchangeHandler() {
    return channel.getExchangeHandler();
}