You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/01/24 00:00:20 UTC

[3/3] kudu git commit: tool: remove dead code

tool: remove dead code

Change-Id: I93b173c4f2f91d1d7466f99ddc3264a8796e5b51
Reviewed-on: http://gerrit.cloudera.org:8080/5770
Tested-by: Kudu Jenkins
Reviewed-by: Dinesh Bhat <di...@cloudera.com>
Reviewed-by: Alexey Serbin <as...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/bbf75306
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/bbf75306
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/bbf75306

Branch: refs/heads/master
Commit: bbf75306127e99b070b214dcc1c9896b8de3989f
Parents: 41c4552
Author: Adar Dembo <ad...@cloudera.com>
Authored: Mon Jan 23 12:57:52 2017 -0800
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Mon Jan 23 23:59:55 2017 +0000

----------------------------------------------------------------------
 src/kudu/tools/fs_dump-tool.cc | 213 ------------------------------------
 src/kudu/tools/fs_list-tool.cc | 153 --------------------------
 2 files changed, 366 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/bbf75306/src/kudu/tools/fs_dump-tool.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/fs_dump-tool.cc b/src/kudu/tools/fs_dump-tool.cc
deleted file mode 100644
index 92bdb8a..0000000
--- a/src/kudu/tools/fs_dump-tool.cc
+++ /dev/null
@@ -1,213 +0,0 @@
-// 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.
-//
-// Tool to dump tablets, rowsets, and blocks
-
-#include "kudu/tools/fs_tool.h"
-
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <vector>
-
-#include <gflags/gflags.h>
-#include <glog/logging.h>
-
-#include "kudu/gutil/strings/numbers.h"
-#include "kudu/gutil/strings/substitute.h"
-#include "kudu/util/flags.h"
-#include "kudu/util/logging.h"
-
-DEFINE_int32(nrows, 0, "Number of rows to dump");
-DEFINE_bool(metadata_only, false, "Whether just to dump the block metadata, "
-                                  "when printing blocks.");
-
-/*
-  TODO: support specifying start and end keys
-
-  DEFINE_string(start_key, "", "Start key for rows to dump");
-  DEFINE_string(end_key, "", "Start key for rows to dump");
-*/
-
-DEFINE_bool(headers_only, false, "Don't dump contents, dump headers only");
-
-namespace kudu {
-namespace tools {
-
-using std::string;
-using std::vector;
-using strings::Substitute;
-
-namespace {
-
-enum CommandType {
-  DUMP_TABLET_BLOCKS,
-  DUMP_TABLET_DATA,
-  DUMP_ROWSET,
-  DUMP_CFILE_BLOCK,
-  PRINT_TABLET_META,
-  PRINT_UUID,
-};
-
-struct CommandHandler {
-  CommandType type_;
-  string name_;
-  string desc_;
-
-  CommandHandler(CommandType type, string name, string desc)
-      : type_(type), name_(std::move(name)), desc_(std::move(desc)) {}
-};
-
-const vector<CommandHandler> kCommandHandlers = {
-    CommandHandler(DUMP_TABLET_DATA, "dump_tablet_data",
-                   "Dump a tablet's data (requires a tablet id)"),
-    CommandHandler(DUMP_TABLET_BLOCKS, "dump_tablet_blocks",
-                   "Dump a tablet's constituent blocks (requires a tablet id)"),
-    CommandHandler(DUMP_ROWSET, "dump_rowset",
-                   "Dump a rowset (requires a tablet id and an index)"),
-    CommandHandler(DUMP_CFILE_BLOCK, "dump_block",
-                   "Dump a cfile block (requires a block id)"),
-    CommandHandler(PRINT_TABLET_META, "print_meta",
-                   "Print a tablet metadata (requires a tablet id)"),
-    CommandHandler(PRINT_UUID, "print_uuid",
-                   "Print the UUID (master or TS) to whom the data belongs") };
-
-void PrintUsageToStream(const std::string& prog_name, std::ostream* out) {
-  *out << "Usage: " << prog_name
-       << " [-headers_only] [-nrows <num rows>] "
-       << "-fs_wal_dir <dir> -fs_data_dirs <dirs> <command> <options> "
-       << std::endl << std::endl;
-  *out << "Commands: " << std::endl;
-  for (const CommandHandler& handler : kCommandHandlers) {
-    *out << handler.name_ << ": " << handler.desc_ << std::endl;
-  }
-}
-void Usage(const string& prog_name, const string& msg) {
-  std::cerr << "Error " << prog_name << ": " << msg << std::endl;
-  PrintUsageToStream(prog_name, &std::cerr);
-}
-
-bool ValidateCommand(int argc, char** argv, CommandType* out) {
-  if (argc < 2) {
-    Usage(argv[0], "At least one command must be specified!");
-    return false;
-  }
-  for (const CommandHandler& handler : kCommandHandlers) {
-    if (argv[1] == handler.name_) {
-      *out = handler.type_;
-      return true;
-    }
-  }
-  Usage("Invalid command specified: ", argv[1]);
-  return false;
-}
-
-} // anonymous namespace
-
-static int FsDumpToolMain(int argc, char** argv) {
-  FLAGS_logtostderr = 1;
-  std::ostringstream usage_str;
-  PrintUsageToStream(argv[0], &usage_str);
-  google::SetUsageMessage(usage_str.str());
-  ParseCommandLineFlags(&argc, &argv, true);
-  InitGoogleLoggingSafe(argv[0]);
-
-  CommandType cmd;
-  if (!ValidateCommand(argc, argv, &cmd)) {
-    return 2;
-  }
-
-  FsTool fs_tool(FLAGS_headers_only ? FsTool::HEADERS_ONLY : FsTool::MAXIMUM);
-  CHECK_OK(fs_tool.Init());
-
-  DumpOptions opts;
-  // opts.start_key = FLAGS_start_key;
-  // opts.end_key = FLAGS_end_key;
-  opts.nrows = FLAGS_nrows;
-  opts.metadata_only = FLAGS_metadata_only;
-
-  switch (cmd) {
-    case DUMP_TABLET_DATA:
-    case DUMP_TABLET_BLOCKS:
-    {
-      if (argc < 3) {
-        Usage(argv[0],
-              Substitute("dump_tablet requires tablet id: $0 "
-                         "dump_tablet <tablet_id>",
-                         argv[0]));
-        return 2;
-      }
-      if (cmd == DUMP_TABLET_DATA) {
-        CHECK_OK(fs_tool.DumpTabletData(argv[2]));
-      } else if (cmd == DUMP_TABLET_BLOCKS) {
-        CHECK_OK(fs_tool.DumpTabletBlocks(argv[2], opts, 0));
-      }
-      break;
-    }
-
-    case DUMP_ROWSET: {
-      if (argc < 4) {
-        Usage(argv[0],
-              Substitute("dump_rowset requires tablet id and rowset index: $0"
-                         "dump_rowset <tablet_id> <rowset_index>",
-                         argv[0]));
-        return 2;
-      }
-      uint32_t rowset_idx;
-      CHECK(safe_strtou32(argv[3], &rowset_idx))
-          << "Invalid index specified: " << argv[2];
-      CHECK_OK(fs_tool.DumpRowSet(argv[2], rowset_idx, opts, 0));
-      break;
-    }
-    case DUMP_CFILE_BLOCK: {
-      if (argc < 3) {
-        Usage(argv[0],
-              Substitute("dump_block requires a block id: $0"
-                         "dump_block <block_id>", argv[0]));
-        return 2;
-      }
-      CHECK_OK(fs_tool.DumpCFileBlock(argv[2], opts, 0));
-      break;
-    }
-    case PRINT_TABLET_META: {
-      if (argc < 3) {
-        Usage(argv[0], Substitute("print_meta requires a tablet id: $0"
-                                  "print_meta <tablet_id>", argv[0]));
-        return 2;
-      }
-      CHECK_OK(fs_tool.PrintTabletMeta(argv[2], 0));
-      break;
-    }
-    case PRINT_UUID: {
-      if (argc < 2) {
-        Usage(argv[0], Substitute("$0 print_uuid", argv[0]));
-        return 2;
-      }
-      CHECK_OK(fs_tool.PrintUUID(0));
-      break;
-    }
-  }
-
-  return 0;
-}
-
-} // namespace tools
-} // namespace kudu
-
-int main(int argc, char** argv) {
-  return kudu::tools::FsDumpToolMain(argc, argv);
-}

