Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3B0BB200C5B for ; Thu, 13 Apr 2017 03:40:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 398C7160BA8; Thu, 13 Apr 2017 01:40:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 58FB5160B95 for ; Thu, 13 Apr 2017 03:39:59 +0200 (CEST) Received: (qmail 13799 invoked by uid 500); 13 Apr 2017 01:39:58 -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 13790 invoked by uid 99); 13 Apr 2017 01:39:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2017 01:39:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 322CFC144D for ; Thu, 13 Apr 2017 01:39:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.92 X-Spam-Level: X-Spam-Status: No, score=0.92 tagged_above=-999 required=6.31 tests=[SPF_FAIL=0.919, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 6Q1MHE5_UBlr for ; Thu, 13 Apr 2017 01:39:56 +0000 (UTC) Received: from unhygienix.ics.uci.edu (unhygienix.ics.uci.edu [128.195.14.130]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 59BBC5FC8E for ; Thu, 13 Apr 2017 01:39:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by unhygienix.ics.uci.edu (Postfix) with ESMTP id 131582407A5; Wed, 12 Apr 2017 18:39:56 -0700 (PDT) Date: Wed, 12 Apr 2017 18:39:56 -0700 From: "Michael Blow (Code Review)" Message-ID: Reply-To: mblow@apache.org X-Gerrit-MessageType: newchange Subject: Change in asterixdb[master]: Wait For ClusterState ACTIVE Before Notifying ZK X-Gerrit-Change-Id: Ieaaeb2876edad9cfa3f23c2cbe00e058bdc1c8cc X-Gerrit-ChangeURL: X-Gerrit-Commit: 86d0ed3f6a1482ca8e9dca18dd2b5b46f44e0121 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 To: undisclosed-recipients:; archived-at: Thu, 13 Apr 2017 01:40:00 -0000 Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1678 Change subject: Wait For ClusterState ACTIVE Before Notifying ZK ...................................................................... Wait For ClusterState ACTIVE Before Notifying ZK Defer notifying ZooKeeper that the cluster is up until it transitions to ACTIVE Change-Id: Ieaaeb2876edad9cfa3f23c2cbe00e058bdc1c8cc --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java 3 files changed, 22 insertions(+), 8 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/78/1678/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java index cb2bf64..578c206 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.List; +import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -52,6 +53,7 @@ import org.apache.asterix.app.external.ExternalLibraryUtils; import org.apache.asterix.app.replication.FaultToleranceStrategyFactory; import org.apache.asterix.common.api.AsterixThreadFactory; +import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; import org.apache.asterix.common.config.AsterixExtension; import org.apache.asterix.common.config.ClusterProperties; import org.apache.asterix.common.config.ExternalProperties; @@ -71,6 +73,7 @@ import org.apache.asterix.metadata.cluster.ClusterManagerProvider; import org.apache.asterix.runtime.job.resource.JobCapacityController; import org.apache.asterix.runtime.utils.AppContextInfo; +import org.apache.asterix.runtime.utils.ClusterStateManager; import org.apache.asterix.translator.IStatementExecutorFactory; import org.apache.hyracks.api.application.ICCServiceContext; import org.apache.hyracks.api.application.IServiceContext; @@ -194,7 +197,7 @@ jsonAPIServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc); jsonAPIServer.setAttribute(ASTERIX_APP_CONTEXT_INFO_ATTR, AppContextInfo.INSTANCE); jsonAPIServer.setAttribute(ServletConstants.EXECUTOR_SERVICE_ATTR, - ((ClusterControllerService) ccServiceCtx.getControllerService()).getExecutor()); + ccServiceCtx.getControllerService().getExecutor()); // AQL rest APIs. addServlet(jsonAPIServer, Servlets.AQL_QUERY); @@ -291,13 +294,16 @@ } private IStatementExecutorFactory getStatementExecutorFactory() { - return ccExtensionManager.getStatementExecutorFactory( - ((ClusterControllerService) ccServiceCtx.getControllerService()).getExecutor()); + return ccExtensionManager.getStatementExecutorFactory(ccServiceCtx.getControllerService().getExecutor()); } @Override public void startupCompleted() throws Exception { - ClusterManagerProvider.getClusterManager().notifyStartupCompleted(); + ccServiceCtx.getControllerService().getExecutor().submit((Callable)() -> { + ClusterStateManager.INSTANCE.waitForState(ClusterState.ACTIVE); + ClusterManagerProvider.getClusterManager().notifyStartupCompleted(); + return null; + }); } @Override diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java index bf03d54..0a0393d 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java @@ -83,4 +83,6 @@ * @return A copy of the current state of the cluster partitions. */ ClusterPartition[] getClusterPartitons(); + + void waitForState(ClusterState state) throws HyracksDataException, InterruptedException; } diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java index f65979f..7f4deeb 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java @@ -29,6 +29,9 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; import org.apache.asterix.common.cluster.ClusterPartition; import org.apache.asterix.common.cluster.IClusterStateManager; @@ -40,10 +43,6 @@ import org.apache.hyracks.api.config.IOption; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.api.exceptions.HyracksException; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; import org.apache.hyracks.control.common.controllers.NCConfig; /** @@ -170,6 +169,13 @@ } } + @Override + public synchronized void waitForState(ClusterState waitForState) throws HyracksDataException, InterruptedException { + while (state != waitForState) { + wait(); + } + } + /** * Returns the IO devices configured for a Node Controller * -- To view, visit https://asterix-gerrit.ics.uci.edu/1678 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieaaeb2876edad9cfa3f23c2cbe00e058bdc1c8cc Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow