Search in sources :

Example 1 with AllConnectConnectionHolder

use of com.alipay.sofa.rpc.client.AllConnectConnectionHolder 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();
}
Also used : AllConnectConnectionHolder(com.alipay.sofa.rpc.client.AllConnectConnectionHolder) HelloService(com.alipay.sofa.rpc.test.HelloService) Cluster(com.alipay.sofa.rpc.client.Cluster) ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) ClientProxyInvoker(com.alipay.sofa.rpc.client.ClientProxyInvoker) Test(org.junit.Test) ActivelyDestroyTest(com.alipay.sofa.rpc.test.ActivelyDestroyTest)

Example 2 with AllConnectConnectionHolder

use of com.alipay.sofa.rpc.client.AllConnectConnectionHolder 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();
}
Also used : AllConnectConnectionHolder(com.alipay.sofa.rpc.client.AllConnectConnectionHolder) ProviderInfo(com.alipay.sofa.rpc.client.ProviderInfo) HelloService(com.alipay.sofa.rpc.test.HelloService) Cluster(com.alipay.sofa.rpc.client.Cluster) ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) ProviderGroup(com.alipay.sofa.rpc.client.ProviderGroup) ClientProxyInvoker(com.alipay.sofa.rpc.client.ClientProxyInvoker) Test(org.junit.Test) ActivelyDestroyTest(com.alipay.sofa.rpc.test.ActivelyDestroyTest)

Example 3 with AllConnectConnectionHolder

use of com.alipay.sofa.rpc.client.AllConnectConnectionHolder 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();
}
Also used : AllConnectConnectionHolder(com.alipay.sofa.rpc.client.AllConnectConnectionHolder) ProviderInfo(com.alipay.sofa.rpc.client.ProviderInfo) HelloService(com.alipay.sofa.rpc.test.HelloService) Cluster(com.alipay.sofa.rpc.client.Cluster) ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) ProviderGroup(com.alipay.sofa.rpc.client.ProviderGroup) ClientProxyInvoker(com.alipay.sofa.rpc.client.ClientProxyInvoker) Test(org.junit.Test) ActivelyDestroyTest(com.alipay.sofa.rpc.test.ActivelyDestroyTest)

Example 4 with AllConnectConnectionHolder

use of com.alipay.sofa.rpc.client.AllConnectConnectionHolder 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")));
}
Also used : AllConnectConnectionHolder(com.alipay.sofa.rpc.client.AllConnectConnectionHolder) HelloService(com.alipay.sofa.rpc.test.HelloService) Cluster(com.alipay.sofa.rpc.client.Cluster) ConsumerConfig(com.alipay.sofa.rpc.config.ConsumerConfig) ClientProxyInvoker(com.alipay.sofa.rpc.client.ClientProxyInvoker) Test(org.junit.Test) ActivelyDestroyTest(com.alipay.sofa.rpc.test.ActivelyDestroyTest)

Aggregations

AllConnectConnectionHolder (com.alipay.sofa.rpc.client.AllConnectConnectionHolder)4 ClientProxyInvoker (com.alipay.sofa.rpc.client.ClientProxyInvoker)4 Cluster (com.alipay.sofa.rpc.client.Cluster)4 ConsumerConfig (com.alipay.sofa.rpc.config.ConsumerConfig)4 ActivelyDestroyTest (com.alipay.sofa.rpc.test.ActivelyDestroyTest)4 HelloService (com.alipay.sofa.rpc.test.HelloService)4 Test (org.junit.Test)4 ProviderGroup (com.alipay.sofa.rpc.client.ProviderGroup)2 ProviderInfo (com.alipay.sofa.rpc.client.ProviderInfo)2