kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject kudu git commit: Replace gscoped_ptr with unique_ptr for ConsensusMetadata
Date Mon, 15 Aug 2016 06:10:04 GMT
Repository: kudu
Updated Branches:
  refs/heads/master b7e4f1212 -> 28a9902ce


Replace gscoped_ptr with unique_ptr for ConsensusMetadata

Change-Id: Iffc81148d497f1da95ccd25cbfc487c3bef71a6c
Reviewed-on: http://gerrit.cloudera.org:8080/3967
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <todd@apache.org>


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

Branch: refs/heads/master
Commit: 28a9902ceeb4ae7be20342c0cdc5af698ea02992
Parents: b7e4f12
Author: Adar Dembo <adar@cloudera.com>
Authored: Thu Aug 11 22:56:54 2016 -0700
Committer: Adar Dembo <adar@cloudera.com>
Committed: Mon Aug 15 06:09:31 2016 +0000

----------------------------------------------------------------------
 src/kudu/consensus/consensus_meta-test.cc       | 23 ++++++++++----------
 src/kudu/consensus/consensus_meta.cc            | 11 ++++++----
 src/kudu/consensus/consensus_meta.h             |  6 ++---
 src/kudu/consensus/raft_consensus-test.cc       |  6 +++--
 src/kudu/consensus/raft_consensus.cc            | 16 +++++++++-----
 src/kudu/consensus/raft_consensus.h             |  4 ++--
 .../consensus/raft_consensus_quorum-test.cc     | 12 +++++-----
 src/kudu/consensus/raft_consensus_state-test.cc |  4 +++-
 src/kudu/consensus/raft_consensus_state.cc      |  4 +++-
 src/kudu/consensus/raft_consensus_state.h       |  5 +++--
 src/kudu/master/sys_catalog.cc                  |  5 +++--
 src/kudu/tablet/tablet_bootstrap-test.cc        |  4 +++-
 src/kudu/tablet/tablet_bootstrap.cc             |  2 +-
 src/kudu/tablet/tablet_peer-test.cc             |  2 +-
 src/kudu/tablet/tablet_peer.cc                  | 21 +++++++++---------
 src/kudu/tserver/tablet_copy_client.cc          |  6 +++--
 src/kudu/tserver/tablet_copy_client.h           |  2 +-
 src/kudu/tserver/tablet_copy_session-test.cc    |  2 +-
 src/kudu/tserver/ts_tablet_manager.cc           |  3 ++-
 19 files changed, 82 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/consensus_meta-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_meta-test.cc b/src/kudu/consensus/consensus_meta-test.cc
index 35d1900..6c95199 100644
--- a/src/kudu/consensus/consensus_meta-test.cc
+++ b/src/kudu/consensus/consensus_meta-test.cc
@@ -16,6 +16,7 @@
 // under the License.
 #include "kudu/consensus/consensus_meta.h"
 
+#include <memory>
 #include <vector>
 
 #include <gtest/gtest.h>
@@ -25,7 +26,6 @@
 #include "kudu/consensus/opid_util.h"
 #include "kudu/consensus/quorum_util.h"
 #include "kudu/fs/fs_manager.h"
-#include "kudu/gutil/gscoped_ptr.h"
 #include "kudu/util/net/net_util.h"
 #include "kudu/util/test_macros.h"
 #include "kudu/util/test_util.h"
