Search in sources :

Example 1 with ZombieJobProducer

use of org.apache.hadoop.tools.rumen.ZombieJobProducer in project hadoop by apache.

the class TestGridMixClasses method testSerialReaderThread.

/*
   * test SerialJobFactory
   */
@Test(timeout = 120000)
public void testSerialReaderThread() throws Exception {
    Configuration conf = new Configuration();
    File fin = new File("src" + File.separator + "test" + File.separator + "resources" + File.separator + "data" + File.separator + "wordcount2.json");
    // read couple jobs from wordcount2.json
    JobStoryProducer jobProducer = new ZombieJobProducer(new Path(fin.getAbsolutePath()), null, conf);
    CountDownLatch startFlag = new CountDownLatch(1);
    UserResolver resolver = new SubmitterUserResolver();
    FakeJobSubmitter submitter = new FakeJobSubmitter();
    File ws = new File("target" + File.separator + this.getClass().getName());
    if (!ws.exists()) {
        Assert.assertTrue(ws.mkdirs());
    }
    SerialJobFactory jobFactory = new SerialJobFactory(submitter, jobProducer, new Path(ws.getAbsolutePath()), conf, startFlag, resolver);
    Path ioPath = new Path(ws.getAbsolutePath());
    jobFactory.setDistCacheEmulator(new DistributedCacheEmulator(conf, ioPath));
    Thread test = jobFactory.createReaderThread();
    test.start();
    Thread.sleep(1000);
    // SerialReaderThread waits startFlag
    assertEquals(0, submitter.getJobs().size());
    // start!
    startFlag.countDown();
    while (test.isAlive()) {
        Thread.sleep(1000);
        jobFactory.update(null);
    }
    // submitter was called twice
    assertEquals(2, submitter.getJobs().size());
}
Also used : JobStoryProducer(org.apache.hadoop.tools.rumen.JobStoryProducer) Path(org.apache.hadoop.fs.Path) ZombieJobProducer(org.apache.hadoop.tools.rumen.ZombieJobProducer) Configuration(org.apache.hadoop.conf.Configuration) CountDownLatch(java.util.concurrent.CountDownLatch) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 JobStoryProducer (org.apache.hadoop.tools.rumen.JobStoryProducer)1 ZombieJobProducer (org.apache.hadoop.tools.rumen.ZombieJobProducer)1 Test (org.junit.Test)1