When the entire set is done, a group of Runnables can be executed. @author Clebert Suconic
11601161116211631164116511661167116811691170
} } public void close(final boolean failed) { OperationContext formerCtx = storageManager.getContext(); try { storageManager.setContext(sessionContext);
313314315316317318319320321322323324325326
{ synchronized (replicationLock) { while (!pendingTokens.isEmpty()) { OperationContext ctx = pendingTokens.poll(); try { ctx.replicationDone(); } catch (Throwable e) { HornetQServerLogger.LOGGER.errorCompletingCallbackOnReplicationManager(e); }
360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
{ if (!enabled) return; 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(); } }
395396397398399400401402403404405406407408
* 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(); }
5354555657585960616263
return getContext(null); } public static OperationContext getContext(final ExecutorFactory executorFactory) { OperationContext token = OperationContextImpl.threadLocalContext.get(); if (token == null) { if (executorFactory == null) { return null;
6869707172737475767778
return name; } public Response propose(final Proposal proposal) throws Exception { OperationContext originalCtx = storageManager.getContext(); try { // the waitCompletion cannot be done inside an ordered executor or we would starve when the thread pool is full storageManager.setContext(storageManager.newSingleThreadContext());
2302230323042305230623072308230923102311231223132314231523162317
// since sendLiveIsStoping my issue a close back from the channel // and we want to ensure a stop here just in case ReplicationManager replicatorInUse = replicator; if (replicatorInUse != null) { final OperationContext token = replicator.sendLiveIsStopping(LiveStopping.FAIL_OVER); if (token != null) { try { token.waitCompletion(5000); } catch (Exception e) { // ignore it }
981982983984985986987988989990991
setStarted(false); } public void waitContextCompletion() { OperationContext formerCtx = storageManager.getContext(); try { try {
10051006100710081009101010111012101310141015
374375376377378379380381382383384385386387
// Complete any pending operations... // Case the backup crashed, this should clean up any pending requests while (!pendingTokens.isEmpty()) { OperationContext ctx = pendingTokens.poll(); try { ctx.replicationDone(); } catch (Throwable e) { ReplicationManagerImpl.log.warn("Error completing callback on replication manager", e); }