コード例 #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
}
コード例 #2
0
ファイル: paxos_impl.go プロジェクト: thuhujin/Paxos
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
}
コード例 #3
0
ファイル: paxos_impl.go プロジェクト: harouwu/p3
// 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
}
コード例 #4
0
ファイル: paxos_impl.go プロジェクト: jbuckman/p3-440
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
}
コード例 #5
0
ファイル: paxos_impl.go プロジェクト: YuchengZ/CodingSample
// 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
}