StackTraceSampleCoordinator { public void cancelStackTraceSample(int sampleId, Exception cause) { synchronized (lock) { if (isShutDown) { return; } PendingStackTraceSample sample = pendingSamples.remove(sampleId); if (sample != null) { if (cause != null) { LOG.info("Cancelling sample " + sampleId, cause); } else { LOG.info("Cancelling sample {}", sampleId); } sample.discard(cause); rememberRecentSampleId(sampleId); } } } StackTraceSampleCoordinator(ActorSystem actorSystem, int sampleTimeout); @SuppressWarnings("unchecked") Future<StackTraceSample> triggerStackTraceSample(
			ExecutionVertex[] tasksToSample,
			int numSamples,
			FiniteDuration delayBetweenSamples,
			int maxStackTraceDepth); void cancelStackTraceSample(int sampleId, Exception cause); void shutDown(); void collectStackTraces(
			int sampleId,
			ExecutionAttemptID executionId,
			List<StackTraceElement[]> stackTraces);  }
@Test public void testCancelStackTraceSample() throws Exception { ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), }; Future<StackTraceSample> sampleFuture = coord.triggerStackTraceSample( vertices, 1, new FiniteDuration(100, TimeUnit.MILLISECONDS), 0); assertFalse(sampleFuture.isCompleted()); coord.cancelStackTraceSample(0, null); assertTrue(sampleFuture.isCompleted()); assertEquals(0, coord.getNumberOfPendingSamples()); }