Search in sources :

Example 21 with OrbConfiguration

use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.

the class CheckPointDataTest method testCheckpointInput.

/**
   * Tests the CheckPointDataInput class by reading several different types of Writables from the checkpoint.
   * Asserts that Writables that were written in are of the same value and type when reading in from HDFS.
   * 
   * @throws Exception
   */
@Test
public void testCheckpointInput() throws Exception {
    int superStep = 0;
    int partition = 0;
    OrbConfiguration orbConf = new OrbConfiguration();
    orbConf.set("fs.default.name", "hdfs://localhost:" + cluster.getNameNodePort());
    orbConf.setJobNumber("0");
    orbConf.setFileOutputPath("test");
    CheckPointDataInput checkpointInput = new CheckPointDataInput(orbConf, superStep, partition);
    // Data is read on a FIFO basis
    IntWritable intInput = new IntWritable();
    intInput.readFields(checkpointInput);
    LongWritable longInput = new LongWritable();
    longInput.readFields(checkpointInput);
    Text textInput = new Text();
    textInput.readFields(checkpointInput);
    FloatWritable floatInput = new FloatWritable();
    floatInput.readFields(checkpointInput);
    checkpointInput.close();
    assertThat(checkpointInput, notNullValue());
    assertEquals(intInput.get(), 4);
    assertEquals(longInput.get(), 9223372036854775807L);
    assertEquals(textInput.toString(), "test");
    assertTrue(floatInput.get() == 3.14159F);
}
Also used : FloatWritable(org.apache.hadoop.io.FloatWritable) OrbConfiguration(org.goldenorb.conf.OrbConfiguration) Text(org.apache.hadoop.io.Text) LongWritable(org.apache.hadoop.io.LongWritable) CheckPointDataInput(org.goldenorb.io.input.checkpoint.CheckPointDataInput) IntWritable(org.apache.hadoop.io.IntWritable)

Example 22 with OrbConfiguration

use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.

the class TestPartitionRequest method testPartitionRequest.

/*
   * Start of user / non-generated code -- any code written outside of this block will be
   * removed in subsequent code generations.
   */
/* End of user / non-generated code */
@Before
public void testPartitionRequest() throws IOException {
    /*
     * Start of user / non-generated code -- any code written outside of this block will be
     * removed in subsequent code generations.
     */
    /* End of user / non-generated code */
    partitionRequest = new PartitionRequest();
    partitionRequest.setReservedPartitions(INT_RESERVEDPARTITIONS_VALUE);
    partitionRequest.setActivePartitions(INT_ACTIVEPARTITIONS_VALUE);
    partitionRequest.setJobID(STRING_JOBID_VALUE);
    partitionRequest.setBasePartitionID(INT_BASEPARTITIONID_VALUE);
    partitionRequest.setJobConf(new OrbConfiguration(true));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutput out = new DataOutputStream(baos);
    partitionRequest.write(out);
    DataInput in = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
    partitionRequestOut = new PartitionRequest();
    partitionRequestOut.readFields(in);
/*
     * Start of user / non-generated code -- any code written outside of this block will be
     * removed in subsequent code generations.
     */
/* End of user / non-generated code */
}
Also used : DataInput(java.io.DataInput) DataOutput(java.io.DataOutput) OrbConfiguration(org.goldenorb.conf.OrbConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) PartitionRequest(org.goldenorb.jet.PartitionRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) Before(org.junit.Before)

Example 23 with OrbConfiguration

use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.

the class ResourceAllocatorTest method testUnbalancedAssignment.

@Test
public void testUnbalancedAssignment() {
    List<OrbTracker> orbTrackers = new ArrayList<OrbTracker>();
    OrbConfiguration conf = new OrbConfiguration(true);
    conf.setOrbRequestedPartitions(6);
    conf.setOrbReservedPartitions(2);
    conf.setNumberOfPartitionsPerMachine(0);
    for (int i = 0; i < 4; i++) {
        OrbTracker ot = new OrbTracker(conf);
        ot.setAvailablePartitions(3);
        ot.setReservedPartitions(1);
        orbTrackers.add(ot);
    }
    orbTrackers.get(1).setAvailablePartitions(1);
    orbTrackers.get(2).setAvailablePartitions(1);
    ResourceAllocator<OrbTracker> ra = new ResourceAllocator<OrbTracker>(conf, orbTrackers);
    Map<OrbTracker, Integer[]> ret = null;
    try {
        ret = ra.assignResources(conf);
    } catch (InvalidJobConfException e) {
        e.printStackTrace();
    }
    // check each assignment
    assertEquals(ret.get(orbTrackers.get(0))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 2);
    assertEquals(ret.get(orbTrackers.get(0))[ResourceAllocator.TRACKER_RESERVED].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(1))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(1))[ResourceAllocator.TRACKER_RESERVED].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(2))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(2))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
    assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 2);
    assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration) OrbTracker(org.goldenorb.OrbTracker) ArrayList(java.util.ArrayList) InvalidJobConfException(org.apache.hadoop.mapred.InvalidJobConfException) Test(org.junit.Test)

