view src/alice/topology/node/ConfigurationFinish.java @ 212:b5daccf36104 working

add Receiver state pattern
author one
date Wed, 27 Mar 2013 17:30:52 +0900
parents 1a498f436332
children fec0726bb126
line wrap: on
line source

package alice.topology.node;

import org.msgpack.type.ValueFactory;

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 CodeSegment startCS;
	
	public ConfigurationFinish(CodeSegment startCS) {
		this.startCS = startCS;
	}
	
	@Override
	public void run() {
		if (reverseCount.data.val.equals(configNodeNum.data.val)) {
			ods.put("manager", "done", ValueFactory.createNilValue());

			Start cs = new Start(startCS);
			cs.done.setKey("manager", "start");

			return;
		}
		
		ConfigurationFinish cs3 = new ConfigurationFinish(startCS);
		cs3.reverseCount.setKey("local", "reverseCount", this.reverseCount.data.index);
		cs3.configNodeNum.setKey("local", "configNodeNum");
	}

}