Repository: kudu Updated Branches: refs/heads/master 270dd9996 -> a66585398
http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/mini-cluster/external_mini_cluster.cc ---------------------------------------------------------------------- diff --git a/src/kudu/mini-cluster/external_mini_cluster.cc b/src/kudu/mini-cluster/external_mini_cluster.cc index df5cb12..55a75fa 100644 --- a/src/kudu/mini-cluster/external_mini_cluster.cc +++ b/src/kudu/mini-cluster/external_mini_cluster.cc @@ -120,9 +120,13 @@ ExternalMiniCluster::~ExternalMiniCluster() { Shutdown(); } +Env* ExternalMiniCluster::env() const { + return Env::Default(); +} + Status ExternalMiniCluster::DeduceBinRoot(std::string* ret) { string exe; - RETURN_NOT_OK(Env::Default()->GetExecutablePath(&exe)); + RETURN_NOT_OK(env()->GetExecutablePath(&exe)); *ret = DirName(exe); return Status::OK(); } @@ -157,7 +161,7 @@ Status ExternalMiniCluster::Start() { .Build(&messenger_), "Failed to start Messenger for minicluster"); - Status s = Env::Default()->CreateDir(opts_.cluster_root); + Status s = env()->CreateDir(opts_.cluster_root); if (!s.ok() && !s.IsAlreadyPresent()) { RETURN_NOT_OK_PREPEND(s, "Could not create root dir " + opts_.cluster_root); } @@ -673,6 +677,14 @@ Status ExternalMiniCluster::SetFlag(ExternalDaemon* daemon, return Status::OK(); } +string ExternalMiniCluster::WalRootForTS(int ts_idx) const { + return tablet_server(ts_idx)->wal_dir(); +} + +string ExternalMiniCluster::UuidForTS(int ts_idx) const { + return tablet_server(ts_idx)->uuid(); +} + //------------------------------------------------------------ // ExternalDaemon //------------------------------------------------------------ http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/mini-cluster/external_mini_cluster.h ---------------------------------------------------------------------- diff --git a/src/kudu/mini-cluster/external_mini_cluster.h b/src/kudu/mini-cluster/external_mini_cluster.h index 0f0c830..a280640 100644 --- a/src/kudu/mini-cluster/external_mini_cluster.h +++ b/src/kudu/mini-cluster/external_mini_cluster.h @@ -43,6 +43,7 @@ namespace kudu { +class Env; class NodeInstancePB; class Sockaddr; class Subprocess; @@ -259,6 +260,15 @@ class ExternalMiniCluster : public MiniCluster { return masters_.size(); } + // Returns the WALs root directory for the tablet server 'ts_idx'. + virtual std::string WalRootForTS(int ts_idx) const override; + + // Returns the UUID for the tablet server 'ts_idx'. + virtual std::string UuidForTS(int ts_idx) const override; + + // Returns the Env on which the cluster operates. + virtual Env* env() const override; + BindMode bind_mode() const override { return opts_.bind_mode; } http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/mini-cluster/internal_mini_cluster.cc ---------------------------------------------------------------------- diff --git a/src/kudu/mini-cluster/internal_mini_cluster.cc b/src/kudu/mini-cluster/internal_mini_cluster.cc index 7e342cc..b9b3187 100644 --- a/src/kudu/mini-cluster/internal_mini_cluster.cc +++ b/src/kudu/mini-cluster/internal_mini_cluster.cc @@ -24,6 +24,7 @@ #include "kudu/client/client.h" #include "kudu/common/wire_protocol.pb.h" +#include "kudu/fs/fs_manager.h" #include "kudu/gutil/gscoped_ptr.h" #include "kudu/gutil/strings/substitute.h" #include "kudu/master/catalog_manager.h" @@ -396,5 +397,13 @@ std::shared_ptr<MasterServiceProxy> InternalMiniCluster::master_proxy(int idx) c return std::make_shared<MasterServiceProxy>(messenger_, addr, addr.host()); } +string InternalMiniCluster::WalRootForTS(int ts_idx) const { + return mini_tablet_server(ts_idx)->options()->fs_opts.wal_root; +} + +string InternalMiniCluster::UuidForTS(int ts_idx) const { + return mini_tablet_server(ts_idx)->uuid(); +} + } // namespace cluster } // namespace kudu http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/mini-cluster/internal_mini_cluster.h ---------------------------------------------------------------------- diff --git a/src/kudu/mini-cluster/internal_mini_cluster.h b/src/kudu/mini-cluster/internal_mini_cluster.h index 4f73505..eedac07 100644 --- a/src/kudu/mini-cluster/internal_mini_cluster.h +++ b/src/kudu/mini-cluster/internal_mini_cluster.h @@ -152,6 +152,17 @@ class InternalMiniCluster : public MiniCluster { return mini_tablet_servers_.size(); } + // Returns the WALs root directory for the tablet server 'ts_idx'. + std::string WalRootForTS(int ts_idx) const override; + + // Returns the UUID for the tablet server 'ts_idx'. + std::string UuidForTS(int ts_idx) const override; + + // Returns the Env on which the cluster operates. + Env* env() const override { + return env_; + } + BindMode bind_mode() const override { return opts_.bind_mode; } http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/mini-cluster/mini_cluster.h ---------------------------------------------------------------------- diff --git a/src/kudu/mini-cluster/mini_cluster.h b/src/kudu/mini-cluster/mini_cluster.h index 8a1440c..845b79c 100644 --- a/src/kudu/mini-cluster/mini_cluster.h +++ b/src/kudu/mini-cluster/mini_cluster.h @@ -26,6 +26,7 @@ namespace kudu { +class Env; class HostPort; namespace client { @@ -150,6 +151,15 @@ class MiniCluster { // master at 'idx' is running. virtual std::shared_ptr<master::MasterServiceProxy> master_proxy(int idx) const = 0; + // Returns the UUID for the tablet server 'ts_idx' + virtual std::string UuidForTS(int ts_idx) const = 0; + + // Returns the WALs root directory for the tablet server 'ts_idx'. + virtual std::string WalRootForTS(int ts_idx) const = 0; + + // Returns the Env on which the cluster operates. + virtual Env* env() const = 0; + protected: // Return the IP address that the daemon with the given index will bind to. // If bind_mode is LOOPBACK, this will be 127.0.0.1 and if it is WILDCARD it http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/tablet/tablet_bootstrap.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/tablet_bootstrap.cc b/src/kudu/tablet/tablet_bootstrap.cc index 759b1b3..04516b4 100644 --- a/src/kudu/tablet/tablet_bootstrap.cc +++ b/src/kudu/tablet/tablet_bootstrap.cc @@ -43,6 +43,7 @@ #include "kudu/consensus/log.h" #include "kudu/consensus/log.pb.h" #include "kudu/consensus/log_anchor_registry.h" +#include "kudu/consensus/log_index.h" #include "kudu/consensus/log_reader.h" #include "kudu/consensus/log_util.h" #include "kudu/consensus/metadata.pb.h" @@ -127,6 +128,7 @@ using consensus::WRITE_OP; using log::Log; using log::LogAnchorRegistry; using log::LogEntryPB; +using log::LogIndex; using log::LogOptions; using log::LogReader; using log::ReadableLogSegment; @@ -646,7 +648,7 @@ Status TabletBootstrap::PrepareRecoveryDir(bool* needs_recovery) { // Since we have a recovery directory, clear out the log_dir by recursively // deleting it and creating a new one so that we don't end up with remnants // of old WAL segments or indexes after replay. - if (fs_manager->env()->FileExists(log_dir)) { + if (fs_manager->Exists(log_dir)) { LOG_WITH_PREFIX(INFO) << "Deleting old log files from previous recovery attempt in " << log_dir; RETURN_NOT_OK_PREPEND(fs_manager->env()->DeleteRecursively(log_dir), @@ -696,13 +698,18 @@ Status TabletBootstrap::PrepareRecoveryDir(bool* needs_recovery) { } Status TabletBootstrap::OpenLogReaderInRecoveryDir() { + const string& tablet_id = tablet_->tablet_id(); + FsManager* fs_manager = tablet_meta_->fs_manager(); VLOG_WITH_PREFIX(1) << "Opening log reader in log recovery dir " - << tablet_meta_->fs_manager()->GetTabletWalRecoveryDir(tablet_->tablet_id()); + << fs_manager->GetTabletWalRecoveryDir(tablet_id); // Open the reader. - RETURN_NOT_OK_PREPEND(LogReader::OpenFromRecoveryDir(tablet_->metadata()->fs_manager(), - tablet_->metadata()->tablet_id(), - tablet_->GetMetricEntity().get(), - &log_reader_), + // Since we're recovering, we don't want to have any log index -- since it + // isn't fsynced() during writing, its contents are useless to us. + scoped_refptr<LogIndex> log_index(nullptr); + const string recovery_dir = fs_manager->GetTabletWalRecoveryDir(tablet_id); + RETURN_NOT_OK_PREPEND(LogReader::Open(fs_manager->env(), recovery_dir, log_index, tablet_id, + tablet_->GetMetricEntity().get(), + &log_reader_), "Could not open LogReader. Reason"); return Status::OK(); } http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/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 de8acf8..2463dfa 100644 --- a/src/kudu/tools/kudu-tool-test.cc +++ b/src/kudu/tools/kudu-tool-test.cc @@ -73,7 +73,7 @@ #include "kudu/gutil/strings/strip.h" #include "kudu/gutil/strings/substitute.h" #include "kudu/integration-tests/cluster_itest_util.h" -#include "kudu/integration-tests/external_mini_cluster_fs_inspector.h" +#include "kudu/integration-tests/mini_cluster_fs_inspector.h" #include "kudu/integration-tests/test_workload.h" #include "kudu/mini-cluster/external_mini_cluster.h" #include "kudu/mini-cluster/internal_mini_cluster.h" @@ -140,7 +140,7 @@ using consensus::ReplicateMsg; using fs::BlockDeletionTransaction; using fs::FsReport; using fs::WritableBlock; -using itest::ExternalMiniClusterFsInspector; +using itest::MiniClusterFsInspector; using itest::TServerDetails; using log::Log; using log::LogOptions; @@ -329,7 +329,7 @@ class ToolTest : public KuduTest { void StartExternalMiniCluster(ExternalMiniClusterOptions opts = {}); void StartMiniCluster(InternalMiniClusterOptions opts = {}); unique_ptr<ExternalMiniCluster> cluster_; - unique_ptr<ExternalMiniClusterFsInspector> inspect_; + unique_ptr<MiniClusterFsInspector> inspect_; unordered_map<string, TServerDetails*> ts_map_; unique_ptr<InternalMiniCluster> mini_cluster_; }; @@ -337,7 +337,7 @@ class ToolTest : public KuduTest { void ToolTest::StartExternalMiniCluster(ExternalMiniClusterOptions opts) { cluster_.reset(new ExternalMiniCluster(std::move(opts))); ASSERT_OK(cluster_->Start()); - inspect_.reset(new ExternalMiniClusterFsInspector(cluster_.get())); + inspect_.reset(new MiniClusterFsInspector(cluster_.get())); ASSERT_OK(CreateTabletServerMap(cluster_->master_proxy(), cluster_->messenger(), &ts_map_)); } http://git-wip-us.apache.org/repos/asf/kudu/blob/2165ce57/src/kudu/tools/kudu-ts-cli-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/kudu-ts-cli-test.cc b/src/kudu/tools/kudu-ts-cli-test.cc index 3a52fdf..736afc8 100644 --- a/src/kudu/tools/kudu-ts-cli-test.cc +++ b/src/kudu/tools/kudu-ts-cli-test.cc @@ -26,7 +26,7 @@ #include "kudu/gutil/strings/substitute.h" #include "kudu/integration-tests/cluster_itest_util.h" #include "kudu/integration-tests/external_mini_cluster-itest-base.h" -#include "kudu/integration-tests/external_mini_cluster_fs_inspector.h" +#include "kudu/integration-tests/mini_cluster_fs_inspector.h" #include "kudu/integration-tests/test_workload.h" #include "kudu/mini-cluster/external_mini_cluster.h" #include "kudu/tablet/metadata.pb.h"
