Skip to content
Open
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
7 changes: 4 additions & 3 deletions common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,10 @@ public static enum ConfVars {
"Turn on ChangeManager, so delete files will go to cmrootdir."),
REPL_CM_DIR("hive.repl.cmrootdir","/user/${system:user.name}/cmroot/",
"Root dir for ChangeManager, used for deleted files."),
REPL_CM_RETAIN("hive.repl.cm.retain","10d",
new TimeValidator(TimeUnit.DAYS),
"Time to retain removed files in cmrootdir."),
REPL_CM_RETAIN("hive.repl.cm.retain","240h",
new TimeValidator(TimeUnit.HOURS),
"Time to retain removed files in cmrootdir. A unit-less value is interpreted in hours, "
+ "matching the metastore counterpart metastore.repl.cm.retain. Default is 240h (10 days)."),
REPL_CM_ENCRYPTED_DIR("hive.repl.cm.encryptionzone.rootdir", ".cmroot",
"Root dir for ChangeManager if encryption zones are enabled, used for deleted files."),
REPL_CM_FALLBACK_NONENCRYPTED_DIR("hive.repl.cm.nonencryptionzone.rootdir",
Expand Down
19 changes: 19 additions & 0 deletions common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@
Assert.assertEquals(TimeUnit.NANOSECONDS, HiveConf.unitFor("nsecs", null));
}

@Test
public void testReplCmRetainTimeUnit() throws Exception {

Check warning on line 128 in common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ_ZH4Ol4OfOpyy8hg-F&open=AZ_ZH4Ol4OfOpyy8hg-F&pullRequest=6682
HiveConf conf = new HiveConf();

// The default (240h) is 10 days. Guards against accidentally changing the default duration.
Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.DAYS));
Assert.assertEquals(240, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.HOURS));

// A unit-less value is interpreted in hours, matching the metastore counterpart
// metastore.repl.cm.retain, which uses a HOURS base unit.
Assert.assertEquals(TimeUnit.HOURS, HiveConf.getDefaultTimeUnit(ConfVars.REPL_CM_RETAIN));
conf.setVar(ConfVars.REPL_CM_RETAIN, "10");
Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.HOURS));

// An explicit unit suffix is still honoured.
conf.setVar(ConfVars.REPL_CM_RETAIN, "10d");
Assert.assertEquals(10, conf.getTimeVar(ConfVars.REPL_CM_RETAIN, TimeUnit.DAYS));
}

@Test
public void testToSizeBytes() throws Exception {
Assert.assertEquals(1L, HiveConf.toSizeBytes("1b"));
Expand Down