copysets.proto 2.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// Copyright 2019 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.

syntax = "proto3";
package cockroach.storage.copysets;
option go_package = "copysets";

import "gogoproto/gogo.proto";

// CopysetStrategy has the set of supported copyset-store allocation strategies.
enum CopysetStrategy {
  // MAXIMIZE_DIVERSITY is a strategy which tries to maximize locality diversity
  // when creating copysets from a store list.
  MAXIMIZE_DIVERSITY = 0;
  // MINIMIZE_MOVEMENT is a strategy which tries to minimize changes to
  // existing copysets when generating new copysets on store list changes.
  // It does not guarantee optimal locality diversity but tries to avoid
  // stores with same localities within copysets.
  MINIMIZE_MOVEMENT = 1;
}

// AllCopysets contains the map between replication factor to
// its copysets.
message AllCopysets {
  // Map from replication factors to copysets.
  map<int32, Copysets> by_rf = 1 [(gogoproto.nullable) = false];
  // Strategy used for store-copyset allocation.
  CopysetStrategy strategy = 2;
}

// Copysets contains copysets for a particular replication factor.
// If copysets based rebalancing is enabled, the replicas of a range will
// be contained within a copy set. Each store belongs to a single copyset.
// Copyset based rebalancing significantly improves failure tolerance.
message Copysets {
  // Map from CopysetID to a Copyset (set of stores in the copyset).
  map<int32, Copyset> sets = 1 [(gogoproto.nullable) = false,
      (gogoproto.castkey) = "CopysetID"];
  // Replication factor of copy sets.
  int32 replication_factor = 2;
}

// Copyset contains the set of stores belonging to the same copyset.
message Copyset{
  // Map of StoreIDs.
  map<int32, bool> ids = 1 [
      (gogoproto.castkey) = "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID"];
}