类com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils源码实例Demo

下面列出了怎么用com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_Lazy_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?lazy=true&connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    try{
        getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
        fail();
    }catch (IllegalStateException e) {
        
    }
    //invoke method --> init client
    
    IDemoService service = (IDemoService)proxy.getProxy(invoker);
    Assert.assertEquals("ok", service.get());
    
    Assert.assertEquals(true, invoker.isAvailable());
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码2 项目: dubbo-2.6.5   文件: ListTelnetHandlerTest.java
@BeforeClass
public static void setUp() {
    StringBuilder buf = new StringBuilder();
    StringBuilder buf2 = new StringBuilder();
    Method[] methods = DemoService.class.getMethods();
    for (Method method : methods) {
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (buf2.length() > 0) {
            buf2.append("\r\n");
        }
        buf2.append(method.getName());
        buf.append(ReflectUtils.getName(method));
    }
    detailMethods = buf.toString();
    methodsName = buf2.toString();

    ProtocolUtils.closeAll();
}
 
源代码3 项目: dubbo-2.6.5   文件: DubboInvokerAvilableTest.java
@Test
public void test_normal_channel_close_wait_gracefully() throws Exception {

    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?scope=true&lazy=false");
    Exporter<IDemoService> exporter = ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    Exporter<IDemoService> exporter0 = ProtocolUtils.export(new DemoServiceImpl0(), IDemoService.class, url);

    DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);

    long start = System.currentTimeMillis();

    try{
        System.setProperty(Constants.SHUTDOWN_WAIT_KEY, "2000");
        protocol.destroy();
    }finally {
        System.getProperties().remove(Constants.SHUTDOWN_WAIT_KEY);
    }

    long waitTime = System.currentTimeMillis() - start;

    Assert.assertTrue(waitTime >= 2000);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码4 项目: dubbo-2.6.5   文件: DubboInvokerAvilableTest.java
@Test
public void test_Lazy_ChannelReadOnly() throws Exception {
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?lazy=true&connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);

    DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());

    try {
        getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
        fail();
    } catch (IllegalStateException e) {

    }
    //invoke method --> init client

    IDemoService service = (IDemoService) proxy.getProxy(invoker);
    Assert.assertEquals("ok", service.get());

    Assert.assertEquals(true, invoker.isAvailable());
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码5 项目: dubbox   文件: ListTelnetHandlerTest.java
@BeforeClass
public static void setUp() {
    StringBuilder buf = new StringBuilder();
    StringBuilder buf2 = new StringBuilder();
    Method[] methods = DemoService.class.getMethods();
    for (Method method : methods) {
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (buf2.length() > 0) {
            buf2.append("\r\n");
        }
        buf2.append(method.getName());
        buf.append(ReflectUtils.getName(method));
    }
    detailMethods = buf.toString();
    methodsName = buf2.toString();
    
    ProtocolUtils.closeAll();
}
 
源代码6 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_Lazy_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?lazy=true&connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    try{
        getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
        fail();
    }catch (IllegalStateException e) {
        
    }
    //invoke method --> init client
    
    IDemoService service = (IDemoService)proxy.getProxy(invoker);
    Assert.assertEquals("ok", service.get());
    
    Assert.assertEquals(true, invoker.isAvailable());
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码7 项目: dubbox-hystrix   文件: ListTelnetHandlerTest.java
@BeforeClass
public static void setUp() {
    StringBuilder buf = new StringBuilder();
    StringBuilder buf2 = new StringBuilder();
    Method[] methods = DemoService.class.getMethods();
    for (Method method : methods) {
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (buf2.length() > 0) {
            buf2.append("\r\n");
        }
        buf2.append(method.getName());
        buf.append(ReflectUtils.getName(method));
    }
    detailMethods = buf.toString();
    methodsName = buf2.toString();
    
    ProtocolUtils.closeAll();
}
 
