[NO ISSUE][*DB] Unusable cluster state / unregistered node should return 503

Change-Id: I37ae8697681b9541bab673da6ceed395bc3b2702
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17971
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
index 9f83aa8..1966a88 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
@@ -438,6 +438,7 @@
                     LOGGER.warn(() -> "handleException: " + ex.getMessage() + ": "
                             + LogRedactionUtil.userData(param.toString()));
                     executionState.setStatus(ResultStatus.FATAL, HttpResponseStatus.SERVICE_UNAVAILABLE);
+                    return true;
                 default:
                     // fall-through
             }
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 3fd339e..626b938 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
@@ -691,7 +691,7 @@
 
     @Override
     public synchronized void replace(Dataset dataset) {
-        if (getDatasets().contains(dataset)) {
+        if (getDatasets().remove(dataset)) {
             getDatasets().remove(dataset);
             getDatasets().add(dataset);
         }