當前位置: 首頁>>代碼示例>>Golang>>正文


Golang proc.ErrorChanf函數代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/contrib/mesos/pkg/proc.ErrorChanf函數的典型用法代碼示例。如果您正苦於以下問題:Golang ErrorChanf函數的具體用法?Golang ErrorChanf怎麽用?Golang ErrorChanf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ErrorChanf函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: makePodRegistryReconciler

// reconciler action factory, performs explicit task reconciliation for non-terminal
// tasks identified by annotations in the Kubernetes pod registry.
func (k *KubernetesScheduler) makePodRegistryReconciler() ReconcilerAction {
    return ReconcilerAction(func(drv bindings.SchedulerDriver, cancel <-chan struct{}) <-chan error {
        ctx := api.NewDefaultContext()
        podList, err := k.client.Pods(api.NamespaceValue(ctx)).List(labels.Everything(), fields.Everything())
        if err != nil {
            return proc.ErrorChanf("failed to reconcile pod registry: %v", err)
        }
        taskToSlave := make(map[string]string)
        for _, pod := range podList.Items {
            if len(pod.Annotations) == 0 {
                continue
            }
            taskId, found := pod.Annotations[meta.TaskIdKey]
            if !found {
                continue
            }
            slaveId, found := pod.Annotations[meta.SlaveIdKey]
            if !found {
                continue
            }
            taskToSlave[taskId] = slaveId
        }
        return proc.ErrorChan(k.explicitlyReconcileTasks(drv, taskToSlave, cancel))
    })
}
開發者ID:hvescovi,項目名稱:kubernetes,代碼行數:27,代碼來源:scheduler.go

示例2: New

// New creates a new KubernetesScheduler
func New(config Config) *KubernetesScheduler {
    var k *KubernetesScheduler
    k = &KubernetesScheduler{
        schedcfg:          &config.Schedcfg,
        RWMutex:           new(sync.RWMutex),
        executor:          config.Executor,
        executorGroup:     uid.Parse(config.Executor.ExecutorId.GetValue()).Group(),
        PodScheduler:      config.Scheduler,
        client:            config.Client,
        etcdClient:        config.EtcdClient,
        failoverTimeout:   config.FailoverTimeout,
        reconcileInterval: config.ReconcileInterval,
        nodeRegistrator:   node.NewRegistrator(config.Client, config.LookupNode),
        offers: offers.CreateRegistry(offers.RegistryConfig{
            Compat: func(o *mesos.Offer) bool {
                // the node must be registered and have up-to-date labels
                n := config.LookupNode(o.GetHostname())
                if n == nil || !node.IsUpToDate(n, node.SlaveAttributesToLabels(o.GetAttributes())) {
                    return false
                }

                // the executor IDs must not identify a kubelet-executor with a group that doesn't match ours
                for _, eid := range o.GetExecutorIds() {
                    execuid := uid.Parse(eid.GetValue())
                    if execuid.Name() == execcfg.DefaultInfoID && execuid.Group() != k.executorGroup {
                        return false
                    }
                }

                return true
            },
            DeclineOffer: func(id string) <-chan error {
                errOnce := proc.NewErrorOnce(k.terminate)
                errOuter := k.asRegisteredMaster.Do(func() {
                    var err error
                    defer errOnce.Report(err)
                    offerId := mutil.NewOfferID(id)
                    filters := &mesos.Filters{}
                    _, err = k.driver.DeclineOffer(offerId, filters)
                })
                return errOnce.Send(errOuter).Err()
            },
            // remember expired offers so that we can tell if a previously scheduler offer relies on one
            LingerTTL:     config.Schedcfg.OfferLingerTTL.Duration,
            TTL:           config.Schedcfg.OfferTTL.Duration,
            ListenerDelay: config.Schedcfg.ListenerDelay.Duration,
        }),
        slaveHostNames:    slave.NewRegistry(),
        taskRegistry:      podtask.NewInMemoryRegistry(),
        reconcileCooldown: config.ReconcileCooldown,
        registration:      make(chan struct{}),
        asRegisteredMaster: proc.DoerFunc(func(proc.Action) <-chan error {
            return proc.ErrorChanf("cannot execute action with unregistered scheduler")
        }),
    }
    return k
}
開發者ID:rettori,項目名稱:kubernetes,代碼行數:58,代碼來源:scheduler.go

示例3: Init

func (k *KubernetesScheduler) Init(electedMaster proc.Process, pl PluginInterface, mux *http.ServeMux) error {
    log.V(1).Infoln("initializing kubernetes mesos scheduler")

    k.asRegisteredMaster = proc.DoerFunc(func(a proc.Action) <-chan error {
        if !k.registered {
            return proc.ErrorChanf("failed to execute action, scheduler is disconnected")
        }
        return electedMaster.Do(a)
    })
    k.terminate = electedMaster.Done()
    k.plugin = pl
    k.offers.Init(k.terminate)
    k.InstallDebugHandlers(mux)
    return k.recoverTasks()
}
開發者ID:niu-team,項目名稱:kubernetes,代碼行數:15,代碼來源:scheduler.go