源代码8 项目: dubbox-hystrix   文件: DubboInvokerAvilableTest.java
@Test
public void test_Lazy_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?lazy=true&connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    try{
        getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
        fail();
    }catch (IllegalStateException e) {
        
    }
    //invoke method --> init client
    
    IDemoService service = (IDemoService)proxy.getProxy(invoker);
    Assert.assertEquals("ok", service.get());
    
    Assert.assertEquals(true, invoker.isAvailable());
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码9 项目: dubbo3   文件: ListTelnetHandlerTest.java
@BeforeClass
public static void setUp() {
    StringBuilder buf = new StringBuilder();
    StringBuilder buf2 = new StringBuilder();
    Method[] methods = DemoService.class.getMethods();
    for (Method method : methods) {
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (buf2.length() > 0) {
            buf2.append("\r\n");
        }
        buf2.append(method.getName());
        buf.append(ReflectUtils.getName(method));
    }
    detailMethods = buf.toString();
    methodsName = buf2.toString();
    
    ProtocolUtils.closeAll();
}
 
源代码10 项目: dubbo3   文件: DubboInvokerAvilableTest.java
@Test
public void test_Lazy_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?lazy=true&connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    try{
        getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
        fail();
    }catch (IllegalStateException e) {
        
    }
    //invoke method --> init client
    
    IDemoService service = (IDemoService)proxy.getProxy(invoker);
    Assert.assertEquals("ok", service.get());
    
    Assert.assertEquals(true, invoker.isAvailable());
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码11 项目: dubbox   文件: ListTelnetHandlerTest.java
@BeforeClass
public static void setUp() {
    StringBuilder buf = new StringBuilder();
    StringBuilder buf2 = new StringBuilder();
    Method[] methods = DemoService.class.getMethods();
    for (Method method : methods) {
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (buf2.length() > 0) {
            buf2.append("\r\n");
        }
        buf2.append(method.getName());
        buf.append(ReflectUtils.getName(method));
    }
    detailMethods = buf.toString();
    methodsName = buf2.toString();
    
    ProtocolUtils.closeAll();
}
 
源代码12 项目: dubbo-2.6.5   文件: DubboLazyConnectTest.java
@Test
public void testSticky4() {
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/hi?" + Constants.LAZY_CONNECT_KEY + "=true");

    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);

    IDemoService service = (IDemoService) ProtocolUtils.refer(IDemoService.class, url);
    Assert.assertEquals("ok", service.get());
}
 
源代码13 项目: dubbo-2.6.5   文件: ExplicitCallbackTest.java
public void exportService() {
    // export one service first, to test connection sharing
    serviceURL = serviceURL.addParameter("connections", 1);
    URL hellourl = serviceURL.setPath(IHelloService.class.getName());
    hello_exporter = ProtocolUtils.export(new HelloServiceImpl(), IHelloService.class, hellourl);
    exporter = ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, serviceURL);
}
 
源代码14 项目: dubbo-2.6.5   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_available() {
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);

    DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    invoker.destroy();
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码15 项目: dubbo-2.6.5   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_ChannelReadOnly() throws Exception {
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);

    DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());

    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);

    Assert.assertEquals(false, invoker.isAvailable());

    // reset status since connection is shared among invokers
    getClients(invoker)[0].removeAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY);
}
 
源代码16 项目: dubbo-2.6.5   文件: DubboInvokerAvilableTest.java
@Test
public void test_NoInvokers() throws Exception {
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);

    DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);

    ExchangeClient[] clients = getClients(invoker);
    clients[0].close();
    Assert.assertEquals(false, invoker.isAvailable());

}
 
源代码17 项目: dubbox   文件: DubboLazyConnectTest.java
@Test
public void testSticky4() {
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:"+port+"/hi?"+Constants.LAZY_CONNECT_KEY+"=true");
    
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    IDemoService service = (IDemoService)ProtocolUtils.refer(IDemoService.class, url);
    Assert.assertEquals("ok", service.get());
}
 
