Skip to content

Commit

Permalink
Rename TabletPeer to TabletReplica
Browse files Browse the repository at this point in the history
This class was confusingly named. This changes the class names as well
as all usages from TabletPeer to TabletReplica.

This was initially done with a Perl script, then the indentation was
corrected, the variable naming was updated, and the documentation was
modified by hand.

Change-Id: Icafecd47268c395a6c0ce0aed75d154f4ace7192
Reviewed-on: http://gerrit.cloudera.org:8080/6794
Tested-by: Kudu Jenkins
Reviewed-by: Will Berkeley <wdberkeley@gmail.com>
  • Loading branch information
mpercy committed May 4, 2017
1 parent 14e9d3d commit 7f72105
Show file tree
Hide file tree
Showing 61 changed files with 930 additions and 927 deletions.
4 changes: 2 additions & 2 deletions docs/design-docs/rpc-retry-and-failover.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ it's not totally clear what happens when an RPC mutates multiple "server objects
what these server objects really are.

2. Handled ad-hoc by the client and the tablet server/master, outside of the RPC layer -
With this option, we choose to handle errors at the TabletServer/TabletPeer, ad-hoc, and for
With this option, we choose to handle errors at the TabletServer/TabletReplica, ad-hoc, and for
each different RPC. For specific RPCs like Write() this option seems to map to existing
components quite well. For instance the completion record can be the raft log and replica
replay would mean that it would be relatively easy to implement a retry rendezvous
Expand All @@ -58,7 +58,7 @@ error handling for operations that are not tablet server transactions.
such as retrying and retry rendez-vous logic, but other parts of the logic would be implemented
ad-hoc in other layers. For instance, for Write()s, the RPC layer would know how to sequence and
retry the RPCs but would delegate durability and cross-server replicated operation rendezvous
to the tablet peer/transaction manager.
to the tablet replica/transaction manager.

# Design choices

Expand Down
68 changes: 34 additions & 34 deletions src/kudu/client/client-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "kudu/rpc/messenger.h"
#include "kudu/security/tls_context.h"
#include "kudu/server/hybrid_clock.h"
#include "kudu/tablet/tablet_peer.h"
#include "kudu/tablet/tablet_replica.h"
#include "kudu/tablet/transactions/write_transaction.h"
#include "kudu/tserver/mini_tablet_server.h"
#include "kudu/tserver/scanners.h"
Expand Down Expand Up @@ -117,7 +117,7 @@ using master::GetTableLocationsRequestPB;
using master::GetTableLocationsResponsePB;
using master::TabletLocationsPB;
using sp::shared_ptr;
using tablet::TabletPeer;
using tablet::TabletReplica;
using tserver::MiniTabletServer;

class ClientTest : public KuduTest {
Expand Down Expand Up @@ -240,10 +240,10 @@ class ClientTest : public KuduTest {

void FlushTablet(const string& tablet_id) {
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
scoped_refptr<TabletPeer> tablet_peer;
scoped_refptr<TabletReplica> tablet_replica;
ASSERT_TRUE(cluster_->mini_tablet_server(i)->server()->tablet_manager()->LookupTablet(
tablet_id, &tablet_peer));
ASSERT_OK(tablet_peer->tablet()->Flush());
tablet_id, &tablet_replica));
ASSERT_OK(tablet_replica->tablet()->Flush());
}
}

Expand Down Expand Up @@ -3376,18 +3376,18 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
ASSERT_STR_CONTAINS(s.ToString(), "unsupported alter operation: string_val");
}

// Need a tablet peer for the next set of tests.
// Need a TabletReplica for the next set of tests.
string tablet_id = GetFirstTabletId(client_table_.get());
scoped_refptr<TabletPeer> tablet_peer;
scoped_refptr<TabletReplica> tablet_replica;
ASSERT_TRUE(cluster_->mini_tablet_server(0)->server()->tablet_manager()->LookupTablet(
tablet_id, &tablet_peer));
tablet_id, &tablet_replica));

