public ClusterElderManager(ClusterDistributionManager clusterDistributionManager, Supplier<ElderState> elderStateSupplier) { this.clusterDistributionManager = clusterDistributionManager; this.elderLock = new StoppableReentrantLock(clusterDistributionManager.getCancelCriterion()); this.elderStateSupplier = elderStateSupplier; }
/** * Sends an AdminRequest and waits for the AdminReponse */ AdminResponse sendAndWait(AdminRequest msg) { try { if (((Boolean) sending.get()).booleanValue()) { throw new OperationCancelledException( String.format("Recursion detected while sending %s", msg)); } else { sending.set(Boolean.TRUE); } ClusterDistributionManager dm = (ClusterDistributionManager) this.system.getDistributionManager(); if (isConnected()) { return msg.sendAndWait(dm); } else { // bug 39824: generate CancelException if we're shutting down dm.getCancelCriterion().checkCancelInProgress(null); throw new RuntimeAdminException( String.format("%s is not currently connected.", this)); } } finally { sending.set(Boolean.FALSE); } }
@Before public void before() { member0 = mock(InternalDistributedMember.class); clusterDistributionManager = mock(ClusterDistributionManager.class); cancelCriterion = mock(CancelCriterion.class); system = mock(InternalDistributedSystem.class); systemCancelCriterion = mock(CancelCriterion.class); memberManager = mock(MembershipManager.class); when(clusterDistributionManager.getCancelCriterion()).thenReturn(cancelCriterion); when(clusterDistributionManager.getSystem()).thenReturn(system); when(system.getCancelCriterion()).thenReturn(systemCancelCriterion); when(clusterDistributionManager.getMembershipManager()).thenReturn(memberManager); }
when(distributionManager.getConfig()).thenReturn(config); when(distributionManager.getSystem()).thenReturn(system); when(distributionManager.getCancelCriterion()).thenReturn(systemCancelCriterion); when(distributionManager.getCache()).thenReturn(cache); when(distributionManager.getExistingCache()).thenReturn(cache);
/** * @return singleton instance of StatAlertsManager */ public static synchronized StatAlertsManager getInstance(ClusterDistributionManager dm) { // As per current implementation set up request will be send only once , // when member joined to Admin distributed system // we don't need to care about race condition if (alertManager != null && alertManager.dm == dm) { return alertManager; } if (alertManager != null) { alertManager.close(); } /* * Throw DistributedSystemDisconnectedException if cancel operation is in progress */ dm.getCancelCriterion().checkCancelInProgress(null); alertManager = new StatAlertsManager(dm); return alertManager; }
while (!this.stopRequested) { this.dm.getCancelCriterion().checkCancelInProgress(null); Thread.sleep(sleepTime); if (!this.stopRequested) {
if (dm.getCancelCriterion().isCancelInProgress()) { return;
} finally { if (thr != null) { dm.getCancelCriterion().checkCancelInProgress(null); logger.info(String.format("This member caught exception processing profile %s %s", p, toString()), thr);
int attempts = 0; while (wait && attempts < 30) { // max 30 seconds of wait. dm.getCancelCriterion().checkCancelInProgress(null); if (isDebugEnabled) { logger.debug( } catch (InterruptedException e) { interrupted = true; dm.getCancelCriterion().checkCancelInProgress(e); } finally { if (interrupted) dm.getCancelCriterion().checkCancelInProgress(null); try { boolean interrupted = Thread.interrupted(); } catch (InterruptedException e) { interrupted = true; dm.getCancelCriterion().checkCancelInProgress(e); } finally { if (interrupted)
dm.getCancelCriterion().checkCancelInProgress(null);
this.getCancelCriterion().checkCancelInProgress(null); boolean interrupted = Thread.interrupted(); try {
} catch (InterruptedException ie) { interrupted = true; dm.getCancelCriterion().checkCancelInProgress(ie);
} finally { if (thr != null) { dm.getCancelCriterion().checkCancelInProgress(null); logger.info(String.format("This member caught exception processing profile %s %s", new Object[] {p, toString()}),
dm.getCancelCriterion().checkCancelInProgress(null); } else { cp.hasCacheServer = true;
try { for (;;) { dm.getCancelCriterion().checkCancelInProgress(null);
dm.getCancelCriterion().checkCancelInProgress(ex); String s = "Request wait was interrupted."; s += " (" + msg + ")";
@Test public void getRegionKeysForIterationTranslatesRemoteOperationException() { expectedException.expect(TransactionDataNodeHasDepartedException.class); InternalDistributedSystem system = mock(InternalDistributedSystem.class); ClusterDistributionManager manager = mock(ClusterDistributionManager.class); when(system.getDistributionManager()).thenReturn(manager); when(manager.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); InternalDistributedMember target = new InternalDistributedMember("localhost", 1234); RemoteFetchKeysMessage.FetchKeysResponse responseProcessor = new RemoteFetchKeysMessage.FetchKeysResponse(system, target); RemoteFetchKeysMessage.FetchKeysResponse spy = Mockito.spy(responseProcessor); Exception replyException = new ReplyException("testing", new RemoteOperationException("The cache is closing", new CacheClosedException())); doThrow(replyException).when(spy).waitForRepliesUninterruptibly(); spy.waitForKeys(); fail( "Expected to translate RemoteOperationException.CacheClosedException to TransactionDataNodeHasDepartedException "); }
dm.getCancelCriterion().checkCancelInProgress(null); boolean interrupted = Thread.interrupted(); try {
logger.trace(LogMarker.DM_VERBOSE, "Processing '{}'", this); String reason = dm.getCancelCriterion().cancelInProgress(); if (reason != null) {
dm.getCancelCriterion().checkCancelInProgress(cce); // TODO anyway to find the region or