You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2018/05/09 20:39:16 UTC
[1/2] kudu git commit: Add a table renaming tool
Repository: kudu
Updated Branches:
refs/heads/master 60c8e305b -> 26af97c8f
Add a table renaming tool
This commit introduces a tool to rename a table. When HMS integration
feature is enabled, users can use this tool to rename legacy tables
that have hive incompatible names. In order to allow these tables to be
upgraded.
Change-Id: I49a8c352ded124eef99f341ab552961fc3dc1260
Reviewed-on: http://gerrit.cloudera.org:8080/10337
Reviewed-by: Dan Burkert <da...@apache.org>
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/38b0c8f2
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/38b0c8f2
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/38b0c8f2
Branch: refs/heads/master
Commit: 38b0c8f27022801957ac30018aefabe447bb3410
Parents: 60c8e30
Author: hahao <ha...@cloudera.com>
Authored: Mon May 7 16:56:47 2018 -0700
Committer: Hao Hao <ha...@cloudera.com>
Committed: Wed May 9 18:19:42 2018 +0000
----------------------------------------------------------------------
src/kudu/tools/kudu-tool-test.cc | 27 ++++++++++++++++++++++++
src/kudu/tools/tool_action_table.cc | 36 +++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/38b0c8f2/src/kudu/tools/kudu-tool-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/kudu-tool-test.cc b/src/kudu/tools/kudu-tool-test.cc
index fcd4e0f..cc4d08c 100644
--- a/src/kudu/tools/kudu-tool-test.cc
+++ b/src/kudu/tools/kudu-tool-test.cc
@@ -128,8 +128,11 @@ namespace tools {
using cfile::CFileWriter;
using cfile::StringDataGenerator;
using cfile::WriterOptions;
+using client::KuduClient;
+using client::KuduClientBuilder;
using client::KuduSchema;
using client::KuduSchemaBuilder;
+using client::KuduTable;
using client::sp::shared_ptr;
using cluster::ExternalMiniCluster;
using cluster::ExternalMiniClusterOptions;
@@ -1831,6 +1834,30 @@ TEST_F(ToolTest, TestMasterList) {
ASSERT_STR_CONTAINS(out, master->bound_rpc_hostport().ToString());
}
+TEST_F(ToolTest, TestRenameTable) {
+ NO_FATALS(StartExternalMiniCluster());
+ const string& kTableName = "kudu.table";
+ const string& kNewTableName = "kudu_table";
+
+ // Create the table.
+ TestWorkload workload(cluster_.get());
+ workload.set_table_name(kTableName);
+ workload.set_num_replicas(1);
+ workload.Setup();
+
+ string master_addr = cluster_->master()->bound_rpc_addr().ToString();
+ string out;
+ NO_FATALS(RunActionStdoutNone(Substitute("table rename $0 $1 $2",
+ master_addr, kTableName,
+ kNewTableName)));
+ shared_ptr<KuduClient> client;
+ ASSERT_OK(KuduClientBuilder()
+ .add_master_server_addr(master_addr)
+ .Build(&client));
+ shared_ptr<KuduTable> table;
+ ASSERT_OK(client->OpenTable(kNewTableName, &table));
+}
+
// This test is parameterized on the serialization mode and Kerberos.
class ControlShellToolTest :
public ToolTest,
http://git-wip-us.apache.org/repos/asf/kudu/blob/38b0c8f2/src/kudu/tools/tool_action_table.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/tool_action_table.cc b/src/kudu/tools/tool_action_table.cc
index d878f36..b9f5308 100644
--- a/src/kudu/tools/tool_action_table.cc
+++ b/src/kudu/tools/tool_action_table.cc
@@ -47,6 +47,7 @@ using client::KuduClientBuilder;
using client::KuduScanToken;
using client::KuduScanTokenBuilder;
using client::KuduTable;
+using client::KuduTableAlterer;
using client::internal::ReplicaController;
using std::cout;
using std::endl;
@@ -101,20 +102,36 @@ class TableLister {
namespace {
const char* const kTableNameArg = "table_name";
+const char* const kNewTableNameArg = "new_table_name";
-Status DeleteTable(const RunnerContext& context) {
+Status CreateKuduClient(const RunnerContext& context,
+ client::sp::shared_ptr<KuduClient>* client) {
const string& master_addresses_str = FindOrDie(context.required_args,
kMasterAddressesArg);
vector<string> master_addresses = Split(master_addresses_str, ",");
- const string& table_name = FindOrDie(context.required_args, kTableNameArg);
+ return KuduClientBuilder()
+ .master_server_addrs(master_addresses)
+ .Build(client);
+}
+Status DeleteTable(const RunnerContext& context) {
+ const string& table_name = FindOrDie(context.required_args, kTableNameArg);
client::sp::shared_ptr<KuduClient> client;
- RETURN_NOT_OK(KuduClientBuilder()
- .master_server_addrs(master_addresses)
- .Build(&client));
+ RETURN_NOT_OK(CreateKuduClient(context, &client));
return client->DeleteTable(table_name);
}
+Status RenameTable(const RunnerContext& context) {
+ const string& table_name = FindOrDie(context.required_args, kTableNameArg);
+ const string& new_table_name = FindOrDie(context.required_args, kNewTableNameArg);
+
+ client::sp::shared_ptr<KuduClient> client;
+ RETURN_NOT_OK(CreateKuduClient(context, &client));
+ unique_ptr<KuduTableAlterer> alterer(client->NewTableAlterer(table_name));
+ return alterer->RenameTo(new_table_name)
+ ->Alter();
+}
+
Status ListTables(const RunnerContext& context) {
const string& master_addresses_str = FindOrDie(context.required_args,
kMasterAddressesArg);
@@ -131,6 +148,14 @@ unique_ptr<Mode> BuildTableMode() {
.AddRequiredParameter({ kTableNameArg, "Name of the table to delete" })
.Build();
+ unique_ptr<Action> rename_table =
+ ActionBuilder("rename", &RenameTable)
+ .Description("Rename a table")
+ .AddRequiredParameter({ kMasterAddressesArg, kMasterAddressesArgDesc })
+ .AddRequiredParameter({ kTableNameArg, "Name of the table to rename" })
+ .AddRequiredParameter({ kNewTableNameArg, "New table name" })
+ .Build();
+
unique_ptr<Action> list_tables =
ActionBuilder("list", &ListTables)
.Description("List all tables")
@@ -141,6 +166,7 @@ unique_ptr<Mode> BuildTableMode() {
return ModeBuilder("table")
.Description("Operate on Kudu tables")
.AddAction(std::move(delete_table))
+ .AddAction(std::move(rename_table))
.AddAction(std::move(list_tables))
.Build();
}
[2/2] kudu git commit: [thirdparty] Fix thirdparty build on Python 2.6
Posted by mp...@apache.org.
[thirdparty] Fix thirdparty build on Python 2.6
60c8e305b introduced a change that uses a subprocess method available
only on Python 2.7+ in preflight's check_openssl() method. This commit
changes the check_openssl() internals to only use API available in
Python 2.6.
Change-Id: Ibc71d15c3e1a4ab70a78b31fe6b5de7a2cf5dbde
Reviewed-on: http://gerrit.cloudera.org:8080/10359
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Mike Percy <mp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/26af97c8
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/26af97c8
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/26af97c8
Branch: refs/heads/master
Commit: 26af97c8f28d3953e7506cf96ef3991d7eee6734
Parents: 38b0c8f
Author: Attila Bukor <ab...@cloudera.com>
Authored: Wed May 9 21:46:53 2018 +0200
Committer: Mike Percy <mp...@apache.org>
Committed: Wed May 9 20:38:49 2018 +0000
----------------------------------------------------------------------
thirdparty/preflight.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/26af97c8/thirdparty/preflight.py
----------------------------------------------------------------------
diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py
index cf813de..29b5775 100755
--- a/thirdparty/preflight.py
+++ b/thirdparty/preflight.py
@@ -133,14 +133,14 @@ def check_sasl():
def check_openssl():
cflags = ["-E"]
- try:
- openssl_include = subprocess.check_output(["pkg-config", "--cflags", "openssl"]).rstrip()
- if openssl_include != "":
- cflags.append(openssl_include)
- except subprocess.CalledProcessError:
- homebrew_openssl_dir="/usr/local/opt/openssl/include"
- if os.path.isdir(homebrew_openssl_dir):
- cflags.append("-I" + homebrew_openssl_dir)
+ proc = subprocess.Popen(["pkg-config", "--cflags", "openssl"], stdout=subprocess.PIPE)
+ openssl_include = proc.communicate()[0].decode("utf-8").rstrip()
+ if openssl_include != "":
+ cflags.append(openssl_include)
+ else:
+ homebrew_openssl_dir="/usr/local/opt/openssl/include"
+ if os.path.isdir(homebrew_openssl_dir):
+ cflags.append("-I" + homebrew_openssl_dir)
try_do(
"Checking for openssl headers",
("Unable to compile a simple program that uses openssl. " +