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);
}
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 */
}
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);
}
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);
}
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);
}
Aggregations