示例#1
0
// Update the node state without moving data.
func (srv *InnerServer) UpdateNode(node *cluster.ClusterTopologyNode, reply *cluster.ClusterTopology) (err error) {
	defer func() {
		// Executes normally even if there is a panic
		if e := recover(); e != nil {
			log.Println("Run time panic: %v", e)
			*reply = srv.config.Topology
			err = errors.New("Runtime error.")
		}
	}()
	log.Printf("Node %s update state %s\r\n", node.Node.Name, node.Node.State)
	srv.config.Topology.AddNode(node)
	srv.config.WriteTmp()
	reply.Nodes = srv.config.Topology.Nodes
	return nil
}
示例#2
0
// Merge the cluster topology configuration.
func (srv *InnerServer) UpdateTopology(topology *cluster.ClusterTopology, reply *cluster.ClusterTopology) (err error) {
	defer func() {
		// Executes normally even if there is a panic
		if e := recover(); e != nil {
			log.Println("Run time panic: %v", e)
			*reply = srv.config.Topology
			err = errors.New("Runtime error.")
		}
	}()
	srv.config.Topology.Merge(topology)
	srv.config.WriteTmp()
	reply.Nodes = srv.config.Topology.Nodes
	// start data partitioner
	go srv.partitioner.MoveData()
	return nil
}
示例#3
0
// Register the new node as a twin.
func (srv *InnerServer) RegisterTwin(node *cluster.ClusterTopologyNode, reply *cluster.ClusterTopology) (err error) {
	defer func() {
		// Executes normally even if there is a panic
		if e := recover(); e != nil {
			log.Println("Run time panic: %v", e)
			*reply = srv.config.Topology
			err = errors.New("Runtime error.")
		}
	}()
	log.Printf("Node %s ask registration as twin\r\n", node.Node.Name)
	srv.config.Topology.AddTwin(node)
	srv.config.WriteTmp()
	reply.Nodes = srv.config.Topology.Nodes
	// start data partitioner
	go srv.partitioner.MoveData()
	go srv.updateAllClusterNodes() // update the state on the other nodes
	return nil
}
示例#4
0
// Register a new node in the cluster.
func (srv *InnerServer) RegisterNode(node *cluster.ClusterTopologyNode, reply *cluster.ClusterTopology) (err error) {
	defer func() {
		// Executes normally even if there is a panic
		if e := recover(); e != nil {
			log.Println("Run time panic: %v", e)
			*reply = srv.config.Topology
			err = errors.New("Runtime error.")
		}
	}()
	log.Printf("Node %s registration or update state %s\r\n", node.Node.Name, node.Node.State)
	srv.config.Topology.AddNode(node)
	srv.config.WriteTmp()
	reply.Nodes = srv.config.Topology.Nodes
	if cluster.Inactive == node.Node.State {
		srv.outcmdproc.Caller.RemoveClient(node.Node.Name)
	}
	// start data partitioner
	go srv.partitioner.MoveData()
	return nil
}
示例#5
0
// Get the topology
func (srv *InnerServer) GetTopology(name *string, reply *cluster.ClusterTopology) (err error) {
	log.Printf("Node %s asked topology\r\n", *name)
	reply.Nodes = srv.config.Topology.GetNodes()
	return nil
}