Documentation
¶
Index ¶
- type CurrentState
- type DynamicBound
- type ExternalView
- func (e *ExternalView) IdealStateMode() string
- func (e *ExternalView) InstanceState(instance, partitionName string) string
- func (e *ExternalView) InstanceWithState(partitionName, state string) string
- func (e *ExternalView) NumPartitions() int
- func (e *ExternalView) Replicas() int
- func (e *ExternalView) Resource() string
- type IdealState
- func (is *IdealState) EnableGroupRouting(yes bool)
- func (is IdealState) ExternalViewDisabled() bool
- func (is *IdealState) IdealStateMode() string
- func (is IdealState) InstanceGroupTag() string
- func (is *IdealState) InstanceState(instance, partitionName string) string
- func (is *IdealState) MaxPartitionsPerInstance() int
- func (is IdealState) NumPartitions() int
- func (is IdealState) PreferenceList(partitionName string) []string
- func (is *IdealState) RebalanceMode() string
- func (is IdealState) RebalanceStrategy() string
- func (is *IdealState) RebalancerClassName() string
- func (is IdealState) Replicas() string
- func (is *IdealState) Resource() string
- func (is IdealState) ResourceGroupName() string
- func (is *IdealState) SetIdealStateMode(mode string)
- func (is *IdealState) SetInstanceGroupTag(tag string)
- func (is *IdealState) SetMaxPartitionsPerInstance(max int)
- func (is IdealState) SetNumPartitions(n int)
- func (is *IdealState) SetRebalanceMode(mode string)
- func (is *IdealState) SetRebalancerClassName(clazz string)
- func (is *IdealState) SetReplicas(replicas string)
- func (is IdealState) StateModelDefRef() string
- func (is IdealState) Valid() bool
- type InstanceConfig
- func (ic *InstanceConfig) AddTag(tag string)
- func (ic *InstanceConfig) ContainsTag(tag string) bool
- func (ic InstanceConfig) DisabledPartitions() []string
- func (ic *InstanceConfig) Enable(enabled bool)
- func (ic InstanceConfig) EnablePartition(partition string, yes bool)
- func (ic InstanceConfig) Host() string
- func (ic InstanceConfig) InstanceName() string
- func (ic *InstanceConfig) IsEnabled() bool
- func (ic InstanceConfig) Node() string
- func (ic InstanceConfig) Port() string
- func (ic *InstanceConfig) RemoveTag(tag string)
- func (ic InstanceConfig) SetHost(host string)
- func (ic InstanceConfig) SetPort(port string)
- func (ic InstanceConfig) String() string
- func (ic InstanceConfig) Tags() []string
- func (ic InstanceConfig) Validate() error
- type LiveInstance
- type Message
- func (m Message) ClusterEventName() string
- func (m Message) CreateReplyMessage(src *Message)
- func (m Message) CreateTimeStamp() int64
- func (m Message) ExecutionTimeout() int
- func (m Message) FromState() string
- func (m Message) ID() string
- func (m Message) IsControllerMsg() bool
- func (m Message) MessageState() string
- func (m Message) MessageSubType() string
- func (m Message) MessageType() string
- func (m Message) PartitionName() string
- func (m Message) PartitionNames() []string
- func (m Message) Resource() string
- func (m Message) ResourceGroupName() string
- func (m Message) ResourceTag() string
- func (m Message) RetryCount() int
- func (m *Message) SetExecuteSessionID(sessID string)
- func (m *Message) SetExecuteStartTimeStamp(val int64)
- func (m *Message) SetMessageState(state string)
- func (m *Message) SetReadTimestamp(val int64)
- func (m Message) SetToState(state string)
- func (m Message) SrcInstanceType() string
- func (m Message) SrcName() string
- func (m Message) SrcSessionID() string
- func (m Message) StateModelDef() string
- func (m Message) StateModelFactory() string
- func (m Message) TargetName() string
- func (m Message) TargetSessionID() string
- func (m Message) ToState() string
- func (m Message) Valid() bool
- type Messages
- type Record
- func (r *Record) AddListField(key string, value string)
- func (r Record) BatchMessageMode() bool
- func (r Record) BucketSize() int
- func (r1 Record) Equals(r2 *Record) bool
- func (r Record) GetBooleanField(key string, defaultValue bool) bool
- func (r Record) GetIntField(key string, defaultValue int) int
- func (r *Record) GetListField(key string) []string
- func (r Record) GetMapField(key string, property string) string
- func (r Record) GetSimpleField(key string) interface{}
- func (r Record) GetStringField(key string, defaultValue string) string
- func (r Record) Marshal() []byte
- func (r *Record) RemoveListField(key string, value string)
- func (r *Record) RemoveMapField(key string)
- func (r *Record) SetBatchMessageMode(yes bool)
- func (r *Record) SetBooleanField(key string, value bool)
- func (r *Record) SetBucketSize(size int)
- func (r *Record) SetIntField(key string, value int)
- func (r *Record) SetMapField(key string, property string, value string)
- func (r *Record) SetSimpleField(key string, value interface{})
- func (r Record) SetStringField(key string, value string)
- func (r Record) String() string
- type Resource
- func (r *Resource) AddPartition(partitionName string) *Resource
- func (r Resource) BatchMessageMode() bool
- func (r Resource) BucketSize() int
- func (r Resource) Name() string
- func (r Resource) Partitions() []string
- func (r *Resource) SetBatchMessageMode(yes bool)
- func (r *Resource) SetBucketSize(size int)
- func (r *Resource) SetStateModelDef(def string)
- func (r *Resource) SetStateModelFactory(f string)
- func (r Resource) String() string
- type ResourceAssignment
- type StateModelDef
- func (smd *StateModelDef) AddState(state string, priority int) *StateModelDef
- func (smd *StateModelDef) AddTransition(fromState, toState string) *StateModelDef
- func (smd *StateModelDef) InitialState() string
- func (smd *StateModelDef) SetDynamicUpperBound(state string, bound DynamicBound) *StateModelDef
- func (smd *StateModelDef) SetInitialState(state string) *StateModelDef
- func (smd *StateModelDef) SetStaticUpperBound(state string, bound int) *StateModelDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurrentState ¶
type CurrentState struct {
*Record
}
func NewCurrentStateFromRecord ¶
func NewCurrentStateFromRecord(r *Record) *CurrentState
func (*CurrentState) SetCurrentState ¶
func (c *CurrentState) SetCurrentState(partitionName, state string)
type DynamicBound ¶
type DynamicBound string
const ( // The number of replicas in the state is at most the specified replica count for the partition. DynamicBoundR DynamicBound = "R" // The number of replicas in the state is at most the number of live participants in the cluster. DynamicBoundN DynamicBound = "N" )
type ExternalView ¶
type ExternalView struct {
*Record
}
func NewExternalViewFromRecord ¶
func NewExternalViewFromRecord(r *Record) *ExternalView
func (*ExternalView) IdealStateMode ¶
func (e *ExternalView) IdealStateMode() string
func (*ExternalView) InstanceState ¶
func (e *ExternalView) InstanceState(instance, partitionName string) string
func (*ExternalView) InstanceWithState ¶
func (e *ExternalView) InstanceWithState(partitionName, state string) string
func (*ExternalView) NumPartitions ¶
func (e *ExternalView) NumPartitions() int
func (*ExternalView) Replicas ¶
func (e *ExternalView) Replicas() int
func (*ExternalView) Resource ¶
func (e *ExternalView) Resource() string
type IdealState ¶
type IdealState struct {
*Record
}
ideal state content example:
{ "id" : "MyResource", "simpleFields" : { "IDEAL_STATE_MODE" : "AUTO", "NUM_PARTITIONS" : "6", "REBALANCE_MODE" : "SEMI_AUTO", "REBALANCE_STRATEGY" : "DEFAULT", "REBALANCER_CLASS_NAME": "", "REPLICAS" : "3", "STATE_MODEL_DEF_REF" : "MyStateModel", "STATE_MODEL_FACTORY_NAME" : "DEFAULT" }, "mapFields" : { "MyResource_0" : { "localhost_12000" : "SLAVE", "localhost_12001" : "MASTER", "localhost_12002" : "SLAVE" }, "MyResource_1" : { "localhost_12000" : "SLAVE", "localhost_12001" : "SLAVE", "localhost_12002" : "MASTER" }, "MyResource_2" : { "localhost_12000" : "MASTER", "localhost_12001" : "SLAVE", "localhost_12002" : "SLAVE" }, "MyResource_3" : { "localhost_12000" : "SLAVE", "localhost_12001" : "SLAVE", "localhost_12002" : "MASTER" }, "MyResource_4" : { "localhost_12000" : "MASTER", "localhost_12001" : "SLAVE", "localhost_12002" : "SLAVE" }, "MyResource_5" : { "localhost_12000" : "SLAVE", "localhost_12001" : "MASTER", "localhost_12002" : "SLAVE" } }, "listFields" : { "MyResource_0" : [ "localhost_12001", "localhost_12000", "localhost_12002" ], "MyResource_1" : [ "localhost_12002", "localhost_12000", "localhost_12001" ], "MyResource_2" : [ "localhost_12000", "localhost_12002", "localhost_12001" ], "MyResource_3" : [ "localhost_12002", "localhost_12001", "localhost_12000" ], "MyResource_4" : [ "localhost_12000", "localhost_12001", "localhost_12002" ], "MyResource_5" : [ "localhost_12001", "localhost_12000", "localhost_12002" ] } }
func NewIdealStateFromRecord ¶
func NewIdealStateFromRecord(record *Record) *IdealState
func (*IdealState) EnableGroupRouting ¶
func (is *IdealState) EnableGroupRouting(yes bool)
func (IdealState) ExternalViewDisabled ¶
func (is IdealState) ExternalViewDisabled() bool
func (*IdealState) IdealStateMode ¶
func (is *IdealState) IdealStateMode() string
func (IdealState) InstanceGroupTag ¶
func (is IdealState) InstanceGroupTag() string
func (*IdealState) InstanceState ¶
func (is *IdealState) InstanceState(instance, partitionName string) string
func (*IdealState) MaxPartitionsPerInstance ¶
func (is *IdealState) MaxPartitionsPerInstance() int
func (IdealState) NumPartitions ¶
func (is IdealState) NumPartitions() int
func (IdealState) PreferenceList ¶
func (is IdealState) PreferenceList(partitionName string) []string
func (*IdealState) RebalanceMode ¶
func (is *IdealState) RebalanceMode() string
func (IdealState) RebalanceStrategy ¶
func (is IdealState) RebalanceStrategy() string
func (*IdealState) RebalancerClassName ¶
func (is *IdealState) RebalancerClassName() string
func (IdealState) Replicas ¶
func (is IdealState) Replicas() string
func (*IdealState) Resource ¶
func (is *IdealState) Resource() string
func (IdealState) ResourceGroupName ¶
func (is IdealState) ResourceGroupName() string
func (*IdealState) SetIdealStateMode ¶
func (is *IdealState) SetIdealStateMode(mode string)
func (*IdealState) SetInstanceGroupTag ¶
func (is *IdealState) SetInstanceGroupTag(tag string)
func (*IdealState) SetMaxPartitionsPerInstance ¶
func (is *IdealState) SetMaxPartitionsPerInstance(max int)
func (IdealState) SetNumPartitions ¶
func (is IdealState) SetNumPartitions(n int)
func (*IdealState) SetRebalanceMode ¶
func (is *IdealState) SetRebalanceMode(mode string)
func (*IdealState) SetRebalancerClassName ¶
func (is *IdealState) SetRebalancerClassName(clazz string)
func (*IdealState) SetReplicas ¶
func (is *IdealState) SetReplicas(replicas string)
func (IdealState) StateModelDefRef ¶
func (is IdealState) StateModelDefRef() string
StateModelDefRef returns the state model associated with this resource.
func (IdealState) Valid ¶
func (is IdealState) Valid() bool
type InstanceConfig ¶
type InstanceConfig struct {
*Record
}
func NewInstanceConfigFromRecord ¶
func NewInstanceConfigFromRecord(record *Record) *InstanceConfig
func (*InstanceConfig) AddTag ¶
func (ic *InstanceConfig) AddTag(tag string)
func (*InstanceConfig) ContainsTag ¶
func (ic *InstanceConfig) ContainsTag(tag string) bool
func (InstanceConfig) DisabledPartitions ¶
func (ic InstanceConfig) DisabledPartitions() []string
func (*InstanceConfig) Enable ¶
func (ic *InstanceConfig) Enable(enabled bool)
func (InstanceConfig) EnablePartition ¶
func (ic InstanceConfig) EnablePartition(partition string, yes bool)
TODO
func (InstanceConfig) Host ¶
func (ic InstanceConfig) Host() string
func (InstanceConfig) InstanceName ¶
func (ic InstanceConfig) InstanceName() string
func (*InstanceConfig) IsEnabled ¶
func (ic *InstanceConfig) IsEnabled() bool
func (InstanceConfig) Node ¶
func (ic InstanceConfig) Node() string
func (InstanceConfig) Port ¶
func (ic InstanceConfig) Port() string
func (*InstanceConfig) RemoveTag ¶
func (ic *InstanceConfig) RemoveTag(tag string)
func (InstanceConfig) SetHost ¶
func (ic InstanceConfig) SetHost(host string)
func (InstanceConfig) SetPort ¶
func (ic InstanceConfig) SetPort(port string)
func (InstanceConfig) String ¶
func (ic InstanceConfig) String() string
func (InstanceConfig) Tags ¶
func (ic InstanceConfig) Tags() []string
type LiveInstance ¶
type LiveInstance struct {
*Record
}
func NewLiveInstanceFromRecord ¶
func NewLiveInstanceFromRecord(record *Record) *LiveInstance
func (*LiveInstance) Node ¶
func (li *LiveInstance) Node() string
func (*LiveInstance) SessionID ¶
func (li *LiveInstance) SessionID() string
func (*LiveInstance) SetSessionID ¶
func (li *LiveInstance) SetSessionID(sessionID string)
type Message ¶
type Message struct {
*Record
}
Message is controller generated payload to instruct participant to carry out some tasks.
message content example:
{ "id": "9ff57fc1-9f2a-41a5-af46-c4ae2a54c539", "simpleFields": { "CREATE_TIMESTAMP": "1425268051457", "ClusterEventName": "currentStateChange", "FROM_STATE": "OFFLINE", "MSG_ID": "9ff57fc1-9f2a-41a5-af46-c4ae2a54c539", "MSG_STATE": "new", "MSG_TYPE": "STATE_TRANSITION", "PARTITION_NAME": "myDB_5", "RESOURCE_NAME": "myDB", "SRC_NAME": "precise64-CONTROLLER", "SRC_SESSION_ID": "14bd852c528004c", "STATE_MODEL_DEF": "MasterSlave", "STATE_MODEL_FACTORY_NAME": "DEFAULT", "TGT_NAME": "localhost_12913", "TGT_SESSION_ID": "93406067297878252", "TO_STATE": "SLAVE" }, "listFields": {}, "mapFields": {} }
func NewMessageFromRecord ¶
func (Message) ClusterEventName ¶
func (Message) CreateReplyMessage ¶
TODO CreateReplyMessage creates a reply based on an incoming message.
func (Message) CreateTimeStamp ¶
CreateTimeStamp returns the time that this message was created.
func (Message) ExecutionTimeout ¶
ExecutionTimeout returns the time to wait before stopping execution of this message.
func (Message) IsControllerMsg ¶
IsControllerMsg checks if this message is targetted for a controller.
func (Message) MessageState ¶
func (Message) MessageSubType ¶
func (Message) MessageType ¶
func (Message) PartitionName ¶
PartitionName returns the name of the partition this message concerns.
func (Message) PartitionNames ¶
PartitionNames returns a list of partitions associated with this message.
func (Message) ResourceGroupName ¶
ResourceGroupName returns the resource group associated with this message.
func (Message) ResourceTag ¶
ResourceTag returns the resource tag associated with this message.
func (Message) RetryCount ¶
func (*Message) SetExecuteSessionID ¶
SetExecuteSessionID sets the session identifier of the node that executes the message.
func (*Message) SetExecuteStartTimeStamp ¶
SetExecuteStartTimeStamp sets the time that the instance executes tasks as instructed by this message.
func (*Message) SetMessageState ¶
func (*Message) SetReadTimestamp ¶
SetReadTimestamp sets the time that this message was read.
func (Message) SetToState ¶
func (Message) SrcInstanceType ¶
func (Message) SrcSessionID ¶
SrcSessionID returns the session identifier of the source node.
func (Message) StateModelDef ¶
StateModelDef returns the state model definition name.
func (Message) StateModelFactory ¶
func (Message) TargetName ¶
TargetName returns the target instance name.
func (Message) TargetSessionID ¶
TargetSessionID returns the session identifier of the destination node.
type Record ¶
type Record struct { ID string `json:"id"` // plain key, value fields SimpleFields map[string]interface{} `json:"simpleFields"` // all fields whose values are a list of values ListFields map[string][]string `json:"listFields"` // all fields whose values are key, value MapFields map[string]map[string]string `json:"mapFields"` }
Generic Record Format to store data at a storage Node. simpleFields mapFields listFields.
func NewLiveInstanceRecord ¶
NewLiveInstanceRecord creates a new instance of Record for representing a live instance.
func NewRecordFromBytes ¶
NewRecordFromBytes creates a Record from a byte slice. If data is empty, returns an empty Record with nil error.
func (*Record) AddListField ¶
func (Record) BatchMessageMode ¶
func (Record) BucketSize ¶
func (Record) GetBooleanField ¶
GetBooleanField gets the value of a key under SimpleField and convert the result to bool type. That is, if the value is "true", the result is true.
func (Record) GetIntField ¶
GetIntField returns the integer value of a field in the SimpleField
func (*Record) GetListField ¶
func (Record) GetMapField ¶
GetMapField returns the string value of the property of a key under MapField.
func (Record) GetSimpleField ¶
GetSimpleField returns a value of a key in SimpleField structure
func (Record) GetStringField ¶
GetStringField returns the string value of a field in the SimpleField
func (*Record) RemoveListField ¶
func (*Record) RemoveMapField ¶
RemoveMapField deletes a key from MapField
func (*Record) SetBatchMessageMode ¶
func (*Record) SetBooleanField ¶
SetBooleanField sets a key under SimpleField with a specified bool value, serialized to string. For example, true will be stored as "TRUE"
func (*Record) SetBucketSize ¶
func (*Record) SetIntField ¶
SetIntField sets the integer value of a key under SimpleField. the value is stored as in string form
func (*Record) SetMapField ¶
SetMapField sets the value of a key under MapField. Both key and value are string format.
func (*Record) SetSimpleField ¶
SetSimpleField sets the value of a key under SimpleField
func (Record) SetStringField ¶
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
A resource contains a set of partitions and its replicas are managed by a state model.
func NewResource ¶
func (*Resource) AddPartition ¶
func (Resource) BatchMessageMode ¶
func (Resource) BucketSize ¶
func (Resource) Partitions ¶
func (*Resource) SetBatchMessageMode ¶
func (*Resource) SetBucketSize ¶
func (*Resource) SetStateModelDef ¶
func (*Resource) SetStateModelFactory ¶
type ResourceAssignment ¶
type ResourceAssignment struct {
*Record
}
ResourceAssignment represents the assignments of replicas for an entire resource, keyed on partitions of the resource.
func (*ResourceAssignment) MappedPartitions ¶
func (ra *ResourceAssignment) MappedPartitions() []string
MappedPartitions returns the currently mapped partition names.
func (*ResourceAssignment) ReplicaMap ¶
func (ra *ResourceAssignment) ReplicaMap(partition string) map[string]string
ReplicaMap returns the instance, state pairs for a partition. e,g. {"localhost_10001": "MASTER"}
func (*ResourceAssignment) Resource ¶
func (ra *ResourceAssignment) Resource() string
type StateModelDef ¶
type StateModelDef struct {
*Record
}
func NewStateModelDef ¶
func NewStateModelDef(stateModel string) *StateModelDef
func NewStateModelDefFromRecord ¶
func NewStateModelDefFromRecord(r *Record) *StateModelDef
func (*StateModelDef) AddState ¶
func (smd *StateModelDef) AddState(state string, priority int) *StateModelDef
TODO
func (*StateModelDef) AddTransition ¶
func (smd *StateModelDef) AddTransition(fromState, toState string) *StateModelDef
TODO
func (*StateModelDef) InitialState ¶
func (smd *StateModelDef) InitialState() string
func (*StateModelDef) SetDynamicUpperBound ¶
func (smd *StateModelDef) SetDynamicUpperBound(state string, bound DynamicBound) *StateModelDef
TODO
func (*StateModelDef) SetInitialState ¶
func (smd *StateModelDef) SetInitialState(state string) *StateModelDef
func (*StateModelDef) SetStaticUpperBound ¶
func (smd *StateModelDef) SetStaticUpperBound(state string, bound int) *StateModelDef
TODO