@@ -37,6 +37,7 @@ namespace kudu {
 namespace consensus {
 
 using std::string;
+using std::unique_ptr;
 using std::vector;
 
 const char* kTabletId = "test-consensus-metadata";
@@ -86,20 +87,20 @@ void ConsensusMetadataTest::AssertValuesEqual(const ConsensusMetadata&
cmeta,
 TEST_F(ConsensusMetadataTest, TestCreateLoad) {
   // Create the file.
   {
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, fs_manager_.uuid(),
                                         config_, kInitialTerm, &cmeta));
   }
 
   // Load the file.
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId, fs_manager_.uuid(), &cmeta));
   ASSERT_VALUES_EQUAL(*cmeta, kInvalidOpIdIndex, fs_manager_.uuid(), kInitialTerm);
 }
 
 // Ensure that we get an error when loading a file that doesn't exist.
 TEST_F(ConsensusMetadataTest, TestFailedLoad) {
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   Status s = ConsensusMetadata::Load(&fs_manager_, kTabletId, fs_manager_.uuid(), &cmeta);
   ASSERT_TRUE(s.IsNotFound()) << "Unexpected status: " << s.ToString();
   LOG(INFO) << "Expected failure: " << s.ToString();
@@ -108,7 +109,7 @@ TEST_F(ConsensusMetadataTest, TestFailedLoad) {
 // Check that changes are not written to disk until Flush() is called.
 TEST_F(ConsensusMetadataTest, TestFlush) {
   const int64_t kNewTerm = 4;
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, fs_manager_.uuid(),
                                       config_, kInitialTerm, &cmeta));
   cmeta->set_current_term(kNewTerm);
@@ -117,7 +118,7 @@ TEST_F(ConsensusMetadataTest, TestFlush) {
   // objects in flight that point to the same file, but for a test this is fine
   // since it's read-only.
   {
-    gscoped_ptr<ConsensusMetadata> cmeta_read;
+    unique_ptr<ConsensusMetadata> cmeta_read;
     ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId, fs_manager_.uuid(), &cmeta_read));
     ASSERT_VALUES_EQUAL(*cmeta_read, kInvalidOpIdIndex, fs_manager_.uuid(), kInitialTerm);
   }
@@ -125,7 +126,7 @@ TEST_F(ConsensusMetadataTest, TestFlush) {
   ASSERT_OK(cmeta->Flush());
 
   {
-    gscoped_ptr<ConsensusMetadata> cmeta_read;
+    unique_ptr<ConsensusMetadata> cmeta_read;
     ASSERT_OK(ConsensusMetadata::Load(&fs_manager_, kTabletId, fs_manager_.uuid(), &cmeta_read));
     ASSERT_VALUES_EQUAL(*cmeta_read, kInvalidOpIdIndex, fs_manager_.uuid(), kNewTerm);
   }
@@ -150,7 +151,7 @@ TEST_F(ConsensusMetadataTest, TestActiveRole) {
   RaftConfigPB config1 = BuildConfig(uuids); // We aren't a member of this config...
   config1.set_opid_index(1);
 
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, peer_uuid,
                                       config1, kInitialTerm, &cmeta));
 
@@ -195,7 +196,7 @@ TEST_F(ConsensusMetadataTest, TestToConsensusStatePB) {
 
   RaftConfigPB committed_config = BuildConfig(uuids); // We aren't a member of this config...
   committed_config.set_opid_index(1);
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, peer_uuid,
                                       committed_config, kInitialTerm, &cmeta));
 
@@ -227,7 +228,7 @@ TEST_F(ConsensusMetadataTest, TestToConsensusStatePB) {
 }
 
 // Helper for TestMergeCommittedConsensusStatePB.
-static void AssertConsensusMergeExpected(const gscoped_ptr<ConsensusMetadata>&
cmeta,
+static void AssertConsensusMergeExpected(const unique_ptr<ConsensusMetadata>& cmeta,
                                          const ConsensusStatePB& cstate,
                                          int64_t expected_term,
                                          const string& expected_voted_for) {
@@ -250,7 +251,7 @@ TEST_F(ConsensusMetadataTest, TestMergeCommittedConsensusStatePB) {
 
   RaftConfigPB committed_config = BuildConfig(uuids); // We aren't a member of this config...
   committed_config.set_opid_index(1);
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, "e",
                                       committed_config, 1, &cmeta));
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/consensus_meta.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_meta.cc b/src/kudu/consensus/consensus_meta.cc
index d6cf74a..9426ceb 100644
--- a/src/kudu/consensus/consensus_meta.cc
+++ b/src/kudu/consensus/consensus_meta.cc
@@ -16,6 +16,8 @@
 // under the License.
 #include "kudu/consensus/consensus_meta.h"
 
+#include <memory>
+
 #include "kudu/consensus/log_util.h"
 #include "kudu/consensus/metadata.pb.h"
 #include "kudu/consensus/opid_util.h"
@@ -30,6 +32,7 @@ namespace kudu {
 namespace consensus {
 
 using std::string;
+using std::unique_ptr;
 using strings::Substitute;
 
 Status ConsensusMetadata::Create(FsManager* fs_manager,
@@ -37,8 +40,8 @@ Status ConsensusMetadata::Create(FsManager* fs_manager,
                                  const std::string& peer_uuid,
                                  const RaftConfigPB& config,
                                  int64_t current_term,
-                                 gscoped_ptr<ConsensusMetadata>* cmeta_out) {
-  gscoped_ptr<ConsensusMetadata> cmeta(new ConsensusMetadata(fs_manager, tablet_id,
peer_uuid));
+                                 unique_ptr<ConsensusMetadata>* cmeta_out) {
+  unique_ptr<ConsensusMetadata> cmeta(new ConsensusMetadata(fs_manager, tablet_id,
peer_uuid));
   cmeta->set_committed_config(config);
   cmeta->set_current_term(current_term);
   RETURN_NOT_OK(cmeta->Flush());
@@ -49,8 +52,8 @@ Status ConsensusMetadata::Create(FsManager* fs_manager,
 Status ConsensusMetadata::Load(FsManager* fs_manager,
                                const std::string& tablet_id,
                                const std::string& peer_uuid,
-                               gscoped_ptr<ConsensusMetadata>* cmeta_out) {
-  gscoped_ptr<ConsensusMetadata> cmeta(new ConsensusMetadata(fs_manager, tablet_id,
peer_uuid));
+                               unique_ptr<ConsensusMetadata>* cmeta_out) {
+  unique_ptr<ConsensusMetadata> cmeta(new ConsensusMetadata(fs_manager, tablet_id,
peer_uuid));
   RETURN_NOT_OK(pb_util::ReadPBContainerFromPath(fs_manager->env(),
                                                  fs_manager->GetConsensusMetadataPath(tablet_id),
                                                  &cmeta->pb_));

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/consensus_meta.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_meta.h b/src/kudu/consensus/consensus_meta.h
index af1424a..a8d5f93 100644
--- a/src/kudu/consensus/consensus_meta.h
+++ b/src/kudu/consensus/consensus_meta.h
@@ -17,11 +17,11 @@
 #ifndef KUDU_CONSENSUS_CONSENSUS_META_H_
 #define KUDU_CONSENSUS_CONSENSUS_META_H_
 
+#include <memory>
 #include <stdint.h>
 #include <string>
 
 #include "kudu/consensus/metadata.pb.h"
-#include "kudu/gutil/gscoped_ptr.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/util/status.h"
 
@@ -63,7 +63,7 @@ class ConsensusMetadata {
                        const std::string& peer_uuid,
                        const RaftConfigPB& config,
                        int64_t current_term,
-                       gscoped_ptr<ConsensusMetadata>* cmeta);
+                       std::unique_ptr<ConsensusMetadata>* cmeta);
 
   // Load a ConsensusMetadata object from disk.
   // Returns Status::NotFound if the file could not be found. May return other
@@ -71,7 +71,7 @@ class ConsensusMetadata {
   static Status Load(FsManager* fs_manager,
                      const std::string& tablet_id,
                      const std::string& peer_uuid,
-                     gscoped_ptr<ConsensusMetadata>* cmeta);
+                     std::unique_ptr<ConsensusMetadata>* cmeta);
 
   // Delete the ConsensusMetadata file associated with the given tablet from
   // disk.

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus-test.cc b/src/kudu/consensus/raft_consensus-test.cc
index 6c6819e..64fce69 100644
--- a/src/kudu/consensus/raft_consensus-test.cc
+++ b/src/kudu/consensus/raft_consensus-test.cc
@@ -17,6 +17,7 @@
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
+#include <memory>
 
 #include "kudu/common/schema.h"
 #include "kudu/common/wire_protocol-test-util.h"
@@ -39,6 +40,7 @@ METRIC_DECLARE_entity(tablet);
 
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 
 namespace kudu {
 namespace consensus {
@@ -101,7 +103,7 @@ class RaftConsensusSpy : public RaftConsensus {
   typedef Callback<Status(const scoped_refptr<ConsensusRound>& round)> AppendCallback;
 
   RaftConsensusSpy(const ConsensusOptions& options,
-                   gscoped_ptr<ConsensusMetadata> cmeta,
+                   unique_ptr<ConsensusMetadata> cmeta,
                    gscoped_ptr<PeerProxyFactory> proxy_factory,
                    gscoped_ptr<PeerMessageQueue> queue,
                    gscoped_ptr<PeerManager> peer_manager,
@@ -205,7 +207,7 @@ class RaftConsensusTest : public KuduTest {
 
     string peer_uuid = config_.peers(num_peers - 1).permanent_uuid();
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     CHECK_OK(ConsensusMetadata::Create(fs_manager_.get(), kTestTablet, peer_uuid,
                                        config_, initial_term, &cmeta));
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index 3cdaa3b..46cf82d 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -21,6 +21,7 @@
 #include <boost/optional.hpp>
 #include <gflags/gflags.h>
 #include <iostream>
+#include <memory>
 #include <mutex>
 
 #include "kudu/common/wire_protocol.h"
@@ -142,6 +143,7 @@ namespace kudu {
 namespace consensus {
 
 using std::shared_ptr;
+using std::unique_ptr;
 using strings::Substitute;
 using tserver::TabletServerErrorPB;
 
@@ -150,7 +152,7 @@ static const char* const kTimerId = "election-timer";
 
 scoped_refptr<RaftConsensus> RaftConsensus::Create(
     const ConsensusOptions& options,
-    gscoped_ptr<ConsensusMetadata> cmeta,
+    unique_ptr<ConsensusMetadata> cmeta,
     const RaftPeerPB& local_peer_pb,
     const scoped_refptr<MetricEntity>& metric_entity,
     const scoped_refptr<server::Clock>& clock,
@@ -203,13 +205,17 @@ scoped_refptr<RaftConsensus> RaftConsensus::Create(
 }
 
 RaftConsensus::RaftConsensus(
-    const ConsensusOptions& options, gscoped_ptr<ConsensusMetadata> cmeta,
+    const ConsensusOptions& options,
+    unique_ptr<ConsensusMetadata> cmeta,
     gscoped_ptr<PeerProxyFactory> proxy_factory,
-    gscoped_ptr<PeerMessageQueue> queue, gscoped_ptr<PeerManager> peer_manager,
+    gscoped_ptr<PeerMessageQueue> queue,
+    gscoped_ptr<PeerManager> peer_manager,
     gscoped_ptr<ThreadPool> thread_pool,
     const scoped_refptr<MetricEntity>& metric_entity,
-    const std::string& peer_uuid, const scoped_refptr<server::Clock>& clock,
-    ReplicaTransactionFactory* txn_factory, const scoped_refptr<log::Log>& log,
+    const std::string& peer_uuid,
+    const scoped_refptr<server::Clock>& clock,
+    ReplicaTransactionFactory* txn_factory,
+    const scoped_refptr<log::Log>& log,
     shared_ptr<MemTracker> parent_mem_tracker,
     Callback<void(const std::string& reason)> mark_dirty_clbk)
     : thread_pool_(std::move(thread_pool)),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.h b/src/kudu/consensus/raft_consensus.h
index b516405..c971b02 100644
--- a/src/kudu/consensus/raft_consensus.h
+++ b/src/kudu/consensus/raft_consensus.h
@@ -65,7 +65,7 @@ class RaftConsensus : public Consensus,
 
   static scoped_refptr<RaftConsensus> Create(
     const ConsensusOptions& options,
-    gscoped_ptr<ConsensusMetadata> cmeta,
+    std::unique_ptr<ConsensusMetadata> cmeta,
     const RaftPeerPB& local_peer_pb,
     const scoped_refptr<MetricEntity>& metric_entity,
     const scoped_refptr<server::Clock>& clock,
@@ -76,7 +76,7 @@ class RaftConsensus : public Consensus,
     const Callback<void(const std::string& reason)>& mark_dirty_clbk);
 
   RaftConsensus(const ConsensusOptions& options,
-                gscoped_ptr<ConsensusMetadata> cmeta,
+                std::unique_ptr<ConsensusMetadata> cmeta,
                 gscoped_ptr<PeerProxyFactory> peer_proxy_factory,
                 gscoped_ptr<PeerMessageQueue> queue,
                 gscoped_ptr<PeerManager> peer_manager,

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus_quorum-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index eb583d1..46002b2 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -16,6 +16,7 @@
 // under the License.
 
 #include <gtest/gtest.h>
+#include <memory>
 
 #include "kudu/common/schema.h"
 #include "kudu/common/wire_protocol-test-util.h"
@@ -53,6 +54,7 @@ METRIC_DECLARE_entity(tablet);
   ASSERT_NO_FATAL_FAILURE(ReplicateSequenceOfMessages(a, b, c, d, e, f, g))
 
 using std::shared_ptr;
+using std::unique_ptr;
 
 namespace kudu {
 
@@ -145,7 +147,7 @@ class RaftConsensusQuorumTest : public KuduTest {
 
       string peer_uuid = Substitute("peer-$0", i);
 
-      gscoped_ptr<ConsensusMetadata> cmeta;
+      unique_ptr<ConsensusMetadata> cmeta;
       CHECK_OK(ConsensusMetadata::Create(fs_managers_[i], kTestTablet, peer_uuid, config_,
                                          kMinimumTerm, &cmeta));
 
@@ -527,23 +529,23 @@ class RaftConsensusQuorumTest : public KuduTest {
   }
 
   // Read the ConsensusMetadata for the given peer from disk.
-  gscoped_ptr<ConsensusMetadata> ReadConsensusMetadataFromDisk(int peer_index) {
+  unique_ptr<ConsensusMetadata> ReadConsensusMetadataFromDisk(int peer_index) {
     string peer_uuid = Substitute("peer-$0", peer_index);
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     CHECK_OK(ConsensusMetadata::Load(fs_managers_[peer_index], kTestTablet, peer_uuid, &cmeta));
     return std::move(cmeta);
   }
 
   // Assert that the durable term == term and that the peer that got the vote == voted_for.
   void AssertDurableTermAndVote(int peer_index, int64_t term, const std::string& voted_for)
{
-    gscoped_ptr<ConsensusMetadata> cmeta = ReadConsensusMetadataFromDisk(peer_index);
+    unique_ptr<ConsensusMetadata> cmeta = ReadConsensusMetadataFromDisk(peer_index);
     ASSERT_EQ(term, cmeta->current_term());
     ASSERT_EQ(voted_for, cmeta->voted_for());
   }
 
   // Assert that the durable term == term and that the peer has not yet voted.
   void AssertDurableTermWithoutVote(int peer_index, int64_t term) {
-    gscoped_ptr<ConsensusMetadata> cmeta = ReadConsensusMetadataFromDisk(peer_index);
+    unique_ptr<ConsensusMetadata> cmeta = ReadConsensusMetadataFromDisk(peer_index);
     ASSERT_EQ(term, cmeta->current_term());
     ASSERT_FALSE(cmeta->has_voted_for());
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus_state-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state-test.cc b/src/kudu/consensus/raft_consensus_state-test.cc
index ab98c96..a63231b 100644
--- a/src/kudu/consensus/raft_consensus_state-test.cc
+++ b/src/kudu/consensus/raft_consensus_state-test.cc
@@ -17,6 +17,7 @@
 #include "kudu/consensus/raft_consensus_state.h"
 
 #include <gtest/gtest.h>
+#include <memory>
 #include <vector>
 
 #include "kudu/consensus/consensus.pb.h"
@@ -29,6 +30,7 @@
 namespace kudu {
 namespace consensus {
 
+using std::unique_ptr;
 using std::vector;
 
 // TODO: Share a test harness with ConsensusMetadataTest?
@@ -52,7 +54,7 @@ class RaftConsensusStateTest : public KuduTest {
     peer->set_permanent_uuid(fs_manager_.uuid());
     peer->set_member_type(RaftPeerPB::VOTER);
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     ASSERT_OK(ConsensusMetadata::Create(&fs_manager_, kTabletId, fs_manager_.uuid(),
                                         config_, kMinimumTerm, &cmeta));
     state_.reset(new ReplicaState(ConsensusOptions(), fs_manager_.uuid(), std::move(cmeta),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus_state.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state.cc b/src/kudu/consensus/raft_consensus_state.cc
index 7d937df..1ab803b 100644
--- a/src/kudu/consensus/raft_consensus_state.cc
+++ b/src/kudu/consensus/raft_consensus_state.cc
@@ -16,6 +16,7 @@
 // under the License.
 
 #include <algorithm>
+#include <memory>
 
 #include "kudu/consensus/log_util.h"
 #include "kudu/consensus/quorum_util.h"
@@ -33,6 +34,7 @@ namespace kudu {
 namespace consensus {
 
 using std::string;
+using std::unique_ptr;
 using strings::Substitute;
 using strings::SubstituteAndAppend;
 
@@ -41,7 +43,7 @@ using strings::SubstituteAndAppend;
 //////////////////////////////////////////////////
 
 ReplicaState::ReplicaState(ConsensusOptions options, string peer_uuid,
-                           gscoped_ptr<ConsensusMetadata> cmeta,
+                           unique_ptr<ConsensusMetadata> cmeta,
                            ReplicaTransactionFactory* txn_factory)
     : options_(std::move(options)),
       peer_uuid_(std::move(peer_uuid)),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/consensus/raft_consensus_state.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state.h b/src/kudu/consensus/raft_consensus_state.h
index cb326ab..9ce24ab 100644
--- a/src/kudu/consensus/raft_consensus_state.h
+++ b/src/kudu/consensus/raft_consensus_state.h
@@ -18,6 +18,7 @@
 #define KUDU_CONSENSUS_RAFT_CONSENSUS_UTIL_H_
 
 #include <map>
+#include <memory>
 #include <mutex>
 #include <set>
 #include <string>
@@ -96,7 +97,7 @@ class ReplicaState {
   typedef IndexToRoundMap::value_type IndexToRoundEntry;
 
   ReplicaState(ConsensusOptions options, std::string peer_uuid,
-               gscoped_ptr<ConsensusMetadata> cmeta,
+               std::unique_ptr<ConsensusMetadata> cmeta,
                ReplicaTransactionFactory* txn_factory);
 
   Status StartUnlocked(const OpId& last_in_wal);
@@ -346,7 +347,7 @@ class ReplicaState {
   mutable simple_spinlock update_lock_;
 
   // Consensus metadata persistence object.
-  gscoped_ptr<ConsensusMetadata> cmeta_;
+  std::unique_ptr<ConsensusMetadata> cmeta_;
 
   // Used by the LEADER. This is the index of the next operation generated
   // by this LEADER.

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/master/sys_catalog.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/sys_catalog.cc b/src/kudu/master/sys_catalog.cc
index 3775009..fe5d161 100644
--- a/src/kudu/master/sys_catalog.cc
+++ b/src/kudu/master/sys_catalog.cc
@@ -19,6 +19,7 @@
 
 #include <gflags/gflags.h>
 #include <glog/logging.h>
+#include <memory>
 
 #include "kudu/common/partial_row.h"
 #include "kudu/common/partition.h"
@@ -117,7 +118,7 @@ Status SysCatalogTable::Load(FsManager *fs_manager) {
     LOG(INFO) << "Configuring consensus for distributed operation...";
 
     string tablet_id = metadata->tablet_id();
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     RETURN_NOT_OK_PREPEND(ConsensusMetadata::Load(fs_manager, tablet_id,
                                                   fs_manager->uuid(), &cmeta),
                           "Unable to load consensus metadata for tablet " + tablet_id);
@@ -166,7 +167,7 @@ Status SysCatalogTable::CreateNew(FsManager *fs_manager) {
   }
 
   string tablet_id = metadata->tablet_id();
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   RETURN_NOT_OK_PREPEND(ConsensusMetadata::Create(fs_manager, tablet_id, fs_manager->uuid(),
                                                   config, consensus::kMinimumTerm, &cmeta),
                         "Unable to persist consensus metadata for tablet " + tablet_id);

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tablet/tablet_bootstrap-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap-test.cc b/src/kudu/tablet/tablet_bootstrap-test.cc
index dd211a8..5cb97b4 100644
--- a/src/kudu/tablet/tablet_bootstrap-test.cc
+++ b/src/kudu/tablet/tablet_bootstrap-test.cc
@@ -17,6 +17,7 @@
 
 #include "kudu/consensus/log-test-base.h"
 
+#include <memory>
 #include <vector>
 
 #include "kudu/common/iterator.h"
@@ -33,6 +34,7 @@
 
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using std::vector;
 
 namespace kudu {
@@ -132,7 +134,7 @@ class BootstrapTest : public LogTestBase {
     peer->set_permanent_uuid(meta->fs_manager()->uuid());
     peer->set_member_type(consensus::RaftPeerPB::VOTER);
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     RETURN_NOT_OK_PREPEND(ConsensusMetadata::Create(meta->fs_manager(), meta->tablet_id(),
                                                     meta->fs_manager()->uuid(),
                                                     config, kMinimumTerm, &cmeta),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tablet/tablet_bootstrap.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap.cc b/src/kudu/tablet/tablet_bootstrap.cc
index 2733881..f84fb1b 100644
--- a/src/kudu/tablet/tablet_bootstrap.cc
+++ b/src/kudu/tablet/tablet_bootstrap.cc
@@ -319,7 +319,7 @@ class TabletBootstrap {
   scoped_refptr<log::Log> log_;
   std::shared_ptr<log::LogReader> log_reader_;
 
-  gscoped_ptr<ConsensusMetadata> cmeta_;
+  unique_ptr<ConsensusMetadata> cmeta_;
 
   // Statistics on the replay of entries in the log.
   struct Stats {

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tablet/tablet_peer-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer-test.cc b/src/kudu/tablet/tablet_peer-test.cc
index 8a04d1f..4c1b004 100644
--- a/src/kudu/tablet/tablet_peer-test.cc
+++ b/src/kudu/tablet/tablet_peer-test.cc
@@ -122,7 +122,7 @@ class TabletPeerTest : public KuduTabletTest {
     config.add_peers()->CopyFrom(config_peer);
     config.set_opid_index(consensus::kInvalidOpIdIndex);
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     ASSERT_OK(ConsensusMetadata::Create(tablet()->metadata()->fs_manager(),
                                         tablet()->tablet_id(),
                                         tablet()->metadata()->fs_manager()->uuid(),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tablet/tablet_peer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer.cc b/src/kudu/tablet/tablet_peer.cc
index cb5cd0d..eb9366b 100644
--- a/src/kudu/tablet/tablet_peer.cc
+++ b/src/kudu/tablet/tablet_peer.cc
@@ -19,6 +19,7 @@
 
 #include <algorithm>
 #include <gflags/gflags.h>
+#include <memory>
 #include <mutex>
 #include <string>
 #include <utility>
@@ -156,20 +157,20 @@ Status TabletPeer::Init(const shared_ptr<Tablet>& tablet,
 
     TRACE("Creating consensus instance");
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     RETURN_NOT_OK(ConsensusMetadata::Load(meta_->fs_manager(), tablet_id_,
                                           meta_->fs_manager()->uuid(), &cmeta));
 
     consensus_ = RaftConsensus::Create(options,
-                                        std::move(cmeta),
-                                        local_peer_pb_,
-                                        metric_entity,
-                                        clock_,
-                                        this,
-                                        messenger_,
-                                        log_.get(),
-                                        tablet_->mem_tracker(),
-                                        mark_dirty_clbk_);
+                                       std::move(cmeta),
+                                       local_peer_pb_,
+                                       metric_entity,
+                                       clock_,
+                                       this,
+                                       messenger_,
+                                       log_.get(),
+                                       tablet_->mem_tracker(),
+                                       mark_dirty_clbk_);
   }
 
   if (tablet_->metrics() != nullptr) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tserver/tablet_copy_client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_client.cc b/src/kudu/tserver/tablet_copy_client.cc
index 56d1837..d3444f0 100644
--- a/src/kudu/tserver/tablet_copy_client.cc
+++ b/src/kudu/tserver/tablet_copy_client.cc
@@ -19,6 +19,7 @@
 
 #include <gflags/gflags.h>
 #include <glog/logging.h>
+#include <memory>
 
 #include "kudu/common/wire_protocol.h"
 #include "kudu/consensus/consensus_meta.h"
@@ -80,6 +81,7 @@ using fs::WritableBlock;
 using rpc::Messenger;
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using std::vector;
 using strings::Substitute;
 using tablet::ColumnDataPB;
@@ -133,7 +135,7 @@ Status TabletCopyClient::SetTabletToReplace(const scoped_refptr<TabletMetadata>&
   }
 
   // Load the old consensus metadata, if it exists.
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   Status s = ConsensusMetadata::Load(fs_manager_, tablet_id_,
                                      fs_manager_->uuid(), &cmeta);
   if (s.IsNotFound()) {
@@ -436,7 +438,7 @@ Status TabletCopyClient::DownloadWAL(uint64_t wal_segment_seqno) {
 Status TabletCopyClient::WriteConsensusMetadata() {
   // If we didn't find a previous consensus meta file, create one.
   if (!cmeta_) {
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     return ConsensusMetadata::Create(fs_manager_, tablet_id_, fs_manager_->uuid(),
                                      remote_committed_cstate_->config(),
                                      remote_committed_cstate_->current_term(),

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tserver/tablet_copy_client.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_client.h b/src/kudu/tserver/tablet_copy_client.h
index 01253ee..de2a730 100644
--- a/src/kudu/tserver/tablet_copy_client.h
+++ b/src/kudu/tserver/tablet_copy_client.h
@@ -190,7 +190,7 @@ class TabletCopyClient {
 
   // Local Consensus metadata file. This may initially be NULL if this is
   // bootstrapping a new replica (rather than replacing an old one).
-  gscoped_ptr<consensus::ConsensusMetadata> cmeta_;
+  std::unique_ptr<consensus::ConsensusMetadata> cmeta_;
 
   tablet::TabletStatusListener* status_listener_;
   std::shared_ptr<TabletCopyServiceProxy> proxy_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tserver/tablet_copy_session-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_session-test.cc b/src/kudu/tserver/tablet_copy_session-test.cc
index e75a3b9..ba62324 100644
--- a/src/kudu/tserver/tablet_copy_session-test.cc
+++ b/src/kudu/tserver/tablet_copy_session-test.cc
@@ -119,7 +119,7 @@ class TabletCopyTest : public KuduTabletTest {
     config.add_peers()->CopyFrom(config_peer);
     config.set_opid_index(consensus::kInvalidOpIdIndex);
 
-    gscoped_ptr<ConsensusMetadata> cmeta;
+    unique_ptr<ConsensusMetadata> cmeta;
     ASSERT_OK(ConsensusMetadata::Create(tablet()->metadata()->fs_manager(),
                                         tablet()->tablet_id(), fs_manager()->uuid(),
                                         config, consensus::kMinimumTerm, &cmeta));

http://git-wip-us.apache.org/repos/asf/kudu/blob/28a9902c/src/kudu/tserver/ts_tablet_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/ts_tablet_manager.cc b/src/kudu/tserver/ts_tablet_manager.cc
index 02ddd95..481f569 100644
--- a/src/kudu/tserver/ts_tablet_manager.cc
+++ b/src/kudu/tserver/ts_tablet_manager.cc
@@ -132,6 +132,7 @@ using master::TabletReportPB;
 using rpc::ResultTracker;
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using std::vector;
 using strings::Substitute;
 using tablet::Tablet;
@@ -291,7 +292,7 @@ Status TSTabletManager::CreateNewTablet(const string& table_id,
 
   // We must persist the consensus metadata to disk before starting a new
   // tablet's TabletPeer and Consensus implementation.
-  gscoped_ptr<ConsensusMetadata> cmeta;
+  unique_ptr<ConsensusMetadata> cmeta;
   RETURN_NOT_OK_PREPEND(ConsensusMetadata::Create(fs_manager_, tablet_id, fs_manager_->uuid(),
                                                   config, consensus::kMinimumTerm, &cmeta),
                         "Unable to create new ConsensusMeta for tablet " + tablet_id);


Mime
View raw message