From notifications-return-86897-archive-asf-public=cust-asf.ponee.io@asterixdb.apache.org Wed Feb 21 11:25:26 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8A32A18061A for ; Wed, 21 Feb 2018 11:25:25 +0100 (CET) Received: (qmail 96223 invoked by uid 500); 21 Feb 2018 10:25:24 -0000 Mailing-List: contact notifications-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list notifications@asterixdb.apache.org Received: (qmail 96214 invoked by uid 99); 21 Feb 2018 10:25:24 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2018 10:25:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2CD9DC0690 for ; Wed, 21 Feb 2018 10:25:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.126 X-Spam-Level: ** X-Spam-Status: No, score=2.126 tagged_above=-999 required=6.31 tests=[MISSING_HEADERS=1.207, SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 4pejxgBsrEYT for ; Wed, 21 Feb 2018 10:25:22 +0000 (UTC) Received: from vitalstatistix.ics.uci.edu (vitalstatistix.ics.uci.edu [128.195.52.38]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id ED53F5F27B for ; Wed, 21 Feb 2018 10:25:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vitalstatistix.ics.uci.edu (Postfix) with ESMTP id 57985100BDB; Wed, 21 Feb 2018 02:25:21 -0800 (PST) Date: Wed, 21 Feb 2018 02:25:21 -0800 From: "Murtadha Hubail (Code Review)" CC: Jenkins , Michael Blow Reply-To: mhubail@apache.org X-Gerrit-MessageType: merged Subject: Change in asterixdb[master]: [NO ISSUE][CLUS] Unify Code Path of Requesting Startup Tasks X-Gerrit-Change-Id: Ieb89d6f293b0e958c3f141afc6f1db372cee7c91 X-Gerrit-ChangeURL: X-Gerrit-Commit: 278df951aef99abbb07ab053f1a3cc78ca582aed In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 Message-Id: <20180221102521.57985100BDB@vitalstatistix.ics.uci.edu> Murtadha Hubail has submitted this change and it was merged. Change subject: [NO ISSUE][CLUS] Unify Code Path of Requesting Startup Tasks ...................................................................... [NO ISSUE][CLUS] Unify Code Path of Requesting Startup Tasks - user model changes: no - storage format changes: no - interface changes: no Details: - Remove special case of requesting startup tasks on NC startup complete. - Handle case where CC might fail before sending startup tasks to NC. Change-Id: Ieb89d6f293b0e958c3f141afc6f1db372cee7c91 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2401 Sonar-Qube: Jenkins Integration-Tests: Jenkins Tested-by: Jenkins Contrib: Jenkins Reviewed-by: Michael Blow --- A asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/task/UpdateNodeStatusTask.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NcLifecycleCoordinator.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java M hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java 4 files changed, 82 insertions(+), 26 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/nc/task/UpdateNodeStatusTask.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/task/UpdateNodeStatusTask.java new file mode 100644 index 0000000..a1e11c2 --- /dev/null +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/task/UpdateNodeStatusTask.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.app.nc.task; + +import org.apache.asterix.common.api.INCLifecycleTask; +import org.apache.hyracks.api.client.NodeStatus; +import org.apache.hyracks.api.control.CcId; +import org.apache.hyracks.api.service.IControllerService; +import org.apache.hyracks.control.nc.NodeControllerService; + +public class UpdateNodeStatusTask implements INCLifecycleTask { + + private static final long serialVersionUID = 1L; + private final NodeStatus status; + + public UpdateNodeStatusTask(NodeStatus status) { + this.status = status; + } + + @Override + public void perform(CcId ccId, IControllerService cs) { + NodeControllerService ncs = (NodeControllerService) cs; + ncs.setNodeStatus(status); + } + + @Override + public String toString() { + return "{ \"class\" : \"" + getClass().getSimpleName() + "\" }"; + } +} 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 25e768d..844851a 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 @@ -34,6 +34,7 @@ import org.apache.asterix.app.nc.task.ReportLocalCountersTask; import org.apache.asterix.app.nc.task.StartLifecycleComponentsTask; import org.apache.asterix.app.nc.task.StartReplicationServiceTask; +import org.apache.asterix.app.nc.task.UpdateNodeStatusTask; import org.apache.asterix.app.replication.message.MetadataNodeRequestMessage; import org.apache.asterix.app.replication.message.MetadataNodeResponseMessage; import org.apache.asterix.app.replication.message.NCLifecycleTaskReportMessage; @@ -145,6 +146,7 @@ return buildActiveNCRegTasks(isMetadataNode); } final List tasks = new ArrayList<>(); + tasks.add(new UpdateNodeStatusTask(NodeStatus.ACTIVE)); if (state == SystemState.CORRUPTED) { //need to perform local recovery for node partitions LocalRecoveryTask rt = new LocalRecoveryTask(Arrays.asList(clusterManager.getNodePartitions(nodeId)) diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java index b0382f7..3a8a92f 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java @@ -73,7 +73,6 @@ private INcApplicationContext runtimeContext; private String nodeId; private boolean stopInitiated; - private boolean startupCompleted; protected WebManager webManager; @Override @@ -190,33 +189,16 @@ // configure servlets after joining the cluster, so we can create HyracksClientConnection configureServers(); webManager.start(); - - // Since we don't pass initial run flag in AsterixHyracksIntegrationUtil, we use the virtualNC flag - final NodeProperties nodeProperties = runtimeContext.getNodeProperties(); - IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager(); - SystemState state = recoveryMgr.getSystemState(); - if (state == SystemState.PERMANENT_DATA_LOSS - && (nodeProperties.isInitialRun() || nodeProperties.isVirtualNc())) { - state = SystemState.BOOTSTRAPPING; - } - // Request registration tasks from CC (we only do this from our primary CC, in the case of multiple CCs) - final NodeControllerService ncControllerService = (NodeControllerService) ncServiceCtx.getControllerService(); - RegistrationTasksRequestMessage.send(ncControllerService.getPrimaryCcId(), ncControllerService, - NodeStatus.BOOTING, state); - startupCompleted = true; } @Override - public void onRegisterNode(CcId ccId) throws Exception { - if (startupCompleted) { - /* - * If the node completed its startup before, then this is a re-registration with - * the primary (or supplemental) CC and therefore the system state should be HEALTHY and the node status - * is ACTIVE - */ - RegistrationTasksRequestMessage.send(ccId, (NodeControllerService) ncServiceCtx.getControllerService(), - NodeStatus.ACTIVE, SystemState.HEALTHY); - } + public synchronized void onRegisterNode(CcId ccId) throws Exception { + final NodeControllerService ncs = (NodeControllerService) ncServiceCtx.getControllerService(); + final NodeStatus currentStatus = ncs.getNodeStatus(); + final SystemState systemState = isPendingStartupTasks(currentStatus, ncs.getPrimaryCcId(), ccId) + ? getCurrentSystemState() : SystemState.HEALTHY; + RegistrationTasksRequestMessage.send(ccId, (NodeControllerService) ncServiceCtx.getControllerService(), + currentStatus, systemState); } @Override @@ -259,4 +241,20 @@ return devices.get(ioDeviceIndex); }; } + + private boolean isPendingStartupTasks(NodeStatus nodeStatus, CcId primaryCc, CcId registeredCc) { + return nodeStatus == NodeStatus.BOOTING && (primaryCc == null || primaryCc.equals(registeredCc)); + } + + private SystemState getCurrentSystemState() { + final NodeProperties nodeProperties = runtimeContext.getNodeProperties(); + IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager(); + SystemState state = recoveryMgr.getSystemState(); + // Since we don't pass initial run flag in AsterixHyracksIntegrationUtil, we use the virtualNC flag + if (state == SystemState.PERMANENT_DATA_LOSS + && (nodeProperties.isInitialRun() || nodeProperties.isVirtualNc())) { + state = SystemState.BOOTSTRAPPING; + } + return state; + } } diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java index 0f40b60..0ccef1d 100644 --- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java +++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java @@ -48,6 +48,7 @@ import org.apache.commons.lang3.mutable.MutableObject; import org.apache.hyracks.api.application.INCApplication; import org.apache.hyracks.api.client.NodeControllerInfo; +import org.apache.hyracks.api.client.NodeStatus; import org.apache.hyracks.api.comm.NetworkAddress; import org.apache.hyracks.api.control.CcId; import org.apache.hyracks.api.dataset.IDatasetPartitionManager; @@ -62,6 +63,7 @@ import org.apache.hyracks.api.lifecycle.ILifeCycleComponentManager; import org.apache.hyracks.api.lifecycle.LifeCycleComponentManager; import org.apache.hyracks.api.service.IControllerService; +import org.apache.hyracks.api.util.InvokeUtil; import org.apache.hyracks.control.common.base.IClusterController; import org.apache.hyracks.control.common.config.ConfigManager; import org.apache.hyracks.control.common.context.ServerContext; @@ -95,7 +97,6 @@ import org.apache.hyracks.net.protocols.muxdemux.FullFrameChannelInterfaceFactory; import org.apache.hyracks.net.protocols.muxdemux.MuxDemuxPerformanceCounters; import org.apache.hyracks.util.ExitUtil; -import org.apache.hyracks.api.util.InvokeUtil; import org.apache.hyracks.util.PidHelper; import org.apache.hyracks.util.trace.ITracer; import org.apache.hyracks.util.trace.Tracer; @@ -183,6 +184,7 @@ private final ConfigManager configManager; private final Map maxJobIds = new ConcurrentHashMap<>(); + private NodeStatus status = NodeStatus.BOOTING; static { ExitUtil.init(); @@ -627,6 +629,14 @@ return workQueue; } + public synchronized NodeStatus getNodeStatus() { + return status; + } + + public synchronized void setNodeStatus(NodeStatus status) { + this.status = status; + } + private class HeartbeatTask implements Runnable { private final Semaphore delayBlock = new Semaphore(0); private final IClusterController cc; -- To view, visit https://asterix-gerrit.ics.uci.edu/2401 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieb89d6f293b0e958c3f141afc6f1db372cee7c91 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Michael Blow Gerrit-Reviewer: Murtadha Hubail