Example 24 with OrbConfiguration

use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.

the class ResourceAllocatorTest method testEnoughCapacityWithPPM.

@Test
public void testEnoughCapacityWithPPM() {
    List<OrbTracker> orbTrackers = new ArrayList<OrbTracker>();
    OrbConfiguration conf = new OrbConfiguration(true);
    conf.setOrbRequestedPartitions(6);
    conf.setOrbReservedPartitions(2);
    // the "PPM" part
    conf.setNumberOfPartitionsPerMachine(2);
    for (int i = 0; i < 4; i++) {
        OrbTracker ot = new OrbTracker(conf);
        ot.setAvailablePartitions(3);
        ot.setReservedPartitions(1);
        orbTrackers.add(ot);
    }
    ResourceAllocator<OrbTracker> ra = new ResourceAllocator<OrbTracker>(conf, orbTrackers);
    Map<OrbTracker, Integer[]> ret = null;
    try {
        ret = ra.assignResources(conf);
    } catch (InvalidJobConfException e) {
        e.printStackTrace();
    }
    // check each assignment
    assertEquals(ret.get(orbTrackers.get(0))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 2);
    assertEquals(ret.get(orbTrackers.get(0))[ResourceAllocator.TRACKER_RESERVED].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(1))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 2);
    assertEquals(ret.get(orbTrackers.get(1))[ResourceAllocator.TRACKER_RESERVED].intValue(), 1);
    assertEquals(ret.get(orbTrackers.get(2))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 2);
    assertEquals(ret.get(orbTrackers.get(2))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
    assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 0);
    assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration) OrbTracker(org.goldenorb.OrbTracker) ArrayList(java.util.ArrayList) InvalidJobConfException(org.apache.hadoop.mapred.InvalidJobConfException) Test(org.junit.Test)

Example 25 with OrbConfiguration

use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.

the class ResourceAllocatorTest method insufficientCapacity.

/**
 * 
 */
@Test
public void insufficientCapacity() {
    List<OrbTracker> orbTrackers = new ArrayList<OrbTracker>();
    OrbConfiguration conf = new OrbConfiguration(true);
    conf.setOrbRequestedPartitions(6);
    conf.setOrbReservedPartitions(2);
    conf.setNumberOfPartitionsPerMachine(0);
    for (int i = 0; i < 4; i++) {
        OrbTracker ot = new OrbTracker(conf);
        ot.setAvailablePartitions(1);
        ot.setReservedPartitions(1);
        orbTrackers.add(ot);
    }
    ResourceAllocator<OrbTracker> ra = new ResourceAllocator<OrbTracker>(conf, orbTrackers);
    Map<OrbTracker, Integer[]> ret = null;
    try {
        ret = ra.assignResources(conf);
    } catch (InvalidJobConfException e) {
        e.printStackTrace();
    }
    assertNull(ret);
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration) OrbTracker(org.goldenorb.OrbTracker) ArrayList(java.util.ArrayList) InvalidJobConfException(org.apache.hadoop.mapred.InvalidJobConfException) Test(org.junit.Test)

Aggregations

OrbConfiguration (org.goldenorb.conf.OrbConfiguration)26 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 BeforeClass (org.junit.BeforeClass)6 InvalidJobConfException (org.apache.hadoop.mapred.InvalidJobConfException)4 OrbTracker (org.goldenorb.OrbTracker)4 IOException (java.io.IOException)3 Path (org.apache.hadoop.fs.Path)3 List (java.util.List)2 FloatWritable (org.apache.hadoop.io.FloatWritable)2 IntWritable (org.apache.hadoop.io.IntWritable)2 LongWritable (org.apache.hadoop.io.LongWritable)2 Text (org.apache.hadoop.io.Text)2 ZooKeeper (org.apache.zookeeper.ZooKeeper)2 InputSplitAllocator (org.goldenorb.io.InputSplitAllocator)2 RawSplit (org.goldenorb.io.input.RawSplit)2 OrbPartitionMember (org.goldenorb.jet.OrbPartitionMember)2 OrbZKFailure (org.goldenorb.zookeeper.OrbZKFailure)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1