Example usage for java.lang Thread isAlive

List of usage examples for java.lang Thread isAlive

Introduction

In this page you can find the example usage for java.lang Thread isAlive.

Prototype

public final native boolean isAlive();

Source Link

Document

Tests if this thread is alive.

Usage

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Tests failures when the fail behaviour is FINISH_ALL_POSSIBLE.
 * In this case, all jobs which have had its pre-requisite met can continue
 * to run. Finishes when the failure is propagated to the last node of the
 * flow./* w ww  .jav a2 s.c o  m*/
 *
 * @throws Exception
 */
@Ignore
@Test
public void testFailedFinishingFailure3() throws Exception {
    // Test propagation of KILLED status to embedded flows different branch
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf", FailureAction.FINISH_ALL_POSSIBLE);
    ExecutableFlow flow = runner.getExecutableFlow();
    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(250);

    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 2. JOB in subflow FAILS
    InteractiveTestJob.getTestJob("joba").succeedJob();
    pause(250);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("joba1").succeedJob();
    InteractiveTestJob.getTestJob("jobb:innerJobA").succeedJob();
    pause(250);
    expectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("jobb:innerJobB").failJob();
    pause(250);
    expectedStateMap.put("jobb", Status.FAILED_FINISHING);
    expectedStateMap.put("jobb:innerJobB", Status.FAILED);
    Assert.assertEquals(Status.FAILED_FINISHING, flow.getStatus());
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("jobb:innerJobC").succeedJob();
    InteractiveTestJob.getTestJob("jobd:innerJobA").succeedJob();
    pause(250);
    expectedStateMap.put("jobb", Status.FAILED);
    expectedStateMap.put("jobd:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("jobd:innerFlow2", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobC", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerFlow", Status.CANCELLED);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("jobd:innerFlow2").succeedJob();
    pause(250);
    expectedStateMap.put("jobd:innerFlow2", Status.SUCCEEDED);
    expectedStateMap.put("jobd", Status.SUCCEEDED);

    // 3. jobc completes, everything is killed
    InteractiveTestJob.getTestJob("jobc").succeedJob();
    pause(250);
    expectedStateMap.put("jobc", Status.SUCCEEDED);
    expectedStateMap.put("jobe", Status.CANCELLED);
    expectedStateMap.put("jobf", Status.CANCELLED);
    compareStates(expectedStateMap, nodeMap);
    Assert.assertEquals(Status.FAILED, flow.getStatus());
    Assert.assertFalse(thread.isAlive());
}

From source file:com.gemstone.gemfire.internal.cache.OplogJUnitTest.java

/**
 * Tests the condition when a 'put' on an alreay created entry
 *  and concurrent 'clear' are happening.
 *  Thus if after HTree ref was set (in//from   w  ww.  j a  va 2 s.  c  o  m
 * 'put'), the region got cleared (and same key re-'put'),
 * the entry will actually become a create in the VM
 * The new Oplog should record it as a create even though the
 * Htree ref in ThreadLocal will not match with the
 * current Htree Ref. But the operation is valid & should get recorded
 * in Oplog
 *
 */
@Test
public void testPutClearCreate() {
    failure = false;
    try {
        // Create a persist only region with rolling true
        diskProps.setPersistBackup(true);
        diskProps.setRolling(true);
        diskProps.setMaxOplogSize(1024);
        diskProps.setSynchronous(true);

        region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);

        region.create("key1", "value1");
        LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = true;
        CacheObserverHolder.setInstance(new CacheObserverAdapter() {
            @Override
            public void afterSettingDiskRef() {
                Thread clearTh = new Thread(new Runnable() {
                    public void run() {
                        region.clear();
                    }
                });
                clearTh.start();
                try {
                    DistributedTestCase.join(clearTh, 120 * 1000, null);
                    failure = clearTh.isAlive();
                    failureCause = "Clear Thread still running !";
                } catch (Exception e) {
                    failure = true;
                    failureCause = e.toString();
                }
            }
        });
        region.put("key1", "value2");
        LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
        assertFalse(failureCause, failure);
        assertEquals(1, region.size());
        region.close();
        region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
        assertEquals(1, region.size());
        assertEquals("value2", (String) region.get("key1"));
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test failed due to exception" + e);
    } finally {
        testFailed = false;
        proceed = false;
        LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
        CacheObserverHolder.setInstance(new CacheObserverAdapter());
        failure = false;
    }
}

