From 9a2994a5a3d889cc6ea469d331006de6a10acaa2 Mon Sep 17 00:00:00 2001 From: Laxman Goswami Date: Thu, 3 Dec 2020 14:31:49 +0530 Subject: [PATCH] HBASE-25230 Embedded zookeeper server not clean up the old data Closes #2732 Signed-off-by: maoling Signed-off-by: Viraj Jasani --- .../hadoop/hbase/zookeeper/HQuorumPeer.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java index 193b7c85c55..86f94516742 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java @@ -44,6 +44,9 @@ import org.apache.zookeeper.server.ZooKeeperServerMain; import org.apache.zookeeper.server.admin.AdminServer; import org.apache.zookeeper.server.quorum.QuorumPeerConfig; import org.apache.zookeeper.server.quorum.QuorumPeerMain; +import org.apache.zookeeper.server.DatadirCleanupManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * HBase's version of ZooKeeper's QuorumPeer. When HBase is set to manage @@ -84,6 +87,20 @@ public final class HQuorumPeer { private static void runZKServer(QuorumPeerConfig zkConfig) throws IOException, AdminServer.AdminServerException { + + /** + * Start and schedule the purge task + * autopurge.purgeInterval is 0 by default,so in fact the DatadirCleanupManager task will not + * be started to clean the logs by default. Config is recommended only for standalone server. + */ + + DatadirCleanupManager purgeMgr=new DatadirCleanupManager( + zkConfig.getDataDir(), + zkConfig.getDataLogDir(), + zkConfig.getSnapRetainCount(), + zkConfig.getPurgeInterval()); + purgeMgr.start(); + if (zkConfig.isDistributed()) { QuorumPeerMain qp = new QuorumPeerMain(); qp.runFromConfig(zkConfig);