public String forceStop() { if (this.dm == null) { return "no distribution manager"; } String reason = dm.getCancelCriterion().cancelInProgress(); return reason; }
@Override public boolean isConnected() { if (this.dm == null) { return false; } if (this.dm.getCancelCriterion().isCancelInProgress()) { return false; } if (this.isDisconnecting) { return false; } return this.isConnected; }
public boolean isDisconnecting() { if (this.dm == null) { return true; } if (this.dm.getCancelCriterion().isCancelInProgress()) { return true; } if (!this.isConnected) { return true; } return this.isDisconnecting; }
private void checkCancellation() { dm.getCancelCriterion().checkCancelInProgress(null); }
protected void put(DispatchArgs args) { for (;;) { RemoteGemFireVM.this.agent.getDM().getCancelCriterion().checkCancelInProgress(null); boolean interrupted = Thread.interrupted(); try { queue.put(args); break; } catch (InterruptedException ignore) { interrupted = true; } finally { if (interrupted) { Thread.currentThread().interrupt(); } } } // for } }
@Override public String cancelInProgress() { checkFailure(); if (dm == null) { return "No dm"; } return dm.getCancelCriterion().cancelInProgress(); }
@Override public RuntimeException generateCancelledException(Throwable e) { if (dm == null) { return new DistributedSystemDisconnectedException("no dm", e); } return dm.getCancelCriterion().generateCancelledException(e); } }
protected void checkCancellation() { DistributionManager dm = this.getDistributionManager(); // TODO does dm == null mean we're dead? if (dm != null) { dm.getCancelCriterion().checkCancelInProgress(null); } }
/** * Throws InterruptedException if local lock request exists and is interruptible or * CancelException if DistributionManager is forcing us to cancel for shutdown. * * @param e the throwable that caused this check */ private void throwIfInterruptible(InterruptedException e) throws InterruptedException { // This needs to be first, otherwise user gets a complaint that // the TV is off when the problem is the house is burning down... this.dm.getCancelCriterion().checkCancelInProgress(e); if (this.dlock.isInterruptibleLockRequest()) { throw e; } }
/** * Acquires the write lock on the destroy ReadWrite lock within specified millis. * * @param millis the milliseconds to attempt to acquire the lock within * @throws DistributedSystemDisconnectedException if system has been disconnected */ private void acquireDestroyWriteLock(long millis) { for (;;) { boolean interrupted = Thread.interrupted(); try { this.dm.getCancelCriterion().checkCancelInProgress(null); boolean acquired = this.destroyLock.writeLock().tryLock(millis); if (acquired) { return; } } catch (InterruptedException e) { interrupted = true; } finally { if (interrupted) { Thread.currentThread().interrupt(); } } } }
@Before public void setUp() throws Exception { resultCollector = mock(BackupResultCollector.class); dm = mock(DistributionManager.class); sender = mock(InternalDistributedMember.class); member = mock(InternalDistributedMember.class); cache = mock(InternalCache.class); recipients = new HashSet<>(); when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class)); when(dm.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); abortBackupFactory = new AbortBackupFactory(); }
@Before public void setUp() throws Exception { resultCollector = mock(BackupResultCollector.class); dm = mock(DistributionManager.class); sender = mock(InternalDistributedMember.class); member = mock(InternalDistributedMember.class); cache = mock(InternalCache.class); recipients = new HashSet<>(); when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class)); when(dm.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); prepareBackupFactory = new PrepareBackupFactory(); }
@Before public void setUp() throws Exception { resultCollector = mock(BackupResultCollector.class); dm = mock(DistributionManager.class); sender = mock(InternalDistributedMember.class); member = mock(InternalDistributedMember.class); cache = mock(InternalCache.class); recipients = new HashSet<>(); when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class)); when(dm.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); finishBackupFactory = new FinishBackupFactory(); }
@Before public void setUp() throws Exception { dm = mock(DistributionManager.class); sender = mock(InternalDistributedMember.class); member = mock(InternalDistributedMember.class); cache = mock(InternalCache.class); recipients = new HashSet<>(); when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class)); when(dm.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); flushToDiskFactory = new FlushToDiskFactory(); }
private void postWait() { waiting = false; removeListener(); final DistributionManager mgr = getDistributionManager(); mgr.getStats().endReplyWait(this.statStart, this.initTime); mgr.getCancelCriterion().checkCancelInProgress(null); }
@Override public String cancelInProgress() { String cancelInProgressString = this.dls.getDistributionManager().getCancelCriterion().cancelInProgress(); if (cancelInProgressString != null) { // delegate to underlying DM's CancelCriterion... return cancelInProgressString; } else if (this.dls.isDestroyed()) { // this.stoppedByDLS = true; return this.dls.generateLockServiceDestroyedMessage(); } else { // return null since neither DM nor DLS are shutting down // cannot call super.cancelInProgress because it's abstract return null; } }
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(); } }
@Test public void commitProcessQueryMessageIsSentIfHostDeparted() { DistributionManager manager = mock(DistributionManager.class); InternalDistributedMember member = mock(InternalDistributedMember.class); DistributionManager dm = mock(DistributionManager.class); TXCommitMessage.CommitProcessQueryReplyProcessor processor = mock( TXCommitMessage.CommitProcessQueryReplyProcessor.class); TXCommitMessage.CommitProcessQueryMessage queryMessage = mock(TXCommitMessage.CommitProcessQueryMessage.class); HashSet farSiders = mock(HashSet.class); TXCommitMessage message = spy(new TXCommitMessage()); doReturn(dm).when(message).getDistributionManager(); when(dm.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); doReturn(member).when(message).getSender(); doReturn(false).when(message).isProcessing(); doReturn(processor).when(message).createReplyProcessor(); doReturn(farSiders).when(message).getFarSiders(); doReturn(queryMessage).when(message).createQueryMessage(processor); when(farSiders.isEmpty()).thenReturn(false); message.memberDeparted(manager, member, false); verify(dm, timeout(60000)).putOutgoing(queryMessage); verify(processor, timeout(60000)).waitForRepliesUninterruptibly(); }
/** * Creates instance of grantor for the lock service. * * @param dlock the lock service the grantor is authority for * @param vId unique id that the elder increments for each new grantor */ private DLockGrantor(DLockService dlock, long vId) { this.dm = dlock.getDistributionManager(); CancelCriterion stopper = this.dm.getCancelCriterion(); this.whileInitializing = new StoppableCountDownLatch(stopper, 1); this.untilDestroyed = new StoppableCountDownLatch(stopper, 1); this.dlock = dlock; this.destroyLock = new StoppableReentrantReadWriteLock(stopper); this.versionId.set(vId); this.dm.addMembershipListener(this.membershipListener); this.thread = new DLockGrantorThread(this, stopper); this.dlock.getStats().incGrantors(1); }
public long getLatestLastAccessTime() { final Set<InternalDistributedMember> recipients = this.region.getCacheDistributionAdvisor().adviseNetSearch(); final DistributionManager dm = this.region.getDistributionManager(); dm.retainMembersWithSameOrNewerVersion(recipients, Version.GEODE_140); final LatestLastAccessTimeReplyProcessor replyProcessor = new LatestLastAccessTimeReplyProcessor(dm, recipients); dm.putOutgoing( new LatestLastAccessTimeMessage<>(replyProcessor, recipients, this.region, this.key)); try { replyProcessor.waitForReplies(); } catch (ReplyException e) { if (!(e.getCause() instanceof CancelException)) { throw e; } } catch (InterruptedException e) { dm.getCancelCriterion().checkCancelInProgress(e); Thread.currentThread().interrupt(); } return replyProcessor.getLatestLastAccessTime(); } }