[HUDI-2530] Adding async compaction support to integ test suite framework (#3750)
This commit is contained in:
committed by
GitHub
parent
10e3a9a3fb
commit
a818020f72
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hudi.integ.testsuite;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
@@ -236,7 +237,7 @@ public class HoodieTestSuiteWriter implements Serializable {
|
||||
|
||||
public Option<String> scheduleCompaction(Option<Map<String, String>> previousCommitExtraMetadata) throws
|
||||
Exception {
|
||||
if (!cfg.useDeltaStreamer) {
|
||||
if (cfg.useDeltaStreamer) {
|
||||
deltaStreamerWrapper.scheduleCompact();
|
||||
return Option.empty();
|
||||
} else {
|
||||
@@ -251,7 +252,7 @@ public class HoodieTestSuiteWriter implements Serializable {
|
||||
/** Store the checkpoint in the commit metadata just like
|
||||
* {@link HoodieDeltaStreamer#commit(SparkRDDWriteClient, JavaRDD, Option)} **/
|
||||
extraMetadata.put(HoodieDeltaStreamerWrapper.CHECKPOINT_KEY, lastCheckpoint.get());
|
||||
if (generatedDataStats != null) {
|
||||
if (generatedDataStats != null && generatedDataStats.count() > 1) {
|
||||
// Just stores the path where this batch of data is generated to
|
||||
extraMetadata.put(GENERATED_DATA_PATH, generatedDataStats.map(s -> s.getFilePath()).collect().get(0));
|
||||
}
|
||||
@@ -259,6 +260,21 @@ public class HoodieTestSuiteWriter implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void commitCompaction(JavaRDD<WriteStatus> records, JavaRDD<DeltaWriteStats> generatedDataStats,
|
||||
Option<String> instantTime) throws IOException {
|
||||
if (!cfg.useDeltaStreamer) {
|
||||
Map<String, String> extraMetadata = new HashMap<>();
|
||||
/** Store the checkpoint in the commit metadata just like
|
||||
* {@link HoodieDeltaStreamer#commit(SparkRDDWriteClient, JavaRDD, Option)} **/
|
||||
extraMetadata.put(HoodieDeltaStreamerWrapper.CHECKPOINT_KEY, lastCheckpoint.get());
|
||||
if (generatedDataStats != null && generatedDataStats.count() > 1) {
|
||||
// Just stores the path where this batch of data is generated to
|
||||
extraMetadata.put(GENERATED_DATA_PATH, generatedDataStats.map(s -> s.getFilePath()).collect().get(0));
|
||||
}
|
||||
writeClient.commitCompaction(instantTime.get(), records, Option.of(extraMetadata));
|
||||
}
|
||||
}
|
||||
|
||||
public SparkRDDWriteClient getWriteClient(DagNode dagNode) throws IllegalAccessException {
|
||||
if (cfg.useDeltaStreamer & !allowWriteClientAccess(dagNode)) {
|
||||
throw new IllegalAccessException("cannot access write client when testing in deltastreamer mode");
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.apache.hudi.common.table.timeline.HoodieInstant;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
import org.apache.hudi.integ.testsuite.configuration.DeltaConfig.Config;
|
||||
import org.apache.hudi.integ.testsuite.dag.ExecutionContext;
|
||||
|
||||
import org.apache.spark.api.java.JavaRDD;
|
||||
|
||||
/**
|
||||
@@ -40,8 +41,8 @@ public class CompactNode extends DagNode<JavaRDD<WriteStatus>> {
|
||||
* if it has one.
|
||||
*
|
||||
* @param executionContext Execution context to run this compaction
|
||||
* @param curItrCount cur interation count.
|
||||
* @throws Exception will be thrown if any error occurred.
|
||||
* @param curItrCount cur interation count.
|
||||
* @throws Exception will be thrown if any error occurred.
|
||||
*/
|
||||
@Override
|
||||
public void execute(ExecutionContext executionContext, int curItrCount) throws Exception {
|
||||
@@ -53,7 +54,7 @@ public class CompactNode extends DagNode<JavaRDD<WriteStatus>> {
|
||||
if (lastInstant.isPresent()) {
|
||||
log.info("Compacting instant {}", lastInstant.get());
|
||||
this.result = executionContext.getHoodieTestSuiteWriter().compact(Option.of(lastInstant.get().getTimestamp()));
|
||||
executionContext.getHoodieTestSuiteWriter().commitCompaction(result, executionContext.getJsc().emptyRDD(), Option.of(lastInstant.get().getTimestamp()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,5 +56,4 @@ public class ScheduleCompactNode extends DagNode<Option<String>> {
|
||||
this.result = scheduledInstant;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user