Search in sources :

Example 6 with HoodieLocalEngineContext

use of org.apache.hudi.common.engine.HoodieLocalEngineContext in project hudi by apache.

the class AbstractSyncHoodieClient method getPartitionsWrittenToSince.

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public List<String> getPartitionsWrittenToSince(Option<String> lastCommitTimeSynced) {
    if (!lastCommitTimeSynced.isPresent()) {
        LOG.info("Last commit time synced is not known, listing all partitions in " + basePath + ",FS :" + fs);
        HoodieLocalEngineContext engineContext = new HoodieLocalEngineContext(metaClient.getHadoopConf());
        return FSUtils.getAllPartitionPaths(engineContext, basePath, useFileListingFromMetadata, assumeDatePartitioning);
    } else {
        LOG.info("Last commit time synced is " + lastCommitTimeSynced.get() + ", Getting commits since then");
        return TimelineUtils.getPartitionsWritten(metaClient.getActiveTimeline().getCommitsTimeline().findInstantsAfter(lastCommitTimeSynced.get(), Integer.MAX_VALUE));
    }
}
Also used : HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext)

Example 7 with HoodieLocalEngineContext

use of org.apache.hudi.common.engine.HoodieLocalEngineContext in project hudi by apache.

the class TimelineService method main.

public static void main(String[] args) throws Exception {
    final Config cfg = new Config();
    JCommander cmd = new JCommander(cfg, null, args);
    if (cfg.help) {
        cmd.usage();
        System.exit(1);
    }
    Configuration conf = FSUtils.prepareHadoopConf(new Configuration());
    FileSystemViewManager viewManager = buildFileSystemViewManager(cfg, new SerializableConfiguration(conf));
    TimelineService service = new TimelineService(new HoodieLocalEngineContext(FSUtils.prepareHadoopConf(new Configuration())), new Configuration(), cfg, FileSystem.get(new Configuration()), viewManager);
    service.run();
}
Also used : FileSystemViewManager(org.apache.hudi.common.table.view.FileSystemViewManager) Configuration(org.apache.hadoop.conf.Configuration) SerializableConfiguration(org.apache.hudi.common.config.SerializableConfiguration) FileSystemViewStorageConfig(org.apache.hudi.common.table.view.FileSystemViewStorageConfig) HoodieCommonConfig(org.apache.hudi.common.config.HoodieCommonConfig) HoodieMetadataConfig(org.apache.hudi.common.config.HoodieMetadataConfig) JCommander(com.beust.jcommander.JCommander) SerializableConfiguration(org.apache.hudi.common.config.SerializableConfiguration) HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext)

Example 8 with HoodieLocalEngineContext

use of org.apache.hudi.common.engine.HoodieLocalEngineContext in project hudi by apache.

the class TestFSUtils method testDeleteNonExistingDir.

@Test
public void testDeleteNonExistingDir() throws IOException {
    String rootDir = basePath + "/.hoodie/.temp";
    FileSystem fileSystem = metaClient.getFs();
    cleanUpTestDirectory(fileSystem, rootDir);
    assertFalse(FSUtils.deleteDir(new HoodieLocalEngineContext(metaClient.getHadoopConf()), fileSystem, new Path(rootDir), 2));
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext) Test(org.junit.jupiter.api.Test)

Example 9 with HoodieLocalEngineContext

use of org.apache.hudi.common.engine.HoodieLocalEngineContext in project hudi by apache.

the class TestFSUtils method testDeleteExistingDir.

@Test
public void testDeleteExistingDir() throws IOException {
    String rootDir = basePath + "/.hoodie/.temp";
    FileSystem fileSystem = metaClient.getFs();
    prepareTestDirectory(fileSystem, rootDir);
    Path rootDirPath = new Path(rootDir);
    assertTrue(fileSystem.exists(rootDirPath));
    assertTrue(FSUtils.deleteDir(new HoodieLocalEngineContext(metaClient.getHadoopConf()), fileSystem, rootDirPath, 2));
    assertFalse(fileSystem.exists(rootDirPath));
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext) Test(org.junit.jupiter.api.Test)

