From issues-return-6424-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Tue Apr 30 03:43:56 2019 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 [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id EE02418061A for ; Tue, 30 Apr 2019 05:43:55 +0200 (CEST) Received: (qmail 68730 invoked by uid 500); 30 Apr 2019 03:43:55 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 68720 invoked by uid 99); 30 Apr 2019 03:43:55 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2019 03:43:55 +0000 From: GitBox To: issues@phoenix.apache.org Subject: [GitHub] [phoenix-queryserver] swaroopak commented on a change in pull request #5: PHOENIX-5255: Create Orchestrator for QueryServerCanaryTool in phoenix-queryserver project Message-ID: <155659583016.19541.16565268525864365204.gitbox@gitbox.apache.org> Date: Tue, 30 Apr 2019 03:43:50 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit swaroopak commented on a change in pull request #5: PHOENIX-5255: Create Orchestrator for QueryServerCanaryTool in phoenix-queryserver project URL: https://github.com/apache/phoenix-queryserver/pull/5#discussion_r279606329 ########## File path: queryserver-orchestrator/src/main/java/org/apache/phoenix/queryserver/orchestrator/TestExecutorClient.java ########## @@ -0,0 +1,122 @@ +/** + * 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.phoenix.queryserver.orchestrator; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.leader.CancelLeadershipException; +import org.apache.curator.framework.recipes.leader.LeaderSelector; +import org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter; +import org.apache.curator.framework.state.ConnectionState; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class TestExecutorClient extends LeaderSelectorListenerAdapter implements Closeable { + + private static final Logger logger = LoggerFactory.getLogger(TestExecutorClient.class); + private final LeaderSelector leaderSelector; + + private Map params; + private ToolWrapper toolWrapper; + + public TestExecutorClient(CuratorFramework client, String path, Map params, ToolWrapper tool) { + + // create a leader selector using the given path for management + // all participants in a given leader selection must use the same path + // ExampleClient here is also a LeaderSelectorListener but this isn't required + this.leaderSelector = new LeaderSelector(client, path, this); + + // for most cases you will want your instance to requeue when it relinquishes leadership + this.leaderSelector.autoRequeue(); + + this.params = params; + this.toolWrapper = tool; + } + + public void start() { + // the selection for this instance doesn't start until the leader selector is started + // leader selection is done in the background so this call to leaderSelector.start() + // returns immediately + leaderSelector.start(); + } + + public void close() { + leaderSelector.close(); + } + + @Override + public void takeLeadership(CuratorFramework client) throws Exception { + // we are now the leader. This method should not return until we want to relinquish + // leadership + logger.info("Took leadership."); + + while (true) { + logger.info("Starting test case suite execution."); + + executeQueryServerCanaryTool(); + + logger.info("Test suite execution completed. Waiting for " + params.get("interval") + + " secs before executing next run."); + + TimeUnit.SECONDS.sleep(Integer.parseInt(params.get("interval"))); + } + } + + @Override + public void stateChanged(CuratorFramework client, ConnectionState newState) { + logger.info("ZK Connection State Changed to [{}]", newState.name()); + switch(newState) { + case CONNECTED: Review comment: No, it means it was able to connect under the zkpath. Updated the comment. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services