Murtadha Hubail has submitted this change and it was merged.

Change subject: [NO ISSUE][CLUS] Log NC Status on Startup Tasks Request
......................................................................


[NO ISSUE][CLUS] Log NC Status on Startup Tasks Request

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Log NC status on startup tasks request.
- Do not respond to startup tasks request if
  no tasks need to be performed.

Change-Id: I6e8f2c8a4144cb6f1768d1f78d819b0057f0056b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2473
Sonar-Qube: 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>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
---
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java
1 file changed, 43 insertions(+), 36 deletions(-)

Approvals:
  Anon. E. Moose #1000171: 
  Jenkins: Verified; No violations found; ; Verified
  Michael Blow: Looks good to me, approved



diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java
index 5c497aa..043e02e 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java
@@ -112,11 +112,13 @@
     private void process(RegistrationTasksRequestMessage msg) throws 
HyracksDataException {
         final String nodeId = msg.getNodeId();
         List<INCLifecycleTask> tasks = buildNCRegTasks(msg.getNodeId(), 
msg.getNodeStatus(), msg.getState());
-        RegistrationTasksResponseMessage response = new 
RegistrationTasksResponseMessage(nodeId, tasks);
-        try {
-            messageBroker.sendApplicationMessageToNC(response, 
msg.getNodeId());
-        } catch (Exception e) {
-            throw HyracksDataException.create(e);
+        if (!tasks.isEmpty()) {
+            RegistrationTasksResponseMessage response = new 
RegistrationTasksResponseMessage(nodeId, tasks);
+            try {
+                messageBroker.sendApplicationMessageToNC(response, 
msg.getNodeId());
+            } catch (Exception e) {
+                throw HyracksDataException.create(e);
+            }
         }
     }
 
@@ -136,39 +138,17 @@
     }
 
     protected List<INCLifecycleTask> buildNCRegTasks(String nodeId, NodeStatus 
nodeStatus, SystemState state) {
-        LOGGER.log(Level.INFO, () -> "Building registration tasks for node: " 
+ nodeId + " with state: " + state);
+        LOGGER.info("Building registration tasks for node {} with status {} 
and system state: {}", nodeId, nodeStatus,
+                state);
         final boolean isMetadataNode = nodeId.equals(metadataNodeId);
-        if (nodeStatus == NodeStatus.ACTIVE) {
-            /*
-             * if the node state is already ACTIVE then it completed
-             * booting and just re-registering with a new/failed CC.
-             */
-            return buildActiveNCRegTasks(isMetadataNode);
+        switch (nodeStatus) {
+            case ACTIVE:
+                return buildActiveNCRegTasks(isMetadataNode);
+            case IDLE:
+                return buildIdleNcRegTasks(nodeId, isMetadataNode, state);
+            default:
+                return new ArrayList<>();
         }
-        final List<INCLifecycleTask> tasks = new ArrayList<>();
-        tasks.add(new UpdateNodeStatusTask(NodeStatus.BOOTING));
-        if (state == SystemState.CORRUPTED) {
-            //need to perform local recovery for node partitions
-            LocalRecoveryTask rt = new 
LocalRecoveryTask(Arrays.asList(clusterManager.getNodePartitions(nodeId))
-                    
.stream().map(ClusterPartition::getPartitionId).collect(Collectors.toSet()));
-            tasks.add(rt);
-        }
-        if (replicationEnabled) {
-            tasks.add(new StartReplicationServiceTask());
-        }
-        if (isMetadataNode) {
-            tasks.add(new 
MetadataBootstrapTask(clusterManager.getMetadataPartition().getPartitionId()));
-        }
-        tasks.add(new ExternalLibrarySetupTask(isMetadataNode));
-        tasks.add(new CheckpointTask());
-        tasks.add(new StartLifecycleComponentsTask());
-        if (isMetadataNode) {
-            tasks.add(new ExportMetadataNodeTask(true));
-            tasks.add(new BindMetadataNodeTask());
-        }
-        tasks.add(new ReportLocalCountersTask());
-        tasks.add(new UpdateNodeStatusTask(NodeStatus.ACTIVE));
-        return tasks;
     }
 
     protected List<INCLifecycleTask> buildActiveNCRegTasks(boolean 
metadataNode) {
@@ -201,6 +181,33 @@
         }
     }
 
+    protected List<INCLifecycleTask> buildIdleNcRegTasks(String nodeId, 
boolean metadataNode, SystemState state) {
+        final List<INCLifecycleTask> tasks = new ArrayList<>();
+        tasks.add(new UpdateNodeStatusTask(NodeStatus.BOOTING));
+        if (state == SystemState.CORRUPTED) {
+            // need to perform local recovery for node partitions
+            LocalRecoveryTask rt = new 
LocalRecoveryTask(Arrays.stream(clusterManager.getNodePartitions(nodeId))
+                    
.map(ClusterPartition::getPartitionId).collect(Collectors.toSet()));
+            tasks.add(rt);
+        }
+        if (replicationEnabled) {
+            tasks.add(new StartReplicationServiceTask());
+        }
+        if (metadataNode) {
+            tasks.add(new 
MetadataBootstrapTask(clusterManager.getMetadataPartition().getPartitionId()));
+        }
+        tasks.add(new ExternalLibrarySetupTask(metadataNode));
+        tasks.add(new CheckpointTask());
+        tasks.add(new StartLifecycleComponentsTask());
+        if (metadataNode) {
+            tasks.add(new ExportMetadataNodeTask(true));
+            tasks.add(new BindMetadataNodeTask());
+        }
+        tasks.add(new ReportLocalCountersTask());
+        tasks.add(new UpdateNodeStatusTask(NodeStatus.ACTIVE));
+        return tasks;
+    }
+
     private void process(MetadataNodeResponseMessage response) throws 
HyracksDataException {
         // rebind metadata node since it might be changing
         MetadataManager.INSTANCE.rebindMetadataNode();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6e8f2c8a4144cb6f1768d1f78d819b0057f0056b
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <mhub...@apache.org>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Murtadha Hubail <mhub...@apache.org>

Reply via email to