Exemplo n.º 1
0
  private OperationContext sendReplicatePacket(final Packet packet, boolean lineUp) {
    if (!enabled) return null;
    boolean runItNow = false;

    OperationContext repliToken = OperationContextImpl.getContext(executorFactory);
    if (lineUp) {
      repliToken.replicationLineUp();
    }

    synchronized (replicationLock) {
      if (enabled) {
        pendingTokens.add(repliToken);
        replicatingChannel.send(packet);
      } else {
        // Already replicating channel failed, so just play the action now
        runItNow = true;
      }
    }

    // Execute outside lock

    if (runItNow) {
      repliToken.replicationDone();
    }

    return repliToken;
  }
Exemplo n.º 2
0
  /**
   * @throws IllegalStateException By default, all replicated packets generate a replicated
   *     response. If your packets are triggering this exception, it may be because the packets were
   *     not sent with {@link #sendReplicatePacket(Packet)}.
   */
  private void replicated() {
    OperationContext ctx = pendingTokens.poll();

    if (ctx == null) {
      throw new IllegalStateException("Missing replication token on the queue.");
    }

    ctx.replicationDone();
  }
Exemplo n.º 3
0
 /**
  * Completes any pending operations.
  *
  * <p>This can be necessary in case the live loses connection to the backup (network failure, or
  * backup crashing).
  */
 public void clearReplicationTokens() {
   synchronized (replicationLock) {
     while (!pendingTokens.isEmpty()) {
       OperationContext ctx = pendingTokens.poll();
       try {
         ctx.replicationDone();
       } catch (Throwable e) {
         HornetQServerLogger.LOGGER.errorCompletingCallbackOnReplicationManager(e);
       }
     }
   }
 }