本文整理汇总了Java中com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolUtils类的具体用法?Java ProtocolUtils怎么用?Java ProtocolUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolUtils类属于com.alibaba.dubbo.rpc.protocol.dubbo.support包,在下文中一共展示了ProtocolUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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();
}
示例2: test_Lazy_ChannelReadOnly
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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());
}
示例3: testSticky4
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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());
}
示例4: exportService
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
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);
}
示例5: test_Normal_available
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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());
}
示例6: test_Normal_ChannelReadOnly
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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);
}
示例7: test_NoInvokers
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; //导入依赖的package包/类
@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());
}