Пример #1
0
func (p *Partitioner) MoveObject(obj *storage.MetaDataObj) {
	if obj != nil {
		if !util.Contains(p.serverNode.Node.HashRange, obj.Hash) {
			log.Printf("Moving key = %s\r\n", obj.Key)
			p.outcomingQueue.Enqueu(&command.Command{OpCode: "move", Obj: obj.MetaDataUpdObj()})
		}
	}
}
Пример #2
0
// Get the node that contains the hashcode
func (ct *ClusterTopology) GetNodeByHash(hash int) (node *ClusterTopologyNode) {
	mux.RLock()
	defer mux.RUnlock()
	for _, nd := range ct.Nodes {
		if util.Contains(nd.Node.HashRange, hash) {
			return nd
		}
	}

	return nil
}
Пример #3
0
func (p *Partitioner) MoveData() {
	var list = p.storage.List()
	log.Printf("Partitioner is moving data (storage size = %d)\r\n", len(list))
	for _, obj := range list {
		if obj != nil {
			if !util.Contains(p.serverNode.Node.HashRange, obj.Hash) {
				log.Printf("Moving key = %s\r\n", obj.Key)
				p.outcomingQueue.Enqueu(&command.Command{OpCode: "move", Obj: obj.MetaDataUpdObj()})
			}
		}
	}
	var counters = p.storage.ListCounters()
	log.Printf("Partitioner is moving counters (storage size = %d)\r\n", len(counters))
	for _, obj := range counters {
		if obj != nil {
			if !util.Contains(p.serverNode.Node.HashRange, obj.Hash) {
				log.Printf("Moving counter key = %s\r\n", obj.Key)
				p.outcomingQueue.Enqueu(&command.Command{OpCode: "movecounter", Obj: obj.MetaDataUpdObj()})
			}
		}
	}
}
Пример #4
0
func (cq *OutCommandQueue) executeUpdateKey(obj *storage.MetaDataUpdObj, operation string) {
	if !util.Contains(cq.serverNode.Node.HashRange, obj.NewHash) {
		// delete the data on the twins
		for _, node := range cq.topology.GetTwins(cq.serverNode.Twins) {
			err := cq.Caller.ExecuteOperation(obj, node.Node, "delete")
			if err != nil {
				cq.enqueuError(newCommandError(obj, node.Node, "delete"))
			}
		}
		// move the data because the new hashcode does not belong to this node
		cq.move(obj)
	} else {
		// update data on the twins
		for _, node := range cq.topology.GetTwins(cq.serverNode.Twins) {
			err := cq.Caller.ExecuteOperation(obj, node.Node, operation)
			if err != nil {
				cq.enqueuError(newCommandError(obj, node.Node, operation))
			}
		}
	}
}