You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/07/01 10:08:00 UTC
[jira] [Work logged] (CURATOR-587) Use ZooKeeper 3.7+ ZooKeeperServerEmbedded in order to start TestingServer
[ https://issues.apache.org/jira/browse/CURATOR-587?focusedWorklogId=787035&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787035 ]
ASF GitHub Bot logged work on CURATOR-587:
------------------------------------------
Author: ASF GitHub Bot
Created on: 01/Jul/22 10:07
Start Date: 01/Jul/22 10:07
Worklog Time Spent: 10m
Work Description: eolivelli commented on code in PR #379:
URL: https://github.com/apache/curator/pull/379#discussion_r911822246
##########
pom.xml:
##########
@@ -69,7 +69,7 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<!
Issue Time Tracking
-------------------
Worklog Id: (was: 787035)
Time Spent: 0.5h (was: 20m)
> Use ZooKeeper 3.7+ ZooKeeperServerEmbedded in order to start TestingServer
> --------------------------------------------------------------------------
>
> Key: CURATOR-587
> URL: https://issues.apache.org/jira/browse/CURATOR-587
> Project: Apache Curator
> Issue Type: Improvement
> Components: Tests
> Reporter: Enrico Olivelli
> Assignee: Enrico Olivelli
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> with 3.7.0 ZooKeeper provides an official API to run a ZooKeeper node.
> We should use that API in order to launch ZooKeeper, this way we won't have any compatibility issues.
> In fact now (5.1) we are starting the ZooKeeper node using internal ZK classes, that are subject to change in the future.
> The ZooKeeperServerEmbedded API is designed to be forward compatible.
> It is a very skinny API, and it basically reproduces the usage for the users, that is to provide a configuration file and a base directory.
> It also provides a way to prevent ZooKeeper to exit the JVM and to shutdown gracefully the server.
> {code:java}
>
> @TempDir
> Path tmpDir;
>
> @Test
> public void hello() throws Exception {
> Properties configuration = new Properties();
> configuration.setProperty("clientPort", "2181");
> try (ZooKeeperServerEmbedded embedded = ZooKeeperServerEmbedded
> .builder()
> .exitHandler(ExitHandler.LOG_ONLY)
> .baseDir(tmpDir)
> .configuration(configuration)
> .build();) {
> embedded.start();
> CountDownLatch l = new CountDownLatch(1);
> try (ZooKeeper zk = new ZooKeeper("localhost:2181", 40000, new Watcher() {
> @Override
> public void process(WatchedEvent event) {
> System.out.println("event "+event) ;
> l.countDown();
> }
> }
> )) {
> l.await();
> System.out.println("WHOAMI"+ zk.whoAmI());
> zk.create("/foo", "foo".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
> }
> }
>
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)