Search in sources :

Example 1 with IntMessage

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) IntMessage(org.goldenorb.types.message.IntMessage) IntWritable(org.apache.hadoop.io.IntWritable) Before(org.junit.Before)

Example 2 with IntMessage

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();
}
Also used : IntMessage(org.goldenorb.types.message.IntMessage) IntWritable(org.apache.hadoop.io.IntWritable)

Example 3 with IntMessage

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);
}
Also used : IntMessage(org.goldenorb.types.message.IntMessage) IntWritable(org.apache.hadoop.io.IntWritable) Test(org.junit.Test)

Aggregations

IntWritable (org.apache.hadoop.io.IntWritable)3 IntMessage (org.goldenorb.types.message.IntMessage)3 InetSocketAddress (java.net.InetSocketAddress)1 Configuration (org.apache.hadoop.conf.Configuration)1 Before (org.junit.Before)1 Test (org.junit.Test)1