org.apache.flink.runtime.jobmaster.TestingLogicalSlot Java Examples
The following examples show how to use
org.apache.flink.runtime.jobmaster.TestingLogicalSlot.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecutionVertexSchedulingTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testScheduleToDeploying() { try { final ExecutionJobVertex ejv = getExecutionVertex(new JobVertexID()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); final LogicalSlot slot = new TestingLogicalSlot(); CompletableFuture<LogicalSlot> future = CompletableFuture.completedFuture(slot); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); // try to deploy to the slot vertex.scheduleForExecution( new TestingSlotProvider(ignore -> future), false, LocationPreferenceConstraint.ALL, Collections.emptySet()); assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #2
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that it can get the task manager location in an Execution. */ @Test public void testGetTaskManagerLocationWhenScheduled() throws Exception { final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1); final TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot(); final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex); final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg); final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next(); onlyExecutionVertex.deployToSlot(testingLogicalSlot); ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0); Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocationOptional = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId); assertTrue(taskManagerLocationOptional.isPresent()); final CompletableFuture<TaskManagerLocation> taskManagerLocationFuture = taskManagerLocationOptional.get(); assertThat(taskManagerLocationFuture.get(), is(testingLogicalSlot.getTaskManagerLocation())); }
Example #3
Source File: ExecutionGraphToInputsLocationsRetrieverAdapterTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that it can get the task manager location in an Execution. */ @Test public void testGetTaskManagerLocationWhenScheduled() throws Exception { final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1); final TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot(); final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(new JobID(), jobVertex); final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg); final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next(); onlyExecutionVertex.deployToSlot(testingLogicalSlot); ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0); Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocationOptional = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId); assertTrue(taskManagerLocationOptional.isPresent()); final CompletableFuture<TaskManagerLocation> taskManagerLocationFuture = taskManagerLocationOptional.get(); assertThat(taskManagerLocationFuture.get(), is(testingLogicalSlot.getTaskManagerLocation())); }
Example #4
Source File: ExecutionVertexDeploymentTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDeployFailedAsynchronously() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); final LogicalSlot slot = new TestingLogicalSlot(new SubmitFailingSimpleAckingTaskManagerGateway()); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); vertex.deployToSlot(slot); // wait until the state transition must be done for (int i = 0; i < 100; i++) { if (vertex.getExecutionState() == ExecutionState.FAILED && vertex.getFailureCause() != null) { break; } else { Thread.sleep(10); } } assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); assertNotNull(vertex.getFailureCause()); assertTrue(vertex.getFailureCause().getMessage().contains(ERROR_MESSAGE)); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #5
Source File: SimpleSlotProvider.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<LogicalSlot> allocateSlot( SlotRequestId slotRequestId, ScheduledUnit task, SlotProfile slotProfile, Time allocationTimeout) { final SlotContext slot; synchronized (lock) { if (slots.isEmpty()) { slot = null; } else { slot = slots.removeFirst(); } if (slot != null) { TestingLogicalSlot result = new TestingLogicalSlotBuilder() .setTaskManagerLocation(slot.getTaskManagerLocation()) .setTaskManagerGateway(slot.getTaskManagerGateway()) .setSlotNumber(slot.getPhysicalSlotNumber()) .setAllocationId(slot.getAllocationId()) .setSlotRequestId(slotRequestId) .setSlotSharingGroupId(task.getSlotSharingGroupId()) .setSlotOwner(this) .createTestingLogicalSlot(); allocatedSlots.put(slotRequestId, slot); return CompletableFuture.completedFuture(result); } else { return FutureUtils.completedExceptionally(new NoResourceAvailableException()); } } }
Example #6
Source File: ExecutionVertexDeploymentTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFailExternallyDuringDeploy() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = ExecutionGraphTestUtils.getExecutionJobVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitBlockingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot(); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); vertex.deployToSlot(testingLogicalSlot); assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState()); Exception testError = new Exception("test error"); vertex.fail(testError); assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); assertEquals(testError, vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #7
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that an ongoing scheduling operation does not fail the {@link ExecutionGraph} * if it gets concurrently cancelled. */ @Test public void testSchedulingOperationCancellationWhenCancel() throws Exception { final JobVertex jobVertex = new JobVertex("NoOp JobVertex"); jobVertex.setInvokableClass(NoOpInvokable.class); jobVertex.setParallelism(2); final JobGraph jobGraph = new JobGraph(jobVertex); jobGraph.setScheduleMode(ScheduleMode.EAGER); jobGraph.setAllowQueuedScheduling(true); final CompletableFuture<LogicalSlot> slotFuture1 = new CompletableFuture<>(); final CompletableFuture<LogicalSlot> slotFuture2 = new CompletableFuture<>(); final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(2); slotProvider.addSlots(jobVertex.getID(), new CompletableFuture[]{slotFuture1, slotFuture2}); final ExecutionGraph executionGraph = createExecutionGraph(jobGraph, slotProvider); executionGraph.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); executionGraph.scheduleForExecution(); final TestingLogicalSlot slot = createTestingSlot(); final CompletableFuture<?> releaseFuture = slot.getReleaseFuture(); slotFuture1.complete(slot); // cancel should change the state of all executions to CANCELLED executionGraph.cancel(); // complete the now CANCELLED execution --> this should cause a failure slotFuture2.complete(new TestingLogicalSlotBuilder().createTestingLogicalSlot()); Thread.sleep(1L); // release the first slot to finish the cancellation releaseFuture.complete(null); // NOTE: This test will only occasionally fail without the fix since there is // a race between the releaseFuture and the slotFuture2 assertThat(executionGraph.getTerminationFuture().get(), is(JobStatus.CANCELED)); }
Example #8
Source File: ExecutionVertexDeploymentTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFailExternallyDuringDeploy() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitBlockingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot(); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); vertex.deployToSlot(testingLogicalSlot); assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState()); Exception testError = new Exception("test error"); vertex.fail(testError); assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); assertEquals(testError, vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #9
Source File: SimpleSlotProvider.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<LogicalSlot> allocateSlot( SlotRequestId slotRequestId, ScheduledUnit task, SlotProfile slotProfile, boolean allowQueued, Time allocationTimeout) { final SlotContext slot; synchronized (lock) { if (slots.isEmpty()) { slot = null; } else { slot = slots.removeFirst(); } if (slot != null) { TestingLogicalSlot result = new TestingLogicalSlotBuilder() .setTaskManagerLocation(slot.getTaskManagerLocation()) .setTaskManagerGateway(slot.getTaskManagerGateway()) .setSlotNumber(slot.getPhysicalSlotNumber()) .setAllocationId(slot.getAllocationId()) .setSlotRequestId(slotRequestId) .setSlotOwner(this) .createTestingLogicalSlot(); allocatedSlots.put(slotRequestId, slot); return CompletableFuture.completedFuture(result); } else { return FutureUtils.completedExceptionally(new NoResourceAvailableException()); } } }
Example #10
Source File: ExecutionGraphCheckpointCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private ExecutionGraph createExecutionGraphAndEnableCheckpointing( CheckpointIDCounter counter, CompletedCheckpointStore store) throws Exception { final Time timeout = Time.days(1L); ExecutionGraph executionGraph = new ExecutionGraph( new DummyJobInformation(), TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), timeout, new NoRestartStrategy(), new RestartAllStrategy.Factory(), new TestingSlotProvider(slotRequestId -> CompletableFuture.completedFuture(new TestingLogicalSlot())), ClassLoader.getSystemClassLoader(), VoidBlobWriter.getInstance(), timeout); executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread()); executionGraph.enableCheckpointing( 100, 100, 100, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), counter, store, new MemoryStateBackend(), CheckpointStatsTrackerTest.createTestTracker()); JobVertex jobVertex = new JobVertex("MockVertex"); jobVertex.setInvokableClass(AbstractInvokable.class); executionGraph.attachJobGraph(Collections.singletonList(jobVertex)); executionGraph.setQueuedSchedulingAllowed(true); return executionGraph; }
Example #11
Source File: ExecutionGraphSchedulingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Nonnull private static TestingLogicalSlot createTestingSlot(@Nullable CompletableFuture<?> releaseFuture) { return new TestingLogicalSlot( new LocalTaskManagerLocation(), new SimpleAckingTaskManagerGateway(), 0, new AllocationID(), new SlotRequestId(), new SlotSharingGroupId(), releaseFuture); }
Example #12
Source File: ExecutionGraphSchedulingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that an ongoing scheduling operation does not fail the {@link ExecutionGraph} * if it gets concurrently cancelled. */ @Test public void testSchedulingOperationCancellationWhenCancel() throws Exception { final JobVertex jobVertex = new JobVertex("NoOp JobVertex"); jobVertex.setInvokableClass(NoOpInvokable.class); jobVertex.setParallelism(2); final JobGraph jobGraph = new JobGraph(jobVertex); jobGraph.setScheduleMode(ScheduleMode.EAGER); jobGraph.setAllowQueuedScheduling(true); final CompletableFuture<LogicalSlot> slotFuture1 = new CompletableFuture<>(); final CompletableFuture<LogicalSlot> slotFuture2 = new CompletableFuture<>(); final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(2); slotProvider.addSlots(jobVertex.getID(), new CompletableFuture[]{slotFuture1, slotFuture2}); final ExecutionGraph executionGraph = createExecutionGraph(jobGraph, slotProvider); executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread()); executionGraph.scheduleForExecution(); final CompletableFuture<?> releaseFuture = new CompletableFuture<>(); final TestingLogicalSlot slot = createTestingSlot(releaseFuture); slotFuture1.complete(slot); // cancel should change the state of all executions to CANCELLED executionGraph.cancel(); // complete the now CANCELLED execution --> this should cause a failure slotFuture2.complete(new TestingLogicalSlot()); Thread.sleep(1L); // release the first slot to finish the cancellation releaseFuture.complete(null); // NOTE: This test will only occasionally fail without the fix since there is // a race between the releaseFuture and the slotFuture2 assertThat(executionGraph.getTerminationFuture().get(), is(JobStatus.CANCELED)); }
Example #13
Source File: ExecutionVertexSchedulingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSlotReleasedWhenScheduledQueued() { try { final ExecutionJobVertex ejv = getExecutionVertex(new JobVertexID()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); // a slot than cannot be deployed to final LogicalSlot slot = new TestingLogicalSlot(); slot.releaseSlot(new Exception("Test Exception")); assertFalse(slot.isAlive()); final CompletableFuture<LogicalSlot> future = new CompletableFuture<>(); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); // try to deploy to the slot vertex.scheduleForExecution( new TestingSlotProvider(ignore -> future), true, LocationPreferenceConstraint.ALL, Collections.emptySet()); // future has not yet a slot assertEquals(ExecutionState.SCHEDULED, vertex.getExecutionState()); future.complete(slot); // will have failed assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #14
Source File: ExecutionVertexSchedulingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSlotReleasedWhenScheduledImmediately() { try { final ExecutionJobVertex ejv = getExecutionVertex(new JobVertexID()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); // a slot than cannot be deployed to final LogicalSlot slot = new TestingLogicalSlot(); slot.releaseSlot(new Exception("Test Exception")); assertFalse(slot.isAlive()); CompletableFuture<LogicalSlot> future = new CompletableFuture<>(); future.complete(slot); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); // try to deploy to the slot vertex.scheduleForExecution(new TestingSlotProvider((i) -> future), false, LocationPreferenceConstraint.ALL, Collections.emptySet()); // will have failed assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #15
Source File: ExecutionVertexCancelTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCancelCallFails() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); LogicalSlot slot = new TestingLogicalSlot(new CancelSequenceSimpleAckingTaskManagerGateway(0)); setVertexResource(vertex, slot); setVertexState(vertex, ExecutionState.RUNNING); assertEquals(ExecutionState.RUNNING, vertex.getExecutionState()); vertex.cancel(); // Callback fails, leading to CANCELED assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); assertFalse(slot.isAlive()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #16
Source File: ExecutionVertexCancelTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCancelFromRunningDidNotFindTask() { // this may happen when the task finished or failed while the call was in progress try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); LogicalSlot slot = new TestingLogicalSlot(new CancelSequenceSimpleAckingTaskManagerGateway(1)); setVertexResource(vertex, slot); setVertexState(vertex, ExecutionState.RUNNING); assertEquals(ExecutionState.RUNNING, vertex.getExecutionState()); vertex.cancel(); assertEquals(ExecutionState.CANCELING, vertex.getExecutionState()); assertNull(vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #17
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that an ongoing scheduling operation does not fail the {@link ExecutionGraph} * if it gets concurrently cancelled. */ @Test public void testSchedulingOperationCancellationWhenCancel() throws Exception { final JobVertex jobVertex = new JobVertex("NoOp JobVertex"); jobVertex.setInvokableClass(NoOpInvokable.class); jobVertex.setParallelism(2); final JobGraph jobGraph = new JobGraph(jobVertex); jobGraph.setScheduleMode(ScheduleMode.EAGER); final CompletableFuture<LogicalSlot> slotFuture1 = new CompletableFuture<>(); final CompletableFuture<LogicalSlot> slotFuture2 = new CompletableFuture<>(); final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(2); slotProvider.addSlots(jobVertex.getID(), new CompletableFuture[]{slotFuture1, slotFuture2}); final ExecutionGraph executionGraph = createExecutionGraph(jobGraph, slotProvider); executionGraph.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); executionGraph.scheduleForExecution(); final TestingLogicalSlot slot = createTestingSlot(); final CompletableFuture<?> releaseFuture = slot.getReleaseFuture(); slotFuture1.complete(slot); // cancel should change the state of all executions to CANCELLED executionGraph.cancel(); // complete the now CANCELLED execution --> this should cause a failure slotFuture2.complete(new TestingLogicalSlotBuilder().createTestingLogicalSlot()); Thread.sleep(1L); // release the first slot to finish the cancellation releaseFuture.complete(null); // NOTE: This test will only occasionally fail without the fix since there is // a race between the releaseFuture and the slotFuture2 assertThat(executionGraph.getTerminationFuture().get(), is(JobStatus.CANCELED)); }
Example #18
Source File: ExecutionVertexCancelTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCancelFromRunning() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); LogicalSlot slot = new TestingLogicalSlot(new CancelSequenceSimpleAckingTaskManagerGateway(1)); setVertexResource(vertex, slot); setVertexState(vertex, ExecutionState.RUNNING); assertEquals(ExecutionState.RUNNING, vertex.getExecutionState()); vertex.cancel(); vertex.getCurrentExecutionAttempt().completeCancelling(); // response by task manager once actually canceled assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); assertFalse(slot.isAlive()); assertNull(vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #19
Source File: ExecutionVertexDeploymentTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testFailExternallyDuringDeploy() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlot(new SubmitBlockingSimpleAckingTaskManagerGateway()); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); vertex.deployToSlot(testingLogicalSlot); assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState()); Exception testError = new Exception("test error"); vertex.fail(testError); assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); assertEquals(testError, vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #20
Source File: ExecutionVertexDeploymentTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDeployFailedSynchronous() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); final LogicalSlot slot = new TestingLogicalSlot(new SubmitFailingSimpleAckingTaskManagerGateway()); assertEquals(ExecutionState.CREATED, vertex.getExecutionState()); vertex.deployToSlot(slot); assertEquals(ExecutionState.FAILED, vertex.getExecutionState()); assertNotNull(vertex.getFailureCause()); assertTrue(vertex.getFailureCause().getMessage().contains(ERROR_MESSAGE)); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #21
Source File: ExecutionTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that slots are released if we cannot assign the allocated resource to the * Execution. */ @Test public void testSlotReleaseOnFailedResourceAssignment() throws Exception { final JobVertex jobVertex = createNoOpJobVertex(); final JobVertexID jobVertexId = jobVertex.getID(); final CompletableFuture<LogicalSlot> slotFuture = new CompletableFuture<>(); final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(1); slotProvider.addSlot(jobVertexId, 0, slotFuture); ExecutionGraph executionGraph = ExecutionGraphTestUtils.createSimpleTestGraph( new JobID(), slotProvider, new NoRestartStrategy(), jobVertex); executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread()); ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(jobVertexId); final Execution execution = executionJobVertex.getTaskVertices()[0].getCurrentExecutionAttempt(); final SingleSlotTestingSlotOwner slotOwner = new SingleSlotTestingSlotOwner(); final SimpleSlot slot = new SimpleSlot( slotOwner, new LocalTaskManagerLocation(), 0, new SimpleAckingTaskManagerGateway()); final LogicalSlot otherSlot = new TestingLogicalSlot(); CompletableFuture<Execution> allocationFuture = execution.allocateAndAssignSlotForExecution( slotProvider, false, LocationPreferenceConstraint.ALL, Collections.emptySet(), TestingUtils.infiniteTime()); assertFalse(allocationFuture.isDone()); assertEquals(ExecutionState.SCHEDULED, execution.getState()); // assign a different resource to the execution assertTrue(execution.tryAssignResource(otherSlot)); // completing now the future should cause the slot to be released slotFuture.complete(slot); assertEquals(slot, slotOwner.getReturnedSlotFuture().get()); }
Example #22
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 4 votes |
@Nonnull private static TestingLogicalSlot createTestingSlot() { return new TestingLogicalSlotBuilder() .setAutomaticallyCompleteReleaseFuture(false) .createTestingLogicalSlot(); }
Example #23
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 4 votes |
private TestingLogicalSlot createTestingLogicalSlot(InteractionsCountingTaskManagerGateway gatewaySource) { return new TestingLogicalSlotBuilder() .setTaskManagerGateway(gatewaySource) .createTestingLogicalSlot(); }
Example #24
Source File: ExecutionTest.java From flink with Apache License 2.0 | 4 votes |
private TestingLogicalSlot createTestingLogicalSlot(SlotOwner slotOwner) { return new TestingLogicalSlotBuilder() .setSlotOwner(slotOwner) .createTestingLogicalSlot(); }
Example #25
Source File: ExecutionTest.java From flink with Apache License 2.0 | 4 votes |
private TestingLogicalSlot createTestingLogicalSlot(SlotOwner slotOwner) { return new TestingLogicalSlotBuilder() .setSlotOwner(slotOwner) .createTestingLogicalSlot(); }
Example #26
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 4 votes |
@Nonnull private static TestingLogicalSlot createTestingSlot() { return new TestingLogicalSlotBuilder() .setAutomaticallyCompleteReleaseFuture(false) .createTestingLogicalSlot(); }
Example #27
Source File: ExecutionGraphSchedulingTest.java From flink with Apache License 2.0 | 4 votes |
private TestingLogicalSlot createTestingLogicalSlot(InteractionsCountingTaskManagerGateway gatewaySource) { return new TestingLogicalSlotBuilder() .setTaskManagerGateway(gatewaySource) .createTestingLogicalSlot(); }
Example #28
Source File: ExecutionGraphDeploymentTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private Tuple2<ExecutionGraph, Map<ExecutionAttemptID, Execution>> setupExecution(JobVertex v1, int dop1, JobVertex v2, int dop2) throws Exception { final JobID jobId = new JobID(); v1.setParallelism(dop1); v2.setParallelism(dop2); v1.setInvokableClass(BatchTask.class); v2.setInvokableClass(BatchTask.class); final ArrayDeque<CompletableFuture<LogicalSlot>> slotFutures = new ArrayDeque<>(); for (int i = 0; i < dop1 + dop2; i++) { slotFutures.addLast(CompletableFuture.completedFuture(new TestingLogicalSlot())); } final SlotProvider slotProvider = new TestingSlotProvider(ignore -> slotFutures.removeFirst()); final JobInformation jobInformation = new DummyJobInformation( jobId, "some job"); DirectScheduledExecutorService executorService = new DirectScheduledExecutorService(); // execution graph that executes actions synchronously ExecutionGraph eg = new ExecutionGraph( jobInformation, executorService, TestingUtils.defaultExecutor(), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new RestartAllStrategy.Factory(), slotProvider, ExecutionGraph.class.getClassLoader(), blobWriter, AkkaUtils.getDefaultTimeout()); checkJobOffloaded(eg); eg.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread()); eg.setQueuedSchedulingAllowed(false); List<JobVertex> ordered = Arrays.asList(v1, v2); eg.attachJobGraph(ordered); // schedule, this triggers mock deployment eg.scheduleForExecution(); Map<ExecutionAttemptID, Execution> executions = eg.getRegisteredExecutions(); assertEquals(dop1 + dop2, executions.size()); return new Tuple2<>(eg, executions); }
Example #29
Source File: ExecutionGraphDeploymentTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that a blocking batch job fails if there are not enough resources left to schedule the * succeeding tasks. This test case is related to [FLINK-4296] where finished producing tasks * swallow the fail exception when scheduling a consumer task. */ @Test public void testNoResourceAvailableFailure() throws Exception { final JobID jobId = new JobID(); JobVertex v1 = new JobVertex("source"); JobVertex v2 = new JobVertex("sink"); int dop1 = 1; int dop2 = 1; v1.setParallelism(dop1); v2.setParallelism(dop2); v1.setInvokableClass(BatchTask.class); v2.setInvokableClass(BatchTask.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING); final ArrayDeque<CompletableFuture<LogicalSlot>> slotFutures = new ArrayDeque<>(); for (int i = 0; i < dop1; i++) { slotFutures.addLast(CompletableFuture.completedFuture(new TestingLogicalSlot())); } final SlotProvider slotProvider = new TestingSlotProvider(ignore -> slotFutures.removeFirst()); final JobInformation jobInformation = new DummyJobInformation( jobId, "failing test job"); DirectScheduledExecutorService directExecutor = new DirectScheduledExecutorService(); // execution graph that executes actions synchronously ExecutionGraph eg = new ExecutionGraph( jobInformation, directExecutor, TestingUtils.defaultExecutor(), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new RestartAllStrategy.Factory(), slotProvider, ExecutionGraph.class.getClassLoader(), blobWriter, AkkaUtils.getDefaultTimeout()); eg.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread()); checkJobOffloaded(eg); eg.setQueuedSchedulingAllowed(false); List<JobVertex> ordered = Arrays.asList(v1, v2); eg.attachJobGraph(ordered); // schedule, this triggers mock deployment eg.scheduleForExecution(); ExecutionAttemptID attemptID = eg.getJobVertex(v1.getID()).getTaskVertices()[0].getCurrentExecutionAttempt().getAttemptId(); eg.updateState(new TaskExecutionState(jobId, attemptID, ExecutionState.RUNNING)); eg.updateState(new TaskExecutionState(jobId, attemptID, ExecutionState.FINISHED, null)); assertEquals(JobStatus.FAILED, eg.getState()); }
Example #30
Source File: ExecutionVertexCancelTest.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
@Test public void testRepeatedCancelFromRunning() { try { final JobVertexID jid = new JobVertexID(); final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService()); final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout()); LogicalSlot slot = new TestingLogicalSlot(new CancelSequenceSimpleAckingTaskManagerGateway(1)); setVertexResource(vertex, slot); setVertexState(vertex, ExecutionState.RUNNING); assertEquals(ExecutionState.RUNNING, vertex.getExecutionState()); vertex.cancel(); assertEquals(ExecutionState.CANCELING, vertex.getExecutionState()); vertex.cancel(); assertEquals(ExecutionState.CANCELING, vertex.getExecutionState()); // callback by TaskManager after canceling completes vertex.getCurrentExecutionAttempt().completeCancelling(); assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); assertFalse(slot.isAlive()); assertNull(vertex.getFailureCause()); assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0); assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELED) > 0); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }