Search in sources :

Example 1 with ConsistencyGuardConfig

use of org.apache.hudi.common.fs.ConsistencyGuardConfig in project hudi by apache.

the class TestConsistencyGuard method testCheckPassingAppearAndDisAppear.

@ParameterizedTest
@MethodSource("consistencyGuardType")
public void testCheckPassingAppearAndDisAppear(String consistencyGuardType) throws Exception {
    FileCreateUtils.createBaseFile(basePath, "partition/path", "000", "f1");
    FileCreateUtils.createBaseFile(basePath, "partition/path", "000", "f2");
    FileCreateUtils.createBaseFile(basePath, "partition/path", "000", "f3");
    ConsistencyGuardConfig config = getConsistencyGuardConfig(1, 1000, 1000);
    ConsistencyGuard passing = consistencyGuardType.equals(FailSafeConsistencyGuard.class.getName()) ? new FailSafeConsistencyGuard(fs, config) : new OptimisticConsistencyGuard(fs, config);
    passing.waitTillFileAppears(new Path(basePath + "/partition/path/f1_1-0-1_000" + BASE_FILE_EXTENSION));
    passing.waitTillFileAppears(new Path(basePath + "/partition/path/f2_1-0-1_000" + BASE_FILE_EXTENSION));
    passing.waitTillAllFilesAppear(basePath + "/partition/path", Arrays.asList(basePath + "/partition/path/f1_1-0-1_000" + BASE_FILE_EXTENSION, basePath + "/partition/path/f2_1-0-1_000" + BASE_FILE_EXTENSION));
    fs.delete(new Path(basePath + "/partition/path/f1_1-0-1_000" + BASE_FILE_EXTENSION), false);
    fs.delete(new Path(basePath + "/partition/path/f2_1-0-1_000" + BASE_FILE_EXTENSION), false);
    passing.waitTillFileDisappears(new Path(basePath + "/partition/path/f1_1-0-1_000" + BASE_FILE_EXTENSION));
    passing.waitTillFileDisappears(new Path(basePath + "/partition/path/f2_1-0-1_000" + BASE_FILE_EXTENSION));
    passing.waitTillAllFilesDisappear(basePath + "/partition/path", Arrays.asList(basePath + "/partition/path/f1_1-0-1_000" + BASE_FILE_EXTENSION, basePath + "/partition/path/f2_1-0-1_000" + BASE_FILE_EXTENSION));
}
Also used : Path(org.apache.hadoop.fs.Path) ConsistencyGuard(org.apache.hudi.common.fs.ConsistencyGuard) FailSafeConsistencyGuard(org.apache.hudi.common.fs.FailSafeConsistencyGuard) OptimisticConsistencyGuard(org.apache.hudi.common.fs.OptimisticConsistencyGuard) ConsistencyGuardConfig(org.apache.hudi.common.fs.ConsistencyGuardConfig) FailSafeConsistencyGuard(org.apache.hudi.common.fs.FailSafeConsistencyGuard) OptimisticConsistencyGuard(org.apache.hudi.common.fs.OptimisticConsistencyGuard) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with ConsistencyGuardConfig

use of org.apache.hudi.common.fs.ConsistencyGuardConfig in project hudi by apache.

the class TestTableCommand method testConnectTable.

/**
 * Test Case for connect table.
 */
@Test
public void testConnectTable() {
    // Prepare table
    assertTrue(prepareTable());
    // Test connect with specified values
    CommandResult cr = shell().executeCommand("connect --path " + tablePath + " --initialCheckIntervalMs 3000 " + "--maxWaitIntervalMs 40000 --maxCheckIntervalMs 8");
    assertTrue(cr.isSuccess());
    // Check specified values
    ConsistencyGuardConfig conf = HoodieCLI.consistencyGuardConfig;
    assertEquals(3000, conf.getInitialConsistencyCheckIntervalMs());
    assertEquals(40000, conf.getMaxConsistencyCheckIntervalMs());
    assertEquals(8, conf.getMaxConsistencyChecks());
    // Check default values
    assertFalse(conf.isConsistencyCheckEnabled());
    assertEquals(new Integer(1), HoodieCLI.layoutVersion.getVersion());
}
Also used : ConsistencyGuardConfig(org.apache.hudi.common.fs.ConsistencyGuardConfig) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.jupiter.api.Test)

Aggregations

ConsistencyGuardConfig (org.apache.hudi.common.fs.ConsistencyGuardConfig)2 Path (org.apache.hadoop.fs.Path)1 ConsistencyGuard (org.apache.hudi.common.fs.ConsistencyGuard)1 FailSafeConsistencyGuard (org.apache.hudi.common.fs.FailSafeConsistencyGuard)1 OptimisticConsistencyGuard (org.apache.hudi.common.fs.OptimisticConsistencyGuard)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 CommandResult (org.springframework.shell.core.CommandResult)1