Description
Classes org.apache.zookeeper.server.NIOServerCnxn and org.apache.zookeeper.server.NettyServerCnxn have following need and scope for improvement
1) Duplicate code.
These two classes have around 250 line duplicate code. All the command code is duplicated
2) Many improvement/bugFix done in one class but not done in other class. These changes should be synced
For example
In NettyServerCnxn
// clone should be faster than iteration // ie give up the cnxns lock faster AbstractSet<ServerCnxn> cnxns; synchronized (factory.cnxns) { cnxns = new HashSet<ServerCnxn>(factory.cnxns); } for (ServerCnxn c : cnxns) { c.dumpConnectionInfo(pw, false); pw.println(); }
In NIOServerCnxn
for (ServerCnxn c : factory.cnxns) { c.dumpConnectionInfo(pw, false); pw.println(); }
3) NettyServerCnxn and NIOServerCnxn classes are bulky unnecessarily. Command classes have altogether different functionality, the command classes should go in different class files.
If this done it will be easy to add new command with minimal change to existing classes.
Attachments
Attachments
Issue Links
- duplicates
-
ZOOKEEPER-845 remove duplicate code from netty and nio ServerCnxn classes
- Resolved