Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct { // SaveKeys save opts SaveKeys []string // SaveValues save opts SaveValues []string // RemoveKeys remove keys RemoveKeys []string }
Batch batch opts
type ClusterStorage ¶
type ClusterStorage interface { // AlreadyBootstrapped returns the cluster was already bootstrapped AlreadyBootstrapped() (bool, error) // PutBootstrapped put cluster is bootstrapped PutBootstrapped(container metadata.Container, resources ...metadata.Resource) (bool, error) }
ClusterStorage cluster storage
type ConfigStorage ¶
type ConfigStorage interface { // SaveConfig stores marshallable cfg to the configPath. SaveConfig(cfg interface{}) error // LoadConfig loads config from configPath then unmarshal it to cfg. LoadConfig(cfg interface{}) (bool, error) // SaveScheduleConfig saves the config of scheduler. SaveScheduleConfig(scheduleName string, data []byte) error // RemoveScheduleConfig removes the config of scheduler. RemoveScheduleConfig(scheduleName string) error // LoadScheduleConfig loads the config of scheduler. LoadScheduleConfig(scheduleName string) (string, error) // LoadAllScheduleConfig loads all schedulers' config. LoadAllScheduleConfig() ([]string, []string, error) }
ConfigStorage config storage
type ContainerStorage ¶
type ContainerStorage interface { // PutContainer returns nil if container is add or update succ PutContainer(meta metadata.Container) error // RemoveContainer remove container from storage RemoveContainer(meta metadata.Container) error // GetContainer returns the spec container GetContainer(id uint64) (metadata.Container, error) // LoadContainers load all containers LoadContainers(limit int64, do func(meta metadata.Container, leaderWeight float64, resourceWeight float64)) error //PutContainerWeight saves a container's leader and resource weight to storage. PutContainerWeight(id uint64, leaderWeight, resourceWeight float64) error }
ContainerStorage container storage
type CustomDataStorage ¶
type CustomDataStorage interface { // PutCustomData puts the custom data to the storage PutCustomData(key []byte, data []byte) error // BatchPutCustomData batch puts the custom data to the storage BatchPutCustomData(keys [][]byte, data [][]byte) error // LoadCustomData load all custom data LoadCustomData(limit int64, f func(k, v []byte) error) error // RemoveCustomData remove custom data RemoveCustomData(key []byte) error }
CustomDataStorage custom data storage
type JobStorage ¶
type JobStorage interface { // PutJob puts the job metadata to the storage PutJob(metapb.Job) error // RemoveJob remove job from storage RemoveJob(jobType metapb.JobType) error // LoadJobs load all jobs LoadJobs(limit int64, do func(metapb.Job)) error // PutJobData put job data PutJobData(metapb.Job, []byte) error // GetJobData returns job data GetJobData(metapb.Job) ([]byte, error) // RemoveJobData removes job data RemoveJobData(metapb.Job) error }
JobStorage job storage
type KV ¶
type KV interface { // Batch do batch Batch(batch *Batch) error // Save save key-value paire to storage Save(key, value string) error // Load load data of key Load(key string) (string, error) // Remove delete key from storage Remove(key string) error // LoadRange iterates all key-value pairs in the storage LoadRange(key, endKey string, limit int64) ([]string, []string, error) // CountRange count all key-value pairs in the storage CountRange(key, endKey string) (uint64, error) // AllocID allocate a id from kv AllocID() (uint64, error) // SaveIfNotExists put the value at path // returns true, nil, nil if created // returns false, exists, nil if not created SaveIfNotExists(key string, value string, batch *Batch) (bool, string, error) // RemoveIfValueMatched returns true if the expect value is and the exists value are matched RemoveIfValueMatched(key string, expect string) (bool, error) // SaveWithoutLeader save without leader SaveWithoutLeader(key, value string) error // RemoveWithoutLeader remove without leader RemoveWithoutLeader(key string) error }
KV is an abstract interface for load/save prophet cluster data.
type ResourceStorage ¶
type ResourceStorage interface { // PutResource puts the meta to the storage PutResource(meta metadata.Resource) error // PutResources put resource in batch PutResources(resources ...metadata.Resource) error // RemoveResource remove resource from storage RemoveResource(meta metadata.Resource) error // GetResource returns the spec resource GetResource(id uint64) (metadata.Resource, error) // LoadResources load all resources LoadResources(limit int64, do func(metadata.Resource)) error // PutResourceAndExtra puts the meta and the extra data to the storage PutResourceAndExtra(meta metadata.Resource, extra []byte) error // GetResourceExtra returns the resource extra data PutResourceExtra(id uint64, extra []byte) error // GetResourceExtra returns the resource extra data GetResourceExtra(id uint64) ([]byte, error) PutScheduleGroupRule(metapb.ScheduleGroupRule) error LoadScheduleGroupRules(limit int64, do func(metapb.ScheduleGroupRule)) error }
ResourceStorage resource storage
type RuleStorage ¶
type RuleStorage interface { // PutRule puts the meta to the storage PutRule(key string, rule interface{}) error // LoadRules load all rules LoadRules(limit int64, f func(k, v string) error) error // RemoveRule remove rule RemoveRule(key string) error // PutResource puts the meta to the storage PutRuleGroup(groupID string, group interface{}) error // RemoveRule remove rule group RemoveRuleGroup(groupID string) error // LoadResources load all rule groups LoadRuleGroups(limit int64, f func(k, v string) error) error }
RuleStorage rule storage
type Storage ¶
type Storage interface { JobStorage CustomDataStorage RuleStorage ConfigStorage ContainerStorage ResourceStorage ContainerStorage ClusterStorage // KV return KV storage KV() KV }
Storage meta storage
func NewStorage ¶
NewStorage returns a metadata storage
Click to show internal directories.
Click to hide internal directories.