HBASE-25230 Embedded zookeeper server not clean up the old data

Closes #2732

Signed-off-by: maoling <maoling199210191@sina.com>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Laxman Goswami 2020-12-03 14:31:49 +05:30 committed by Viraj Jasani
parent 946fa81715
commit fa257539ca
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
1 changed files with 15 additions and 0 deletions

View File

@ -44,6 +44,7 @@ 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;
@ -88,6 +89,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);