use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.
the class SharedSlotTest method testConstructorAssignsPayload.
@Test
public void testConstructorAssignsPayload() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
assertThat(physicalSlot.getPayload(), not(nullValue()));
}
use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.
the class SharedSlotTest method testCannotAllocateLogicalSlotDuringRelease.
@Test(expected = IllegalStateException.class)
public void testCannotAllocateLogicalSlotDuringRelease() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
logicalSlot.tryAssignPayload(new TestLogicalSlotPayload(ignored -> sharedSlot.allocateLogicalSlot()));
sharedSlot.release(new Exception("test"));
}
use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.
the class SharedSlotTest method testReleaseDoesNotTriggersExternalRelease.
@Test
public void testReleaseDoesNotTriggersExternalRelease() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final AtomicBoolean externalReleaseInitiated = new AtomicBoolean(false);
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> externalReleaseInitiated.set(true));
sharedSlot.release(new Exception("test"));
assertThat(externalReleaseInitiated.get(), is(false));
}
use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.
the class SharedSlotTest method testAllocateLogicalSlot.
@Test
public void testAllocateLogicalSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
assertThat(logicalSlot.getAllocationId(), equalTo(physicalSlot.getAllocationId()));
assertThat(logicalSlot.getLocality(), is(Locality.UNKNOWN));
assertThat(logicalSlot.getPayload(), nullValue());
assertThat(logicalSlot.getTaskManagerLocation(), equalTo(physicalSlot.getTaskManagerLocation()));
assertThat(logicalSlot.getTaskManagerGateway(), equalTo(physicalSlot.getTaskManagerGateway()));
}
use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotTriggersExternalReleaseOnLastSlot.
@Test
public void testReturnLogicalSlotTriggersExternalReleaseOnLastSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final AtomicBoolean externalReleaseInitiated = new AtomicBoolean(false);
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> externalReleaseInitiated.set(true));
final LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot();
final LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot();
// this implicitly returns the slot
logicalSlot1.releaseSlot(new Exception("test"));
assertThat(externalReleaseInitiated.get(), is(false));
logicalSlot2.releaseSlot(new Exception("test"));
assertThat(externalReleaseInitiated.get(), is(true));
}
Aggregations