@@ -176,84 +176,87 @@ public String getDetail() {
176
176
177
177
@ Override
178
178
public NextAction apply (Packet packet ) {
179
- if (it .hasNext ()) {
180
- DomainPresenceInfo info = packet .getSPI (DomainPresenceInfo .class );
181
- WlsDomainConfig config = (WlsDomainConfig ) packet .get (ProcessingConstants .DOMAIN_TOPOLOGY );
182
-
183
- // Refresh as this is constantly changing
184
- Domain dom = info .getDomain ();
185
- // These are presently Ready servers
186
- List <String > availableServers = getReadyServers (info );
187
-
188
- List <String > servers = new ArrayList <>();
189
- List <String > readyServers = new ArrayList <>();
190
- List <V1Pod > notReadyServers = new ArrayList <>();
191
-
192
- Collection <StepAndPacket > serversThatCanRestartNow = new ArrayList <>();
193
-
194
- int countReady = 0 ;
195
- WlsClusterConfig cluster = config != null ? config .getClusterConfig (clusterName ) : null ;
196
- if (cluster != null ) {
197
- List <WlsServerConfig > serversConfigs = cluster .getServerConfigs ();
198
- if (serversConfigs != null ) {
199
- for (WlsServerConfig s : serversConfigs ) {
200
- // figure out how many servers are currently ready
201
- String name = s .getName ();
202
- if (availableServers .contains (name )) {
203
- readyServers .add (s .getName ());
204
- countReady ++;
205
- } else {
206
- V1Pod pod = info .getServerPod (name );
207
- if (pod != null ) {
208
- notReadyServers .add (pod );
179
+ synchronized (it ) {
180
+ if (it .hasNext ()) {
181
+ DomainPresenceInfo info = packet .getSPI (DomainPresenceInfo .class );
182
+ WlsDomainConfig config =
183
+ (WlsDomainConfig ) packet .get (ProcessingConstants .DOMAIN_TOPOLOGY );
184
+
185
+ // Refresh as this is constantly changing
186
+ Domain dom = info .getDomain ();
187
+ // These are presently Ready servers
188
+ List <String > availableServers = getReadyServers (info );
189
+
190
+ List <String > servers = new ArrayList <>();
191
+ List <String > readyServers = new ArrayList <>();
192
+ List <V1Pod > notReadyServers = new ArrayList <>();
193
+
194
+ Collection <StepAndPacket > serversThatCanRestartNow = new ArrayList <>();
195
+
196
+ int countReady = 0 ;
197
+ WlsClusterConfig cluster = config != null ? config .getClusterConfig (clusterName ) : null ;
198
+ if (cluster != null ) {
199
+ List <WlsServerConfig > serversConfigs = cluster .getServerConfigs ();
200
+ if (serversConfigs != null ) {
201
+ for (WlsServerConfig s : serversConfigs ) {
202
+ // figure out how many servers are currently ready
203
+ String name = s .getName ();
204
+ if (availableServers .contains (name )) {
205
+ readyServers .add (s .getName ());
206
+ countReady ++;
207
+ } else {
208
+ V1Pod pod = info .getServerPod (name );
209
+ if (pod != null ) {
210
+ notReadyServers .add (pod );
211
+ }
209
212
}
210
213
}
211
214
}
212
215
}
213
- }
214
216
215
- // then add as many as possible next() entries leaving at least minimum cluster
216
- // availability
217
- while (countReady -- > dom .getMinAvailable (clusterName )) {
218
- StepAndPacket current = it .next ();
219
- WlsServerConfig serverConfig =
220
- (WlsServerConfig ) current .packet .get (ProcessingConstants .SERVER_SCAN );
221
- String serverName = null ;
222
- if (serverConfig != null ) {
223
- serverName = serverConfig .getName ();
224
- } else if (config != null ) {
225
- serverName = config .getAdminServerName ();
226
- }
227
- if (serverName != null ) {
228
- servers .add (serverName );
229
- }
230
- serversThatCanRestartNow .add (current );
231
- if (!it .hasNext ()) {
232
- break ;
217
+ // then add as many as possible next() entries leaving at least minimum cluster
218
+ // availability
219
+ while (countReady -- > dom .getMinAvailable (clusterName )) {
220
+ StepAndPacket current = it .next ();
221
+ WlsServerConfig serverConfig =
222
+ (WlsServerConfig ) current .packet .get (ProcessingConstants .SERVER_SCAN );
223
+ String serverName = null ;
224
+ if (serverConfig != null ) {
225
+ serverName = serverConfig .getName ();
226
+ } else if (config != null ) {
227
+ serverName = config .getAdminServerName ();
228
+ }
229
+ if (serverName != null ) {
230
+ servers .add (serverName );
231
+ }
232
+ serversThatCanRestartNow .add (current );
233
+ if (!it .hasNext ()) {
234
+ break ;
235
+ }
233
236
}
234
- }
235
237
236
- if (serversThatCanRestartNow .isEmpty ()) {
237
- // Not enough servers are ready to let us restart a server now
238
- if (!notReadyServers .isEmpty ()) {
239
- PodAwaiterStepFactory pw = PodHelper .getPodAwaiterStepFactory (packet );
240
- Collection <StepAndPacket > waitForUnreadyServers = new ArrayList <>();
241
- for (V1Pod pod : notReadyServers ) {
242
- waitForUnreadyServers .add (
243
- new StepAndPacket (pw .waitForReady (pod , null ), packet .clone ()));
244
- }
238
+ if (serversThatCanRestartNow .isEmpty ()) {
239
+ // Not enough servers are ready to let us restart a server now
240
+ if (!notReadyServers .isEmpty ()) {
241
+ PodAwaiterStepFactory pw = PodHelper .getPodAwaiterStepFactory (packet );
242
+ Collection <StepAndPacket > waitForUnreadyServers = new ArrayList <>();
243
+ for (V1Pod pod : notReadyServers ) {
244
+ waitForUnreadyServers .add (
245
+ new StepAndPacket (pw .waitForReady (pod , null ), packet .clone ()));
246
+ }
245
247
246
- // Wait for at least one of the not-yet-ready servers to become ready
247
- return doForkAtLeastOne (this , packet , waitForUnreadyServers );
248
- } else {
249
- throw new IllegalStateException ();
248
+ // Wait for at least one of the not-yet-ready servers to become ready
249
+ return doForkAtLeastOne (this , packet , waitForUnreadyServers );
250
+ } else {
251
+ throw new IllegalStateException ();
252
+ }
250
253
}
251
- }
252
254
253
- readyServers .removeAll (servers );
254
- LOGGER .info (MessageKeys .ROLLING_SERVERS , dom .getDomainUID (), servers , readyServers );
255
+ readyServers .removeAll (servers );
256
+ LOGGER .info (MessageKeys .ROLLING_SERVERS , dom .getDomainUID (), servers , readyServers );
255
257
256
- return doNext (new ServersThatCanRestartNowStep (serversThatCanRestartNow , this ), packet );
258
+ return doNext (new ServersThatCanRestartNowStep (serversThatCanRestartNow , this ), packet );
259
+ }
257
260
}
258
261
259
262
return doNext (packet );
0 commit comments