Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public BlueGreenStatusMonitor(
this.onBlueGreenStatusChangeFunc = onBlueGreenStatusChangeFunc;

this.blueGreenDialect = (BlueGreenDialect) this.pluginService.getDialect();
}

public void start() {
executorService.submit(this::runMonitoringLoop);
executorService.shutdown(); // executor accepts no more tasks
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -158,7 +159,7 @@ public BlueGreenStatusProvider(
}

protected void initMonitoring() {
monitors[BlueGreenRole.SOURCE.getValue()] =
final BlueGreenStatusMonitor sourceMonitor =
new BlueGreenStatusMonitor(
BlueGreenRole.SOURCE,
this.bgdId,
Expand All @@ -167,7 +168,10 @@ protected void initMonitoring() {
this.getMonitoringProperties(),
statusCheckIntervalMap,
this::prepareStatus);
monitors[BlueGreenRole.TARGET.getValue()] =
monitors[BlueGreenRole.SOURCE.getValue()] = sourceMonitor;
sourceMonitor.start();

final BlueGreenStatusMonitor targetMonitor =
new BlueGreenStatusMonitor(
BlueGreenRole.TARGET,
this.bgdId,
Expand All @@ -176,6 +180,8 @@ protected void initMonitoring() {
this.getMonitoringProperties(),
statusCheckIntervalMap,
this::prepareStatus);
monitors[BlueGreenRole.TARGET.getValue()] = targetMonitor;
targetMonitor.start();
}

protected Properties getMonitoringProperties() {
Expand Down Expand Up @@ -448,15 +454,15 @@ protected void updateSummaryStatus(BlueGreenRole role, BlueGreenInterimStatus in
protected void updateMonitors() {
switch (this.summaryStatus.getCurrentPhase()) {
case NOT_CREATED:
Arrays.stream(this.monitors).forEach(x -> {
Arrays.stream(this.monitors).filter(Objects::nonNull).forEach(x -> {
x.setIntervalRate(BlueGreenIntervalRate.BASELINE);
x.setCollectIpAddresses(false);
x.setCollectTopology(false);
x.setUseIpAddress(false);
});
break;
case CREATED:
Arrays.stream(this.monitors).forEach(x -> {
Arrays.stream(this.monitors).filter(Objects::nonNull).forEach(x -> {
x.setIntervalRate(BlueGreenIntervalRate.INCREASED);
x.setCollectIpAddresses(true);
x.setCollectTopology(true);
Expand All @@ -469,15 +475,15 @@ protected void updateMonitors() {
case PREPARATION:
case IN_PROGRESS:
case POST:
Arrays.stream(this.monitors).forEach(x -> {
Arrays.stream(this.monitors).filter(Objects::nonNull).forEach(x -> {
x.setIntervalRate(BlueGreenIntervalRate.HIGH);
x.setCollectIpAddresses(false);
x.setCollectTopology(false);
x.setUseIpAddress(true);
});
break;
case COMPLETED:
Arrays.stream(this.monitors).forEach(x -> {
Arrays.stream(this.monitors).filter(Objects::nonNull).forEach(x -> {
x.setIntervalRate(BlueGreenIntervalRate.BASELINE);
x.setCollectIpAddresses(false);
x.setCollectTopology(false);
Expand Down
Loading