源代码18 项目: dubbox   文件: ExplicitCallbackTest.java
public void exportService(){
  //先export一个service,测试共享连接的问题
    serviceURL=serviceURL.addParameter("connections", 1);
    URL hellourl = serviceURL.setPath(IHelloService.class.getName());
    hello_exporter = ProtocolUtils.export(new HelloServiceImpl(), IHelloService.class, hellourl);
    exporter = ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, serviceURL);
}
 
源代码19 项目: dubbox   文件: DubboLazyConnectTest.java
@Test
public void testSticky4() {
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:"+port+"/hi?"+Constants.LAZY_CONNECT_KEY+"=true");
    
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    IDemoService service = (IDemoService)ProtocolUtils.refer(IDemoService.class, url);
    Assert.assertEquals("ok", service.get());
}
 
源代码20 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_NoInvokers() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    
    ExchangeClient[] clients = getClients(invoker);
    clients[0].close();
    Assert.assertEquals(false, invoker.isAvailable());
    
}
 
源代码21 项目: dubbox   文件: ExplicitCallbackTest.java
public void exportService(){
  //先export一个service,测试共享连接的问题
    serviceURL=serviceURL.addParameter("connections", 1);
    URL hellourl = serviceURL.setPath(IHelloService.class.getName());
    hello_exporter = ProtocolUtils.export(new HelloServiceImpl(), IHelloService.class, hellourl);
    exporter = ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, serviceURL);
}
 
源代码22 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_available(){
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    invoker.destroy();
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码23 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_available(){
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    invoker.destroy();
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码24 项目: dubbox   文件: DubboInvokerAvilableTest.java
@Test
public void test_NoInvokers() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    
    ExchangeClient[] clients = getClients(invoker);
    clients[0].close();
    Assert.assertEquals(false, invoker.isAvailable());
    
}
 
源代码25 项目: dubbox-hystrix   文件: DubboLazyConnectTest.java
@Test
public void testSticky4() {
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:"+port+"/hi?"+Constants.LAZY_CONNECT_KEY+"=true");
    
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    IDemoService service = (IDemoService)ProtocolUtils.refer(IDemoService.class, url);
    Assert.assertEquals("ok", service.get());
}
 
源代码26 项目: dubbox-hystrix   文件: ExplicitCallbackTest.java
public void exportService(){
  //先export一个service,测试共享连接的问题
    serviceURL=serviceURL.addParameter("connections", 1);
    URL hellourl = serviceURL.setPath(IHelloService.class.getName());
    hello_exporter = ProtocolUtils.export(new HelloServiceImpl(), IHelloService.class, hellourl);
    exporter = ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, serviceURL);
}
 
源代码27 项目: dubbox-hystrix   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_available(){
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    invoker.destroy();
    Assert.assertEquals(false, invoker.isAvailable());
}
 
源代码28 项目: dubbox-hystrix   文件: DubboInvokerAvilableTest.java
@Test
public void test_Normal_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    
    Assert.assertEquals(false, invoker.isAvailable());
 
    //恢复状态,invoker共享连接
    getClients(invoker)[0].removeAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY);
}
 
源代码29 项目: dubbox-hystrix   文件: DubboInvokerAvilableTest.java
@Test
public void test_NoInvokers() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi?connections=1");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    
    ExchangeClient[] clients = getClients(invoker);
    clients[0].close();
    Assert.assertEquals(false, invoker.isAvailable());
    
}
 
源代码30 项目: dubbo3   文件: DubboLazyConnectTest.java
@Test
public void testSticky4() {
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:"+port+"/hi?"+Constants.LAZY_CONNECT_KEY+"=true");
    
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    IDemoService service = (IDemoService)ProtocolUtils.refer(IDemoService.class, url);
    Assert.assertEquals("ok", service.get());
}
 
 类所在包
 类方法
 同包方法