Search in sources :

Example 6 with OrbConfiguration

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());
    }
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration) Test(org.junit.Test)

Example 7 with OrbConfiguration

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);
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration)

Example 8 with OrbConfiguration

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);
}
Also used : OrbConfiguration(org.goldenorb.conf.OrbConfiguration)

Example 9 with OrbConfiguration

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();
}
Also used : OrbExceptionEvent(org.goldenorb.event.OrbExceptionEvent) OrbConfiguration(org.goldenorb.conf.OrbConfiguration) ArrayList(java.util.ArrayList) OrbZKFailure(org.goldenorb.zookeeper.OrbZKFailure) KeeperException(org.apache.zookeeper.KeeperException)

Example 10 with OrbConfiguration

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);
}
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