Package org.infinispan.client.hotrod.impl.consistenthash

Examples of org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash


   protected void readNewTopologyAndHash(Transport transport, AtomicInteger topologyId) {
      int newTopologyId = transport.readVInt();
      topologyId.set(newTopologyId);
      int numKeyOwners = transport.readUnsignedShort();
      short hashFctVersion = transport.readByte();
      ConsistentHash ch = null;
      if (hashFctVersion != 0)
         ch = transport.getTransportFactory().getConsistentHashFactory()
               .newConsistentHash(hashFctVersion);
      else
         log.trace("Not using a consistent hash function (hash function version == 0)");
View Full Code Here


   }

   @Override
   public void updateHashFunction(Map<SocketAddress, Set<Integer>> servers2Hash, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
       synchronized (lock) {
         ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
         if (hash == null) {
            log.noHasHFunctionConfigured(hashFunctionVersion);
         } else {
            hash.init(servers2Hash, numKeyOwners, hashSpace);
         }
         consistentHash = hash;
      }
   }
View Full Code Here

   }

   @Override
   public void updateHashFunction(Map<SocketAddress, Set<Integer>> servers2Hash, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
       synchronized (lock) {
         ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
         if (hash == null) {
            log.noHasHFunctionConfigured(hashFunctionVersion);
         } else {
            hash.init(servers2Hash, numKeyOwners, hashSpace);
         }
         consistentHash = hash;
      }
   }
View Full Code Here

   }

   @Override
   public void updateHashFunction(Map<SocketAddress, Set<Integer>> servers2Hash, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
       synchronized (lock) {
         ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
         if (hash == null) {
            log.noHasHFunctionConfigured(hashFunctionVersion);
         } else {
            hash.init(servers2Hash, numKeyOwners, hashSpace);
         }
         consistentHash = hash;
      }
   }
View Full Code Here

         if (log.isInfoEnabled())
            log.newTopology(addresses);

         transport.getTransportFactory().updateServers(addresses);
      } else {
         ConsistentHash ch = transport.getTransportFactory()
               .getConsistentHashFactory().newConsistentHash(hashFctVersion);
         int hashSpace = transport.readVInt();
         int clusterSize = transport.readVInt();
         // New in 1.1
         int numVirtualNodes = transport.readVInt();
View Full Code Here

   }

   @Override
   public void updateHashFunction(Map<SocketAddress, Set<Integer>> servers2Hash, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
       synchronized (lock) {
         ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
         if (hash == null) {
            log.noHasHFunctionConfigured(hashFunctionVersion);
         } else {
            hash.init(servers2Hash, numKeyOwners, hashSpace);
         }
         consistentHash = hash;
      }
   }
View Full Code Here

      RemoteCache<Object, Object> cache = rcm.getCache();
      // This will initialize the consistent hash
      cache.put("k", "v");

      TcpTransportFactory transportFactory = (TcpTransportFactory) TestingUtil.extractField(rcm, "transportFactory");
      ConsistentHash ch = transportFactory.getConsistentHash();
      byte[][] keys = new byte[NUM_KEYS][];

      for (int i = 0; i < NUM_KEYS; i++) {
         keys[i] = String.valueOf(i).getBytes("UTF-8");
      }

      SocketAddress aServer = null;
      // warm-up
      for (int i = 0; i < ITERATIONS/10; i++) {
         SocketAddress server = ch.getServer(keys[i % keys.length]);
         if (server != null) aServer = server;
      }

      long startNanos = System.nanoTime();
      for (int i = 0; i < ITERATIONS; i++) {
         SocketAddress server = ch.getServer(keys[i % keys.length]);
         if (server != null) aServer = server;
      }
      double duration = System.nanoTime() - startNanos;
      log.infof("Test took %.3f s, average CH lookup was %.3f ns", duration / 1000000000L, duration / ITERATIONS);
   }
View Full Code Here

      RemoteCache<Object, Object> cache = rcm.getCache();
      // This will initialize the consistent hash
      cache.put("k", "v");

      TcpTransportFactory transportFactory = (TcpTransportFactory) TestingUtil.extractField(rcm, "transportFactory");
      ConsistentHash ch = transportFactory.getConsistentHash();
      byte[][] keys = new byte[NUM_KEYS][];

      for (int i = 0; i < NUM_KEYS; i++) {
         keys[i] = String.valueOf(i).getBytes("UTF-8");
      }

      SocketAddress aServer = null;
      // warm-up
      for (int i = 0; i < ITERATIONS/10; i++) {
         SocketAddress server = ch.getServer(keys[i % keys.length]);
         if (server != null) aServer = server;
      }

      long startNanos = System.nanoTime();
      for (int i = 0; i < ITERATIONS; i++) {
         SocketAddress server = ch.getServer(keys[i % keys.length]);
         if (server != null) aServer = server;
      }
      double duration = System.nanoTime() - startNanos;
      log.infof("Test took %.3f s, average CH lookup was %.3f ns", duration / 1000000000L, duration / ITERATIONS);
   }
View Full Code Here

   }

   @Override
   public void updateHashFunction(Map<SocketAddress, Set<Integer>> servers2Hash, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
       synchronized (lock) {
         ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
         if (hash == null) {
            log.noHasHFunctionConfigured(hashFunctionVersion);
         } else {
            hash.init(servers2Hash, numKeyOwners, hashSpace);
         }
         consistentHash = hash;
      }
   }
View Full Code Here

      }
   }

   @Override
   public void updateHashFunction(LinkedHashMap<InetSocketAddress,Integer> servers2HashCode, int numKeyOwners, short hashFunctionVersion, int hashSpace) {
      ConsistentHash hash = hashFactory.newConsistentHash(hashFunctionVersion);
      if (hash == null) {
         log.warn("No hash function configured for version: " + hashFunctionVersion);
      } else {
         hash.init(servers2HashCode, numKeyOwners, hashSpace);
      }
      consistentHash = hash;
   }
View Full Code Here

TOP

Related Classes of org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.