view src/alice/topology/manager/reconnection/CheckABSName.java @ 268:709936c00c89

creating reconnect manager
author sugi
date Sun, 18 Aug 2013 02:13:52 +0900
parents fac206b7849c
children 9982e1c4f099
line wrap: on
line source

package alice.topology.manager.reconnection;

import java.util.List;

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

public class CheckABSName extends CodeSegment{
	private Receiver abs = ids.create(CommandType.PEEK);
	private Receiver host = ids.create(CommandType.TAKE); 
	private HostMessage message;
	
	public CheckABSName(HostMessage mes) {
		message = mes;
		abs.setKey("_ABSTABLE");
		host.setKey("host");
	}

	@Override
	public void run() {
		@SuppressWarnings("unchecked")
		List<HostMessage> absList = abs.asClass(List.class);
		for (HostMessage mes : absList){
			if (mes.name.equals(message.name)&&mes.port == message.port){
				HostMessage hostInfo = host.asClass(HostMessage.class);
				DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port);
				ods.put(mes.getABSName(), "host", mes.getABSName());
				
			}
			
		}
	}

}