org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy Java Examples
The following examples show how to use
org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void matchPreviousLocationNotAvailableAndSomeOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(3); blacklisted.add(aid1); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // we expect that the candidate that is not blacklisted is returned Assert.assertEquals(slotInfo2, match.get().getSlotInfo()); }
Example #2
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void matchPreviousLocationNotAvailableAndAllOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // there should be no valid option left and we expect null as return Assert.assertFalse(match.isPresent()); }
Example #3
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void matchPreviousAllocationOverridesPreferredLocation() { SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Collections.singletonList(tml2), Collections.singleton(aid3), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(slotInfo3, match.get().getSlotInfo()); slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Arrays.asList(tmlX, tml1), new HashSet<>(Arrays.asList(aidX, aid2)), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertEquals(slotInfo2, match.get().getSlotInfo()); }
Example #4
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void matchPreviousLocationAvailableButAlsoBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Collections.singletonList(tml3), Collections.singletonList(aid3), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // available previous allocation should override blacklisting Assert.assertEquals(slotInfo3, match.get().getSlotInfo()); }
Example #5
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testPhysicalSlotResourceProfileRespected() { SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, biggerResourceProfile, Collections.emptyList(), Collections.emptyList(), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.get().getSlotInfo().getResourceProfile().isMatching(slotProfile.getPhysicalSlotResourceProfile())); ResourceProfile evenBiggerResourceProfile = ResourceProfile.fromResources( biggerResourceProfile.getCpuCores().getValue().doubleValue() + 1.0, resourceProfile.getTaskHeapMemory().getMebiBytes()); slotProfile = SlotProfile.priorAllocation( resourceProfile, evenBiggerResourceProfile, Collections.emptyList(), Collections.emptyList(), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertFalse(match.isPresent()); }
Example #6
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void returnsHostLocalMatchingIfExactTMLocationCannotBeFulfilled() { SlotProfile slotProfile = SlotProfile.preferredLocality(resourceProfile, Collections.singletonList(tmlX)); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.isPresent()); final SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality = match.get(); final SlotInfo slotInfo = slotInfoAndLocality.getSlotInfo(); assertThat(candidates, hasItem(withSlotInfo(slotInfo))); assertThat(slotInfoAndLocality, hasLocality(Locality.HOST_LOCAL)); }
Example #7
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationAvailableButAlsoBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml3), Collections.singletonList(aid3), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // available previous allocation should override blacklisting Assert.assertEquals(ssc3, match.get().getSlotInfo()); }
Example #8
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableButByLocality() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singleton(aidX)); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(ssc4, match.get().getSlotInfo()); }
Example #9
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableAndAllOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // there should be no valid option left and we expect null as return Assert.assertFalse(match.isPresent()); }
Example #10
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableAndSomeOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(3); blacklisted.add(aid1); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // we expect that the candidate that is not blacklisted is returned Assert.assertEquals(ssc2, match.get().getSlotInfo()); }
Example #11
Source File: SlotSelectionStrategyTestBase.java From flink with Apache License 2.0 | 5 votes |
private Set<SlotSelectionStrategy.SlotInfoAndResources> createCandidates() { Set<SlotSelectionStrategy.SlotInfoAndResources> candidates = new HashSet<>(4); candidates.add(new SlotSelectionStrategy.SlotInfoAndResources(ssc1)); candidates.add(new SlotSelectionStrategy.SlotInfoAndResources(ssc2)); candidates.add(new SlotSelectionStrategy.SlotInfoAndResources(ssc3)); candidates.add(new SlotSelectionStrategy.SlotInfoAndResources(ssc4)); return candidates; }
Example #12
Source File: SchedulerTestBase.java From flink with Apache License 2.0 | 5 votes |
public TestingScheduler( @Nonnull Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagersMap, @Nonnull SlotSelectionStrategy slotSelectionStrategy, @Nonnull SlotPool slotPoolGateway) { super(slotSelectionStrategy, slotPoolGateway, slotSharingManagersMap); this.slotSharingManagersMap = slotSharingManagersMap; }
Example #13
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchNoRequirements() { SlotProfile slotProfile = SlotProfile.noRequirements(); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.isPresent()); final SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality = match.get(); assertThat(candidates, hasItem(withSlotInfo(slotInfoAndLocality.getSlotInfo()))); assertThat(slotInfoAndLocality, hasLocality(Locality.UNCONSTRAINED)); }
Example #14
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testResourceProfileRespected() { SlotProfile slotProfile = new SlotProfile(biggerResourceProfile, Collections.emptyList(), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.get().getSlotInfo().getResourceProfile().isMatching(slotProfile.getResourceProfile())); ResourceProfile evenBiggerResourceProfile = new ResourceProfile(biggerResourceProfile.getCpuCores() + 1, resourceProfile.getHeapMemoryInMB()); slotProfile = new SlotProfile(evenBiggerResourceProfile, Collections.emptyList(), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertFalse(match.isPresent()); }
Example #15
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void returnsNonLocalMatchingIfResourceProfileCanBeFulfilledButNotTheTMLocationPreferences() throws Exception { final InetAddress nonHostLocalInetAddress = InetAddress.getByAddress(new byte[]{10, 0, 0, 24}); final TaskManagerLocation nonLocalTm = new TaskManagerLocation(new ResourceID("non-local-tm"), nonHostLocalInetAddress, 42); SlotProfile slotProfile = SlotProfile.preferredLocality(resourceProfile, Collections.singletonList(nonLocalTm)); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.isPresent()); final SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality = match.get(); assertThat(candidates, hasItem(withSlotInfo(slotInfoAndLocality.getSlotInfo()))); assertThat(slotInfoAndLocality, hasLocality(Locality.NON_LOCAL)); }
Example #16
Source File: PreviousAllocationSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableButByLocality() { SlotProfile slotProfile = SlotProfile.priorAllocation( resourceProfile, resourceProfile, Collections.singletonList(tml4), Collections.singleton(aidX), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(slotInfo4, match.get().getSlotInfo()); }
Example #17
Source File: SlotSelectionStrategyTestBase.java From flink with Apache License 2.0 | 5 votes |
private Set<SlotSelectionStrategy.SlotInfoAndResources> createCandidates() { Set<SlotSelectionStrategy.SlotInfoAndResources> candidates = new HashSet<>(4); candidates.add(SlotSelectionStrategy.SlotInfoAndResources.fromSingleSlot(slotInfo1)); candidates.add(SlotSelectionStrategy.SlotInfoAndResources.fromSingleSlot(slotInfo2)); candidates.add(SlotSelectionStrategy.SlotInfoAndResources.fromSingleSlot(slotInfo3)); candidates.add(SlotSelectionStrategy.SlotInfoAndResources.fromSingleSlot(slotInfo4)); return candidates; }
Example #18
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchNoRequirements() { SlotProfile slotProfile = new SlotProfile(ResourceProfile.UNKNOWN, Collections.emptyList(), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(candidates.contains(match.get().getSlotInfo())); }
Example #19
Source File: PreviousAllocationSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableButByLocality() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singleton(aidX)); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(ssc4, match.get().getSlotInfo()); }
Example #20
Source File: PreviousAllocationSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableAndAllOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // there should be no valid option left and we expect null as return Assert.assertFalse(match.isPresent()); }
Example #21
Source File: PreviousAllocationSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationNotAvailableAndSomeOthersBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(3); blacklisted.add(aid1); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // we expect that the candidate that is not blacklisted is returned Assert.assertEquals(ssc2, match.get().getSlotInfo()); }
Example #22
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchPreviousLocationAvailableButAlsoBlacklisted() { HashSet<AllocationID> blacklisted = new HashSet<>(4); blacklisted.add(aid1); blacklisted.add(aid2); blacklisted.add(aid3); blacklisted.add(aid4); SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml3), Collections.singletonList(aid3), blacklisted); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); // available previous allocation should override blacklisting Assert.assertEquals(ssc3, match.get().getSlotInfo()); }
Example #23
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void matchPreferredLocationNotAvailable() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tmlX), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(candidates.contains(match.get().getSlotInfo())); }
Example #24
Source File: SchedulerTestBase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public TestingScheduler( @Nonnull Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagersMap, @Nonnull SlotSelectionStrategy slotSelectionStrategy, @Nonnull SlotPool slotPoolGateway) { super(slotSelectionStrategy, slotPoolGateway, slotSharingManagersMap); this.slotSharingManagersMap = slotSharingManagersMap; }
Example #25
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testResourceProfileRespected() { SlotProfile slotProfile = new SlotProfile(biggerResourceProfile, Collections.emptyList(), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue(match.get().getSlotInfo().getResourceProfile().isMatching(slotProfile.getResourceProfile())); ResourceProfile evenBiggerResourceProfile = new ResourceProfile(biggerResourceProfile.getCpuCores() + 1, resourceProfile.getHeapMemoryInMB()); slotProfile = new SlotProfile(evenBiggerResourceProfile, Collections.emptyList(), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertFalse(match.isPresent()); }
Example #26
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchNoRequirements() { SlotProfile slotProfile = new SlotProfile(ResourceProfile.UNKNOWN, Collections.emptyList(), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue( candidates.stream() .map(SlotSelectionStrategy.SlotInfoAndResources::getSlotInfo) .collect(Collectors.toList()) .contains(match.get().getSlotInfo())); }
Example #27
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void matchPreferredLocationNotAvailable() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tmlX), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertTrue( candidates.stream() .map(SlotSelectionStrategy.SlotInfoAndResources::getSlotInfo) .collect(Collectors.toList()) .contains(match.get().getSlotInfo())); }
Example #28
Source File: SlotSelectionStrategyTestBase.java From flink with Apache License 2.0 | 4 votes |
public SlotSelectionStrategyTestBase(SlotSelectionStrategy slotSelectionStrategy) { this.selectionStrategy = slotSelectionStrategy; }
Example #29
Source File: SlotSelectionStrategyTestBase.java From flink with Apache License 2.0 | 4 votes |
protected Optional<SlotSelectionStrategy.SlotInfoAndLocality> runMatching(SlotProfile slotProfile) { return selectionStrategy.selectBestSlotForProfile(candidates, slotProfile); }
Example #30
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
protected LocationPreferenceSlotSelectionStrategyTest(SlotSelectionStrategy slotSelectionStrategy) { super(slotSelectionStrategy); }