Documentation ¶
Index ¶
- func Validate(p Placement) error
- type ActiveStagedPlacement
- type ActiveStagedPlacementOptions
- type Algorithm
- type ByIDAscending
- type DeploymentOptions
- type DeploymentPlanner
- type DoneFn
- type Instance
- type InstanceSelector
- type Instances
- type MockActiveStagedPlacement
- type MockActiveStagedPlacementOptions
- func (_m *MockActiveStagedPlacementOptions) ClockOptions() clock.Options
- func (_m *MockActiveStagedPlacementOptions) EXPECT() *_MockActiveStagedPlacementOptionsRecorder
- func (_m *MockActiveStagedPlacementOptions) OnPlacementsAddedFn() OnPlacementsAddedFn
- func (_m *MockActiveStagedPlacementOptions) OnPlacementsRemovedFn() OnPlacementsRemovedFn
- func (_m *MockActiveStagedPlacementOptions) SetClockOptions(value clock.Options) ActiveStagedPlacementOptions
- func (_m *MockActiveStagedPlacementOptions) SetOnPlacementsAddedFn(value OnPlacementsAddedFn) ActiveStagedPlacementOptions
- func (_m *MockActiveStagedPlacementOptions) SetOnPlacementsRemovedFn(value OnPlacementsRemovedFn) ActiveStagedPlacementOptions
- type MockAlgorithm
- func (_m *MockAlgorithm) AddInstances(p Placement, instances []Instance) (Placement, error)
- func (_m *MockAlgorithm) AddReplica(p Placement) (Placement, error)
- func (_m *MockAlgorithm) EXPECT() *_MockAlgorithmRecorder
- func (_m *MockAlgorithm) InitialPlacement(instances []Instance, shards []uint32, rf int) (Placement, error)
- func (_m *MockAlgorithm) IsCompatibleWith(p Placement) error
- func (_m *MockAlgorithm) MarkAllShardsAvailable(p Placement) (Placement, bool, error)
- func (_m *MockAlgorithm) MarkShardsAvailable(p Placement, instanceID string, shardIDs ...uint32) (Placement, error)
- func (_m *MockAlgorithm) RemoveInstances(p Placement, leavingInstanceIDs []string) (Placement, error)
- func (_m *MockAlgorithm) ReplaceInstances(p Placement, leavingInstanecIDs []string, addingInstances []Instance) (Placement, error)
- type MockDeploymentOptions
- type MockDeploymentPlanner
- type MockInstance
- func (_m *MockInstance) Clone() Instance
- func (_m *MockInstance) EXPECT() *_MockInstanceRecorder
- func (_m *MockInstance) Endpoint() string
- func (_m *MockInstance) Hostname() string
- func (_m *MockInstance) ID() string
- func (_m *MockInstance) IsAvailable() bool
- func (_m *MockInstance) IsInitializing() bool
- func (_m *MockInstance) IsLeaving() bool
- func (_m *MockInstance) IsolationGroup() string
- func (_m *MockInstance) Port() uint32
- func (_m *MockInstance) Proto() (*placementpb.Instance, error)
- func (_m *MockInstance) SetEndpoint(ip string) Instance
- func (_m *MockInstance) SetHostname(value string) Instance
- func (_m *MockInstance) SetID(id string) Instance
- func (_m *MockInstance) SetIsolationGroup(r string) Instance
- func (_m *MockInstance) SetPort(value uint32) Instance
- func (_m *MockInstance) SetShardSetID(value uint32) Instance
- func (_m *MockInstance) SetShards(s shard.Shards) Instance
- func (_m *MockInstance) SetWeight(w uint32) Instance
- func (_m *MockInstance) SetZone(z string) Instance
- func (_m *MockInstance) ShardSetID() uint32
- func (_m *MockInstance) Shards() shard.Shards
- func (_m *MockInstance) String() string
- func (_m *MockInstance) Weight() uint32
- func (_m *MockInstance) Zone() string
- type MockInstanceSelector
- func (_m *MockInstanceSelector) EXPECT() *_MockInstanceSelectorRecorder
- func (_m *MockInstanceSelector) SelectAddingInstances(candidates []Instance, p Placement) ([]Instance, error)
- func (_m *MockInstanceSelector) SelectInitialInstances(candidates []Instance, rf int) ([]Instance, error)
- func (_m *MockInstanceSelector) SelectReplaceInstances(candidates []Instance, leavingInstanceIDs []string, p Placement) ([]Instance, error)
- type MockOptions
- func (_m *MockOptions) AddAllCandidates() bool
- func (_m *MockOptions) AllowPartialReplace() bool
- func (_m *MockOptions) Dryrun() bool
- func (_m *MockOptions) EXPECT() *_MockOptionsRecorder
- func (_m *MockOptions) InstrumentOptions() instrument.Options
- func (_m *MockOptions) IsMirrored() bool
- func (_m *MockOptions) IsShardCutoffFn() ShardValidationFn
- func (_m *MockOptions) IsShardCutoverFn() ShardValidationFn
- func (_m *MockOptions) IsSharded() bool
- func (_m *MockOptions) IsStaged() bool
- func (_m *MockOptions) NowFn() clock.NowFn
- func (_m *MockOptions) PlacementCutoverNanosFn() TimeNanosFn
- func (_m *MockOptions) SetAddAllCandidates(addAllCandidates bool) Options
- func (_m *MockOptions) SetAllowPartialReplace(allowPartialReplace bool) Options
- func (_m *MockOptions) SetDryrun(d bool) Options
- func (_m *MockOptions) SetInstrumentOptions(iopts instrument.Options) Options
- func (_m *MockOptions) SetIsMirrored(m bool) Options
- func (_m *MockOptions) SetIsShardCutoffFn(fn ShardValidationFn) Options
- func (_m *MockOptions) SetIsShardCutoverFn(fn ShardValidationFn) Options
- func (_m *MockOptions) SetIsSharded(sharded bool) Options
- func (_m *MockOptions) SetIsStaged(v bool) Options
- func (_m *MockOptions) SetNowFn(fn clock.NowFn) Options
- func (_m *MockOptions) SetPlacementCutoverNanosFn(fn TimeNanosFn) Options
- func (_m *MockOptions) SetShardCutoffNanosFn(fn TimeNanosFn) Options
- func (_m *MockOptions) SetShardCutoverNanosFn(fn TimeNanosFn) Options
- func (_m *MockOptions) SetShardStateMode(value ShardStateMode) Options
- func (_m *MockOptions) SetValidZone(z string) Options
- func (_m *MockOptions) ShardCutoffNanosFn() TimeNanosFn
- func (_m *MockOptions) ShardCutoverNanosFn() TimeNanosFn
- func (_m *MockOptions) ShardStateMode() ShardStateMode
- func (_m *MockOptions) ValidZone() string
- type MockPlacement
- func (_m *MockPlacement) Clone() Placement
- func (_m *MockPlacement) CutoverNanos() int64
- func (_m *MockPlacement) EXPECT() *_MockPlacementRecorder
- func (_m *MockPlacement) GetVersion() int
- func (_m *MockPlacement) Instance(id string) (Instance, bool)
- func (_m *MockPlacement) Instances() []Instance
- func (_m *MockPlacement) InstancesForShard(shard uint32) []Instance
- func (_m *MockPlacement) IsMirrored() bool
- func (_m *MockPlacement) IsSharded() bool
- func (_m *MockPlacement) MaxShardSetID() uint32
- func (_m *MockPlacement) NumInstances() int
- func (_m *MockPlacement) NumShards() int
- func (_m *MockPlacement) Proto() (*placementpb.Placement, error)
- func (_m *MockPlacement) ReplicaFactor() int
- func (_m *MockPlacement) SetCutoverNanos(cutoverNanos int64) Placement
- func (_m *MockPlacement) SetInstances(instances []Instance) Placement
- func (_m *MockPlacement) SetIsMirrored(v bool) Placement
- func (_m *MockPlacement) SetIsSharded(v bool) Placement
- func (_m *MockPlacement) SetMaxShardSetID(value uint32) Placement
- func (_m *MockPlacement) SetReplicaFactor(rf int) Placement
- func (_m *MockPlacement) SetShards(s []uint32) Placement
- func (_m *MockPlacement) SetVersion(v int) Placement
- func (_m *MockPlacement) Shards() []uint32
- func (_m *MockPlacement) String() string
- type MockService
- func (_m *MockService) AddInstances(candidates []Instance) (Placement, []Instance, error)
- func (_m *MockService) AddReplica() (Placement, error)
- func (_m *MockService) BuildInitialPlacement(instances []Instance, numShards int, rf int) (Placement, error)
- func (_m *MockService) CheckAndSet(p Placement, version int) error
- func (_m *MockService) CheckAndSetProto(p proto.Message, version int) error
- func (_m *MockService) Delete() error
- func (_m *MockService) EXPECT() *_MockServiceRecorder
- func (_m *MockService) MarkAllShardsAvailable() (Placement, error)
- func (_m *MockService) MarkInstanceAvailable(instanceID string) error
- func (_m *MockService) MarkShardsAvailable(instanceID string, shardIDs ...uint32) error
- func (_m *MockService) Placement() (Placement, int, error)
- func (_m *MockService) PlacementForVersion(version int) (Placement, error)
- func (_m *MockService) Proto() (proto.Message, int, error)
- func (_m *MockService) RemoveInstances(leavingInstanceIDs []string) (Placement, error)
- func (_m *MockService) ReplaceInstances(leavingInstanceIDs []string, candidates []Instance) (Placement, []Instance, error)
- func (_m *MockService) Set(p Placement) error
- func (_m *MockService) SetIfNotExist(p Placement) error
- func (_m *MockService) SetProto(p proto.Message) error
- func (_m *MockService) Watch() (Watch, error)
- type MockStagedPlacement
- func (_m *MockStagedPlacement) ActiveStagedPlacement(timeNanos int64) ActiveStagedPlacement
- func (_m *MockStagedPlacement) ActiveStagedPlacementOptions() ActiveStagedPlacementOptions
- func (_m *MockStagedPlacement) EXPECT() *_MockStagedPlacementRecorder
- func (_m *MockStagedPlacement) Placements() Placements
- func (_m *MockStagedPlacement) Proto() (*placementpb.PlacementSnapshots, error)
- func (_m *MockStagedPlacement) SetActiveStagedPlacementOptions(opts ActiveStagedPlacementOptions) StagedPlacement
- func (_m *MockStagedPlacement) SetPlacements(placements []Placement) StagedPlacement
- func (_m *MockStagedPlacement) SetVersion(version int) StagedPlacement
- func (_m *MockStagedPlacement) Version() int
- type MockStagedPlacementWatcher
- type MockStagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) ActiveStagedPlacementOptions() ActiveStagedPlacementOptions
- func (_m *MockStagedPlacementWatcherOptions) ClockOptions() clock.Options
- func (_m *MockStagedPlacementWatcherOptions) EXPECT() *_MockStagedPlacementWatcherOptionsRecorder
- func (_m *MockStagedPlacementWatcherOptions) InitWatchTimeout() time.Duration
- func (_m *MockStagedPlacementWatcherOptions) InstrumentOptions() instrument.Options
- func (_m *MockStagedPlacementWatcherOptions) SetActiveStagedPlacementOptions(value ActiveStagedPlacementOptions) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) SetClockOptions(value clock.Options) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) SetInitWatchTimeout(value time.Duration) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) SetInstrumentOptions(value instrument.Options) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) SetStagedPlacementKey(value string) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) SetStagedPlacementStore(store kv.Store) StagedPlacementWatcherOptions
- func (_m *MockStagedPlacementWatcherOptions) StagedPlacementKey() string
- func (_m *MockStagedPlacementWatcherOptions) StagedPlacementStore() kv.Store
- type MockStorage
- func (_m *MockStorage) CheckAndSet(p Placement, version int) error
- func (_m *MockStorage) CheckAndSetProto(p proto.Message, version int) error
- func (_m *MockStorage) Delete() error
- func (_m *MockStorage) EXPECT() *_MockStorageRecorder
- func (_m *MockStorage) Placement() (Placement, int, error)
- func (_m *MockStorage) PlacementForVersion(version int) (Placement, error)
- func (_m *MockStorage) Proto() (proto.Message, int, error)
- func (_m *MockStorage) Set(p Placement) error
- func (_m *MockStorage) SetIfNotExist(p Placement) error
- func (_m *MockStorage) SetProto(p proto.Message) error
- func (_m *MockStorage) Watch() (Watch, error)
- type MockWatch
- type OnPlacementsAddedFn
- type OnPlacementsRemovedFn
- type Options
- type Placement
- type Placements
- type Service
- type ShardStateMode
- type ShardValidationFn
- type StagedPlacement
- type StagedPlacementWatcher
- type StagedPlacementWatcherOptions
- type Storage
- type TimeNanosFn
- type Watch
- type WatcherConfiguration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActiveStagedPlacement ¶
type ActiveStagedPlacement interface { // ActivePlacement returns the currently active placement for a given time, the callback // function when the caller is done using the placement, and any errors encountered. ActivePlacement() (Placement, DoneFn, error) // Close closes the active staged placement. Close() error }
ActiveStagedPlacement describes active staged placement.
type ActiveStagedPlacementOptions ¶
type ActiveStagedPlacementOptions interface { // SetClockOptions sets the clock options. SetClockOptions(value clock.Options) ActiveStagedPlacementOptions // ClockOptions returns the clock options. ClockOptions() clock.Options // SetOnPlacementsAddedFn sets the callback function for adding placement. SetOnPlacementsAddedFn(value OnPlacementsAddedFn) ActiveStagedPlacementOptions // OnPlacementsAddedFn returns the callback function for adding placement. OnPlacementsAddedFn() OnPlacementsAddedFn // SetOnPlacementsRemovedFn sets the callback function for removing placement. SetOnPlacementsRemovedFn(value OnPlacementsRemovedFn) ActiveStagedPlacementOptions // OnPlacementsRemovedFn returns the callback function for removing placement. OnPlacementsRemovedFn() OnPlacementsRemovedFn }
ActiveStagedPlacementOptions provide a set of options for active staged placement.
func NewActiveStagedPlacementOptions ¶
func NewActiveStagedPlacementOptions() ActiveStagedPlacementOptions
NewActiveStagedPlacementOptions create a new set of active staged placement options.
type Algorithm ¶
type Algorithm interface { // InitPlacement initialize a sharding placement with given replica factor. InitialPlacement(instances []Instance, shards []uint32, rf int) (Placement, error) // AddReplica up the replica factor by 1 in the placement. AddReplica(p Placement) (Placement, error) // AddInstances adds a list of instance to the placement. AddInstances(p Placement, instances []Instance) (Placement, error) // RemoveInstances removes a list of instances from the placement. RemoveInstances(p Placement, leavingInstanceIDs []string) (Placement, error) // ReplaceInstance replace a list of instances with new instances. ReplaceInstances( p Placement, leavingInstanecIDs []string, addingInstances []Instance, ) (Placement, error) // IsCompatibleWith checks whether the algorithm could be applied to given placement. IsCompatibleWith(p Placement) error // MarkShardsAvailable marks given shards as available. MarkShardsAvailable(p Placement, instanceID string, shardIDs ...uint32) (Placement, error) // MarkAllShardsAvailable marks shard states as available where applicable. MarkAllShardsAvailable(p Placement) (Placement, bool, error) }
Algorithm places shards on instances.
type ByIDAscending ¶
type ByIDAscending []Instance
ByIDAscending sorts Instance by ID ascending
func (ByIDAscending) Len ¶
func (s ByIDAscending) Len() int
func (ByIDAscending) Less ¶
func (s ByIDAscending) Less(i, j int) bool
func (ByIDAscending) Swap ¶
func (s ByIDAscending) Swap(i, j int)
type DeploymentOptions ¶
type DeploymentOptions interface { // MaxStepSize limits the number of instances to be deployed in one step MaxStepSize() int SetMaxStepSize(stepSize int) DeploymentOptions }
DeploymentOptions provides options for DeploymentPlanner
func NewDeploymentOptions ¶
func NewDeploymentOptions() DeploymentOptions
NewDeploymentOptions returns a default DeploymentOptions
type DeploymentPlanner ¶
type DeploymentPlanner interface { // DeploymentSteps returns the deployment steps DeploymentSteps(p Placement) [][]Instance }
DeploymentPlanner generates deployment steps for a placement
type Instance ¶
type Instance interface { // String is for debugging. String() string // ID is the id of the instance. ID() string // SetID sets the id of the instance. SetID(id string) Instance // IsolationGroup is the isolation group of the instance, // which usually but not necessarily refers to the rack of the instance. IsolationGroup() string // SetIsolationGroup sets the isolation group of the instance. SetIsolationGroup(r string) Instance // Zone is the zone of the instance. Zone() string // SetZone sets the zone of the instance. SetZone(z string) Instance // Weight is the weight of the instance. Weight() uint32 // SetWeight sets the weight of the instance. SetWeight(w uint32) Instance // Endpoint is the endpoint of the instance. Endpoint() string // SetEndpoint sets the endpoint of the instance. SetEndpoint(ip string) Instance // Shards returns the shards owned by the instance. Shards() shard.Shards // SetShards sets the shards owned by the instance. SetShards(s shard.Shards) Instance // ShardSetID returns the shard set id. ShardSetID() uint32 // SetShardSetID sets the shard set id. SetShardSetID(value uint32) Instance // Hostname returns the hostname of the instance. Hostname() string // SetHostname sets the hostname of the instance. SetHostname(value string) Instance // Port returns the port of the instance. Port() uint32 // SetPort sets the port of the instance. SetPort(value uint32) Instance // Proto returns the proto representation for the Instance. Proto() (*placementpb.Instance, error) // IsLeaving returns whether the instance contains only leaving shards. IsLeaving() bool // IsInitializing returns whether the instance contains only initializing shards. IsInitializing() bool // IsAvailable returns whether the instance contains only available shards. IsAvailable() bool // Clone returns a clone of the Instance. Clone() Instance }
Instance represents an instance in a placement.
func NewEmptyInstance ¶
NewEmptyInstance returns a Instance with some basic properties but no shards assigned
func NewInstanceFromProto ¶
func NewInstanceFromProto(instance *placementpb.Instance) (Instance, error)
NewInstanceFromProto creates a new placement instance from proto.
type InstanceSelector ¶
type InstanceSelector interface { // SelectInitialInstances selects instances for the initial placement. SelectInitialInstances( candidates []Instance, rf int, ) ([]Instance, error) // SelectAddingInstances selects instances to be added to the placement. SelectAddingInstances( candidates []Instance, p Placement, ) ([]Instance, error) // SelectReplaceInstances selects instances to replace existing instances in the placement. SelectReplaceInstances( candidates []Instance, leavingInstanceIDs []string, p Placement, ) ([]Instance, error) }
InstanceSelector selects valid instances for the placement change.
type Instances ¶
type Instances []Instance
Instances is a slice of instances that can produce a debug string.
type MockActiveStagedPlacement ¶
type MockActiveStagedPlacement struct {
// contains filtered or unexported fields
}
Mock of ActiveStagedPlacement interface
func NewMockActiveStagedPlacement ¶
func NewMockActiveStagedPlacement(ctrl *gomock.Controller) *MockActiveStagedPlacement
func (*MockActiveStagedPlacement) ActivePlacement ¶
func (_m *MockActiveStagedPlacement) ActivePlacement() (Placement, DoneFn, error)
func (*MockActiveStagedPlacement) Close ¶
func (_m *MockActiveStagedPlacement) Close() error
func (*MockActiveStagedPlacement) EXPECT ¶
func (_m *MockActiveStagedPlacement) EXPECT() *_MockActiveStagedPlacementRecorder
type MockActiveStagedPlacementOptions ¶
type MockActiveStagedPlacementOptions struct {
// contains filtered or unexported fields
}
Mock of ActiveStagedPlacementOptions interface
func NewMockActiveStagedPlacementOptions ¶
func NewMockActiveStagedPlacementOptions(ctrl *gomock.Controller) *MockActiveStagedPlacementOptions
func (*MockActiveStagedPlacementOptions) ClockOptions ¶
func (_m *MockActiveStagedPlacementOptions) ClockOptions() clock.Options
func (*MockActiveStagedPlacementOptions) EXPECT ¶
func (_m *MockActiveStagedPlacementOptions) EXPECT() *_MockActiveStagedPlacementOptionsRecorder
func (*MockActiveStagedPlacementOptions) OnPlacementsAddedFn ¶
func (_m *MockActiveStagedPlacementOptions) OnPlacementsAddedFn() OnPlacementsAddedFn
func (*MockActiveStagedPlacementOptions) OnPlacementsRemovedFn ¶
func (_m *MockActiveStagedPlacementOptions) OnPlacementsRemovedFn() OnPlacementsRemovedFn
func (*MockActiveStagedPlacementOptions) SetClockOptions ¶
func (_m *MockActiveStagedPlacementOptions) SetClockOptions(value clock.Options) ActiveStagedPlacementOptions
func (*MockActiveStagedPlacementOptions) SetOnPlacementsAddedFn ¶
func (_m *MockActiveStagedPlacementOptions) SetOnPlacementsAddedFn(value OnPlacementsAddedFn) ActiveStagedPlacementOptions
func (*MockActiveStagedPlacementOptions) SetOnPlacementsRemovedFn ¶
func (_m *MockActiveStagedPlacementOptions) SetOnPlacementsRemovedFn(value OnPlacementsRemovedFn) ActiveStagedPlacementOptions
type MockAlgorithm ¶
type MockAlgorithm struct {
// contains filtered or unexported fields
}
Mock of Algorithm interface
func NewMockAlgorithm ¶
func NewMockAlgorithm(ctrl *gomock.Controller) *MockAlgorithm
func (*MockAlgorithm) AddInstances ¶
func (_m *MockAlgorithm) AddInstances(p Placement, instances []Instance) (Placement, error)
func (*MockAlgorithm) AddReplica ¶
func (_m *MockAlgorithm) AddReplica(p Placement) (Placement, error)
func (*MockAlgorithm) EXPECT ¶
func (_m *MockAlgorithm) EXPECT() *_MockAlgorithmRecorder
func (*MockAlgorithm) InitialPlacement ¶
func (*MockAlgorithm) IsCompatibleWith ¶
func (_m *MockAlgorithm) IsCompatibleWith(p Placement) error
func (*MockAlgorithm) MarkAllShardsAvailable ¶
func (_m *MockAlgorithm) MarkAllShardsAvailable(p Placement) (Placement, bool, error)
func (*MockAlgorithm) MarkShardsAvailable ¶
func (*MockAlgorithm) RemoveInstances ¶
func (_m *MockAlgorithm) RemoveInstances(p Placement, leavingInstanceIDs []string) (Placement, error)
func (*MockAlgorithm) ReplaceInstances ¶
type MockDeploymentOptions ¶
type MockDeploymentOptions struct {
// contains filtered or unexported fields
}
Mock of DeploymentOptions interface
func NewMockDeploymentOptions ¶
func NewMockDeploymentOptions(ctrl *gomock.Controller) *MockDeploymentOptions
func (*MockDeploymentOptions) EXPECT ¶
func (_m *MockDeploymentOptions) EXPECT() *_MockDeploymentOptionsRecorder
func (*MockDeploymentOptions) MaxStepSize ¶
func (_m *MockDeploymentOptions) MaxStepSize() int
func (*MockDeploymentOptions) SetMaxStepSize ¶
func (_m *MockDeploymentOptions) SetMaxStepSize(stepSize int) DeploymentOptions
type MockDeploymentPlanner ¶
type MockDeploymentPlanner struct {
// contains filtered or unexported fields
}
Mock of DeploymentPlanner interface
func NewMockDeploymentPlanner ¶
func NewMockDeploymentPlanner(ctrl *gomock.Controller) *MockDeploymentPlanner
func (*MockDeploymentPlanner) DeploymentSteps ¶
func (_m *MockDeploymentPlanner) DeploymentSteps(p Placement) [][]Instance
func (*MockDeploymentPlanner) EXPECT ¶
func (_m *MockDeploymentPlanner) EXPECT() *_MockDeploymentPlannerRecorder
type MockInstance ¶
type MockInstance struct {
// contains filtered or unexported fields
}
Mock of Instance interface
func NewMockInstance ¶
func NewMockInstance(ctrl *gomock.Controller) *MockInstance
func (*MockInstance) Clone ¶
func (_m *MockInstance) Clone() Instance
func (*MockInstance) EXPECT ¶
func (_m *MockInstance) EXPECT() *_MockInstanceRecorder
func (*MockInstance) Endpoint ¶
func (_m *MockInstance) Endpoint() string
func (*MockInstance) Hostname ¶
func (_m *MockInstance) Hostname() string
func (*MockInstance) ID ¶
func (_m *MockInstance) ID() string
func (*MockInstance) IsAvailable ¶
func (_m *MockInstance) IsAvailable() bool
func (*MockInstance) IsInitializing ¶
func (_m *MockInstance) IsInitializing() bool
func (*MockInstance) IsLeaving ¶
func (_m *MockInstance) IsLeaving() bool
func (*MockInstance) IsolationGroup ¶
func (_m *MockInstance) IsolationGroup() string
func (*MockInstance) Port ¶
func (_m *MockInstance) Port() uint32
func (*MockInstance) Proto ¶
func (_m *MockInstance) Proto() (*placementpb.Instance, error)
func (*MockInstance) SetEndpoint ¶
func (_m *MockInstance) SetEndpoint(ip string) Instance
func (*MockInstance) SetHostname ¶
func (_m *MockInstance) SetHostname(value string) Instance
func (*MockInstance) SetID ¶
func (_m *MockInstance) SetID(id string) Instance
func (*MockInstance) SetIsolationGroup ¶
func (_m *MockInstance) SetIsolationGroup(r string) Instance
func (*MockInstance) SetPort ¶
func (_m *MockInstance) SetPort(value uint32) Instance
func (*MockInstance) SetShardSetID ¶
func (_m *MockInstance) SetShardSetID(value uint32) Instance
func (*MockInstance) SetWeight ¶
func (_m *MockInstance) SetWeight(w uint32) Instance
func (*MockInstance) SetZone ¶
func (_m *MockInstance) SetZone(z string) Instance
func (*MockInstance) ShardSetID ¶
func (_m *MockInstance) ShardSetID() uint32
func (*MockInstance) Shards ¶
func (_m *MockInstance) Shards() shard.Shards
func (*MockInstance) String ¶
func (_m *MockInstance) String() string
func (*MockInstance) Weight ¶
func (_m *MockInstance) Weight() uint32
func (*MockInstance) Zone ¶
func (_m *MockInstance) Zone() string
type MockInstanceSelector ¶
type MockInstanceSelector struct {
// contains filtered or unexported fields
}
Mock of InstanceSelector interface
func NewMockInstanceSelector ¶
func NewMockInstanceSelector(ctrl *gomock.Controller) *MockInstanceSelector
func (*MockInstanceSelector) EXPECT ¶
func (_m *MockInstanceSelector) EXPECT() *_MockInstanceSelectorRecorder
func (*MockInstanceSelector) SelectAddingInstances ¶
func (_m *MockInstanceSelector) SelectAddingInstances(candidates []Instance, p Placement) ([]Instance, error)
func (*MockInstanceSelector) SelectInitialInstances ¶
func (_m *MockInstanceSelector) SelectInitialInstances(candidates []Instance, rf int) ([]Instance, error)
func (*MockInstanceSelector) SelectReplaceInstances ¶
type MockOptions ¶
type MockOptions struct {
// contains filtered or unexported fields
}
Mock of Options interface
func NewMockOptions ¶
func NewMockOptions(ctrl *gomock.Controller) *MockOptions
func (*MockOptions) AddAllCandidates ¶
func (_m *MockOptions) AddAllCandidates() bool
func (*MockOptions) AllowPartialReplace ¶
func (_m *MockOptions) AllowPartialReplace() bool
func (*MockOptions) Dryrun ¶
func (_m *MockOptions) Dryrun() bool
func (*MockOptions) EXPECT ¶
func (_m *MockOptions) EXPECT() *_MockOptionsRecorder
func (*MockOptions) InstrumentOptions ¶
func (_m *MockOptions) InstrumentOptions() instrument.Options
func (*MockOptions) IsMirrored ¶
func (_m *MockOptions) IsMirrored() bool
func (*MockOptions) IsShardCutoffFn ¶
func (_m *MockOptions) IsShardCutoffFn() ShardValidationFn
func (*MockOptions) IsShardCutoverFn ¶
func (_m *MockOptions) IsShardCutoverFn() ShardValidationFn
func (*MockOptions) IsSharded ¶
func (_m *MockOptions) IsSharded() bool
func (*MockOptions) IsStaged ¶
func (_m *MockOptions) IsStaged() bool
func (*MockOptions) NowFn ¶
func (_m *MockOptions) NowFn() clock.NowFn
func (*MockOptions) PlacementCutoverNanosFn ¶
func (_m *MockOptions) PlacementCutoverNanosFn() TimeNanosFn
func (*MockOptions) SetAddAllCandidates ¶
func (_m *MockOptions) SetAddAllCandidates(addAllCandidates bool) Options
func (*MockOptions) SetAllowPartialReplace ¶
func (_m *MockOptions) SetAllowPartialReplace(allowPartialReplace bool) Options
func (*MockOptions) SetDryrun ¶
func (_m *MockOptions) SetDryrun(d bool) Options
func (*MockOptions) SetInstrumentOptions ¶
func (_m *MockOptions) SetInstrumentOptions(iopts instrument.Options) Options
func (*MockOptions) SetIsMirrored ¶
func (_m *MockOptions) SetIsMirrored(m bool) Options
func (*MockOptions) SetIsShardCutoffFn ¶
func (_m *MockOptions) SetIsShardCutoffFn(fn ShardValidationFn) Options
func (*MockOptions) SetIsShardCutoverFn ¶
func (_m *MockOptions) SetIsShardCutoverFn(fn ShardValidationFn) Options
func (*MockOptions) SetIsSharded ¶
func (_m *MockOptions) SetIsSharded(sharded bool) Options
func (*MockOptions) SetIsStaged ¶
func (_m *MockOptions) SetIsStaged(v bool) Options
func (*MockOptions) SetPlacementCutoverNanosFn ¶
func (_m *MockOptions) SetPlacementCutoverNanosFn(fn TimeNanosFn) Options
func (*MockOptions) SetShardCutoffNanosFn ¶
func (_m *MockOptions) SetShardCutoffNanosFn(fn TimeNanosFn) Options
func (*MockOptions) SetShardCutoverNanosFn ¶
func (_m *MockOptions) SetShardCutoverNanosFn(fn TimeNanosFn) Options
func (*MockOptions) SetShardStateMode ¶
func (_m *MockOptions) SetShardStateMode(value ShardStateMode) Options
func (*MockOptions) SetValidZone ¶
func (_m *MockOptions) SetValidZone(z string) Options
func (*MockOptions) ShardCutoffNanosFn ¶
func (_m *MockOptions) ShardCutoffNanosFn() TimeNanosFn
func (*MockOptions) ShardCutoverNanosFn ¶
func (_m *MockOptions) ShardCutoverNanosFn() TimeNanosFn
func (*MockOptions) ShardStateMode ¶
func (_m *MockOptions) ShardStateMode() ShardStateMode
func (*MockOptions) ValidZone ¶
func (_m *MockOptions) ValidZone() string
type MockPlacement ¶
type MockPlacement struct {
// contains filtered or unexported fields
}
Mock of Placement interface
func NewMockPlacement ¶
func NewMockPlacement(ctrl *gomock.Controller) *MockPlacement
func (*MockPlacement) Clone ¶
func (_m *MockPlacement) Clone() Placement
func (*MockPlacement) CutoverNanos ¶
func (_m *MockPlacement) CutoverNanos() int64
func (*MockPlacement) EXPECT ¶
func (_m *MockPlacement) EXPECT() *_MockPlacementRecorder
func (*MockPlacement) GetVersion ¶
func (_m *MockPlacement) GetVersion() int
func (*MockPlacement) Instances ¶
func (_m *MockPlacement) Instances() []Instance
func (*MockPlacement) InstancesForShard ¶
func (_m *MockPlacement) InstancesForShard(shard uint32) []Instance
func (*MockPlacement) IsMirrored ¶
func (_m *MockPlacement) IsMirrored() bool
func (*MockPlacement) IsSharded ¶
func (_m *MockPlacement) IsSharded() bool
func (*MockPlacement) MaxShardSetID ¶
func (_m *MockPlacement) MaxShardSetID() uint32
func (*MockPlacement) NumInstances ¶
func (_m *MockPlacement) NumInstances() int
func (*MockPlacement) NumShards ¶
func (_m *MockPlacement) NumShards() int
func (*MockPlacement) Proto ¶
func (_m *MockPlacement) Proto() (*placementpb.Placement, error)
func (*MockPlacement) ReplicaFactor ¶
func (_m *MockPlacement) ReplicaFactor() int
func (*MockPlacement) SetCutoverNanos ¶
func (_m *MockPlacement) SetCutoverNanos(cutoverNanos int64) Placement
func (*MockPlacement) SetInstances ¶
func (_m *MockPlacement) SetInstances(instances []Instance) Placement
func (*MockPlacement) SetIsMirrored ¶
func (_m *MockPlacement) SetIsMirrored(v bool) Placement
func (*MockPlacement) SetIsSharded ¶
func (_m *MockPlacement) SetIsSharded(v bool) Placement
func (*MockPlacement) SetMaxShardSetID ¶
func (_m *MockPlacement) SetMaxShardSetID(value uint32) Placement
func (*MockPlacement) SetReplicaFactor ¶
func (_m *MockPlacement) SetReplicaFactor(rf int) Placement
func (*MockPlacement) SetShards ¶
func (_m *MockPlacement) SetShards(s []uint32) Placement
func (*MockPlacement) SetVersion ¶
func (_m *MockPlacement) SetVersion(v int) Placement
func (*MockPlacement) Shards ¶
func (_m *MockPlacement) Shards() []uint32
func (*MockPlacement) String ¶
func (_m *MockPlacement) String() string
type MockService ¶
type MockService struct {
// contains filtered or unexported fields
}
Mock of Service interface
func NewMockService ¶
func NewMockService(ctrl *gomock.Controller) *MockService
func (*MockService) AddInstances ¶
func (_m *MockService) AddInstances(candidates []Instance) (Placement, []Instance, error)
func (*MockService) AddReplica ¶
func (_m *MockService) AddReplica() (Placement, error)
func (*MockService) BuildInitialPlacement ¶
func (*MockService) CheckAndSet ¶
func (_m *MockService) CheckAndSet(p Placement, version int) error
func (*MockService) CheckAndSetProto ¶
func (_m *MockService) CheckAndSetProto(p proto.Message, version int) error
func (*MockService) Delete ¶
func (_m *MockService) Delete() error
func (*MockService) EXPECT ¶
func (_m *MockService) EXPECT() *_MockServiceRecorder
func (*MockService) MarkAllShardsAvailable ¶
func (_m *MockService) MarkAllShardsAvailable() (Placement, error)
func (*MockService) MarkInstanceAvailable ¶
func (_m *MockService) MarkInstanceAvailable(instanceID string) error
func (*MockService) MarkShardsAvailable ¶
func (_m *MockService) MarkShardsAvailable(instanceID string, shardIDs ...uint32) error
func (*MockService) PlacementForVersion ¶
func (_m *MockService) PlacementForVersion(version int) (Placement, error)
func (*MockService) RemoveInstances ¶
func (_m *MockService) RemoveInstances(leavingInstanceIDs []string) (Placement, error)
func (*MockService) ReplaceInstances ¶
func (*MockService) Set ¶
func (_m *MockService) Set(p Placement) error
func (*MockService) SetIfNotExist ¶
func (_m *MockService) SetIfNotExist(p Placement) error
func (*MockService) Watch ¶
func (_m *MockService) Watch() (Watch, error)
type MockStagedPlacement ¶
type MockStagedPlacement struct {
// contains filtered or unexported fields
}
Mock of StagedPlacement interface
func NewMockStagedPlacement ¶
func NewMockStagedPlacement(ctrl *gomock.Controller) *MockStagedPlacement
func (*MockStagedPlacement) ActiveStagedPlacement ¶
func (_m *MockStagedPlacement) ActiveStagedPlacement(timeNanos int64) ActiveStagedPlacement
func (*MockStagedPlacement) ActiveStagedPlacementOptions ¶
func (_m *MockStagedPlacement) ActiveStagedPlacementOptions() ActiveStagedPlacementOptions
func (*MockStagedPlacement) EXPECT ¶
func (_m *MockStagedPlacement) EXPECT() *_MockStagedPlacementRecorder
func (*MockStagedPlacement) Placements ¶
func (_m *MockStagedPlacement) Placements() Placements
func (*MockStagedPlacement) Proto ¶
func (_m *MockStagedPlacement) Proto() (*placementpb.PlacementSnapshots, error)
func (*MockStagedPlacement) SetActiveStagedPlacementOptions ¶
func (_m *MockStagedPlacement) SetActiveStagedPlacementOptions(opts ActiveStagedPlacementOptions) StagedPlacement
func (*MockStagedPlacement) SetPlacements ¶
func (_m *MockStagedPlacement) SetPlacements(placements []Placement) StagedPlacement
func (*MockStagedPlacement) SetVersion ¶
func (_m *MockStagedPlacement) SetVersion(version int) StagedPlacement
func (*MockStagedPlacement) Version ¶
func (_m *MockStagedPlacement) Version() int
type MockStagedPlacementWatcher ¶
type MockStagedPlacementWatcher struct {
// contains filtered or unexported fields
}
Mock of StagedPlacementWatcher interface
func NewMockStagedPlacementWatcher ¶
func NewMockStagedPlacementWatcher(ctrl *gomock.Controller) *MockStagedPlacementWatcher
func (*MockStagedPlacementWatcher) ActiveStagedPlacement ¶
func (_m *MockStagedPlacementWatcher) ActiveStagedPlacement() (ActiveStagedPlacement, DoneFn, error)
func (*MockStagedPlacementWatcher) EXPECT ¶
func (_m *MockStagedPlacementWatcher) EXPECT() *_MockStagedPlacementWatcherRecorder
func (*MockStagedPlacementWatcher) Unwatch ¶
func (_m *MockStagedPlacementWatcher) Unwatch() error
func (*MockStagedPlacementWatcher) Watch ¶
func (_m *MockStagedPlacementWatcher) Watch() error
type MockStagedPlacementWatcherOptions ¶
type MockStagedPlacementWatcherOptions struct {
// contains filtered or unexported fields
}
Mock of StagedPlacementWatcherOptions interface
func NewMockStagedPlacementWatcherOptions ¶
func NewMockStagedPlacementWatcherOptions(ctrl *gomock.Controller) *MockStagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) ActiveStagedPlacementOptions ¶
func (_m *MockStagedPlacementWatcherOptions) ActiveStagedPlacementOptions() ActiveStagedPlacementOptions
func (*MockStagedPlacementWatcherOptions) ClockOptions ¶
func (_m *MockStagedPlacementWatcherOptions) ClockOptions() clock.Options
func (*MockStagedPlacementWatcherOptions) EXPECT ¶
func (_m *MockStagedPlacementWatcherOptions) EXPECT() *_MockStagedPlacementWatcherOptionsRecorder
func (*MockStagedPlacementWatcherOptions) InitWatchTimeout ¶
func (_m *MockStagedPlacementWatcherOptions) InitWatchTimeout() time.Duration
func (*MockStagedPlacementWatcherOptions) InstrumentOptions ¶
func (_m *MockStagedPlacementWatcherOptions) InstrumentOptions() instrument.Options
func (*MockStagedPlacementWatcherOptions) SetActiveStagedPlacementOptions ¶
func (_m *MockStagedPlacementWatcherOptions) SetActiveStagedPlacementOptions(value ActiveStagedPlacementOptions) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) SetClockOptions ¶
func (_m *MockStagedPlacementWatcherOptions) SetClockOptions(value clock.Options) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) SetInitWatchTimeout ¶
func (_m *MockStagedPlacementWatcherOptions) SetInitWatchTimeout(value time.Duration) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) SetInstrumentOptions ¶
func (_m *MockStagedPlacementWatcherOptions) SetInstrumentOptions(value instrument.Options) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) SetStagedPlacementKey ¶
func (_m *MockStagedPlacementWatcherOptions) SetStagedPlacementKey(value string) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) SetStagedPlacementStore ¶
func (_m *MockStagedPlacementWatcherOptions) SetStagedPlacementStore(store kv.Store) StagedPlacementWatcherOptions
func (*MockStagedPlacementWatcherOptions) StagedPlacementKey ¶
func (_m *MockStagedPlacementWatcherOptions) StagedPlacementKey() string
func (*MockStagedPlacementWatcherOptions) StagedPlacementStore ¶
func (_m *MockStagedPlacementWatcherOptions) StagedPlacementStore() kv.Store
type MockStorage ¶
type MockStorage struct {
// contains filtered or unexported fields
}
Mock of Storage interface
func NewMockStorage ¶
func NewMockStorage(ctrl *gomock.Controller) *MockStorage
func (*MockStorage) CheckAndSet ¶
func (_m *MockStorage) CheckAndSet(p Placement, version int) error
func (*MockStorage) CheckAndSetProto ¶
func (_m *MockStorage) CheckAndSetProto(p proto.Message, version int) error
func (*MockStorage) Delete ¶
func (_m *MockStorage) Delete() error
func (*MockStorage) EXPECT ¶
func (_m *MockStorage) EXPECT() *_MockStorageRecorder
func (*MockStorage) PlacementForVersion ¶
func (_m *MockStorage) PlacementForVersion(version int) (Placement, error)
func (*MockStorage) Set ¶
func (_m *MockStorage) Set(p Placement) error
func (*MockStorage) SetIfNotExist ¶
func (_m *MockStorage) SetIfNotExist(p Placement) error
func (*MockStorage) Watch ¶
func (_m *MockStorage) Watch() (Watch, error)
type MockWatch ¶
type MockWatch struct {
// contains filtered or unexported fields
}
Mock of Watch interface
func NewMockWatch ¶
func NewMockWatch(ctrl *gomock.Controller) *MockWatch
type OnPlacementsAddedFn ¶
type OnPlacementsAddedFn func(placements []Placement)
OnPlacementsAddedFn is called when placements are added.
type OnPlacementsRemovedFn ¶
type OnPlacementsRemovedFn func(placements []Placement)
OnPlacementsRemovedFn is called when placements are removed.
type Options ¶
type Options interface { // AllowPartialReplace allows shards from the leaving instance to be // placed on instances other than the new instances in a replace operation AllowPartialReplace() bool // SetAllowPartialReplace sets AllowPartialReplace. SetAllowPartialReplace(allowPartialReplace bool) Options // AddAllCandidates determines whether the placement will attempt to add all // candidates when adding instances or just a single one. AddAllCandidates() bool // SetAddAllCandidates sets AddAllCandidates. SetAddAllCandidates(addAllCandidates bool) Options // IsSharded describes whether a placement needs to be sharded, // when set to false, no specific shards will be assigned to any instance. IsSharded() bool // SetIsSharded sets IsSharded. SetIsSharded(sharded bool) Options // ShardStateMode describes the mode to manage shard state in the placement. ShardStateMode() ShardStateMode // SetShardStateMode sets ShardStateMode. SetShardStateMode(value ShardStateMode) Options // Dryrun will try to perform the placement operation but will not persist the final result. Dryrun() bool // SetDryrun sets whether the Dryrun value. SetDryrun(d bool) Options // IsMirrored returns whether the shard distribution should be mirrored // to support master/slave model. IsMirrored() bool // SetIsMirrored sets IsMirrored. SetIsMirrored(m bool) Options // IsStaged returns whether the placement should keep all the snapshots. IsStaged() bool // SetIsStaged sets whether the placement should keep all the snapshots. SetIsStaged(v bool) Options // InstrumentOptions is the options for instrument. InstrumentOptions() instrument.Options // SetInstrumentOptions sets the instrument options. SetInstrumentOptions(iopts instrument.Options) Options // ValidZone returns the zone that added instances must be in in order // to be added to a placement. ValidZone() string // SetValidZone sets the zone that added instances must be in in order to // be added to a placement. By default the valid zone will be the zone of // instances already in a placement, however if a placement is empty then // it is necessary to specify the valid zone when adding the first // instance. SetValidZone(z string) Options // PlacementCutoverNanosFn returns the TimeNanosFn for placement cutover time. PlacementCutoverNanosFn() TimeNanosFn // SetPlacementCutoverNanosFn sets the TimeNanosFn for placement cutover time. SetPlacementCutoverNanosFn(fn TimeNanosFn) Options // ShardCutoverNanosFn returns the TimeNanosFn for shard cutover time. ShardCutoverNanosFn() TimeNanosFn // SetShardCutoverNanosFn sets the TimeNanosFn for shard cutover time. SetShardCutoverNanosFn(fn TimeNanosFn) Options // ShardCutoffNanosFn returns the TimeNanosFn for shard cutoff time. ShardCutoffNanosFn() TimeNanosFn // SetShardCutoffNanosFn sets the TimeNanosFn for shard cutoff time. SetShardCutoffNanosFn(fn TimeNanosFn) Options // IsShardCutoverFn returns the validation function for shard cutover. IsShardCutoverFn() ShardValidationFn // SetIsShardCutoverFn sets the validation function for shard cutover. SetIsShardCutoverFn(fn ShardValidationFn) Options // IsShardCutoffFn returns the validation function for shard cutoff. IsShardCutoffFn() ShardValidationFn // SetIsShardCutoffFn sets the validation function for shard cutoff. SetIsShardCutoffFn(fn ShardValidationFn) Options // NowFn returns the function to get time now. NowFn() clock.NowFn // SetNowFn sets the function to get time now. SetNowFn(fn clock.NowFn) Options }
Options is the interface for placement options.
type Placement ¶
type Placement interface { // InstancesForShard returns the instances for a given shard id. InstancesForShard(shard uint32) []Instance // Instances returns all instances in the placement Instances() []Instance // SetInstances sets the instances SetInstances(instances []Instance) Placement // NumInstances returns the number of instances in the placement NumInstances() int // Instance returns the instance for the requested id Instance(id string) (Instance, bool) // ReplicaFactor returns the replica factor in the placement ReplicaFactor() int // SetReplicaFactor sets the ReplicaFactor SetReplicaFactor(rf int) Placement // Shards returns all the unique shard ids for a replica Shards() []uint32 // SetShards sets the unique shard ids for a replica SetShards(s []uint32) Placement // ShardsLen returns the number of shards in a replica NumShards() int // IsSharded() returns whether this placement is sharded IsSharded() bool // SetIsSharded() sets IsSharded SetIsSharded(v bool) Placement // CutoverNanos returns the cutover time in nanoseconds. CutoverNanos() int64 // SetCutoverNanos sets the cutover time in nanoseconds. SetCutoverNanos(cutoverNanos int64) Placement // IsMirrored() returns whether the placement is mirrored. IsMirrored() bool // SetIsMirrored() sets IsMirrored. SetIsMirrored(v bool) Placement // MaxShardSetID returns the maximum shard set id used before to guarantee unique // shard set id generations across placement changes. MaxShardSetID() uint32 // SetMaxShardSetID sets the maximum shard set id used before to guarantee unique // shard set id generations across placement changes. SetMaxShardSetID(value uint32) Placement // String returns a description of the placement String() string // GetVersion() returns the version of the placement retreived from the // backing MVCC store. GetVersion() int // SetVersion() sets the version of the placement object. Since version // is determined by the backing MVCC store, calling this method has no // effect in terms of the updated ServicePlacement that is written back // to the MVCC store. SetVersion(v int) Placement // Proto returns the proto representation for the Placement. Proto() (*placementpb.Placement, error) // Clone returns a clone of the Placement. Clone() Placement }
Placement describes how instances are placed.
func NewPlacementFromProto ¶
func NewPlacementFromProto(p *placementpb.Placement) (Placement, error)
NewPlacementFromProto creates a new placement from proto.
type Placements ¶
type Placements []Placement
Placements represents a list of placements.
func NewPlacementsFromProto ¶
func NewPlacementsFromProto(p *placementpb.PlacementSnapshots) (Placements, error)
NewPlacementsFromProto creates a list of placements from proto.
func (Placements) ActiveIndex ¶
func (placements Placements) ActiveIndex(timeNanos int64) int
ActiveIndex finds the index of the last placement whose cutover time is no later than timeNanos (a.k.a. the active placement). Assuming the cutover times of the placements are sorted in ascending order (i.e., earliest time first).
func (Placements) Proto ¶
func (placements Placements) Proto() (*placementpb.PlacementSnapshots, error)
Proto converts a list of Placement to a proto.
type Service ¶
type Service interface { Storage // BuildInitialPlacement initialize a placement. BuildInitialPlacement(instances []Instance, numShards int, rf int) (Placement, error) // AddReplica up the replica factor by 1 in the placement. AddReplica() (Placement, error) // AddInstances adds instances from the candidate list to the placement. AddInstances(candidates []Instance) (newPlacement Placement, addedInstances []Instance, err error) // RemoveInstances removes instances from the placement. RemoveInstances(leavingInstanceIDs []string) (Placement, error) // ReplaceInstances picks instances from the candidate list to replace instances in current placement. ReplaceInstances( leavingInstanceIDs []string, candidates []Instance, ) ( newPlacement Placement, usedInstances []Instance, err error, ) // MarkShardsAvailable marks given shards as available. MarkShardsAvailable(instanceID string, shardIDs ...uint32) error // MarkAllShardsAvailable marks shard states as available where applicable. MarkAllShardsAvailable() (Placement, error) // MarkInstanceAvailable marks all the shards on a given instance as available. MarkInstanceAvailable(instanceID string) error }
Service handles the placement related operations for registered services all write or update operations will persist the generated placement before returning success.
type ShardStateMode ¶
type ShardStateMode int
ShardStateMode describes the way to manage shard state in the placement.
const ( // StableShardStateOnly means the placement should only keep stable shard state. StableShardStateOnly ShardStateMode = iota // IncludeTransitionalShardStates means the placement will include transitional shard states. IncludeTransitionalShardStates )
type ShardValidationFn ¶
ShardValidationFn validates the shard.
type StagedPlacement ¶
type StagedPlacement interface { // ActiveStagedPlacement returns the active staged placement for a given time. ActiveStagedPlacement(timeNanos int64) ActiveStagedPlacement // Version returns the version of the staged placement. Version() int // SetVersion sets the version of the staged placement. SetVersion(version int) StagedPlacement // Placements return the placements in the staged placement. Placements() Placements // SetPlacements sets the placements in the staged placement. SetPlacements(placements []Placement) StagedPlacement // ActiveStagedPlacementOptions returns the active staged placement options. ActiveStagedPlacementOptions() ActiveStagedPlacementOptions // SetActiveStagedPlacementOptions sets the active staged placement options. SetActiveStagedPlacementOptions(opts ActiveStagedPlacementOptions) StagedPlacement // Proto returns the proto representation for the StagedPlacement. Proto() (*placementpb.PlacementSnapshots, error) }
StagedPlacement describes a series of placements applied in staged fashion.
func NewStagedPlacement ¶
func NewStagedPlacement() StagedPlacement
NewStagedPlacement creates an empty staged placement.
func NewStagedPlacementFromProto ¶
func NewStagedPlacementFromProto( version int, p *placementpb.PlacementSnapshots, opts ActiveStagedPlacementOptions, ) (StagedPlacement, error)
NewStagedPlacementFromProto creates a new staged placement from proto.
type StagedPlacementWatcher ¶
type StagedPlacementWatcher interface { // Watch starts watching the updates. Watch() error // ActiveStagedPlacement returns the currently active staged placement, the // callback function when the caller is done using the active staged placement, // and any errors encountered. ActiveStagedPlacement() (ActiveStagedPlacement, DoneFn, error) // Unwatch stops watching the updates. Unwatch() error }
StagedPlacementWatcher watches for updates to staged placement.
func NewStagedPlacementWatcher ¶
func NewStagedPlacementWatcher(opts StagedPlacementWatcherOptions) StagedPlacementWatcher
NewStagedPlacementWatcher creates a new staged placement watcher.
type StagedPlacementWatcherOptions ¶
type StagedPlacementWatcherOptions interface { // SetClockOptions sets the clock options. SetClockOptions(value clock.Options) StagedPlacementWatcherOptions // ClockOptions returns the clock options. ClockOptions() clock.Options // SetInstrumentOptions sets the instrument options. SetInstrumentOptions(value instrument.Options) StagedPlacementWatcherOptions // InstrumentOptions returns the instrument options. InstrumentOptions() instrument.Options // SetActiveStagedPlacementOptions sets the active staged placement options. SetActiveStagedPlacementOptions(value ActiveStagedPlacementOptions) StagedPlacementWatcherOptions // ActiveStagedPlacementOptions returns the active staged placement options. ActiveStagedPlacementOptions() ActiveStagedPlacementOptions // SetStagedPlacementKey sets the kv key to watch for staged placement. SetStagedPlacementKey(value string) StagedPlacementWatcherOptions // StagedPlacementKey returns the kv key to watch for staged placement. StagedPlacementKey() string // SetStagedPlacementStore sets the staged placement store. SetStagedPlacementStore(store kv.Store) StagedPlacementWatcherOptions // StagedPlacementStore returns the staged placement store. StagedPlacementStore() kv.Store // SetInitWatchTimeout sets the initial watch timeout. SetInitWatchTimeout(value time.Duration) StagedPlacementWatcherOptions // InitWatchTimeout returns the initial watch timeout. InitWatchTimeout() time.Duration }
StagedPlacementWatcherOptions provide a set of staged placement watcher options.
func NewStagedPlacementWatcherOptions ¶
func NewStagedPlacementWatcherOptions() StagedPlacementWatcherOptions
NewStagedPlacementWatcherOptions create a new set of topology options.
type Storage ¶
type Storage interface { // Set writes a placement. Set(p Placement) error // CheckAndSet writes a placement if the current version // matches the expected version. CheckAndSet(p Placement, version int) error // SetIfNotExist writes a placement. SetIfNotExist(p Placement) error // Placement reads placement and version. Placement() (Placement, int, error) // Watch returns a watch for the placement updates. Watch() (Watch, error) // Delete deletes the placement. Delete() error // SetProto sets the proto as the placement. SetProto(p proto.Message) error // CheckAndSetProto writes a proto if the current version // matches the expected version. CheckAndSetProto(p proto.Message, version int) error // Proto returns the placement proto. Proto() (proto.Message, int, error) // PlacementForVersion returns the placement of a specific version. PlacementForVersion(version int) (Placement, error) }
Storage provides read and write access to placement.
type TimeNanosFn ¶
type TimeNanosFn func() int64
TimeNanosFn returns the time in the format of Unix nanoseconds.
type Watch ¶
type Watch interface { // C returns the notification channel. C() <-chan struct{} // Get returns the latest version of the placement. Get() (Placement, error) // Close stops watching for placement updates. Close() }
Watch watches for updates of a placement.
type WatcherConfiguration ¶
type WatcherConfiguration struct { // Placement key. Key string `yaml:"key" validate:"nonzero"` // Initial watch timeout. InitWatchTimeout time.Duration `yaml:"initWatchTimeout"` }
WatcherConfiguration contains placement watcher configuration.
func (*WatcherConfiguration) NewOptions ¶
func (c *WatcherConfiguration) NewOptions( store kv.Store, instrumentOpts instrument.Options, ) StagedPlacementWatcherOptions
NewOptions creates a placement watcher option.