From source file:la2launcher.MainFrame.java

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

    Thread th = new Thread() {
        @Override//from  w w w  . j  ava2  s  . c  o  m
        public void run() {
            try {
                jTextArea2.setText(" ");
                File patch = File.createTempFile("patch", ".zip");
                patch.deleteOnExit();
                CloseableHttpClient httpclient = HttpClients.createDefault();
                HttpGet httpGet = new HttpGet(patchPath);
                CloseableHttpResponse response1 = httpclient.execute(httpGet);

                FileOutputStream fos = new FileOutputStream(patch);
                HttpEntity entity1 = response1.getEntity();
                copyStream(entity1.getContent(), fos, new CopyListener() {
                    @Override
                    public void transfered(int n) {
                        bytesRecieved += n;
                        bytesRecievedTotal += n;
                    }
                });
                response1.close();
                fos.close();
                jTextArea2.setText(jTextArea2.getText() + "\r\n ");

                try {
                    new DirDeltaPatcher().patch(new File(gamePath + "\\system"), patch);
                } catch (Exception e) {
                    jTextArea2.setText(jTextArea2.getText() + "\r\n" + e);
                    return;
                }
                jTextArea2.setText(jTextArea2.getText() + "\r\n? ");

            } catch (IOException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    };

    th.start();

    jButton5.setEnabled(false);
    jButton6.setEnabled(false);
    jButton7.setEnabled(false);
    jButton8.setEnabled(false);
    jButton10.setEnabled(false);
    jProgressBar1.setIndeterminate(true);
    new Thread() {
        @Override
        public void run() {
            do {
                long millis = new Date().getTime();
                try {
                    sleep(300);
                } catch (InterruptedException ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
                millis = new Date().getTime() - millis;
                BigDecimal totBig = new BigDecimal(bytesRecievedTotal / (1024 * 1024.0));
                totBig = totBig.setScale(2, BigDecimal.ROUND_CEILING);
                jLabel5.setText("?: " + (bytesRecieved / millis) + "KB/s. : "
                        + totBig + " MB");
                bytesRecieved = 0;
            } while (th.isAlive());

            jButton5.setEnabled(true);
            jButton6.setEnabled(true);
            jButton7.setEnabled(true);
            jButton8.setEnabled(true);
            jButton10.setEnabled(true);
            jProgressBar1.setIndeterminate(false);
        }
    }.start();

}

From source file:org.apache.flink.streaming.connectors.kafka.KafkaConsumerTestBase.java

/**
 * Test metrics reporting for consumer// w  ww .  ja va2 s.  c  o  m
 *
 * @throws Exception
 */
public void runMetricsTest() throws Throwable {

    // create a stream with 5 topics
    final String topic = "metricsStream";
    createTestTopic(topic, 5, 1);

    final Tuple1<Throwable> error = new Tuple1<>(null);
    Runnable job = new Runnable() {
        @Override
        public void run() {
            try {
                // start job writing & reading data.
                final StreamExecutionEnvironment env1 = StreamExecutionEnvironment
                        .createRemoteEnvironment("localhost", flinkPort);
                env1.setParallelism(1);
                env1.getConfig().setRestartStrategy(RestartStrategies.noRestart());
                env1.getConfig().disableSysoutLogging();
                env1.disableOperatorChaining(); // let the source read everything into the network buffers

                Properties props = new Properties();
                props.putAll(standardProps);
                props.putAll(secureProps);

                TypeInformationSerializationSchema<Tuple2<Integer, Integer>> schema = new TypeInformationSerializationSchema<>(
                        TypeInfoParser.<Tuple2<Integer, Integer>>parse("Tuple2<Integer, Integer>"),
                        env1.getConfig());
                DataStream<Tuple2<Integer, Integer>> fromKafka = env1
                        .addSource(kafkaServer.getConsumer(topic, schema, standardProps));
                fromKafka.flatMap(new FlatMapFunction<Tuple2<Integer, Integer>, Void>() {
                    @Override
                    public void flatMap(Tuple2<Integer, Integer> value, Collector<Void> out) throws Exception {// no op
                    }
                });

                DataStream<Tuple2<Integer, Integer>> fromGen = env1
                        .addSource(new RichSourceFunction<Tuple2<Integer, Integer>>() {
                            boolean running = true;

                            @Override
                            public void run(SourceContext<Tuple2<Integer, Integer>> ctx) throws Exception {
                                int i = 0;
                                while (running) {
                                    ctx.collect(Tuple2.of(i++, getRuntimeContext().getIndexOfThisSubtask()));
                                    Thread.sleep(1);
                                }
                            }

                            @Override
                            public void cancel() {
                                running = false;
                            }
                        });

                kafkaServer.produceIntoKafka(fromGen, topic, new KeyedSerializationSchemaWrapper<>(schema),
                        standardProps, null);

                env1.execute("Metrics test job");
            } catch (Throwable t) {
                LOG.warn("Got exception during execution", t);
                if (!(t.getCause() instanceof JobCancellationException)) { // we'll cancel the job
                    error.f0 = t;
                }
            }
        }
    };
    Thread jobThread = new Thread(job);
    jobThread.start();

    try {
        // connect to JMX
        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        // wait until we've found all 5 offset metrics
        Set<ObjectName> offsetMetrics = mBeanServer.queryNames(new ObjectName("*current-offsets*:*"), null);
        while (offsetMetrics.size() < 5) { // test will time out if metrics are not properly working
            if (error.f0 != null) {
                // fail test early
                throw error.f0;
            }
            offsetMetrics = mBeanServer.queryNames(new ObjectName("*current-offsets*:*"), null);
            Thread.sleep(50);
        }
        Assert.assertEquals(5, offsetMetrics.size());
        // we can't rely on the consumer to have touched all the partitions already
        // that's why we'll wait until all five partitions have a positive offset.
        // The test will fail if we never meet the condition
        while (true) {
            int numPosOffsets = 0;
            // check that offsets are correctly reported
            for (ObjectName object : offsetMetrics) {
                Object offset = mBeanServer.getAttribute(object, "Value");
                if ((long) offset >= 0) {
                    numPosOffsets++;
                }
            }
            if (numPosOffsets == 5) {
                break;
            }
            // wait for the consumer to consume on all partitions
            Thread.sleep(50);
        }

        // check if producer metrics are also available.
        Set<ObjectName> producerMetrics = mBeanServer.queryNames(new ObjectName("*KafkaProducer*:*"), null);
        Assert.assertTrue("No producer metrics found", producerMetrics.size() > 30);

        LOG.info("Found all JMX metrics. Cancelling job.");
    } finally {
        // cancel
        JobManagerCommunicationUtils.cancelCurrentJob(flink.getLeaderGateway(timeout));
    }

    while (jobThread.isAlive()) {
        Thread.sleep(50);
    }
    if (error.f0 != null) {
        throw error.f0;
    }

    deleteTestTopic(topic);
}

From source file:azkaban.execapp.FlowRunnerPipelineTest.java

@Ignore
@Test/*from w ww. j  a va2  s  .c  o m*/
public void testBasicPipelineLevel2Run2() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner previousRunner = createFlowRunner(eventCollector, "pipeline1_2", "prev");

    ExecutionOptions options = new ExecutionOptions();
    options.setPipelineExecutionId(previousRunner.getExecutableFlow().getExecutionId());
    options.setPipelineLevel(2);
    FlowWatcher watcher = new LocalFlowWatcher(previousRunner);
    FlowRunner pipelineRunner = createFlowRunner(eventCollector, "pipeline1_2", "pipe", options);
    pipelineRunner.setFlowWatcher(watcher);

    Map<String, Status> previousExpectedStateMap = new HashMap<String, Status>();
    Map<String, Status> pipelineExpectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> previousNodeMap = new HashMap<String, ExecutableNode>();
    Map<String, ExecutableNode> pipelineNodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow pipelineFlow = pipelineRunner.getExecutableFlow();
    ExecutableFlow previousFlow = previousRunner.getExecutableFlow();
    createExpectedStateMap(previousFlow, previousExpectedStateMap, previousNodeMap);
    createExpectedStateMap(pipelineFlow, pipelineExpectedStateMap, pipelineNodeMap);

    Thread thread1 = runFlowRunnerInThread(previousRunner);
    pause(250);
    Thread thread2 = runFlowRunnerInThread(pipelineRunner);
    pause(250);

    previousExpectedStateMap.put("pipeline1_1", Status.RUNNING);
    previousExpectedStateMap.put("pipeline1_1:innerJobA", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_1", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_1:innerJobA", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline1_1:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline1_1:innerJobA", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline1_1:innerFlow2", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline1_1:innerFlow2").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline1_1", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline1_1:innerFlow2", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline1_2", Status.RUNNING);
    previousExpectedStateMap.put("pipeline1_2:innerJobA", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_1:innerJobA", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1_1:innerJobA").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1_1:innerJobA", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_1:innerFlow2", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline1_2:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline1_2:innerJobA", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline1_2:innerFlow2", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_1:innerFlow2", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1_1:innerFlow2").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1_1", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_1:innerFlow2", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_2", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_2:innerJobA", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1_1:innerFlow2").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1_1", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_1:innerFlow2", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_2", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1_2:innerJobA", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline1_2:innerFlow2").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline1_2:innerFlow2", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline1_2", Status.SUCCEEDED);
    Assert.assertEquals(Status.SUCCEEDED, previousFlow.getStatus());
    Assert.assertFalse(thread1.isAlive());
    pipelineExpectedStateMap.put("pipeline1_2:innerJobA", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1_2:innerJobA").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1_2:innerJobA", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_2:innerFlow2", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1_2:innerFlow2").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1_2", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline1_2:innerFlow2", Status.SUCCEEDED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);
    Assert.assertEquals(Status.SUCCEEDED, pipelineFlow.getStatus());
    Assert.assertFalse(thread2.isAlive());
}

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Tests that pause and resume work/* w  ww  .j  a va 2 s  .  c o m*/
 *
 * @throws Exception
 */