Example 10 with HoodieLocalEngineContext

use of org.apache.hudi.common.engine.HoodieLocalEngineContext in project hudi by apache.

the class TestFSUtils method testGetFileStatusAtLevel.

@Test
public void testGetFileStatusAtLevel() throws IOException {
    String rootDir = basePath + "/.hoodie/.temp";
    FileSystem fileSystem = metaClient.getFs();
    prepareTestDirectory(fileSystem, rootDir);
    List<FileStatus> fileStatusList = FSUtils.getFileStatusAtLevel(new HoodieLocalEngineContext(fileSystem.getConf()), fileSystem, new Path(basePath), 3, 2);
    assertEquals(CollectionUtils.createImmutableSet(basePath + "/.hoodie/.temp/subdir1/file1.txt", basePath + "/.hoodie/.temp/subdir2/file2.txt"), fileStatusList.stream().map(fileStatus -> fileStatus.getPath().toString()).filter(filePath -> filePath.endsWith(".txt")).collect(Collectors.toSet()));
}
Also used : Path(org.apache.hadoop.fs.Path) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FileSystem(org.apache.hadoop.fs.FileSystem) Date(java.util.Date) HoodieException(org.apache.hudi.exception.HoodieException) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CollectionUtils(org.apache.hudi.common.util.CollectionUtils) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) EnvironmentVariables(org.junit.contrib.java.lang.system.EnvironmentVariables) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) HoodieTableConfig(org.apache.hudi.common.table.HoodieTableConfig) HoodieTableMetaClient(org.apache.hudi.common.table.HoodieTableMetaClient) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) HoodieLogFile(org.apache.hudi.common.model.HoodieLogFile) URI(java.net.URI) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext) HoodieActiveTimeline(org.apache.hudi.common.table.timeline.HoodieActiveTimeline) Files(java.nio.file.Files) IOException(java.io.IOException) UUID(java.util.UUID) HoodieCommonTestHarness(org.apache.hudi.common.testutils.HoodieCommonTestHarness) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) HOODIE_LOG(org.apache.hudi.common.model.HoodieFileFormat.HOODIE_LOG) List(java.util.List) Rule(org.junit.Rule) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SerializableConfiguration(org.apache.hudi.common.config.SerializableConfiguration) HoodieIOException(org.apache.hudi.exception.HoodieIOException) HoodieTestUtils(org.apache.hudi.common.testutils.HoodieTestUtils) Collections(java.util.Collections) FileStatus(org.apache.hadoop.fs.FileStatus) FileSystem(org.apache.hadoop.fs.FileSystem) HoodieLocalEngineContext(org.apache.hudi.common.engine.HoodieLocalEngineContext) Test(org.junit.jupiter.api.Test)

Aggregations

HoodieLocalEngineContext (org.apache.hudi.common.engine.HoodieLocalEngineContext)20 Path (org.apache.hadoop.fs.Path)15 Map (java.util.Map)10 FileStatus (org.apache.hadoop.fs.FileStatus)10 Test (org.junit.jupiter.api.Test)10 IOException (java.io.IOException)9 List (java.util.List)9 SerializableConfiguration (org.apache.hudi.common.config.SerializableConfiguration)8 Arrays (java.util.Arrays)7 Collections (java.util.Collections)7 HoodieMetadataConfig (org.apache.hudi.common.config.HoodieMetadataConfig)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ArrayList (java.util.ArrayList)6 Collectors (java.util.stream.Collectors)6 HoodieCommonTestHarness (org.apache.hudi.common.testutils.HoodieCommonTestHarness)6 IntStream (java.util.stream.IntStream)5 HoodieTestTable (org.apache.hudi.common.testutils.HoodieTestTable)5 AfterEach (org.junit.jupiter.api.AfterEach)5 Assertions (org.junit.jupiter.api.Assertions)5 Configuration (org.apache.hadoop.conf.Configuration)4