view src/main/java/alice/topology/node/IncomingConnectionInfo.java @ 557:1a860019b2fe dispose

add ip to HostMessage.class
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Fri, 20 Nov 2015 17:57:55 +0900
parents 145c425db88d
children
line wrap: on
line source

package alice.topology.node;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.DataSegment;
import alice.datasegment.Receiver;
import alice.topology.HostMessage;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IncomingConnectionInfo extends CodeSegment {

    public Receiver hostInfo = ids.create(CommandType.TAKE);
    private String absName;
    private int count;

    public IncomingConnectionInfo(String absName, int count) {
        this.absName = absName;
        this.count = count;
    }


    @Override
    public void run() {
        if (this.hostInfo.getVal() == null) {
            ods.put("local", "configNodeNum", count);
        } else {
            HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class);
            if (DataSegment.contains(hostInfo.connectionName)) {
                // need to wait remove by DeleteConnection
                ods.put("manager", absName, hostInfo);
            } else {
                DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.ip, hostInfo.port);
                ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName);
                count++;

                ods.put("cMember", hostInfo.connectionName);
                new CreateConnectionList();
            }

        }

        IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, count);
        cs.hostInfo.setKey("manager", absName);
    }

}