kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject [2/5] kudu git commit: Rename TabletPeer to TabletReplica
Date Thu, 04 May 2017 22:14:27 GMT
http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tablet/transactions/write_transaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/write_transaction.cc b/src/kudu/tablet/transactions/write_transaction.cc
index 592635e..acec316 100644
--- a/src/kudu/tablet/transactions/write_transaction.cc
+++ b/src/kudu/tablet/transactions/write_transaction.cc
@@ -29,7 +29,7 @@
 #include "kudu/server/hybrid_clock.h"
 #include "kudu/tablet/row_op.h"
 #include "kudu/tablet/tablet.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tablet/tablet_metrics.h"
 #include "kudu/tserver/tserver.pb.h"
 #include "kudu/util/debug/trace_event.h"
@@ -86,7 +86,7 @@ Status WriteTransaction::Prepare() {
     return s;
   }
 
-  Tablet* tablet = state()->tablet_peer()->tablet();
+  Tablet* tablet = state()->tablet_replica()->tablet();
 
   Status s = tablet->DecodeWriteOperations(&client_schema, state());
   if (!s.ok()) {
@@ -112,8 +112,8 @@ Status WriteTransaction::Start() {
   DCHECK(!state_->has_timestamp());
   DCHECK(state_->consensus_round()->replicate_msg()->has_timestamp());
   state_->set_timestamp(Timestamp(state_->consensus_round()->replicate_msg()->timestamp()));
-  state_->tablet_peer()->tablet()->StartTransaction(state_.get());
-  TRACE("Timestamp: $0", state_->tablet_peer()->clock()->Stringify(state_->timestamp()));
+  state_->tablet_replica()->tablet()->StartTransaction(state_.get());
+  TRACE("Timestamp: $0", state_->tablet_replica()->clock()->Stringify(state_->timestamp()));
   return Status::OK();
 }
 
@@ -130,7 +130,7 @@ Status WriteTransaction::Apply(gscoped_ptr<CommitMsg>* commit_msg) {
     SleepFor(MonoDelta::FromMilliseconds(FLAGS_tablet_inject_latency_on_apply_write_txn_ms));
   }
 
-  Tablet* tablet = state()->tablet_peer()->tablet();
+  Tablet* tablet = state()->tablet_replica()->tablet();
 
   tablet->ApplyRowOperations(state());
 
@@ -171,7 +171,7 @@ void WriteTransaction::Finish(TransactionResult result) {
 
   TRACE("FINISH: updating metrics");
 
-  TabletMetrics* metrics = state_->tablet_peer()->tablet()->metrics();
+  TabletMetrics* metrics = state_->tablet_replica()->tablet()->metrics();
   if (metrics) {
     // TODO: should we change this so it's actually incremented by the
     // Tablet code itself instead of this wrapper code?
@@ -210,11 +210,11 @@ string WriteTransaction::ToString() const {
                     DriverType_Name(type()), abs_time_formatted, state_->ToString());
 }
 
-WriteTransactionState::WriteTransactionState(TabletPeer* tablet_peer,
+WriteTransactionState::WriteTransactionState(TabletReplica* tablet_replica,
                                              const tserver::WriteRequestPB *request,
                                              const rpc::RequestIdPB* request_id,
                                              tserver::WriteResponsePB *response)
-  : TransactionState(tablet_peer),
+  : TransactionState(tablet_replica),
     request_(DCHECK_NOTNULL(request)),
     response_(response),
     mvcc_tx_(nullptr),

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tablet/transactions/write_transaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/write_transaction.h b/src/kudu/tablet/transactions/write_transaction.h
index da03433..f8ea48d 100644
--- a/src/kudu/tablet/transactions/write_transaction.h
+++ b/src/kudu/tablet/transactions/write_transaction.h
@@ -73,7 +73,7 @@ struct TabletComponents;
 // NOTE: this class isn't thread safe.
 class WriteTransactionState : public TransactionState {
  public:
-  WriteTransactionState(TabletPeer* tablet_peer,
+  WriteTransactionState(TabletReplica* tablet_replica,
                         const tserver::WriteRequestPB *request,
                         const rpc::RequestIdPB* request_id,
                         tserver::WriteResponsePB *response = NULL);

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/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 d996e1e..1ffd090 100644
--- a/src/kudu/tools/kudu-tool-test.cc
+++ b/src/kudu/tools/kudu-tool-test.cc
@@ -57,7 +57,7 @@
 #include "kudu/tablet/local_tablet_writer.h"
 #include "kudu/tablet/tablet-harness.h"
 #include "kudu/tablet/tablet_metadata.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tablet/tablet.h"
 #include "kudu/tools/tool_action_common.h"
 #include "kudu/tools/tool_test_util.h"
@@ -107,7 +107,7 @@ using tablet::Tablet;
 using tablet::TabletDataState;
 using tablet::TabletHarness;
 using tablet::TabletMetadata;
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 using tablet::TabletSuperBlockPB;
 using tserver::DeleteTabletRequestPB;
 using tserver::DeleteTabletResponsePB;
@@ -1250,12 +1250,12 @@ TEST_F(ToolTest, TestLocalReplicaDelete) {
   // is reduced at all.
   string tablet_id;
   {
-    vector<scoped_refptr<TabletPeer>> tablet_peers;
-    ts->server()->tablet_manager()->GetTabletPeers(&tablet_peers);
-    ASSERT_EQ(1, tablet_peers.size());
-    Tablet* tablet = tablet_peers[0]->tablet();
+    vector<scoped_refptr<TabletReplica>> tablet_replicas;
+    ts->server()->tablet_manager()->GetTabletReplicas(&tablet_replicas);
+    ASSERT_EQ(1, tablet_replicas.size());
+    Tablet* tablet = tablet_replicas[0]->tablet();
     ASSERT_OK(tablet->Flush());
-    tablet_id = tablet_peers[0]->tablet_id();
+    tablet_id = tablet_replicas[0]->tablet_id();
   }
   const string& tserver_dir = ts->options()->fs_opts.wal_path;
   // Using the delete tool with tablet server running fails.
@@ -1297,9 +1297,9 @@ TEST_F(ToolTest, TestLocalReplicaDelete) {
   // we can expect the tablet server to have nothing after it comes up.
   ASSERT_OK(ts->Start());
   ASSERT_OK(ts->WaitStarted());
-  vector<scoped_refptr<TabletPeer>> tablet_peers;
-  ts->server()->tablet_manager()->GetTabletPeers(&tablet_peers);
-  ASSERT_EQ(0, tablet_peers.size());
+  vector<scoped_refptr<TabletReplica>> tablet_replicas;
+  ts->server()->tablet_manager()->GetTabletReplicas(&tablet_replicas);
+  ASSERT_EQ(0, tablet_replicas.size());
 }
 
 // Test 'kudu local_replica delete' tool for tombstoning the tablet.
@@ -1330,12 +1330,12 @@ TEST_F(ToolTest, TestLocalReplicaTombstoneDelete) {
   last_logged_opid.Clear();
   string tablet_id;
   {
-    vector<scoped_refptr<TabletPeer>> tablet_peers;
-    ts->server()->tablet_manager()->GetTabletPeers(&tablet_peers);
-    ASSERT_EQ(1, tablet_peers.size());
-    tablet_id = tablet_peers[0]->tablet_id();
-    tablet_peers[0]->log()->GetLatestEntryOpId(&last_logged_opid);
-    Tablet* tablet = tablet_peers[0]->tablet();
+    vector<scoped_refptr<TabletReplica>> tablet_replicas;
+    ts->server()->tablet_manager()->GetTabletReplicas(&tablet_replicas);
+    ASSERT_EQ(1, tablet_replicas.size());
+    tablet_id = tablet_replicas[0]->tablet_id();
+    tablet_replicas[0]->log()->GetLatestEntryOpId(&last_logged_opid);
+    Tablet* tablet = tablet_replicas[0]->tablet();
     ASSERT_OK(tablet->Flush());
   }
   const string& tserver_dir = ts->options()->fs_opts.wal_path;
@@ -1362,13 +1362,13 @@ TEST_F(ToolTest, TestLocalReplicaTombstoneDelete) {
   ASSERT_OK(ts->Start());
   ASSERT_OK(ts->WaitStarted());
   {
-    vector<scoped_refptr<TabletPeer>> tablet_peers;
-    ts->server()->tablet_manager()->GetTabletPeers(&tablet_peers);
-    ASSERT_EQ(1, tablet_peers.size());
-    ASSERT_EQ(tablet_id, tablet_peers[0]->tablet_id());
+    vector<scoped_refptr<TabletReplica>> tablet_replicas;
+    ts->server()->tablet_manager()->GetTabletReplicas(&tablet_replicas);
+    ASSERT_EQ(1, tablet_replicas.size());
+    ASSERT_EQ(tablet_id, tablet_replicas[0]->tablet_id());
     ASSERT_EQ(TabletDataState::TABLET_DATA_TOMBSTONED,
-              tablet_peers[0]->tablet_metadata()->tablet_data_state());
-    OpId tombstoned_opid = tablet_peers[0]->tablet_metadata()->tombstone_last_logged_opid();
+              tablet_replicas[0]->tablet_metadata()->tablet_data_state());
+    OpId tombstoned_opid = tablet_replicas[0]->tablet_metadata()->tombstone_last_logged_opid();
     ASSERT_TRUE(tombstoned_opid.IsInitialized());
     ASSERT_EQ(last_logged_opid.term(), tombstoned_opid.term());
     ASSERT_EQ(last_logged_opid.index(), tombstoned_opid.index());

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/scanners-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners-test.cc b/src/kudu/tserver/scanners-test.cc
index 5541bc3..f0b7473 100644
--- a/src/kudu/tserver/scanners-test.cc
+++ b/src/kudu/tserver/scanners-test.cc
@@ -19,7 +19,7 @@
 #include <vector>
 
 #include <gtest/gtest.h>
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tserver/scanner_metrics.h"
 #include "kudu/tserver/tserver.pb.h"
 #include "kudu/util/metrics.h"
@@ -29,20 +29,20 @@ DECLARE_int32(scanner_ttl_ms);
 
 namespace kudu {
 
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 
 namespace tserver {
 
 using std::vector;
 
 TEST(ScannersTest, TestManager) {
-  scoped_refptr<TabletPeer> null_peer(nullptr);
+  scoped_refptr<TabletReplica> null_replica(nullptr);
   ScannerManager mgr(nullptr);
 
   // Create two scanners, make sure their ids are different.
   SharedScanner s1, s2;
-  mgr.NewScanner(null_peer, "", RowFormatFlags::NO_FLAGS, &s1);
-  mgr.NewScanner(null_peer, "", RowFormatFlags::NO_FLAGS, &s2);
+  mgr.NewScanner(null_replica, "", RowFormatFlags::NO_FLAGS, &s1);
+  mgr.NewScanner(null_replica, "", RowFormatFlags::NO_FLAGS, &s2);
   ASSERT_NE(s1->id(), s2->id());
 
   // Check that they're both registered.
@@ -65,13 +65,13 @@ TEST(ScannersTest, TestManager) {
 }
 
 TEST(ScannerTest, TestExpire) {
-  scoped_refptr<TabletPeer> null_peer(nullptr);
+  scoped_refptr<TabletReplica> null_replica(nullptr);
   FLAGS_scanner_ttl_ms = 100;
   MetricRegistry registry;
   ScannerManager mgr(METRIC_ENTITY_server.Instantiate(&registry, "test"));
   SharedScanner s1, s2;
-  mgr.NewScanner(null_peer, "", RowFormatFlags::NO_FLAGS, &s1);
-  mgr.NewScanner(null_peer, "", RowFormatFlags::NO_FLAGS, &s2);
+  mgr.NewScanner(null_replica, "", RowFormatFlags::NO_FLAGS, &s1);
+  mgr.NewScanner(null_replica, "", RowFormatFlags::NO_FLAGS, &s2);
   SleepFor(MonoDelta::FromMilliseconds(200));
   s2->UpdateAccessTime();
   mgr.RemoveExpiredScanners();

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/scanners.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.cc b/src/kudu/tserver/scanners.cc
index ec0f77c..6dd8295 100644
--- a/src/kudu/tserver/scanners.cc
+++ b/src/kudu/tserver/scanners.cc
@@ -49,7 +49,7 @@ using strings::Substitute;
 
 namespace kudu {
 
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 
 namespace tserver {
 
@@ -106,7 +106,7 @@ ScannerManager::ScannerMapStripe& ScannerManager::GetStripeByScannerId(const str
   return *scanner_maps_[slot];
 }
 
-void ScannerManager::NewScanner(const scoped_refptr<TabletPeer>& tablet_peer,
+void ScannerManager::NewScanner(const scoped_refptr<TabletReplica>& tablet_replica,
                                 const std::string& requestor_string,
                                 uint64 row_format_flags,
                                 SharedScanner* scanner) {
@@ -119,7 +119,7 @@ void ScannerManager::NewScanner(const scoped_refptr<TabletPeer>& tablet_peer,
     // verify that the requestor userid does not change mid-scan.
     string id = oid_generator_.Next();
     scanner->reset(new Scanner(id,
-                               tablet_peer,
+                               tablet_replica,
                                requestor_string,
                                metrics_.get(),
                                row_format_flags));
@@ -192,11 +192,11 @@ void ScannerManager::RemoveExpiredScanners() {
 
 const std::string Scanner::kNullTabletId = "null tablet";
 
-Scanner::Scanner(string id, const scoped_refptr<TabletPeer>& tablet_peer,
+Scanner::Scanner(string id, const scoped_refptr<TabletReplica>& tablet_replica,
                  string requestor_string, ScannerMetrics* metrics,
                  uint64_t row_format_flags)
     : id_(std::move(id)),
-      tablet_peer_(tablet_peer),
+      tablet_replica_(tablet_replica),
       requestor_string_(std::move(requestor_string)),
       call_seq_id_(0),
       start_time_(MonoTime::Now()),

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/scanners.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.h b/src/kudu/tserver/scanners.h
index 1204860..5e425b2 100644
--- a/src/kudu/tserver/scanners.h
+++ b/src/kudu/tserver/scanners.h
@@ -28,7 +28,7 @@
 #include "kudu/gutil/gscoped_ptr.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/ref_counted.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/util/auto_release_pool.h"
 #include "kudu/util/memory/arena.h"
 #include "kudu/util/metrics.h"
@@ -71,7 +71,7 @@ class ScannerManager {
   Status StartRemovalThread();
 
   // Create a new scanner with a unique ID, inserting it into the map.
-  void NewScanner(const scoped_refptr<tablet::TabletPeer>& tablet_peer,
+  void NewScanner(const scoped_refptr<tablet::TabletReplica>& tablet_replica,
                   const std::string& requestor_string,
                   uint64_t row_format_flags,
                   SharedScanner* scanner);
@@ -169,7 +169,7 @@ class ScopedUnregisterScanner {
 class Scanner {
  public:
   Scanner(std::string id,
-          const scoped_refptr<tablet::TabletPeer>& tablet_peer,
+          const scoped_refptr<tablet::TabletReplica>& tablet_replica,
           std::string requestor_string, ScannerMetrics* metrics,
           uint64_t row_format_flags);
   ~Scanner();
@@ -217,11 +217,11 @@ class Scanner {
   const ScanSpec& spec() const;
 
   const std::string& tablet_id() const {
-    // scanners-test passes a null tablet_peer.
-    return tablet_peer_ ? tablet_peer_->tablet_id() : kNullTabletId;
+    // scanners-test passes a null tablet_replica.
+    return tablet_replica_ ? tablet_replica_->tablet_id() : kNullTabletId;
   }
 
-  const scoped_refptr<tablet::TabletPeer>& tablet_peer() const { return tablet_peer_; }
+  const scoped_refptr<tablet::TabletReplica>& tablet_replica() const { return tablet_replica_; }
 
   const std::string& requestor_string() const { return requestor_string_; }
 
@@ -287,7 +287,7 @@ class Scanner {
   const std::string id_;
 
   // Tablet associated with the scanner.
-  const scoped_refptr<tablet::TabletPeer> tablet_peer_;
+  const scoped_refptr<tablet::TabletReplica> tablet_replica_;
 
   // Information about the requestor. Populated from
   // RpcContext::requestor_string().

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy-test-base.h b/src/kudu/tserver/tablet_copy-test-base.h
index bb9bc45..6e14d30 100644
--- a/src/kudu/tserver/tablet_copy-test-base.h
+++ b/src/kudu/tserver/tablet_copy-test-base.h
@@ -47,13 +47,13 @@ class TabletCopyTest : public TabletServerTestBase {
     // to test that we are anchoring correctly. Since GenerateTestData() does a
     // Flush(), Log GC is allowed to eat the logs before we get around to
     // starting a tablet copy session.
-    tablet_peer_->log_anchor_registry()->Register(
+    tablet_replica_->log_anchor_registry()->Register(
         consensus::MinimumOpId().index(), CURRENT_TEST_NAME(), &anchor_);
     NO_FATALS(GenerateTestData());
   }
 
   virtual void TearDown() OVERRIDE {
-    ASSERT_OK(tablet_peer_->log_anchor_registry()->Unregister(&anchor_));
+    ASSERT_OK(tablet_replica_->log_anchor_registry()->Unregister(&anchor_));
     NO_FATALS(TabletServerTestBase::TearDown());
   }
 
@@ -106,19 +106,19 @@ class TabletCopyTest : public TabletServerTestBase {
     LOG_TIMING(INFO, "Loading test data") {
       for (int row_id = 0; row_id < kNumLogRolls * kIncr; row_id += kIncr) {
         InsertTestRowsRemote(0, row_id, kIncr);
-        ASSERT_OK(tablet_peer_->tablet()->Flush());
-        ASSERT_OK(tablet_peer_->log()->AllocateSegmentAndRollOver());
+        ASSERT_OK(tablet_replica_->tablet()->Flush());
+        ASSERT_OK(tablet_replica_->log()->AllocateSegmentAndRollOver());
       }
     }
   }
 
   // Return the permananent_uuid of the local service.
   const std::string GetLocalUUID() const {
-    return tablet_peer_->permanent_uuid();
+    return tablet_replica_->permanent_uuid();
   }
 
   const std::string& GetTabletId() const {
-    return tablet_peer_->tablet()->tablet_id();
+    return tablet_replica_->tablet()->tablet_id();
   }
 
   // Read a block file from the file system fully into memory and return a

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_client-test.cc b/src/kudu/tserver/tablet_copy_client-test.cc
index cf6cdd5..7c70688 100644
--- a/src/kudu/tserver/tablet_copy_client-test.cc
+++ b/src/kudu/tserver/tablet_copy_client-test.cc
@@ -46,12 +46,12 @@ class TabletCopyClientTest : public TabletCopyTest {
     ASSERT_OK(fs_manager_->CreateInitialFileSystemLayout());
     ASSERT_OK(fs_manager_->Open());
 
-    tablet_peer_->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10.0));
+    tablet_replica_->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10.0));
     rpc::MessengerBuilder(CURRENT_TEST_NAME()).Build(&messenger_);
     client_.reset(new TabletCopyClient(GetTabletId(),
                                        fs_manager_.get(),
                                        messenger_));
-    ASSERT_OK(GetRaftConfigLeader(tablet_peer_->consensus()
+    ASSERT_OK(GetRaftConfigLeader(tablet_replica_->consensus()
         ->ConsensusState(consensus::CONSENSUS_CONFIG_COMMITTED), &leader_));
 
     HostPort host_port;
@@ -139,7 +139,7 @@ TEST_F(TabletCopyClientTest, TestDownloadWalSegment) {
   ASSERT_TRUE(fs_manager_->Exists(path));
 
   log::SegmentSequence local_segments;
-  ASSERT_OK(tablet_peer_->log()->reader()->GetSegmentsSnapshot(&local_segments));
+  ASSERT_OK(tablet_replica_->log()->reader()->GetSegmentsSnapshot(&local_segments));
   const scoped_refptr<log::ReadableLogSegment>& segment = local_segments[0];
   string server_path = segment->path();
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/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 495074f..21c5630 100644
--- a/src/kudu/tserver/tablet_copy_client.cc
+++ b/src/kudu/tserver/tablet_copy_client.cc
@@ -34,7 +34,7 @@
 #include "kudu/rpc/transfer.h"
 #include "kudu/tablet/tablet.pb.h"
 #include "kudu/tablet/tablet_bootstrap.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tserver/tablet_copy.pb.h"
 #include "kudu/tserver/tablet_copy.proxy.h"
 #include "kudu/tserver/tablet_server.h"

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/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 3545915..259196f 100644
--- a/src/kudu/tserver/tablet_copy_client.h
+++ b/src/kudu/tserver/tablet_copy_client.h
@@ -49,7 +49,7 @@ class RpcController;
 
 namespace tablet {
 class TabletMetadata;
-class TabletPeer;
+class TabletReplica;
 class TabletStatusListener;
 class TabletSuperBlockPB;
 } // namespace tablet

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_service-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_service-test.cc b/src/kudu/tserver/tablet_copy_service-test.cc
index 72346f9..420bd28 100644
--- a/src/kudu/tserver/tablet_copy_service-test.cc
+++ b/src/kudu/tserver/tablet_copy_service-test.cc
@@ -443,7 +443,7 @@ TEST_F(TabletCopyServiceTest, TestFetchLog) {
 
   // Fetch the local data.
   log::SegmentSequence local_segments;
-  ASSERT_OK(tablet_peer_->log()->reader()->GetSegmentsSnapshot(&local_segments));
+  ASSERT_OK(tablet_replica_->log()->reader()->GetSegmentsSnapshot(&local_segments));
 
   uint64_t first_seg_seqno = (*local_segments.begin())->header().sequence_number();
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_service.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_service.cc b/src/kudu/tserver/tablet_copy_service.cc
index 74a34c5..cc5016b 100644
--- a/src/kudu/tserver/tablet_copy_service.cc
+++ b/src/kudu/tserver/tablet_copy_service.cc
@@ -30,8 +30,8 @@
 #include "kudu/rpc/rpc_context.h"
 #include "kudu/server/server_base.h"
 #include "kudu/tserver/tablet_copy_source_session.h"
-#include "kudu/tserver/tablet_peer_lookup.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tserver/tablet_replica_lookup.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/util/crc.h"
 #include "kudu/util/fault_injection.h"
 #include "kudu/util/flag_tags.h"
@@ -74,7 +74,7 @@ namespace kudu {
 
 using crc::Crc32c;
 using server::ServerBase;
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 
 namespace tserver {
 
@@ -84,11 +84,11 @@ static MonoTime GetNewExpireTime() {
 
 TabletCopyServiceImpl::TabletCopyServiceImpl(
     ServerBase* server,
-    TabletPeerLookupIf* tablet_peer_lookup)
+    TabletReplicaLookupIf* tablet_replica_lookup)
     : TabletCopyServiceIf(server->metric_entity(), server->result_tracker()),
       server_(server),
       fs_manager_(CHECK_NOTNULL(server->fs_manager())),
-      tablet_peer_lookup_(CHECK_NOTNULL(tablet_peer_lookup)),
+      tablet_replica_lookup_(CHECK_NOTNULL(tablet_replica_lookup)),
       rand_(GetRandomSeed32()),
       shutdown_latch_(1) {
   CHECK_OK(Thread::Create("tablet-copy", "tc-session-exp",
@@ -117,8 +117,8 @@ void TabletCopyServiceImpl::BeginTabletCopySession(
   // but there is no guarantee this will not change in the future.
   const string session_id = Substitute("$0-$1", requestor_uuid, tablet_id);
 
-  scoped_refptr<TabletPeer> tablet_peer;
-  RPC_RETURN_NOT_OK(tablet_peer_lookup_->GetTabletPeer(tablet_id, &tablet_peer),
+  scoped_refptr<TabletReplica> tablet_replica;
+  RPC_RETURN_NOT_OK(tablet_replica_lookup_->GetTabletReplica(tablet_id, &tablet_replica),
                     TabletCopyErrorPB::TABLET_NOT_FOUND,
                     Substitute("Unable to find specified tablet: $0", tablet_id),
                     context);
@@ -132,7 +132,7 @@ void TabletCopyServiceImpl::BeginTabletCopySession(
           "Beginning new tablet copy session on tablet $0 from peer $1"
           " at $2: session id = $3",
           tablet_id, requestor_uuid, context->requestor_string(), session_id);
-      session.reset(new TabletCopySourceSession(tablet_peer, session_id,
+      session.reset(new TabletCopySourceSession(tablet_replica, session_id,
                                                 requestor_uuid, fs_manager_));
       RPC_RETURN_NOT_OK(session->Init(),
                         TabletCopyErrorPB::UNKNOWN_ERROR,

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_service.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_service.h b/src/kudu/tserver/tablet_copy_service.h
index 81b1be2..c4f701e 100644
--- a/src/kudu/tserver/tablet_copy_service.h
+++ b/src/kudu/tserver/tablet_copy_service.h
@@ -45,12 +45,12 @@ class ReadableLogSegment;
 namespace tserver {
 
 class TabletCopySourceSession;
-class TabletPeerLookupIf;
+class TabletReplicaLookupIf;
 
 class TabletCopyServiceImpl : public TabletCopyServiceIf {
  public:
   TabletCopyServiceImpl(server::ServerBase* server,
-                        TabletPeerLookupIf* tablet_peer_lookup);
+                        TabletReplicaLookupIf* tablet_replica_lookup);
 
   bool AuthorizeServiceUser(const google::protobuf::Message* req,
                             google::protobuf::Message* resp,
@@ -112,7 +112,7 @@ class TabletCopyServiceImpl : public TabletCopyServiceIf {
 
   server::ServerBase* server_;
   FsManager* fs_manager_;
-  TabletPeerLookupIf* tablet_peer_lookup_;
+  TabletReplicaLookupIf* tablet_replica_lookup_;
 
   // Protects sessions_ map.
   mutable Mutex sessions_lock_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_source_session-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session-test.cc b/src/kudu/tserver/tablet_copy_source_session-test.cc
index 80d270a..5c34774 100644
--- a/src/kudu/tserver/tablet_copy_source_session-test.cc
+++ b/src/kudu/tserver/tablet_copy_source_session-test.cc
@@ -34,7 +34,7 @@
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/rpc/messenger.h"
 #include "kudu/tserver/tablet_copy_source_session.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/util/crc.h"
 #include "kudu/util/metrics.h"
 #include "kudu/util/pb_util.h"
@@ -64,7 +64,7 @@ using tablet::ColumnDataPB;
 using tablet::DeltaDataPB;
 using tablet::KuduTabletTest;
 using tablet::RowSetDataPB;
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 using tablet::TabletSuperBlockPB;
 using tablet::WriteTransactionState;
 
@@ -78,19 +78,19 @@ class TabletCopyTest : public KuduTabletTest {
 
   virtual void SetUp() OVERRIDE {
     NO_FATALS(KuduTabletTest::SetUp());
-    NO_FATALS(SetUpTabletPeer());
+    NO_FATALS(SetUpTabletReplica());
     NO_FATALS(PopulateTablet());
     NO_FATALS(InitSession());
   }
 
   virtual void TearDown() OVERRIDE {
     session_.reset();
-    tablet_peer_->Shutdown();
+    tablet_replica_->Shutdown();
     KuduTabletTest::TearDown();
   }
 
  protected:
-  void SetUpTabletPeer() {
+  void SetUpTabletReplica() {
     scoped_refptr<Log> log;
     ASSERT_OK(Log::Open(LogOptions(), fs_manager(), tablet()->tablet_id(),
                         *tablet()->schema(),
@@ -106,15 +106,15 @@ class TabletCopyTest : public KuduTabletTest {
     config_peer.mutable_last_known_addr()->set_port(0);
     config_peer.set_member_type(RaftPeerPB::VOTER);
 
-    tablet_peer_.reset(
-        new TabletPeer(tablet()->metadata(),
-                       config_peer,
-                       apply_pool_.get(),
-                       Bind(&TabletCopyTest::TabletPeerStateChangedCallback,
-                            Unretained(this),
-                            tablet()->tablet_id())));
+    tablet_replica_.reset(
+        new TabletReplica(tablet()->metadata(),
+                          config_peer,
+                          apply_pool_.get(),
+                          Bind(&TabletCopyTest::TabletReplicaStateChangedCallback,
+                               Unretained(this),
+                               tablet()->tablet_id())));
 
-    // TODO(dralves) similar to code in tablet_peer-test, consider refactor.
+    // TODO(dralves) similar to code in tablet_replica-test, consider refactor.
     RaftConfigPB config;
     config.add_peers()->CopyFrom(config_peer);
     config.set_opid_index(consensus::kInvalidOpIdIndex);
@@ -129,27 +129,27 @@ class TabletCopyTest : public KuduTabletTest {
     mbuilder.Build(&messenger);
 
     log_anchor_registry_.reset(new LogAnchorRegistry());
-    tablet_peer_->SetBootstrapping();
-    ASSERT_OK(tablet_peer_->Init(tablet(),
+    tablet_replica_->SetBootstrapping();
+    ASSERT_OK(tablet_replica_->Init(tablet(),
                                  clock(),
                                  messenger,
                                  scoped_refptr<rpc::ResultTracker>(),
                                  log,
                                  metric_entity));
     consensus::ConsensusBootstrapInfo boot_info;
-    ASSERT_OK(tablet_peer_->Start(boot_info));
-    ASSERT_OK(tablet_peer_->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10)));
-    ASSERT_OK(tablet_peer_->consensus()->WaitUntilLeaderForTests(MonoDelta::FromSeconds(10)));
+    ASSERT_OK(tablet_replica_->Start(boot_info));
+    ASSERT_OK(tablet_replica_->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10)));
+    ASSERT_OK(tablet_replica_->consensus()->WaitUntilLeaderForTests(MonoDelta::FromSeconds(10)));
   }
 
-  void TabletPeerStateChangedCallback(const string& tablet_id, const string& reason) {
-    LOG(INFO) << "Tablet peer state changed for tablet " << tablet_id << ". Reason: " << reason;
+  void TabletReplicaStateChangedCallback(const string& tablet_id, const string& reason) {
+    LOG(INFO) << "Tablet replica state changed for tablet " << tablet_id << ". Reason: " << reason;
   }
 
   void PopulateTablet() {
     for (int32_t i = 0; i < 1000; i++) {
       WriteRequestPB req;
-      req.set_tablet_id(tablet_peer_->tablet_id());
+      req.set_tablet_id(tablet_replica_->tablet_id());
       ASSERT_OK(SchemaToPB(client_schema_, req.mutable_schema()));
       RowOperationsPB* data = req.mutable_row_operations();
       RowOperationsPBEncoder enc(data);
@@ -164,13 +164,13 @@ class TabletCopyTest : public KuduTabletTest {
       CountDownLatch latch(1);
 
       unique_ptr<tablet::WriteTransactionState> state(
-          new tablet::WriteTransactionState(tablet_peer_.get(),
+          new tablet::WriteTransactionState(tablet_replica_.get(),
                                             &req,
                                             nullptr, // No RequestIdPB
                                             &resp));
       state->set_completion_callback(gscoped_ptr<tablet::TransactionCompletionCallback>(
           new tablet::LatchTransactionCompletionCallback<WriteResponsePB>(&latch, &resp)));
-      ASSERT_OK(tablet_peer_->SubmitWrite(std::move(state)));
+      ASSERT_OK(tablet_replica_->SubmitWrite(std::move(state)));
       latch.Wait();
       ASSERT_FALSE(resp.has_error()) << "Request failed: " << SecureShortDebugString(resp.error());
       ASSERT_EQ(0, resp.per_row_errors_size()) << "Insert error: " << SecureShortDebugString(resp);
@@ -179,7 +179,7 @@ class TabletCopyTest : public KuduTabletTest {
   }
 
   void InitSession() {
-    session_.reset(new TabletCopySourceSession(tablet_peer_.get(), "TestSession", "FakeUUID",
+    session_.reset(new TabletCopySourceSession(tablet_replica_.get(), "TestSession", "FakeUUID",
                    fs_manager()));
     ASSERT_OK(session_->Init());
   }
@@ -214,7 +214,7 @@ class TabletCopyTest : public KuduTabletTest {
   MetricRegistry metric_registry_;
   scoped_refptr<LogAnchorRegistry> log_anchor_registry_;
   gscoped_ptr<ThreadPool> apply_pool_;
-  scoped_refptr<TabletPeer> tablet_peer_;
+  scoped_refptr<TabletReplica> tablet_replica_;
   scoped_refptr<TabletCopySourceSession> session_;
 };
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_source_session.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session.cc b/src/kudu/tserver/tablet_copy_source_session.cc
index 17b73f7..6021e85 100644
--- a/src/kudu/tserver/tablet_copy_source_session.cc
+++ b/src/kudu/tserver/tablet_copy_source_session.cc
@@ -27,7 +27,7 @@
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/gutil/type_traits.h"
 #include "kudu/rpc/transfer.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/util/flag_tags.h"
 #include "kudu/util/mutex.h"
 #include "kudu/util/pb_util.h"
@@ -50,12 +50,12 @@ using std::shared_ptr;
 using std::unique_ptr;
 using strings::Substitute;
 using tablet::TabletMetadata;
-using tablet::TabletPeer;
+using tablet::TabletReplica;
 
 TabletCopySourceSession::TabletCopySourceSession(
-    const scoped_refptr<TabletPeer>& tablet_peer, std::string session_id,
+    const scoped_refptr<TabletReplica>& tablet_replica, std::string session_id,
     std::string requestor_uuid, FsManager* fs_manager)
-    : tablet_peer_(tablet_peer),
+    : tablet_replica_(tablet_replica),
       session_id_(std::move(session_id)),
       requestor_uuid_(std::move(requestor_uuid)),
       fs_manager_(fs_manager),
@@ -71,17 +71,17 @@ Status TabletCopySourceSession::Init() {
   MutexLock l(session_lock_);
   CHECK(!initted_);
 
-  RETURN_NOT_OK(tablet_peer_->CheckRunning());
+  RETURN_NOT_OK(tablet_replica_->CheckRunning());
 
-  const string& tablet_id = tablet_peer_->tablet_id();
+  const string& tablet_id = tablet_replica_->tablet_id();
 
   // Prevent log GC while we grab log segments and Tablet metadata.
   string anchor_owner_token = Substitute("TabletCopy-$0", session_id_);
-  tablet_peer_->log_anchor_registry()->Register(
+  tablet_replica_->log_anchor_registry()->Register(
       MinimumOpId().index(), anchor_owner_token, &log_anchor_);
 
   // Read the SuperBlock from disk.
-  const scoped_refptr<TabletMetadata>& metadata = tablet_peer_->tablet_metadata();
+  const scoped_refptr<TabletMetadata>& metadata = tablet_replica_->tablet_metadata();
   RETURN_NOT_OK_PREPEND(metadata->ReadSuperBlockFromDisk(&tablet_superblock_),
                         Substitute("Unable to access superblock for tablet $0",
                                    tablet_id));
@@ -98,14 +98,14 @@ Status TabletCopySourceSession::Init() {
 
   // Get the latest opid in the log at this point in time so we can re-anchor.
   OpId last_logged_opid;
-  CHECK_NOTNULL(tablet_peer_->log())->GetLatestEntryOpId(&last_logged_opid);
+  CHECK_NOTNULL(tablet_replica_->log())->GetLatestEntryOpId(&last_logged_opid);
 
   // Get the current segments from the log, including the active segment.
   // The Log doesn't add the active segment to the log reader's list until
   // a header has been written to it (but it will not have a footer).
-  shared_ptr<log::LogReader> reader = tablet_peer_->log()->reader();
+  shared_ptr<log::LogReader> reader = tablet_replica_->log()->reader();
   if (!reader) {
-    tablet::TabletStatePB tablet_state = tablet_peer_->state();
+    tablet::TabletStatePB tablet_state = tablet_replica_->state();
     return Status::IllegalState(Substitute(
         "Unable to initialize tablet copy session for tablet $0. "
         "Log reader is not available. Tablet state: $1 ($2)",
@@ -120,9 +120,9 @@ Status TabletCopySourceSession::Init() {
   // We do this after snapshotting the log to avoid a scenario where the latest
   // entry in the log has a term higher than the term stored in the consensus
   // metadata, which will results in a CHECK failure on RaftConsensus init.
-  scoped_refptr<consensus::Consensus> consensus = tablet_peer_->shared_consensus();
+  scoped_refptr<consensus::Consensus> consensus = tablet_replica_->shared_consensus();
   if (!consensus) {
-    tablet::TabletStatePB tablet_state = tablet_peer_->state();
+    tablet::TabletStatePB tablet_state = tablet_replica_->state();
     return Status::IllegalState(Substitute(
         "Unable to initialize tablet copy session for tablet $0. "
         "Consensus is not available. Tablet state: $1 ($2)",
@@ -135,7 +135,7 @@ Status TabletCopySourceSession::Init() {
   // tablet copy loop due to a follower falling too far behind the
   // leader's log when tablet copy is slow. The remote controls when
   // this anchor is released by ending the tablet copy session.
-  RETURN_NOT_OK(tablet_peer_->log_anchor_registry()->UpdateRegistration(
+  RETURN_NOT_OK(tablet_replica_->log_anchor_registry()->UpdateRegistration(
       last_logged_opid.index(), anchor_owner_token, &log_anchor_));
 
   LOG(INFO) << Substitute(
@@ -147,7 +147,7 @@ Status TabletCopySourceSession::Init() {
 
 const std::string& TabletCopySourceSession::tablet_id() const {
   DCHECK(initted_);
-  return tablet_peer_->tablet_id();
+  return tablet_replica_->tablet_id();
 }
 
 const std::string& TabletCopySourceSession::requestor_uuid() const {
@@ -377,7 +377,7 @@ Status TabletCopySourceSession::FindLogSegment(uint64_t segment_seqno,
 }
 
 Status TabletCopySourceSession::UnregisterAnchorIfNeededUnlocked() {
-  return tablet_peer_->log_anchor_registry()->UnregisterIfAnchored(&log_anchor_);
+  return tablet_replica_->log_anchor_registry()->UnregisterIfAnchored(&log_anchor_);
 }
 
 } // namespace tserver

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_copy_source_session.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session.h b/src/kudu/tserver/tablet_copy_source_session.h
index 0d8aad1..2615869 100644
--- a/src/kudu/tserver/tablet_copy_source_session.h
+++ b/src/kudu/tserver/tablet_copy_source_session.h
@@ -41,12 +41,12 @@ namespace kudu {
 class FsManager;
 
 namespace tablet {
-class TabletPeer;
+class TabletReplica;
 } // namespace tablet
 
 namespace tserver {
 
-class TabletPeerLookupIf;
+class TabletReplicaLookupIf;
 
 // Caches file size and holds a shared_ptr reference to a RandomAccessFile.
 // Assumes that the file underlying the RandomAccessFile is immutable.
@@ -86,9 +86,9 @@ struct ImmutableReadableBlockInfo {
 // on expiration while it is in use by another thread.
 class TabletCopySourceSession : public RefCountedThreadSafe<TabletCopySourceSession> {
  public:
-  TabletCopySourceSession(const scoped_refptr<tablet::TabletPeer>& tablet_peer,
-                         std::string session_id, std::string requestor_uuid,
-                         FsManager* fs_manager);
+  TabletCopySourceSession(const scoped_refptr<tablet::TabletReplica>& tablet_replica,
+                          std::string session_id, std::string requestor_uuid,
+                          FsManager* fs_manager);
 
   // Initialize the session, including anchoring files (TODO) and fetching the
   // tablet superblock and list of WAL segments.
@@ -172,7 +172,7 @@ class TabletCopySourceSession : public RefCountedThreadSafe<TabletCopySourceSess
   // Unregister log anchor, if it's registered.
   Status UnregisterAnchorIfNeededUnlocked();
 
-  scoped_refptr<tablet::TabletPeer> tablet_peer_;
+  scoped_refptr<tablet::TabletReplica> tablet_replica_;
   const std::string session_id_;
   const std::string requestor_uuid_;
   FsManager* const fs_manager_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_peer_lookup.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_peer_lookup.h b/src/kudu/tserver/tablet_peer_lookup.h
deleted file mode 100644
index 70901fd..0000000
--- a/src/kudu/tserver/tablet_peer_lookup.h
+++ /dev/null
@@ -1,63 +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.
-#ifndef KUDU_TSERVER_TABLET_PEER_LOOKUP_H_
-#define KUDU_TSERVER_TABLET_PEER_LOOKUP_H_
-
-#include <boost/optional/optional_fwd.hpp>
-#include <functional>
-#include <memory>
-#include <string>
-
-#include "kudu/gutil/ref_counted.h"
-#include "kudu/tserver/tserver.pb.h"
-#include "kudu/util/status.h"
-
-namespace kudu {
-
-class HostPort;
-class NodeInstancePB;
-
-namespace consensus {
-class StartTabletCopyRequestPB;
-} // namespace consensus
-
-namespace tablet {
-class TabletPeer;
-} // namespace tablet
-
-namespace tserver {
-
-// Pure virtual interface that provides an abstraction for something that
-// contains and manages TabletPeers. This interface is implemented on both
-// tablet servers and master servers.
-// TODO: Rename this interface.
-class TabletPeerLookupIf {
- public:
-  virtual Status GetTabletPeer(const std::string& tablet_id,
-                               scoped_refptr<tablet::TabletPeer>* tablet_peer) const = 0;
-
-  virtual const NodeInstancePB& NodeInstance() const = 0;
-
-  virtual void StartTabletCopy(
-      const consensus::StartTabletCopyRequestPB* req,
-      std::function<void(const Status&, TabletServerErrorPB::Code)> cb) = 0;
-};
-
-} // namespace tserver
-} // namespace kudu
-
-#endif // KUDU_TSERVER_TABLET_PEER_LOOKUP_H_

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_replica_lookup.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_replica_lookup.h b/src/kudu/tserver/tablet_replica_lookup.h
new file mode 100644
index 0000000..6e91af2
--- /dev/null
+++ b/src/kudu/tserver/tablet_replica_lookup.h
@@ -0,0 +1,63 @@
+// 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 KUDU_TSERVER_TABLET_REPLICA_LOOKUP_H_
+#define KUDU_TSERVER_TABLET_REPLICA_LOOKUP_H_
+
+#include <boost/optional/optional_fwd.hpp>
+#include <functional>
+#include <memory>
+#include <string>
+
+#include "kudu/gutil/ref_counted.h"
+#include "kudu/tserver/tserver.pb.h"
+#include "kudu/util/status.h"
+
+namespace kudu {
+
+class HostPort;
+class NodeInstancePB;
+
+namespace consensus {
+class StartTabletCopyRequestPB;
+} // namespace consensus
+
+namespace tablet {
+class TabletReplica;
+} // namespace tablet
+
+namespace tserver {
+
+// Pure virtual interface that provides an abstraction for something that
+// contains and manages TabletReplicas. This interface is implemented on both
+// tablet servers and master servers.
+// TODO: Rename this interface.
+class TabletReplicaLookupIf {
+ public:
+  virtual Status GetTabletReplica(const std::string& tablet_id,
+                                  scoped_refptr<tablet::TabletReplica>* tablet_replica) const = 0;
+
+  virtual const NodeInstancePB& NodeInstance() const = 0;
+
+  virtual void StartTabletCopy(
+      const consensus::StartTabletCopyRequestPB* req,
+      std::function<void(const Status&, TabletServerErrorPB::Code)> cb) = 0;
+};
+
+} // namespace tserver
+} // namespace kudu
+
+#endif // KUDU_TSERVER_TABLET_REPLICA_LOOKUP_H_

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_server-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server-test-base.h b/src/kudu/tserver/tablet_server-test-base.h
index 29495dc..178bb11 100644
--- a/src/kudu/tserver/tablet_server-test-base.h
+++ b/src/kudu/tserver/tablet_server-test-base.h
@@ -41,7 +41,7 @@
 #include "kudu/server/server_base.proxy.h"
 #include "kudu/tablet/local_tablet_writer.h"
 #include "kudu/tablet/tablet.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tserver/mini_tablet_server.h"
 #include "kudu/tserver/tablet_copy.proxy.h"
 #include "kudu/tserver/scanners.h"
@@ -107,7 +107,8 @@ class TabletServerTestBase : public KuduTest {
 
     // Set up a tablet inside the server.
     ASSERT_OK(mini_server_->AddTestTablet(kTableId, kTabletId, schema_));
-    ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet_peer_));
+    ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId,
+                                                                       &tablet_replica_));
 
     // Creating a tablet is async, we wait here instead of having to handle errors later.
     ASSERT_OK(WaitForTabletRunning(kTabletId));
@@ -117,10 +118,11 @@ class TabletServerTestBase : public KuduTest {
   }
 
   Status WaitForTabletRunning(const char *tablet_id) {
-    scoped_refptr<tablet::TabletPeer> tablet_peer;
-    RETURN_NOT_OK(mini_server_->server()->tablet_manager()->GetTabletPeer(tablet_id, &tablet_peer));
-    RETURN_NOT_OK(tablet_peer->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10)));
-    RETURN_NOT_OK(tablet_peer->consensus()->WaitUntilLeaderForTests(MonoDelta::FromSeconds(10)));
+    scoped_refptr<tablet::TabletReplica> tablet_replica;
+    RETURN_NOT_OK(mini_server_->server()->tablet_manager()->GetTabletReplica(tablet_id,
+                                                                             &tablet_replica));
+    RETURN_NOT_OK(tablet_replica->WaitUntilConsensusRunning(MonoDelta::FromSeconds(10)));
+    RETURN_NOT_OK(tablet_replica->consensus()->WaitUntilLeaderForTests(MonoDelta::FromSeconds(10)));
     return Status::OK();
   }
 
@@ -158,7 +160,7 @@ class TabletServerTestBase : public KuduTest {
 
   // Inserts 'num_rows' test rows directly into the tablet (i.e not via RPC)
   void InsertTestRowsDirect(int64_t start_row, uint64_t num_rows) {
-    tablet::LocalTabletWriter writer(tablet_peer_->tablet(), &schema_);
+    tablet::LocalTabletWriter writer(tablet_replica_->tablet(), &schema_);
     KuduPartialRow row(&schema_);
     for (int64_t i = 0; i < num_rows; i++) {
       BuildTestRow(start_row + i, &row);
@@ -329,9 +331,9 @@ class TabletServerTestBase : public KuduTest {
 
   void ShutdownTablet() {
     if (mini_server_.get()) {
-      // The tablet peer must be destroyed before the TS, otherwise data
+      // The TabletReplica must be destroyed before the TS, otherwise data
       // blocks may be destroyed after their owning block manager.
-      tablet_peer_.reset();
+      tablet_replica_.reset();
       mini_server_->Shutdown();
       mini_server_.reset();
     }
@@ -347,11 +349,11 @@ class TabletServerTestBase : public KuduTest {
     // this should open the tablet created on StartTabletServer()
     RETURN_NOT_OK(mini_server_->Start());
 
-    // Don't RETURN_NOT_OK immediately -- even if we fail, we may still get a TabletPeer object
+    // Don't RETURN_NOT_OK immediately -- even if we fail, we may still get a TabletReplica object
     // which has information about the failure.
     Status wait_status = mini_server_->WaitStarted();
     bool found_peer = mini_server_->server()->tablet_manager()->LookupTablet(
-        kTabletId, &tablet_peer_);
+        kTabletId, &tablet_replica_);
     RETURN_NOT_OK(wait_status);
     if (!found_peer) {
       return Status::NotFound("Tablet was not found");
@@ -368,7 +370,7 @@ class TabletServerTestBase : public KuduTest {
   // Verifies that a set of expected rows (key, value) is present in the tablet.
   void VerifyRows(const Schema& schema, const vector<KeyValue>& expected) {
     gscoped_ptr<RowwiseIterator> iter;
-    ASSERT_OK(tablet_peer_->tablet()->NewRowIterator(schema, &iter));
+    ASSERT_OK(tablet_replica_->tablet()->NewRowIterator(schema, &iter));
     ASSERT_OK(iter->Init(NULL));
 
     int batch_size = std::max(
@@ -456,7 +458,7 @@ class TabletServerTestBase : public KuduTest {
   std::shared_ptr<rpc::Messenger> client_messenger_;
 
   gscoped_ptr<MiniTabletServer> mini_server_;
-  scoped_refptr<tablet::TabletPeer> tablet_peer_;
+  scoped_refptr<tablet::TabletReplica> tablet_replica_;
   gscoped_ptr<TabletServerServiceProxy> proxy_;
   gscoped_ptr<TabletServerAdminServiceProxy> admin_proxy_;
   gscoped_ptr<consensus::ConsensusServiceProxy> consensus_proxy_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_server-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index f4ba760..43f01a6 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -44,7 +44,7 @@ using kudu::rpc::RpcController;
 using kudu::server::Clock;
 using kudu::server::HybridClock;
 using kudu::tablet::Tablet;
-using kudu::tablet::TabletPeer;
+using kudu::tablet::TabletReplica;
 using std::shared_ptr;
 using std::string;
 using std::unique_ptr;
@@ -271,7 +271,7 @@ TEST_F(TabletServerTest, TestInsert) {
   WriteResponsePB resp;
   RpcController controller;
 
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
   ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet));
   scoped_refptr<Counter> rows_inserted =
     METRIC_rows_inserted.Instantiate(tablet->tablet()->GetMetricEntity());
@@ -375,7 +375,7 @@ TEST_F(TabletServerTest, TestExternalConsistencyModes_ClientPropagated) {
   WriteResponsePB resp;
   RpcController controller;
 
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
   ASSERT_TRUE(
       mini_server_->server()->tablet_manager()->LookupTablet(kTabletId,
                                                              &tablet));
@@ -426,7 +426,7 @@ TEST_F(TabletServerTest, TestExternalConsistencyModes_CommitWait) {
   RpcController controller;
   HybridClock* hclock = down_cast<HybridClock*, Clock>(mini_server_->server()->clock());
 
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
   ASSERT_TRUE(
       mini_server_->server()->tablet_manager()->LookupTablet(kTabletId,
                                                              &tablet));
@@ -490,7 +490,7 @@ TEST_F(TabletServerTest, TestExternalConsistencyModes_CommitWait) {
 
 TEST_F(TabletServerTest, TestInsertAndMutate) {
 
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
   ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet));
   scoped_refptr<Counter> rows_inserted =
       METRIC_rows_inserted.Instantiate(tablet->tablet()->GetMetricEntity());
@@ -779,11 +779,11 @@ TEST_F(TabletServerTest, TestRecoveryWithMutationsWhileFlushing) {
 
   shared_ptr<MyCommonHooks> hooks(new MyCommonHooks(this));
 
-  tablet_peer_->tablet()->SetFlushHooksForTests(hooks);
-  tablet_peer_->tablet()->SetCompactionHooksForTests(hooks);
-  tablet_peer_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushHooksForTests(hooks);
+  tablet_replica_->tablet()->SetCompactionHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
 
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
 
   // Shutdown the tserver and try and rebuild the tablet from the log
   // produced on recovery (recovery flushed no state, but produced a new
@@ -819,12 +819,12 @@ TEST_F(TabletServerTest, TestRecoveryWithMutationsWhileFlushingAndCompacting) {
 
   shared_ptr<MyCommonHooks> hooks(new MyCommonHooks(this));
 
-  tablet_peer_->tablet()->SetFlushHooksForTests(hooks);
-  tablet_peer_->tablet()->SetCompactionHooksForTests(hooks);
-  tablet_peer_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushHooksForTests(hooks);
+  tablet_replica_->tablet()->SetCompactionHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
 
   // flush the first time
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
 
   ASSERT_NO_FATAL_FAILURE(ShutdownAndRebuildTablet());
   VerifyRows(schema_, { KeyValue(1, 10),
@@ -837,9 +837,9 @@ TEST_F(TabletServerTest, TestRecoveryWithMutationsWhileFlushingAndCompacting) {
   hooks->increment_iteration();
 
   // set the hooks on the new tablet
-  tablet_peer_->tablet()->SetFlushHooksForTests(hooks);
-  tablet_peer_->tablet()->SetCompactionHooksForTests(hooks);
-  tablet_peer_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushHooksForTests(hooks);
+  tablet_replica_->tablet()->SetCompactionHooksForTests(hooks);
+  tablet_replica_->tablet()->SetFlushCompactCommonHooksForTests(hooks);
 
   // insert an additional row so that we can flush
   InsertTestRowsRemote(0, 8, 1);
@@ -847,7 +847,7 @@ TEST_F(TabletServerTest, TestRecoveryWithMutationsWhileFlushingAndCompacting) {
   // flush an additional MRS so that we have two DiskRowSets and then compact
   // them making sure that mutations executed mid compaction are replayed as
   // expected
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   VerifyRows(schema_, { KeyValue(1, 11),
                         KeyValue(2, 21),
                         KeyValue(3, 31),
@@ -858,7 +858,7 @@ TEST_F(TabletServerTest, TestRecoveryWithMutationsWhileFlushingAndCompacting) {
                         KeyValue(8, 8) });
 
   hooks->increment_iteration();
-  ASSERT_OK(tablet_peer_->tablet()->Compact(Tablet::FORCE_COMPACT_ALL));
+  ASSERT_OK(tablet_replica_->tablet()->Compact(Tablet::FORCE_COMPACT_ALL));
 
   // get the clock's current timestamp
   Timestamp now_before = mini_server_->server()->clock()->Now();
@@ -891,21 +891,21 @@ TEST_F(TabletServerTest, TestKUDU_176_RecoveryAfterMajorDeltaCompaction) {
 
   // Flush a DRS with 1 rows.
   ASSERT_NO_FATAL_FAILURE(InsertTestRowsRemote(0, 1, 1));
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   ANFF(VerifyRows(schema_, { KeyValue(1, 1) }));
 
   // Update it, flush deltas.
   ANFF(UpdateTestRowRemote(0, 1, 2));
-  ASSERT_OK(tablet_peer_->tablet()->FlushBiggestDMS());
+  ASSERT_OK(tablet_replica_->tablet()->FlushBiggestDMS());
   ANFF(VerifyRows(schema_, { KeyValue(1, 2) }));
 
   // Major compact deltas.
   {
     vector<shared_ptr<tablet::RowSet> > rsets;
-    tablet_peer_->tablet()->GetRowSetsForTests(&rsets);
-    vector<ColumnId> col_ids = { tablet_peer_->tablet()->schema()->column_id(1),
-                                 tablet_peer_->tablet()->schema()->column_id(2) };
-    ASSERT_OK(tablet_peer_->tablet()->DoMajorDeltaCompaction(col_ids, rsets[0]))
+    tablet_replica_->tablet()->GetRowSetsForTests(&rsets);
+    vector<ColumnId> col_ids = { tablet_replica_->tablet()->schema()->column_id(1),
+                                 tablet_replica_->tablet()->schema()->column_id(2) };
+    ASSERT_OK(tablet_replica_->tablet()->DoMajorDeltaCompaction(col_ids, rsets[0]))
   }
 
   // Verify that data is still the same.
@@ -925,7 +925,7 @@ TEST_F(TabletServerTest, TestKUDU_1341) {
   for (int i = 0; i < 3; i++) {
     // Insert a row to DMS and flush it.
     ANFF(InsertTestRowsRemote(kTid, 1, 1));
-    ASSERT_OK(tablet_peer_->tablet()->Flush());
+    ASSERT_OK(tablet_replica_->tablet()->Flush());
 
     // Update and delete row (in DMS)
     ANFF(UpdateTestRowRemote(kTid, 1, i));
@@ -936,18 +936,18 @@ TEST_F(TabletServerTest, TestKUDU_1341) {
   // flush.
   ANFF(InsertTestRowsRemote(kTid, 1, 1));
   ANFF(UpdateTestRowRemote(kTid, 1, 12345));
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
 
   ANFF(VerifyRows(schema_, { KeyValue(1, 12345) }));
 
   // Test restart.
   ASSERT_OK(ShutdownAndRebuildTablet());
   ANFF(VerifyRows(schema_, { KeyValue(1, 12345) }));
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   ANFF(VerifyRows(schema_, { KeyValue(1, 12345) }));
 
   // Test compaction after restart.
-  ASSERT_OK(tablet_peer_->tablet()->Compact(Tablet::FORCE_COMPACT_ALL));
+  ASSERT_OK(tablet_replica_->tablet()->Compact(Tablet::FORCE_COMPACT_ALL));
   ANFF(VerifyRows(schema_, { KeyValue(1, 12345) }));
 }
 
@@ -1016,12 +1016,12 @@ TEST_F(TabletServerTest, DISABLED_TestExactlyOnceForErrorsAcrossRestart) {
 TEST_F(TabletServerTest, TestKUDU_177_RecoveryOfDMSEditsAfterMajorDeltaCompaction) {
   // Flush a DRS with 1 rows.
   ANFF(InsertTestRowsRemote(0, 1, 1));
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   ANFF(VerifyRows(schema_, { KeyValue(1, 1) }));
 
   // Update it, flush deltas.
   ANFF(UpdateTestRowRemote(0, 1, 2));
-  ASSERT_OK(tablet_peer_->tablet()->FlushBiggestDMS());
+  ASSERT_OK(tablet_replica_->tablet()->FlushBiggestDMS());
 
   // Update it again, so this last update is in the DMS.
   ANFF(UpdateTestRowRemote(0, 1, 3));
@@ -1031,10 +1031,10 @@ TEST_F(TabletServerTest, TestKUDU_177_RecoveryOfDMSEditsAfterMajorDeltaCompactio
   // DMS should "move over" to the output of the delta compaction.
   {
     vector<shared_ptr<tablet::RowSet> > rsets;
-    tablet_peer_->tablet()->GetRowSetsForTests(&rsets);
-    vector<ColumnId> col_ids = { tablet_peer_->tablet()->schema()->column_id(1),
-                                 tablet_peer_->tablet()->schema()->column_id(2) };
-    ASSERT_OK(tablet_peer_->tablet()->DoMajorDeltaCompaction(col_ids, rsets[0]));
+    tablet_replica_->tablet()->GetRowSetsForTests(&rsets);
+    vector<ColumnId> col_ids = { tablet_replica_->tablet()->schema()->column_id(1),
+                                 tablet_replica_->tablet()->schema()->column_id(2) };
+    ASSERT_OK(tablet_replica_->tablet()->DoMajorDeltaCompaction(col_ids, rsets[0]));
   }
   // Verify that data is still the same.
   ANFF(VerifyRows(schema_, { KeyValue(1, 3) }));
@@ -1047,11 +1047,11 @@ TEST_F(TabletServerTest, TestKUDU_177_RecoveryOfDMSEditsAfterMajorDeltaCompactio
 TEST_F(TabletServerTest, TestClientGetsErrorBackWhenRecoveryFailed) {
   ANFF(InsertTestRowsRemote(0, 1, 7));
 
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
 
   // Save the log path before shutting down the tablet (and destroying
-  // the tablet peer).
-  string log_path = tablet_peer_->log()->ActiveSegmentPathForTests();
+  // the TabletReplica).
+  string log_path = tablet_replica_->log()->ActiveSegmentPathForTests();
   ShutdownTablet();
 
   ASSERT_OK(log::CorruptLogFile(env_, log_path, log::FLIP_BYTE, 300));
@@ -1074,8 +1074,8 @@ TEST_F(TabletServerTest, TestClientGetsErrorBackWhenRecoveryFailed) {
   ASSERT_EQ(TabletServerErrorPB::TABLET_NOT_RUNNING, resp.error().code());
   ASSERT_STR_CONTAINS(resp.error().status().message(), "Tablet not RUNNING: FAILED");
 
-  // Check that the tablet peer's status message is updated with the failure.
-  ASSERT_STR_CONTAINS(tablet_peer_->last_status(),
+  // Check that the TabletReplica's status message is updated with the failure.
+  ASSERT_STR_CONTAINS(tablet_replica_->last_status(),
                       "Log file corruption detected");
 }
 
@@ -1286,7 +1286,7 @@ TEST_F(TabletServerTest, TestSnapshotScan_OpenScanner) {
   vector<uint64_t> write_timestamps_collector;
   // Write and flush and write, so we have some rows in MRS and DRS
   InsertTestRowsRemote(0, 0, 100, 2, nullptr, kTabletId, &write_timestamps_collector);
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   InsertTestRowsRemote(0, 100, 100, 2, nullptr, kTabletId, &write_timestamps_collector);
 
   ScanRequestPB req;
@@ -1326,7 +1326,7 @@ TEST_F(TabletServerTest, TestSnapshotScan_LastRow) {
 
   // Generate some interleaved rows
   for (int i = 0; i < batch_size; i++) {
-    ASSERT_OK(tablet_peer_->tablet()->Flush());
+    ASSERT_OK(tablet_replica_->tablet()->Flush());
     for (int j = 0; j < num_rows; j++) {
       if (j % batch_size == i) {
         InsertTestRowsDirect(j, 1);
@@ -1717,7 +1717,7 @@ TEST_F(TabletServerTest, TestInvalidScanRequest_BadProjectionTypes) {
 // Column IDs are assigned to the user request schema on the tablet server
 // based on the latest schema.
 TEST_F(TabletServerTest, TestInvalidScanRequest_WithIds) {
-  const Schema* projection = tablet_peer_->tablet()->schema();
+  const Schema* projection = tablet_replica_->tablet()->schema();
   ASSERT_TRUE(projection->has_column_ids());
   VerifyScanRequestFailure(*projection,
                            TabletServerErrorPB::INVALID_SCHEMA,
@@ -1809,9 +1809,9 @@ TEST_F(TabletServerTest, TestScan_KeepAliveExpiredScanner) {
 void TabletServerTest::DoOrderedScanTest(const Schema& projection,
                                          const string& expected_rows_as_string) {
   InsertTestRowsDirect(0, 10);
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   InsertTestRowsDirect(10, 10);
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   InsertTestRowsDirect(20, 10);
 
   ScanResponsePB resp;
@@ -1911,7 +1911,7 @@ TEST_F(TabletServerTest, TestAlterSchema) {
 
   {
     InsertTestRowsRemote(0, 2, 2);
-    scoped_refptr<TabletPeer> tablet;
+    scoped_refptr<TabletReplica> tablet;
     ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet));
     ASSERT_OK(tablet->tablet()->Flush());
   }
@@ -2006,7 +2006,7 @@ TEST_F(TabletServerTest, TestCreateTablet_TabletExists) {
 }
 
 TEST_F(TabletServerTest, TestDeleteTablet) {
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
 
   // Verify that the tablet exists
   ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet));
@@ -2024,7 +2024,7 @@ TEST_F(TabletServerTest, TestDeleteTablet) {
   // Put some data in the tablet. We flush and insert more rows to ensure that
   // there is data both in the MRS and on disk.
   ASSERT_NO_FATAL_FAILURE(InsertTestRowsRemote(0, 1, 1));
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   ASSERT_NO_FATAL_FAILURE(InsertTestRowsRemote(0, 2, 1));
 
   const int block_count_after_flush = ondisk->value();
@@ -2035,7 +2035,7 @@ TEST_F(TabletServerTest, TestDeleteTablet) {
   // Drop any local references to the tablet from within this test,
   // so that when we delete it on the server, it's not held alive
   // by the test code.
-  tablet_peer_.reset();
+  tablet_replica_.reset();
   tablet.reset();
 
   DeleteTabletRequestPB req;
@@ -2101,7 +2101,7 @@ TEST_F(TabletServerTest, TestDeleteTablet_TabletNotCreated) {
 // the other fails, with no assertion failures. Regression test for KUDU-345.
 TEST_F(TabletServerTest, TestConcurrentDeleteTablet) {
   // Verify that the tablet exists
-  scoped_refptr<TabletPeer> tablet;
+  scoped_refptr<TabletReplica> tablet;
   ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId, &tablet));
 
   static const int kNumDeletes = 2;
@@ -2390,15 +2390,15 @@ TEST_F(TabletServerTest, TestKudu120PreRequisites) {
   // Insert a few rows...
   InsertTestRowsRemote(0, 0, 10);
   // ... now flush ...
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
   // ... insert a few rows...
   InsertTestRowsRemote(0, 10, 10);
   // ... and flush again so that we have two disk row sets.
-  ASSERT_OK(tablet_peer_->tablet()->Flush());
+  ASSERT_OK(tablet_replica_->tablet()->Flush());
 
   // Add a hook so that we can make the log wait right after an append
   // (before the callback is triggered).
-  log::Log* log = tablet_peer_->log();
+  log::Log* log = tablet_replica_->log();
   shared_ptr<DelayFsyncLogHook> log_hook(new DelayFsyncLogHook);
   log->SetLogFaultHooksForTests(log_hook);
 
@@ -2418,7 +2418,7 @@ TEST_F(TabletServerTest, TestKudu120PreRequisites) {
   CountDownLatch flush_done_latch(1);
   CHECK_OK(kudu::Thread::Create("CompactThread", "CompactThread",
                                 CompactAsync,
-                                tablet_peer_->tablet(),
+                                tablet_replica_->tablet(),
                                 &flush_done_latch,
                                 &flush_thread));
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/7f72105b/src/kudu/tserver/tablet_service.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_service.cc b/src/kudu/tserver/tablet_service.cc
index e5df72c..4f3eab8 100644
--- a/src/kudu/tserver/tablet_service.cc
+++ b/src/kudu/tserver/tablet_service.cc
@@ -41,7 +41,7 @@
 #include "kudu/tablet/metadata.pb.h"
 #include "kudu/tablet/tablet_bootstrap.h"
 #include "kudu/tablet/tablet_metrics.h"
-#include "kudu/tablet/tablet_peer.h"
+#include "kudu/tablet/tablet_replica.h"
 #include "kudu/tablet/transactions/alter_schema_transaction.h"
 #include "kudu/tablet/transactions/write_transaction.h"
 #include "kudu/tserver/tablet_copy_service.h"
@@ -125,7 +125,7 @@ using kudu::rpc::RpcSidecar;
 using kudu::server::ServerBase;
 using kudu::tablet::AlterSchemaTransactionState;
 using kudu::tablet::Tablet;
-using kudu::tablet::TabletPeer;
+using kudu::tablet::TabletReplica;
 using kudu::tablet::TabletStatusPB;
 using kudu::tablet::TransactionCompletionCallback;
 using kudu::tablet::WriteTransactionState;
@@ -152,12 +152,12 @@ namespace {
 //
 // Returns true if successful.
 template<class RespClass>
-bool LookupTabletPeerOrRespond(TabletPeerLookupIf* tablet_manager,
-                               const string& tablet_id,
-                               RespClass* resp,
-                               rpc::RpcContext* context,
-                               scoped_refptr<TabletPeer>* peer) {
-  if (PREDICT_FALSE(!tablet_manager->GetTabletPeer(tablet_id, peer).ok())) {
+bool LookupTabletReplicaOrRespond(TabletReplicaLookupIf* tablet_manager,
+                                  const string& tablet_id,
+                                  RespClass* resp,
+                                  rpc::RpcContext* context,
+                                  scoped_refptr<TabletReplica>* replica) {
+  if (PREDICT_FALSE(!tablet_manager->GetTabletReplica(tablet_id, replica).ok())) {
     SetupErrorAndRespond(resp->mutable_error(),
                          Status::NotFound("Tablet not found"),
                          TabletServerErrorPB::TABLET_NOT_FOUND, context);
@@ -165,12 +165,12 @@ bool LookupTabletPeerOrRespond(TabletPeerLookupIf* tablet_manager,
   }
 
   // Check RUNNING state.
-  tablet::TabletStatePB state = (*peer)->state();
+  tablet::TabletStatePB state = (*replica)->state();
   if (PREDICT_FALSE(state != tablet::RUNNING)) {
     Status s = Status::IllegalState("Tablet not RUNNING",
                                     tablet::TabletStatePB_Name(state));
     if (state == tablet::FAILED) {
-      s = s.CloneAndAppend((*peer)->error().ToString());
+      s = s.CloneAndAppend((*replica)->error().ToString());
     }
     SetupErrorAndRespond(resp->mutable_error(), s,
                          TabletServerErrorPB::TABLET_NOT_RUNNING, context);
@@ -180,7 +180,7 @@ bool LookupTabletPeerOrRespond(TabletPeerLookupIf* tablet_manager,
 }
 
 template<class ReqClass, class RespClass>
-bool CheckUuidMatchOrRespond(TabletPeerLookupIf* tablet_manager,
+bool CheckUuidMatchOrRespond(TabletReplicaLookupIf* tablet_manager,
                              const char* method_name,
                              const ReqClass* req,
                              RespClass* resp,
@@ -211,11 +211,11 @@ bool CheckUuidMatchOrRespond(TabletPeerLookupIf* tablet_manager,
 }
 
 template<class RespClass>
-bool GetConsensusOrRespond(const scoped_refptr<TabletPeer>& tablet_peer,
+bool GetConsensusOrRespond(const scoped_refptr<TabletReplica>& replica,
                            RespClass* resp,
                            rpc::RpcContext* context,
                            scoped_refptr<Consensus>* consensus) {
-  *consensus = tablet_peer->shared_consensus();
+  *consensus = replica->shared_consensus();
   if (!*consensus) {
     Status s = Status::ServiceUnavailable("Consensus unavailable. Tablet not running");
     SetupErrorAndRespond(resp->mutable_error(), s,
@@ -225,10 +225,10 @@ bool GetConsensusOrRespond(const scoped_refptr<TabletPeer>& tablet_peer,
   return true;
 }
 
-Status GetTabletRef(const scoped_refptr<TabletPeer>& tablet_peer,
+Status GetTabletRef(const scoped_refptr<TabletReplica>& replica,
                     shared_ptr<Tablet>* tablet,
                     TabletServerErrorPB::Code* error_code) {
-  *DCHECK_NOTNULL(tablet) = tablet_peer->shared_tablet();
+  *DCHECK_NOTNULL(tablet) = replica->shared_tablet();
   if (PREDICT_FALSE(!*tablet)) {
     *error_code = TabletServerErrorPB::TABLET_NOT_RUNNING;
     return Status::IllegalState("Tablet is not running");
@@ -573,13 +573,13 @@ void TabletServiceAdminImpl::AlterSchema(const AlterSchemaRequestPB* req,
   }
   DVLOG(3) << "Received Alter Schema RPC: " << SecureDebugString(*req);
 
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(server_->tablet_manager(), req->tablet_id(), resp, context,
-                                 &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(server_->tablet_manager(), req->tablet_id(), resp, context,
+                                    &replica)) {
     return;
   }
 
-  uint32_t schema_version = tablet_peer->tablet_metadata()->schema_version();
+  uint32_t schema_version = replica->tablet_metadata()->schema_version();
 
   // If the schema was already applied, respond as succeded
   if (schema_version == req->schema_version()) {
@@ -593,13 +593,13 @@ void TabletServiceAdminImpl::AlterSchema(const AlterSchemaRequestPB* req,
       return;
     }
 
-    Schema tablet_schema = tablet_peer->tablet_metadata()->schema();
+    Schema tablet_schema = replica->tablet_metadata()->schema();
     if (req_schema.Equals(tablet_schema)) {
       context->RespondSuccess();
       return;
     }
 
-    schema_version = tablet_peer->tablet_metadata()->schema_version();
+    schema_version = replica->tablet_metadata()->schema_version();
     if (schema_version == req->schema_version()) {
       LOG(ERROR) << "The current schema does not match the request schema."
                  << " version=" << schema_version
@@ -622,14 +622,14 @@ void TabletServiceAdminImpl::AlterSchema(const AlterSchemaRequestPB* req,
   }
 
   unique_ptr<AlterSchemaTransactionState> tx_state(
-    new AlterSchemaTransactionState(tablet_peer.get(), req, resp));
+    new AlterSchemaTransactionState(replica.get(), req, resp));
 
   tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
       new RpcTransactionCompletionCallback<AlterSchemaResponsePB>(context,
                                                                   resp)));
 
   // Submit the alter schema op. The RPC will be responded to asynchronously.
-  Status s = tablet_peer->SubmitAlterSchema(std::move(tx_state));
+  Status s = replica->SubmitAlterSchema(std::move(tx_state));
   if (PREDICT_FALSE(!s.ok())) {
     SetupErrorAndRespond(resp->mutable_error(), s,
                          TabletServerErrorPB::UNKNOWN_ERROR,
@@ -739,15 +739,15 @@ void TabletServiceImpl::Write(const WriteRequestPB* req,
                "tablet_id", req->tablet_id());
   DVLOG(3) << "Received Write RPC: " << SecureDebugString(*req);
 
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(server_->tablet_manager(), req->tablet_id(), resp, context,
-                                 &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(server_->tablet_manager(), req->tablet_id(), resp, context,
+                                    &replica)) {
     return;
   }
 
   shared_ptr<Tablet> tablet;
   TabletServerErrorPB::Code error_code;
-  Status s = GetTabletRef(tablet_peer, &tablet, &error_code);
+  Status s = GetTabletRef(replica, &tablet, &error_code);
   if (PREDICT_FALSE(!s.ok())) {
     SetupErrorAndRespond(resp->mutable_error(), s, error_code, context);
     return;
@@ -792,7 +792,7 @@ void TabletServiceImpl::Write(const WriteRequestPB* req,
   }
 
   unique_ptr<WriteTransactionState> tx_state(new WriteTransactionState(
-      tablet_peer.get(),
+      replica.get(),
       req,
       context->AreResultsTracked() ? context->request_id() : nullptr,
       resp));
@@ -815,7 +815,7 @@ void TabletServiceImpl::Write(const WriteRequestPB* req,
                                                             resp)));
 
   // Submit the write. The RPC will be responded to asynchronously.
-  s = tablet_peer->SubmitWrite(std::move(tx_state));
+  s = replica->SubmitWrite(std::move(tx_state));
 
   // Check that we could submit the write
   if (PREDICT_FALSE(!s.ok())) {
@@ -826,7 +826,7 @@ void TabletServiceImpl::Write(const WriteRequestPB* req,
 }
 
 ConsensusServiceImpl::ConsensusServiceImpl(ServerBase* server,
-                                           TabletPeerLookupIf* tablet_manager)
+                                           TabletReplicaLookupIf* tablet_manager)
     : ConsensusServiceIf(server->metric_entity(), server->result_tracker()),
       server_(server),
       tablet_manager_(tablet_manager) {
@@ -848,16 +848,16 @@ void ConsensusServiceImpl::UpdateConsensus(const ConsensusRequestPB* req,
   if (!CheckUuidMatchOrRespond(tablet_manager_, "UpdateConsensus", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
-  tablet_peer->permanent_uuid();
+  replica->permanent_uuid();
 
-  // Submit the update directly to the TabletPeer's Consensus instance.
+  // Submit the update directly to the TabletReplica's Consensus instance.
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   Status s = consensus->Update(req, resp);
   if (PREDICT_FALSE(!s.ok())) {
     // Clear the response first, since a partially-filled response could
@@ -880,14 +880,14 @@ void ConsensusServiceImpl::RequestConsensusVote(const VoteRequestPB* req,
   if (!CheckUuidMatchOrRespond(tablet_manager_, "RequestConsensusVote", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
   // Submit the vote request directly to the consensus instance.
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   Status s = consensus->RequestVote(req, resp);
   if (PREDICT_FALSE(!s.ok())) {
     SetupErrorAndRespond(resp->mutable_error(), s,
@@ -905,14 +905,14 @@ void ConsensusServiceImpl::ChangeConfig(const ChangeConfigRequestPB* req,
   if (!CheckUuidMatchOrRespond(tablet_manager_, "ChangeConfig", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context,
-                                 &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context,
+                                    &replica)) {
     return;
   }
 
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   boost::optional<TabletServerErrorPB::Code> error_code;
   Status s = consensus->ChangeConfig(*req, BindHandleResponse(req, resp, context), &error_code);
   if (PREDICT_FALSE(!s.ok())) {
@@ -929,14 +929,14 @@ void ConsensusServiceImpl::UnsafeChangeConfig(const UnsafeChangeConfigRequestPB*
   if (!CheckUuidMatchOrRespond(tablet_manager_, "UnsafeChangeConfig", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context,
-                                 &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context,
+                                    &replica)) {
     return;
   }
 
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   TabletServerErrorPB::Code error_code;
   Status s = consensus->UnsafeChangeConfig(*req, &error_code);
   if (PREDICT_FALSE(!s.ok())) {
@@ -961,13 +961,13 @@ void ConsensusServiceImpl::RunLeaderElection(const RunLeaderElectionRequestPB* r
   if (!CheckUuidMatchOrRespond(tablet_manager_, "RunLeaderElection", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   Status s = consensus->StartElection(
       consensus::Consensus::ELECT_EVEN_IF_LEADER_IS_ALIVE,
       consensus::Consensus::EXTERNAL_REQUEST);
@@ -987,13 +987,13 @@ void ConsensusServiceImpl::LeaderStepDown(const LeaderStepDownRequestPB* req,
   if (!CheckUuidMatchOrRespond(tablet_manager_, "LeaderStepDown", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   Status s = consensus->StepDown(resp);
   if (PREDICT_FALSE(!s.ok())) {
     SetupErrorAndRespond(resp->mutable_error(), s,
@@ -1011,19 +1011,19 @@ void ConsensusServiceImpl::GetLastOpId(const consensus::GetLastOpIdRequestPB *re
   if (!CheckUuidMatchOrRespond(tablet_manager_, "GetLastOpId", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
-  if (tablet_peer->state() != tablet::RUNNING) {
+  if (replica->state() != tablet::RUNNING) {
     SetupErrorAndRespond(resp->mutable_error(),
-                         Status::ServiceUnavailable("Tablet Peer not in RUNNING state"),
+                         Status::ServiceUnavailable("TabletReplica not in RUNNING state"),
                          TabletServerErrorPB::TABLET_NOT_RUNNING, context);
     return;
   }
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   if (PREDICT_FALSE(req->opid_type() == consensus::UNKNOWN_OPID_TYPE)) {
     HandleUnknownError(Status::InvalidArgument("Invalid opid_type specified to GetLastOpId()"),
                        resp, context);
@@ -1046,13 +1046,13 @@ void ConsensusServiceImpl::GetConsensusState(const consensus::GetConsensusStateR
   if (!CheckUuidMatchOrRespond(tablet_manager_, "GetConsensusState", req, resp, context)) {
     return;
   }
-  scoped_refptr<TabletPeer> tablet_peer;
-  if (!LookupTabletPeerOrRespond(tablet_manager_, req->tablet_id(), resp, context, &tablet_peer)) {
+  scoped_refptr<TabletReplica> replica;
+  if (!LookupTabletReplicaOrRespond(tablet_manager_, req->tablet_id(), resp, context, &replica)) {
     return;
   }
 
   scoped_refptr<Consensus> consensus;
-  if (!GetConsensusOrRespond(tablet_peer, resp, context, &consensus)) return;
+  if (!GetConsensusOrRespond(replica, resp, context, &consensus)) return;
   ConsensusConfigType type = req->type();
   if (PREDICT_FALSE(type != CONSENSUS_CONFIG_ACTIVE && type != CONSENSUS_CONFIG_COMMITTED)) {
     HandleUnknownError(
@@ -1128,14 +1128,14 @@ void TabletServiceImpl::Scan(const ScanRequestPB* req,
   TabletServerErrorPB::Code error_code = TabletServerErrorPB::UNKNOWN_ERROR;
   if (req->has_new_scan_request()) {
     const NewScanRequestPB& scan_pb = req->new_scan_request();
-    scoped_refptr<TabletPeer> tablet_peer;
-    if (!LookupTabletPeerOrRespond(server_->tablet_manager(), scan_pb.tablet_id(), resp, context,
-                                   &tablet_peer)) {
+    scoped_refptr<TabletReplica> replica;
+    if (!LookupTabletReplicaOrRespond(server_->tablet_manager(), scan_pb.tablet_id(), resp, context,
+                                      &replica)) {
       return;
     }
     string scanner_id;
     Timestamp scan_timestamp;
-    Status s = HandleNewScanRequest(tablet_peer.get(), req, context,
+    Status s = HandleNewScanRequest(replica.get(), req, context,
                                     &collector, &scanner_id, &scan_timestamp, &has_more_results,
                                     &error_code);
     if (PREDICT_FALSE(!s.ok())) {
@@ -1197,17 +1197,17 @@ void TabletServiceImpl::Scan(const ScanRequestPB* req,
 void TabletServiceImpl::ListTablets(const ListTabletsRequestPB* req,
                                     ListTabletsResponsePB* resp,
                                     rpc::RpcContext* context) {
-  vector<scoped_refptr<TabletPeer> > peers;
-  server_->tablet_manager()->GetTabletPeers(&peers);
-  RepeatedPtrField<StatusAndSchemaPB>* peer_status = resp->mutable_status_and_schema();
-  for (const scoped_refptr<TabletPeer>& peer : peers) {
-    StatusAndSchemaPB* status = peer_status->Add();
-    peer->GetTabletStatusPB(status->mutable_tablet_status());
+  vector<scoped_refptr<TabletReplica>> replicas;
+  server_->tablet_manager()->GetTabletReplicas(&replicas);
+  RepeatedPtrField<StatusAndSchemaPB>* replica_status = resp->mutable_status_and_schema();
+  for (const scoped_refptr<TabletReplica>& replica : replicas) {
+    StatusAndSchemaPB* status = replica_status->Add();
+    replica->GetTabletStatusPB(status->mutable_tablet_status());
 
     if (req->need_schema_info()) {
-      CHECK_OK(SchemaToPB(peer->tablet_metadata()->schema(),
+      CHECK_OK(SchemaToPB(replica->tablet_metadata()->schema(),
                           status->mutable_schema()));
-      peer->tablet_metadata()->partition_schema().ToPB(status->mutable_partition_schema());
+      replica->tablet_metadata()->partition_schema().ToPB(status->mutable_partition_schema());
     }
   }
   context->RespondSuccess();
@@ -1239,15 +1239,15 @@ void TabletServiceImpl::Checksum(const ChecksumRequestPB* req,
   if (req->has_new_request()) {
     scan_req.mutable_new_scan_request()->CopyFrom(req->new_request());
     const NewScanRequestPB& new_req = req->new_request();
-    scoped_refptr<TabletPeer> tablet_peer;
-    if (!LookupTabletPeerOrRespond(server_->tablet_manager(), new_req.tablet_id(), resp, context,
-                                   &tablet_peer)) {
+    scoped_refptr<TabletReplica> replica;
+    if (!LookupTabletReplicaOrRespond(server_->tablet_manager(), new_req.tablet_id(), resp, context,
+                                      &replica)) {
       return;
     }
 
     string scanner_id;
     Timestamp snap_timestamp;
-    Status s = HandleNewScanRequest(tablet_peer.get(), &scan_req, context,
+    Status s = HandleNewScanRequest(replica.get(), &scan_req, context,
                                     &collector, &scanner_id, &snap_timestamp, &has_more,
                                     &error_code);
     if (PREDICT_FALSE(!s.ok())) {
@@ -1478,7 +1478,7 @@ Status VerifyNotAncientHistory(Tablet* tablet, ReadMode read_mode, Timestamp tim
 } // anonymous namespace
 
 // Start a new scan.
-Status TabletServiceImpl::HandleNewScanRequest(TabletPeer* tablet_peer,
+Status TabletServiceImpl::HandleNewScanRequest(TabletReplica* replica,
                                                const ScanRequestPB* req,
                                                const RpcContext* rpc_context,
                                                ScanResultCollector* result_collector,
@@ -1493,10 +1493,10 @@ Status TabletServiceImpl::HandleNewScanRequest(TabletPeer* tablet_peer,
   TRACE_EVENT1("tserver", "TabletServiceImpl::HandleNewScanRequest",
                "tablet_id", scan_pb.tablet_id());
 
-  const Schema& tablet_schema = tablet_peer->tablet_metadata()->schema();
+  const Schema& tablet_schema = replica->tablet_metadata()->schema();
 
   SharedScanner scanner;
-  server_->scanner_manager()->NewScanner(tablet_peer,
+  server_->scanner_manager()->NewScanner(replica,
                                          rpc_context->requestor_string(),
                                          scan_pb.row_format_flags(),
                                          &scanner);
@@ -1571,7 +1571,7 @@ Status TabletServiceImpl::HandleNewScanRequest(TabletPeer* tablet_peer,
   TabletServerErrorPB::Code tmp_error_code = TabletServerErrorPB::MISMATCHED_SCHEMA;
 
   shared_ptr<Tablet> tablet;
-  RETURN_NOT_OK(GetTabletRef(tablet_peer, &tablet, error_code));
+  RETURN_NOT_OK(GetTabletRef(replica, &tablet, error_code));
   {
     TRACE("Creating iterator");
     TRACE_EVENT0("tserver", "Create iterator");
@@ -1587,7 +1587,7 @@ Status TabletServiceImpl::HandleNewScanRequest(TabletPeer* tablet_peer,
         break;
       }
       case READ_AT_SNAPSHOT: {
-        s = HandleScanAtSnapshot(scan_pb, rpc_context, projection, tablet_peer,
+        s = HandleScanAtSnapshot(scan_pb, rpc_context, projection, replica,
                                  &iter, snap_timestamp);
         // If we got a Status::ServiceUnavailable() from HandleScanAtSnapshot() it might
         // mean we're just behind so let the client try again.
@@ -1790,10 +1790,10 @@ Status TabletServiceImpl::HandleContinueScanRequest(const ScanRequestPB* req,
     }
   }
 
-  scoped_refptr<TabletPeer> tablet_peer = scanner->tablet_peer();
+  scoped_refptr<TabletReplica> replica = scanner->tablet_replica();
   shared_ptr<Tablet> tablet;
   TabletServerErrorPB::Code tablet_ref_error_code;
-  const Status s = GetTabletRef(tablet_peer, &tablet, &tablet_ref_error_code);
+  const Status s = GetTabletRef(replica, &tablet, &tablet_ref_error_code);
   // If the tablet is not running, but the scan operation in progress
   // has reached this point, the tablet server has the necessary data to
   // send in response for the scan continuation request.
@@ -1864,7 +1864,7 @@ MonoTime ClampScanDeadlineForWait(const MonoTime& deadline, bool* was_clamped) {
 Status TabletServiceImpl::HandleScanAtSnapshot(const NewScanRequestPB& scan_pb,
                                                const RpcContext* rpc_context,
                                                const Schema& projection,
-                                               TabletPeer* tablet_peer,
+                                               TabletReplica* replica,
                                                gscoped_ptr<RowwiseIterator>* iter,
                                                Timestamp* snap_timestamp) {
   // If the client sent a timestamp update our clock with it.
@@ -1910,13 +1910,13 @@ Status TabletServiceImpl::HandleScanAtSnapshot(const NewScanRequestPB& scan_pb,
   // Before we wait on anything check that the timestamp is after the AHM.
   // This is not the final check. We'll check this again after the iterators are open but
   // there is no point in waiting if we can't actually scan afterwards.
-  RETURN_NOT_OK(VerifyNotAncientHistory(tablet_peer->tablet(),
+  RETURN_NOT_OK(VerifyNotAncientHistory(replica->tablet(),
                                         ReadMode::READ_AT_SNAPSHOT,
                                         tmp_snap_timestamp));
 
   tablet::MvccSnapshot snap;
-  Tablet* tablet = tablet_peer->tablet();
-  scoped_refptr<consensus::TimeManager> time_manager = tablet_peer->time_manager();
+  Tablet* tablet = replica->tablet();
+  scoped_refptr<consensus::TimeManager> time_manager = replica->time_manager();
   tablet::MvccManager* mvcc_manager = tablet->mvcc_manager();
 
   // Reduce the client's deadline by a few msecs to allow for overhead.


Mime
View raw message