Skip to content

Commit

Permalink
storage: add interfaces for copysets
Browse files Browse the repository at this point in the history
Copysets significantly reduce the probability of data loss
in the presence of multi node failures. The RFC for copysets
is presented in cockroachdb#32816.

This commit adds interfaces and protos for copysets.
The implementation added later will have two independent tracks:
1. Assignment and persistance of store_id-copyset_id mapping.
2. Rebalancer changes to rebalance replicas into copysets.

Release note: None
  • Loading branch information
Vijay Karthik committed Jan 22, 2019
1 parent 7983048 commit 945ebd9
Show file tree
Hide file tree
Showing 4 changed files with 1,166 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/roachpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func (n StoreID) String() string {
return strconv.FormatInt(int64(n), 10)
}

// CopysetID is a custom type for a cockroach copyset ID.
// Copyset is a group of stores where a range should be contained within
// if copyset based rebalancing is enabled.
type CopysetID int32

// ReplicaID is a custom type for a range replica ID.
type ReplicaID int32

Expand Down
38 changes: 38 additions & 0 deletions pkg/storage/copysets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2018 The Cockroach Authors.
//
// Licensed 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.

package storage

import "context"

// copysetsReader is used to read copysets in the cluster.
type copysetsReader interface {
// forRF returns copysets for the given replication factor.
forRF(ctx context.Context, replicationFactor int32) (*Copysets, error)
}

// CopysetsMaintainer maintains and assigns copysets to stores.
// TODO(hassan): implement CopysetsMaintainer.
type CopysetsMaintainer struct {
}

// Ensure CopysetsMaintainer implements copysetsReader.
var _ copysetsReader = &CopysetsMaintainer{}

// forRF returns copysets for the given replication factor.
func (cs *CopysetsMaintainer) forRF(
ctx context.Context, replicationFactor int32,
) (*Copysets, error) {
return nil, nil
}
Loading

0 comments on commit 945ebd9

Please sign in to comment.