Search in sources :

Example 46 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId 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 47 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId 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 48 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId 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 49 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId 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 50 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId 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

SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)51 Test (org.junit.Test)40 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)15 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)11 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)8 TestLogger (org.apache.flink.util.TestLogger)6 Collectors (java.util.stream.Collectors)5 CoreMatchers.is (org.hamcrest.CoreMatchers.is)5 Assert.fail (org.junit.Assert.fail)5 Collection (java.util.Collection)4 Collections (java.util.Collections)4 List (java.util.List)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Consumer (java.util.function.Consumer)4 Time (org.apache.flink.api.common.time.Time)4 Arrays (java.util.Arrays)3 ExecutionException (java.util.concurrent.ExecutionException)3 SlotProfile (org.apache.flink.runtime.clusterframework.types.SlotProfile)3