Java Code Examples for org.apache.flink.runtime.jobmanager.scheduler.Locality#UNKNOWN

The following examples show how to use org.apache.flink.runtime.jobmanager.scheduler.Locality#UNKNOWN . 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: SharedSlot.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public Locality getLocality() {
	return Locality.UNKNOWN;
}
 
Example 2
Source File: TestingLogicalSlot.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public Locality getLocality() {
	return Locality.UNKNOWN;
}
 
Example 3
Source File: TestingLogicalSlot.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Locality getLocality() {
	return Locality.UNKNOWN;
}
 
Example 4
Source File: LocationPreferenceSlotSelectionStrategy.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
private Optional<SlotInfoAndLocality> selectWitLocationPreference(
	@Nonnull Collection<SlotInfoAndResources> availableSlots,
	@Nonnull Collection<TaskManagerLocation> locationPreferences,
	@Nonnull ResourceProfile resourceProfile) {

	// we build up two indexes, one for resource id and one for host names of the preferred locations.
	final Map<ResourceID, Integer> preferredResourceIDs = new HashMap<>(locationPreferences.size());
	final Map<String, Integer> preferredFQHostNames = new HashMap<>(locationPreferences.size());

	for (TaskManagerLocation locationPreference : locationPreferences) {
		preferredResourceIDs.merge(locationPreference.getResourceID(), 1, Integer::sum);
		preferredFQHostNames.merge(locationPreference.getFQDNHostname(), 1, Integer::sum);
	}

	SlotInfoAndResources bestCandidate = null;
	Locality bestCandidateLocality = Locality.UNKNOWN;
	double bestCandidateScore = Double.NEGATIVE_INFINITY;

	for (SlotInfoAndResources candidate : availableSlots) {

		if (candidate.getRemainingResources().isMatching(resourceProfile)) {

			// this gets candidate is local-weigh
			int localWeigh = preferredResourceIDs.getOrDefault(
				candidate.getSlotInfo().getTaskManagerLocation().getResourceID(), 0);

			// this gets candidate is host-local-weigh
			int hostLocalWeigh = preferredFQHostNames.getOrDefault(
				candidate.getSlotInfo().getTaskManagerLocation().getFQDNHostname(), 0);

			double candidateScore = calculateCandidateScore(localWeigh, hostLocalWeigh, candidate.getTaskExecutorUtilization());
			if (candidateScore > bestCandidateScore) {
				bestCandidateScore = candidateScore;
				bestCandidate = candidate;
				bestCandidateLocality = localWeigh > 0 ?
					Locality.LOCAL : hostLocalWeigh > 0 ?
					Locality.HOST_LOCAL : Locality.NON_LOCAL;
			}
		}
	}

	// at the end of the iteration, we return the candidate with best possible locality or null.
	return bestCandidate != null ?
		Optional.of(SlotInfoAndLocality.of(bestCandidate.getSlotInfo(), bestCandidateLocality)) :
		Optional.empty();
}
 
Example 5
Source File: TestingLogicalSlot.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Locality getLocality() {
	return Locality.UNKNOWN;
}