blob: 6aafb20bee2148eedc192a7fa7a9e35ff7934f20 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package com.yahoo.config.provision;
/**
* A class which can be asked if allocations should be exclusive.
*
* @author bratseth
*/
public class Exclusivity {
private final Zone zone;
private final SharedHosts sharedHost;
public Exclusivity(Zone zone, SharedHosts sharedHost) {
this.zone = zone;
this.sharedHost = sharedHost;
}
/** Returns whether nodes must be allocated to hosts that are exclusive to the cluster type. */
public boolean clusterType(ClusterSpec cluster) {
return sharedHost.hasClusterType(cluster.type());
}
/** Returns whether the nodes of this cluster must be running on hosts that are specifically provisioned for the application. */
public boolean provisioning(ClusterSpec clusterSpec) {
return !zone.cloud().allowHostSharing() && clusterSpec.isExclusive();
}
/**
* Returns whether nodes are allocated exclusively in this instance given this cluster spec.
* Exclusive allocation requires that the wanted node resources matches the advertised resources of the node
* perfectly.
*/
public boolean allocation(ClusterSpec clusterSpec) {
return clusterSpec.isExclusive() ||
( clusterSpec.type().isContainer() && zone.system().isPublic() && !zone.environment().isTest() ) ||
( !zone.cloud().allowHostSharing() && !sharedHost.supportsClusterType(clusterSpec.type()));
}
}
|