models

package
v0.0.0-...-db7089b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CreateJobEvent      = "create_job"      //创建任务事件
	ChangeJobEvent      = "change_job"      //修改任务事件
	RemoveJobEvent      = "remove_job"      //删除任务事件
	ChangeJobsFileEvent = "change_jobsfile" //任务文件批量修改事件
	CreateGroupEvent    = "create_group"    //创建分组事件
	ChangeGroupEvent    = "change_group"    //改变分组事件
	RemoveGroupEvent    = "remove_group"    //删除分组事件
	CreateRuntimeEvent  = "create_runtime"  //创建Runtime事件
	ChangeRuntimeEvent  = "change_runtime"  //改变Runtime事件
	RemoveRuntimeEvent  = "remove_runtime"  //删除Runtime事件
)

事件类型定义

View Source
const (
	MsgJobExecute = "JobExecute" //任务执行状态结果消息
	MsgJobSelect  = "JobSelect"  //任务选择下次执行消息

)

消息头类型定义

View Source
const (
	TURNMODE_SECONDS = 1 //秒轮询
	TURNMODE_MINUTES = 2 //分钟轮询
	TURNMODE_HOURLY  = 3 //小时轮询
	TURNMODE_DAILY   = 4 //天轮询
	TURNMODE_WEEKLY  = 5 //周轮询
	TURNMODE_MONTHLY = 6 //月轮询
)

任务轮询模式信息

View Source
const (
	STATE_REALLOC int = 202 //重新分配
	STATE_CREATED int = 201 //初始创建
	STATE_STARTED int = 200 //成功状态
	STATE_STOPED  int = 0   //停止状态
	STATE_FAILED  int = -1  //失败状态
)
View Source
const (
	MsgSystemEvent = "SystemEvent" //系统事件消息
)

消息头类型定义

Variables

This section is empty.

Functions

func AttachEncode

func AttachEncode(attach *AttachData) []byte

func GetStateString

func GetStateString(state int) string

GetStateString is exported return state string.

func JobBaseEnCode

func JobBaseEnCode(jobbase *JobBase) ([]byte, error)

func JobsAllocDeCode

func JobsAllocDeCode(b []byte, alloc *JobsAlloc) error

解码分配表

func JobsAllocEnCode

func JobsAllocEnCode(pool *sync.Pool, alloc *JobsAlloc) ([]byte, error)

编码分配表

Types

type AllocMapper

type AllocMapper map[string]*JobsAlloc

任务分配表信息定义

type AttachData

type AttachData struct {
	JobMaxCount int `json:"jobmaxcount"` //每个节点的最大任务数配置
}

节点附加数据定义

func AttachDecode

func AttachDecode(data []byte) *AttachData

type Group

type Group struct {
	Id     string   `json:"id" bson:"id"`         //组编号
	Name   string   `json:"name" bson:"name"`     //组名称
	Owners []string `json:"owners" bson:"owners"` //组管理员
}

分组信息

type Job

type Job struct {
	JobId         string         `json:"jobid"`         //任务编号
	Name          string         `json:"name"`          //任务名称
	Location      string         `json:"location"`      //隶属位置
	Servers       []string       `json:"servers"`       //分配服务器信息,若为空则由调度器以hash分配,一但设置了Servers,Job仅限于Servers范围进行分配.
	GroupId       string         `json:"groupid"`       //隶属分组
	FileName      string         `json:"filename"`      //文件名称
	Cmd           string         `json:"cmd"`           //执行命令
	Env           []string       `json:"env"`           //环境变量
	Timeout       int            `json:"timeout"`       //执行超时(0:永远等待)
	Enabled       int            `json:"enabled"`       //任务开关(0:关 1:开)
	Schedule      []*Schedule    `json:"schedule"`      //任务计划
	NotifySetting *NotifySetting `json:"notifysetting"` //任务通知配置
	Stat          int            `json:"stat"`          //执行编码
	ExecErr       string         `json:"execerr"`       //执行错误信息
	ExecAt        time.Time      `json:"execat"`        //本次执行时间
	NextAt        time.Time      `json:"nextat"`        //下次执行时间
}

