static void sendInterestChange(DistributionManager dm, ClientProxyMembershipID clientId, ClientInterestMessageImpl clientInterestMessage) { ServerInterestRegistrationMessage registrationMessage = new ServerInterestRegistrationMessage(clientId, clientInterestMessage); Set recipients = dm.getOtherDistributionManagerIds(); registrationMessage.setRecipients(recipients); ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, recipients); registrationMessage.processorId = replyProcessor.getProcessorId(); dm.putOutgoing(registrationMessage); try { replyProcessor.waitForReplies(); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } }
/** * If this processor is not waiting for any more replies, then the waiting thread will be * notified. */ protected void checkIfDone() { boolean finished = !stillWaiting(); if (finished) { finished(); } }
public static void send(Set<InternalDistributedMember> recipients, DistributionManager dm, String regionPath) throws ReplyException { ReplyProcessor21 processor = new ReplyProcessor21(dm, recipients); MembershipFlushRequest msg = new MembershipFlushRequest(regionPath, processor.getProcessorId()); msg.setRecipients(recipients); dm.putOutgoing(msg); processor.waitForRepliesUninterruptibly(); }
@Override public String toString() { return "<" + shortName() + " " + this.getProcessorId() + " waiting for " + numMembers() + " replies" + (exception == null ? "" : (" exception: " + exception)) + " from " + membersToString() + ">"; }
/** * Wait a given number of milliseconds for the expected acks to be received. If <code>msecs</code> * milliseconds pass before all acknowlegdements are received, <code>false</code> is returned. * * @param msecs the number of milliseconds to wait for replies * @throws InterruptedException if interrupted while waiting on latch * @throws ReplyException an exception passed back in reply * @throws InternalGemFireException if ack-threshold was exceeded and system property * "ack-threshold-exception" is set to true * @throws IllegalStateException if the processor is not registered to receive messages * * @return Whether or not we received all of the replies in the given amount of time. */ public boolean waitForReplies(long msecs) throws InterruptedException, ReplyException { return waitForReplies(msecs, getLatch(), true); }
public TXMessage(int txUniqueId, InternalDistributedMember onBehalfOfMember, ReplyProcessor21 processor) { this.txUniqId = txUniqueId; this.txMemberId = onBehalfOfMember; this.processorId = processor == null ? 0 : processor.getProcessorId(); }
public static void send(ClusterDistributionManager dm) throws InterruptedException { long viewId = dm.getMembershipManager().getView().getViewId(); ReplyProcessor21 rp = new ReplyProcessor21(dm, dm.getOtherDistributionManagerIds()); rp.enableSevereAlertProcessing(); dm.putOutgoing(new WaitForViewInstallation(viewId, rp.getProcessorId())); try { rp.waitForReplies(); } catch (ReplyException e) { if (e.getCause() != null && !(e.getCause() instanceof CancelException)) { if (logger.isDebugEnabled()) { logger.debug("Reply to WaitForViewInstallation received odd exception", e.getCause()); } } } // this isn't necessary for TXFailoverCommand, which is the only use of this // message right now. TXFailoverCommand performs messaging to all servers, // which will force us to wait for the view containing the crash of another // server to be processed. // dm.waitForViewInstallation(viewId); }
if (stillWaiting()) { preWait(); try { result = basicWait(msecs, latch); } catch (InterruptedException e) { interrupted = true; } finally { if (doCleanUp) { postWait(); if (doCleanUp) { try { cleanup(); } finally { if (interrupted)
/** * Send a profile update to a set of members. * * @param recipients the set of members to be notified * @param dm the distribution manager used to send the message * @param prId the unique partitioned region identifier * @param profiles bucked id to profile map * @return an instance of reply processor if requireAck is true on which the caller can wait until * the event has finished. */ public static ReplyProcessor21 send(Set recipients, DistributionManager dm, int prId, Map<Integer, BucketAdvisor.BucketProfile> profiles) { if (recipients.isEmpty()) { return null; } ReplyProcessor21 rp = null; int procId = 0; rp = new ReplyProcessor21(dm, recipients); procId = rp.getProcessorId(); AllBucketProfilesUpdateMessage m = new AllBucketProfilesUpdateMessage(recipients, prId, procId, profiles); dm.putOutgoing(m); return rp; }
public PartitionMessage(Collection<InternalDistributedMember> recipients, int regionId, ReplyProcessor21 processor) { setRecipients(recipients); this.regionId = regionId; this.processorId = processor == null ? 0 : processor.getProcessorId(); if (processor != null && isSevereAlertCompatible()) { processor.enableSevereAlertProcessing(); } initTxMemberId(); }
@Test public void shouldBeMockable() throws Exception { ReplyProcessor21 mockReplyProcessor21 = mock(ReplyProcessor21.class); mockReplyProcessor21.waitForRepliesUninterruptibly(); mockReplyProcessor21.finished(); verify(mockReplyProcessor21, times(1)).waitForRepliesUninterruptibly(); verify(mockReplyProcessor21, times(1)).finished(); } }
return true; ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, filteredRecipients); ServerPingMessage spm = new ServerPingMessage(replyProcessor); boolean receivedReplies = replyProcessor.waitForReplies(0L);
/** * Wait a given number of milliseconds for the expected acks to be received. If <code>msecs</code> * milliseconds pass before all acknowlegdements are received, <code>false</code> is returned. * <p> * Thread interruptions will be ignored while waiting. If interruption occurred while in this * method, the current thread's interrupt flag will be true, but InterruptedException will not be * thrown. * * @param p_msecs the number of milliseconds to wait for replies, zero will be interpreted as * Long.MAX_VALUE * * @throws ReplyException an exception passed back in reply * * @throws InternalGemFireException if ack-threshold was exceeded and system property * "ack-threshold-exception" is set to true * @throws IllegalStateException if the processor is not registered to receive replies */ public boolean waitForRepliesUninterruptibly(long p_msecs) throws ReplyException { return waitForRepliesUninterruptibly(p_msecs, getLatch(), true); }
/** * Wait for all expected acks to be returned or an exception to come in. This method will return * whether a) we have received replies from all desired members or b) the necessary conditions * have been met so that we don't need to wait anymore. * * @throws InternalGemFireException if ack-threshold was exceeded and system property * "ack-threshold-exception" is set to true * @throws InterruptedException thrown if the wait is interrupted * @see #canStopWaiting() */ public void waitForReplies() throws InterruptedException, ReplyException { boolean result = waitForReplies(0); Assert.assertTrue(result, "failed but no exception thrown"); }
/** * Wait for the expected acks to be received. * <p> * Thread interruptions will be ignored while waiting. If interruption occurred while in this * method, the current thread's interrupt flag will be true, but InterruptedException will not be * thrown. * * @throws ReplyException an exception passed back in reply * * @throws InternalGemFireException if ack-threshold was exceeded and system property * "ack-threshold-exception" is set to true */ public void waitForRepliesUninterruptibly() throws ReplyException { waitForRepliesUninterruptibly(0); }
protected void preWait() { waiting = true; DistributionManager mgr = getDistributionManager(); statStart = mgr.getStats().startReplyWait(); synchronized (this.members) { Set activeMembers = addListenerAndGetMembers(); processActiveMembers(activeMembers); } }
/** * We're still waiting if there is any member still left in the set and an exception hasn't been * returned from anyone yet. * * @return true if we are still waiting for a response */ protected boolean stillWaiting() { if (shutdown) { // Create the exception here, so that the call stack reflects the // failed computation. If you set the exception in onShutdown, // the resulting stack is not of interest. ReplyException re = new ReplyException(new DistributedSystemDisconnectedException( "aborted due to shutdown")); this.exception = re; return false; } // Optional override by subclass if (canStopWaiting()) { return false; } // If an error has occurred, we're done. if (stopBecauseOfExceptions()) { return false; } // All else is good, keep waiting if we have members to wait on. return numMembers() > 0; }
public void waitForProfileResponse() { if (processor == null) { return; } DistributionManager mgr = this.advisee.getDistributionManager(); try { // bug 36983 - you can't loop on a reply processor mgr.getCancelCriterion().checkCancelInProgress(null); try { processor.waitForRepliesUninterruptibly(); } catch (ReplyException e) { e.handleCause(); } } finally { processor.cleanup(); } }
public static ReplyProcessor21 send(Set recipients, PartitionedRegion r, RegionEventImpl event) { ReplyProcessor21 response = new ReplyProcessor21(r.getSystem(), recipients); InvalidatePartitionedRegionMessage msg = new InvalidatePartitionedRegionMessage(recipients, event.getCallbackArgument(), r, response); msg.setTransactionDistributed(r.getCache().getTxManager().isDistributed()); r.getSystem().getDistributionManager().putOutgoing(msg); return response; }
if (!allowReplyFromSender()) { Assert.assertTrue(initMembers != null, "null initMembers"); Assert.assertTrue(system != null, "null system"); this.exception = null; if (register) { register();