diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 54516007d32a..c838cc70a3c5 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -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", diff --git a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java index a9b3c089c3f2..299abd0d44eb 100644 --- a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java +++ b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java @@ -124,6 +124,25 @@ public void testUnitFor() throws Exception { Assert.assertEquals(TimeUnit.NANOSECONDS, HiveConf.unitFor("nsecs", null)); } + @Test + public void testReplCmRetainTimeUnit() throws Exception { + 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"));