blob: 285b4b8f5802127a51db66b6296461c24d28ea60 [file] [log] [blame]
Scott Baker8487c5d2019-10-18 12:49:46 -07001// Copyright 2019 The etcd 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 implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package tracker
16
17// StateType is the state of a tracked follower.
18type StateType uint64
19
20const (
21 // StateProbe indicates a follower whose last index isn't known. Such a
22 // follower is "probed" (i.e. an append sent periodically) to narrow down
23 // its last index. In the ideal (and common) case, only one round of probing
24 // is necessary as the follower will react with a hint. Followers that are
25 // probed over extended periods of time are often offline.
26 StateProbe StateType = iota
27 // StateReplicate is the state steady in which a follower eagerly receives
28 // log entries to append to its log.
29 StateReplicate
30 // StateSnapshot indicates a follower that needs log entries not available
31 // from the leader's Raft log. Such a follower needs a full snapshot to
32 // return to StateReplicate.
33 StateSnapshot
34)
35
36var prstmap = [...]string{
37 "StateProbe",
38 "StateReplicate",
39 "StateSnapshot",
40}
41
42func (st StateType) String() string { return prstmap[uint64(st)] }