Categories:
Audio (13)
Biotech (29)
Bytecode (35)
Database (77)
Framework (7)
Game (7)
General (512)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (86)
JavaBeans (16)
JDBC (89)
JDK (337)
JSP (20)
Logging (103)
Mail (54)
Messaging (8)
Network (71)
PDF (94)
Report (7)
Scripting (83)
Security (32)
Server (119)
Servlet (17)
SOAP (24)
Testing (50)
Web (19)
XML (301)
Other Resources:
Apache ZooKeeper Server Source Code
Apache ZooKeeper is an open-source server which enables highly
reliable distributed coordination.
Apache ZooKeeper Server Source Code files are provided in the source packge (apache-zookeeper-3.7.0.tar.gz). You can download it at Apache ZooKeeper Website.
You can also browse Apache ZooKeeper Server Source Code below:
✍: FYIcenter.com
⏎ org/apache/zookeeper/server/DatadirCleanupManager.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.zookeeper.server; import java.io.File; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This class manages the cleanup of snapshots and corresponding transaction * logs by scheduling the auto purge task with the specified * 'autopurge.purgeInterval'. It keeps the most recent * 'autopurge.snapRetainCount' number of snapshots and corresponding transaction * logs. */ public class DatadirCleanupManager { private static final Logger LOG = LoggerFactory.getLogger(DatadirCleanupManager.class); /** * Status of the dataDir purge task */ public enum PurgeTaskStatus { NOT_STARTED, STARTED, COMPLETED } private PurgeTaskStatus purgeTaskStatus = PurgeTaskStatus.NOT_STARTED; private final File snapDir; private final File dataLogDir; private final int snapRetainCount; private final int purgeInterval; private Timer timer; /** * Constructor of DatadirCleanupManager. It takes the parameters to schedule * the purge task. * * @param snapDir * snapshot directory * @param dataLogDir * transaction log directory * @param snapRetainCount * number of snapshots to be retained after purge * @param purgeInterval * purge interval in hours */ public DatadirCleanupManager(File snapDir, File dataLogDir, int snapRetainCount, int purgeInterval) { this.snapDir = snapDir; this.dataLogDir = dataLogDir; this.snapRetainCount = snapRetainCount; this.purgeInterval = purgeInterval; LOG.info("autopurge.snapRetainCount set to {}", snapRetainCount); LOG.info("autopurge.purgeInterval set to {}", purgeInterval); } /** * Validates the purge configuration and schedules the purge task. Purge * task keeps the most recent <code>snapRetainCount</code> number of * snapshots and deletes the remaining for every <code>purgeInterval</code> * hour(s). * <p> * <code>purgeInterval</code> of <code>0</code> or * <code>negative integer</code> will not schedule the purge task. * </p> * * @see PurgeTxnLog#purge(File, File, int) */ public void start() { if (PurgeTaskStatus.STARTED == purgeTaskStatus) { LOG.warn("Purge task is already running."); return; } // Don't schedule the purge task with zero or negative purge interval. if (purgeInterval <= 0) { LOG.info("Purge task is not scheduled."); return; } timer = new Timer("PurgeTask", true); TimerTask task = new PurgeTask(dataLogDir, snapDir, snapRetainCount); timer.scheduleAtFixedRate(task, 0, TimeUnit.HOURS.toMillis(purgeInterval)); purgeTaskStatus = PurgeTaskStatus.STARTED; } /** * Shutdown the purge task. */ public void shutdown() { if (PurgeTaskStatus.STARTED == purgeTaskStatus) { LOG.info("Shutting down purge task."); timer.cancel(); purgeTaskStatus = PurgeTaskStatus.COMPLETED; } else { LOG.warn("Purge task not started. Ignoring shutdown!"); } } static class PurgeTask extends TimerTask { private File logsDir; private File snapsDir; private int snapRetainCount; public PurgeTask(File dataDir, File snapDir, int count) { logsDir = dataDir; snapsDir = snapDir; snapRetainCount = count; } @Override public void run() { LOG.info("Purge task started."); try { PurgeTxnLog.purge(logsDir, snapsDir, snapRetainCount); } catch (Exception e) { LOG.error("Error occurred while purging.", e); } LOG.info("Purge task completed."); } } /** * Returns the status of the purge task. * * @return the status of the purge task */ public PurgeTaskStatus getPurgeTaskStatus() { return purgeTaskStatus; } /** * Returns the snapshot directory. * * @return the snapshot directory. */ public File getSnapDir() { return snapDir; } /** * Returns transaction log directory. * * @return the transaction log directory. */ public File getDataLogDir() { return dataLogDir; } /** * Returns purge interval in hours. * * @return the purge interval in hours. */ public int getPurgeInterval() { return purgeInterval; } /** * Returns the number of snapshots to be retained after purge. * * @return the number of snapshots to be retained after purge. */ public int getSnapRetainCount() { return snapRetainCount; } }
⏎ org/apache/zookeeper/server/DatadirCleanupManager.java
Â
⇒ Apache ZooKeeper Jute Source Code
⇑ Downloading and Reviewing zookeeper.jar
⇑⇑ FAQ for Apache ZooKeeper
2018-10-18, 29073👍, 1💬
Popular Posts:
JDK 11 jdk.internal.le.jmod is the JMOD file for JDK 11 Internal Line Editing module. JDK 11 Interna...
How to read XML document with XML Schema validation from socket connections with the socket\DelayedI...
What Is commons-io-2.6.jar? commons-io-2.6.jar is the JAR file for Commons IO 2.5, which is a librar...
How to download and install ojdbc14.jar for Oracle 10g R2? ojdbc14.jar for Oracle 10g R2 is a Java 1...
Woodstox, Release 3.2.8 is a high-performance validating namespace-aware StAX-compliant (JSR-173) Op...