Java Code Examples for com.alibaba.dubbo.remoting.transport.dispatcher.connection.ConnectionOrderedChannelHandler#disconnected()

The following examples show how to use com.alibaba.dubbo.remoting.transport.dispatcher.connection.ConnectionOrderedChannelHandler#disconnected() . 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: ConnectChannelHandlerTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException {
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor) getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());

    int runs = 20;
    int taskCount = runs * 2;
    for (int i = 0; i < runs; i++) {
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1", executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount - 1, executor.getQueue().size());

    for (int i = 0; i < taskCount; i++) {
        if (executor.getCompletedTaskCount() < taskCount) {
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());
}
 
Example 2
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());
    
    int runs = 20;
    int taskCount = runs * 2;
    for(int i=0; i<runs;i++){
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1" ,executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount -1 , executor.getQueue().size());
    
    for( int i=0;i<taskCount; i++){
        if (executor.getCompletedTaskCount() < taskCount){
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());        
}
 
Example 3
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());
    
    int runs = 20;
    int taskCount = runs * 2;
    for(int i=0; i<runs;i++){
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1" ,executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount -1 , executor.getQueue().size());
    
    for( int i=0;i<taskCount; i++){
        if (executor.getCompletedTaskCount() < taskCount){
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());        
}
 
Example 4
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());
    
    int runs = 20;
    int taskCount = runs * 2;
    for(int i=0; i<runs;i++){
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1" ,executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount -1 , executor.getQueue().size());
    
    for( int i=0;i<taskCount; i++){
        if (executor.getCompletedTaskCount() < taskCount){
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());        
}
 
Example 5
Source File: ConnectChannelHandlerTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());
    
    int runs = 20;
    int taskCount = runs * 2;
    for(int i=0; i<runs;i++){
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1" ,executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount -1 , executor.getQueue().size());
    
    for( int i=0;i<taskCount; i++){
        if (executor.getCompletedTaskCount() < taskCount){
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());        
}
 
Example 6
Source File: ConnectChannelHandlerTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Connect_Blocked() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    Assert.assertEquals(1, executor.getMaximumPoolSize());
    
    int runs = 20;
    int taskCount = runs * 2;
    for(int i=0; i<runs;i++){
        handler.connected(new MockedChannel());
        handler.disconnected(new MockedChannel());
        Assert.assertTrue(executor.getActiveCount() + " must <=1" ,executor.getActiveCount() <= 1);
    }
    //queue.size 
    Assert.assertEquals(taskCount -1 , executor.getQueue().size());
    
    for( int i=0;i<taskCount; i++){
        if (executor.getCompletedTaskCount() < taskCount){
            sleep(100);
        }
    }
    Assert.assertEquals(taskCount, executor.getCompletedTaskCount());        
}
 
Example 7
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 8
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 9
Source File: ConnectChannelHandlerTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 10
Source File: ConnectChannelHandlerTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 11
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 12
Source File: ConnectChannelHandlerTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutionException.class)
public void test_Disconnect_Execute_Error() throws RemotingException {
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(false), url);
    ThreadPoolExecutor executor = (ThreadPoolExecutor) getField(handler, "connectionExecutor", 1);
    executor.shutdown();
    handler.disconnected(new MockedChannel());
}
 
Example 13
Source File: ConnectChannelHandlerTest.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
@Test //biz error 不抛出到线程异常上来.
public void test_Disconnect_Biz_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}
 
Example 14
Source File: ConnectChannelHandlerTest.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
@Test //biz error 不抛出到线程异常上来.
public void test_Disconnect_Biz_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}
 
Example 15
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test //biz error 不抛出到线程异常上来.
public void test_Disconnect_Biz_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}
 
Example 16
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test //biz error 不抛出到线程异常上来.
public void test_Disconnect_Biz_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}
 
Example 17
Source File: ConnectChannelHandlerTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Test //biz error 不抛出到线程异常上来.
public void test_Disconnect_Biz_Error() throws RemotingException{
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}
 
Example 18
Source File: ConnectChannelHandlerTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Test //biz error should not throw and affect biz thread.
public void test_Disconnect_Biz_Error() throws RemotingException {
    handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
    handler.disconnected(new MockedChannel());
}