Exemple #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();
   }
 }
  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);
 }
Exemple #4
0
 public void allowSerialization() {
   if (lockable) latch.open();
 }
 public void waitForCommandToBlock() throws InterruptedException {
   blockingLatch.await();
 }
 public void stopBlocking() {
   blockBeforeFilter = Collections.emptySet();
   blockAfterFilter = Collections.emptySet();
   replicationLatch.open();
 }
 public void blockAfter(Class... filter) {
   this.blockAfterFilter = new HashSet<Class>(Arrays.asList(filter));
   replicationLatch.close();
   blockingLatch.close();
 }