scheduler

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2018 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Nodes

type Nodes struct {
	Online  gzkwrapper.NodesPair
	Offline gzkwrapper.NodesPair
}

Nodes is exported

func NewNodes

func NewNodes() *Nodes

NewNodes is exported

type Scheduler

type Scheduler struct {
	*SchedulerConfigs
	// contains filtered or unexported fields
}

Scheduler is exported

func NewScheduler

func NewScheduler(configs *SchedulerConfigs, cacheRepository *cache.CacheRepository) *Scheduler

NewScheduler is exported

func (*Scheduler) HashAlloc

func (scheduler *Scheduler) HashAlloc(location string, nodes *Nodes)
  HashAlloc
  hash分配原则:
  1、若location下只有worker上线情况(online > 0, offline == 0)
     location中worker环发生了变化, 将环中所有worker的jobs重新分配一次, 状态为STARTED的job排除在外.
     将job的状态设置为REALLOC.

  2、若location下只有worker下线情况(online == 0, offline > 0)
     location中worker环虽然发生了变化,但为了避免location下所有jobs全都调整(抖动过大),因此只处理下线worker的所有jobs.
     将job的状态设置为REALLOC.

  3、若location下既有worker上线,也有worker下线(online > 0, offline > 0)
	 记录下线worker的jobs到临时缓存(tempOffJobs)
	 将location中所有worker的job重新分配一次,但状态为STARTED同时在tempOffJobs中未查询到的job排除在外.
	 在tempOffJobs中的job虽然为启动状态,但有可能worker是异常关闭没有改变job状态,所以必须重新分配.
	 将job的状态设置为REALLOC.

func (*Scheduler) HashSingleJobAlloc

func (scheduler *Scheduler) HashSingleJobAlloc(location string, jobid string)

HashSingleJobAlloc: 调整单一job 条件:当创建或修改job后调用该方法

func (*Scheduler) PrefAlloc

func (s *Scheduler) PrefAlloc(location string, nodes *Nodes)

func (*Scheduler) PrefSingleJobAlloc

func (s *Scheduler) PrefSingleJobAlloc(location string, jobid string)

func (*Scheduler) QuickAlloc

func (scheduler *Scheduler) QuickAlloc(online gzkwrapper.NodesPair, offline gzkwrapper.NodesPair)

QuickAlloc is exported 以节点状态改变为条件进行分配,调度器对上下线节点进行job调整.

func (*Scheduler) RecoveryLocationAlloc

func (scheduler *Scheduler) RecoveryLocationAlloc(location string, jobs []*models.SimpleJob)

RecoveryLocationAlloc is exported 检查location下所有enabled已打开的job 1、若分配表中不存在,则重新分配一次. 2、已存在,则检测分配的节点是否已发生改变,若改变则重新再分配.

func (*Scheduler) SingleJobAlloc

func (scheduler *Scheduler) SingleJobAlloc(location string, jobid string)

SingleJobAlloc is exported 以job为条件进行分配,当创建或删除Job时调度器会立即分配

type SchedulerConfigs

type SchedulerConfigs struct {
	AllocMode     string
	AllocRecovery string
}

SchedulerConfigs is exported

Jump to

Keyboard shortcuts

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