cache

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: Apache-2.0 Imports: 19 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ERROR_GETJOBBASE  = -1000 //获取任务信息失败
	ERROR_READJOBBASE = -1001 //读取任务信息失败
	ERROR_PULLJOBFILE = -1002 //拉取任务文件失败
	ERROR_DECOMPRESS  = -1003 //解压任务文件失败
	ERROR_MAKECMDFILE = -1004 //上传任务文件为空,根据Cmd创建脚本文件失败
)

错误值枚举定义

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is exported

func NewCache

func NewCache(configs *CacheConfigs, handler ICacheHandler) *Cache

NewCache is exported

func (*Cache) Clear

func (cache *Cache) Clear()

Clear is exported clear local all jobs & alloc

func (*Cache) GetAllocVersion

func (cache *Cache) GetAllocVersion() int

GetAllocVersion is exported return jobsalloc version

func (*Cache) GetJob

func (cache *Cache) GetJob(jobid string) *models.JobBase

GetJob is exported return a cache job

func (*Cache) GetJobs

func (cache *Cache) GetJobs() []*models.JobBase

GetJobs is exported return cache jobs

func (*Cache) GetJobsCount

func (cache *Cache) GetJobsCount() int

GetJobsCount is exported return jobsalloc job count

func (*Cache) LoadJobs

func (cache *Cache) LoadJobs()

LoadJobs is exported load local jobs

func (*Cache) MakeAllocBuffer

func (cache *Cache) MakeAllocBuffer() ([]byte, error)

MakeAllocBuffer is exported

func (*Cache) SetAllocBuffer

func (cache *Cache) SetAllocBuffer(key string, data []byte) (int, error)

SetAllocBuffer is exported set jobs alloc

func (*Cache) SetServerConfigsParameter

func (cache *Cache) SetServerConfigsParameter(centerHost string, websiteHost string)

SetServerConfigsParameter is exported

func (*Cache) StartDumpCleaner

func (cache *Cache) StartDumpCleaner()

StartDumpCleaner is exported

func (*Cache) StopDumpCleaner

func (cache *Cache) StopDumpCleaner()

StopDumpCleaner is exported

type CacheConfigs

type CacheConfigs struct {
	CenterHost    string
	WebsiteHost   string
	MaxJobs       int
	SaveDirectory string
	AutoClean     bool
	CleanInterval string
	PullRecovery  string
}

CacheConfigs is exported

type CacheEvent

type CacheEvent string
const (
	CACHE_EVENT_JOBERROR  CacheEvent = "CACHE_EVENT_JOBERROR"
	CACHE_EVENT_JOBSET    CacheEvent = "CACHE_EVENT_JOBSET"
	CACHE_EVENT_JOBREMOVE CacheEvent = "CACHE_EVENT_JOBREMOVE"
)

type DumpCleaner

type DumpCleaner struct {
	Root     string
	Enabled  bool
	Duration time.Duration
	// contains filtered or unexported fields
}

DumpCleaner is exported

func NewDumpCleaner

func NewDumpCleaner(configs *CacheConfigs) *DumpCleaner

NewDumpCleaner is exported

func (*DumpCleaner) Start

func (dumpCleaner *DumpCleaner) Start()

Start is exported dumpCleaner GC start

func (*DumpCleaner) Stop

func (dumpCleaner *DumpCleaner) Stop()

Stop is exported dumpCleaner GC stop

type ErrorCode

type ErrorCode int

ErrorCode is exported 错误值类型定义

type GetState

type GetState int

GetState is exported 拉取Job文件包状态类型定义

const (
	GET_WAITING GetState = iota + 1 //等待下载
	GET_DOING                       //正在下载
)

状态枚举定义

func (GetState) String

func (state GetState) String() string

获取状态类型名称

type ICacheHandler

type ICacheHandler interface {
	OnJobCacheChangedHandlerFunc(event CacheEvent, jobbase *models.JobBase)
	OnJobCacheExceptionHandlerFunc(event CacheEvent, workdir string, jobget *JobGet, jobgeterror *JobGetError)
}

ICacheHandler is exported

type IJobGetterHandler

type IJobGetterHandler interface {
	OnJobGetterExceptionHandlerFunc(workdir string, jobget *JobGet, jobgeterror *JobGetError)
	OnJobGetterHandlerFunc(workdir string, jobbase *models.JobBase)
}

IJobGetterHandler is exported

type JobCacheChangedHandlerFunc

type JobCacheChangedHandlerFunc func(event CacheEvent, jobbase *models.JobBase)

func (JobCacheChangedHandlerFunc) OnJobCacheChangedHandlerFunc

func (fn JobCacheChangedHandlerFunc) OnJobCacheChangedHandlerFunc(event CacheEvent, jobbase *models.JobBase)

type JobCacheExceptionHandlerFunc

type JobCacheExceptionHandlerFunc func(event CacheEvent, workdir string, jobget *JobGet, jobgeterror *JobGetError)

