view src/main/java/christie/test/topology/paxos/learner/RecieveAcceptProposalCodeGear.java @ 181:33b4966d4d24

update paxos
author akahori
date Sat, 02 Feb 2019 11:42:48 +0900
parents a0391cfdcef6
children 1bffd8151c6a
line wrap: on
line source

package christie.test.topology.paxos.learner;

import christie.annotation.Peek;
import christie.annotation.Take;
import christie.codegear.CodeGear;
import christie.codegear.CodeGearManager;
import christie.test.topology.paxos.Proposal;

import java.util.HashMap;

public class RecieveAcceptProposalCodeGear extends CodeGear{

    @Take
    Proposal acceptedProposal;

    @Take
    HashMap<String, Proposal> acceptedMap;


    @Override
    protected void run(CodeGearManager cgm) {
        System.out.println("accepted : " + acceptedProposal);
        acceptedMap.put(acceptedProposal.getAcceptorName(),
                        acceptedProposal);
        put("acceptedMap", acceptedMap);
        if(acceptedMap.size() > acceptedProposal.getAcceptorNum()/2) cgm.setup(new AggregateProposalCodeGear());
        cgm.setup(new RecieveAcceptProposalCodeGear());
    }
}