state.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. package tracker
  15. // StateType is the state of a tracked follower.
  16. type StateType uint64
  17. const (
  18. // StateProbe indicates a follower whose last index isn't known. Such a
  19. // follower is "probed" (i.e. an append sent periodically) to narrow down
  20. // its last index. In the ideal (and common) case, only one round of probing
  21. // is necessary as the follower will react with a hint. Followers that are
  22. // probed over extended periods of time are often offline.
  23. StateProbe StateType = iota
  24. // StateReplicate is the state steady in which a follower eagerly receives
  25. // log entries to append to its log.
  26. StateReplicate
  27. // StateSnapshot indicates a follower that needs log entries not available
  28. // from the leader's Raft log. Such a follower needs a full snapshot to
  29. // return to StateReplicate.
  30. StateSnapshot
  31. )
  32. var prstmap = [...]string{
  33. "StateProbe",
  34. "StateReplicate",
  35. "StateSnapshot",
  36. }
  37. func (st StateType) String() string { return prstmap[uint64(st)] }