Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public class HoodieWriteConfig extends HoodieConfig {

public static final ConfigProperty<String> MARKERS_TYPE = ConfigProperty
.key("hoodie.write.markers.type")
.defaultValue(MarkerType.DIRECT.toString())
.defaultValue(MarkerType.TIMELINE_SERVER_BASED.toString())
.sinceVersion("0.9.0")
.withDocumentation("Marker type to use. Two modes are supported: "
+ "- DIRECT: individual marker file corresponding to each data file is directly "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ protected Option<Path> create(String partitionPath, String dataFileName, IOType
LOG.info("[timeline-server-based] Created marker file " + partitionPath + "/" + markerFileName
+ " in " + timer.endTimer() + " ms");
if (success) {
return Option.of(new Path(new Path(markerDirPath, partitionPath), markerFileName));
if (partitionPath.isEmpty()) {
return Option.of(new Path(markerDirPath, markerFileName));
} else {
return Option.of(new Path(new Path(markerDirPath, partitionPath), markerFileName));
}
} else {
return Option.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Map<ConfigProperty, String> downgrade(
List<HoodieInstant> commits = inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
for (HoodieInstant inflightInstant : commits) {
// delete existing markers
String markerType = config.getMarkersType().name();
WriteMarkers writeMarkers = WriteMarkersFactory.get(config.getMarkersType(), table, inflightInstant.getTimestamp());
writeMarkers.quietDeleteMarkerDir(context, config.getMarkersDeleteParallelism());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.hudi.common.model.HoodieRecord;
import org.apache.hudi.common.model.HoodieTableType;
import org.apache.hudi.common.table.HoodieTableMetaClient;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.testutils.HoodieTestDataGenerator;
import org.apache.hudi.common.testutils.HoodieTestUtils;
import org.apache.hudi.common.testutils.RawTripTestPayload;
Expand Down Expand Up @@ -114,7 +115,8 @@ private HoodieWriteConfig.Builder makeHoodieClientConfigBuilder() {
return HoodieWriteConfig.newBuilder()
.withEngineType(EngineType.JAVA)
.withPath(basePath)
.withSchema(SCHEMA.toString());
.withSchema(SCHEMA.toString())
.withMarkersType(MarkerType.DIRECT.name());
}

@Test
Expand Down Expand Up @@ -413,6 +415,7 @@ public void testInsertUpsertWithHoodieAvroPayload() throws Exception {
.withEngineType(EngineType.JAVA)
.withPath(basePath)
.withSchema(schema.toString())
.withMarkersType(MarkerType.DIRECT.name())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any plan/ticket to convert all these tests to timeline based markers? Or by design these still have to be direct type?

.withStorageConfig(HoodieStorageConfig.newBuilder()
.parquetMaxFileSize(1000 * 1024).hfileMaxFileSize(1000 * 1024).build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hudi.common.model.HoodieTableType;
import org.apache.hudi.common.model.TableServiceType;
import org.apache.hudi.common.model.WriteConcurrencyMode;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
import org.apache.hudi.common.table.view.FileSystemViewStorageType;
Expand Down Expand Up @@ -212,6 +213,7 @@ private void testMultiWriterWithAsyncTableServicesWithConflict(HoodieTableType t
.withFailedWritesCleaningPolicy(HoodieFailedWritesCleaningPolicy.LAZY)
.withMaxNumDeltaCommitsBeforeCompaction(2).build())
.withEmbeddedTimelineServerEnabled(false)
.withMarkersType(MarkerType.DIRECT.name())
.withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder().withStorageType(
FileSystemViewStorageType.MEMORY).build())
.withClusteringConfig(HoodieClusteringConfig.newBuilder().withInlineClusteringNumCommits(1).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.hudi.common.model.HoodieRecord;
import org.apache.hudi.common.model.HoodieTableType;
import org.apache.hudi.common.table.HoodieTableMetaClient;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
import org.apache.hudi.common.testutils.HoodieTestDataGenerator;
Expand Down Expand Up @@ -77,6 +78,7 @@ protected HoodieWriteConfig getHoodieWriteConfig(String basePath, boolean enable
.withSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA).withParallelism(2, 2).forTable(tableName)
.withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(HoodieIndex.IndexType.BLOOM).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(enableMetadata).build())
.withMarkersType(MarkerType.DIRECT.name())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hudi.common.model.HoodieKey;
import org.apache.hudi.common.model.HoodieRecord;
import org.apache.hudi.common.model.HoodieRecordLocation;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
import org.apache.hudi.common.testutils.HoodieTestUtils;
import org.apache.hudi.common.testutils.RawTripTestPayload;
Expand Down Expand Up @@ -228,6 +229,8 @@ public void testSchemaEvolutionOnUpdateMisMatchWithChangeColumnType() throws Exc

private HoodieWriteConfig makeHoodieClientConfig(String name) {
Schema schema = getSchemaFromResource(getClass(), name);
return HoodieWriteConfig.newBuilder().withPath(basePath).withSchema(schema.toString()).build();
return HoodieWriteConfig.newBuilder().withPath(basePath)
.withMarkersType(MarkerType.DIRECT.name())
.withSchema(schema.toString()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hudi.common.table.HoodieTableConfig;
import org.apache.hudi.common.table.HoodieTableMetaClient;
import org.apache.hudi.common.table.HoodieTableVersion;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
Expand Down Expand Up @@ -1265,6 +1266,7 @@ private HoodieWriteConfig getSmallInsertWriteConfig(int insertSplitSize, String
.hfileMaxFileSize(dataGen.getEstimatedFileSizeInBytes(200))
.parquetMaxFileSize(dataGen.getEstimatedFileSizeInBytes(200)).build())
.withMergeAllowDuplicateOnInserts(mergeAllowDuplicateInserts)
.withMarkersType(MarkerType.DIRECT.name())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.hudi.common.model.IOType;
import org.apache.hudi.common.model.WriteOperationType;
import org.apache.hudi.common.table.HoodieTableMetaClient;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
Expand Down Expand Up @@ -495,7 +496,7 @@ void assertNodupesInPartition(List<HoodieRecord> records) {
@ParameterizedTest
@MethodSource("populateMetaFieldsParams")
public void testUpserts(boolean populateMetaFields) throws Exception {
HoodieWriteConfig.Builder cfgBuilder = getConfigBuilder().withRollbackUsingMarkers(true);
HoodieWriteConfig.Builder cfgBuilder = getConfigBuilder().withRollbackUsingMarkers(true).withMarkersType(MarkerType.DIRECT.name());
addConfigsForPopulateMetaFields(cfgBuilder, populateMetaFields);
testUpsertsInternal(cfgBuilder.build(), SparkRDDWriteClient::upsert, false);
}
Expand All @@ -506,7 +507,7 @@ public void testUpserts(boolean populateMetaFields) throws Exception {
@ParameterizedTest
@MethodSource("populateMetaFieldsParams")
public void testUpsertsPrepped(boolean populateMetaFields) throws Exception {
HoodieWriteConfig.Builder cfgBuilder = getConfigBuilder().withRollbackUsingMarkers(true);
HoodieWriteConfig.Builder cfgBuilder = getConfigBuilder().withRollbackUsingMarkers(true).withMarkersType(MarkerType.DIRECT.name());
addConfigsForPopulateMetaFields(cfgBuilder, populateMetaFields);
testUpsertsInternal(cfgBuilder.build(), SparkRDDWriteClient::upsertPreppedRecords, true);
}
Expand All @@ -524,8 +525,11 @@ private void testUpsertsInternal(HoodieWriteConfig config,
// Force using older timeline layout
HoodieWriteConfig hoodieWriteConfig = getConfigBuilder(HoodieFailedWritesCleaningPolicy.LAZY)
.withRollbackUsingMarkers(true)
.withMarkersType(MarkerType.DIRECT.name()) // in this test, we directly operate with HoodieMergeHandle and so timeline server is not available for such
// operations
.withProps(config.getProps()).withTimelineLayoutVersion(
VERSION_0).build();
LOG.warn("Enabled " + hoodieWriteConfig.isEmbeddedTimelineServerEnabled() + ", " + config.isEmbeddedTimelineServerEnabled());

HoodieTableMetaClient.withPropertyBuilder()
.fromMetaClient(metaClient)
Expand Down Expand Up @@ -561,8 +565,10 @@ private void testUpsertsInternal(HoodieWriteConfig config,
0, 150, config.populateMetaFields());

// Now simulate an upgrade and perform a restore operation
HoodieWriteConfig newConfig = getConfigBuilder().withProps(config.getProps()).withTimelineLayoutVersion(
TimelineLayoutVersion.CURR_VERSION).build();
HoodieWriteConfig newConfig = getConfigBuilder().withProps(config.getProps())
.withTimelineLayoutVersion(TimelineLayoutVersion.CURR_VERSION)
.withMarkersType(MarkerType.DIRECT.name()).build();
LOG.warn("timeline server " + newConfig.isEmbeddedTimelineServerEnabled());
client = getHoodieWriteClient(newConfig);
client.restoreToInstant("004");

Expand Down Expand Up @@ -2014,7 +2020,7 @@ public void testConsistencyCheckDuringFinalize(boolean enableOptimisticConsisten
HoodieTableMetaClient metaClient = HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(basePath).build();
String instantTime = "000";
HoodieWriteConfig cfg = getConfigBuilder().withAutoCommit(false).withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder()
.withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard).build()).build();
.withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard).build()).withMarkersType(MarkerType.DIRECT.name()).build();
SparkRDDWriteClient client = getHoodieWriteClient(cfg);
Pair<Path, JavaRDD<WriteStatus>> result = testConsistencyCheck(metaClient, instantTime, enableOptimisticConsistencyGuard);

Expand Down Expand Up @@ -2045,10 +2051,12 @@ private void testRollbackAfterConsistencyCheckFailureUsingFileList(boolean rollb
properties = getPropertiesForKeyGen();
}

HoodieWriteConfig cfg = !enableOptimisticConsistencyGuard ? getConfigBuilder().withRollbackUsingMarkers(rollbackUsingMarkers).withAutoCommit(false)
HoodieWriteConfig cfg = !enableOptimisticConsistencyGuard ? getConfigBuilder().withRollbackUsingMarkers(rollbackUsingMarkers)
.withAutoCommit(false).withMarkersType(MarkerType.DIRECT.name())
.withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder().withConsistencyCheckEnabled(true)
.withMaxConsistencyCheckIntervalMs(1).withInitialConsistencyCheckIntervalMs(1).withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard).build()).build() :
getConfigBuilder().withRollbackUsingMarkers(rollbackUsingMarkers).withAutoCommit(false)
.withMarkersType(MarkerType.DIRECT.name())
.withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder()
.withConsistencyCheckEnabled(true)
.withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard)
Expand Down Expand Up @@ -2280,10 +2288,12 @@ private Pair<Path, JavaRDD<WriteStatus>> testConsistencyCheck(HoodieTableMetaCli
HoodieWriteConfig cfg = !enableOptimisticConsistencyGuard ? (getConfigBuilder().withAutoCommit(false)
.withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder().withConsistencyCheckEnabled(true)
.withMaxConsistencyCheckIntervalMs(1).withInitialConsistencyCheckIntervalMs(1).withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard).build())
.withMarkersType(MarkerType.DIRECT.name())
.build()) : (getConfigBuilder().withAutoCommit(false)
.withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder().withConsistencyCheckEnabled(true)
.withEnableOptimisticConsistencyGuard(enableOptimisticConsistencyGuard)
.withOptimisticConsistencyGuardSleepTimeMs(1).build())
.withMarkersType(MarkerType.DIRECT.name())
.build());
SparkRDDWriteClient client = getHoodieWriteClient(cfg);

Expand Down Expand Up @@ -2448,6 +2458,7 @@ private HoodieWriteConfig getParallelWritingWriteConfig(HoodieFailedWritesCleani
.withTimelineLayoutVersion(1)
.withHeartbeatIntervalInMs(3 * 1000)
.withAutoCommit(false)
.withMarkersType(MarkerType.DIRECT.name())
.withProperties(populateMetaFields ? new Properties() : getPropertiesForKeyGen()).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.hudi.common.config.HoodieMetadataConfig;
import org.apache.hudi.common.model.HoodieCommitMetadata;
import org.apache.hudi.common.model.HoodieTableType;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.testutils.HoodieMetadataTestTable;
import org.apache.hudi.common.testutils.HoodieTestDataGenerator;
import org.apache.hudi.common.testutils.HoodieTestTable;
Expand Down Expand Up @@ -242,6 +243,7 @@ private HoodieWriteConfig getWriteConfig(int minArchivalCommits, int maxArchival
.withSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA).withParallelism(2, 2)
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(minArchivalCommits, maxArchivalCommits).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.forTable("test-trip-table").build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hudi.common.model.HoodieTableType;
import org.apache.hudi.common.model.WriteOperationType;
import org.apache.hudi.common.table.HoodieTableMetaClient;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.timeline.HoodieInstant.State;
Expand Down Expand Up @@ -124,6 +125,7 @@ private HoodieWriteConfig initTestTableAndGetWriteConfig(boolean enableMetadata,
HoodieTableType tableType) throws Exception {
init(tableType);
HoodieWriteConfig writeConfig = HoodieWriteConfig.newBuilder().withPath(basePath)
.withMarkersType(MarkerType.DIRECT.name())
.withSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA).withParallelism(2, 2)
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(minArchivalCommits, maxArchivalCommits).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(enableMetadata)
Expand Down Expand Up @@ -211,6 +213,7 @@ public void testArchiveCommitSavepointNoHole() throws Exception {
.withSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA).withParallelism(2, 2).forTable("test-trip-table")
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(2, 5).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.build();

HoodieTestDataGenerator.createCommitFile(basePath, "100", wrapperFs.getConf());
Expand Down Expand Up @@ -329,6 +332,7 @@ public void testArchiveCommitTimeline() throws Exception {
.withParallelism(2, 2).forTable("test-trip-table")
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(2, 3).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.build();
metaClient = HoodieTableMetaClient.reload(metaClient);

Expand Down Expand Up @@ -485,6 +489,7 @@ public void testArchiveCompletedRollbackAndClean() throws Exception {
.withParallelism(2, 2).forTable("test-trip-table")
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(minInstantsToKeep, maxInstantsToKeep).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.build();
metaClient = HoodieTableMetaClient.reload(metaClient);

Expand Down Expand Up @@ -520,6 +525,7 @@ public void testArchiveInflightClean() throws Exception {
.withParallelism(2, 2).forTable("test-trip-table")
.withCompactionConfig(HoodieCompactionConfig.newBuilder().retainCommits(1).archiveCommitsWith(2, 3).build())
.withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.build();
metaClient = HoodieTableMetaClient.reload(metaClient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hudi.common.config.HoodieMetadataConfig;
import org.apache.hudi.common.model.HoodieRecord;
import org.apache.hudi.common.model.HoodieWriteStat;
import org.apache.hudi.common.table.marker.MarkerType;
import org.apache.hudi.common.testutils.HoodieTestDataGenerator;
import org.apache.hudi.config.HoodieWriteConfig;
import org.apache.hudi.exception.HoodieInsertException;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void tearDown() throws Exception {
@Test
public void testRowCreateHandle() throws Exception {
// init config and table
HoodieWriteConfig cfg = SparkDatasetTestUtils.getConfigBuilder(basePath).build();
HoodieWriteConfig cfg = SparkDatasetTestUtils.getConfigBuilder(basePath).withMarkersType(MarkerType.DIRECT.name()).build();
HoodieTable table = HoodieSparkTable.create(cfg, context, metaClient);
List<String> fileNames = new ArrayList<>();
List<String> fileAbsPaths = new ArrayList<>();
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testRowCreateHandle() throws Exception {
@Test
public void testGlobalFailure() throws Exception {
// init config and table
HoodieWriteConfig cfg = SparkDatasetTestUtils.getConfigBuilder(basePath).build();
HoodieWriteConfig cfg = SparkDatasetTestUtils.getConfigBuilder(basePath).withMarkersType(MarkerType.DIRECT.name()).build();
HoodieTable table = HoodieSparkTable.create(cfg, context, metaClient);
String partitionPath = HoodieTestDataGenerator.DEFAULT_PARTITION_PATHS[0];

Expand Down Expand Up @@ -170,6 +171,7 @@ public void testGlobalFailure() throws Exception {
public void testInstantiationFailure() throws IOException {
// init config and table
HoodieWriteConfig cfg = SparkDatasetTestUtils.getConfigBuilder(basePath).withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(false).build())
.withMarkersType(MarkerType.DIRECT.name())
.withPath("/dummypath/abc/").build();
HoodieTable table = HoodieSparkTable.create(cfg, context, metaClient);

Expand Down
Loading