Documentation
¶
Index ¶
- Constants
- Variables
- type Deps
- type DerivedFlag
- type DescriptorFlag
- type ErrorFlag
- type LastChangeFlag
- type LastUpdateFlag
- type Option
- type OriginFlag
- type PendingFlag
- type Scheduler
- func (scheduler *Scheduler) AfterInit() error
- func (scheduler *Scheduler) Close() error
- func (scheduler *Scheduler) GetFailedValues(selector KeySelector) []KeyWithError
- func (scheduler *Scheduler) GetMetadataMap(descriptor string) idxmap.NamedMapping
- func (scheduler *Scheduler) GetPendingValues(selector KeySelector) []KeyValuePair
- func (scheduler *Scheduler) GetRegisteredNBKeyPrefixes() []string
- func (scheduler *Scheduler) GetValue(key string) proto.Message
- func (scheduler *Scheduler) GetValues(selector KeySelector) []KeyValuePair
- func (scheduler *Scheduler) Init() error
- func (scheduler *Scheduler) IsInitialized() bool
- func (scheduler *Scheduler) PushSBNotification(key string, value proto.Message, metadata Metadata) error
- func (scheduler *Scheduler) RegisterKVDescriptor(descriptor *KVDescriptor)
- func (scheduler *Scheduler) StartNBTransaction() Txn
- func (scheduler *Scheduler) SubscribeForErrors(channel chan<- KeyWithError, selector KeySelector)
- func (scheduler *Scheduler) TransactionBarrier()
- type SchedulerTxn
Constants ¶
const ( // DependencyRelation identifies dependency relation for the graph. DependencyRelation = "depends-on" // DerivesRelation identifies relation of value derivation for the graph. DerivesRelation = "derives" )
const ( // SB = southbound (what there really is) SB = "SB" // NB = northbound (the requested state) NB = "NB" )
const ( // LastChangeFlagName is the name of the LastChange flag. LastChangeFlagName = "last-change" // LastUpdateFlagName is the name of the LastUpdate flag. LastUpdateFlagName = "last-update" // ErrorFlagName is the name of the Error flag. ErrorFlagName = "error" // PendingFlagName is the name of the Pending flag. PendingFlagName = "pending" // OriginFlagName is the name of the Origin flag. OriginFlagName = "origin" // DescriptorFlagName is the name of the Descriptor flag. DescriptorFlagName = "descriptor" // DerivedFlagName is the name of the Derived flag. DerivedFlagName = "derived" )
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of Plugin.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
infra.PluginName
Log logging.PluginLogger
HTTPHandlers rest.HTTPHandlers
Watcher datasync.KeyValProtoWatcher
}
Deps lists dependencies of the scheduler.
type DerivedFlag ¶
type DerivedFlag struct {
}
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 return empty string (presence of the flag is the only information).
type DescriptorFlag ¶
type DescriptorFlag struct {
// contains filtered or unexported fields
}
DescriptorFlag is used to lookup values by their descriptor.
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 mark base values that are in a failed state (or their derived values). It is used for KVScheduler.GetFailedValues(), also to inform user in the graph dump about currently failing values and finally for statistical purposes.
func (*ErrorFlag) GetName ¶
GetName return name of the Origin flag.
type LastChangeFlag ¶
type LastChangeFlag struct {
// contains filtered or unexported fields
}
LastChangeFlag is set to all base values to remember the last change from a NB transaction or a SB notification for a potential retry.
func (*LastChangeFlag) GetName ¶
func (flag *LastChangeFlag) GetName() string
GetName return name of the LastChange flag.
func (*LastChangeFlag) GetValue ¶
func (flag *LastChangeFlag) GetValue() string
GetValue describes the last change (txn-seq number only).
type LastUpdateFlag ¶
type LastUpdateFlag struct {
// contains filtered or unexported fields
}
LastUpdateFlag is set to all values to remember the last transaction which has changed/updated the value.
func (*LastUpdateFlag) GetName ¶
func (flag *LastUpdateFlag) GetName() string
GetName return name of the LastUpdate flag.
func (*LastUpdateFlag) GetValue ¶
func (flag *LastUpdateFlag) GetValue() string
GetValue return the sequence number of the last transaction that performed update.
type Option ¶
type Option func(*Scheduler)
Option is a function that can be used in NewPlugin to customize Plugin.
type OriginFlag ¶
type OriginFlag struct {
// contains filtered or unexported fields
}
OriginFlag is used to remember the origin of the value.
func (*OriginFlag) GetName ¶
func (flag *OriginFlag) GetName() string
GetName return name of the Origin flag.
func (*OriginFlag) GetValue ¶
func (flag *OriginFlag) GetValue() string
GetValue returns the value origin (as string).
type PendingFlag ¶
type PendingFlag struct {
}
PendingFlag is used to mark values that cannot be created because dependencies are not satisfied or the Add operation has failed.
func (*PendingFlag) GetName ¶
func (flag *PendingFlag) GetName() string
GetName return name of the Pending flag.
func (*PendingFlag) GetValue ¶
func (flag *PendingFlag) GetValue() string
GetValue return empty string (presence of the flag is the only information).
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 NewPlugin ¶
NewPlugin creates a new Plugin with the provided Options.
func (*Scheduler) AfterInit ¶
AfterInit subscribes to known NB prefixes.
func (*Scheduler) Close ¶
Close stops all the go routines.
func (*Scheduler) GetFailedValues ¶
func (scheduler *Scheduler) GetFailedValues(selector KeySelector) []KeyWithError
GetFailedValues returns a list of keys (possibly filtered by selector) whose (base) values are in a failed state (i.e. possibly not in the state as set by the last transaction).
func (*Scheduler) GetMetadataMap ¶
func (scheduler *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) GetPendingValues ¶
func (scheduler *Scheduler) GetPendingValues(selector KeySelector) []KeyValuePair
GetPendingValues returns list of values (possibly filtered by selector) waiting for their dependencies to be met.
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) GetValue ¶
GetValue currently set for the given key. The function can be used from within a transaction. However, if update of A uses the value of B, then A should be marked as dependent on B so that the scheduler can ensure that B is updated before A is.
func (*Scheduler) GetValues ¶
func (scheduler *Scheduler) GetValues(selector KeySelector) []KeyValuePair
GetValues returns a set of values matched by the given selector.
func (*Scheduler) Init ¶
Init initializes the scheduler. Single go routine is started that will process all the transactions synchronously.
func (*Scheduler) IsInitialized ¶
IsInitialized is a method temporarily used by PropagateChanges until datasync and scheduler are properly integrated.
func (*Scheduler) PushSBNotification ¶
func (scheduler *Scheduler) PushSBNotification(key string, value proto.Message, metadata Metadata) error
PushSBNotification notifies about a spontaneous value change in the SB plane (i.e. not triggered by NB transaction).
func (*Scheduler) RegisterKVDescriptor ¶
func (scheduler *Scheduler) RegisterKVDescriptor(descriptor *KVDescriptor)
RegisterKVDescriptor registers descriptor 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 ¶
func (scheduler *Scheduler) StartNBTransaction() Txn
StartNBTransaction starts a new transaction from NB to SB plane. The enqueued actions are scheduled for execution by Txn.Commit().
type SchedulerTxn ¶
type SchedulerTxn struct {
// contains filtered or unexported fields
}
SchedulerTxn implements transaction for the KV scheduler.
func (*SchedulerTxn) Commit ¶
func (txn *SchedulerTxn) Commit(ctx context.Context) (kvErrors []KeyWithError, txnError error)
Commit orders scheduler to execute enqueued operations. Operations with unmet dependencies will get postponed and possibly executed later.
func (*SchedulerTxn) SetValue ¶
func (txn *SchedulerTxn) SetValue(key string, value datasync.LazyValue) Txn
SetValue changes (non-derived) lazy value - un-marshalled during transaction pre-processing using ValueTypeName given by descriptor. If <value> is nil, the value will get deleted.
Source Files
¶
- descriptor_handler.go
- node_utils.go
- options.go
- plugin_scheduler.go
- refresh.go
- rest.go
- txn_exec.go
- txn_order.go
- txn_process.go
- txn_queue.go
- txn_record.go
- value_flags.go