Repository: asterixdb
Updated Branches:
  refs/heads/master 02825e092 -> b227a0d37


[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>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/b227a0d3
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/b227a0d3
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/b227a0d3

Branch: refs/heads/master
Commit: b227a0d37893831f94a971cc116600860d8d23d7
Parents: 02825e0
Author: Abdullah Alamoudi <bamou...@gmail.com>
Authored: Mon Feb 19 15:55:56 2018 -0800
Committer: abdullah alamoudi <bamou...@gmail.com>
Committed: Mon Feb 19 22:06:21 2018 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/asterix/active/ActiveManager.java   | 4 +++-
 .../asterix/app/active/ActiveEntityEventsListener.java       | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b227a0d3/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
----------------------------------------------------------------------
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 @@ public class ActiveManager {
         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) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b227a0d3/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
----------------------------------------------------------------------
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 @@ public abstract class ActiveEntityEventsListener implements 
IActiveEntityControl
     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 @@ public abstract class ActiveEntityEventsListener implements 
IActiveEntityControl
             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 {

Reply via email to