view src/main/java/alice/topology/node/IncomingConnectionInfo.java @ 429:1b32ea1263f3 dispose

work but have bug
author sugi
date Tue, 22 Jul 2014 18:44:18 +0900
parents aefbe41fcf12
children 59e84cd75403
line wrap: on
line source

package alice.topology.node;

import java.util.ArrayList;

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

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 {
            if (count == 0)
                ods.put("_CLIST", new ArrayList<String>());

            HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class);
            if (DataSegment.contains(hostInfo.connectionName)) {
                System.out.println("reconnection");
                DataSegment.remove(hostInfo.connectionName);
            } else {
                ods.put("cMember", hostInfo.connectionName);
                new CreateConnectionList();
                count++;             
            } 
            DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port);
            ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName);
            
        }
        
        IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, count);
        cs.hostInfo.setKey("manager", absName);
    }

}