Java Code Examples for com.alibaba.dubbo.common.utils.DubboAppender#clear()

The following examples show how to use com.alibaba.dubbo.common.utils.DubboAppender#clear() . 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: ReferenceCountExchangeClientTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
/**
 * test counter won't count down incorrectly when invoker is destroyed for multiple times
 */
@Test
public void test_multi_destory() {
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 2
Source File: ReferenceCountExchangeClientTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
/**
 * Test against invocation still succeed even if counter has error
 */
@Test
public void test_counter_error() {
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();

    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    // close once, counter counts down from 2 to 1, no warning occurs
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    // counter is incorrect, invocation still succeeds
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));

    // output one error every 5000 invocations.
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));

    DubboAppender.doStop();

    // status switch to available once invoke again
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());

    client.close();
    // client has been replaced with lazy client. lazy client is fetched from referenceclientmap, and since it's
    // been invoked once, it's close status is false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 3
Source File: DubboAppenderTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testClear() throws Exception {
    DubboAppender.doStart();
    DubboAppender appender = new DubboAppender();
    appender.append(event);
    assertThat(DubboAppender.logList, hasSize(1));
    DubboAppender.clear();
    assertThat(DubboAppender.logList, hasSize(0));
}
 
Example 4
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试invoker多次destory不会导致计数器多次减少
 */
@Test
public void test_multi_destory(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 5
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试计数器错误,调用成功
 */
@Test
public void test_counter_error(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    
    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    //close一次,计数器从2减少到1,不能warning
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    //计数器错误,调用正常
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
   
    //调用5千次输出一个错误
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
    
    DubboAppender.doStop();
    
    //重新调用一次后status已经是available.
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());
    
    client.close();
    //client已经被替换为lazyclient lazy client从referenceclientmap中获取,获取到的是上次的client(已经被调用过一次),所以close状态为false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 6
Source File: ReferenceCountExchangeClientTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
 * 测试invoker多次destory不会导致计数器多次减少
 */
@Test
public void test_multi_destory(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 7
Source File: ReferenceCountExchangeClientTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
 * 测试计数器错误,调用成功
 */
@Test
public void test_counter_error(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    
    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    //close一次,计数器从2减少到1,不能warning
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    //计数器错误,调用正常
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
   
    //调用5千次输出一个错误
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
    
    DubboAppender.doStop();
    
    //重新调用一次后status已经是available.
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());
    
    client.close();
    //client已经被替换为lazyclient lazy client从referenceclientmap中获取,获取到的是上次的client(已经被调用过一次),所以close状态为false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 8
Source File: ReferenceCountExchangeClientTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
/**
 * 测试invoker多次destory不会导致计数器多次减少
 */
@Test
public void test_multi_destory(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 9
Source File: ReferenceCountExchangeClientTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
/**
 * 测试计数器错误,调用成功
 */
@Test
public void test_counter_error(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    
    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    //close一次,计数器从2减少到1,不能warning
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    //计数器错误,调用正常
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
   
    //调用5千次输出一个错误
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
    
    DubboAppender.doStop();
    
    //重新调用一次后status已经是available.
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());
    
    client.close();
    //client已经被替换为lazyclient lazy client从referenceclientmap中获取,获取到的是上次的client(已经被调用过一次),所以close状态为false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 10
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试invoker多次destory不会导致计数器多次减少
 */
@Test
public void test_multi_destory(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 11
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试计数器错误,调用成功
 */
@Test
public void test_counter_error(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    
    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    //close一次,计数器从2减少到1,不能warning
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    //计数器错误,调用正常
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
   
    //调用5千次输出一个错误
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
    
    DubboAppender.doStop();
    
    //重新调用一次后status已经是available.
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());
    
    client.close();
    //client已经被替换为lazyclient lazy client从referenceclientmap中获取,获取到的是上次的client(已经被调用过一次),所以close状态为false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 12
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试invoker多次destory不会导致计数器多次减少
 */
@Test
public void test_multi_destory(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    demoServiceInvoker.destroy();
    demoServiceInvoker.destroy();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not  warning message", 0, LogUtil.findMessage(errorMsg));
    LogUtil.checkNoError();
    DubboAppender.doStop();
    destoy();
}
 
Example 13
Source File: ReferenceCountExchangeClientTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试计数器错误,调用成功
 */
@Test
public void test_counter_error(){
    init(0);
    DubboAppender.doStart();
    DubboAppender.clear();
    
    ReferenceCountExchangeClient client = getReferenceClient(helloServiceInvoker);
    //close一次,计数器从2减少到1,不能warning
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should not warning message", 0, LogUtil.findMessage(errorMsg));
    //计数器错误,调用正常
    client.close();
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
   
    //调用5千次输出一个错误
    Assert.assertEquals("hello", helloService.hello());
    Assert.assertEquals("should warning message", 1, LogUtil.findMessage(errorMsg));
    
    DubboAppender.doStop();
    
    //重新调用一次后status已经是available.
    Assert.assertEquals("client status available", true, helloServiceInvoker.isAvailable());
    
    client.close();
    //client已经被替换为lazyclient lazy client从referenceclientmap中获取,获取到的是上次的client(已经被调用过一次),所以close状态为false
    Assert.assertEquals("client status close", false, client.isClosed());
    Assert.assertEquals("client status close", false, helloServiceInvoker.isAvailable());
    destoy();
}
 
Example 14
Source File: ClientReconnectTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Before
public void clear() {
    DubboAppender.clear();
}
 
Example 15
Source File: ClientReconnectTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Before
public void clear() {
    DubboAppender.clear();
}
 
Example 16
Source File: DubboAppenderTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() throws Exception {
    DubboAppender.clear();
    DubboAppender.doStop();
}