types

package
v0.0.0-...-57f92f0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScheduleActionCreateController = "create-controller"
	ScheduleActionCreateReplica    = "create-replica"
	ScheduleActionDeleteInstance   = "delete"
	ScheduleActionStartInstance    = "start"
	ScheduleActionStopInstance     = "stop"
)
View Source
const (
	VolumeStateNone     = VolumeState("")
	VolumeStateCreated  = VolumeState("created")
	VolumeStateDetached = VolumeState("detached")
	VolumeStateFaulted  = VolumeState("faulted")
	VolumeStateHealthy  = VolumeState("healthy")
	VolumeStateDegraded = VolumeState("degraded")
)
View Source
const (
	ReplicaModeRW  = ReplicaMode("RW")
	ReplicaModeWO  = ReplicaMode("WO")
	ReplicaModeERR = ReplicaMode("ERR")
)
View Source
const (
	InstanceTypeNone       = InstanceType("")
	InstanceTypeController = InstanceType("controller")
	InstanceTypeReplica    = InstanceType("replica")
)
View Source
const (
	SnapshotTaskName = "snapshot"
	BackupTaskName   = "backup"
)
View Source
const (
	SchedulePolicyBindingSoftAntiAffinity = "soft.anti-affinity"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupBgTask

type BackupBgTask struct {
	Snapshot     string `json:"snapshot"`
	BackupTarget string `json:"backupTarget"`

	CleanupHook func() error `json:"-"`
}

type BackupInfo

type BackupInfo struct {
	Name            string `json:"name,omitempty"`
	URL             string `json:"url,omitempty"`
	SnapshotName    string `json:"snapshotName,omitempty"`
	SnapshotCreated string `json:"snapshotCreated,omitempty"`
	Created         string `json:"created,omitempty"`
	Size            string `json:"size,omitempty"`
	VolumeName      string `json:"volumeName,omitempty"`
	VolumeSize      string `json:"volumeSize,omitempty"`
	VolumeCreated   string `json:"volumeCreated,omitempty"`
}

type BackupVolumeInfo

type BackupVolumeInfo struct {
	Name    string `json:"name"`
	Size    string `json:"size"`
	Created string `json:"created"`
}

type BeginMonitoring

type BeginMonitoring func(volume *VolumeInfo, man VolumeManager) Monitor

type BgTask

type BgTask struct {
	Num       int64       `json:"num"`
	Err       error       `json:"err"`
	Finished  string      `json:"finished"`
	Started   string      `json:"started"`
	Submitted string      `json:"submitted"`
	Task      interface{} `json:"task"`
}

type Controller

type Controller interface {
	Name() string
	Endpoint() string
	GetReplicaStates() ([]*ReplicaInfo, error)
	AddReplica(replica *ReplicaInfo) error
	RemoveReplica(replica *ReplicaInfo) error

	BgTaskQueue() TaskQueue
	LatestBgTasks() []*BgTask

	SnapshotOps() SnapshotOps
	BackupOps() VolumeBackupOps
}

type ControllerInfo

type ControllerInfo struct {
	InstanceInfo
}

type Event

type Event interface{}

type GetController

type GetController func(volume *VolumeInfo) Controller

type GetManagerBackupOps

type GetManagerBackupOps func(backupTarget string) ManagerBackupOps

type HostInfo

type HostInfo struct {
	UUID    string `json:"uuid"`
	Name    string `json:"name"`
	Address string `json:"address"`
}

type InstanceInfo

type InstanceInfo struct {
	ID         string
	Type       InstanceType
	Name       string
	HostID     string
	Address    string
	Running    bool
	VolumeName string
}

type InstanceType

type InstanceType string

type ManagerBackupOps

type ManagerBackupOps interface {
	List(volumeName string) ([]*BackupInfo, error)
	Get(url string) (*BackupInfo, error)
	Delete(url string) error

	ListVolumes() ([]*BackupVolumeInfo, error)
	GetVolume(volumeName string) (*BackupVolumeInfo, error)
}

type Monitor

type Monitor interface {
	io.Closer
	CronCh() chan<- Event
}

type Orchestrator

type Orchestrator interface {
	CreateVolume(volume *VolumeInfo) (*VolumeInfo, error) // creates volume metadata and prepare for volume
	DeleteVolume(volumeName string) error                 // removes volume metadata
	GetVolume(volumeName string) (*VolumeInfo, error)     // For non-existing volume, return (nil, nil)
	ListVolumes() ([]*VolumeInfo, error)
	MarkBadReplica(volumeName string, replica *ReplicaInfo) error // find replica by Address
	UpdateVolume(volume *VolumeInfo) error

	CreateController(volumeName, controllerName string, replicas map[string]*ReplicaInfo) (*ControllerInfo, error)
	CreateReplica(volumeName, replicaName string) (*ReplicaInfo, error)

	StartInstance(instance *InstanceInfo) (*InstanceInfo, error)
	StopInstance(instance *InstanceInfo) (*InstanceInfo, error)
	RemoveInstance(instance *InstanceInfo) (*InstanceInfo, error)

	ListHosts() (map[string]*HostInfo, error)
	GetHost(id string) (*HostInfo, error)

	Scheduler() Scheduler // return nil if not supported

	ServiceLocator
	Settings
}

type RecurringJob

type RecurringJob struct {
	Name   string `json:"name,omitempty"`
	Cron   string `json:"cron,omitempty"`
	Task   string `json:"task,omitempty"`
	Retain int    `json:"retain,omitempty"`
}

type ReplicaInfo

type ReplicaInfo struct {
	InstanceInfo

	Mode         ReplicaMode
	BadTimestamp string
}

type ReplicaMode

type ReplicaMode string

type ScheduleData

type ScheduleData struct {
	Orchestrator string
	Data         []byte
}

type ScheduleInstance

type ScheduleInstance struct {
	ID         string
	Type       InstanceType
	HostID     string
	VolumeName string
	Name       string
}

type ScheduleItem

type ScheduleItem struct {
	Action   string
	Instance ScheduleInstance
	Data     ScheduleData
}

type ScheduleOps

type ScheduleOps interface {
	ListHosts() (map[string]*HostInfo, error)
	GetHost(id string) (*HostInfo, error)
	GetCurrentHostID() string
	ProcessSchedule(item *ScheduleItem) (*InstanceInfo, error)
}

type SchedulePolicy

type SchedulePolicy struct {
	Binding   SchedulePolicyBinding
	HostIDMap map[string]struct{}
}

type SchedulePolicyBinding

type SchedulePolicyBinding string

type ScheduleSpec

type ScheduleSpec struct {
	HostID string
}

type Scheduler

type Scheduler interface {
	Schedule(item *ScheduleItem, policy *SchedulePolicy) (*InstanceInfo, error)
	Process(spec *ScheduleSpec, item *ScheduleItem) (*InstanceInfo, error)
}

type ServiceLocator

type ServiceLocator interface {
	GetCurrentHostID() string
	GetAddress(hostID string) (string, error) // Return <host>:<port>
}

type Settings

type Settings interface {
	GetSettings() (*SettingsInfo, error)
	SetSettings(*SettingsInfo) error
}

type SettingsInfo

type SettingsInfo struct {
	BackupTarget string `json:"backupTarget" mapstructure:"backupTarget"`
	EngineImage  string `json:"engineImage" mapstructure:"engineImage"`
}

type SnapshotInfo

type SnapshotInfo struct {
	Name        string            `json:"name"`
	Parent      string            `json:"parent"`
	Children    []string          `json:"children"`
	Removed     bool              `json:"removed"`
	UserCreated bool              `json:"usercreated"`
	Created     string            `json:"created"`
	Size        string            `json:"size"`
	Labels      map[string]string `json:"labels"`
}

type SnapshotOps

type SnapshotOps interface {
	Create(name string, labels map[string]string) (string, error)
	List() ([]*SnapshotInfo, error)
	Get(name string) (*SnapshotInfo, error)
	Delete(name string) error
	Revert(name string) error
	Purge() error
}

type TaskQueue

type TaskQueue interface {
	io.Closer
	List() []*BgTask
	Put(*BgTask)
	Take() *BgTask
}

type VolumeBackupOps

type VolumeBackupOps interface {
	StartBackup(snapName, backupTarget string) error
	Restore(backup string) error
	DeleteBackup(backup string) error
}

type VolumeInfo

type VolumeInfo struct {
	Name                string
	Size                int64
	BaseImage           string
	FromBackup          string
	NumberOfReplicas    int
	StaleReplicaTimeout time.Duration
	Controller          *ControllerInfo
	Replicas            map[string]*ReplicaInfo //key is replicaName
	State               VolumeState
	EngineImage         string
	Endpoint            string
	Created             string
	RecurringJobs       []*RecurringJob
}

type VolumeManager

type VolumeManager interface {
	Start() error
	Create(volume *VolumeInfo) (*VolumeInfo, error)
	Delete(name string) error
	Get(name string) (*VolumeInfo, error)
	List() ([]*VolumeInfo, error)
	Attach(name string) error
	Detach(name string) error
	UpdateRecurring(name string, jobs []*RecurringJob) error
	ReplicaRemove(volumeName, replicaName string) error

	ListHosts() (map[string]*HostInfo, error)
	GetHost(id string) (*HostInfo, error)

	CheckController(ctrl Controller, volume *VolumeInfo) error
	Cleanup(volume *VolumeInfo) error

	Controller(name string) (Controller, error)
	SnapshotOps(name string) (SnapshotOps, error)
	VolumeBackupOps(name string) (VolumeBackupOps, error)
	Settings() Settings
	ManagerBackupOps(backupTarget string) ManagerBackupOps

	ProcessSchedule(spec *ScheduleSpec, item *ScheduleItem) (*InstanceInfo, error)
}

type VolumeState

type VolumeState string

Jump to

Keyboard shortcuts

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