use of org.goldenorb.types.message.IntMessage in project goldenorb by jzachr.
the class SampleIntMessageTest method startServer.
/**
*
*/
@SuppressWarnings("unchecked")
@Before
public void startServer() throws IOException {
server = new RPCServer<IntMessage, IntWritable>(SERVER_PORT);
server.start();
Configuration conf = new Configuration();
InetSocketAddress addr = new InetSocketAddress("localhost", SERVER_PORT);
if (client == null)
client = (RPCProtocol<IntMessage, IntWritable>) RPC.waitForProxy(RPCProtocol.class, RPCProtocol.versionID, addr, conf);
}
use of org.goldenorb.types.message.IntMessage in project goldenorb by jzachr.
the class MaximumValueVertex method compute.
@Override
public void compute(Collection<IntMessage> messages) {
int _maxValue = 0;
for (IntMessage m : messages) {
int msgValue = ((IntWritable) m.getMessageValue()).get();
if (msgValue > _maxValue) {
_maxValue = msgValue;
}
}
if (this.getValue().get() > _maxValue) {
_maxValue = this.getValue().get();
}
if (_maxValue > maxValue) {
maxValue = _maxValue;
for (Edge<IntWritable> e : getEdges()) {
sendMessage(new IntMessage(e.getDestinationVertex(), new IntWritable(maxValue)));
}
}
this.voteToHalt();
}
use of org.goldenorb.types.message.IntMessage in project goldenorb by jzachr.
the class SampleIntMessageTest method testRPC.
@Test
public void testRPC() {
IntMessage im1 = client.sendAndReceiveMessage(im0, DESTINATION_VALUE, new IntWritable(MESSAGE_VALUE));
assertTrue(im0.get() == client.getMessage().get());
assertEquals(im0.getDestinationVertex(), client.getMessage().getDestinationVertex());
assertEquals(im1.getDestinationVertex(), DESTINATION_VALUE);
assertTrue(((IntWritable) im1.getMessageValue()).get() == MESSAGE_VALUE);
}
Aggregations