Documentation
¶
Index ¶
- Constants
- Variables
- func InitZkStore(zkPath *url.URL) error
- type Application
- type AtomicOp
- type Container
- type Docker
- type DummyStore
- func (dummy *DummyStore) CreateApp(app *Application) error
- func (dummy *DummyStore) CreateOfferAllocatorItem(item *OfferAllocatorItem) error
- func (dummy *DummyStore) CreateSlot(slot *Slot) error
- func (dummy *DummyStore) CreateVersion(appId string, version *Version) error
- func (dummy *DummyStore) DeleteApp(appId string) error
- func (dummy *DummyStore) DeleteOfferAllocatorItem(slotId string) error
- func (dummy *DummyStore) DeleteSlot(appId, slotId string) error
- func (dummy *DummyStore) GetApp(appId string) *Application
- func (dummy *DummyStore) GetFrameworkId() string
- func (dummy *DummyStore) GetSlot(appId, slotId string) *Slot
- func (dummy *DummyStore) GetVersion(appId, versionId string) *Version
- func (dummy *DummyStore) ListApps() []*Application
- func (dummy *DummyStore) ListOfferallocatorItems() []*OfferAllocatorItem
- func (dummy *DummyStore) ListSlots(appId string) []*Slot
- func (dummy *DummyStore) ListTaskHistory(appId, slotId string) []*Task
- func (dummy *DummyStore) ListVersions(appId string) []*Version
- func (dummy *DummyStore) Synchronize() error
- func (dummy *DummyStore) UpdateApp(app *Application) error
- func (dummy *DummyStore) UpdateCurrentTask(appId, slotId string, task *Task) error
- func (dummy *DummyStore) UpdateFrameworkId(frameworkId string) error
- func (dummy *DummyStore) UpdateSlot(appId, slotId string, slot *Slot) error
- type HealthCheck
- type KillPolicy
- type OfferAllocatorItem
- type Parameter
- type PortMapping
- type RestartPolicy
- type Slot
- type State
- type StateMachine
- type Storage
- type Store
- type StoreEntity
- type StoreOp
- type Task
- type UpdatePolicy
- type Version
- type Volume
- type ZkStore
- func (zk *ZkStore) Apply(op *AtomicOp, zkPersistNeeded bool) error
- func (zk *ZkStore) CreateApp(app *Application) error
- func (zk *ZkStore) CreateOfferAllocatorItem(item *OfferAllocatorItem) error
- func (zk *ZkStore) CreateSlot(slot *Slot) error
- func (zk *ZkStore) CreateVersion(appId string, version *Version) error
- func (zk *ZkStore) DeleteApp(appId string) error
- func (zk *ZkStore) DeleteOfferAllocatorItem(offerId string) error
- func (zk *ZkStore) DeleteSlot(appId, slotId string) error
- func (zk *ZkStore) GetApp(appId string) *Application
- func (zk *ZkStore) GetFrameworkId() string
- func (zk *ZkStore) GetSlot(appId, slotId string) *Slot
- func (zk *ZkStore) GetVersion(appId, versionId string) *Version
- func (zk *ZkStore) ListApps() []*Application
- func (zk *ZkStore) ListOfferallocatorItems() []*OfferAllocatorItem
- func (zk *ZkStore) ListSlots(appId string) []*Slot
- func (zk *ZkStore) ListTaskHistory(appId, slotId string) []*Task
- func (zk *ZkStore) ListVersions(appId string) []*Version
- func (zk *ZkStore) Recover() error
- func (zk *ZkStore) Start(ctx context.Context) error
- func (zk *ZkStore) UpdateApp(app *Application) error
- func (zk *ZkStore) UpdateCurrentTask(appId, slotId string, task *Task) error
- func (zk *ZkStore) UpdateFrameworkId(frameworkId string) error
- func (zk *ZkStore) UpdateSlot(appId, slotId string, slot *Slot) error
Constants ¶
View Source
const ( SWAN_ATOMIC_STORE_NODE_PATH = "%s/atomic-store" SWAN_SNAPSHOT_PATH = "%s/snapshot" )
Variables ¶
View Source
var ( ErrAppNotFound = errors.New("app not found") ErrAppAlreadyExists = errors.New("app already exists") ErrSlotNotFound = errors.New("slot not found") ErrSlotAlreadyExists = errors.New("slot already exists") ErrVersionAlreadyExists = errors.New("version already exists") )
View Source
var (
ZK_DEFAULT_ACL = zookeeper.WorldACL(zookeeper.PermAll)
)
Functions ¶
func InitZkStore ¶
Types ¶
type Application ¶
type Application struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Version *Version `json:"version,omitempty"`
ProposedVersion *Version `json:"proposedVersion,omitempty"`
ClusterID string `json:"clusterId,omitempty"`
StateMachine *StateMachine `json:"stateMachine,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
State string `json:"State,omitempty"`
}
func (*Application) Bytes ¶
func (app *Application) Bytes() []byte
func (*Application) FromBytes ¶
func (app *Application) FromBytes(buf []byte) *Application
type AtomicOp ¶
type AtomicOp struct {
// atomic operaiton type, ADD | REMOVE | UPDATE
Op StoreOp
// which object type been operating
Entity StoreEntity
// can be explained by any specfic operation & object type operating on appId/slotId maybe
Param1 string
// same as Param1
Param2 string
// same as Param1
Param3 string
// contains the data that the operation care, mostly object itself like App/Slot/Version
Payload interface{}
}
type Docker ¶
type Docker struct {
ForcePullImage bool `json:"forcePullImage,omitempty"`
Image string `json:"image,omitempty"`
Network string `json:"network,omitempty"`
Parameters []*Parameter `json:"parameters,omitempty"`
PortMappings []*PortMapping `json:"portMappings,omitempty"`
Privileged bool `json:"privileged,omitempty"`
}
type DummyStore ¶
type DummyStore struct {
Apps map[string]*appHolder
OfferAllocator map[string]*OfferAllocatorItem
FrameworkId string
// contains filtered or unexported fields
}
func NewDummyStore ¶
func NewDummyStore() *DummyStore
func (*DummyStore) CreateApp ¶
func (dummy *DummyStore) CreateApp(app *Application) error
func (*DummyStore) CreateOfferAllocatorItem ¶
func (dummy *DummyStore) CreateOfferAllocatorItem(item *OfferAllocatorItem) error
func (*DummyStore) CreateSlot ¶
func (dummy *DummyStore) CreateSlot(slot *Slot) error
func (*DummyStore) CreateVersion ¶
func (dummy *DummyStore) CreateVersion(appId string, version *Version) error
func (*DummyStore) DeleteApp ¶
func (dummy *DummyStore) DeleteApp(appId string) error
func (*DummyStore) DeleteOfferAllocatorItem ¶
func (dummy *DummyStore) DeleteOfferAllocatorItem(slotId string) error
func (*DummyStore) DeleteSlot ¶
func (dummy *DummyStore) DeleteSlot(appId, slotId string) error
func (*DummyStore) GetApp ¶
func (dummy *DummyStore) GetApp(appId string) *Application
func (*DummyStore) GetFrameworkId ¶
func (dummy *DummyStore) GetFrameworkId() string
func (*DummyStore) GetSlot ¶
func (dummy *DummyStore) GetSlot(appId, slotId string) *Slot
func (*DummyStore) GetVersion ¶
func (dummy *DummyStore) GetVersion(appId, versionId string) *Version
func (*DummyStore) ListApps ¶
func (dummy *DummyStore) ListApps() []*Application
func (*DummyStore) ListOfferallocatorItems ¶
func (dummy *DummyStore) ListOfferallocatorItems() []*OfferAllocatorItem
func (*DummyStore) ListSlots ¶
func (dummy *DummyStore) ListSlots(appId string) []*Slot
func (*DummyStore) ListTaskHistory ¶
func (dummy *DummyStore) ListTaskHistory(appId, slotId string) []*Task
func (*DummyStore) ListVersions ¶
func (dummy *DummyStore) ListVersions(appId string) []*Version
func (*DummyStore) Synchronize ¶
func (dummy *DummyStore) Synchronize() error
func (*DummyStore) UpdateApp ¶
func (dummy *DummyStore) UpdateApp(app *Application) error
func (*DummyStore) UpdateCurrentTask ¶
func (dummy *DummyStore) UpdateCurrentTask(appId, slotId string, task *Task) error
func (*DummyStore) UpdateFrameworkId ¶
func (dummy *DummyStore) UpdateFrameworkId(frameworkId string) error
func (*DummyStore) UpdateSlot ¶
func (dummy *DummyStore) UpdateSlot(appId, slotId string, slot *Slot) error
type HealthCheck ¶
type HealthCheck struct {
ID string `json:"id,omitempty"`
Address string `json:"address,omitempty"`
Protocol string `json:"protocol,omitempty"`
Port int32 `json:"port,omitempty"`
PortIndex int32 `json:"portIndex,omitempty"`
PortName string `json:"portName,omitempty"`
Value string `json:"value,omitempty"`
Path string `json:"path,omitempty"`
ConsecutiveFailures uint32 `json:"consecutiveFailures,omitempty"`
GracePeriodSeconds float64 `json:"gracePeriodSeconds,omitempty"`
IntervalSeconds float64 `json:"intervalSeconds,omitempty"`
TimeoutSeconds float64 `json:"timeoutSeconds,omitempty"`
DelaySeconds float64 `json:"delaySeconds,omitempty"`
}
type KillPolicy ¶
type KillPolicy struct {
Duration int64 `json:"duration,omitempty"`
}
type OfferAllocatorItem ¶
type PortMapping ¶
type RestartPolicy ¶
type RestartPolicy struct {
}
type Slot ¶
type Slot struct {
Index int32 `json:"index,omitempty"`
ID string `json:"id,omitempty"`
AppID string `json:"appId,omitempty"`
VersionID string `json:"versionId,omitempty"`
State string `json:"state,omitempty"`
MarkForDeletion bool `json:"markForDeletion,omitempty"`
MarkForRollingUpdate bool `json:"markForRollingUpdate,omitempty"`
Healthy bool `json:"healthy,omitempty"`
CurrentTask *Task `json:"CurrentTask,omitempty"`
TaskHistory []*Task `json:"TaskHistory,omitempty"`
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty"`
Weight float64 `json:"weight,omitempty"`
}
type StateMachine ¶
type StateMachine struct {
State *State `json:"state,omitempty"`
}
type Storage ¶
type Storage struct {
Apps map[string]*appHolder `json:"apps"`
OfferAllocator map[string]*OfferAllocatorItem `json:"offerAllocator"`
FrameworkId string `json:"frameworkid"`
}
func NewStorage ¶
func NewStorage() *Storage
type Store ¶
type Store interface {
CreateApp(app *Application) error
UpdateApp(app *Application) error
GetApp(appId string) *Application
ListApps() []*Application
DeleteApp(appId string) error
CreateVersion(appId string, version *Version) error
GetVersion(appId, versionId string) *Version
ListVersions(appId string) []*Version
CreateSlot(slot *Slot) error
GetSlot(appId, slotId string) *Slot
ListSlots(appId string) []*Slot
UpdateSlot(appId, slotId string, slot *Slot) error
DeleteSlot(appId, slotId string) error
UpdateCurrentTask(appId, slotId string, task *Task) error
ListTaskHistory(appId, slotId string) []*Task
UpdateFrameworkId(frameworkId string) error
GetFrameworkId() string
CreateOfferAllocatorItem(item *OfferAllocatorItem) error
DeleteOfferAllocatorItem(slotId string) error
ListOfferallocatorItems() []*OfferAllocatorItem
Recover() error
Start(context.Context) error
}
type StoreEntity ¶
type StoreEntity uint8
represents the object type been manipulation by any specfic operation
var ( ENTITY_APP StoreEntity = 1 ENTITY_SLOT StoreEntity = 2 ENTITY_VERSION StoreEntity = 3 ENTITY_CURRENT_TASK StoreEntity = 4 ENTITY_FRAMEWORKID StoreEntity = 5 ENTITY_OFFER_ALLOCATOR_ITEM StoreEntity = 6 )
func (StoreEntity) String ¶
func (entity StoreEntity) String() string
type StoreOp ¶
type StoreOp uint8
represents atomic operation both apply to ZK and intertal storage structure
type Task ¶
type Task struct {
ID string `json:"id,omitempty"`
AppID string `json:"appId,omitempty"`
VersionID string `json:"versionId,omitempty"`
SlotID string `json:"slotId,omitempty"`
State string `json:"state,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
HostPorts []uint64 `json:"hostPorts,omitempty"`
OfferID string `json:"offerId,omitempty"`
AgentID string `json:"agentId,omitempty"`
Ip string `json:"ip,omitempty"`
AgentHostName string `json:"agentHostName,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
ArchivedAt int64 `json:"archivedAt,omitempty"`
ContainerId string `json:"containerId,omitempty"`
ContainerName string `json:"containerName,omitempty"`
Weight float64 `json:"weight,omitempty"`
}
type UpdatePolicy ¶
type Version ¶
type Version struct {
ID string `json:"id,omitempty"`
Command string `json:"command,omitempty"`
Cpus float64 `json:"cpus,omitempty"`
Mem float64 `json:"mem,omitempty"`
Disk float64 `json:"disk,omitempty"`
Instances int32 `json:"instances,omitempty"`
RunAs string `json:"runAs,omitempty"`
Container *Container `json:"container,omitempty"`
Labels map[string]string `protobuf_val:"bytes,2,opt,name=value,proto3"`
HealthCheck *HealthCheck `json:"healthCheck,omitempty"`
Env map[string]string `protobuf_val:"bytes,2,opt,name=value,proto3"`
KillPolicy *KillPolicy `json:"killPolicy,omitempty"`
UpdatePolicy *UpdatePolicy `json:"updatePolicy,omitempty"`
Constraints string `json:"constraints,omitempty"`
Uris []string `json:"uris,omitempty"`
Ip []string `json:"ip,omitempty"`
Mode string `json:"mode,omitempty"`
AppName string `json:"appName,omitempty"`
AppID string `json:"appID,omitempty"`
Priority int32 `json:"priority,omitempty"`
Args []string `json:"args,omitempty"`
AppVersion string `json:"appVersion,omitempty"`
}
type ZkStore ¶
type ZkStore struct {
Storage *Storage
// contains filtered or unexported fields
}
func (*ZkStore) CreateApp ¶
func (zk *ZkStore) CreateApp(app *Application) error
func (*ZkStore) CreateOfferAllocatorItem ¶
func (zk *ZkStore) CreateOfferAllocatorItem(item *OfferAllocatorItem) error
func (*ZkStore) CreateSlot ¶
func (*ZkStore) CreateVersion ¶
func (*ZkStore) DeleteOfferAllocatorItem ¶
func (*ZkStore) DeleteSlot ¶
func (*ZkStore) GetApp ¶
func (zk *ZkStore) GetApp(appId string) *Application
func (*ZkStore) GetFrameworkId ¶
func (*ZkStore) GetVersion ¶
func (*ZkStore) ListApps ¶
func (zk *ZkStore) ListApps() []*Application
func (*ZkStore) ListOfferallocatorItems ¶
func (zk *ZkStore) ListOfferallocatorItems() []*OfferAllocatorItem
func (*ZkStore) ListTaskHistory ¶
func (*ZkStore) ListVersions ¶
func (*ZkStore) UpdateApp ¶
func (zk *ZkStore) UpdateApp(app *Application) error
func (*ZkStore) UpdateCurrentTask ¶
func (*ZkStore) UpdateFrameworkId ¶
Click to show internal directories.
Click to hide internal directories.