Package org.apache.hama.bsp.message.type

Examples of org.apache.hama.bsp.message.type.ByteMessage


public class TestMessages extends TestCase {

  public void testByteMessage() {
    int dataSize = (int) (Runtime.getRuntime().maxMemory() * 0.60);
    ByteMessage msg = new ByteMessage(Bytes.toBytes("tag"), new byte[dataSize]);
    assertEquals(msg.getData().length, dataSize);
    msg = null;
   
    byte[] dummyData = new byte[1024];
    ByteMessage msg2 = new ByteMessage(Bytes.tail(dummyData, 128), dummyData);
    assertEquals(
        Bytes.compareTo(msg2.getTag(), 0, 128, msg2.getData(),
            msg2.getData().length - 128, 128), 0);
  }
View Full Code Here


public class TestMessages extends TestCase {

  public void testByteMessage() {
    int dataSize = 1234;
    ByteMessage msg = new ByteMessage(Bytes.toBytes("tag"), new byte[dataSize]);
    assertEquals(msg.getData().length, dataSize);
    msg = null;

    byte[] dummyData = new byte[1024];
    ByteMessage msg2 = new ByteMessage(Bytes.tail(dummyData, 128), dummyData);
    assertEquals(Bytes.compareTo(msg2.getTag(), 0, 128, msg2.getData(),
        msg2.getData().length - 128, 128), 0);
  }
View Full Code Here

    }
    assertTrue("Make sure directory is created.",
        dfs.exists(new Path(checkpointedDir)));
    byte[] tmpData = "data".getBytes();
    BSPMessageBundle bundle = new BSPMessageBundle();
    bundle.addMessage(new ByteMessage("abc".getBytes(), tmpData));
    assertNotNull("Message bundle can not be null.", bundle);
    assertNotNull("Configuration should not be null.", config);
    bspTask.checkpoint(checkpointedDir + "/attempt_201110302255_0001_000000_0",
        bundle);
    FSDataInputStream in = dfs.open(new Path(checkpointedDir
        + "/attempt_201110302255_0001_000000_0"));
    BSPMessageBundle bundleRead = new BSPMessageBundle();
    bundleRead.readFields(in);
    in.close();
    ByteMessage byteMsg = (ByteMessage) (bundleRead.getMessages()).get(0);
    String content = new String(byteMsg.getData());
    LOG.info("Saved checkpointed content is " + content);
    assertTrue("Message content should be the same.", "data".equals(content));
    dfs.delete(new Path("checkpoint"), true);
  }
View Full Code Here

TOP

Related Classes of org.apache.hama.bsp.message.type.ByteMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.