Documentation
¶
Index ¶
- Constants
- type Cluster
- func (c *Cluster) Close() error
- func (c *Cluster) FetchPluginAvailableNodesByHashedId(hashedPluginId string) ([]string, error)
- func (c *Cluster) FetchPluginAvailableNodesById(plugin_id string) ([]string, error)
- func (c *Cluster) GetNodes() (map[string]node, error)
- func (c *Cluster) ID() string
- func (c *Cluster) IsMaster() bool
- func (c *Cluster) IsNodeAlive(nodeId string) bool
- func (c *Cluster) IsPluginOnCurrentNode(identity plugin_entities.PluginUniqueIdentifier) (bool, error)
- func (c *Cluster) Launch()
- func (c *Cluster) LockNodeStatus(nodeId string) error
- func (c *Cluster) NotifyBecomeMaster() <-chan bool
- func (c *Cluster) NotifyClusterStopped() <-chan bool
- func (c *Cluster) NotifyMasterGC() <-chan bool
- func (c *Cluster) NotifyMasterGCCompleted() <-chan bool
- func (c *Cluster) NotifyNodeUpdate() <-chan bool
- func (c *Cluster) NotifyNodeUpdateCompleted() <-chan bool
- func (c *Cluster) NotifyPluginSchedule() <-chan bool
- func (c *Cluster) NotifyPluginScheduleCompleted() <-chan bool
- func (c *Cluster) NotifyVoting() <-chan bool
- func (c *Cluster) NotifyVotingCompleted() <-chan bool
- func (c *Cluster) RedirectRequest(node_id string, request *http.Request) (int, http.Header, io.ReadCloser, error)
- func (c *Cluster) RegisterPlugin(lifetime plugin_entities.PluginLifetime) error
- func (c *Cluster) SortIps(nodeStatus node) []address
- func (c *Cluster) UnlockNodeStatus(nodeId string) error
Constants ¶
View Source
const ( // master // the cluster master is responsible for managing garbage collection for both nodes and plugins. // typically, each node handles the garbage collection for its own plugins // However, if a node becomes inactive, the master takes over this task. // every node has an equal chance of becoming the master. // once a node is selected as the master, it is locked in that role. // If the master node becomes inactive, the master slot is released, allowing other nodes to attempt to take over the role. MASTER_LOCKING_INTERVAL = time.Millisecond * 500 // interval to try to lock the slot to be the master MASTER_LOCK_EXPIRED_TIME = time.Second * 2 // expired time of master key MASTER_GC_INTERVAL = time.Second * 10 // interval to do garbage collection of nodes has already deactivated // node // To determine the available IPs of the nodes, each node will vote for the IPs of other nodes. // this voting process will occur every $NODE_VOTE_INTERVAL. // simultaneously, all nodes will synchronize to the latest status in memory every $UPDATE_NODE_STATUS_INTERVAL. // each node will also update its own status to remain active. If a node becomes inactive, it will be removed from the cluster. NODE_VOTE_INTERVAL = time.Second * 30 // interval to vote the ips of the nodes UPDATE_NODE_STATUS_INTERVAL = time.Second * 5 // interval to update the status of the node NODE_DISCONNECTED_TIMEOUT = time.Second * 10 // once a node is no longer active, it will be removed from the cluster // plugin scheduler // each node will schedule its plugins every $PLUGIN_SCHEDULER_INTERVAL time // and schedule process will be triggered every $PLUGIN_SCHEDULER_TICKER_INTERVAL time // not all the plugins will be scheduled every time, only the plugins that are not scheduled in $PLUGIN_SCHEDULER_INTERVAL time will be scheduled // and the plugins that are not active will be removed from the cluster PLUGIN_SCHEDULER_TICKER_INTERVAL = time.Second * 3 // interval to schedule the plugins PLUGIN_SCHEDULER_INTERVAL = time.Second * 10 // interval to schedule the plugins PLUGIN_DEACTIVATED_TIMEOUT = time.Second * 30 // once a plugin is no longer active, it will be removed from the cluster )
View Source
const ( CLUSTER_STATUS_HASH_MAP_KEY = "cluster-nodes-status-hash-map" PREEMPTION_LOCK_KEY = "cluster-master-preemption-lock" )
View Source
const (
CLUSTER_NEW_NODE_CHANNEL = "cluster-new-node-channel"
)
View Source
const (
CLUSTER_UPDATE_NODE_STATUS_LOCK_PREFIX = "cluster-update-node-status-lock"
)
View Source
const (
PLUGIN_STATE_MAP_KEY = "plugin_state"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func NewCluster(config *app.Config, plugin_manager *plugin_manager.PluginManager) *Cluster
func (*Cluster) FetchPluginAvailableNodesByHashedId ¶
FetchPluginAvailableNodesByHashedId fetches the available nodes of the given plugin
func (*Cluster) FetchPluginAvailableNodesById ¶
func (*Cluster) IsNodeAlive ¶
func (*Cluster) IsPluginOnCurrentNode ¶
func (c *Cluster) IsPluginOnCurrentNode(identity plugin_entities.PluginUniqueIdentifier) (bool, error)
func (*Cluster) LockNodeStatus ¶
func (*Cluster) NotifyBecomeMaster ¶
receive the master event
func (*Cluster) NotifyClusterStopped ¶
receive the cluster stopped event
func (*Cluster) NotifyMasterGC ¶
receive the master gc event
func (*Cluster) NotifyMasterGCCompleted ¶
receive the master gc completed event
func (*Cluster) NotifyNodeUpdate ¶
receive the node update event
func (*Cluster) NotifyNodeUpdateCompleted ¶
receive the node update completed event
func (*Cluster) NotifyPluginSchedule ¶
receive the plugin schedule event
func (*Cluster) NotifyPluginScheduleCompleted ¶
receive the plugin schedule completed event
func (*Cluster) NotifyVoting ¶
receive the voting event
func (*Cluster) NotifyVotingCompleted ¶
receive the voting completed event
func (*Cluster) RedirectRequest ¶
func (c *Cluster) RedirectRequest( node_id string, request *http.Request, ) (int, http.Header, io.ReadCloser, error)
RedirectRequest redirects the request to the specified node
func (*Cluster) RegisterPlugin ¶
func (c *Cluster) RegisterPlugin(lifetime plugin_entities.PluginLifetime) error
RegisterPlugin registers a plugin to the cluster, and start to be scheduled
func (*Cluster) UnlockNodeStatus ¶
Click to show internal directories.
Click to hide internal directories.