{
gscoped_ptr<KuduTableAlterer> table_alterer(client_->NewTableAlterer(kTableName));
table_alterer->DropColumn("int_val")
->AddColumn("new_col")->Type(KuduColumnSchema::INT32);
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(1, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(1, tablet_replica->tablet()->metadata()->schema_version());
}

// Specifying an encoding incompatible with the column's type is an error.
Expand All @@ -3398,7 +3398,7 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
Status s = table_alterer->Alter();
ASSERT_TRUE(s.IsNotSupported());
ASSERT_STR_CONTAINS(s.ToString(), "encoding GROUP_VARINT not supported for type BINARY");
ASSERT_EQ(1, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(1, tablet_replica->tablet()->metadata()->schema_version());
}

// Test adding a new column of type string.
Expand All @@ -3407,7 +3407,7 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AddColumn("new_string_val")->Type(KuduColumnSchema::STRING)
->Encoding(KuduColumnStorageAttributes::PREFIX_ENCODING);
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(2, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(2, tablet_replica->tablet()->metadata()->schema_version());
}

// Test renaming a primary key column.
Expand All @@ -3416,7 +3416,7 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AlterColumn("key")->RenameTo("key2");
Status s = table_alterer->Alter();
ASSERT_FALSE(s.IsInvalidArgument());
ASSERT_EQ(3, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(3, tablet_replica->tablet()->metadata()->schema_version());
}

// Changing the type of a primary key column is an error.
Expand All @@ -3435,8 +3435,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AlterColumn("string_val")
->Default(KuduValue::CopyString("hello!"));
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(4, tablet_peer->tablet()->metadata()->schema_version());
Schema schema = tablet_peer->tablet()->metadata()->schema();
ASSERT_EQ(4, tablet_replica->tablet()->metadata()->schema_version());
Schema schema = tablet_replica->tablet()->metadata()->schema();
ColumnSchema col_schema = schema.column(schema.find_column("string_val"));
ASSERT_FALSE(col_schema.has_read_default());
ASSERT_TRUE(col_schema.has_write_default());
Expand All @@ -3449,8 +3449,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AlterColumn("non_null_with_default")
->Default(KuduValue::FromInt(54321));
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(5, tablet_peer->tablet()->metadata()->schema_version());
Schema schema = tablet_peer->tablet()->metadata()->schema();
ASSERT_EQ(5, tablet_replica->tablet()->metadata()->schema_version());
Schema schema = tablet_replica->tablet()->metadata()->schema();
ColumnSchema col_schema = schema.column(schema.find_column("non_null_with_default"));
ASSERT_TRUE(col_schema.has_read_default()); // Started with a default
ASSERT_TRUE(col_schema.has_write_default());
Expand All @@ -3463,8 +3463,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AlterColumn("string_val")
->RemoveDefault();
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(6, tablet_peer->tablet()->metadata()->schema_version());
Schema schema = tablet_peer->tablet()->metadata()->schema();
ASSERT_EQ(6, tablet_replica->tablet()->metadata()->schema_version());
Schema schema = tablet_replica->tablet()->metadata()->schema();
ColumnSchema col_schema = schema.column(schema.find_column("string_val"));
ASSERT_FALSE(col_schema.has_read_default());
ASSERT_FALSE(col_schema.has_write_default());
Expand All @@ -3476,8 +3476,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
table_alterer->AlterColumn("non_null_with_default")
->RemoveDefault();
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(7, tablet_peer->tablet()->metadata()->schema_version());
Schema schema = tablet_peer->tablet()->metadata()->schema();
ASSERT_EQ(7, tablet_replica->tablet()->metadata()->schema_version());
Schema schema = tablet_replica->tablet()->metadata()->schema();
ColumnSchema col_schema = schema.column(schema.find_column("non_null_with_default"));
ASSERT_TRUE(col_schema.has_read_default());
ASSERT_FALSE(col_schema.has_write_default());
Expand All @@ -3494,7 +3494,7 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
Status s = table_alterer->Alter();
ASSERT_TRUE(s.IsInvalidArgument());
ASSERT_STR_CONTAINS(s.ToString(), "wrong size for default value");
ASSERT_EQ(7, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(7, tablet_replica->tablet()->metadata()->schema_version());
}

// Test altering encoding, compression, and block size.
Expand All @@ -3505,8 +3505,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
->Compression(KuduColumnStorageAttributes::LZ4)
->BlockSize(16 * 1024 * 1024);
ASSERT_OK(table_alterer->Alter());
ASSERT_EQ(8, tablet_peer->tablet()->metadata()->schema_version());
Schema schema = tablet_peer->tablet()->metadata()->schema();
ASSERT_EQ(8, tablet_replica->tablet()->metadata()->schema_version());
Schema schema = tablet_replica->tablet()->metadata()->schema();
ColumnSchema col_schema = schema.column(schema.find_column("string_val"));
ASSERT_EQ(KuduColumnStorageAttributes::PLAIN_ENCODING, col_schema.attributes().encoding);
ASSERT_EQ(KuduColumnStorageAttributes::LZ4, col_schema.attributes().compression);
Expand All @@ -3520,8 +3520,8 @@ TEST_F(ClientTest, TestBasicAlterOperations) {
ASSERT_OK(table_alterer
->RenameTo(kRenamedTableName)
->Alter());
ASSERT_EQ(9, tablet_peer->tablet()->metadata()->schema_version());
ASSERT_EQ(kRenamedTableName, tablet_peer->tablet()->metadata()->table_name());
ASSERT_EQ(9, tablet_replica->tablet()->metadata()->schema_version());
ASSERT_EQ(kRenamedTableName, tablet_replica->tablet()->metadata()->table_name());

CatalogManager *catalog_manager = cluster_->mini_master()->master()->catalog_manager();
CatalogManager::ScopedLeaderSharedLock l(catalog_manager);
Expand Down Expand Up @@ -3561,9 +3561,9 @@ TEST_F(ClientTest, TestDeleteTable) {
int wait_time = 1000;
bool tablet_found = true;
for (int i = 0; i < 80 && tablet_found; ++i) {
scoped_refptr<TabletPeer> tablet_peer;
scoped_refptr<TabletReplica> tablet_replica;
tablet_found = cluster_->mini_tablet_server(0)->server()->tablet_manager()->LookupTablet(
tablet_id, &tablet_peer);
tablet_id, &tablet_replica);
SleepFor(MonoDelta::FromMicroseconds(wait_time));
wait_time = std::min(wait_time * 5 / 4, 1000000);
}
Expand Down Expand Up @@ -4258,9 +4258,9 @@ TEST_F(ClientTest, TestInsertEmptyPK) {
ASSERT_OK(client_->OpenTable(kTableName, &table));

// Find the tablet.
scoped_refptr<TabletPeer> tablet_peer;
scoped_refptr<TabletReplica> tablet_replica;
ASSERT_TRUE(cluster_->mini_tablet_server(0)->server()->tablet_manager()->LookupTablet(
GetFirstTabletId(table.get()), &tablet_peer));
GetFirstTabletId(table.get()), &tablet_replica));

// Utility function to get the current value of the row.
const auto ReadRowAsString = [&]() {
Expand All @@ -4285,7 +4285,7 @@ TEST_F(ClientTest, TestInsertEmptyPK) {
ASSERT_EQ("(string k1=\"\", string v1=\"initial\")", ReadRowAsString());

// Make sure that Flush works properly, and the data is still readable.
ASSERT_OK(tablet_peer->tablet()->Flush());
ASSERT_OK(tablet_replica->tablet()->Flush());
ASSERT_EQ("(string k1=\"\", string v1=\"initial\")", ReadRowAsString());

// Perform an update.
Expand All @@ -4297,9 +4297,9 @@ TEST_F(ClientTest, TestInsertEmptyPK) {
ASSERT_OK(session->Flush());
}
ASSERT_EQ("(string k1=\"\", string v1=\"updated\")", ReadRowAsString());
ASSERT_OK(tablet_peer->tablet()->FlushAllDMSForTests());
ASSERT_OK(tablet_replica->tablet()->FlushAllDMSForTests());
ASSERT_EQ("(string k1=\"\", string v1=\"updated\")", ReadRowAsString());
ASSERT_OK(tablet_peer->tablet()->Compact(tablet::Tablet::FORCE_COMPACT_ALL));
ASSERT_OK(tablet_replica->tablet()->Compact(tablet::Tablet::FORCE_COMPACT_ALL));
ASSERT_EQ("(string k1=\"\", string v1=\"updated\")", ReadRowAsString());

// Perform a delete.
Expand All @@ -4310,9 +4310,9 @@ TEST_F(ClientTest, TestInsertEmptyPK) {
ASSERT_OK(session->Flush());
}
ASSERT_EQ("<none>", ReadRowAsString());
ASSERT_OK(tablet_peer->tablet()->FlushAllDMSForTests());
ASSERT_OK(tablet_replica->tablet()->FlushAllDMSForTests());
ASSERT_EQ("<none>", ReadRowAsString());
ASSERT_OK(tablet_peer->tablet()->Compact(tablet::Tablet::FORCE_COMPACT_ALL));
ASSERT_OK(tablet_replica->tablet()->Compact(tablet::Tablet::FORCE_COMPACT_ALL));
ASSERT_EQ("<none>", ReadRowAsString());
}

Expand Down
2 changes: 1 addition & 1 deletion src/kudu/consensus/consensus-test-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class TestDriver {
Log* log_;
};

// A transaction factory for tests, usually this is implemented by TabletPeer.
// A transaction factory for tests, usually this is implemented by TabletReplica.
class TestTransactionFactory : public ReplicaTransactionFactory {
public:
explicit TestTransactionFactory(Log* log) : consensus_(nullptr),
Expand Down
4 changes: 2 additions & 2 deletions src/kudu/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Clock;
}

namespace tablet {
class TabletPeer;
class TabletReplica;
}

namespace tserver {
Expand Down Expand Up @@ -294,7 +294,7 @@ class Consensus : public RefCountedThreadSafe<Consensus> {

protected:
friend class RefCountedThreadSafe<Consensus>;
friend class tablet::TabletPeer;
friend class tablet::TabletReplica;
friend class master::SysCatalogTable;

// This class is refcounted.
Expand Down
4 changes: 2 additions & 2 deletions src/kudu/consensus/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ Status Log::DoAppend(LogEntryBatch* entry_batch) {
// We keep track of the last-written OpId here.
// This is needed to initialize Consensus on startup.
if (entry_batch->type_ == REPLICATE) {
// TODO Probably remove the code below as it looks suspicious: Tablet peer uses this
// TODO Probably remove the code below as it looks suspicious: TabletReplica uses this
// as 'safe' anchor as it believes it in the log, when it actually isn't, i.e. this
// is not the last durable operation. Either move this to tablet peer (since we're
// is not the last durable operation. Either move this to TabletReplica (since we're
// using in flights anyway no need to scan for ids here) or actually delay doing this
// until fsync() has been done. See KUDU-527.
std::lock_guard<rw_spinlock> write_lock(last_entry_op_id_lock_);
Expand Down
2 changes: 1 addition & 1 deletion src/kudu/consensus/raft_consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ Status RaftConsensus::UpdateReplica(const ConsensusRequestPB* request,
// state machine so, were we to crash afterwards, having the prepares in-flight
// won't hurt.
// - Prepares depend on factors external to consensus (the transaction drivers and
// the tablet peer) so if for some reason they cannot be enqueued we must know
// the TabletReplica) so if for some reason they cannot be enqueued we must know
// before we try write them to the WAL. Once enqueued, we assume that prepare will
// always succeed on a replica transaction (because the leader already prepared them
// successfully, and thus we know they are valid).
Expand Down
2 changes: 1 addition & 1 deletion src/kudu/consensus/raft_consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class RaftConsensus : public Consensus,
Status HandleTermAdvanceUnlocked(ConsensusTerm new_term,
ReplicaState::FlushToDisk flush = ReplicaState::FLUSH_TO_DISK);

// Asynchronously (on thread_pool_) notify the tablet peer that the consensus configuration
// Asynchronously (on thread_pool_) notify the TabletReplica that the consensus configuration
// has changed, thus reporting it back to the master.
void MarkDirty(const std::string& reason);

Expand Down
Loading

0 comments on commit 7f72105

Please sign in to comment.