zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2655: Improve NIOServerCnxn#isZKServerRunning to reflect the seman…
Date Thu, 22 Dec 2016 22:23:36 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/master ef0a8ae68 -> f588e1982


ZOOKEEPER-2655: Improve NIOServerCnxn#isZKServerRunning to reflect the seman…

…tics correctly

Author: Rakesh Radhakrishnan <rakeshr@apache.org>

Reviewers: Edward Ribeiro <edward.ribeiro@gmail.com>, Michael Han <hanm@apache.org>

Closes #133 from rakeshadr/ZK-2655


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/f588e198
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/f588e198
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/f588e198

Branch: refs/heads/master
Commit: f588e1982f382a586fea53a1fbb11914d48560de
Parents: ef0a8ae
Author: Rakesh Radhakrishnan <rakeshr@apache.org>
Authored: Thu Dec 22 14:23:29 2016 -0800
Committer: Michael Han <hanm@apache.org>
Committed: Thu Dec 22 14:23:29 2016 -0800

----------------------------------------------------------------------
 .../main/org/apache/zookeeper/server/NIOServerCnxn.java     | 9 ++++++---
 .../zookeeper/server/command/AbstractFourLetterCommand.java | 5 ++++-
 .../zookeeper/server/command/CnxnStatResetCommand.java      | 2 +-
 .../org/apache/zookeeper/server/command/ConfCommand.java    | 2 +-
 .../org/apache/zookeeper/server/command/ConsCommand.java    | 2 +-
 .../org/apache/zookeeper/server/command/DirsCommand.java    | 2 +-
 .../org/apache/zookeeper/server/command/DumpCommand.java    | 2 +-
 .../org/apache/zookeeper/server/command/IsroCommand.java    | 2 +-
 .../org/apache/zookeeper/server/command/MonitorCommand.java | 2 +-
 .../org/apache/zookeeper/server/command/StatCommand.java    | 2 +-
 .../apache/zookeeper/server/command/StatResetCommand.java   | 2 +-
 .../org/apache/zookeeper/server/command/WatchCommand.java   | 2 +-
 12 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java b/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
index c944889..76b9be0 100644
--- a/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
+++ b/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
@@ -426,7 +426,7 @@ public class NIOServerCnxn extends ServerCnxn {
     }
 
     private void readConnectRequest() throws IOException, InterruptedException {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             throw new IOException("ZooKeeperServer not running");
         }
         zkServer.processConnectRequest(this, incomingBuffer);
@@ -539,15 +539,18 @@ public class NIOServerCnxn extends ServerCnxn {
         if (len < 0 || len > BinaryInputArchive.maxBuffer) {
             throw new IOException("Len error " + len);
         }
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             throw new IOException("ZooKeeperServer not running");
         }
         incomingBuffer = ByteBuffer.allocate(len);
         return true;
     }
 
