Ejemplo n.º 1
0
 private HotRodServer addHotRodServer() {
   EmbeddedCacheManager cm = addClusterEnabledCacheManager(defaultBuilder);
   cm.defineConfiguration(DIST_ONE_CACHE_NAME, distOneBuilder.build());
   cm.defineConfiguration(DIST_TWO_CACHE_NAME, distTwoBuilder.build());
   HotRodServer server = HotRodClientTestingUtil.startHotRodServer(cm);
   addr2hrServer.put(new InetSocketAddress(server.getHost(), server.getPort()), server);
   return server;
 }
Ejemplo n.º 2
0
 private void assertRequestRouting(byte[] key, String cacheName, HotRodServer server) {
   RemoteCache<Object, Object> rcOne = rcm.getCache(cacheName);
   InetSocketAddress serverAddress = new InetSocketAddress(server.getHost(), server.getPort());
   for (int i = 0; i < 2; i++) {
     log.infof("Routing put test for key %s", Util.printArray(key, false));
     rcOne.put(key, "value");
     assertServerHit(serverAddress, cacheName, i + 1);
   }
 }
Ejemplo n.º 3
0
  @Override
  protected void createCacheManagers() throws Throwable {
    defaultBuilder = defaultCacheConfigurationBuilder();
    distOneBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC));
    distOneBuilder
        .clustering()
        .hash()
        .numOwners(1)
        .numSegments(1)
        .consistentHashFactory(new ControlledConsistentHashFactory(0));
    distTwoBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC));
    distTwoBuilder
        .clustering()
        .hash()
        .numOwners(1)
        .numSegments(1)
        .consistentHashFactory(new ControlledConsistentHashFactory(1));

    server1 = addHotRodServer();
    server2 = addHotRodServer();

    blockUntilViewReceived(manager(0).getCache(), 2);
    blockUntilCacheStatusAchieved(manager(0).getCache(), ComponentStatus.RUNNING, 10000);
    blockUntilCacheStatusAchieved(manager(1).getCache(), ComponentStatus.RUNNING, 10000);

    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
        new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
    clientBuilder
        .addServer()
        .host(server1.getHost())
        .port(server1.getPort())
        .addServer()
        .host(server2.getHost())
        .port(server2.getPort());
    rcm = new RemoteCacheManager(clientBuilder.build());
  }
 public static RemoteCacheManager getRemoteCacheManager(HotRodServer server) {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.addServer().host(server.getHost()).port(server.getPort());
   return new InternalRemoteCacheManager(builder.build());
 }