Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
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/embedded/ZooKeeperServerEmbeddedImpl.java
package org.apache.zookeeper.server.embedded;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Properties;
import org.apache.zookeeper.server.DatadirCleanupManager;
import org.apache.zookeeper.server.ExitCode;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;
import org.apache.zookeeper.server.quorum.QuorumPeer;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
import org.apache.zookeeper.server.quorum.QuorumPeerMain;
import org.apache.zookeeper.util.ServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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.
*/
/**
* Implementation of ZooKeeperServerEmbedded.
*/
class ZooKeeperServerEmbeddedImpl implements ZooKeeperServerEmbedded {
private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperServerEmbeddedImpl.class);
private final QuorumPeerConfig config;
private QuorumPeerMain maincluster;
private ZooKeeperServerMain mainsingle;
private Thread thread;
private DatadirCleanupManager purgeMgr;
private final ExitHandler exitHandler;
private volatile boolean stopping;
ZooKeeperServerEmbeddedImpl(Properties p, Path baseDir, ExitHandler exitHandler) throws Exception {
if (!p.containsKey("dataDir")) {
p.put("dataDir", baseDir.resolve("data").toAbsolutePath().toString());
}
Path configFile = Files.createTempFile(baseDir, "zookeeper.configuration", ".properties");
try (OutputStream oo = Files.newOutputStream(configFile)) {
p.store(oo, "Automatically generated at every-boot");
}
this.exitHandler = exitHandler;
LOG.info("Current configuration is at {}", configFile.toAbsolutePath());
config = new QuorumPeerConfig();
config.parse(configFile.toAbsolutePath().toString());
LOG.info("ServerID:" + config.getServerId());
LOG.info("DataDir:" + config.getDataDir());
LOG.info("Servers:" + config.getServers());
LOG.info("ElectionPort:" + config.getElectionPort());
LOG.info("SyncLimit:" + config.getSyncLimit());
LOG.info("PeerType:" + config.getPeerType());
LOG.info("Distributed:" + config.isDistributed());
LOG.info("SyncEnabled:" + config.getSyncEnabled());
LOG.info("MetricsProviderClassName:" + config.getMetricsProviderClassName());
for (Map.Entry<Long, QuorumPeer.QuorumServer> server : config.getServers().entrySet()) {
LOG.info("Server: " + server.getKey() + " -> addr " + server.getValue().addr + " elect "
+ server.getValue().electionAddr + " id=" + server.getValue().id + " type "
+ server.getValue().type);
}
}
@Override
public void start() throws Exception {
switch (exitHandler) {
case EXIT:
ServiceUtils.setSystemExitProcedure(ServiceUtils.SYSTEM_EXIT);
break;
case LOG_ONLY:
ServiceUtils.setSystemExitProcedure(ServiceUtils.LOG_ONLY);
break;
default:
ServiceUtils.setSystemExitProcedure(ServiceUtils.SYSTEM_EXIT);
break;
}
if (config.getServers().size() > 1 || config.isDistributed()) {
LOG.info("Running ZK Server in single Quorum MODE");
maincluster = new QuorumPeerMain();
// Start and schedule the the purge task
purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
thread = new Thread("zkservermainrunner") {
@Override
public void run() {
try {
maincluster.runFromConfig(config);
maincluster.close();
LOG.info("ZK server died. Requsting stop on JVM");
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
}
} catch (Throwable t) {
LOG.error("error during server lifecycle", t);
maincluster.close();
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
}
}
}
};
thread.start();
} else {
LOG.info("Running ZK Server in single STANDALONE MODE");
mainsingle = new ZooKeeperServerMain();
purgeMgr = new DatadirCleanupManager(config
.getDataDir(), config.getDataLogDir(), config
.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
thread = new Thread("zkservermainrunner") {
@Override
public void run() {
try {
ServerConfig cc = new ServerConfig();
cc.readFrom(config);
LOG.info("ZK server starting");
mainsingle.runFromConfig(cc);
LOG.info("ZK server died. Requesting stop on JVM");
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
}
} catch (Throwable t) {
LOG.error("error during server lifecycle", t);
mainsingle.close();
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
}
}
}
};
thread.start();
}
}
@Override
public void close() {
LOG.info("Stopping ZK Server");
stopping = true;
if (mainsingle != null) {
mainsingle.close();
}
if (maincluster != null) {
maincluster.close();
}
}
}
⏎ org/apache/zookeeper/server/embedded/ZooKeeperServerEmbeddedImpl.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, ≈71🔥, 0💬
Popular Posts:
JDK 11 jdk.jfr.jmod is the JMOD file for JDK 11 JFR module. JDK 11 JFR module compiled class files a...
Apache Commons CLI Source Code Files are provided in the source package file commons-cli-1.5.0-sourc. ..
JAX-WS is an API for building web services and clients. It is the next generation Web Services API r...
JDK 11 java.sql.rowset.jmod is the JMOD file for JDK 11 SQL Rowset module. JDK 11 SQL Rowset module ...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...