Esempio n. 1
0
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(value);
   if (lockable) {
     try {
       if (!latch.await(1, TimeUnit.MINUTES)) throw new RuntimeException("Cannot serialize!!");
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     latch.close();
   }
 }
Esempio n. 2
0
  protected void waitForReplicationLatch(ReplicableCommand rpcCommand, Set<Class> filter) {
    Class cmdClass = getActualClass(rpcCommand);
    if (!filter.contains(cmdClass)) {
      return;
    }

    try {
      log.debugf("Replication trigger called, waiting for latch to open.");
      blockingLatch.open();
      replicationLatch.await();
      log.trace("Replication latch opened, continuing.");
    } catch (Exception e) {
      throw new RuntimeException("Unexpected exception!", e);
    }
  }
 @Override
 public void initializeReplicableCommand(ReplicableCommand command, boolean isRemote) {
   log.tracef("Received command %s", command);
   receivedCommands.add(command);
   if (isRemote) {
     remoteCommandsReceived.incrementAndGet();
     if (toBlock != null && command.getClass().isAssignableFrom(toBlock)) {
       blockTypeCommandsReceived.incrementAndGet();
       try {
         gate.await();
         log.tracef("gate is opened, processing the lock cleanup:  %s", command);
       } catch (InterruptedException e) {
         throw new RuntimeException(e);
       }
     }
   }
   actual.initializeReplicableCommand(command, isRemote);
 }
Esempio n. 4
0
 public void waitForCommandToBlock() throws InterruptedException {
   blockingLatch.await();
 }