/** flush current ops to the given members for the given region */ public static void flushTo(Set<InternalDistributedMember> targets, DistributedRegion region) { DM dm = region.getDistributionManager(); DistributedRegion r = region; boolean initialized = r.isInitialized(); if (initialized) { r.getDistributionAdvisor() .forceNewMembershipVersion(); // force a new "view" so we can track current ops try { r.getDistributionAdvisor().waitForCurrentOperations(); } catch (RegionDestroyedException e) { return; } } // send all state-flush messages and then wait for replies Set<ReplyProcessor21> processors = new HashSet<ReplyProcessor21>(); for (InternalDistributedMember target : targets) { StateStabilizationMessage gr = new StateStabilizationMessage(); gr.isSingleFlushTo = true; // new for flushTo operation gr.requestingMember = dm.getDistributionManagerId(); gr.setRecipient(target); ReplyProcessor21 processor = new ReplyProcessor21(dm, target); gr.processorId = processor.getProcessorId(); gr.channelState = dm.getMembershipManager().getMessageState(target, false); if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP) && ((gr.channelState != null) && (gr.channelState.size() > 0))) { logger.trace( LogMarker.STATE_FLUSH_OP, "channel states: {}", gr.channelStateDescription(gr.channelState)); } if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP)) { logger.trace(LogMarker.STATE_FLUSH_OP, "Sending {}", gr); } dm.putOutgoing(gr); processors.add(processor); } for (ReplyProcessor21 processor : processors) { try { processor.waitForReplies(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } }
/** * Constructor for StateFlushOperation * * @param r The region whose state is to be flushed */ public StateFlushOperation(DistributedRegion r) { this.region = r; this.dm = r.getDistributionManager(); }