本文整理汇总了Golang中github.com/intelsdi-x/snap/control/strategy.Pool.RUnlock方法的典型用法代码示例。如果您正苦于以下问题:Golang Pool.RUnlock方法的具体用法?Golang Pool.RUnlock怎么用?Golang Pool.RUnlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/intelsdi-x/snap/control/strategy.Pool
的用法示例。
在下文中一共展示了Pool.RUnlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HandleGomitEvent
// Empty handler acting as placeholder until implementation. This helps tests
// pass to ensure registration works.
func (r *runner) HandleGomitEvent(e gomit.Event) {
switch v := e.Body.(type) {
case *control_event.DeadAvailablePluginEvent:
runnerLog.WithFields(log.Fields{
"_block": "handle-events",
"event": v.Namespace(),
"aplugin": v.String,
}).Warning("handling dead available plugin event")
pool, err := r.availablePlugins.getPool(v.Key)
if err != nil {
runnerLog.WithFields(log.Fields{
"_block": "handle-events",
"aplugin": v.String,
}).Error(err.Error())
return
}
if pool != nil {
pool.Kill(v.Id, "plugin dead")
}
if pool.Eligible() {
if pool.RestartCount() < MaxPluginRestartCount {
e := r.restartPlugin(v.Key)
if e != nil {
runnerLog.WithFields(log.Fields{
"_block": "handle-events",
"aplugin": v.String,
}).Error(e.Error())
return
}
pool.IncRestartCount()
runnerLog.WithFields(log.Fields{
"_block": "handle-events",
"event": v.Name,
"aplugin": v.Version,
"restart_count": pool.RestartCount(),
}).Warning("plugin restarted")
r.emitter.Emit(&control_event.RestartedAvailablePluginEvent{
Id: v.Id,
Name: v.Name,
Version: v.Version,
Key: v.Key,
Type: v.Type,
})
} else {
r.emitter.Emit(&control_event.MaxPluginRestartsExceededEvent{
Id: v.Id,
Name: v.Name,
Version: v.Version,
Key: v.Key,
Type: v.Type,
})
}
}
case *control_event.PluginUnsubscriptionEvent:
runnerLog.WithFields(log.Fields{
"_block": "subscribe-pool",
"event": v.Namespace(),
"plugin-name": v.PluginName,
"plugin-version": v.PluginVersion,
"plugin-type": core.PluginType(v.PluginType).String(),
}).Debug("handling plugin unsubscription event")
err := r.handleUnsubscription(core.PluginType(v.PluginType).String(), v.PluginName, v.PluginVersion, v.TaskId)
if err != nil {
return
}
case *control_event.UnloadPluginEvent:
// On plugin unload, find the key and pool info for the plugin being unloaded.
r.availablePlugins.RLock()
var pool strategy.Pool
var k string
for key, p := range r.availablePlugins.table {
tnv := strings.Split(key, ":")
if core.PluginType(v.Type).String() == tnv[0] && v.Name == tnv[1] && v.Version == p.Version() {
pool = p
k = key
break
}
}
r.availablePlugins.RUnlock()
if pool == nil {
return
}
// Check for the highest lower version plugin and move subscriptions that
// are not bound to a plugin version to this pool.
plugin, err := r.pluginManager.get(fmt.Sprintf("%s:%s:%d", core.PluginType(v.Type).String(), v.Name, -1))
if err != nil {
return
}
newPool, err := r.availablePlugins.getOrCreatePool(plugin.Key())
if err != nil {
return
//.........这里部分代码省略.........