任务信息

type JobBase

type JobBase struct {
	JobId    string      `json:"jobid"`
	JobName  string      `json:"jobname"`
	FileName string      `json:"filename"`
	FileCode string      `json:"filecode"`
	Cmd      string      `json:"cmd"`
	Env      []string    `json:"env"`
	Timeout  int         `json:"timeout"`
	Version  int         `json:"version"`
	Schedule []*Schedule `json:"schedule"`
}

func JobBaseDeCode

func JobBaseDeCode(buf []byte) (*JobBase, error)

type JobData

type JobData struct {
	JobId   string `json:"jobid"`   //任务编号
	Key     string `json:"key"`     //任务名称
	Version int    `json:"version"` //任务版本
}

分配表单条Job信息

type JobDataInfo

type JobDataInfo struct {
	JobData
	JobName  string `json:"jobname"`
	IpAddr   string `json:"ipaddr"`
	HostName string `json:"hostname"`
}

Job分配信息

type JobExecute

type JobExecute struct {
	MsgHeader           //消息头
	JobId     string    `json:"jobid"`     //任务编号
	Location  string    `json:"location"`  //所在位置
	Key       string    `json:"key"`       //执行服务器
	IPAddr    string    `json:"ipaddr"`    //服务器地址
	State     int       `json:"state"`     //执行编码
	ExecErr   string    `json:"execerr"`   //执行错误信息
	ExecAt    time.Time `json:"execat"`    //本次执行时间
	NextAt    time.Time `json:"nextat"`    //下次执行时间
	Timestamp int64     `json:"timestamp"` //消息时间戳
}

任务执行状态结果消息体定义 Header.MsgName = MsgJobExecute

type JobLog

type JobLog struct {
	JobId     string    `json:"jobid"`     //任务编号
	MsgId     string    `json:"msgid"`     //消息编号
	Event     string    `json:"event"`     //事件描述
	Group     string    `json:"group"`     //隶属分组
	Stat      int       `json:"stat"`      //状态编码
	Location  string    `json:"location"`  //所在位置
	Command   string    `json:"command"`   //执行命令
	WorkDir   string    `json:"workdir"`   //执行工作目录
	IpAddr    string    `json:"ipaddr"`    //服务器地址
	StdOut    string    `json:"stdout"`    //标准输出
	ErrOut    string    `json:"errout"`    //错误输出
	ExecErr   string    `json:"execerr"`   //执行错误信息
	ExecAt    time.Time `json:"execat"`    //本次执行时间
	ExecTimes float64   `json:"exectimes"` //执行耗时(毫秒)
	CreateAt  int64     `json:"createat"`  //日志时间
}

任务日志信息定义

type JobSelect

type JobSelect struct {
	MsgHeader           //消息头
	JobId     string    `json:"jobid"`     //任务编号
	Location  string    `json:"location"`  //所在位置
	NextAt    time.Time `json:"nextat"`    //下次执行时间
	Timestamp int64     `json:"timestamp"` //消息时间戳
}

type JobsAlloc

type JobsAlloc struct {
	Version int        `json:"version"` //分配表版本
	Jobs    []*JobData `json:"jobs"`    //任务列表
}

type JobsAllocData

type JobsAllocData struct {
	Location string         `json:"location"`
	Version  int            `json:"version"`
	Data     []*JobDataInfo `json:"data"`
}

Job分配表详细数据

type MessageCache

type MessageCache struct {
	sync.Mutex
	Data map[string]int64
}

func NewMessageCache

func NewMessageCache() *MessageCache

func (*MessageCache) ValidateMessage

func (mc *MessageCache) ValidateMessage(message interface{}) bool

type MonthlyOf

type MonthlyOf struct {
	/* Day 选定月份第n天
	   > 0 表示每月第n天
	   < 0 表示每月倒数第n天
	   == 0 表示按Week方式处理
	*/
	Day int `json:"day"`
	/*
	   Week 选定月份第n个星期, 星期由0~6编码表示
	   "0:1" 表示最后一个星期一
	   "1:2" 表示第一个星期二
	   "2:4" 表示第二个星期四
	*/
	Week string `json:"week"`
}

