helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [5/6] helix git commit: Wrap debug log statement in CallbackHandler and ZkClient to reduce GC pressure.
Date Fri, 23 Mar 2018 19:29:26 GMT
Wrap debug log statement in CallbackHandler and ZkClient to reduce GC pressure.


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

Branch: refs/heads/master
Commit: 90730bff49120fc1ca0103e8be2cbab90e6ceced
Parents: 1c04f2f
Author: Lei Xia <lxia@linkedin.com>
Authored: Fri Mar 23 10:35:29 2018 -0700
Committer: Lei Xia <lxia@linkedin.com>
Committed: Fri Mar 23 12:12:44 2018 -0700

----------------------------------------------------------------------
 .../helix/manager/zk/CallbackHandler.java       | 36 ++++++++++++++------
 .../helix/manager/zk/zookeeper/ZkClient.java    | 20 +++++++----
 2 files changed, 40 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/90730bff/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
index c5a035f..663fa32 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
@@ -276,7 +276,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
       throws Exception {
     //async mode only applicable to CALLBACK from ZK, During INIT and FINALIZE invoke the
callback's immediately.
     if (_batchModeEnabled && changeContext.getType() == NotificationContext.Type.CALLBACK)
{
-      logger.info("Enqueuing callback");
+      logger.debug("Enqueuing callback");
       _queue.put(changeContext);
     } else {
       invoke(changeContext);
@@ -442,15 +442,23 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
 
     if (_eventTypes.contains(EventType.NodeDataChanged) || _eventTypes
         .contains(EventType.NodeCreated) || _eventTypes.contains(EventType.NodeDeleted))
{
-      logger.debug("Subscribing data change listener to path:" + path);
+      if (logger.isDebugEnabled()) {
+        logger.debug("Subscribing data change listener to path:" + path);
+      }
       subscribeDataChange(path, context);
     }
 
     if (_eventTypes.contains(EventType.NodeChildrenChanged)) {
-      logger.debug("Subscribing child change listener to path:" + path);
+      if (logger.isDebugEnabled()) {
+        logger.debug("Subscribing child change listener to path:" + path);
+      }
+
       subscribeChildChange(path, context);
       if (watchChild) {
-        logger.debug("Subscribing data change listener to all children for path:" + path);
+        if (logger.isDebugEnabled()) {
+          logger.debug("Subscribing data change listener to all children for path:" + path);
+        }
+
         try {
           switch (_changeType) {
           case CURRENT_STATE:
@@ -504,7 +512,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
     }
 
     long end = System.currentTimeMillis();
-    logger.info("Subcribing to path:" + path + " took:" + (end - start));
+    logger.info("Subscribing to path:" + path + " took:" + (end - start));
   }
 
   public EventType[] getEventTypes() {
@@ -530,7 +538,9 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
 
   @Override
   public void handleDataChange(String dataPath, Object data) {
-    logger.info("Data change callback: paths changed: " + dataPath);
+    if (logger.isDebugEnabled()) {
+      logger.debug("Data change callback: paths changed: " + dataPath);
+    }
 
     try {
       updateNotificationTime(System.nanoTime());
@@ -547,8 +557,11 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
     }
   }
 
-  @Override public void handleDataDeleted(String dataPath) {
-    logger.info("Data change callback: path deleted: " + dataPath);
+  @Override
+  public void handleDataDeleted(String dataPath) {
+    if (logger.isDebugEnabled()) {
+      logger.debug("Data change callback: path deleted: " + dataPath);
+    }
 
     try {
       updateNotificationTime(System.nanoTime());
@@ -573,8 +586,11 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
{
 
   @Override
   public void handleChildChange(String parentPath, List<String> currentChilds) {
-    logger.info("Data change callback: child changed, path: " + parentPath + ", current child
count: "
-        + currentChilds.size());
+    if (logger.isDebugEnabled()) {
+      logger.debug(
+          "Data change callback: child changed, path: " + parentPath + ", current child count:
"
+              + currentChilds.size());
+    }
 
     try {
       updateNotificationTime(System.nanoTime());

http://git-wip-us.apache.org/repos/asf/helix/blob/90730bff/helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
b/helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
index 45c397a..2ae7f63 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
@@ -142,7 +142,9 @@ public class ZkClient implements Watcher {
       listeners.add(listener);
     }
     watchForData(path);
-    LOG.debug("Subscribed data changes for " + path);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Subscribed data changes for " + path);
+    }
   }
 
   public void unsubscribeDataChanges(String path, IZkDataListener dataListener) {
@@ -525,7 +527,9 @@ public class ZkClient implements Watcher {
 
   @Override
   public void process(WatchedEvent event) {
-    LOG.debug("Received event: " + event);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Received event: " + event);
+    }
     _zookeeperEventThread = Thread.currentThread();
 
     boolean stateChanged = event.getPath() == null;
@@ -540,8 +544,10 @@ public class ZkClient implements Watcher {
 
       // We might have to install child change event listener if a new node was created
       if (getShutdownTrigger()) {
-        LOG.debug("ignoring event '{" + event.getType() + " | " + event.getPath()
-            + "}' since shutdown triggered");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("ignoring event '{" + event.getType() + " | " + event.getPath()
+              + "}' since shutdown triggered");
+        }
         return;
       }
       if (stateChanged) {
@@ -692,7 +698,7 @@ public class ZkClient implements Watcher {
         reconnect();
         fireNewSessionEvents();
       } catch (final Exception e) {
-        LOG.info(
+        LOG.warn(
             "Unable to re-establish connection. Notifying consumer of the following exception:
",
             e);
         fireSessionEstablishmentError(e);
@@ -855,7 +861,9 @@ public class ZkClient implements Watcher {
   public boolean waitUntilExists(String path, TimeUnit timeUnit, long time)
       throws ZkInterruptedException {
     Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
-    LOG.debug("Waiting until znode '" + path + "' becomes available.");
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Waiting until znode '" + path + "' becomes available.");
+    }
     if (exists(path)) {
       return true;
     }


Mime
View raw message