- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.zookeeper.server.ZooKeeperServer
类的一些代码示例,展示了ZooKeeperServer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperServer
类的具体详情如下:
包路径:org.apache.zookeeper.server.ZooKeeperServer
类名称:ZooKeeperServer
[英]This class implements a simple standalone ZooKeeperServer. It sets up the following chain of RequestProcessors to process requests: PrepRequestProcessor -> SyncRequestProcessor -> FinalRequestProcessor
[中]这个类实现了一个简单的独立ZookePerserver。它设置了以下请求处理器链来处理请求:PreRequestProcessor->SyncRequestProcessor->FinalRequestProcessor
代码示例来源:origin: alibaba/jstorm
public static Factory mkInprocessZookeeper(String localDir, int port)
throws IOException, InterruptedException {
LOG.info("Starting in-process zookeeper at port " + port + " and dir " + localDir);
File localFile = new File(localDir);
ZooKeeperServer zk = new ZooKeeperServer(localFile, localFile, 2000);
Factory factory = new Factory(new InetSocketAddress(port), 0);
factory.startup(zk);
return factory;
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
final ZooKeeperServer zkServer = new ZooKeeperServer();
zkServer.registerServerShutdownHandler(
new ZooKeeperServerShutdownHandler(shutdownLatch));
txnLog.setServerStats(zkServer.serverStats());
zkServer.setTxnLogFactory(txnLog);
zkServer.setTickTime(config.tickTime);
zkServer.setMinSessionTimeout(config.minSessionTimeout);
zkServer.setMaxSessionTimeout(config.maxSessionTimeout);
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(),
config.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
cnxnFactory.join();
if (zkServer.canShutdown()) {
zkServer.shutdown(true);
代码示例来源:origin: apache/hbase
/**
* Kill one back up ZK servers.
*
* @throws IOException if waiting for the shutdown of a server fails
*/
public void killOneBackupZooKeeperServer() throws IOException, InterruptedException {
if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) {
return ;
}
int backupZKServerIndex = activeZKServerIndex+1;
// Shutdown the current active one
NIOServerCnxnFactory standaloneServerFactory =
standaloneServerFactoryList.get(backupZKServerIndex);
int clientPort = clientPortList.get(backupZKServerIndex);
standaloneServerFactory.shutdown();
if (!waitForServerDown(clientPort, connectionTimeout)) {
throw new IOException("Waiting for shutdown of standalone server");
}
zooKeeperServers.get(backupZKServerIndex).getZKDatabase().close();
// remove this backup zk server
standaloneServerFactoryList.remove(backupZKServerIndex);
clientPortList.remove(backupZKServerIndex);
zooKeeperServers.remove(backupZKServerIndex);
LOG.info("Kill one backup ZK servers in the cluster " +
"on client port: " + clientPort);
}
代码示例来源:origin: prestodb/presto
public EmbeddedZookeeper(int port)
throws IOException
{
this.port = port;
zkDataDir = Files.createTempDir();
zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir);
zkServer.setTxnLogFactory(ftxn);
cnxnFactory = NIOServerCnxnFactory.createFactory(new InetSocketAddress(port), 0);
}
代码示例来源:origin: apache/zookeeper
private ZooKeeperServer setupSessionTracker() throws IOException {
File tmpDir = ClientBase.createTmpDir();
ClientBase.setupTestEnv();
ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
zks.setupRequestProcessors();
firstProcessor = new FirstProcessor(zks, null);
zks.firstProcessor = firstProcessor;
// setup session tracker
zks.createSessionTracker();
zks.startSessionTracker();
return zks;
}
代码示例来源:origin: apache/zookeeper
/**
* Creates a ZooKeeperServer instance. It sets everything up, but doesn't
* actually start listening for clients until run() is invoked.
*
* @param dataDir the directory to put the data
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
int minSessionTimeout, int maxSessionTimeout, ZKDatabase zkDb) {
serverStats = new ServerStats(this);
this.txnLogFactory = txnLogFactory;
this.txnLogFactory.setServerStats(this.serverStats);
this.zkDb = zkDb;
this.tickTime = tickTime;
setMinSessionTimeout(minSessionTimeout);
setMaxSessionTimeout(maxSessionTimeout);
listener = new ZooKeeperServerListenerImpl(this);
readResponseCache = new ResponseCache();
connThrottle = new BlueThrottle();
LOG.info("Created server with tickTime " + tickTime
+ " minSessionTimeout " + getMinSessionTimeout()
+ " maxSessionTimeout " + getMaxSessionTimeout()
+ " datadir " + txnLogFactory.getDataDir()
+ " snapdir " + txnLogFactory.getSnapDir());
}
代码示例来源:origin: apache/hbase
ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
server.setMinSessionTimeout(configuration.getInt(
"hbase.zookeeper.property.minSessionTimeout", -1));
server.setMaxSessionTimeout(configuration.getInt(
"hbase.zookeeper.property.maxSessionTimeout", -1));
NIOServerCnxnFactory standaloneServerFactory;
while (true) {
try {
standaloneServerFactory = new NIOServerCnxnFactory();
standaloneServerFactory.configure(
new InetSocketAddress(currentClientPort),
configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS,
HConstants.DEFAULT_ZOOKEEPER_MAX_CLIENT_CNXNS));
standaloneServerFactory.startup(server);
代码示例来源:origin: apache/zookeeper
public void testSnapshot() throws Exception {
File snapDir = new File(testData, "invalidsnap");
ZooKeeperServer zks = new ZooKeeperServer(snapDir, snapDir, 3000);
SyncRequestProcessor.setSnapCount(1000);
final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
f.startup(zks);
LOG.info("starting up the zookeeper server .. waiting");
Assert.assertTrue("waiting for server being up",
zk.close();
f.shutdown();
zks.shutdown();
Assert.assertTrue("waiting for server down",
ClientBase.waitForServerDown(HOSTPORT,
代码示例来源:origin: org.apache.atlas/atlas-notification
private String startZk() throws IOException, InterruptedException, URISyntaxException {
String zkValue = properties.getProperty("zookeeper.connect");
LOG.info("Starting zookeeper at {}", zkValue);
URL zkAddress = getURL(zkValue);
File snapshotDir = constructDir("zk/txn");
File logDir = constructDir("zk/snap");
factory = NIOServerCnxnFactory.createFactory(new InetSocketAddress(zkAddress.getHost(), zkAddress.getPort()), 1024);
factory.startup(new ZooKeeperServer(snapshotDir, logDir, 500));
String ret = factory.getLocalAddress().getAddress().toString();
LOG.info("Embedded zookeeper for Kafka started at {}", ret);
return ret;
}
代码示例来源:origin: apache/zookeeper
@Test
public void testGetSecureClientAddress() throws IOException {
ZooKeeperServer zks = new ZooKeeperServer();
/**
* case 1: When secure client is not configured getSecureClientAddress
* should return empty string
*/
ZooKeeperServerBean serverBean = new ZooKeeperServerBean(zks);
String result = serverBean.getSecureClientPort();
assertEquals("", result);
/**
* case 2: When secure client is configured getSecureClientAddress
* should return configured SecureClientAddress
*/
ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
int secureClientPort = 8443;
InetSocketAddress address = new InetSocketAddress(secureClientPort);
cnxnFactory.configure(address, 5, true);
zks.setSecureServerCnxnFactory(cnxnFactory);
result = serverBean.getSecureClientAddress();
String ipv4 = "0.0.0.0:" + secureClientPort;
String ipv6 = "0:0:0:0:0:0:0:0:" + secureClientPort;
assertTrue(result.equals(ipv4) || result.equals(ipv6));
// cleanup
cnxnFactory.shutdown();
}
代码示例来源:origin: alibaba/mdrill
public ServerCnxnFactory mkInprocessZookeeper(String localdir, int port)
throws IOException, InterruptedException {
LOG.info("Starting inprocess zookeeper at port " + port + " and dir "
+ localdir);
File localfile = new File(localdir);
ZooKeeperServer zk = new ZooKeeperServer(localfile, localfile, 2000);
ServerCnxnFactory factory =NIOServerCnxnFactory.createFactory(
new InetSocketAddress(port),60);
factory.startup(zk);
return factory;
}
代码示例来源:origin: debezium/debezium
this.factory = ServerCnxnFactory.createFactory(new InetSocketAddress("localhost", port), 1024);
if ( this.dataDir == null ) {
try {
server = new ZooKeeperServer(snapshotDir, logDir, tickTime);
factory.startup(server);
return this;
} catch (InterruptedException e) {
代码示例来源:origin: apache/zookeeper
zkDb = zs.getZKDatabase();
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
new InetSocketAddress("127.0.0.1", port1)));
peers.put(Long.valueOf(2), new QuorumServer(2,
代码示例来源:origin: stackoverflow.com
int clientPort = 2199; // not standard
int numConnections = 5000;
int tickTime = 2000;
String dataDirectory = System.getProperty("java.io.tmpdir");
File dir = new File(dataDirectory, "zookeeper").getAbsoluteFile();
ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTime);
ServerCnxnFactory factory = new NIOServerCnxnFactory();
factory.configure(new InetSocketAddress(clientPort), numConnections);
factory.startup(server); // start the server.
// ...shutdown some time later
factory.shutdown();
代码示例来源:origin: org.deeplearning4j/deeplearning4j-scaleout-zookeeper
public void run() throws Exception {
File dir = new File(dataDirectory, "zookeeper").getAbsoluteFile();
NIOServerCnxnFactory factory = new NIOServerCnxnFactory();
ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTime);
factory.setZooKeeperServer(server);
factory.setMaxClientCnxnsPerHost(numConnections);
factory.configure(new InetSocketAddress(clientPort), numConnections);
factory.startup(server);
}
代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common
public EmbeddedZookeeper(int port, Path baseDir) throws Exception {
this.port = port;
zookeeperBaseDir = baseDir;
zkServer = new ZooKeeperServer();
File dataDir = zookeeperBaseDir.resolve("log").toFile();
File snapDir = zookeeperBaseDir.resolve("data").toFile();
FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(1000);
connectionFactory = new NIOServerCnxnFactory() {
@Override
protected void configureSaslLogin() throws IOException {
// do nothing
}
};
connectionFactory.configure(new InetSocketAddress("localhost", port), 0);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
private void startSingleZkServer(final int tickTime, final File dataDir, final File dataLogDir, final int port) {
try {
_zk = new ZooKeeperServer(dataDir, dataLogDir, tickTime);
_zk.setMinSessionTimeout(_minSessionTimeout);
_nioFactory = new NIOServerCnxn.Factory(new InetSocketAddress(port));
_nioFactory.startup(_zk);
} catch (IOException e) {
throw new ZkException("Unable to start single ZooKeeper server.", e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: apache/nifi
private void startStandalone() throws IOException {
logger.info("Starting Embedded ZooKeeper Server");
final ServerConfig config = new ServerConfig();
config.readFrom(quorumPeerConfig);
try {
transactionLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
embeddedZkServer = new ZooKeeperServer();
embeddedZkServer.setTxnLogFactory(transactionLog);
embeddedZkServer.setTickTime(config.getTickTime());
embeddedZkServer.setMinSessionTimeout(config.getMinSessionTimeout());
embeddedZkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
connectionFactory = ServerCnxnFactory.createFactory();
connectionFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());
connectionFactory.startup(embeddedZkServer);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.warn("Embedded ZooKeeper Server interrupted", e);
} catch (final IOException ioe) {
throw new IOException("Failed to start embedded ZooKeeper Server", ioe);
} catch (final Exception e) {
throw new RuntimeException("Failed to start embedded ZooKeeper Server", e);
}
}
代码示例来源:origin: io.fabric8/fabric-zookeeper-spring
public void afterPropertiesSet() throws Exception {
if( purge ) {
deleteFilesInDir(getDataLogDir());
deleteFilesInDir(getDataDir());
}
FileTxnSnapLog ftxn = new FileTxnSnapLog(getDataLogDir(), getDataDir());
zooKeeperServer.setTxnLogFactory(ftxn);
zooKeeperServer.setTickTime(getTickTime());
zooKeeperServer.setMinSessionTimeout(getMinSessionTimeout());
zooKeeperServer.setMaxSessionTimeout(getMaxSessionTimeout());
connectionFactory = new NIOServerCnxnFactory();
connectionFactory.configure(getClientPortAddress(), getMaxClientConnections());
connectionFactory.startup(zooKeeperServer);
}
代码示例来源:origin: org.apache.twill/twill-zookeeper
@Override
protected void startUp() throws Exception {
ZooKeeperServer zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(tickTime);
factory = ServerCnxnFactory.createFactory();
factory.configure(getAddress(port), -1);
factory.startup(zkServer);
LOG.info("In memory ZK started: " + getConnectionStr());
}
在流处理方面,Apache Beam和Apache Kafka之间有什么区别? 我也试图掌握技术和程序上的差异。 请通过您的经验报告来帮助我理解。 最佳答案 Beam是一种API,它以一种统一的方式使
有点n00b的问题。 如果我使用 Apache Ignite 进行消息传递和事件处理,是否还需要使用 Kafka? 与 Ignite 相比,Kafka 基本上会给我哪些(如果有的话)额外功能? 提前致
Apache MetaModel 是一个数据访问框架,它为发现、探索和查询不同类型的数据源提供了一个通用接口(interface)。 Apache Drill 是一种无架构的 SQL 查询引擎,它通过
Tomcat是一个广泛使用的java web服务器,而Apache也是一个web服务器,它们在实际项目使用中有什么不同? 经过一些研究,我有了一个简单的想法,比如, Apache Tomcat Ja
既然简单地使用 Apache 就足以运行许多 Web 应用程序,那么人们何时以及为什么除了 Apache 之外还使用 Tomcat? 最佳答案 Apache Tomcat是一个网络服务器和 Java
我在某个 VPS( friend 的带 cPanel 的 apache 服务器)上有一个帐户,我在那里有一个 public_html 目录。我们有大约 5-6 个网站: /home/myusernam
我目前正在尝试将模块加载到 Apache,使用 cmake 构建。该模块称为 mod_mapcache。它已成功构建并正确安装在/usr/lib/apache2/modules directroy 中
我对 url 中的问号有疑问。 例如:我有 url test.com/controller/action/part_1%3Fpart_2 (其中 %3F 是 url 编码的问号),并使用此重写规则:R
在同一台机器上,Apache 在端口 80 上运行,Tomcat 在端口 8080 上运行。 Apache 包括 html;css;js;文件并调用 tomcat 服务。 基本上 exampledom
Apache 1 和 Apache 2 的分支有什么区别? 使用一种或另一种的优点和缺点? 似乎 Apache 2 的缺点之一是使用大量内存,但也许它处理请求的速度更快? 最有趣的是 Apache 作
实际上,我们正在使用 Apache 网络服务器来托管我们的 REST-API。 脚本是用 Lua 编写的,并使用 mod-lua 映射。 例如来自 httpd.conf 的实际片段: [...] Lu
我在 apache 上的 ubuntu 中有一个虚拟主机,这不是我的主要配置,我有另一个网页作为我的主要网页,所以我想使用虚拟主机在同一个 IP 上设置这个。 urologyexpert.mx 是我的
我使用 Apache camel 已经很长时间了,发现它是满足各种系统集成相关业务需求的绝佳解决方案。但是几年前我遇到了 Apache Nifi 解决方案。经过一番谷歌搜索后,我发现虽然 Nifi 可
由于两者都是一次处理事件的流框架,这两种技术/流框架之间的核心架构差异是什么? 此外,在哪些特定用例中,一个比另一个更合适? 最佳答案 正如您所提到的,两者都是实时内存计算的流式平台。但是当您仔细观察
apache 文件(如 httpd.conf 和虚拟主机)中使用的语言名称是什么,例如 # Ensure that Apache listens on port 80 Listen 80 D
作为我学习过程的一部分,我认为如果我扩展更多关于 apache 的知识会很好。我有几个问题,虽然我知道有些内容可能需要相当冗长的解释,但我希望您能提供一个概述,以便我知道去哪里寻找。 (最好引用 mo
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4 个月前关闭。 Improve
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
这个问题在这里已经有了答案: Difference Between Apache Kafka and Camel (Broker vs Integration) (4 个回答) 3年前关闭。 据我所知
我有 2 个使用相同规则的子域,如下所示: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond
我是一名优秀的程序员,十分优秀!