view src/alice/test/topology/ring/CheckMyName.java @ 33:20c67f673224

change name of DataSegmentReceiver
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Wed, 18 Jan 2012 01:34:23 +0900
parents 2bfb796b0fa1
children f9334781344a
line wrap: on
line source

package alice.test.topology.ring;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

public class CheckMyName extends CodeSegment {

	Receiver host = ids.create(CommandType.PEEK);
	
	@Override
	public void run() {
		String host = this.host.asString();
		if (host.equals("node0")) {
			System.out.println("I am first node");
			ods.put("local", "counter", 0);
			FirstRingMessagePassing cs1 = new FirstRingMessagePassing();
			cs1.counter.setKey("local", "counter");
			RingFinish cs2 = new RingFinish("manager");
			cs2.finish.setKey("local", "finish");
			
		} else {
			System.out.println("I am normal node");
			RingMessagePassing cs1 = new RingMessagePassing();
			cs1.counter.setKey("local", "counter");
			RingFinish cs2 = new RingFinish("right");
			cs2.finish.setKey("local", "finish");
		}
	}

}