Documentation ¶
Index ¶
- Constants
- Variables
- func NewDotCluster(id string) *dotCluster
- func WriteDot(w io.Writer, g *dotGraph) error
- type Config
- type Deps
- type DerivedFlag
- type DescriptorFlag
- type ErrorFlag
- type LastUpdateFlag
- type Option
- type Scheduler
- func (s *Scheduler) Close() error
- func (s *Scheduler) DumpValuesByDescriptor(descriptor string, view kvs.View) (values []kvs.KVWithMetadata, err error)
- func (s *Scheduler) DumpValuesByKeyPrefix(keyPrefix string, view kvs.View) (values []kvs.KVWithMetadata, err error)
- func (s *Scheduler) GetMetadataMap(descriptor string) idxmap.NamedMapping
- func (s *Scheduler) GetRecordedTransaction(SeqNum uint64) (txn *kvs.RecordedTxn)
- func (s *Scheduler) GetRegisteredNBKeyPrefixes() []string
- func (s *Scheduler) GetTransactionHistory(since, until time.Time) (history kvs.RecordedTxns)
- func (s *Scheduler) GetValueStatus(key string) *kvs.BaseValueStatus
- func (s *Scheduler) Init() error
- func (s *Scheduler) PushSBNotification(key string, value proto.Message, metadata kvs.Metadata) error
- func (s *Scheduler) RegisterKVDescriptor(descriptors ...*kvs.KVDescriptor) error
- func (s *Scheduler) StartNBTransaction() kvs.Txn
- func (s *Scheduler) TransactionBarrier()
- func (s *Scheduler) WatchValueStatus(channel chan<- *kvs.BaseValueStatus, keySelector kvs.KeySelector)
- type SchedulerTxn
- type Stats
- type StructStats
- type TxnStats
- type UnavailValueFlag
- type ValueStateFlag
Constants ¶
const ( // DependencyRelation identifies dependency relation for the graph. DependencyRelation = "depends-on" // DerivesRelation identifies relation of value derivation for the graph. DerivesRelation = "derives" )
const ( // LastUpdateFlagName is the name of the LastUpdate flag. LastUpdateFlagName = "last-update" // LastUpdateFlagIndex is the Index of the LastUpdate flag. LastUpdateFlagIndex = 0 // ErrorFlagName is the name of the Error flag. ErrorFlagName = "error" // ErrorFlagIndex is the Index of the ErrorFlag flag. ErrorFlagIndex = 1 // ValueStateFlagName is the name of the Value-State flag. ValueStateFlagName = "value-state" // ValueStateFlagIndex is the index of the Value-State flag. ValueStateFlagIndex = 2 UnavailValueFlagName = "unavailable" UnavailValueFlagIndex = 3 // DescriptorFlagName is the name of the Descriptor flag. DescriptorFlagName = "descriptor" // DescriptorFlagIndex is the index of the Descriptor flag. DescriptorFlagIndex = 4 // DerivedFlagName is the name of the Derived flag. DerivedFlagName = "derived" // DerivedFlagIndex is the index of the Derived flag. DerivedFlagIndex = 5 )
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of Plugin.
Functions ¶
func NewDotCluster ¶
func NewDotCluster(id string) *dotCluster
Types ¶
type Config ¶
type Config struct { RecordTransactionHistory bool `json:"record-transaction-history"` TransactionHistoryAgeLimit uint32 `json:"transaction-history-age-limit"` // in minutes PermanentlyRecordedInitPeriod uint32 `json:"permanently-recorded-init-period"` // in minutes EnableTxnSimulation bool `json:"enable-txn-simulation"` PrintTxnSummary bool `json:"print-txn-summary"` }
Config holds the KVScheduler configuration.
type Deps ¶
type Deps struct { infra.PluginDeps HTTPHandlers rest.HTTPHandlers }
Deps lists dependencies of the scheduler.
type DerivedFlag ¶
type DerivedFlag struct {
// contains filtered or unexported fields
}
DerivedFlag is used to mark derived values.
func (*DerivedFlag) GetName ¶
func (flag *DerivedFlag) GetName() string
GetName return name of the Derived flag.
func (*DerivedFlag) GetValue ¶
func (flag *DerivedFlag) GetValue() string
GetValue returns the key of the base value from which the given derived value is derived from (directly or transitively).
type DescriptorFlag ¶
type DescriptorFlag struct {
// contains filtered or unexported fields
}
DescriptorFlag is used to lookup values by their descriptor. Not assigned to properties and UNIMPLEMENTED values.
func (*DescriptorFlag) GetName ¶
func (flag *DescriptorFlag) GetName() string
GetName return name of the Descriptor flag.
func (*DescriptorFlag) GetValue ¶
func (flag *DescriptorFlag) GetValue() string
GetValue returns the descriptor name.
type ErrorFlag ¶
type ErrorFlag struct {
// contains filtered or unexported fields
}
ErrorFlag is used to store error returned from the last operation, including validation errors.
type LastUpdateFlag ¶
type LastUpdateFlag struct {
// contains filtered or unexported fields
}
LastUpdateFlag is set to remember the last transaction which has changed/updated the value. Not set to values just discovered by refresh (state = DISCOVERED).
func (*LastUpdateFlag) GetName ¶
func (flag *LastUpdateFlag) GetName() string
GetName return name of the LastUpdate flag.
func (*LastUpdateFlag) GetValue ¶
func (flag *LastUpdateFlag) GetValue() string
GetValue describes the last update (txn-seq number only).
type Option ¶
type Option func(*Scheduler)
Option is a function that can be used in NewPlugin to customize Plugin.
type Scheduler ¶
type Scheduler struct { Deps // contains filtered or unexported fields }
Scheduler is a CN-infra plugin implementing KVScheduler. Detailed documentation can be found in the "api" and "docs" sub-folders.
func (*Scheduler) DumpValuesByDescriptor ¶
func (s *Scheduler) DumpValuesByDescriptor(descriptor string, view kvs.View) (values []kvs.KVWithMetadata, err error)
DumpValuesByDescriptor dumps values associated with the given descriptor as viewed from either NB (what was requested to be applied), SB (what is actually applied) or from the inside (what kvscheduler's cached view of SB is).
func (*Scheduler) DumpValuesByKeyPrefix ¶
func (s *Scheduler) DumpValuesByKeyPrefix(keyPrefix string, view kvs.View) (values []kvs.KVWithMetadata, err error)
DumpValuesByKeyPrefix like DumpValuesByDescriptor returns a dump of values, but the descriptor is selected based on the key prefix.
func (*Scheduler) GetMetadataMap ¶
func (s *Scheduler) GetMetadataMap(descriptor string) idxmap.NamedMapping
GetMetadataMap returns (read-only) map associating value label with value metadata of a given descriptor. Returns nil if the descriptor does not expose metadata.
func (*Scheduler) GetRecordedTransaction ¶
func (s *Scheduler) GetRecordedTransaction(SeqNum uint64) (txn *kvs.RecordedTxn)
GetRecordedTransaction returns record of a transaction referenced by the sequence number.
func (*Scheduler) GetRegisteredNBKeyPrefixes ¶
GetRegisteredNBKeyPrefixes returns a list of key prefixes from NB with values described by registered descriptors and therefore managed by the scheduler.
func (*Scheduler) GetTransactionHistory ¶
func (s *Scheduler) GetTransactionHistory(since, until time.Time) (history kvs.RecordedTxns)
GetTransactionHistory returns history of transactions started within the specified time window, or the full recorded history if the timestamps are zero values.
func (*Scheduler) GetValueStatus ¶
func (s *Scheduler) GetValueStatus(key string) *kvs.BaseValueStatus
GetValueStatus returns the status of a non-derived value with the given key.
func (*Scheduler) Init ¶
Init initializes the scheduler. Single go routine is started that will process all the transactions synchronously.
func (*Scheduler) PushSBNotification ¶
func (s *Scheduler) PushSBNotification(key string, value proto.Message, metadata kvs.Metadata) error
PushSBNotification notifies about a spontaneous value change in the SB plane (i.e. not triggered by NB transaction).
func (*Scheduler) RegisterKVDescriptor ¶
func (s *Scheduler) RegisterKVDescriptor(descriptors ...*kvs.KVDescriptor) error
RegisterKVDescriptor registers descriptor(s) for a set of selected keys. It should be called in the Init phase of agent plugins. Every key-value pair must have at most one descriptor associated with it (none for derived values expressing properties).
func (*Scheduler) StartNBTransaction ¶
StartNBTransaction starts a new transaction from NB to SB plane. The enqueued actions are scheduled for execution by Txn.Commit().
func (*Scheduler) TransactionBarrier ¶
func (s *Scheduler) TransactionBarrier()
TransactionBarrier ensures that all notifications received prior to the call are associated with transactions that have already finalized.
func (*Scheduler) WatchValueStatus ¶
func (s *Scheduler) WatchValueStatus(channel chan<- *kvs.BaseValueStatus, keySelector kvs.KeySelector)
WatchValueStatus allows to watch for changes in the status of non-derived values with keys selected by the selector (all if keySelector==nil).
type SchedulerTxn ¶
type SchedulerTxn struct {
// contains filtered or unexported fields
}
SchedulerTxn implements transaction for the KV scheduler.
type Stats ¶
type Stats struct { TxnStats TxnStats GraphMethods StructStats AllDescriptors StructStats Descriptors map[string]*StructStats }
type StructStats ¶
func (*StructStats) MarshalJSON ¶
func (s *StructStats) MarshalJSON() ([]byte, error)
type UnavailValueFlag ¶
type UnavailValueFlag struct { }
UnavailValueFlag is used to mark NB values which should not be considered when resolving dependencies of other values (for various possible reasons).
func (*UnavailValueFlag) GetIndex ¶
func (flag *UnavailValueFlag) GetIndex() int
GetIndex returns 3.
func (*UnavailValueFlag) GetName ¶
func (flag *UnavailValueFlag) GetName() string
GetName return name of the UnavailValue flag.
func (*UnavailValueFlag) GetValue ¶
func (flag *UnavailValueFlag) GetValue() string
GetValue return empty string (presence of the flag is the only information).
type ValueStateFlag ¶
type ValueStateFlag struct {
// contains filtered or unexported fields
}
ValueStateFlag stores current state of the value. Assigned to every value.
func (*ValueStateFlag) GetName ¶
func (flag *ValueStateFlag) GetName() string
GetName returns name of the ValueState flag.
func (*ValueStateFlag) GetValue ¶
func (flag *ValueStateFlag) GetValue() string
GetValue returns the string representation of the state.