Search in sources :

Example 1 with WorkflowDag

use of org.apache.hudi.integ.testsuite.dag.WorkflowDag in project hudi by apache.

the class TestWorkflowBuilder method testWorkloadOperationSequenceBuilder.

@Test
public void testWorkloadOperationSequenceBuilder() {
    DagNode root = new InsertNode(DeltaConfig.Config.newBuilder().withNumRecordsToInsert(10000).withNumInsertPartitions(1).withNumTimesToRepeat(2).withRecordSize(1000).build());
    DagNode child1 = new UpsertNode(DeltaConfig.Config.newBuilder().withNumRecordsToUpdate(10000).withNumInsertPartitions(1).withNumTimesToRepeat(2).withRecordSize(1000).build());
    root.addChildNode(child1);
    child1.addParentNode(root);
    List<DagNode> rootNodes = new ArrayList<>();
    rootNodes.add(root);
    WorkflowDag workflowDag = new WorkflowDag(rootNodes);
    assertEquals(workflowDag.getNodeList().size(), 1);
    assertEquals(((DagNode) workflowDag.getNodeList().get(0)).getChildNodes().size(), 1);
    DagNode dagNode = (DagNode) workflowDag.getNodeList().get(0);
    assertTrue(dagNode instanceof InsertNode);
    DeltaConfig.Config config = dagNode.getConfig();
    assertEquals(config.getNumInsertPartitions(), 1);
    assertEquals(config.getRecordSize(), 1000);
    assertEquals(config.getRepeatCount(), 2);
    assertEquals(config.getNumRecordsInsert(), 10000);
    assertEquals(config.getNumRecordsUpsert(), 0);
    dagNode = (DagNode) ((DagNode) workflowDag.getNodeList().get(0)).getChildNodes().get(0);
    assertTrue(dagNode instanceof UpsertNode);
    config = dagNode.getConfig();
    assertEquals(config.getNumInsertPartitions(), 1);
    assertEquals(config.getRecordSize(), 1000);
    assertEquals(config.getRepeatCount(), 2);
    assertEquals(config.getNumRecordsInsert(), 0);
    assertEquals(config.getNumRecordsUpsert(), 10000);
}
Also used : DagNode(org.apache.hudi.integ.testsuite.dag.nodes.DagNode) ArrayList(java.util.ArrayList) WorkflowDag(org.apache.hudi.integ.testsuite.dag.WorkflowDag) InsertNode(org.apache.hudi.integ.testsuite.dag.nodes.InsertNode) UpsertNode(org.apache.hudi.integ.testsuite.dag.nodes.UpsertNode) Test(org.junit.jupiter.api.Test)

Example 2 with WorkflowDag

use of org.apache.hudi.integ.testsuite.dag.WorkflowDag in project hudi by apache.

the class HoodieTestSuiteJob method runTestSuite.

public void runTestSuite() {
    try {
        WorkflowDag workflowDag = createWorkflowDag();
        log.info("Workflow Dag => " + DagUtils.convertDagToYaml(workflowDag));
        long startTime = System.currentTimeMillis();
        WriterContext writerContext = new WriterContext(jsc, props, cfg, keyGenerator, sparkSession);
        writerContext.initContext(jsc);
        startOtherServicesIfNeeded(writerContext);
        if (this.cfg.saferSchemaEvolution) {
            // rollback most recent upsert/insert, by default.
            int numRollbacks = 2;
            // if root is RollbackNode, get num_rollbacks
            List<DagNode> root = workflowDag.getNodeList();
            if (!root.isEmpty() && root.get(0) instanceof RollbackNode) {
                numRollbacks = root.get(0).getConfig().getNumRollbacks();
            }
            int version = getSchemaVersionFromCommit(numRollbacks - 1);
            SaferSchemaDagScheduler dagScheduler = new SaferSchemaDagScheduler(workflowDag, writerContext, jsc, version);
            dagScheduler.schedule();
        } else {
            DagScheduler dagScheduler = new DagScheduler(workflowDag, writerContext, jsc);
            dagScheduler.schedule();
        }
        log.info("Finished scheduling all tasks, Time taken {}", System.currentTimeMillis() - startTime);
    } catch (Exception e) {
        log.error("Failed to run Test Suite ", e);
        throw new HoodieException("Failed to run Test Suite ", e);
    } finally {
        stopQuietly();
    }
}
Also used : WriterContext(org.apache.hudi.integ.testsuite.dag.WriterContext) DagNode(org.apache.hudi.integ.testsuite.dag.nodes.DagNode) SaferSchemaDagScheduler(org.apache.hudi.integ.testsuite.dag.scheduler.SaferSchemaDagScheduler) DagScheduler(org.apache.hudi.integ.testsuite.dag.scheduler.DagScheduler) RollbackNode(org.apache.hudi.integ.testsuite.dag.nodes.RollbackNode) SaferSchemaDagScheduler(org.apache.hudi.integ.testsuite.dag.scheduler.SaferSchemaDagScheduler) WorkflowDag(org.apache.hudi.integ.testsuite.dag.WorkflowDag) HoodieException(org.apache.hudi.exception.HoodieException) HoodieException(org.apache.hudi.exception.HoodieException) IOException(java.io.IOException)

Aggregations

WorkflowDag (org.apache.hudi.integ.testsuite.dag.WorkflowDag)2 DagNode (org.apache.hudi.integ.testsuite.dag.nodes.DagNode)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HoodieException (org.apache.hudi.exception.HoodieException)1 WriterContext (org.apache.hudi.integ.testsuite.dag.WriterContext)1 InsertNode (org.apache.hudi.integ.testsuite.dag.nodes.InsertNode)1 RollbackNode (org.apache.hudi.integ.testsuite.dag.nodes.RollbackNode)1 UpsertNode (org.apache.hudi.integ.testsuite.dag.nodes.UpsertNode)1 DagScheduler (org.apache.hudi.integ.testsuite.dag.scheduler.DagScheduler)1 SaferSchemaDagScheduler (org.apache.hudi.integ.testsuite.dag.scheduler.SaferSchemaDagScheduler)1 Test (org.junit.jupiter.api.Test)1