view src/main/java/alice/topology/node/ConfigurationFinish.java @ 470:780ae843cdac dispose

Delete disconnect managerKey from connection list
author sugi
date Mon, 24 Nov 2014 19:52:13 +0900
parents b31b1d197c42
children cf345b10a21a
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.CatchDisconnectEvent;

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");

            DisconnectEventManager.getInstance().register(CatchDisconnectEvent.class);
            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");
    }

}