ZOOKEEPER-3633: AdminServer commands throw NPE when only secure client port is used

When only secureClientPort is defined in the config and there is no regular clientPort,
then both the stat and the conf commands on the AdminServer result in 500 Server Error caused by
NullPointerExceptions. The problem is that no serverCnxFactory is defined in the
ZooKeeperServer in this case, we have only secureServerCnxnFactory.

In the fix we return info about both the secure and unsecure connections.
Example of the stat command output for secure-only configuration:
```
{
  "version" : "3.6.0-SNAPSHOT-8e8905069f4bff670c0492fe9e28ced0f86bca00, built on 11/29/2019 08:04 GMT",
  "read_only" : false,
  "server_stats" : {
    "packets_sent" : 1,
    "packets_received" : 1,
    "fsync_threshold_exceed_count" : 0,
    "client_response_stats" : {
      "last_buffer_size" : -1,
      "min_buffer_size" : -1,
      "max_buffer_size" : -1
    },
    "data_dir_size" : 671094270,
    "log_dir_size" : 671094270,
    "last_processed_zxid" : 20,
    "outstanding_requests" : 0,
    "server_state" : "standalone",
    "avg_latency" : 5.0,
    "max_latency" : 5,
    "min_latency" : 5,
    "num_alive_client_connections" : 1,
    "provider_null" : false,
    "uptime" : 15020
  },
  "client_response" : {
    "last_buffer_size" : -1,
    "min_buffer_size" : -1,
    "max_buffer_size" : -1
  },
  "node_count" : 6,
  "connections" : [ ],
  "secure_connections" : [ {
    "remote_socket_address" : "127.0.0.1:57276",
    "interest_ops" : 1,
    "outstanding_requests" : 0,
    "packets_received" : 1,
    "packets_sent" : 1
  } ],
  "command" : "stats",
  "error" : null
}
```

Author: Mate Szalay-Beko <szalay.beko.mate@gmail.com>

Reviewers: Andor Molnar <andor@apache.org>, Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes #1161 from symat/ZOOKEEPER-3633
3 files changed
tree: 80a4e4bce4d1144eb194ae9ef7656468f643bad4
  1. bin/
  2. conf/
  3. dev/
  4. zookeeper-assembly/
  5. zookeeper-client/
  6. zookeeper-contrib/
  7. zookeeper-docs/
  8. zookeeper-it/
  9. zookeeper-jute/
  10. zookeeper-metrics-providers/
  11. zookeeper-recipes/
  12. zookeeper-server/
  13. .gitattributes
  14. .gitignore
  15. .travis.yml
  16. checkstyle-simple.xml
  17. checkstyle-strict.xml
  18. checkstyleSuppressions.xml
  19. excludeFindBugsFilter.xml
  20. LICENSE.txt
  21. NOTICE.txt
  22. owaspSuppressions.xml
  23. pom.xml
  24. README.md
  25. README_packaging.md
  26. zk-merge-pr.py
README.md

Apache ZooKeeper Build Status Maven Central License

alt text

For the latest information about Apache ZooKeeper, please visit our website at:

http://zookeeper.apache.org/

and our wiki, at:

https://cwiki.apache.org/confluence/display/ZOOKEEPER


Packaging/release artifacts

Either downloaded from https://zookeeper.apache.org/releases.html or found in zookeeper-assembly/target directory after building the project with maven.

apache-zookeeper-[version].tar.gz

    Contains all the source files which can be built by running:
    mvn clean install

    To generate an aggregated apidocs for zookeeper-server and zookeeper-jute:
    mvn javadoc:aggregate
    (generated files will be at target/site/apidocs)

apache-zookeeper-[version]-bin.tar.gz

    Contains all the jar files required to run ZooKeeper
    Full documentation can also be found in the docs folder

As of version 3.5.5, the parent, zookeeper and zookeeper-jute artifacts are deployed to the central repository after the release is voted on and approved by the Apache ZooKeeper PMC:

https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/

Contributing

We always welcome new contributors to the project! See How to Contribute for details on how to submit patch through pull request and our contribution workflow.