[NO ISSUE][ING] Prevent duplicate active runtimes in NCs
- user model changes: no
- storage format changes: no
- interface changes: no
details:
- Previously, when an active runtime is registered, we ignore
if the runtime id is already registered.
- After this change, such operation will throw an exception.
Change-Id: Id7065625537f930394fa7387af2fd1e851582c86
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2392
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
index f9aef4c..bb76204 100644
--- a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
+++ b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
@@ -73,7 +73,9 @@
if (shutdown) {
throw new RuntimeDataException(ErrorCode.ACTIVE_MANAGER_SHUTDOWN);
}
- runtimes.putIfAbsent(runtime.getRuntimeId(), runtime);
+ if (runtimes.putIfAbsent(runtime.getRuntimeId(), runtime) != null) {
+ throw new IllegalStateException("Active Runtime " + runtime.getRuntimeId() + " is already registered");
+ }
}
public void deregisterRuntime(ActiveRuntimeId id) {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
index 1758daa..2a214e3 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
@@ -182,8 +182,9 @@
protected void finish(ActiveEvent event) throws HyracksDataException {
LOGGER.log(level, "the job " + jobId + " finished");
if (numRegistered != numDeRegistered) {
- LOGGER.log(Level.WARN, "the job " + jobId + " finished with reported runtime registrations = "
- + numRegistered + " and deregistrations = " + numDeRegistered + " on node controllers");
+ LOGGER.log(Level.WARN,
+ "the job {} finished with reported runtime registrations = {} and deregistrations = {}", jobId,
+ numRegistered, numDeRegistered);
}
jobId = null;
Pair<JobStatus, List<Exception>> status = (Pair<JobStatus, List<Exception>>) event.getEventObject();
@@ -194,8 +195,7 @@
jobFailure = exceptions.isEmpty() ? new RuntimeDataException(ErrorCode.UNREPORTED_TASK_FAILURE_EXCEPTION)
: exceptions.get(0);
setState((state == ActivityState.STOPPING) ? ActivityState.STOPPED : ActivityState.TEMPORARILY_FAILED);
- if (prevState != ActivityState.SUSPENDING && prevState != ActivityState.RECOVERING
- && prevState != ActivityState.RESUMING && prevState != ActivityState.STOPPING) {
+ if (prevState == ActivityState.RUNNING) {
recover();
}
} else {