abdullah alamoudi has submitted this change and it was merged.

Change subject: [NO ISSUE][ING] Prevent duplicate active runtimes in NCs
......................................................................


[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 <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
---
M 
asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
2 files changed, 7 insertions(+), 5 deletions(-)

Approvals:
  Jenkins: Verified; No violations found; ; Verified
  Michael Blow: Looks good to me, approved



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 {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2392
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id7065625537f930394fa7387af2fd1e851582c86
Gerrit-PatchSet: 14
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamou...@gmail.com>
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Murtadha Hubail <mhub...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-Reviewer: abdullah alamoudi <bamou...@gmail.com>

Reply via email to