view src/main/java/alice/topology/node/ConfigurationFinish.java @ 498:e5d2141af6c2 dispose

keep alive Scheduler has bug
author sugi
date Mon, 15 Dec 2014 19:16:20 +0900
parents 24e535123df7
children 9e69b5c6fe44
line wrap: on
line source

package alice.topology.node;

import org.msgpack.type.ValueFactory;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;
import alice.topology.manager.keeparive.StartKeepAlive;

public class ConfigurationFinish extends CodeSegment {

    public Receiver reverseCount = ids.create(CommandType.PEEK);
    public Receiver configNodeNum = ids.create(CommandType.PEEK);
    private CodeSegment startCS;

    public ConfigurationFinish(CodeSegment startCS) {
        this.startCS = startCS;
    }

    @Override
    public void run() {
        int rcount = reverseCount.asInteger();
        int ncount = configNodeNum.asInteger();
        if (rcount == ncount) {
            ods.put("manager", "done", ValueFactory.createNilValue());
            Start cs = new Start(startCS);
            cs.done.setKey("manager", "start");

            new StartKeepAlive().execute();
            new ReceiveCloseMessage(CommandType.PEEK);
            DisconnectEventManager.getInstance().register(DeleteConnection.class);
            DisconnectEventManager.getInstance().setKey();
            return;
        }

        ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
        cs3.reverseCount.setKey("local", "reverseCount", this.reverseCount.index);
        cs3.configNodeNum.setKey("local", "configNodeNum");
    }

}