use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployCall.
@Test
public void testDeployCall() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployWithSynchronousAnswer.
@Test
public void testDeployWithSynchronousAnswer() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.RUNNING) == 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexCancelTest method testCancelFromRunning.
@Test
public void testCancelFromRunning() {
try {
final ExecutionVertex vertex = getExecutionVertex();
LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(1)).createTestingLogicalSlot();
setVertexResource(vertex, slot);
setVertexState(vertex, ExecutionState.RUNNING);
assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
vertex.cancel();
vertex.getCurrentExecutionAttempt().completeCancelling();
assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
assertFalse(slot.isAlive());
assertFalse(vertex.getFailureInfo().isPresent());
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());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotWhileReleasingDoesNotCauseConcurrentModificationException.
@Test
public void testReturnLogicalSlotWhileReleasingDoesNotCauseConcurrentModificationException() {
CompletableFuture<PhysicalSlot> slotContextFuture = CompletableFuture.completedFuture(new TestingPhysicalSlot(RP, new AllocationID()));
SharedSlot sharedSlot = SharedSlotBuilder.newBuilder().withSlotContextFuture(slotContextFuture).build();
LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot(EV1).join();
LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot(EV2).join();
logicalSlot1.tryAssignPayload(new LogicalSlot.Payload() {
@Override
public void fail(Throwable cause) {
sharedSlot.returnLogicalSlot(logicalSlot2);
}
@Override
public CompletableFuture<?> getTerminalStateFuture() {
return CompletableFuture.completedFuture(null);
}
});
sharedSlot.release(new Throwable());
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReleaseIfPhysicalSlotIsAllocated.
@Test
public void testReleaseIfPhysicalSlotIsAllocated() {
CompletableFuture<PhysicalSlot> slotContextFuture = CompletableFuture.completedFuture(new TestingPhysicalSlot(RP, new AllocationID()));
CompletableFuture<ExecutionSlotSharingGroup> released = new CompletableFuture<>();
SharedSlot sharedSlot = SharedSlotBuilder.newBuilder().withSlotContextFuture(slotContextFuture).withExternalReleaseCallback(released::complete).build();
LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot(EV1).join();
CompletableFuture<Object> terminalFuture = new CompletableFuture<>();
logicalSlot.tryAssignPayload(new DummyPayload(terminalFuture));
assertThat(terminalFuture.isDone(), is(false));
sharedSlot.release(new Throwable());
assertThat(terminalFuture.isDone(), is(true));
assertThat(sharedSlot.isEmpty(), is(true));
assertThat(released.isDone(), is(true));
}
Aggregations