Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache ZooKeeper 3.7.0 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
Or download all of them as a single archive file:
File name: zookeeper-server-3.7.0-fyi.zip File size: 871011 bytes Release date: 2021-05-17 Download
⇒ Apache ZooKeeper 3.7.0 Jute Source Code
⇐ Download Apache ZooKeeper 3.7.0 Source Package
2022-11-16, 24899👍, 0💬
Popular Posts:
Joda-Time provides a quality replacement for the Java date and time classes. The design allows for m...
JDK 17 jdk.compiler.jmod is the JMOD file for JDK 17 Compiler tool, which can be invoked by the "jav...
JDK 11 java.compiler.jmod is the JMOD file for JDK 11 Compiler module. JDK 11 Compiler module compil...
commons-collections4-4.2 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...
maven-core-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Core module. Apache Maven is a software ...