Search in sources :

Example 1 with RemoteCacheManagerCallable

use of org.infinispan.client.hotrod.test.RemoteCacheManagerCallable in project infinispan by infinispan.

the class PingOnStartupTest method testTopologyFetched.

public void testTopologyFetched() {
    HotRodServer hotRodServer2 = server(1);
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder(hotRodServer2);
    withRemoteCacheManager(new RemoteCacheManagerCallable(new InternalRemoteCacheManager(clientBuilder.build())) {

        @Override
        public void call() {
            ChannelFactory channelFactory = ((InternalRemoteCacheManager) rcm).getChannelFactory();
            for (int i = 0; i < 10; i++) {
                if (channelFactory.getServers().size() == 1) {
                    TestingUtil.sleepThread(1000);
                } else {
                    break;
                }
            }
            assertEquals(2, channelFactory.getServers().size());
        }
    });
}
Also used : InternalRemoteCacheManager(org.infinispan.client.hotrod.test.InternalRemoteCacheManager) RemoteCacheManagerCallable(org.infinispan.client.hotrod.test.RemoteCacheManagerCallable) HotRodServer(org.infinispan.server.hotrod.HotRodServer) ChannelFactory(org.infinispan.client.hotrod.impl.transport.netty.ChannelFactory)

Example 2 with RemoteCacheManagerCallable

use of org.infinispan.client.hotrod.test.RemoteCacheManagerCallable in project infinispan by infinispan.

the class PingOnStartupTest method testGetCacheWithPingOnStartupDisabledMultipleNodes.

public void testGetCacheWithPingOnStartupDisabledMultipleNodes() {
    HotRodServer hotRodServer2 = server(1);
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder();
    clientBuilder.addServers("boomoo:12345;localhost:" + hotRodServer2.getPort());
    withRemoteCacheManager(new RemoteCacheManagerCallable(new RemoteCacheManager(clientBuilder.build())) {

        @Override
        public void call() {
            RemoteCache<Object, Object> cache = rcm.getCache();
            assertFalse(cache.containsKey("k"));
        }
    });
}
Also used : InternalRemoteCacheManager(org.infinispan.client.hotrod.test.InternalRemoteCacheManager) HotRodClientTestingUtil.withRemoteCacheManager(org.infinispan.client.hotrod.test.HotRodClientTestingUtil.withRemoteCacheManager) RemoteCacheManagerCallable(org.infinispan.client.hotrod.test.RemoteCacheManagerCallable) HotRodServer(org.infinispan.server.hotrod.HotRodServer)

Example 3 with RemoteCacheManagerCallable

use of org.infinispan.client.hotrod.test.RemoteCacheManagerCallable in project infinispan by infinispan.

the class PingOnStartupTest method testHashAwareIntelligence.

public void testHashAwareIntelligence() {
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder();
    clientBuilder.addServer().host("127.0.0.1").port(server(0).getPort());
    clientBuilder.clientIntelligence(ClientIntelligence.HASH_DISTRIBUTION_AWARE);
    withRemoteCacheManager(new RemoteCacheManagerCallable(new InternalRemoteCacheManager(clientBuilder.build())) {

        @Override
        public void call() {
            rcm.getCache();
            ChannelFactory channelFactory = ((InternalRemoteCacheManager) rcm).getChannelFactory();
            assertEquals(2, channelFactory.getServers().size());
        }
    });
}
Also used : InternalRemoteCacheManager(org.infinispan.client.hotrod.test.InternalRemoteCacheManager) RemoteCacheManagerCallable(org.infinispan.client.hotrod.test.RemoteCacheManagerCallable) ChannelFactory(org.infinispan.client.hotrod.impl.transport.netty.ChannelFactory)

Example 4 with RemoteCacheManagerCallable

use of org.infinispan.client.hotrod.test.RemoteCacheManagerCallable in project infinispan by infinispan.

the class PingOnStartupTest method testTopologyAwareIntelligence.

public void testTopologyAwareIntelligence() {
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder();
    clientBuilder.addServer().host("127.0.0.1").port(server(0).getPort());
    clientBuilder.clientIntelligence(ClientIntelligence.TOPOLOGY_AWARE);
    withRemoteCacheManager(new RemoteCacheManagerCallable(new InternalRemoteCacheManager(clientBuilder.build())) {

        @Override
        public void call() {
            rcm.getCache();
            ChannelFactory channelFactory = ((InternalRemoteCacheManager) rcm).getChannelFactory();
            assertEquals(2, channelFactory.getServers().size());
        }
    });
}
Also used : InternalRemoteCacheManager(org.infinispan.client.hotrod.test.InternalRemoteCacheManager) RemoteCacheManagerCallable(org.infinispan.client.hotrod.test.RemoteCacheManagerCallable) ChannelFactory(org.infinispan.client.hotrod.impl.transport.netty.ChannelFactory)

Example 5 with RemoteCacheManagerCallable

use of org.infinispan.client.hotrod.test.RemoteCacheManagerCallable in project infinispan by infinispan.

the class PingOnStartupTest method testGetCacheWorksIfNodeNotDown.

public void testGetCacheWorksIfNodeNotDown() {
    HotRodServer hotRodServer2 = server(1);
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder();
    clientBuilder.addServers("localhost:" + hotRodServer2.getPort());
    withRemoteCacheManager(new RemoteCacheManagerCallable(new RemoteCacheManager(clientBuilder.build())) {

        @Override
        public void call() {
            rcm.getCache();
        }
    });
}
Also used : InternalRemoteCacheManager(org.infinispan.client.hotrod.test.InternalRemoteCacheManager) HotRodClientTestingUtil.withRemoteCacheManager(org.infinispan.client.hotrod.test.HotRodClientTestingUtil.withRemoteCacheManager) RemoteCacheManagerCallable(org.infinispan.client.hotrod.test.RemoteCacheManagerCallable) HotRodServer(org.infinispan.server.hotrod.HotRodServer)

Aggregations

RemoteCacheManagerCallable (org.infinispan.client.hotrod.test.RemoteCacheManagerCallable)11 InternalRemoteCacheManager (org.infinispan.client.hotrod.test.InternalRemoteCacheManager)7 HotRodServer (org.infinispan.server.hotrod.HotRodServer)6 HotRodClientTestingUtil.withRemoteCacheManager (org.infinispan.client.hotrod.test.HotRodClientTestingUtil.withRemoteCacheManager)5 ChannelFactory (org.infinispan.client.hotrod.impl.transport.netty.ChannelFactory)4 CacheManagerCallable (org.infinispan.test.CacheManagerCallable)2 ExecutionException (java.util.concurrent.ExecutionException)1 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1