本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.DesiredLRPSchedulingInfo.Validate方法的典型用法代碼示例。如果您正苦於以下問題:Golang DesiredLRPSchedulingInfo.Validate方法的具體用法?Golang DesiredLRPSchedulingInfo.Validate怎麽用?Golang DesiredLRPSchedulingInfo.Validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/bbs/models.DesiredLRPSchedulingInfo
的用法示例。
在下文中一共展示了DesiredLRPSchedulingInfo.Validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GatherAndPruneDesiredLRPs
func (db *ETCDDB) GatherAndPruneDesiredLRPs(logger lager.Logger, guids map[string]struct{}, lmc *LRPMetricCounter) (map[string]*models.DesiredLRP, error) {
desiredLRPsRoot, modelErr := db.fetchRecursiveRaw(logger, DesiredLRPComponentsSchemaRoot)
if modelErr == models.ErrResourceNotFound {
logger.Info("actual-lrp-schema-root-not-found")
return map[string]*models.DesiredLRP{}, nil
}
if modelErr != nil {
return nil, modelErr
}
schedulingInfos := map[string]*models.DesiredLRPSchedulingInfo{}
runInfos := map[string]*models.DesiredLRPRunInfo{}
var malformedSchedulingInfos, malformedRunInfos []string
var guidsLock, schedulingInfosLock, runInfosLock sync.Mutex
works := []func(){}
logger.Debug("walking-desired-lrp-components-tree")
for _, componentRoot := range desiredLRPsRoot.Nodes {
switch componentRoot.Key {
case DesiredLRPSchedulingInfoSchemaRoot:
for _, node := range componentRoot.Nodes {
node := node
works = append(works, func() {
var schedulingInfo models.DesiredLRPSchedulingInfo
err := db.deserializeModel(logger, node, &schedulingInfo)
if err != nil || schedulingInfo.Validate() != nil {
logger.Error("failed-to-deserialize-scheduling-info", err)
schedulingInfosLock.Lock()
malformedSchedulingInfos = append(malformedSchedulingInfos, node.Key)
schedulingInfosLock.Unlock()
} else {
schedulingInfosLock.Lock()
schedulingInfos[schedulingInfo.ProcessGuid] = &schedulingInfo
schedulingInfosLock.Unlock()
atomic.AddInt32(&lmc.desiredLRPs, schedulingInfo.Instances)
guidsLock.Lock()
guids[schedulingInfo.ProcessGuid] = struct{}{}
guidsLock.Unlock()
}
})
}
case DesiredLRPRunInfoSchemaRoot:
for _, node := range componentRoot.Nodes {
node := node
works = append(works, func() {
var runInfo models.DesiredLRPRunInfo
err := db.deserializeModel(logger, node, &runInfo)
if err != nil || runInfo.Validate() != nil {
runInfosLock.Lock()
malformedRunInfos = append(malformedRunInfos, node.Key)
runInfosLock.Unlock()
} else {
runInfosLock.Lock()
runInfos[runInfo.ProcessGuid] = &runInfo
runInfosLock.Unlock()
}
})
}
default:
err := fmt.Errorf("unrecognized node under desired LRPs root node: %s", componentRoot.Key)
logger.Error("unrecognized-node", err)
return nil, err
}
}
throttler, err := workpool.NewThrottler(db.convergenceWorkersSize, works)
if err != nil {
logger.Error("failed-to-create-throttler", err)
}
throttler.Work()
db.batchDeleteNodes(malformedSchedulingInfos, logger)
db.batchDeleteNodes(malformedRunInfos, logger)
malformedSchedulingInfosMetric.Add(uint64(len(malformedSchedulingInfos)))
malformedRunInfosMetric.Add(uint64(len(malformedRunInfos)))
logger.Debug("done-walking-desired-lrp-tree")
desireds := make(map[string]*models.DesiredLRP)
var schedInfosToDelete []string
for guid, schedulingInfo := range schedulingInfos {
runInfo, ok := runInfos[guid]
if !ok {
err := fmt.Errorf("Missing runInfo for GUID %s", guid)
logger.Error("runInfo-not-found-error", err)
schedInfosToDelete = append(schedInfosToDelete, DesiredLRPSchedulingInfoSchemaPath(guid))
} else {
desiredLRP := models.NewDesiredLRP(*schedulingInfo, *runInfo)
desireds[guid] = &desiredLRP
}
}
db.batchDeleteNodes(schedInfosToDelete, logger)
//.........這裏部分代碼省略.........