@Ignore
@Test
public void testPause() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf");

    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow flow = runner.getExecutableFlow();
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(250);

    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    runner.pause("test");
    InteractiveTestJob.getTestJob("joba").succeedJob();
    // 2.1 JOB A COMPLETES SUCCESSFULLY AFTER PAUSE
    pause(250);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);
    Assert.assertEquals(flow.getStatus(), Status.PAUSED);

    // 2.2 Flow is unpaused
    runner.resume("test");
    pause(250);
    Assert.assertEquals(flow.getStatus(), Status.RUNNING);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.RUNNING);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 3. jobb:Inner completes
    runner.pause("test");

    /// innerJobA completes, but paused
    InteractiveTestJob.getTestJob("jobb:innerJobA")
            .succeedJob(Props.of("output.jobb.innerJobA", "jobb.innerJobA"));
    pause(250);
    expectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);

    runner.resume("test");
    pause(250);
    expectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    /// innerJobB, C completes
    InteractiveTestJob.getTestJob("jobb:innerJobB")
            .succeedJob(Props.of("output.jobb.innerJobB", "jobb.innerJobB"));
    InteractiveTestJob.getTestJob("jobb:innerJobC")
            .succeedJob(Props.of("output.jobb.innerJobC", "jobb.innerJobC"));
    pause(250);
    expectedStateMap.put("jobb:innerJobB", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerJobC", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerFlow", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 4. Finish up on inner flow for jobb
    InteractiveTestJob.getTestJob("jobb:innerFlow")
            .succeedJob(Props.of("output1.jobb", "test1", "output2.jobb", "test2"));
    pause(250);
    expectedStateMap.put("jobb:innerFlow", Status.SUCCEEDED);
    expectedStateMap.put("jobb", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);

    // 5. Finish jobc, jobd
    InteractiveTestJob.getTestJob("jobc").succeedJob(Props.of("output.jobc", "jobc"));
    pause(250);
    expectedStateMap.put("jobc", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);
    InteractiveTestJob.getTestJob("jobd:innerJobA").succeedJob();
    pause(250);
    InteractiveTestJob.getTestJob("jobd:innerFlow2").succeedJob();
    pause(250);
    expectedStateMap.put("jobd:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("jobd:innerFlow2", Status.SUCCEEDED);
    expectedStateMap.put("jobd", Status.SUCCEEDED);
    expectedStateMap.put("jobe", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 6. Finish off flow
    InteractiveTestJob.getTestJob("joba1").succeedJob();
    pause(250);
    InteractiveTestJob.getTestJob("jobe").succeedJob();
    pause(250);
    expectedStateMap.put("joba1", Status.SUCCEEDED);
    expectedStateMap.put("jobe", Status.SUCCEEDED);
    expectedStateMap.put("jobf", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("jobf").succeedJob();
    pause(250);
    expectedStateMap.put("jobf", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);
    Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());

    Assert.assertFalse(thread.isAlive());
}

From source file:gui.images.ImageHubExplorer.java

/**
 * This method sets the image of the specified history index as the
 * currently selected image and updates all the views.
 *
 * @param index Integer that is the history index of the image to select as
 * the current image./*from www.  j av a2 s .  c  o m*/
 */
private synchronized void setSelectedImageForHistoryIndex(int historyIndex) {
    // Update the selected image panels.
    BufferedImage photo = getPhoto(selectedImageHistory.get(historyIndex));
    selectedImagePanelClassNeighborMain.setImage(photo);
    selectedImagePanelClassNeighbor.setImage(photo);
    selectedImagePanelClass.setImage(photo);
    selectedImagePanelSearch.setImage(photo);
    int index = selectedImageHistory.get(historyIndex);
    // Update the labels with the new name.
    String shortPath = imgPaths.get(index).substring(workspace.getPath().length(),
            imgPaths.get(index).length());
    selectedImagePathLabelClassNeighborMain.setText(shortPath);
    selectedImagePathLabelClassNeighbor.setText(shortPath);
    selectedImagePathLabelClass.setText(shortPath);
    selectedImagePathLabelSearch.setText(shortPath);
    // Update the class colors.
    selectedImageLabelClassNeighborMain.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
    selectedImageLabelClassNeighbor.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
    selectedImageLabelClass.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
    selectedImageLabelSearch.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
    // Refresh the display.
    selectedImageLabelClassNeighborMain.setOpaque(true);
    selectedImageLabelClassNeighbor.setOpaque(true);
    selectedImageLabelClass.setOpaque(true);
    selectedImageLabelSearch.setOpaque(true);
    selectedImageLabelClassNeighborMain.repaint();
    selectedImageLabelClassNeighbor.repaint();
    selectedImageLabelClass.repaint();
    selectedImageLabelSearch.repaint();
    // Update the nearest neighbors and the reverse nearest neighbors.
    NeighborSetFinder nsf = getNSF();
    nnPanel.removeAll();
    rnnPanel.removeAll();
    nnPanel.revalidate();
    nnPanel.repaint();
    rnnPanel.revalidate();
    rnnPanel.repaint();
    int[][] kneighbors = nsf.getKNeighbors();
    for (int neighborIndex = 0; neighborIndex < neighborhoodSize; neighborIndex++) {
        BufferedImage thumb = thumbnails.get(kneighbors[index][neighborIndex]);
        try {
            Thread t = new Thread(new SetImageNeighborsHelper(nnPanel, thumb,
                    quantizedRepresentation.getLabelOf(kneighbors[index][neighborIndex]),
                    kneighbors[index][neighborIndex]));
            t.start();
            t.join(500);
            if (t.isAlive()) {
                t.interrupt();
            }
        } catch (Throwable thr) {
            System.err.println(thr.getMessage());
        }
    }
    ArrayList<Integer>[] rrns = rnnSetsAllK[neighborhoodSize - 1];
    if (rrns[index] != null && rrns[index].size() > 0) {
        for (int i = 0; i < rrns[index].size(); i++) {
            BufferedImage thumb = thumbnails.get(rrns[index].get(i));
            try {
                Thread t = new Thread(new SetImageNeighborsHelper(rnnPanel, thumb,
                        quantizedRepresentation.getLabelOf(rrns[index].get(i)), rrns[index].get(i)));
                t.start();
                t.join(500);
                if (t.isAlive()) {
                    t.interrupt();
                }
            } catch (Throwable thr) {
                System.err.println(thr.getMessage());
            }
        }
    }
    // Refresh the neighbor and reverse neighbor panels.
    nnPanel.revalidate();
    nnPanel.repaint();
    rnnPanel.revalidate();
    rnnPanel.repaint();
    // Visualize the neighbor occurrence profile of the selected image.
    DefaultPieDataset pieData = new DefaultPieDataset();
    for (int c = 0; c < numClasses; c++) {
        pieData.setValue(classNames[c], occurrenceProfilesAllK[neighborhoodSize - 1][index][c]);
    }
    JFreeChart chart = ChartFactory.createPieChart3D("occurrence profile", pieData, true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    PieRenderer prend = new PieRenderer(classColors);
    prend.setColor(plot, pieData);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(240, 200));
    occProfileChartHolder.removeAll();
    occProfileChartHolder.add(chartPanel);
    occProfileChartHolder.revalidate();
    occProfileChartHolder.repaint();
}

From source file:gui.images.ImageHubExplorer.java

/**
 * This method sets the image of the specified index as the currently
 * selected image and updates all the views.
 *
 * @param index Integer that is the index of the image to select as the
 * current image.//from  w w w  .ja  v a  2s.co m
 */
private synchronized void setSelectedImageForIndex(int index) {
    try {
        // Update the selected image panels.
        BufferedImage photo = getPhoto(index);
        selectedImagePanelClassNeighborMain.setImage(photo);
        selectedImagePanelClassNeighbor.setImage(photo);
        selectedImagePanelClass.setImage(photo);
        selectedImagePanelSearch.setImage(photo);
        String shortPath = imgPaths.get(index).substring(workspace.getPath().length(),
                imgPaths.get(index).length());
        // Update the labels with the new name.
        selectedImagePathLabelClassNeighborMain.setText(shortPath);
        selectedImagePathLabelClassNeighbor.setText(shortPath);
        selectedImagePathLabelClass.setText(shortPath);
        selectedImagePathLabelSearch.setText(shortPath);
        // Update the class colors.
        selectedImageLabelClassNeighborMain
                .setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
        selectedImageLabelClassNeighbor.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
        selectedImageLabelClass.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
        selectedImageLabelSearch.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]);
        // Refresh the display.
        selectedImageLabelClassNeighborMain.setOpaque(true);
        selectedImageLabelClassNeighbor.setOpaque(true);
        selectedImageLabelClass.setOpaque(true);
        selectedImageLabelSearch.setOpaque(true);
        selectedImageLabelClassNeighborMain.repaint();
        selectedImageLabelClassNeighbor.repaint();
        selectedImageLabelClass.repaint();
        selectedImageLabelSearch.repaint();
        // Update the history.
        if (selectedImageHistory == null) {
            selectedImageHistory = new ArrayList<>(200);
            selectedImageIndexInHistory = -1;
        }
        // Discard the future history.
        if (selectedImageIndexInHistory < selectedImageHistory.size() - 1) {
            for (int i = selectedImageHistory.size() - 1; i > selectedImageIndexInHistory; i--) {
                selectedImageHistory.remove(i);
            }
        }
        selectedImageHistory.add(index);
        selectedImageIndexInHistory = selectedImageHistory.size() - 1;
        // Update the nearest neighbors and the reverse nearest neighbors.
        NeighborSetFinder nsf = getNSF();
        nnPanel.removeAll();
        rnnPanel.removeAll();
        nnPanel.revalidate();
        nnPanel.repaint();
        rnnPanel.revalidate();
        rnnPanel.repaint();
        int[][] kneighbors = nsf.getKNeighbors();
        for (int neighborIndex = 0; neighborIndex < neighborhoodSize; neighborIndex++) {
            // Insert all the nearest neighbors to their panel.
            BufferedImage thumb = thumbnails.get(kneighbors[index][neighborIndex]);
            try {
                Thread t = new Thread(new SetImageNeighborsHelper(nnPanel, thumb,
                        quantizedRepresentation.getLabelOf(kneighbors[index][neighborIndex]),
                        kneighbors[index][neighborIndex]));
                t.start();
                t.join(500);
                if (t.isAlive()) {
                    t.interrupt();
                }
            } catch (Throwable thr) {
                System.err.println(thr.getMessage());
            }
        }
        // Insert all the reverse nearest neighbors to their panel.
        ArrayList<Integer>[] rrns = null;
        if (rnnSetsAllK != null) {
            rrns = rnnSetsAllK[neighborhoodSize - 1];
        }
        if (rrns != null && rrns[index] != null && rrns[index].size() > 0) {
            for (int i = 0; i < rrns[index].size(); i++) {
                BufferedImage thumb = thumbnails.get(rrns[index].get(i));
                try {
                    Thread t = new Thread(new SetImageNeighborsHelper(rnnPanel, thumb,
                            quantizedRepresentation.getLabelOf(rrns[index].get(i)), rrns[index].get(i)));
                    t.start();
                    t.join(500);
                    if (t.isAlive()) {
                        t.interrupt();
                    }
                } catch (Throwable thr) {
                    System.err.println(thr.getMessage());
                }
            }
        }
        // Refresh the neighbor and reverse neighbor panels.
        nnPanel.revalidate();
        nnPanel.repaint();
        rnnPanel.revalidate();
        rnnPanel.repaint();
        // Visualize the neighbor occurrence profile of the selected image.
        DefaultPieDataset pieData = new DefaultPieDataset();
        for (int c = 0; c < numClasses; c++) {
            pieData.setValue(classNames[c], occurrenceProfilesAllK[neighborhoodSize - 1][index][c]);
        }
        JFreeChart chart = ChartFactory.createPieChart3D("occurrence " + "profile", pieData, true, true, false);
        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        PieRenderer prend = new PieRenderer(classColors);
        prend.setColor(plot, pieData);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(240, 200));
        occProfileChartHolder.removeAll();
        occProfileChartHolder.add(chartPanel);
        occProfileChartHolder.revalidate();
        occProfileChartHolder.repaint();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:azkaban.execapp.FlowRunnerPipelineTest.java

@Ignore
@Test/*from   w  w w.j a  va  2s  . com*/
public void testBasicPipelineLevel2Run() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner previousRunner = createFlowRunner(eventCollector, "pipelineFlow", "prev");

    ExecutionOptions options = new ExecutionOptions();
    options.setPipelineExecutionId(previousRunner.getExecutableFlow().getExecutionId());
    options.setPipelineLevel(2);
    FlowWatcher watcher = new LocalFlowWatcher(previousRunner);
    FlowRunner pipelineRunner = createFlowRunner(eventCollector, "pipelineFlow", "pipe", options);
    pipelineRunner.setFlowWatcher(watcher);

    Map<String, Status> previousExpectedStateMap = new HashMap<String, Status>();
    Map<String, Status> pipelineExpectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> previousNodeMap = new HashMap<String, ExecutableNode>();
    Map<String, ExecutableNode> pipelineNodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow pipelineFlow = pipelineRunner.getExecutableFlow();
    ExecutableFlow previousFlow = previousRunner.getExecutableFlow();
    createExpectedStateMap(previousFlow, previousExpectedStateMap, previousNodeMap);
    createExpectedStateMap(pipelineFlow, pipelineExpectedStateMap, pipelineNodeMap);

    Thread thread1 = runFlowRunnerInThread(previousRunner);
    pause(250);
    Thread thread2 = runFlowRunnerInThread(pipelineRunner);
    pause(250);

    previousExpectedStateMap.put("pipeline1", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline1").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline1", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline2", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline2").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline2", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3", Status.RUNNING);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobA", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline1", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline1").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline1", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline2", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipelineEmbeddedFlow3:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobA", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobB", Status.RUNNING);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobC", Status.RUNNING);
    pipelineExpectedStateMap.put("pipeline2", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline2").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline2", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3", Status.RUNNING);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobA", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipelineEmbeddedFlow3:innerJobB").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobB", Status.SUCCEEDED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipelineEmbeddedFlow3:innerJobC").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.RUNNING);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobC", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobA", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipelineEmbeddedFlow3:innerJobA").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobA", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobC", Status.QUEUED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobB", Status.QUEUED);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipelineEmbeddedFlow3:innerFlow").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipelineEmbeddedFlow3", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipeline4", Status.RUNNING);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobC", Status.RUNNING);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobB", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipelineEmbeddedFlow3:innerJobB").succeedJob();
    InteractiveTestJob.getTestJob("pipe:pipelineEmbeddedFlow3:innerJobC").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobC", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerJobB", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipeline4").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipeline4", Status.SUCCEEDED);
    previousExpectedStateMap.put("pipelineFlow", Status.RUNNING);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:pipelineFlow").succeedJob();
    pause(250);
    previousExpectedStateMap.put("pipelineFlow", Status.SUCCEEDED);
    Assert.assertEquals(Status.SUCCEEDED, previousFlow.getStatus());
    Assert.assertFalse(thread1.isAlive());
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipelineEmbeddedFlow3:innerFlow").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3:innerFlow", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineEmbeddedFlow3", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipeline4", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipeline4").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipeline4", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("pipelineFlow", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:pipelineFlow").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("pipelineFlow", Status.SUCCEEDED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);
    Assert.assertEquals(Status.SUCCEEDED, pipelineFlow.getStatus());
    Assert.assertFalse(thread2.isAlive());
}

