view src/alice/test/topology/ring/CheckMyName.java @ 46:1a498f436332

bug fix for time calculate
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sat, 04 Feb 2012 16:03:05 +0900
parents ae24d5d40c10
children 0c2ad7c70f4e
line wrap: on
line source

package alice.test.topology.ring;

import java.util.Date;

import org.apache.log4j.Logger;

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

public class CheckMyName extends CodeSegment {

	public Receiver host = ids.create(CommandType.PEEK);
	
	private Logger logger = Logger.getLogger(CheckMyName.class);
	private RingTopologyConfig conf;
	public CheckMyName(RingTopologyConfig conf) {
		this.conf = conf;
	}
	@Override
	public void run() {
		String host = this.host.asString();
		logger.debug(host);
		if (host.equals("node0")) {
			ods.put("local", "counter", 0);
			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(new Date(), conf.count);
			cs1.counter.setKey("local", "counter");
			RingFinish cs2 = new RingFinish("manager");
			cs2.finish.setKey("local", "finish");
		} else {
			ods.close("manager");
			RingMessagePassing cs1 = new RingMessagePassing();
			cs1.counter.setKey("local", "counter");
			RingFinish cs2 = new RingFinish("right");
			cs2.finish.setKey("local", "finish");
		}
	}

}