use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.
the class OrbRunnerTest method testOrbRunner.
@Test
public void testOrbRunner() throws Exception {
runJob(orbConf);
List<String> jobList = ZK.getChildren("/GoldenOrb/" + orbConf.getOrbClusterName() + "/JobQueue", false);
for (String jobName : jobList) {
OrbConfiguration compareOrbConf = (OrbConfiguration) ZookeeperUtils.getNodeWritable(ZK, "/GoldenOrb/" + orbConf.getOrbClusterName() + "/JobQueue/" + jobName, OrbConfiguration.class, orbConf);
assertEquals(compareOrbConf.getOrbClusterName(), orbConf.getOrbClusterName());
}
}
use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.
the class PartitionRequest method readFields.
// /////////////////////////////////////
// Writable
// /////////////////////////////////////
/**
*
* @param DataInput in
*/
public void readFields(DataInput in) throws IOException {
reservedPartitions = in.readInt();
activePartitions = in.readInt();
jobID = Text.readString(in);
basePartitionID = in.readInt();
jobConf = new OrbConfiguration();
jobConf.readFields(in);
}
use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.
the class OrbSingleSourceShortestPathJob method startJob.
public void startJob(String[] args) {
OrbConfiguration orbConf = new OrbConfiguration(true);
orbConf.setFileInputFormatClass(TextInputFormat.class);
orbConf.setFileOutputFormatClass(TextOutputFormat.class);
orbConf.setVertexClass(SingleSourceShortestPathVertex.class);
orbConf.setMessageClass(PathMessage.class);
orbConf.setVertexInputFormatClass(SingleSourceShortestPathReader.class);
orbConf.setVertexOutputFormatClass(SingleSourceShortestPathWriter.class);
orbConf.setNumberOfMessageHandlers(10);
orbConf.setNumberOfVertexThreads(10);
try {
parseArgs(orbConf, args, ALGORITHM_NAME);
} catch (Exception e) {
printHelpMessage();
System.exit(-1);
}
runJob(orbConf);
}
use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.
the class JobManager method getJobsInQueue.
/**
* Return the jobsInQueue
*/
private void getJobsInQueue() {
logger.info("getting jobs in queue.");
synchronized (jobs) {
List<String> jobQueueChildren = null;
try {
jobQueueChildren = zk.getChildren(jobQueuePath, jobsInQueueWatcher);
} catch (KeeperException e) {
fireEvent(new OrbExceptionEvent(e));
} catch (InterruptedException e) {
fireEvent(new OrbExceptionEvent(e));
}
List<String> jobsToRemove = new ArrayList<String>();
for (String jobPath : jobs.keySet()) {
if (!jobQueueChildren.contains(jobPath)) {
jobsToRemove.add(jobPath);
// Either a job has completed or been removed by someone else this should fire an event.
// This should really not occur since it should only be removed by the JobManager itself.
// In reality does an event really even need to be thrown?
}
}
for (String job : jobsToRemove) {
logger.debug("Removing job: " + job);
jobs.remove(job);
activeJobs.remove(job);
}
for (String jobPath : jobQueueChildren) {
OrbConfiguration jobConf;
try {
jobConf = (OrbConfiguration) ZookeeperUtils.getNodeWritable(zk, jobQueuePath + "/" + jobPath, OrbConfiguration.class, orbConf);
if (jobConf != null) {
if (!jobs.containsKey(jobPath)) {
logger.debug("Adding job: " + jobPath);
jobs.put(jobPath, new OrbJob(jobPath, jobConf));
// Here we have a new job--once again an event should be fired.
// Although I am not sure that an event really needs to be fired at this point. We will see.
}
} else {
logger.debug("Job is not a valid job.");
}
} catch (OrbZKFailure e) {
fireEvent(new OrbExceptionEvent(e));
}
}
}
tryToLaunchJob();
}
use of org.goldenorb.conf.OrbConfiguration in project goldenorb by jzachr.
the class ResourceAllocatorTest method testEnoughCapacity.
@Test
public void testEnoughCapacity() {
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);
}
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(), 1);
assertEquals(ret.get(orbTrackers.get(2))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_AVAILABLE].intValue(), 1);
assertEquals(ret.get(orbTrackers.get(3))[ResourceAllocator.TRACKER_RESERVED].intValue(), 0);
}
Aggregations