Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: add data distribution debug page (aka replica matrix) #24855

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions pkg/server/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1359,13 +1359,13 @@ func (s *adminServer) Decommission(
return s.DecommissionStatus(ctx, &serverpb.DecommissionStatusRequest{NodeIDs: nodeIDs})
}

// ReplicaMatrix returns a count of replicas on each node for each table.
func (s *adminServer) ReplicaMatrix(
ctx context.Context, req *serverpb.ReplicaMatrixRequest,
) (*serverpb.ReplicaMatrixResponse, error) {
resp := &serverpb.ReplicaMatrixResponse{
DatabaseInfo: make(map[string]serverpb.ReplicaMatrixResponse_DatabaseInfo),
ZoneConfigs: make(map[int64]serverpb.ReplicaMatrixResponse_ZoneConfig),
// DataDistribution returns a count of replicas on each node for each table.
func (s *adminServer) DataDistribution(
ctx context.Context, req *serverpb.DataDistributionRequest,
) (*serverpb.DataDistributionResponse, error) {
resp := &serverpb.DataDistributionResponse{
DatabaseInfo: make(map[string]serverpb.DataDistributionResponse_DatabaseInfo),
ZoneConfigs: make(map[int64]serverpb.DataDistributionResponse_ZoneConfig),
}

// Get ids and names for databases and tables.
Expand All @@ -1384,7 +1384,7 @@ func (s *adminServer) ReplicaMatrix(
}

// Used later when we're scanning Meta2 and only have IDs, not names.
tableInfosByTableID := map[uint64]serverpb.ReplicaMatrixResponse_TableInfo{}
tableInfosByTableID := map[uint64]serverpb.DataDistributionResponse_TableInfo{}

for _, row := range rows1 {
tableName := (*string)(row[0].(*tree.DString))
Expand All @@ -1394,8 +1394,8 @@ func (s *adminServer) ReplicaMatrix(
// Insert database if it doesn't exist.
dbInfo, ok := resp.DatabaseInfo[*dbName]
if !ok {
dbInfo = serverpb.ReplicaMatrixResponse_DatabaseInfo{
TableInfo: make(map[string]serverpb.ReplicaMatrixResponse_TableInfo),
dbInfo = serverpb.DataDistributionResponse_DatabaseInfo{
TableInfo: make(map[string]serverpb.DataDistributionResponse_TableInfo),
}
resp.DatabaseInfo[*dbName] = dbInfo
}
Expand All @@ -1422,7 +1422,7 @@ func (s *adminServer) ReplicaMatrix(
zcID := int64(tree.MustBeDInt(zcRow[0]))

// Insert table.
tableInfo := serverpb.ReplicaMatrixResponse_TableInfo{
tableInfo := serverpb.DataDistributionResponse_TableInfo{
ReplicaCountByNodeId: make(map[roachpb.NodeID]int64),
ZoneConfigId: zcID,
}
Expand Down Expand Up @@ -1492,7 +1492,7 @@ func (s *adminServer) ReplicaMatrix(
return nil, s.serverError(err)
}

resp.ZoneConfigs[zcID] = serverpb.ReplicaMatrixResponse_ZoneConfig{
resp.ZoneConfigs[zcID] = serverpb.DataDistributionResponse_ZoneConfig{
CliSpecifier: zcCliSpecifier,
Config: zcProto,
ConfigYaml: string(zcYaml),
Expand Down
18 changes: 9 additions & 9 deletions pkg/server/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ func TestAdminAPIFullRangeLog(t *testing.T) {
}
}

func TestAdminAPIReplicaMatrix(t *testing.T) {
func TestAdminAPIDataDistribution(t *testing.T) {
defer leaktest.AfterTest(t)()

t.Skip("#24802")
Expand All @@ -1328,12 +1328,12 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {
sqlDB.Exec(t, `CREATE DATABASE "sp'ec\ch""ars"`)
sqlDB.Exec(t, `CREATE TABLE "sp'ec\ch""ars"."more\spec'chars" (id INT PRIMARY KEY)`)

// Verify that we see their replicas in the ReplicaMatrix response, evenly spread
// Verify that we see their replicas in the DataDistribution response, evenly spread
// across the test cluster's three nodes.

expectedResp := map[string]serverpb.ReplicaMatrixResponse_DatabaseInfo{
expectedResp := map[string]serverpb.DataDistributionResponse_DatabaseInfo{
"roachblog": {
TableInfo: map[string]serverpb.ReplicaMatrixResponse_TableInfo{
TableInfo: map[string]serverpb.DataDistributionResponse_TableInfo{
"posts": {
ReplicaCountByNodeId: map[roachpb.NodeID]int64{
1: 1,
Expand All @@ -1351,7 +1351,7 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {
},
},
`sp'ec\ch"ars`: {
TableInfo: map[string]serverpb.ReplicaMatrixResponse_TableInfo{
TableInfo: map[string]serverpb.DataDistributionResponse_TableInfo{
`more\spec'chars`: {
ReplicaCountByNodeId: map[roachpb.NodeID]int64{
1: 1,
Expand All @@ -1365,7 +1365,7 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {

// Wait for the new tables' ranges to be created and replicated.
testutils.SucceedsSoon(t, func() error {
var resp serverpb.ReplicaMatrixResponse
var resp serverpb.DataDistributionResponse
if err := getAdminJSONProto(firstServer, "replica_matrix", &resp); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1399,7 +1399,7 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {

// Verify that we see the zone config and its effects.
testutils.SucceedsSoon(t, func() error {
var resp serverpb.ReplicaMatrixResponse
var resp serverpb.DataDistributionResponse
if err := getAdminJSONProto(firstServer, "replica_matrix", &resp); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1428,7 +1428,7 @@ func TestAdminAPIReplicaMatrix(t *testing.T) {
})
}

func BenchmarkAdminAPIReplicaMatrix(b *testing.B) {
func BenchmarkAdminAPIDataDistribution(b *testing.B) {
testCluster := serverutils.StartTestCluster(b, 3, base.TestClusterArgs{})
defer testCluster.Stopper().Stop(context.Background())

Expand All @@ -1448,7 +1448,7 @@ func BenchmarkAdminAPIReplicaMatrix(b *testing.B) {

b.ResetTimer()
for n := 0; n < b.N; n++ {
var resp serverpb.ReplicaMatrixResponse
var resp serverpb.DataDistributionResponse
if err := getAdminJSONProto(firstServer, "replica_matrix", &resp); err != nil {
b.Fatal(err)
}
Expand Down
Loading