view src/main/java/alice/topology/node/StartTopologyNode.java @ 655:1c93e82e05c6 default tip

fix timestamp
author suruga
date Sat, 17 Feb 2018 00:33:00 +0900
parents e321c5ec9b58
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.datasegment.DataSegment;
import alice.topology.HostMessage;

public class StartTopologyNode extends CodeSegment {

    private final String manager;
    private final String local;
    private TopologyNodeConfig conf;
    private CodeSegment startCS;

    public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) {
        this.conf = conf;
        this.startCS = startCS;
        this.manager = conf.getManagerKey();
        this.local = conf.getLocalKey();
    }

    @Override
    public void run() {
        DataSegment.connect(manager, manager, conf.getManagerHostName(), conf.getManagerPort());
        String localHostName = null;
        try {
            localHostName = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        new SaveCookie();
        if (conf.localPort == 0) {
            // local test mode
            localHostName = conf.getLocalKey();
        }
        ods.put("config" , conf );

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

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

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

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

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

        ConfigurationFinish cs3 = new ConfigurationFinish(startCS);

    }

}