@Override
 public Address getPrimaryOwner(Object key) {
   return stateTransferManager
       .getCacheTopology()
       .getWriteConsistentHash()
       .locatePrimaryOwner(key);
 }
 @Override
 public boolean localNodeIsOwner(Object key) {
   return stateTransferManager
       .getCacheTopology()
       .getWriteConsistentHash()
       .isKeyLocalToNode(rpcManager.getAddress(), key);
 }
 @Override
 public boolean localNodeIsPrimaryOwner(Object key) {
   return stateTransferManager
       .getCacheTopology()
       .getWriteConsistentHash()
       .locatePrimaryOwner(key)
       .equals(rpcManager.getAddress());
 }
 /**
  * @deprecated Should use {@link #waitForRehashToComplete(org.infinispan.Cache[])} instead, this
  *     is not reliable with merges
  */
 public static void waitForInitRehashToComplete(Cache... caches) {
   int gracetime = 30000; // 30 seconds?
   long giveup = System.currentTimeMillis() + gracetime;
   for (Cache c : caches) {
     StateTransferManager stateTransferManager =
         TestingUtil.extractComponent(c, StateTransferManager.class);
     RpcManager rpcManager = TestingUtil.extractComponent(c, RpcManager.class);
     while (!stateTransferManager.isJoinComplete()) {
       if (System.currentTimeMillis() > giveup) {
         String message =
             "Timed out waiting for join to complete on node " + rpcManager.getAddress() + " !";
         log.error(message);
         throw new RuntimeException(message);
       }
       LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(100));
     }
     log.trace("Node " + rpcManager.getAddress() + " finished join task.");
   }
 }
 @Override
 public Object perform(InvocationContext ctx) throws Throwable {
   final boolean trace = log.isTraceEnabled();
   LogFactory.pushNDC(cacheName, trace);
   stateTransferManager.waitForJoinToStart();
   try {
     switch (type) {
       case APPLY_STATE:
         stateTransferManager.applyState(state, sender, viewId);
         return null;
       case APPLY_LOCKS:
         stateTransferManager.applyLocks(locks, sender, viewId);
         return null;
       default:
         throw new CacheException("Unknown rehash control command type " + type);
     }
   } catch (Throwable t) {
     log.exceptionHandlingCommand(this, t);
     return null;
   } finally {
     LogFactory.popNDC(trace);
   }
 }
 @Override
 protected boolean canLoad(Object key) {
   // Don't load the value if we are using distributed mode and aren't in the read CH
   return stateTransferManager.isJoinComplete() && (!distributed || isKeyLocal(key));
 }
 private boolean isKeyLocal(Object key) {
   return stateTransferManager
       .getCacheTopology()
       .getReadConsistentHash()
       .isKeyLocalToNode(cdl.getAddress(), key);
 }