示例4: Init

func (k *framework) Init(sched scheduler.Scheduler, electedMaster proc.Process, mux *http.ServeMux) error {
    log.V(1).Infoln("initializing kubernetes mesos scheduler")

    k.sched = sched
    k.mux = mux
    k.asRegisteredMaster = proc.DoerFunc(func(a proc.Action) <-chan error {
        if !k.registered {
            return proc.ErrorChanf("failed to execute action, scheduler is disconnected")
        }
        return electedMaster.Do(a)
    })
    k.terminate = electedMaster.Done()
    k.offers.Init(k.terminate)
    k.nodeRegistrator.Run(k.terminate)
    return k.recoverTasks()
}
開發者ID:robertabbott,項目名稱:kubernetes,代碼行數:16,代碼來源:framework.go

示例5: makePodRegistryReconciler

// reconciler action factory, performs explicit task reconciliation for non-terminal
// tasks identified by annotations in the Kubernetes pod registry.
func (k *framework) makePodRegistryReconciler() taskreconciler.Action {
    return taskreconciler.Action(func(drv bindings.SchedulerDriver, cancel <-chan struct{}) <-chan error {
        podList, err := k.client.Core().Pods(api.NamespaceAll).List(api.ListOptions{})
        if err != nil {
            return proc.ErrorChanf("failed to reconcile pod registry: %v", err)
        }
        taskToSlave := make(map[string]string)
        for _, pod := range podList.Items {
            if len(pod.Annotations) == 0 {
                continue
            }
            taskId, found := pod.Annotations[meta.TaskIdKey]
            if !found {
                continue
            }
            slaveId, found := pod.Annotations[meta.SlaveIdKey]
            if !found {
                continue
            }
            taskToSlave[taskId] = slaveId
        }
        return proc.ErrorChan(k.explicitlyReconcileTasks(drv, taskToSlave, cancel))
    })
}
開發者ID:40a,項目名稱:bootkube,代碼行數:26,代碼來源:framework.go

示例6: New

// New creates a new Framework
func New(config Config) Framework {
    var k *framework
    k = &framework{
        schedulerConfig:   &config.SchedulerConfig,
        RWMutex:           new(sync.RWMutex),
        client:            config.Client,
        failoverTimeout:   config.FailoverTimeout,
        reconcileInterval: config.ReconcileInterval,
        nodeRegistrator:   node.NewRegistrator(config.Client, config.LookupNode),
        executorId:        config.ExecutorId,
        offers: offers.CreateRegistry(offers.RegistryConfig{
            Compat: func(o *mesos.Offer) bool {
                // the node must be registered and have up-to-date labels
                n := config.LookupNode(o.GetHostname())
                if n == nil || !node.IsUpToDate(n, node.SlaveAttributesToLabels(o.GetAttributes())) {
                    return false
                }

                eids := len(o.GetExecutorIds())
                switch {
                case eids > 1:
                    // at most one executor id expected. More than one means that
                    // the given node is seriously in trouble.
                    return false

                case eids == 1:
                    // the executor id must match, otherwise the running executor
                    // is incompatible with the current scheduler configuration.
                    if eid := o.GetExecutorIds()[0]; eid.GetValue() != config.ExecutorId.GetValue() {
                        return false
                    }
                }

                return true
            },
            DeclineOffer: func(id string) <-chan error {
                errOnce := proc.NewErrorOnce(k.terminate)
                errOuter := k.asRegisteredMaster.Do(func() {
                    var err error
                    defer errOnce.Report(err)
                    offerId := mutil.NewOfferID(id)
                    filters := &mesos.Filters{}
                    _, err = k.driver.DeclineOffer(offerId, filters)
                })
                return errOnce.Send(errOuter).Err()
            },
            // remember expired offers so that we can tell if a previously scheduler offer relies on one
            LingerTTL:     config.SchedulerConfig.OfferLingerTTL.Duration,
            TTL:           config.SchedulerConfig.OfferTTL.Duration,
            ListenerDelay: config.SchedulerConfig.ListenerDelay.Duration,
        }),
        slaveHostNames:    newSlaveRegistry(),
        reconcileCooldown: config.ReconcileCooldown,
        registration:      make(chan struct{}),
        asRegisteredMaster: proc.DoerFunc(func(proc.Action) <-chan error {
            return proc.ErrorChanf("cannot execute action with unregistered scheduler")
        }),
        storeFrameworkId: config.StoreFrameworkId,
        lookupNode:       config.LookupNode,
    }
    return k
}
開發者ID:robertabbott,項目名稱:kubernetes,代碼行數:63,代碼來源:framework.go


注:本文中的k8s/io/kubernetes/contrib/mesos/pkg/proc.ErrorChanf函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。