Java Code Examples for org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy#SlotInfoAndLocality
The following examples show how to use
org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy#SlotInfoAndLocality .
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 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 2
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 3
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 4
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 5
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 6
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 7
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 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 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 10
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 11
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 12
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 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: 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 15
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 16
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void matchPreferredLocation() { SlotProfile slotProfile = SlotProfile.preferredLocality(resourceProfile, Collections.singletonList(tml2)); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(slotInfo2, match.get().getSlotInfo()); slotProfile = SlotProfile.preferredLocality(resourceProfile, Arrays.asList(tmlX, tml4)); match = runMatching(slotProfile); Assert.assertEquals(slotInfo4, match.get().getSlotInfo()); slotProfile = SlotProfile.preferredLocality(resourceProfile, Arrays.asList(tml3, tml1, tml3, tmlX)); match = runMatching(slotProfile); Assert.assertEquals(slotInfo3, match.get().getSlotInfo()); }
Example 17
Source File: LocationPreferenceSlotSelectionStrategyTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void matchPreferredLocation() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(ssc2, match.get().getSlotInfo()); slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml4), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertEquals(ssc4, match.get().getSlotInfo()); slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tml3, tml1, tml3, tmlX), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertEquals(ssc3, match.get().getSlotInfo()); }
Example 18
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 19
Source File: LocationPreferenceSlotSelectionStrategyTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void matchPreferredLocation() { SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.emptySet()); Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile); Assert.assertEquals(ssc2, match.get().getSlotInfo()); slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml4), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertEquals(ssc4, match.get().getSlotInfo()); slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tml3, tml1, tml3, tmlX), Collections.emptySet()); match = runMatching(slotProfile); Assert.assertEquals(ssc3, match.get().getSlotInfo()); }
Example 20
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); }