2525import java .util .List ;
2626import java .util .Map ;
2727import java .util .Map .Entry ;
28+ import java .util .Objects ;
2829import java .util .Optional ;
2930import java .util .Properties ;
3031import java .util .Set ;
@@ -158,7 +159,7 @@ public BlueGreenStatusProvider(
158159 }
159160
160161 protected void initMonitoring () {
161- monitors [ BlueGreenRole . SOURCE . getValue ()] =
162+ final BlueGreenStatusMonitor sourceMonitor =
162163 new BlueGreenStatusMonitor (
163164 BlueGreenRole .SOURCE ,
164165 this .bgdId ,
@@ -167,7 +168,10 @@ protected void initMonitoring() {
167168 this .getMonitoringProperties (),
168169 statusCheckIntervalMap ,
169170 this ::prepareStatus );
170- monitors [BlueGreenRole .TARGET .getValue ()] =
171+ monitors [BlueGreenRole .SOURCE .getValue ()] = sourceMonitor ;
172+ sourceMonitor .start ();
173+
174+ final BlueGreenStatusMonitor targetMonitor =
171175 new BlueGreenStatusMonitor (
172176 BlueGreenRole .TARGET ,
173177 this .bgdId ,
@@ -176,6 +180,8 @@ protected void initMonitoring() {
176180 this .getMonitoringProperties (),
177181 statusCheckIntervalMap ,
178182 this ::prepareStatus );
183+ monitors [BlueGreenRole .TARGET .getValue ()] = targetMonitor ;
184+ targetMonitor .start ();
179185 }
180186
181187 protected Properties getMonitoringProperties () {
@@ -448,15 +454,15 @@ protected void updateSummaryStatus(BlueGreenRole role, BlueGreenInterimStatus in
448454 protected void updateMonitors () {
449455 switch (this .summaryStatus .getCurrentPhase ()) {
450456 case NOT_CREATED :
451- Arrays .stream (this .monitors ).forEach (x -> {
457+ Arrays .stream (this .monitors ).filter ( Objects :: nonNull ). forEach (x -> {
452458 x .setIntervalRate (BlueGreenIntervalRate .BASELINE );
453459 x .setCollectIpAddresses (false );
454460 x .setCollectTopology (false );
455461 x .setUseIpAddress (false );
456462 });
457463 break ;
458464 case CREATED :
459- Arrays .stream (this .monitors ).forEach (x -> {
465+ Arrays .stream (this .monitors ).filter ( Objects :: nonNull ). forEach (x -> {
460466 x .setIntervalRate (BlueGreenIntervalRate .INCREASED );
461467 x .setCollectIpAddresses (true );
462468 x .setCollectTopology (true );
@@ -469,15 +475,15 @@ protected void updateMonitors() {
469475 case PREPARATION :
470476 case IN_PROGRESS :
471477 case POST :
472- Arrays .stream (this .monitors ).forEach (x -> {
478+ Arrays .stream (this .monitors ).filter ( Objects :: nonNull ). forEach (x -> {
473479 x .setIntervalRate (BlueGreenIntervalRate .HIGH );
474480 x .setCollectIpAddresses (false );
475481 x .setCollectTopology (false );
476482 x .setUseIpAddress (true );
477483 });
478484 break ;
479485 case COMPLETED :
480- Arrays .stream (this .monitors ).forEach (x -> {
486+ Arrays .stream (this .monitors ).filter ( Objects :: nonNull ). forEach (x -> {
481487 x .setIntervalRate (BlueGreenIntervalRate .BASELINE );
482488 x .setCollectIpAddresses (false );
483489 x .setCollectTopology (false );
0 commit comments