view src/alice/topology/node/ConfigurationFinish.java @ 28:98ab26e09a98

Configuration Manager work and implements reverseKey
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 08:41:34 +0900
parents
children b5a21baf0b07
line wrap: on
line source

package alice.topology.node;

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

public class ConfigurationFinish extends CodeSegment {

	public DataSegmentReceiver reverseCount = new DataSegmentReceiver(ids, CommandType.PEEK);
	public DataSegmentReceiver configNodeNum = new DataSegmentReceiver(ids, CommandType.PEEK);
	private Class<CodeSegment> clazz;
	
	public ConfigurationFinish(Class<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");
	}

}