// nodeA is the head node and runs some tests while all other nodes
// simply listen for incoming messages
if ( nodeName.equals("nodeA") ) {
// do some application stuff
CalculatorService calculatorService =
node.getDomain().getService(CalculatorService.class, "CalculatorServiceComponentA");
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));
// a little hidden loop test to put some load on the nodes
if (args.length > 2){
for (int i=0; i < 1000; i++){
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));
}
}
} else {
// start up and wait for messages
try {