http://git-wip-us.apache.org/repos/asf/kudu/blob/bbf75306/src/kudu/tools/fs_list-tool.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/fs_list-tool.cc b/src/kudu/tools/fs_list-tool.cc
deleted file mode 100644
index 5f3836f..0000000
--- a/src/kudu/tools/fs_list-tool.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-// 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.
-//
-// Tool to list local files and directories
-
-#include "kudu/tools/fs_tool.h"
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-
-#include <gflags/gflags.h>
-#include <glog/logging.h>
-
-#include "kudu/util/flags.h"
-#include "kudu/util/logging.h"
-
-DEFINE_bool(verbose, false,
-            "Print additional information (e.g., log segment headers)");
-
-namespace kudu {
-namespace tools {
-
-using std::string;
-using std::vector;
-
-namespace {
-
-enum CommandType {
-  FS_TREE = 1,
-  LIST_LOGS = 2,
-  LIST_TABLETS = 3,
-  LIST_BLOCKS = 4
-};
-
-// TODO: extract and generalized the "verb" handling code with other
-// tools such that it can be shared with other tools.
-
-struct CommandHandler {
-  CommandType type_;
-  string name_;
-  string desc_;
-
-  CommandHandler(CommandType type, string name, string desc)
-      : type_(type), name_(std::move(name)), desc_(std::move(desc)) {}
-};
-
-const vector<CommandHandler> kCommandHandlers = {
-    CommandHandler(FS_TREE, "tree", "Print out a file system tree." ),
-    CommandHandler(LIST_LOGS, "list_logs",
-                   "List file system logs (optionally accepts a tablet id)."),
-    CommandHandler(LIST_TABLETS, "list_tablets", "List tablets." ),
-    CommandHandler(LIST_BLOCKS, "list_blocks",
-                   "List block for tablet (optionally accepts a tablet id).") };
-
-void PrintUsageToStream(const string& prog_name, std::ostream* out) {
-  *out << "Usage: " << prog_name << " [-verbose] "
-       << "-fs_wal_dir <dir> -fs_data_dirs <dirs> <command> [option] "
-       << std::endl << std::endl
-       << "Commands: " << std::endl;
-  for (const CommandHandler& handler : kCommandHandlers) {
-    *out << handler.name_ << ": " << handler.desc_ << std::endl;
-  }
-}
-
-void Usage(const string& prog_name, const string& msg) {
-  std::cerr << "Error " << prog_name << ": " << msg << std::endl
-            << std::endl;
-  PrintUsageToStream(prog_name, &std::cerr);
-}
-
-bool ValidateCommand(int argc, char** argv, CommandType* out) {
-  if (argc < 2) {
-    Usage(argv[0], "At least one command must be specified!");
-    return false;
-  }
-  for (const CommandHandler& handler : kCommandHandlers) {
-    if (argv[1] == handler.name_) {
-      *out = handler.type_;
-      return true;
-    }
-  }
-  Usage("Invalid command specified ", argv[1]);
-  return false;
-}
-
-} // anonymous namespace
-
-static int FsListToolMain(int argc, char** argv) {
-  FLAGS_logtostderr = 1;
-  std::ostringstream usage_str;
-  PrintUsageToStream(argv[0], &usage_str);
-  google::SetUsageMessage(usage_str.str());
-  ParseCommandLineFlags(&argc, &argv, true);
-  InitGoogleLoggingSafe(argv[0]);
-
-  CommandType cmd;
-  if (!ValidateCommand(argc, argv, &cmd)) {
-    return 2;
-  }
-
-  FsTool fs_tool(FLAGS_verbose ? FsTool::HEADERS_ONLY : FsTool::MINIMUM);
-  CHECK_OK_PREPEND(fs_tool.Init(), "Error initializing file system tool");
-
-  switch (cmd) {
-    case FS_TREE: {
-      CHECK_OK(fs_tool.FsTree());
-      break;
-    }
-    case LIST_LOGS: {
-      if (argc > 2) {
-        CHECK_OK(fs_tool.ListLogSegmentsForTablet(argv[2]));
-      } else {
-        CHECK_OK(fs_tool.ListAllLogSegments());
-      }
-      break;
-    }
-    case LIST_TABLETS: {
-      CHECK_OK(fs_tool.ListAllTablets());
-      break;
-    }
-    case LIST_BLOCKS: {
-      if (argc > 2) {
-        CHECK_OK(fs_tool.ListBlocksForTablet(argv[2]));
-      } else {
-         CHECK_OK(fs_tool.ListBlocksForAllTablets());
-      }
-    }
-  }
-
-  return 0;
-}
-
-} // namespace tools
-} // namespace kudu
-
-int main(int argc, char** argv) {
-  return kudu::tools::FsListToolMain(argc, argv);
-}