Example #1
0
// Send all commited information to new node
func (pn *paxosNode) RecvReplaceCatchup(args *paxosrpc.ReplaceCatchupArgs, reply *paxosrpc.ReplaceCatchupReply) error {
	pn.storage.storageLock.Lock()
	defer pn.storage.storageLock.Unlock()
	jsonMap, _ := json.Marshal(pn.storage.storage)
	reply.Data = jsonMap
	return nil
}
Example #2
0
func (pn *paxosNode) RecvReplaceCatchup(args *paxosrpc.ReplaceCatchupArgs, reply *paxosrpc.ReplaceCatchupReply) error {
	data, err := json.Marshal(pn.keyValue)
	if err == nil {
		reply.Data = data
	}
	return nil
}
Example #3
0
// Request the value that was agreed upon for a particular round. A node
// receiving this message should reply with the data (as an array of bytes)
// needed to make the replacement server aware of the keys and values
// committed so far.
func (pn *paxosNode) RecvReplaceCatchup(args *paxosrpc.ReplaceCatchupArgs, reply *paxosrpc.ReplaceCatchupReply) error {
	var network bytes.Buffer // Stand-in for the network.

	// Create an encoder and send a value.
	enc := gob.NewEncoder(&network)
	err := enc.Encode(pn.instances)
	if err != nil {
	}
	reply.Data = network.Bytes()
	return nil
}
Example #4
0
func (pn *paxosNode) RecvReplaceCatchup(args *paxosrpc.ReplaceCatchupArgs, reply *paxosrpc.ReplaceCatchupReply) error {

	var network bytes.Buffer
	enc := gob.NewEncoder(&network)
	err := enc.Encode(pn.storage)
	if err != nil {
		return err
	}

	reply.Data = network.Bytes()

	return nil
}
Example #5
0
// receive replace cat chup request
func (pn *paxosNode) RecvReplaceCatchup(args *paxosrpc.ReplaceCatchupArgs, reply *paxosrpc.ReplaceCatchupReply) error {
	value, _ := json.Marshal(pn.valueMap)
	reply.Data = value
	return nil
}