use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReleaseAlsoReleasesLogicalSlots.
@Test
public void testReleaseAlsoReleasesLogicalSlots() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
sharedSlot.release(new Exception("test"));
assertThat(logicalSlot.isAlive(), is(false));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotRejectsUnknownSlot.
@Test(expected = IllegalStateException.class)
public void testReturnLogicalSlotRejectsUnknownSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
logicalSlot.releaseSlot(new Exception("test"));
sharedSlot.returnLogicalSlot(logicalSlot);
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testAllocateLogicalSlotIssuesUniqueSlotRequestIds.
@Test
public void testAllocateLogicalSlotIssuesUniqueSlotRequestIds() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot();
final LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot();
assertThat(logicalSlot1.getSlotRequestId(), not(equalTo(logicalSlot2.getSlotRequestId())));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotRejectsAliveSlots.
@Test(expected = IllegalStateException.class)
public void testReturnLogicalSlotRejectsAliveSlots() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
sharedSlot.returnLogicalSlot(logicalSlot);
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testCanReturnLogicalSlotDuringRelease.
@Test
public void testCanReturnLogicalSlotDuringRelease() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot();
final LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot();
// both slots try to release the other one, simulating that the failure of one execution due
// to the release also fails others
logicalSlot1.tryAssignPayload(new TestLogicalSlotPayload(cause -> {
if (logicalSlot2.isAlive()) {
logicalSlot2.releaseSlot(cause);
}
}));
logicalSlot2.tryAssignPayload(new TestLogicalSlotPayload(cause -> {
if (logicalSlot1.isAlive()) {
logicalSlot1.releaseSlot(cause);
}
}));
sharedSlot.release(new Exception("test"));
// if all logical slots were released, and the sharedSlot no longer allows the allocation of
// logical slots, then the slot release was completed
assertThat(logicalSlot1.isAlive(), is(false));
assertThat(logicalSlot2.isAlive(), is(false));
try {
sharedSlot.allocateLogicalSlot();
fail("Allocation of logical slot should have failed because the slot was released.");
} catch (IllegalStateException expected) {
}
}
Aggregations