private NodeInternal registerNodeBase(ClientID clientId, boolean isLocalNode) {
    final NodeInternal node = new NodeImpl(clientId.toString(), clientId.toLong());

    nodesWriteLock.lock();
    try {
      NodeInternal old = nodes.putIfAbsent(clientId, node);
      if (old != null) {
        return old;
      } else {
        return node;
      }
    } finally {
      nodesWriteLock.unlock();
    }
  }
  public void testValidations() throws Exception {
    // Valid object ids
    ObjectIDSet validOids = new BitSetObjectIDSet();
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 50; j++) {
        long longOid = 100 * i + j;
        validOids.add(new ObjectID(longOid));
      }
    }

    ClientID[] cids = new ClientID[10];
    for (int i = 0; i < 10; i++) {
      cids[i] = new ClientID(i);
    }

    for (int i = 0; i < 10; i++) {
      ObjectIDSet validate = new BitSetObjectIDSet();
      for (int j = 0; j < 100; j++) {
        long longOid = 100 * i + j;
        validate.add(new ObjectID(longOid));
      }
      invalidateObjectManager.addObjectsToValidateFor(cids[i], validate);
    }

    invalidateObjectManager.start();

    invalidateObjectManager.validateObjects(validOids);

    ArrayList list = inValidateSink.getList();
    Assert.assertEquals(10, list.size());

    for (int i = 0; i < 10; i++) {
      InvalidateObjectsForClientContext clientContext =
          (InvalidateObjectsForClientContext) list.get(i);
      ClientID cid = clientContext.getClientID();
      int k = (int) cid.toLong();

      Invalidations invalidationsGot = invalidateObjectManager.getObjectsIDsToInvalidate(cid);
      Invalidations expected = new Invalidations();
      ObjectID mapID = ObjectID.NULL_ID;
      for (int j = 50; j < 100; j++) {
        long longOid = 100 * k + j;
        expected.add(mapID, new ObjectID(longOid));
      }
      Assert.assertEquals(expected, invalidationsGot);
    }
  }
 NodeInternal updateOnRejoin(ClientID thisNodeId, NodeID[] clusterMembers) {
   nodesWriteLock.lock();
   try {
     for (NodeID otherNode : clusterMembers) {
       if (!thisNodeId.equals(otherNode)) {
         registerNodeBase((ClientID) otherNode, false);
       }
     }
     return registerNodeBase(thisNodeId, true);
   } finally {
     nodesWriteLock.unlock();
   }
 }