From notifications-return-1454-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Aug 15 20:17:52 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id A240C180645 for ; Thu, 15 Aug 2019 22:17:52 +0200 (CEST) Received: (qmail 24437 invoked by uid 500); 15 Aug 2019 20:17:52 -0000 Mailing-List: contact notifications-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list notifications@zookeeper.apache.org Received: (qmail 24428 invoked by uid 99); 15 Aug 2019 20:17:52 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Aug 2019 20:17:52 +0000 From: GitBox To: notifications@zookeeper.apache.org Subject: [GitHub] [zookeeper] TisonKun commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server Message-ID: <156590027194.3284.7477804359277140366.gitbox@gitbox.apache.org> Date: Thu, 15 Aug 2019 20:17:51 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit TisonKun commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314479796 ########## File path: zookeeper-server/src/test/java/org/apache/zookeeper/test/ZooKeeperTestClient.java ########## @@ -18,450 +18,435 @@ package org.apache.zookeeper.test; -import java.io.File; import java.io.IOException; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; - import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; -import org.apache.zookeeper.ZKTestCase; -import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.Watcher.Event.EventType; +import org.apache.zookeeper.ZKTestCase; import org.apache.zookeeper.ZooDefs.Ids; +import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.common.Time; import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.server.ServerCnxnFactory; -import org.apache.zookeeper.server.ZooKeeperServer; import org.junit.Assert; public class ZooKeeperTestClient extends ZKTestCase implements Watcher { - protected String hostPort = "127.0.0.1:22801"; - protected static final String dirOnZK = "/test_dir"; + protected String hostPort = "127.0.0.1:22801"; + + protected static final String dirOnZK = "/test_dir"; + + protected String testDirOnZK = dirOnZK + "/" + Time.currentElapsedTime(); - protected String testDirOnZK = dirOnZK + "/" + Time.currentElapsedTime(); + LinkedBlockingQueue events = new LinkedBlockingQueue(); - LinkedBlockingQueue events = new LinkedBlockingQueue(); + private WatchedEvent getEvent(int numTries) throws InterruptedException { + WatchedEvent event = null; + for (int i = 0; i < numTries; i++) { + System.out.println("i = " + i); + event = events.poll(10, TimeUnit.SECONDS); + if (event != null) { + break; + } + Thread.sleep(5000); + } + return event; - private WatchedEvent getEvent(int numTries) throws InterruptedException { - WatchedEvent event = null; - for (int i = 0; i < numTries; i++) { - System.out.println("i = " + i); - event = events.poll(10, TimeUnit.SECONDS); - if (event != null) { - break; - } - Thread.sleep(5000); } - return event; - } + private void deleteZKDir(ZooKeeper zk, String nodeName) throws IOException, InterruptedException, KeeperException { - private void deleteZKDir(ZooKeeper zk, String nodeName) - throws IOException, InterruptedException, KeeperException { + Stat stat = zk.exists(nodeName, false); + if (stat == null) { + return; + } - Stat stat = zk.exists(nodeName, false); - if (stat == null) { - return; - } + List children1 = zk.getChildren(nodeName, false); + List c2 = zk.getChildren(nodeName, false, stat); - List children1 = zk.getChildren(nodeName, false); - List c2 = zk.getChildren(nodeName, false, stat); + if (!children1.equals(c2)) { + Assert.fail("children lists from getChildren()/getChildren2() do not match"); + } - if (!children1.equals(c2)) { - Assert.fail("children lists from getChildren()/getChildren2() do not match"); - } + if (!stat.equals(stat)) { + Assert.fail("stats from exists()/getChildren2() do not match"); + } - if (!stat.equals(stat)) { - Assert.fail("stats from exists()/getChildren2() do not match"); + if (children1.size() == 0) { + zk.delete(nodeName, -1); + return; + } + for (String n : children1) { + deleteZKDir(zk, n); + } } - if (children1.size() == 0) { - zk.delete(nodeName, -1); - return; - } - for (String n : children1) { - deleteZKDir(zk, n); - } - } - - private void checkRoot() throws IOException, - InterruptedException { - ZooKeeper zk = new ZooKeeper(hostPort, 10000, this); - - try { - zk.create(dirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); - } catch (KeeperException.NodeExistsException ke) { - // expected, sort of - } catch (KeeperException ke) { - Assert.fail("Unexpected exception code for create " + dirOnZK + ": " - + ke.getMessage()); - } + private void checkRoot() throws IOException, InterruptedException { + ZooKeeper zk = new ZooKeeper(hostPort, 10000, this); - try { - zk.create(testDirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); - } catch (KeeperException.NodeExistsException ke) { - // expected, sort of - } catch (KeeperException ke) { - Assert.fail("Unexpected exception code for create " + testDirOnZK + ": " - + ke.getMessage()); - } + try { + zk.create(dirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); + } catch (KeeperException.NodeExistsException ke) { + // expected, sort of + } catch (KeeperException ke) { + Assert.fail("Unexpected exception code for create " + dirOnZK + ": " + ke.getMessage()); + } - zk.close(); - } - - private void enode_test_1() throws IOException, - InterruptedException, KeeperException { - checkRoot(); - String parentName = testDirOnZK; - String nodeName = parentName + "/enode_abc"; - ZooKeeper zk = new ZooKeeper(hostPort, 10000, this); - - Stat stat = zk.exists(parentName, false); - if (stat == null) { - try { - zk.create(parentName, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); - } catch (KeeperException ke) { - Assert.fail("Creating node " + parentName + ke.getMessage()); - } - } + try { + zk.create(testDirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); + } catch (KeeperException.NodeExistsException ke) { + // expected, sort of + } catch (KeeperException ke) { + Assert.fail("Unexpected exception code for create " + testDirOnZK + ": " + ke.getMessage()); Review comment: Hmmm I have done it with a script remove `import org.junit.Assert;` and replace ` Assert.` with ` `. And then add a redundant `import static` headers which is followed by an imports clean up automate phase. I do it inside zookeeper-server scope and it should not be hard to review.(just import -> import static) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services