35 lines
1.6 KiB
Java
35 lines
1.6 KiB
Java
package dev.ltms.bridged.placement;
|
|
|
|
/**
|
|
* A profile (and, in CB-308, a host) that can be chosen by a {@link PlacementPolicy}.
|
|
*
|
|
* <p>Keeping this as a small descriptor rather than a bare profile name lets CB-308 widen
|
|
* selection to {@code (host, profile)} pairs without changing the policy interface.
|
|
*/
|
|
public record PlacementCandidate(String profile, String host, float weight, Integer maxLoad) {
|
|
|
|
/** A candidate with no explicit host (the single-host default) and the given weight/cap. */
|
|
public static PlacementCandidate profile(String profile, float weight, Integer maxLoad) {
|
|
return new PlacementCandidate(profile, null, weight, maxLoad);
|
|
}
|
|
|
|
/** A candidate with no explicit host, unit weight, and no cap. */
|
|
public static PlacementCandidate profile(String profile) {
|
|
return new PlacementCandidate(profile, null, 1.0f, null);
|
|
}
|
|
|
|
/**
|
|
* True when this candidate carries an explicit {@code weight <= 0} (CB-554) and must be
|
|
* skipped by every automatic policy — the same way a quarantined or unreachable candidate is
|
|
* skipped. {@code BridgedConfig.Profile}'s compact constructor already normalises "absent" to
|
|
* {@code 1.0} and "negative" to {@code 0.0}, so this is a plain threshold check here; it does
|
|
* not need to distinguish "explicit 0" from "absent" itself.
|
|
*
|
|
* <p>Exclusion is about <em>automatic</em> selection only — an explicit
|
|
* {@code bridge_spawn{profile:"..."}} bypasses placement entirely and is unaffected.
|
|
*/
|
|
public boolean excluded() {
|
|
return weight <= 0.0f;
|
|
}
|
|
}
|