Documentation ¶
Overview ¶
Package control PluginManger manages loading, unloading, and swapping of plugins
Index ¶
- Constants
- Variables
- func MonitorDurationOption(v time.Duration) monitorOption
- func New(cfg *Config) *pluginControl
- func NewPluginConfigItem() *pluginConfigItem
- func NewPluginsConfig() map[string]*pluginConfigItem
- func OptSetPluginConfig(cf *pluginConfig) pluginManagerOpt
- type Config
- func (p *Config) DeletePluginConfigDataNodeField(pluginType core.PluginType, name string, ver int, fields ...string) cdata.ConfigDataNode
- func (p *Config) DeletePluginConfigDataNodeFieldAll(fields ...string) cdata.ConfigDataNode
- func (p *Config) GetPluginConfigDataNode(pluginType core.PluginType, name string, ver int) cdata.ConfigDataNode
- func (p *Config) GetPluginConfigDataNodeAll() cdata.ConfigDataNode
- func (p *Config) MergePluginConfigDataNode(pluginType core.PluginType, name string, ver int, cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
- func (p *Config) MergePluginConfigDataNodeAll(cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
- func (c *Config) UnmarshalJSON(data []byte) error
- type ControlGRPCServer
- func (pc *ControlGRPCServer) CollectMetrics(ctx context.Context, r *rpc.CollectMetricsRequest) (*rpc.CollectMetricsResponse, error)
- func (pc *ControlGRPCServer) GetAutodiscoverPaths(ctx context.Context, _ *common.Empty) (*rpc.GetAutodiscoverPathsReply, error)
- func (pc *ControlGRPCServer) ProcessMetrics(ctx context.Context, r *rpc.PubProcMetricsRequest) (*rpc.ProcessMetricsReply, error)
- func (pc *ControlGRPCServer) PublishMetrics(ctx context.Context, r *rpc.PubProcMetricsRequest) (*rpc.ErrorReply, error)
- func (pc *ControlGRPCServer) SubscribeDeps(ctx context.Context, r *rpc.SubscribeDepsRequest) (*rpc.SubscribeDepsReply, error)
- func (pc *ControlGRPCServer) UnsubscribeDeps(ctx context.Context, r *rpc.UnsubscribeDepsRequest) (*rpc.UnsubscribeDepsReply, error)
- func (pc *ControlGRPCServer) ValidateDeps(ctx context.Context, r *rpc.ValidateDepsRequest) (*rpc.ValidateDepsReply, error)
- type MTTrie
- func (mtt MTTrie) Add(mt *metricType)
- func (m *MTTrie) DeleteByPlugin(lp *loadedPlugin)
- func (mtt MTTrie) Fetch(ns []string) ([]*metricType, error)
- func (mtt MTTrie) Get(ns []string) ([]*metricType, error)
- func (mtt MTTrie) Remove(ns []string) error
- func (m *MTTrie) RemoveMetric(mt metricType)
- func (m *MTTrie) String() string
- type ManagesSubscriptionGroups
- type PluginControlOpt
Constants ¶
const ( // DefaultClientTimeout - default timeout for a client connection attempt DefaultClientTimeout = time.Second * 10 // DefaultHealthCheckTimeout - default timeout for a health check DefaultHealthCheckTimeout = time.Second * 1 // DefaultHealthCheckFailureLimit - how any consecutive health check timeouts must occur to trigger a failure DefaultHealthCheckFailureLimit = 3 )
const ( // PluginTrustDisabled - enum representing plugin trust disabled PluginTrustDisabled int = iota // PluginTrustEnabled - enum representing plugin trust enabled PluginTrustEnabled // PluginTrustWarn - enum representing plugin trust warning PluginTrustWarn )
const ( // MonitorStopped - enum representation of monitor stopped state MonitorStopped monitorState = iota - 1 // default is stopped // MonitorStarted - enum representation of monitor started state MonitorStarted // DefaultMonitorDuration - the default monitor duration. DefaultMonitorDuration = time.Second * 1 )
const ( // DetectedState is the detected state of a plugin DetectedState pluginState = "detected" // LoadingState is the loading state of a plugin LoadingState pluginState = "loading" // LoadedState is the loaded state of a plugin LoadedState pluginState = "loaded" // UnloadedState is the unloaded state of a plugin UnloadedState pluginState = "unloaded" )
const ( // HandlerRegistrationName is the registered name of the control runner HandlerRegistrationName = "control.runner" // PluginRunning is the running state of a plugin PluginRunning availablePluginState = iota - 1 // Default value (0) is Running // PluginStopped is the stopped state of a plugin PluginStopped // PluginDisabled is the disabled state of a plugin PluginDisabled // MaximumRestartOnDeadPluginEvent is the maximum count of restarting a plugin // after the event of control_event.DeadAvailablePluginEvent MaxPluginRestartCount = 3 )
const (
CONFIG_CONSTRAINTS = `` /* 803-byte string literal not displayed */
)
Variables ¶
var ( ErrPoolNotFound = errors.New("plugin pool not found") ErrBadKey = errors.New("bad key") ErrBadTaskId = errors.New("bad task id") )
var ( // ErrLoadedPluginNotFound - error message when a loaded plugin is not found ErrLoadedPluginNotFound = errors.New("Loaded plugin not found") // ErrControllerNotStarted - error message when the Controller was not started ErrControllerNotStarted = errors.New("Must start Controller before use") )
var ( // ErrPluginNotFound - error message when a plugin is not found ErrPluginNotFound = errors.New("plugin not found") // ErrPluginAlreadyLoaded - error message when a plugin is already loaded ErrPluginAlreadyLoaded = errors.New("plugin is already loaded") // ErrPluginNotInLoadedState - error message when a plugin must ne in a loaded state ErrPluginNotInLoadedState = errors.New("Plugin must be in a LoadedState") )
var ( // ErrSubscriptionGroupAlreadyExists - error message when the subscription // group already exists ErrSubscriptionGroupAlreadyExists = core.ErrSubscriptionGroupAlreadyExists // ErrSubscriptionGroupDoesNotExist - error message when the subscription // group does not exist ErrSubscriptionGroupDoesNotExist = core.ErrSubscriptionGroupDoesNotExist ErrConfigRequiredForMetric = errors.New("config required") )
var ErrNotFound = errors.New("metric not found")
ErrNotFound is returned when Get cannot find the given namespace
var (
Flags = []cli.Flag{flNumberOfPLs, flPluginLoadTimeout, flAutoDiscover, flPluginTrust, flKeyringPaths, flCache, flControlRpcPort, flControlRpcAddr}
)
Functions ¶
func MonitorDurationOption ¶
MonitorDurationOption sets monitor's duration to v.
func NewPluginConfigItem ¶
func NewPluginConfigItem() *pluginConfigItem
NewPluginConfigItem returns a *pluginConfigItem.
func NewPluginsConfig ¶
func NewPluginsConfig() map[string]*pluginConfigItem
NewPluginsConfig returns a map of *pluginConfigItems where the key is the plugin name.
func OptSetPluginConfig ¶
func OptSetPluginConfig(cf *pluginConfig) pluginManagerOpt
OptSetPluginConfig sets the config on the plugin manager
Types ¶
type Config ¶
type Config struct { MaxRunningPlugins int `json:"max_running_plugins"yaml:"max_running_plugins"` PluginLoadTimeout int `json:"plugin_load_timeout"yaml:"plugin_load_timeout"` PluginTrust int `json:"plugin_trust_level"yaml:"plugin_trust_level"` AutoDiscoverPath string `json:"auto_discover_path"yaml:"auto_discover_path"` KeyringPaths string `json:"keyring_paths"yaml:"keyring_paths"` CacheExpiration jsonutil.Duration `json:"cache_expiration"yaml:"cache_expiration"` Plugins *pluginConfig `json:"plugins"yaml:"plugins"` ListenAddr string `json:"listen_addr,omitempty"yaml:"listen_addr"` ListenPort int `json:"listen_port,omitempty"yaml:"listen_port"` }
holds the configuration passed in through the SNAP config file
Note: if this struct is modified, then the switch statement in the UnmarshalJSON method in this same file needs to be modified to match the field mapping that is defined here
func (*Config) DeletePluginConfigDataNodeField ¶
func (p *Config) DeletePluginConfigDataNodeField(pluginType core.PluginType, name string, ver int, fields ...string) cdata.ConfigDataNode
func (*Config) DeletePluginConfigDataNodeFieldAll ¶
func (p *Config) DeletePluginConfigDataNodeFieldAll(fields ...string) cdata.ConfigDataNode
func (*Config) GetPluginConfigDataNode ¶
func (p *Config) GetPluginConfigDataNode(pluginType core.PluginType, name string, ver int) cdata.ConfigDataNode
func (*Config) GetPluginConfigDataNodeAll ¶
func (p *Config) GetPluginConfigDataNodeAll() cdata.ConfigDataNode
func (*Config) MergePluginConfigDataNode ¶
func (p *Config) MergePluginConfigDataNode(pluginType core.PluginType, name string, ver int, cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
func (*Config) MergePluginConfigDataNodeAll ¶
func (p *Config) MergePluginConfigDataNodeAll(cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals valid json into a Config. An example Config can be found at github.com/intelsdi-x/snap/blob/master/examples/configs/snap-config-sample.json
type ControlGRPCServer ¶
type ControlGRPCServer struct {
// contains filtered or unexported fields
}
func (*ControlGRPCServer) CollectMetrics ¶
func (pc *ControlGRPCServer) CollectMetrics(ctx context.Context, r *rpc.CollectMetricsRequest) (*rpc.CollectMetricsResponse, error)
func (*ControlGRPCServer) GetAutodiscoverPaths ¶
func (pc *ControlGRPCServer) GetAutodiscoverPaths(ctx context.Context, _ *common.Empty) (*rpc.GetAutodiscoverPathsReply, error)
func (*ControlGRPCServer) ProcessMetrics ¶
func (pc *ControlGRPCServer) ProcessMetrics(ctx context.Context, r *rpc.PubProcMetricsRequest) (*rpc.ProcessMetricsReply, error)
func (*ControlGRPCServer) PublishMetrics ¶
func (pc *ControlGRPCServer) PublishMetrics(ctx context.Context, r *rpc.PubProcMetricsRequest) (*rpc.ErrorReply, error)
--------- Scheduler's managesMetrics implementation ----------
func (*ControlGRPCServer) SubscribeDeps ¶
func (pc *ControlGRPCServer) SubscribeDeps(ctx context.Context, r *rpc.SubscribeDepsRequest) (*rpc.SubscribeDepsReply, error)
func (*ControlGRPCServer) UnsubscribeDeps ¶
func (pc *ControlGRPCServer) UnsubscribeDeps(ctx context.Context, r *rpc.UnsubscribeDepsRequest) (*rpc.UnsubscribeDepsReply, error)
func (*ControlGRPCServer) ValidateDeps ¶
func (pc *ControlGRPCServer) ValidateDeps(ctx context.Context, r *rpc.ValidateDepsRequest) (*rpc.ValidateDepsReply, error)
type MTTrie ¶
type MTTrie struct {
// contains filtered or unexported fields
}
MTTrie struct representing the root in the trie
func (MTTrie) Add ¶
func (mtt MTTrie) Add(mt *metricType)
Add adds a node with the given namespace with the given MetricType
func (*MTTrie) DeleteByPlugin ¶
func (m *MTTrie) DeleteByPlugin(lp *loadedPlugin)
DeleteByPlugin removes all metrics from the catalog if they match a loadedPlugin
func (MTTrie) Fetch ¶
Fetch collects all children below a given namespace and concatenates their metric types into a single slice
func (MTTrie) Get ¶
Get works like fetch, but only returns the MT at the given node and does not gather the node's children.
func (*MTTrie) RemoveMetric ¶
func (m *MTTrie) RemoveMetric(mt metricType)
RemoveMetric removes a specific metric by namespace and version from the tree
type ManagesSubscriptionGroups ¶
type ManagesSubscriptionGroups interface { Process() (errs []serror.SnapError) Add(id string, requested []core.RequestedMetric, configTree *cdata.ConfigDataTree, plugins []core.SubscribedPlugin) []serror.SnapError Get(id string) ([]core.Metric, []serror.SnapError, error) Remove(id string) []serror.SnapError ValidateDeps(requested []core.RequestedMetric, plugins []core.SubscribedPlugin, configTree *cdata.ConfigDataTree) (serrs []serror.SnapError) // contains filtered or unexported methods }
ManagesSubscriptionGroups is the interface implemented by an object that can manage subscription groups.
type PluginControlOpt ¶
type PluginControlOpt func(*pluginControl)
PluginControlOpt is used to set optional parameters on the pluginControl struct
func CacheExpiration ¶
func CacheExpiration(t time.Duration) PluginControlOpt
CacheExpiration is the PluginControlOpt which sets the global metric cache TTL
func MaxRunningPlugins ¶
func MaxRunningPlugins(m int) PluginControlOpt
MaxRunningPlugins sets the maximum number of plugins to run per pool
func OptSetConfig ¶
func OptSetConfig(cfg *Config) PluginControlOpt
OptSetConfig sets the plugin control configuration.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
rpc
Package rpc is a generated protocol buffer package.
|
Package rpc is a generated protocol buffer package. |
Package strategy provides basic interfaces for routing to available plugins and caching metric data.
|
Package strategy provides basic interfaces for routing to available plugins and caching metric data. |