Search in sources :

Example 11 with TestingPhysicalSlot

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()));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) Test(org.junit.Test)

Example 12 with TestingPhysicalSlot

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"));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestingPhysicalSlotPayload(org.apache.flink.runtime.jobmaster.slotpool.TestingPhysicalSlotPayload) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) CoreMatchers.not(org.hamcrest.CoreMatchers.not) Locality(org.apache.flink.runtime.jobmanager.scheduler.Locality) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test) CompletableFuture(java.util.concurrent.CompletableFuture) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) Consumer(java.util.function.Consumer) Assert.assertThat(org.junit.Assert.assertThat) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) TestLogger(org.apache.flink.util.TestLogger) Assert.fail(org.junit.Assert.fail) SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Example 13 with TestingPhysicalSlot

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));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test)

Example 14 with TestingPhysicalSlot

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()));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Example 15 with TestingPhysicalSlot

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));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Aggregations

TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)16 Test (org.junit.Test)15 SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)13 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)3 TestingLogicalSlotBuilder (org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder)3 TestingPhysicalSlotPayload (org.apache.flink.runtime.jobmaster.slotpool.TestingPhysicalSlotPayload)3 SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)3 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)3 Consumer (java.util.function.Consumer)2 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 Locality (org.apache.flink.runtime.jobmanager.scheduler.Locality)2 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)2 TestLogger (org.apache.flink.util.TestLogger)2 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2 CoreMatchers.not (org.hamcrest.CoreMatchers.not)2