From source file:azkaban.execapp.FlowRunnerPipelineTest.java

@Ignore
@Test//w w w .j  a v  a 2s  . c  om
public void testBasicPipelineLevel1Run() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner previousRunner = createFlowRunner(eventCollector, "jobf", "prev");

    ExecutionOptions options = new ExecutionOptions();
    options.setPipelineExecutionId(previousRunner.getExecutableFlow().getExecutionId());
    options.setPipelineLevel(1);
    FlowWatcher watcher = new LocalFlowWatcher(previousRunner);
    FlowRunner pipelineRunner = createFlowRunner(eventCollector, "jobf", "pipe", options);
    pipelineRunner.setFlowWatcher(watcher);

    Map<String, Status> previousExpectedStateMap = new HashMap<String, Status>();
    Map<String, Status> pipelineExpectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> previousNodeMap = new HashMap<String, ExecutableNode>();
    Map<String, ExecutableNode> pipelineNodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow pipelineFlow = pipelineRunner.getExecutableFlow();
    ExecutableFlow previousFlow = previousRunner.getExecutableFlow();
    createExpectedStateMap(previousFlow, previousExpectedStateMap, previousNodeMap);
    createExpectedStateMap(pipelineFlow, pipelineExpectedStateMap, pipelineNodeMap);

    Thread thread1 = runFlowRunnerInThread(previousRunner);
    pause(250);
    Thread thread2 = runFlowRunnerInThread(pipelineRunner);
    pause(500);

    previousExpectedStateMap.put("joba", Status.RUNNING);
    previousExpectedStateMap.put("joba1", Status.RUNNING);
    pipelineExpectedStateMap.put("joba", Status.QUEUED);
    pipelineExpectedStateMap.put("joba1", Status.QUEUED);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:joba").succeedJob();
    pause(250);
    previousExpectedStateMap.put("joba", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobb", Status.RUNNING);
    previousExpectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    previousExpectedStateMap.put("jobd", Status.RUNNING);
    previousExpectedStateMap.put("jobc", Status.RUNNING);
    previousExpectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    pipelineExpectedStateMap.put("joba", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:jobb:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    previousExpectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:joba").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("joba", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb", Status.RUNNING);
    pipelineExpectedStateMap.put("jobd", Status.RUNNING);
    pipelineExpectedStateMap.put("jobc", Status.QUEUED);
    pipelineExpectedStateMap.put("jobd:innerJobA", Status.QUEUED);
    pipelineExpectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:jobd:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobd:innerJobA", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobd:innerFlow2", Status.RUNNING);
    pipelineExpectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    // Finish the previous d side
    InteractiveTestJob.getTestJob("prev:jobd:innerFlow2").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobd:innerFlow2", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobd", Status.SUCCEEDED);
    compareStates(previousExpectedStateMap, previousNodeMap);

    InteractiveTestJob.getTestJob("prev:jobb:innerJobB").succeedJob();
    InteractiveTestJob.getTestJob("prev:jobb:innerJobC").succeedJob();
    InteractiveTestJob.getTestJob("prev:jobc").succeedJob();
    pause(250);
    InteractiveTestJob.getTestJob("pipe:jobb:innerJobA").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobb:innerJobB", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobb:innerJobC", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobb:innerFlow", Status.RUNNING);
    previousExpectedStateMap.put("jobc", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobc", Status.RUNNING);
    pipelineExpectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    pipelineExpectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("prev:jobb:innerFlow").succeedJob();
    InteractiveTestJob.getTestJob("pipe:jobc").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobb:innerFlow", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobb", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobe", Status.RUNNING);
    pipelineExpectedStateMap.put("jobc", Status.SUCCEEDED);

    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:jobb:innerJobB").succeedJob();
    InteractiveTestJob.getTestJob("pipe:jobb:innerJobC").succeedJob();
    InteractiveTestJob.getTestJob("prev:jobe").succeedJob();
    pause(250);
    previousExpectedStateMap.put("jobe", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb:innerJobB", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb:innerJobC", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb:innerFlow", Status.RUNNING);

    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:jobd:innerJobA").succeedJob();
    InteractiveTestJob.getTestJob("pipe:jobb:innerFlow").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("jobb", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobd:innerJobA", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobb:innerFlow", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobd:innerFlow2", Status.RUNNING);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:jobd:innerFlow2").succeedJob();
    InteractiveTestJob.getTestJob("prev:joba1").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("jobd:innerFlow2", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobd", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobf", Status.RUNNING);
    previousExpectedStateMap.put("joba1", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("joba1", Status.RUNNING);
    pipelineExpectedStateMap.put("jobe", Status.RUNNING);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);
    compareStates(previousExpectedStateMap, previousNodeMap);

    InteractiveTestJob.getTestJob("pipe:jobe").succeedJob();
    InteractiveTestJob.getTestJob("prev:jobf").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("jobe", Status.SUCCEEDED);
    previousExpectedStateMap.put("jobf", Status.SUCCEEDED);
    Assert.assertEquals(Status.SUCCEEDED, previousFlow.getStatus());
    compareStates(previousExpectedStateMap, previousNodeMap);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:joba1").succeedJob();
    pause(250);
    pipelineExpectedStateMap.put("joba1", Status.SUCCEEDED);
    pipelineExpectedStateMap.put("jobf", Status.RUNNING);
    compareStates(pipelineExpectedStateMap, pipelineNodeMap);

    InteractiveTestJob.getTestJob("pipe:jobf").succeedJob();
    pause(250);
    Assert.assertEquals(Status.SUCCEEDED, pipelineFlow.getStatus());
    Assert.assertFalse(thread1.isAlive());
    Assert.assertFalse(thread2.isAlive());
}