月轮询选项

type MsgHeader

type MsgHeader struct {
	MsgName string `json:"msgname"` //消息名称
	MsgId   string `json:"msgid"`   //消息编号
}

消息头定义

type Notify

type Notify struct {
	Enabled bool   `json:"enabled"` //通知开关
	Subject string `json:"subject"` //通知标题
	To      string `json:"to"`      //接收者
	Content string `json:"content"` //通知内容
}

通知定义

type NotifySetting

type NotifySetting struct {
	Succeed Notify `json:"succeed"` //成功通知
	Failed  Notify `json:"failed"`  //失败通知
}

通知设置定义

type Schedule

type Schedule struct {
	Id        string    `json:"id"`        //计划编号
	Enabled   int       `json:"enabled"`   //计划开关(0:关 1:开)
	TurnMode  int       `json:"turnmode"`  //轮询模式
	Interval  int       `json:"interval"`  //轮询间隔
	StartDate string    `json:"startdate"` //开始日期
	EndDate   string    `json:"enddate"`   //结束日期
	StartTime string    `json:"starttime"` //开始时间
	EndTime   string    `json:"endtime"`   //结束时间
	SelectAt  string    `json:"selectat"`  //选择条件(条件已","符号分隔)
	MonthlyOf MonthlyOf `json:"monthlyof"` //月轮询选项
}

计划信息

type Server

type Server struct {
	Key        string `json:"key" bson:"key"`               //主机Key
	Name       string `json:"name" bson:"name"`             //主机名称
	IPAddr     string `json:"ipaddr" bson:"ipaddr"`         //Ip地址
	APIAddr    string `json:"apiaddr" bson:"apiaddr"`       //API地址
	OS         string `json:"os"  bson:"os"`                //系统环境
	Platform   string `json:"platform"  bson:"platform"`    //运行平台
	Status     int    `json:"status" bson:"status"`         //状态(0:离线 1:在线)
	Alivestamp int64  `json:"alivestamp" bson:"alivestamp"` //存活时间戳
}

服务器信息

func CreateServer

func CreateServer(key string, node *gzkwrapper.NodeData, status int) *Server

type ServerConfig

type ServerConfig struct {
	WebSiteHost   string      `json:"websitehost"`
	CenterHost    string      `json:"centerhost"`
	StorageDriver interface{} `json:"storagedriver"`
}

ServerConfig is exported

func ParseServerConfigs

func ParseServerConfigs(b []byte) (*ServerConfig, error)

ParseServerConfigs is exported parse bytes to ServerConfig object.

type SimpleJob

type SimpleJob struct {
	JobId    string   `json:"jobid"`    //任务编号
	Name     string   `json:"name"`     //任务名称
	Location string   `json:"location"` //隶属位置
	GroupId  string   `json:"groupid"`  //隶属分组
	Servers  []string `json:"servers"`  //分配服务器信息
	Enabled  int      `json:"enabled"`  //任务开关(0:关 1:开)
	Stat     int      `json:"stat"`     //执行编码
}

任务基础简要信息 用于任务调度等信息交换

type SystemEvent

type SystemEvent struct {
	MsgHeader          //消息头
	Event     string   `json:"event"`     //事件名称
	Runtime   string   `json:"runtime"`   //runtime名称
	JobIds    []string `json:"jobids"`    //事件相关所有jobs
	GroupIds  []string `json:"groupids"`  //事件相关所有groups
	Timestamp int64    `json:"timestamp"` //消息时间戳
}

系统事件定义

type WorkLocation

type WorkLocation struct {
	Location string    `json:"location" bson:"location"` //位置名称
	Owners   []string  `json:"owners" bson:"owners"`     //管理员
	Group    []*Group  `json:"group" bson:"group"`       //分组信息
	Server   []*Server `json:"server" bson:"server"`     //主机信息
}

位置信息

Jump to

Keyboard shortcuts

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