view src/alice/test/topology/fishmodel/beta/CheckMyName.java @ 110:aa9fc077c286 working

remove host from checkFishLocation
author sugi
date Sun, 15 Jul 2012 21:32:48 +0900
parents 96674c803853
children ba64a9d76e70
line wrap: on
line source

package alice.test.topology.fishmodel.beta;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;
import alice.test.topology.fishmodel.alpha.CheckFishLocation;
import alice.test.topology.fishmodel.alpha.FishPoint;
import alice.test.topology.fishmodel.alpha.MakeFrame;
import alice.test.topology.fishmodel.alpha.MakeObject;


public class CheckMyName extends CodeSegment {
	Receiver host = ids.create(CommandType.PEEK);
	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
	String key = "fish";
	
	@Override
	public void run(){
		
		String name = host.asString();
		Matcher matcher = pattern.matcher(name);
		
		matcher.find();
		String type = matcher.group(1);
		int num = new Integer(matcher.group(2));
		
		RoutingTable routing = new RoutingTable();
		ods.update("local", key, new FishPoint(0.0f,0.0f));
		
		if (type.equals("cli")){
			System.out.println("cli"+num);
			routing.table.add(new Routing("parent"));
			ods.put("local", "list", routing);
			
			new AddRoutingTable(routing,0);
			ods.put("parent", "member", name);
				
		}else if (type.equals("node")){
			System.out.println("node"+num);
			if (num != 0){
				routing.table.add(new Routing("parent"));
				ods.put("parent", "member", name);
				
				
			}
			ods.put("local", "list", routing);
			new AddRoutingTable(routing,0);
			
		}
		
		MakeFrame frame =  new MakeFrame(name);
		
		MakeObject obj3 = new MakeObject(frame);
		frame.register(obj3);
		new CheckFishLocation(obj3,key,0,num);
		
		new CheckLocalIndex(key,1);
	}
}