view src/fdl/test/debug2/DebugStartCallback.java @ 92:ea4ee892baf5

commit
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Thu, 22 Apr 2010 16:13:03 +0900
parents
children
line wrap: on
line source

package fdl.test.debug2;

import java.nio.ByteBuffer;
//import java.util.Date;

import fdl.PSXCallback;

class DebugStartCallback implements PSXCallback {
	public NodeProperty np;
	public DebugProperty dp;
	public DebugStartCallback(NodeProperty np, DebugProperty dp) {
			this.np = np;
			this.dp = dp;
	}
	public void callback(ByteBuffer reply) {
		String[] commands = new String(reply.array()).split(",");
		String command = commands[0];
		if (command.equals("relay")) {
			dp.relayNum = Integer.parseInt(commands[1]);
			dp.relaySize = Integer.parseInt(commands[2]);
			dp.relayCounter = 0;
			Debug.print("relay num=" + dp.relayNum + " size=" + dp.relaySize);
			Routing r = np.nodes.get(TupleId.RINGRIGHT);
			// 実験開始
			// TODO: startTime?
			//startTime = new Date();
			r.linda.out(r.dstId, ByteBuffer.wrap(new byte[dp.relaySize]));
			np.ml.in(TupleId.DEBUGSTART.id, this);
		} else if (command.equals("print")) {
			Routing r = np.nodes.get(TupleId.RINGRIGHT);
			r.linda.out(r.dstId, reply);
			Debug.print("Send Debug Message: print");
			np.ml.in(TupleId.DEBUGSTART.id, this);
		} else if (command.equals("shutdown")) {
			Routing r = np.nodes.get(TupleId.RINGRIGHT);
			r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
		}
	}
}