Voter Coordinator

The Voter-Coordinator style of coordination involves a coordinator (always the agent that sends the message) and several voters (that could be other agents or components or arrays of agents or components). Methods invoked on voters, in case they are not arrays of a voter type, could have different signatures but all of them need to return a boolean. Only when all voters send back a Boolean true, the coordinator passes control to the logic block following the expression.

Syntax : Voted(agent.methodA(paramlist), component.methodB(paramlist)) {		// business logic } where,
 * agent and component are instances of type Agent and Component

In the voter-coordinator style, the channel only stops only when all voters have returned back calls or the exit timer is notified.

For invocations on arrays of agents or components, the coordinator sends the same message (invokes methods with the same signature) to all instances of type agent or component found across the network at that point in time.

Syntax : Voted([agent[ ] | component [ ]].method(parameter_list)) {		// business logic } where,
 * agent[ ] and component[ ] are arrays of type Agent or Component

Unlike in Broadcasts, an Agent or Component (returning the call) role and id may not be retrieved in the logic block in the voter coordinator style of coordination by using __voted__agent__role and __voted__agent__id respectively as this coordination style is only used for transaction management where a signal to commit (process logic on commit) is all that is expected.

public Agent Voter {	public int resetTemp; public double getTemp; public void setTemp(double t); public boolean isBoiling; } Definition file : Voter.indus

public class tempSlave implements Voter {	double temp = 0.0; Context {		setServantType(cx.USER); }

public int resetTemp {		temp = 100.0; return 0; }

public double getTemp {				return (temp); }

public void setTemp(double t)	{ temp = t;	}

public boolean isBoiling {		if (temp >= 100.0) return true; return false; } } Implementation file : tempSlave.indus

public Agent Coordinator {

} Definition file : Coordinator.indus

public class sampleCoordinator implements Coordinator {	double temp = 0.0; Context {		setServantType(cx.USER); }

public static void main(String [] args) {		try {			Slave1 slave1 = newType Slave1("slave1"); Slave1 slave2 = newType Slave1("slave2"); Slave1 slave3 = newType Slave1("slave3");

double result = 0.0; Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("First :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }

slave1.setTemp(120.0); Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("Second :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }

slave2.setTemp(120.0); Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("Third :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }

slave3.setTemp(120.0);

Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("Fourth :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }			slave1.setTemp(20.0);

Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("Fifth :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }			slave1.setTemp(120.0);

Voted(slave1.isBoiling, slave2.isBoiling, slave3.isBoiling) {				System.out.println("Sixth :                                ALL TEMPERATURES ARE ABOVE BOILING POINT"); }		}			catch (Exception e) {}

} } Implementation file : sampleCoordinator.indus

Next : Blackboard