You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2017/07/11 07:15:23 UTC
incubator-hawq git commit: HAWQ-1373 - Added feature to reload GUC
values using hawq reload-config
Repository: incubator-hawq
Updated Branches:
refs/heads/master 7e4edd4d2 -> 64bd28213
HAWQ-1373 - Added feature to reload GUC values using hawq reload-config <object> deprecating hawq stop <object> -u
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/64bd2821
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/64bd2821
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/64bd2821
Branch: refs/heads/master
Commit: 64bd28213f5051987e0c9addfea286b10b0348c2
Parents: 7e4edd4
Author: Shubham Sharma <sh...@gmail.com>
Authored: Tue Jun 13 08:02:33 2017 -0700
Committer: rlei <rl...@pivotal.io>
Committed: Tue Jul 11 15:14:04 2017 +0800
----------------------------------------------------------------------
.../feature/ManagementTool/test_hawq_reload.cpp | 52 ++++++++++++++++++++
.../feature/ManagementTool/test_hawq_reload.h | 45 +++++++++++++++++
tools/bin/hawq | 18 ++++++-
tools/bin/hawqpylib/HAWQ_HELP.py | 22 ++++++++-
4 files changed, 135 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64bd2821/src/test/feature/ManagementTool/test_hawq_reload.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_reload.cpp b/src/test/feature/ManagementTool/test_hawq_reload.cpp
new file mode 100644
index 0000000..f554e36
--- /dev/null
+++ b/src/test/feature/ManagementTool/test_hawq_reload.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#include <string>
+#include <stdio.h>
+#include "lib/command.h"
+#include "lib/sql_util.h"
+#include "lib/string_util.h"
+#include "lib/hawq_config.h"
+#include "test_hawq_reload.h"
+
+#include "gtest/gtest.h"
+
+using std::string;
+using hawq::test::SQLUtility;
+using hawq::test::Command;
+
+/*
+Test case for hawq reload <object>. This test changes the value of GUC
+log_min_messages to debug. Reloads the cluster and verifies if the change
+was reloaded successfully. After the test it resets the value of GUC to
+default.
+*/
+TEST_F(TestHawqReload,TestReloadLogMinMessages) {
+
+ hawq::test::HawqConfig hawq_config;
+ string defaultGUCValue = hawq_config.getGucValue("log_min_messages");
+ hawq_config.setGucValue("log_min_messages","debug");
+ string cmd = "hawq reload cluster -au";
+ Command reload(cmd);
+ string result = reload.run().getResultOutput();
+ EXPECT_EQ("debug", hawq_config.getGucValue("log_min_messages"));
+ // Reset to default
+ hawq_config.setGucValue("log_min_messages",defaultGUCValue);
+ Command setoriginal(cmd);
+ string org_result = setoriginal.run().getResultOutput();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64bd2821/src/test/feature/ManagementTool/test_hawq_reload.h
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_reload.h b/src/test/feature/ManagementTool/test_hawq_reload.h
new file mode 100644
index 0000000..64e8370
--- /dev/null
+++ b/src/test/feature/ManagementTool/test_hawq_reload.h
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#ifndef TEST_HAWQ_RELOAD_H
+#define TEST_HAWQ_RELOAD_H
+
+#include <string>
+#include <pwd.h>
+#include <fstream>
+#include "lib/hdfs_config.h"
+#include "gtest/gtest.h"
+
+class TestHawqReload: public ::testing::Test {
+ public:
+ TestHawqReload() {
+ std::string user = HAWQ_USER;
+ if(user.empty()) {
+ struct passwd *pw;
+ uid_t uid = geteuid();
+ pw = getpwuid(uid);
+ user.assign(pw->pw_name);
+ }
+ conn.reset(new hawq::test::PSQL(HAWQ_DB, HAWQ_HOST, HAWQ_PORT, user, HAWQ_PASSWORD));
+ }
+ ~TestHawqReload() {}
+
+ private:
+ std::unique_ptr<hawq::test::PSQL> conn;
+};
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64bd2821/tools/bin/hawq
----------------------------------------------------------------------
diff --git a/tools/bin/hawq b/tools/bin/hawq
index 5d7571a..b456df2 100755
--- a/tools/bin/hawq
+++ b/tools/bin/hawq
@@ -23,11 +23,12 @@ try:
import subprocess
from hawqpylib.HAWQ_HELP import *
from hawqpylib.hawqlib import *
+ from gppylib.gplog import get_default_logger
except ImportError, e:
sys.exit('ERROR: Cannot import modules. Please check that you '
'have sourced greenplum_path.sh. Detail: ' + str(e))
-global hawq_home, source_hawq_env
+global hawq_home, source_hawq_env, logger
def print_version():
@@ -53,6 +54,7 @@ def check_master_or_standby_host(master_host_name='localhost', standby_host_name
return True
def main():
+ logger = get_default_logger()
hawq_home = os.getenv('GPHOME')
if not hawq_home:
print "HAWQ home directory not defined, please check GPHOME settings."
@@ -120,6 +122,20 @@ def main():
if second_arg not in cluster_type_list:
print STOP_HELP
sys.exit(1)
+ # Prints deprecation warning when using old syntax "hawq stop <object> -u" to reload GUC
+ if len(sub_args.split("-")) > 1:
+ if "-u" in sub_args or "--reload" in sub_args or "u" in sub_args.split("-")[1]:
+ logger.info("hawq stop <object> -u is being deprecated and replaced by 'hawq reload <object>'")
+ logger.info("Current syntax will work, please use 'hawq reload <object>' going forward.")
+ cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
+ result = local_run(cmd)
+ elif hawq_command == "reload":
+ if second_arg not in cluster_type_list:
+ print RELOAD_CONFIG_HELP
+ sys.exit(1)
+ hawq_command="stop"
+ sub_args_list.append("-u")
+ sub_args=" ".join(sub_args_list)
cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
result = local_run(cmd)
elif hawq_command == "init":
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64bd2821/tools/bin/hawqpylib/HAWQ_HELP.py
----------------------------------------------------------------------
diff --git a/tools/bin/hawqpylib/HAWQ_HELP.py b/tools/bin/hawqpylib/HAWQ_HELP.py
index f506f38..b544629 100755
--- a/tools/bin/hawqpylib/HAWQ_HELP.py
+++ b/tools/bin/hawqpylib/HAWQ_HELP.py
@@ -38,6 +38,7 @@ The most commonly used hawq "commands" are:
check Verifies and validates HAWQ settings.
checkperf Verifies the baseline hardware performance of hosts.
register Register parquet files generated by other system into the corrsponding table in HAWQ
+ reload Reload GUC values without restarting hawq cluster.
See 'hawq <command> help' for more information on a specific command.
"""
@@ -82,7 +83,6 @@ The "options" are:
-t --timeout Sets timeout value in seconds, default is 600 seconds.
-M --mode Stop with mode [smart|fast|immediate]
-u --reload Reload GUC values without restarting hawq cluster.
-
See 'hawq --help' for more information on other commands.
"""
@@ -180,3 +180,23 @@ The "options" are:
See 'hawq --help' for more information on other commands.
"""
+RELOAD_CONFIG_HELP = """
+usage: hawq reload <object> [--options]
+
+The "objects" are:
+ cluster Reload GUC values for hawq cluster.
+ master Reload GUC values for hawq master.
+ segment Reload GUC values for local segment node.
+ standby Reload GUC values for hawq standby.
+ allsegments Reload GUC values for all segments.
+
+The "options" are:
+ -a --prompt Do not ask before execution.
+ -l --logdir Sets log dir of management tools.
+ -q --quiet Run in quiet mode.
+ -v --verbose Displays detailed status, progress and error messages output by the utility.
+ -t --timeout Sets timeout value in seconds, default is 600 seconds.
+ -M --mode Stop with mode [smart|fast|immediate]
+
+See 'hawq --help' for more information on other commands.
+"""