kvscheduler

package
v2.0.0-alpha+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 22 Imported by: 222

Documentation

Index

Constants

View Source
const (
	// DependencyRelation identifies dependency relation for the graph.
	DependencyRelation = "depends-on"

	// DerivesRelation identifies relation of value derivation for the graph.
	DerivesRelation = "derives"
)
View Source
const (

	// SB = southbound (what there really is)
	SB = "SB"

	// NB = northbound (the requested state)
	NB = "NB"
)
View Source
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

View Source
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

func (flag *ErrorFlag) GetName() string

GetName return name of the Origin flag.

func (*ErrorFlag) GetValue

func (flag *ErrorFlag) GetValue() string

GetValue returns the error as string.

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.

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

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

func NewPlugin(opts ...Option) *Scheduler

NewPlugin creates a new Plugin with the provided Options.

func (*Scheduler) AfterInit

func (scheduler *Scheduler) AfterInit() error

AfterInit subscribes to known NB prefixes.

func (*Scheduler) Close

func (scheduler *Scheduler) Close() error

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

func (scheduler *Scheduler) GetRegisteredNBKeyPrefixes() []string

GetRegisteredNBKeyPrefixes returns a list of key prefixes from NB with values described by registered descriptors and therefore managed by the scheduler.

func (*Scheduler) GetValue

func (scheduler *Scheduler) GetValue(key string) proto.Message

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

func (scheduler *Scheduler) Init() error

Init initializes the scheduler. Single go routine is started that will process all the transactions synchronously.

func (*Scheduler) IsInitialized

func (scheduler *Scheduler) IsInitialized() bool

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().

func (*Scheduler) SubscribeForErrors

func (scheduler *Scheduler) SubscribeForErrors(channel chan<- KeyWithError, selector KeySelector)

SubscribeForErrors allows to get notified about all failed (Error!=nil) and restored (Error==nil) values (possibly filtered using the selector).

func (*Scheduler) TransactionBarrier

func (scheduler *Scheduler) TransactionBarrier()

TransactionBarrier ensures that all notifications received prior to the call are associated with transactions that have already finalized.

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.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL