abdullah alamoudi has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2392

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
---
M 
asterixdb/asterix-active/src/main/java/org/apache/asterix/active/ActiveManager.java
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
M asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
3 files changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/92/2392/1

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..cc13272 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,10 @@
         if (shutdown) {
             throw new RuntimeDataException(ErrorCode.ACTIVE_MANAGER_SHUTDOWN);
         }
-        runtimes.putIfAbsent(runtime.getRuntimeId(), runtime);
+        if (runtimes.containsKey(runtime.getRuntimeId())) {
+            throw new 
RuntimeDataException(ErrorCode.ACTIVE_RUNTIME_ALREADY_REGISTERED, 
runtime.getRuntimeId());
+        }
+        runtimes.put(runtime.getRuntimeId(), runtime);
     }
 
     public void deregisterRuntime(ActiveRuntimeId id) {
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 1fc0f54..5b19e62 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -249,6 +249,7 @@
     public static final int FEED_FAILED_WHILE_GETTING_A_NEW_RECORD = 3110;
     public static final int FEED_START_FEED_WITHOUT_CONNECTION = 3111;
     public static final int PARSER_COLLECTION_ITEM_CANNOT_BE_NULL = 3112;
+    public static final int ACTIVE_RUNTIME_ALREADY_REGISTERED = 3113;
 
     // Lifecycle management errors
     public static final int DUPLICATE_PARTITION_ID = 4000;
diff --git 
a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties 
b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 8341a33..df2c847 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -238,6 +238,7 @@
 3110 = Feed failed while reading a new record
 3111 = Feed %1$s is not connected to any dataset
 3112 = Array/Multiset item cannot be null
+3113 = Active Runtime %1$s is already registered
 
 # Lifecycle management errors
 4000 = Partition id %1$d for node %2$s already in use by node %3$s

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7065625537f930394fa7387af2fd1e851582c86
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamou...@gmail.com>

Reply via email to