Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.DataTransferHeaderOptions


public class TestDataTransferHeaderOptions {

  @Test
  public void testRandom() {
    DataTransferHeaderOptions options = new DataTransferHeaderOptions();
    for (int c = 0; c < 4; c++) {
      for (int data = 0; data < 8; data++) {
        for (int advise = 0; advise < 6; advise++) {
          options.setFadvise(advise);
          options.setIoprio(c, data);
          assertEquals(advise, options.getFadvise());
          assertEquals(c, options.getIoprioClass());
          assertEquals(data, options.getIoprioData());
        }
      }
    }
  }
View Full Code Here


    }
  }

  @Test
  public void testRandomSerialize() throws Exception {
    DataTransferHeaderOptions options = new DataTransferHeaderOptions();
    for (int c = 0; c < 4; c++) {
      for (int data = 0; data < 8; data++) {
        for (int advise = 0; advise < 6; advise++) {
          options.setFadvise(advise);
          options.setIoprio(c, data);

          // Serialize.
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          DataOutputStream out = new DataOutputStream(bos);
          options.write(out);
          byte[] buf = bos.toByteArray();
          out.close();

          // De - Serialize
          DataInputStream in = new DataInputStream(
              new ByteArrayInputStream(buf));
          DataTransferHeaderOptions expectedOptions = new DataTransferHeaderOptions();
          expectedOptions
          .readFields(in);

          assertEquals(advise, expectedOptions.getFadvise());
          assertEquals(c, expectedOptions.getIoprioClass());
          assertEquals(data, expectedOptions.getIoprioData());
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.DataTransferHeaderOptions

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.