use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SingleLogicalSlotTest method testSlotRelease.
/**
* Tests that the slot release is only signaled after the owner has taken it back.
*/
@Test
public void testSlotRelease() {
final CompletableFuture<LogicalSlot> returnedSlotFuture = new CompletableFuture<>();
final CompletableFuture<Boolean> returnSlotResponseFuture = new CompletableFuture<>();
final WaitingSlotOwner waitingSlotOwner = new WaitingSlotOwner(returnedSlotFuture, returnSlotResponseFuture);
final CompletableFuture<?> terminalStateFuture = new CompletableFuture<>();
final CompletableFuture<?> failFuture = new CompletableFuture<>();
final ManualTestingPayload dummyPayload = new ManualTestingPayload(failFuture, terminalStateFuture);
final SingleLogicalSlot singleLogicalSlot = createSingleLogicalSlot(waitingSlotOwner);
assertThat(singleLogicalSlot.tryAssignPayload(dummyPayload), is(true));
final CompletableFuture<?> releaseFuture = singleLogicalSlot.releaseSlot(new FlinkException("Test exception"));
assertThat(releaseFuture.isDone(), is(false));
assertThat(returnedSlotFuture.isDone(), is(false));
assertThat(failFuture.isDone(), is(true));
terminalStateFuture.complete(null);
assertThat(returnedSlotFuture.isDone(), is(true));
returnSlotResponseFuture.complete(true);
assertThat(releaseFuture.isDone(), is(true));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexCancelTest method testCancelFromRunningDidNotFindTask.
@Test
public void testCancelFromRunningDidNotFindTask() {
// this may happen when the task finished or failed while the call was in progress
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();
assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 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 testCancelCallFails.
@Test
public void testCancelCallFails() {
try {
final ExecutionVertex vertex = getExecutionVertex();
LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(0)).createTestingLogicalSlot();
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());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexCancelTest method testRepeatedCancelFromRunning.
@Test
public void testRepeatedCancelFromRunning() {
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();
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());
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 DeploymentHandleTest method getLogicalSlotReturnsSlotIfFutureCompletedNormally.
@Test
public void getLogicalSlotReturnsSlotIfFutureCompletedNormally() {
final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
logicalSlotFuture.complete(logicalSlot);
assertTrue(deploymentHandle.getLogicalSlot().isPresent());
assertSame(logicalSlot, deploymentHandle.getLogicalSlot().get());
}
Aggregations