view src/main/java/alice/topology/node/StartTopologyNode.java @ 547:e91a574b69de dispose

remove index
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Tue, 18 Aug 2015 16:15:17 +0900
parents f3f7e256ee03
children
line wrap: on
line source

package alice.topology.node;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;

import alice.codesegment.CodeSegment;
import alice.daemon.AliceDaemon;
import alice.datasegment.DataSegment;
import alice.topology.HostMessage;

public class StartTopologyNode extends CodeSegment {

    private TopologyNodeConfig conf;
    private CodeSegment startCS;

    public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
        this.conf = conf;
        this.startCS = startCS;
    }

    @Override
    public void run() {
        aliceDaemon.dataSegment.connect("manager", "manager", conf.getManagerHostName(), conf.getManagerPort());
        String localHostName = null;
        try {
            localHostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        new SaveCookie();

        HostMessage host = new HostMessage(localHostName, conf.localPort);
        host.cookie = conf.cookie;
        ods.put("manager", "host", host);

        ods.put("_CLIST", new ArrayList<String>());

        IncomingAbstractHostName cs = new IncomingAbstractHostName();
        cs.absName.setKey("local", "host", this);

        IncomingReverseKey cs2 = new IncomingReverseKey();
        cs2.reverseKey.setKey("local", "reverseKey", this);
        cs2.reverseCount.setKey("local", "reverseCount", this);

        ods.put("local", "reverseCount", 0);

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

    }

}