Search in sources :

Example 1 with MARKERS_FILENAME_PREFIX

use of org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX in project hudi by apache.

the class TestUpgradeDowngrade method getTimelineServerBasedMarkerFileCount.

private long getTimelineServerBasedMarkerFileCount(String markerDir, FileSystem fileSystem) throws IOException {
    FileStatus[] fileStatuses = fileSystem.listStatus(new Path(markerDir));
    Predicate<String> prefixFilter = pathStr -> pathStr.contains(MARKERS_FILENAME_PREFIX);
    return Arrays.stream(fileStatuses).map(fileStatus -> fileStatus.getPath().toString()).filter(prefixFilter).collect(Collectors.toList()).stream().count();
}
Also used : Path(org.apache.hadoop.fs.Path) HoodieTable(org.apache.hudi.table.HoodieTable) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FileSystem(org.apache.hadoop.fs.FileSystem) HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) TYPE(org.apache.hudi.common.table.HoodieTableConfig.TYPE) HoodieTestDataGenerator(org.apache.hudi.common.testutils.HoodieTestDataGenerator) FileStatus(org.apache.hadoop.fs.FileStatus) HoodieTableType(org.apache.hudi.common.model.HoodieTableType) HoodieConfig(org.apache.hudi.common.config.HoodieConfig) HoodieFileGroup(org.apache.hudi.common.model.HoodieFileGroup) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) HoodieTableConfig(org.apache.hudi.common.table.HoodieTableConfig) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) FileUtil(org.apache.hadoop.fs.FileUtil) WriteMarkers(org.apache.hudi.table.marker.WriteMarkers) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) MethodSource(org.junit.jupiter.params.provider.MethodSource) Predicate(java.util.function.Predicate) KeyGeneratorOptions(org.apache.hudi.keygen.constant.KeyGeneratorOptions) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) BASE_FILE_FORMAT(org.apache.hudi.common.table.HoodieTableConfig.BASE_FILE_FORMAT) List(java.util.List) Stream(java.util.stream.Stream) Assertions(org.apache.hudi.testutils.Assertions) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) HoodieClientTestUtils(org.apache.hudi.testutils.HoodieClientTestUtils) HoodieClientTestBase(org.apache.hudi.testutils.HoodieClientTestBase) Dataset(org.apache.spark.sql.Dataset) FileSlice(org.apache.hudi.common.model.FileSlice) Option(org.apache.hudi.common.util.Option) EnumSource(org.junit.jupiter.params.provider.EnumSource) HashMap(java.util.HashMap) DEFAULT_FIRST_PARTITION_PATH(org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_FIRST_PARTITION_PATH) ArrayList(java.util.ArrayList) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) MarkerType(org.apache.hudi.common.table.marker.MarkerType) MARKERS_FILENAME_PREFIX(org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX) HoodieTableMetaClient(org.apache.hudi.common.table.HoodieTableMetaClient) HoodieLogFile(org.apache.hudi.common.model.HoodieLogFile) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) JavaRDD(org.apache.spark.api.java.JavaRDD) TimelineLayoutVersion(org.apache.hudi.common.table.timeline.versioning.TimelineLayoutVersion) SyncableFileSystemView(org.apache.hudi.common.table.view.SyncableFileSystemView) HoodieRecord(org.apache.hudi.common.model.HoodieRecord) Properties(java.util.Properties) HoodieWriteConfig(org.apache.hudi.config.HoodieWriteConfig) WriteMarkersFactory(org.apache.hudi.table.marker.WriteMarkersFactory) DEFAULT_SECOND_PARTITION_PATH(org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH) IOException(java.io.IOException) Row(org.apache.spark.sql.Row) HoodieTableVersion(org.apache.hudi.common.table.HoodieTableVersion) WriteStatus(org.apache.hudi.client.WriteStatus) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) SparkRDDWriteClient(org.apache.hudi.client.SparkRDDWriteClient) HoodieTestUtils(org.apache.hudi.common.testutils.HoodieTestUtils) Pair(org.apache.hudi.common.util.collection.Pair) FileStatus(org.apache.hadoop.fs.FileStatus)

Example 2 with MARKERS_FILENAME_PREFIX

use of org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX in project hudi by apache.

the class TwoToOneDowngradeHandler method deleteTimelineBasedMarkerFiles.

private void deleteTimelineBasedMarkerFiles(HoodieEngineContext context, String markerDir, FileSystem fileSystem, int parallelism) throws IOException {
    // Deletes timeline based marker files if any.
    Predicate<FileStatus> prefixFilter = fileStatus -> fileStatus.getPath().getName().startsWith(MARKERS_FILENAME_PREFIX);
    FSUtils.parallelizeSubPathProcess(context, fileSystem, new Path(markerDir), parallelism, prefixFilter, pairOfSubPathAndConf -> FSUtils.deleteSubPath(pairOfSubPathAndConf.getKey(), pairOfSubPathAndConf.getValue(), false));
}
Also used : HoodieTable(org.apache.hudi.table.HoodieTable) FileSystem(org.apache.hadoop.fs.FileSystem) HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) HoodieException(org.apache.hudi.exception.HoodieException) Option(org.apache.hudi.common.util.Option) HoodieEngineContext(org.apache.hudi.common.engine.HoodieEngineContext) FileStatus(org.apache.hadoop.fs.FileStatus) MarkerType(org.apache.hudi.common.table.marker.MarkerType) MARKERS_FILENAME_PREFIX(org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX) HoodieTableMetaClient(org.apache.hudi.common.table.HoodieTableMetaClient) Map(java.util.Map) DirectWriteMarkers(org.apache.hudi.table.marker.DirectWriteMarkers) Path(org.apache.hadoop.fs.Path) HoodieTimeline(org.apache.hudi.common.table.timeline.HoodieTimeline) HoodieWriteConfig(org.apache.hudi.config.HoodieWriteConfig) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) MarkerUtils(org.apache.hudi.common.util.MarkerUtils) Collectors(java.util.stream.Collectors) List(java.util.List) ConfigProperty(org.apache.hudi.common.config.ConfigProperty) Collections(java.util.Collections) FSUtils(org.apache.hudi.common.fs.FSUtils) Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus)

Aggregations

IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 HoodieTableMetaClient (org.apache.hudi.common.table.HoodieTableMetaClient)2 MarkerType (org.apache.hudi.common.table.marker.MarkerType)2 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)2 MARKERS_FILENAME_PREFIX (org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX)2 Option (org.apache.hudi.common.util.Option)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1