@@ -171,14 +171,11 @@ public int getMaxDynamicClusterSize() {
171
171
* It is the responsibility of the caller to persist the changes to ClusterStartup to kubernetes.
172
172
*
173
173
* @param clusterStartup The ClusterStartup to be validated against the WLS configuration
174
- * @param machineNamePrefix Optional, if this is not null, also validate whether the WebLogic domain already contains
175
- * all the machines that will be used by the dynamic cluster
176
174
* @param suggestedConfigUpdates A List containing suggested WebLogic configuration update to be filled in by this
177
175
* method. Optional.
178
176
* @return true if the DomainSpec has been updated, false otherwise
179
177
*/
180
178
public boolean validateClusterStartup (ClusterStartup clusterStartup ,
181
- String machineNamePrefix ,
182
179
List <ConfigUpdate > suggestedConfigUpdates ) {
183
180
LOGGER .entering ();
184
181
@@ -190,7 +187,7 @@ public boolean validateClusterStartup(ClusterStartup clusterStartup,
190
187
}
191
188
192
189
// Warns if replicas is larger than the number of servers configured in the cluster
193
- validateReplicas (clusterStartup .getReplicas (), machineNamePrefix , "clusterStartup" , suggestedConfigUpdates );
190
+ validateReplicas (clusterStartup .getReplicas (),"clusterStartup" , suggestedConfigUpdates );
194
191
195
192
LOGGER .exiting (modified );
196
193
@@ -204,34 +201,33 @@ public boolean validateClusterStartup(ClusterStartup clusterStartup,
204
201
*
205
202
* @param replicas The configured replicas value for this cluster in the kubernetes weblogic domain spec
206
203
* for this cluster
207
- * @param machineNamePrefix Optional, if this is not null, also validate whether the WebLogic domain already contains
208
- * all the machines that will be used by the dynamic cluster
209
204
* @param source The name of the section in the domain spec where the replicas is specified,
210
205
* for logging purposes
211
206
* @param suggestedConfigUpdates A List containing suggested WebLogic configuration update to be filled in by this
212
207
* method. Optional.
213
208
*/
214
- public void validateReplicas (Integer replicas , String machineNamePrefix ,
209
+ public void validateReplicas (Integer replicas ,
215
210
String source , List <ConfigUpdate > suggestedConfigUpdates ) {
216
211
if (replicas == null ) {
217
212
return ;
218
213
}
219
- // log warning if replicas is too large and cluster only contains statically configured servers
220
- if (!hasDynamicServers () && replicas > getClusterSize ()) {
221
- LOGGER .warning (MessageKeys .REPLICA_MORE_THAN_WLS_SERVERS , source , clusterName , replicas , getClusterSize ());
214
+ // log warning if replicas is too large and cluster
215
+ int maxClusterSize = getClusterSize ();
216
+ if (hasDynamicServers ()) {
217
+ maxClusterSize += getMaxDynamicClusterSize ();
218
+ }
219
+ if (replicas > maxClusterSize ) {
220
+ LOGGER .warning (MessageKeys .REPLICA_MORE_THAN_WLS_SERVERS , source , clusterName , replicas , maxClusterSize );
222
221
}
223
222
// recommend updating WLS dynamic cluster size and machines if requested to recommend
224
223
// updates, ie, suggestedConfigUpdates is not null, and if replicas value is larger than
225
- // the current dynamic cluster size, or if some of the machines to be used for the dynamic
226
- // servers are not yet configured.
224
+ // the current dynamic cluster size.
227
225
//
228
226
// Note: Never reduce the value of dynamicClusterSize even during scale down
229
- if (suggestedConfigUpdates != null ) {
230
- if (hasDynamicServers ()) {
231
- // if (replicas > getDynamicClusterSize() || !verifyMachinesConfigured(machineNamePrefix, replicas)) {
232
- if (replicas > getDynamicClusterSize () ) {
233
- suggestedConfigUpdates .add (new DynamicClusterSizeConfigUpdate (this , Math .max (replicas , getDynamicClusterSize ())));
234
- }
227
+ if (suggestedConfigUpdates != null && hasDynamicServers ()) {
228
+ if (replicas > getDynamicClusterSize () && getDynamicClusterSize () < getMaxDynamicClusterSize ()) {
229
+ // increase dynamic cluster size to satisfy replicas, but only up to the configured max dynamic cluster size
230
+ suggestedConfigUpdates .add (new DynamicClusterSizeConfigUpdate (this , Math .min (replicas , getMaxDynamicClusterSize ())));
235
231
}
236
232
}
237
233
}
@@ -329,17 +325,14 @@ public String getUpdateDynamicClusterSizeUrl() {
329
325
330
326
/**
331
327
* Return the payload used in the REST request for updating the dynamic cluster size. It will
332
- * be used to update the cluster size and if necessary, the max cluster size of the dynamic servers
333
- * of this cluster.
328
+ * be used to update the cluster size of the dynamic servers of this cluster.
334
329
*
335
330
* @param clusterSize Desired dynamic cluster size
336
331
* @return A string containing the payload to be used in the REST request for updating the dynamic
337
332
* cluster size to the specified value.
338
333
*/
339
334
public String getUpdateDynamicClusterSizePayload (final int clusterSize ) {
340
- return "{ dynamicClusterSize: " + clusterSize + ", " +
341
- " maxDynamicClusterSize: " + (clusterSize > getMaxDynamicClusterSize ()? clusterSize : getMaxDynamicClusterSize ()) +
342
- " }" ;
335
+ return "{ dynamicClusterSize: " + clusterSize + " }" ;
343
336
}
344
337
345
338
@ Override
0 commit comments