public BlockingTransport(Transport actual) { super(actual); notifierLatch = new NotifierLatch(); notifierLatch.stopBlocking(); }
@Override protected void beforeBackupRemotely(XSiteReplicateCommand command) { if (command instanceof XSiteStatePushCommand) { notifierLatch.blockIfNeeded(); } } }
public void blockCommands() { notifierLatch.startBlocking(); }
public void waitToBlockAndUnblockOnce() throws InterruptedException { waitToBlock(); unblockOnce(); }
public void unblockCommands() { notifierLatch.stopBlocking(); }
public void unblockOnce() { latch.unblockOnce(); } }
public void waitToBlock() throws InterruptedException { latch.waitToBlock(); }
public void stopBlocking() { latch.stopBlocking(); topologyUpdates.remove(this); }
@Override public void broadcastTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, boolean totalOrder, boolean distributed) { for (Handle<CacheTopology> h : topologyUpdates) { if (h.condition.test(cacheTopology)) { h.latch.blockIfNeeded(); } } delegate.broadcastTopologyUpdate(cacheName, cacheTopology, availabilityMode, totalOrder, distributed); }
public Handle(Predicate<T> condition) { this.condition = condition; latch.startBlocking(); }
@Override public void handleRebalancePhaseConfirm(String cacheName, Address node, int topologyId, Throwable throwable, int viewId) throws Exception { for (Handle<Integer> h : topologyConfirmations) { if (h.condition.test(topologyId)) { h.latch.blockIfNeeded(); } } delegate.handleRebalancePhaseConfirm(cacheName, node, topologyId, throwable, viewId); }