Documentation ¶
Index ¶
- type AgentState
- type AgentStateSnapshot
- type AlertInfosStateSnapShot
- type Cluster
- func (cluster *Cluster) DeleteFaultInStorage(faultName string) error
- func (cluster *Cluster) GetFaultInStorage(faultName string) int32
- func (cluster *Cluster) GetFaultSn(faultID int32) int64
- func (cluster *Cluster) GetFaultStartEpoch(faultID int32) int64
- func (cluster *Cluster) IncrementFaultSn(faultID int32) error
- func (cluster *Cluster) InitAlertInfos(faultID int32) error
- func (cluster *Cluster) Interval(sched string) time.Duration
- func (cluster *Cluster) LeaderCh() <-chan bool
- func (cluster *Cluster) NextFaultIndex() (int32, error)
- func (cluster *Cluster) NextHeartbeatIndex() (int64, error)
- func (cluster *Cluster) NextMeasurementIndex() (int64, error)
- func (cluster *Cluster) NextRun(sched string) time.Time
- func (cluster *Cluster) SetFaultStartEpoch(faultID int32, epoch int64) error
- func (cluster *Cluster) Shutdown() error
- func (cluster *Cluster) Stats() map[string]string
- func (cluster *Cluster) StoreFaultInStorage(faultName string, faultID int32) error
- func (cluster *Cluster) UpdateInterval(sched string, interval time.Duration) error
- func (cluster *Cluster) UpdateNextRun(sched string, next time.Time) error
- func (cluster *Cluster) UpdateScheduler(sched string, interval time.Duration, next time.Time) error
- type CmdType
- type DeleteFaultFields
- type FSM
- func (fsm *FSM) Apply(logEntry *raft.Log) interface{}
- func (fsm *FSM) DeleteFaultInStorage(faultName string) error
- func (fsm *FSM) GetFaultInStorage(faultName string) int32
- func (fsm *FSM) GetFaultSn(fault int32) int64
- func (fsm *FSM) GetFaultStartEpoch(fault int32) int64
- func (fsm *FSM) InitAlertInfos(fault int32) error
- func (fsm *FSM) Interval(sched string) time.Duration
- func (fsm *FSM) NextRun(sched string) time.Time
- func (fsm *FSM) Restore(input io.ReadCloser) error
- func (fsm *FSM) Snapshot() (raft.FSMSnapshot, error)
- type SchedulerStateSnapshot
- type SnapshotableAgentState
- type StateCmd
- type UpdateFaultFields
- type UpdateSchedulerFields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentState ¶
type AgentState interface { scheduler.State heartbeat.MonitorState metrics.CollectorState convert.FaultManagerState }
AgentState is the interface that abstract manipulation of agent internal state
type AgentStateSnapshot ¶
type AgentStateSnapshot struct { MeasIdx int64 `json:"meas_idx"` HbIdx int64 `json:"hb_idx"` Schedulers map[string]SchedulerStateSnapshot `json:"schedulers"` FaultIdx int32 `json:"fault_idx"` AlertInfos map[int32]AlertInfosStateSnapShot `json:"alertInfos"` StorageFault map[string]int32 `json:"storageFault"` }
AgentStateSnapshot holds a serializable copy of agent state
func (*AgentStateSnapshot) Persist ¶
func (snap *AgentStateSnapshot) Persist(sink raft.SnapshotSink) error
Persist serialize the snapshot to the given output sink
func (*AgentStateSnapshot) Release ¶
func (snap *AgentStateSnapshot) Release()
Release realeases resources used by snapshot. Currently does nothing for AgentStateSnapshot
type AlertInfosStateSnapShot ¶
AlertInfosStateSnapShot is a snapshot of an alert info
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is a replicated AgentState in a raft cluster. It provides consistent write operations across the cluster, and those write operations are permitted only on the leader node.
func NewCluster ¶
func NewCluster(datadir string, cfg *config.ClusterConfiguration, state SnapshotableAgentState) (*Cluster, error)
NewCluster creates and start a new cluster around `state`. Cluster topology is included in `cfg`, but if `cfg` is null, the cluster will fallsback into single-node mode. On first creation, the cluster is boostrapped
func (*Cluster) DeleteFaultInStorage ¶
DeleteFaultInStorage delete Fault in storage
func (*Cluster) GetFaultInStorage ¶
GetFaultInStorage checks if faultName already associated to an index
func (*Cluster) GetFaultSn ¶
GetFaultSn return the fault sequence number
func (*Cluster) GetFaultStartEpoch ¶
GetFaultStartEpoch return the startEpoch
func (*Cluster) IncrementFaultSn ¶
IncrementFaultSn increments the fault sequence number
func (*Cluster) InitAlertInfos ¶
InitAlertInfos update the alertInfos map
func (*Cluster) LeaderCh ¶
LeaderCh returns a buffered channel which receive cluster leadership changes for the current node. It MUST be consummed
func (*Cluster) NextFaultIndex ¶
NextFaultIndex return the Fault Index and increments it
func (*Cluster) NextHeartbeatIndex ¶
NextHeartbeatIndex return the next event index and increments it
func (*Cluster) NextMeasurementIndex ¶
NextMeasurementIndex return the next event index and increments it
func (*Cluster) SetFaultStartEpoch ¶
SetFaultStartEpoch set the startEpoch
func (*Cluster) Stats ¶
Stats return a map with stats about the Raft cluster. This should be used only for debugging purpose. Do net expect this interface to remain stable over time
func (*Cluster) StoreFaultInStorage ¶
StoreFaultInStorage stores the index associated to the faultName
func (*Cluster) UpdateInterval ¶
UpdateInterval set a new execution interval for the scheduler
func (*Cluster) UpdateNextRun ¶
UpdateNextRun set the time of the next execution
type DeleteFaultFields ¶
type DeleteFaultFields struct { // FaultName of the fault to create FaultName string `json:"faultName"` }
DeleteFaultFields holds the fields for command of kind DeleteFault
func (*DeleteFaultFields) String ¶
func (fields *DeleteFaultFields) String() string
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
FSM is the internal Finite State Machine handling internal state changes across raft cluster
func NewFSM ¶
func NewFSM(state SnapshotableAgentState, debug bool) *FSM
NewFSM creates a new finite state machine wrapping a snapshotable state, and handling state changes across the raft cluster If `debug` is true, Commit logs are displayed in log output
func (*FSM) DeleteFaultInStorage ¶
DeleteFaultInStorage delete Fault in storage
func (*FSM) GetFaultInStorage ¶
GetFaultInStorage checks if faultName already associated to an index
func (*FSM) GetFaultSn ¶
GetFaultSn return the fault sequence number
func (*FSM) GetFaultStartEpoch ¶
GetFaultStartEpoch return the startEpoch
func (*FSM) InitAlertInfos ¶
InitAlertInfos update the alertInfos map
type SchedulerStateSnapshot ¶
type SchedulerStateSnapshot struct { Interval time.Duration `json:"interval"` Next time.Time `json:"time"` }
SchedulerStateSnapshot is a snapshiot of a scheduler's state
type SnapshotableAgentState ¶
type SnapshotableAgentState interface { AgentState // Snapshot creates a new state snapshot Snapshot() *AgentStateSnapshot // Restore state from the provided snapshot Restore(*AgentStateSnapshot) }
SnapshotableAgentState represent an agent state that supports snapshots and restore from a snapshot
func NewInMemState ¶
func NewInMemState() SnapshotableAgentState
NewInMemState creates a new snapshotable state stored in memory
type StateCmd ¶
type StateCmd struct { // Kind of command Type CmdType `json:"ty"` // Fields for command of kind UpdateScheduler UpdateScheduler *UpdateSchedulerFields `json:"sched,omitempty"` // Fields for command of kind UpdateFault UpdateFault *UpdateFaultFields `json:"updatefault,omitempty"` // Fields for command of kind DeleteFault DeleteFault *DeleteFaultFields `json:"deletefault,omitempty"` }
StateCmd is a state change command sent through commit logs
type UpdateFaultFields ¶
type UpdateFaultFields struct { // FaultID of the fault to update FaultID *int32 `json:"faultId"` // FaultName of the fault to create FaultName string `json:"faultName,omitempty"` // New value of sequenceNumber SequenceNumber *int64 `json:"sn,omitempty"` // New value of startEpoch StartEpoch *int64 `json:"epoch,omitempty"` }
UpdateFaultFields holds the fields for command of kind UpdateFault
func (*UpdateFaultFields) String ¶
func (fields *UpdateFaultFields) String() string
type UpdateSchedulerFields ¶
type UpdateSchedulerFields struct { // Name of scheduler to update Name string `json:"name"` // New value of interval, if updated, or nil Interval *time.Duration `json:"intv,omitempty"` // New value of next run epoch time (in seconds), if updated, or nil Next *int64 `json:"nxt,omitempty"` }
UpdateSchedulerFields holds the fields for command of kind UpdateScheduler
func (*UpdateSchedulerFields) String ¶
func (fields *UpdateSchedulerFields) String() string