use of com.alipay.sofa.rpc.client.ClientProxyInvoker in project sofa-rpc by sofastack.
the class AllConnectConnectionHolderTest method getAvailableClientTransport2.
@Test
public void getAvailableClientTransport2() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setDirectUrl("bolt://127.0.0.1:22223,bolt://127.0.0.1:22224").setConnectionHolder("all").setRegister(false).setLazy(true).setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService, consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();
Assert.assertTrue(holder.isAvailableEmpty());
Assert.assertNotNull(holder.getAvailableClientTransport(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223")));
Assert.assertNotNull(holder.getAvailableClientTransport(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224")));
consumerConfig.unRefer();
}
use of com.alipay.sofa.rpc.client.ClientProxyInvoker in project sofa-rpc by sofastack.
the class AllConnectConnectionHolderTest method getAvailableClientTransport3.
@Test
public void getAvailableClientTransport3() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setDirectUrl("bolt://127.0.0.1:22223,bolt://127.0.0.1:22224").setConnectionHolder("all").setRegister(false).setLazy(true).setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService, consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();
ProviderGroup providerGroups = new ProviderGroup();
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223"));
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224"));
holder.updateProviders(providerGroups);
Set<ProviderInfo> last = holder.currentProviderList();
Assert.assertEquals(2, last.size());
ProviderGroup providerGroups2 = new ProviderGroup();
providerGroups2.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223"));
providerGroups2.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224"));
providerGroups2.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22225"));
holder.updateProviders(providerGroups2);
Set<ProviderInfo> current = holder.currentProviderList();
Assert.assertEquals(3, current.size());
consumerConfig.unRefer();
}
use of com.alipay.sofa.rpc.client.ClientProxyInvoker in project sofa-rpc by sofastack.
the class AllConnectConnectionHolderTest method getAvailableClientTransport4.
@Test
public void getAvailableClientTransport4() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setDirectUrl("bolt://127.0.0.1:22223,bolt://127.0.0.1:22224").setConnectionHolder("all").setRegister(false).setLazy(true).setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService, consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();
ProviderGroup providerGroups = new ProviderGroup();
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223"));
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224"));
holder.updateProviders(providerGroups);
Set<ProviderInfo> last = holder.currentProviderList();
Assert.assertEquals(2, last.size());
ProviderGroup providerGroups2 = new ProviderGroup();
holder.updateProviders(providerGroups2);
Set<ProviderInfo> current = holder.currentProviderList();
Assert.assertEquals(0, current.size());
consumerConfig.unRefer();
}
use of com.alipay.sofa.rpc.client.ClientProxyInvoker in project sofa-rpc by sofastack.
the class AllConnectConnectionHolderTest method getAvailableClientTransport1.
@Test
public void getAvailableClientTransport1() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setDirectUrl("bolt://127.0.0.1:22221").setConnectionHolder("all").setRegister(false).setLazy(true).setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService, consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();
Assert.assertTrue(holder.isAvailableEmpty());
Assert.assertNull(holder.getAvailableClientTransport(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22221?serialization=hessian2")));
}
Aggregations