Search in sources :

Example 6 with HoodieRollbackRequest

use of org.apache.hudi.avro.model.HoodieRollbackRequest in project hudi by apache.

the class TestMarkerBasedRollbackStrategy method testMarkerBasedRollbackAppend.

@Test
public void testMarkerBasedRollbackAppend() throws Exception {
    HoodieTestTable testTable = HoodieTestTable.of(metaClient);
    String f0 = testTable.addRequestedCommit("000").getFileIdsWithBaseFilesInPartitions("partA").get("partA");
    testTable.forCommit("001").withMarkerFile("partA", f0, IOType.APPEND);
    HoodieTable hoodieTable = HoodieSparkTable.create(getConfig(), context, metaClient);
    List<HoodieRollbackRequest> rollbackRequests = new MarkerBasedRollbackStrategy(hoodieTable, context, getConfig(), "002").getRollbackRequests(new HoodieInstant(HoodieInstant.State.INFLIGHT, HoodieTimeline.COMMIT_ACTION, "001"));
    assertEquals(1, rollbackRequests.size());
}
Also used : HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) HoodieTestTable(org.apache.hudi.common.testutils.HoodieTestTable) HoodieTable(org.apache.hudi.table.HoodieTable) HoodieRollbackRequest(org.apache.hudi.avro.model.HoodieRollbackRequest) MarkerBasedRollbackStrategy(org.apache.hudi.table.action.rollback.MarkerBasedRollbackStrategy) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with HoodieRollbackRequest

use of org.apache.hudi.avro.model.HoodieRollbackRequest in project hudi by apache.

the class TestMarkerBasedRollbackStrategy method testRun.

private List<HoodieRollbackStat> testRun(boolean useFileListingMetadata, HoodieWriteConfig writeConfig, SparkRDDWriteClient writeClient) {
    String newCommitTime = "001";
    writeClient.startCommitWithTime(newCommitTime);
    List<HoodieRecord> records = dataGen.generateInserts(newCommitTime, 100);
    JavaRDD<WriteStatus> writeStatuses = writeClient.insert(jsc.parallelize(records, 1), newCommitTime);
    writeClient.commit(newCommitTime, writeStatuses);
    // Updates
    newCommitTime = "002";
    writeClient.startCommitWithTime(newCommitTime);
    records = dataGen.generateUniqueUpdates(newCommitTime, 50);
    writeStatuses = writeClient.upsert(jsc.parallelize(records, 1), newCommitTime);
    writeStatuses.collect();
    HoodieTable hoodieTable = HoodieSparkTable.create(getConfig(), context, metaClient);
    List<HoodieRollbackRequest> rollbackRequests = new MarkerBasedRollbackStrategy(hoodieTable, context, getConfig(), "003").getRollbackRequests(new HoodieInstant(HoodieInstant.State.INFLIGHT, HoodieTimeline.DELTA_COMMIT_ACTION, "002"));
    // rollback 2nd commit and ensure stats reflect the info.
    return new BaseRollbackHelper(hoodieTable.getMetaClient(), getConfig()).performRollback(context, new HoodieInstant(HoodieInstant.State.INFLIGHT, HoodieTimeline.DELTA_COMMIT_ACTION, "002"), rollbackRequests);
}
Also used : HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) BaseRollbackHelper(org.apache.hudi.table.action.rollback.BaseRollbackHelper) HoodieRecord(org.apache.hudi.common.model.HoodieRecord) HoodieTable(org.apache.hudi.table.HoodieTable) WriteStatus(org.apache.hudi.client.WriteStatus) HoodieRollbackRequest(org.apache.hudi.avro.model.HoodieRollbackRequest) MarkerBasedRollbackStrategy(org.apache.hudi.table.action.rollback.MarkerBasedRollbackStrategy)

Aggregations

HoodieRollbackRequest (org.apache.hudi.avro.model.HoodieRollbackRequest)7 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)4 IOException (java.io.IOException)3 HoodieTable (org.apache.hudi.table.HoodieTable)3 MarkerBasedRollbackStrategy (org.apache.hudi.table.action.rollback.MarkerBasedRollbackStrategy)3 Path (org.apache.hadoop.fs.Path)2 HoodieTestTable (org.apache.hudi.common.testutils.HoodieTestTable)2 HoodieRollbackException (org.apache.hudi.exception.HoodieRollbackException)2 BaseRollbackHelper (org.apache.hudi.table.action.rollback.BaseRollbackHelper)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 HoodieInstantInfo (org.apache.hudi.avro.model.HoodieInstantInfo)1 HoodieRollbackPlan (org.apache.hudi.avro.model.HoodieRollbackPlan)1 WriteStatus (org.apache.hudi.client.WriteStatus)1 HoodieRollbackStat (org.apache.hudi.common.HoodieRollbackStat)1 HoodieLogFile (org.apache.hudi.common.model.HoodieLogFile)1 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)1