divyadesai | 81bb7ba | 2020-03-11 11:45:23 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package tracker |
| 16 | |
| 17 | // StateType is the state of a tracked follower. |
| 18 | type StateType uint64 |
| 19 | |
| 20 | const ( |
| 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 | |
| 36 | var prstmap = [...]string{ |
| 37 | "StateProbe", |
| 38 | "StateReplicate", |
| 39 | "StateSnapshot", |
| 40 | } |
| 41 | |
| 42 | func (st StateType) String() string { return prstmap[uint64(st)] } |