func (JobCacheExceptionHandlerFunc) OnJobCacheExceptionHandlerFunc

func (fn JobCacheExceptionHandlerFunc) OnJobCacheExceptionHandlerFunc(event CacheEvent, workdir string, jobget *JobGet, jobgeterror *JobGetError)

type JobGet

type JobGet struct {
	JobId   string          //任务编号
	JobData *models.JobData //任务分配数据
	JobBase *models.JobBase //任务基础信息
	State   GetState        //获取状态
}

JobGet is exported 待获取的Job状态信息

type JobGetError

type JobGetError struct {
	Code  ErrorCode //错误编码
	Error error     //错误描述
}

JobGetError is exported 错误类型定义

func (*JobGetError) String

func (jobGetError *JobGetError) String() string

type JobGetter

type JobGetter struct {
	sync.RWMutex               //互斥锁对象
	Root         string        //缓存根目录
	Recovery     time.Duration //恢复拉取间隔
	CenterHost   string        //中心服务器API地址
	WebsiteHost  string        //站点文件服务器API地址
	// contains filtered or unexported fields
}

JobGetter is exported Job信息获取器 1、主要负责Job基础信息获取和Job文件包下载 2、定时恢复失败Job信息或文件的拉取 3、下载Job文件包成功负责解压生成目录结构,写入job.json信息文件

func NewJobGetter

func NewJobGetter(configs *CacheConfigs, handler IJobGetterHandler) *JobGetter

NewJobGetter is exported

func (*JobGetter) Check

func (getter *JobGetter) Check(jobbase *models.JobBase) bool

func (*JobGetter) Get

func (getter *JobGetter) Get(jobdata *models.JobData)

Get is exported get a jobbase and jobfile

func (*JobGetter) Load

func (getter *JobGetter) Load() []*models.JobBase

func (*JobGetter) Quit

func (getter *JobGetter) Quit()

func (*JobGetter) Remove

func (getter *JobGetter) Remove(jobid string)

type JobGetterExceptionHandlerFunc

type JobGetterExceptionHandlerFunc func(workdir string, jobget *JobGet, jobgeterror *JobGetError)

func (JobGetterExceptionHandlerFunc) OnJobGetterExceptionHandlerFunc

func (fn JobGetterExceptionHandlerFunc) OnJobGetterExceptionHandlerFunc(workdir string, jobget *JobGet, jobgeterror *JobGetError)

type JobGetterHandlerFunc

type JobGetterHandlerFunc func(workdir string, jobbase *models.JobBase)

func (JobGetterHandlerFunc) OnJobGetterHandlerFunc

func (fn JobGetterHandlerFunc) OnJobGetterHandlerFunc(workdir string, jobbase *models.JobBase)

type JobStore

type JobStore struct {
	sync.RWMutex      //互斥锁对象
	IJobGetterHandler //getter回调句柄
	// contains filtered or unexported fields
}

JobStore is exported

func NewJobStore

func NewJobStore(configs *CacheConfigs,
	changedCallback JobCacheChangedHandlerFunc,
	exceptionCallback JobCacheExceptionHandlerFunc) *JobStore

NewJobStore is exported jobs & alloc cache

func (*JobStore) ClearJobs

func (store *JobStore) ClearJobs()

ClearJobs is exported clear all cache jobs and alloc.

func (*JobStore) GetAllocVersion

func (store *JobStore) GetAllocVersion() int

GetAllocVersion is exported return jobs alloc version.

func (*JobStore) GetJob

func (store *JobStore) GetJob(jobid string) *models.JobBase

GetJob is exported return a job from cache alloc.

func (*JobStore) GetJobs

func (store *JobStore) GetJobs() []*models.JobBase

GetJobs is exported return jobs from cache alloc.

func (*JobStore) GetJobsCount

func (store *JobStore) GetJobsCount() int

GetJobsCount is exported return jobs count from cache alloc.

func (*JobStore) LoadJobs

func (store *JobStore) LoadJobs()

LoadJobs is exported load cache root jobs directory data.

func (*JobStore) MakeAllocBuffer

func (store *JobStore) MakeAllocBuffer() ([]byte, error)

MakeAllocBuffer is exported

func (*JobStore) OnJobGetterExceptionHandlerFunc

func (store *JobStore) OnJobGetterExceptionHandlerFunc(workdir string, jobget *JobGet, jobgeterror *JobGetError)

OnJobGetterExceptionHandlerFunc is exported

func (*JobStore) OnJobGetterHandlerFunc

func (store *JobStore) OnJobGetterHandlerFunc(workdir string, jobbase *models.JobBase)

OnJobGetterHandlerFunc is exported

func (*JobStore) SetAllocBuffer

func (store *JobStore) SetAllocBuffer(key string, data []byte) error

SetAllocBuffer is exported alloc changed, set alloc data.

func (*JobStore) SetServerConfigsParameter

func (store *JobStore) SetServerConfigsParameter(centerHost string, websiteHost string)

SetServerConfigsParameter is exported

Jump to

Keyboard shortcuts

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