55import com .yahoo .component .Version ;
66import com .yahoo .config .application .api .DeployLogger ;
77import com .yahoo .config .model .ConfigModelContext ;
8+ import com .yahoo .config .provision .AzName ;
89import com .yahoo .config .provision .Capacity ;
910import com .yahoo .config .provision .CloudAccount ;
1011import com .yahoo .config .provision .CloudResourceTags ;
@@ -64,8 +65,10 @@ public class NodesSpecification {
6465 /** The cloud resource tags to apply to nodes in this spec */
6566 private final CloudResourceTags cloudResourceTags ;
6667
67- /* Whether the count attribute was present on the nodes element. */
68- private final boolean hasCountAttribute ;
68+ private final List <AzName > availabilityZones ;
69+
70+ /** Whether the count attribute is present on the 'nodes' element. */
71+ private final boolean specifiesNodeCount ;
6972
7073 private NodesSpecification (ClusterResources min ,
7174 ClusterResources max ,
@@ -75,7 +78,8 @@ private NodesSpecification(ClusterResources min,
7578 Optional <DockerImage > dockerImageRepo ,
7679 Optional <CloudAccount > cloudAccount ,
7780 CloudResourceTags cloudResourceTags ,
78- boolean hasCountAttribute ) {
81+ List <AzName > availabilityZones ,
82+ boolean specifiesNodeCount ) {
7983 if (max .smallerThan (min ))
8084 throw new IllegalArgumentException ("Max resources must be larger or equal to min resources, but " +
8185 max + " is smaller than " + min );
@@ -101,13 +105,15 @@ private NodesSpecification(ClusterResources min,
101105 this .dockerImageRepo = dockerImageRepo ;
102106 this .cloudAccount = cloudAccount ;
103107 this .cloudResourceTags = cloudResourceTags ;
104- this .hasCountAttribute = hasCountAttribute ;
108+ this .availabilityZones = List .copyOf (availabilityZones );
109+ this .specifiesNodeCount = specifiesNodeCount ;
105110 }
106111
107112 static NodesSpecification create (boolean dedicated , boolean canFail , Version version ,
108113 ModelElement nodesElement , Optional <DockerImage > dockerImageRepo ,
109114 Optional <CloudAccount > cloudAccount ,
110- CloudResourceTags cloudResourceTags ) {
115+ CloudResourceTags cloudResourceTags ,
116+ List <AzName > availabilityZones ) {
111117 var resolvedElement = resolveElement (nodesElement );
112118 var resourceConstraints = toResourceConstraints (resolvedElement );
113119 boolean hasCountAttribute = resolvedElement .stringAttribute ("count" ) != null ;
@@ -122,6 +128,7 @@ static NodesSpecification create(boolean dedicated, boolean canFail, Version ver
122128 dockerImageToUse (resolvedElement , dockerImageRepo ),
123129 cloudAccount ,
124130 cloudResourceTags ,
131+ availabilityZones ,
125132 hasCountAttribute );
126133 }
127134
@@ -140,7 +147,8 @@ private static ResourceConstraints toResourceConstraints(ModelElement nodesEleme
140147
141148 // Allow use of groups and group-size if count is not specified
142149 if (groupsAndGroupSizeButNoNodeCount (groups , groupSize , nodes ))
143- nodes = IntRange .of (groupSize .from ().orElse (1 ) * groups .from ().orElse (1 ), groupSize .to ().orElse (1 ) * groups .to ().orElse (1 ));
150+ nodes = IntRange .of (groupSize .from ().orElse (1 ) * groups .from ().orElse (1 ),
151+ groupSize .to ().orElse (1 ) * groups .to ().orElse (1 ));
144152
145153 var min = new ClusterResources (nodes .from ().orElse (1 ), groups .from ().orElse (defaultMinGroups ), nodeResources (nodesElement ).getFirst ());
146154 var max = new ClusterResources (nodes .to ().orElse (1 ), groups .to ().orElse (defaultMaxGroups ), nodeResources (nodesElement ).getSecond ());
@@ -170,7 +178,8 @@ public static NodesSpecification from(ModelElement nodesElement, ConfigModelCont
170178 nodesElement ,
171179 context .getDeployState ().getWantedDockerImageRepo (),
172180 context .getDeployState ().getProperties ().cloudAccount (),
173- context .getDeployState ().getProperties ().cloudResourceTags ());
181+ context .getDeployState ().getProperties ().cloudResourceTags (),
182+ context .availabilityZones ());
174183 }
175184
176185 /**
@@ -189,7 +198,8 @@ public static Optional<NodesSpecification> optionalDedicatedFromParent(ModelElem
189198 nodesElement ,
190199 context .getDeployState ().getWantedDockerImageRepo (),
191200 context .getDeployState ().getProperties ().cloudAccount (),
192- context .getDeployState ().getProperties ().cloudResourceTags ()));
201+ context .getDeployState ().getProperties ().cloudResourceTags (),
202+ context .availabilityZones ()));
193203 }
194204
195205 /**
@@ -207,6 +217,7 @@ public static NodesSpecification nonDedicated(int count, ConfigModelContext cont
207217 context .getDeployState ().getWantedDockerImageRepo (),
208218 context .getDeployState ().getProperties ().cloudAccount (),
209219 context .getDeployState ().getProperties ().cloudResourceTags (),
220+ context .availabilityZones (),
210221 false );
211222 }
212223
@@ -223,6 +234,7 @@ public static NodesSpecification dedicated(int count, ConfigModelContext context
223234 context .getDeployState ().getWantedDockerImageRepo (),
224235 context .getDeployState ().getProperties ().cloudAccount (),
225236 context .getDeployState ().getProperties ().cloudResourceTags (),
237+ context .availabilityZones (),
226238 false );
227239 }
228240
@@ -250,6 +262,7 @@ public static NodesSpecification requiredFromSharedParents(int count, NodeResour
250262 context .getDeployState ().getWantedDockerImageRepo (),
251263 context .getDeployState ().getProperties ().cloudAccount (),
252264 context .getDeployState ().getProperties ().cloudResourceTags (),
265+ context .availabilityZones (),
253266 false );
254267 }
255268
@@ -271,8 +284,8 @@ public static NodesSpecification requiredFromSharedParents(int count, NodeResour
271284 public boolean isExclusive () { return exclusive ; }
272285
273286 /** Returns whether the count attribute was present on the {@code <nodes>} element. */
274- public boolean hasCountAttribute () {
275- return hasCountAttribute ;
287+ public boolean specifiesNodeCount () {
288+ return specifiesNodeCount ;
276289 }
277290
278291 public Map <HostResource , ClusterMembership > provision (HostSystem hostSystem ,
@@ -299,6 +312,7 @@ public Map<HostResource, ClusterMembership> provision(HostSystem hostSystem,
299312 .loadBalancerSettings (zoneEndpoint )
300313 .stateful (stateful )
301314 .sidecars (sidecars )
315+ .availabilityZones (availabilityZones )
302316 .build ();
303317
304318 return hostSystem .allocateHosts (cluster , Capacity .from (min , max , groupSize , required , canFail , cloudAccount , cloudResourceTags , info ), logger );
0 commit comments