Explorar el Código

ZOOKEEPER-3722: make logs of ResponseCache more readable

As per [ZOOKEEPER-3722](https://issues.apache.org/jira/browse/ZOOKEEPER-3722), we need to make ResponseCache logs more readable by adding the request type to the logs. For this I made the following changes:
- Added a parameter named requestType to ResponseCache constructor.
- Passed requestType as getData and getChild when the constructor is called to initialize readResponseCache and getChildrenResponseCache respectively.

Please let me know if additional changes are required.

Author: Nishanth Entoor <entoor.nishanth@gmail.com>

Reviewers: hanm, HorizonNet, maoling

Closes #1253 from nishanth-entoor/ZOOKEEPER-3722
Nishanth Entoor hace 4 años
padre
commit
e453497689

+ 2 - 2
zookeeper-server/src/main/java/org/apache/zookeeper/server/ResponseCache.java

@@ -39,10 +39,10 @@ public class ResponseCache {
 
     private final Map<String, Entry> cache;
 
-    public ResponseCache(int cacheSize) {
+    public ResponseCache(int cacheSize, String requestType) {
         this.cacheSize = cacheSize;
         cache = Collections.synchronizedMap(new LRUCache<>(cacheSize));
-        LOG.info("Response cache size is initialized with value {}.", cacheSize);
+        LOG.info("{} response cache size is initialized with value {}.", requestType, cacheSize);
     }
 
     public int getCacheSize() {

+ 2 - 2
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java

@@ -327,11 +327,11 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
 
         readResponseCache = new ResponseCache(Integer.getInteger(
             GET_DATA_RESPONSE_CACHE_SIZE,
-            ResponseCache.DEFAULT_RESPONSE_CACHE_SIZE));
+            ResponseCache.DEFAULT_RESPONSE_CACHE_SIZE), "getData");
 
         getChildrenResponseCache = new ResponseCache(Integer.getInteger(
             GET_CHILDREN_RESPONSE_CACHE_SIZE,
-            ResponseCache.DEFAULT_RESPONSE_CACHE_SIZE));
+            ResponseCache.DEFAULT_RESPONSE_CACHE_SIZE), "getChildren");
 
         this.initialConfig = initialConfig;