view src/alice/topology/node/ConfigurationFinish.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 ac3b48c5f4da
line wrap: on
line source

package alice.topology.node;

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

public class ConfigurationFinish extends CodeSegment {

	public Receiver reverseCount = ids.create(CommandType.PEEK);
	public Receiver configNodeNum = ids.create(CommandType.PEEK);
	private Class<? extends CodeSegment> clazz;
	
	public ConfigurationFinish(Class<? extends CodeSegment> clazz) {
		this.clazz = clazz;
	}
	
	@Override
	public void run() {
		if (reverseCount.val.equals(configNodeNum.val)) {
			System.out.println("Configuration finished");
			if (clazz == null)
				return;
			try {
				clazz.newInstance().execute();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
			return;
		}
		
		ConfigurationFinish cs3 = new ConfigurationFinish(clazz);
		cs3.reverseCount.setKey("local", "reverseCount");
		cs3.configNodeNum.setKey("local", "configNodeNum");
	}

}