Permalink
Newer
Older
100644 181 lines (154 sloc) 8.13 KB
1
// Copyright 2015 The Cockroach Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
14
15
syntax = "proto2";
16
package cockroach.config;
17
option go_package = "config";
18
19
import "gogoproto/gogo.proto";
20
21
// GCPolicy defines garbage collection policies which apply to MVCC
22
// values within a zone.
23
//
24
// TODO(spencer): flesh this out to include maximum number of values
25
// as well as whether there's an intersection between max values
26
// and TTL or a union.
27
message GCPolicy {
28
option (gogoproto.equal) = true;
29
option (gogoproto.populate) = true;
31
// TTLSeconds specifies the maximum age of a value before it's
32
// garbage collected. Only older versions of values are garbage
33
// collected. Specifying <=0 mean older versions are never GC'd.
34
optional int32 ttl_seconds = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "TTLSeconds"];
35
}
36
37
// Constraint constrains the stores a replica can be stored on.
38
message Constraint {
39
option (gogoproto.equal) = true;
40
option (gogoproto.goproto_stringer) = false;
41
option (gogoproto.populate) = true;
42
43
enum Type {
44
// DEPRECATED_POSITIVE has no effect on a replica's placement.
45
DEPRECATED_POSITIVE = 0;
46
// REQUIRED ensures all replicas are placed on stores that match the
47
// constraint. Replication will fail if there aren't any such stores.
48
REQUIRED = 1;
49
// PROHIBITED will prevent replicas from having this key, value.
50
PROHIBITED = 2;
51
}
52
optional Type type = 1 [(gogoproto.nullable) = false];
53
// Key is only set if this is a constraint on locality.
54
optional string key = 2 [(gogoproto.nullable) = false];
55
// Value to constrain to.
56
optional string value = 3 [(gogoproto.nullable) = false];
57
}
58
59
// Constraints is a collection of constraints.
60
message Constraints {
61
option (gogoproto.equal) = true;
62
option (gogoproto.populate) = true;
63
64
// The number of replicas that should abide by the constraints. If left
65
// unspecified (i.e. set to 0), the constraints will be assumed to apply
66
// to all replicas of the range.
67
// As of v2.0, only REQUIRED constraints are allowed when num_replicas is
68
// set to a non-zero value.
69
optional int32 num_replicas = 7 [(gogoproto.nullable) = false];
71
repeated Constraint constraints = 6 [(gogoproto.nullable) = false];
72
}
73
74
// LeasePreference specifies a preference about where range leases should be
75
// located.
76
message LeasePreference {
77
option (gogoproto.equal) = true;
78
option (gogoproto.populate) = true;
79
80
repeated Constraint constraints = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constraints,flow\""];
81
}
82
83
// ZoneConfig holds configuration that applies to one or more ranges.
84
//
85
// Note: when adding.removing fields here, be sure to update
86
// supportedZoneConfigOptions in the sql package, to synchronize
87
// with the code for ALTER ... CONFIGURE ZONE.
88
message ZoneConfig {
89
option (gogoproto.equal) = true;
90
option (gogoproto.populate) = true;
92
reserved 1;
93
optional int64 range_min_bytes = 2 [(gogoproto.moretags) = "yaml:\"range_min_bytes\""];
94
optional int64 range_max_bytes = 3 [(gogoproto.moretags) = "yaml:\"range_max_bytes\""];
95
// If GC policy is not set, uses the next highest, non-null policy
96
// in the zone config hierarchy, up to the default policy if necessary.
97
optional GCPolicy gc = 4 [(gogoproto.customname) = "GC"];
98
// NumReplicas specifies the desired number of replicas
99
optional int32 num_replicas = 5 [(gogoproto.moretags) = "yaml:\"num_replicas\""];
100
// Constraints constrains which stores the replicas can be stored on. The
101
// order in which the constraints are stored is arbitrary and may change.
Oct 11, 2017
102
// https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20160706_expressive_zone_config.md#constraint-system
103
//
104
// NOTE: The sum of the num_replicas fields of the Constraints must add up to
105
// ZoneConfig.num_replicas, or there must be no more than a single Constraints
106
// field with num_replicas set to 0.
107
repeated Constraints constraints = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constraints,flow\""];
109
// InheritedContraints specifies if the value in the Constraints field was
110
// inherited from the zone's parent or specified explicitly by the user.
111
optional bool inherited_constraints = 10 [(gogoproto.nullable) = false];
113
// LeasePreference stores information about where the user would prefer for
114
// range leases to be placed. Leases are allowed to be placed elsewhere if
115
// needed, but will follow the provided preference when possible.
116
//
117
// More than one lease preference is allowed, but they should be ordered from
118
// most preferred to lease preferred. The first preference that an existing
119
// replica of a range matches will take priority.
120
repeated LeasePreference lease_preferences = 9 [(gogoproto.nullable) = false,
121
(gogoproto.moretags) = "yaml:\"lease_preferences,flow\""];
123
// InheritedLeasePreferences specifies if the value in the LeasePreferences field
124
// was inherited from the zone's parent or specified explicitly by the user.
125
optional bool inherited_lease_preferences = 11 [(gogoproto.nullable) = false];
127
// Subzones stores config overrides for "subzones", each of which represents
128
// either a SQL table index or a partition of a SQL table index. Subzones are
129
// not applicable when the zone does not represent a SQL table (i.e., when the
130
// zone represents a database, a special system range, or is itself a
131
// subzone.)
132
repeated Subzone subzones = 8 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"-\""];
133
134
// SubzoneSpans maps each key span in a subzone to the slice index of an entry
135
// in SubzoneConfig. Spans are non-overlapping and sorted by start key to
136
// allow binary searching. SubzoneSpans can be easily derived from a
137
// TableDescriptor, but are denormalized here to make GetZoneConfigForKey
138
// lookups efficient.
139
repeated SubzoneSpan subzone_spans = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"-\""];
140
}
141
142
message Subzone {
143
option (gogoproto.equal) = true;
144
option (gogoproto.populate) = true;
146
// IndexID is the ID of the SQL table index that the subzone represents. It
147
// must always be set even though partition names are unique across all of a
148
// table's indices.
149
optional uint32 index_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "IndexID"];
150
151
// PartitionName is the partition of the SQL table index that the subzone
152
// represents. It is empty when the subzone represents the entire index.
153
optional string partition_name = 2 [(gogoproto.nullable) = false];
154
155
// Config stores the ZoneConfig that applies to this Subzone. It never
156
// contains nested subzones.
157
optional ZoneConfig config = 3 [(gogoproto.nullable) = false];
158
}
159
160
message SubzoneSpan {
161
option (gogoproto.equal) = true;
162
option (gogoproto.populate) = true;
163
164
// Key stores a key suffix that represents the inclusive lower bound for this
165
// span. The SQL table prefix, like /Table/51/, is omitted.
166
//
167
// Both Key and EndKey, below, are cast to roachpb.Key for convenience, but
168
// there's no technical restriction that prevents switching them to []byte or
169
// another type that communicates their missing prefix.
170
optional bytes key = 1 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.Key"];
171
172
// EndKey stores a key suffix that represents the exclusive upper bound for
173
// this span. Like with Key, the SQL table prefix is omitted. If EndKey is
174
// empty, it is assumed to be Key.PrefixEnd().
175
optional bytes end_key = 2 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.Key"];
176
177
// SubzoneIndex is the slice index of the Subzone this span belongs to in the
178
// parent ZoneConfig's Subzones field.
179
optional int32 subzone_index = 3 [(gogoproto.nullable) = false];