+    /**
+     * @return true if the server is running, false otherwise.
+     */
     boolean isZKServerRunning() {
-        return zkServer == null || !zkServer.isRunning();
+        return zkServer != null && zkServer.isRunning();
     }
 
     public long getOutstandingRequests() {

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/AbstractFourLetterCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/AbstractFourLetterCommand.java
b/src/java/main/org/apache/zookeeper/server/command/AbstractFourLetterCommand.java
index a075a91..5a8a16e 100644
--- a/src/java/main/org/apache/zookeeper/server/command/AbstractFourLetterCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/AbstractFourLetterCommand.java
@@ -64,8 +64,11 @@ public abstract class AbstractFourLetterCommand {
         this.zkServer = zkServer;
     }
 
+    /**
+     * @return true if the server is running, false otherwise.
+     */
     boolean isZKServerRunning() {
-        return zkServer == null || !zkServer.isRunning();
+        return zkServer != null && zkServer.isRunning();
     }
 
     public void setFactory(ServerCnxnFactory factory) {

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/CnxnStatResetCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/CnxnStatResetCommand.java b/src/java/main/org/apache/zookeeper/server/command/CnxnStatResetCommand.java
index c44c840..06e82b6 100644
--- a/src/java/main/org/apache/zookeeper/server/command/CnxnStatResetCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/CnxnStatResetCommand.java
@@ -29,7 +29,7 @@ public class CnxnStatResetCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             factory.resetAllConnectionStats();

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/ConfCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/ConfCommand.java b/src/java/main/org/apache/zookeeper/server/command/ConfCommand.java
index a06666d..1cfa78d 100644
--- a/src/java/main/org/apache/zookeeper/server/command/ConfCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/ConfCommand.java
@@ -29,7 +29,7 @@ public class ConfCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             zkServer.dumpConf(pw);

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/ConsCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/ConsCommand.java b/src/java/main/org/apache/zookeeper/server/command/ConsCommand.java
index 0c8e3dd..36e40ad 100644
--- a/src/java/main/org/apache/zookeeper/server/command/ConsCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/ConsCommand.java
@@ -29,7 +29,7 @@ public class ConsCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             for (ServerCnxn c : factory.getConnections()) {

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/DirsCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/DirsCommand.java b/src/java/main/org/apache/zookeeper/server/command/DirsCommand.java
index 09623d7..0f82a2d 100644
--- a/src/java/main/org/apache/zookeeper/server/command/DirsCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/DirsCommand.java
@@ -31,7 +31,7 @@ public class DirsCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() throws IOException {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
             return;
         }

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/DumpCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/DumpCommand.java b/src/java/main/org/apache/zookeeper/server/command/DumpCommand.java
index 903bfd6..a52ebea 100644
--- a/src/java/main/org/apache/zookeeper/server/command/DumpCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/DumpCommand.java
@@ -30,7 +30,7 @@ public class DumpCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             pw.println("SessionTracker dump:");

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/IsroCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/IsroCommand.java b/src/java/main/org/apache/zookeeper/server/command/IsroCommand.java
index 542831e..a8f9f21 100644
--- a/src/java/main/org/apache/zookeeper/server/command/IsroCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/IsroCommand.java
@@ -31,7 +31,7 @@ public class IsroCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.print("null");
         } else if (zkServer instanceof ReadOnlyZooKeeperServer) {
             pw.print("ro");

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/MonitorCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/MonitorCommand.java b/src/java/main/org/apache/zookeeper/server/command/MonitorCommand.java
index b3e75f3..a3f5733 100644
--- a/src/java/main/org/apache/zookeeper/server/command/MonitorCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/MonitorCommand.java
@@ -36,7 +36,7 @@ public class MonitorCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
             return;
         }

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/StatCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/StatCommand.java b/src/java/main/org/apache/zookeeper/server/command/StatCommand.java
index 021b296..fbe42d0 100644
--- a/src/java/main/org/apache/zookeeper/server/command/StatCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/StatCommand.java
@@ -37,7 +37,7 @@ public class StatCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             pw.print("Zookeeper version: ");

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/StatResetCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/StatResetCommand.java b/src/java/main/org/apache/zookeeper/server/command/StatResetCommand.java
index c7d5ad7..88ac4c3 100644
--- a/src/java/main/org/apache/zookeeper/server/command/StatResetCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/StatResetCommand.java
@@ -29,7 +29,7 @@ public class StatResetCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             zkServer.serverStats().reset();

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/f588e198/src/java/main/org/apache/zookeeper/server/command/WatchCommand.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/command/WatchCommand.java b/src/java/main/org/apache/zookeeper/server/command/WatchCommand.java
index dd6c247..ac0476e 100644
--- a/src/java/main/org/apache/zookeeper/server/command/WatchCommand.java
+++ b/src/java/main/org/apache/zookeeper/server/command/WatchCommand.java
@@ -32,7 +32,7 @@ public class WatchCommand extends AbstractFourLetterCommand {
 
     @Override
     public void commandRun() {
-        if (isZKServerRunning()) {
+        if (!isZKServerRunning()) {
             pw.println(ZK_NOT_SERVING);
         } else {
             DataTree dt = zkServer.getZKDatabase().getDataTree();


Mime
View raw message