accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/5] accumulo git commit: ACCUMULO-3440 Bin assingment log messages
Date Fri, 19 Dec 2014 06:37:26 GMT
ACCUMULO-3440 Bin assingment log messages

Don't spam log messages about assignments, but
also don't make huge log messages. Nice sized
log messages that are managable.


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

Branch: refs/heads/master
Commit: c558211ea6cfcd38991e9e8a264773e73b0a2af6
Parents: 27d79c2
Author: Josh Elser <elserj@apache.org>
Authored: Fri Dec 19 01:18:33 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Dec 19 01:18:33 2014 -0500

----------------------------------------------------------------------
 .../accumulo/master/TabletGroupWatcher.java     | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c558211e/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
index f5ed941..72a96bd 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
@@ -87,7 +87,10 @@ import org.apache.thrift.TException;
 import com.google.common.collect.Iterators;
 
 class TabletGroupWatcher extends Daemon {
-  
+  // Constants used to make sure assignment logging isn't excessive in quantity or size
+  private static final String ASSIGNMENT_BUFFER_SEPARATOR = ", ";
+  private static final int ASSINGMENT_BUFFER_MAX_LENGTH = 4096;
+
   private final Master master;
   final TabletStateStore store;
   final TabletGroupWatcher dependentWatcher;
@@ -722,6 +725,7 @@ class TabletGroupWatcher extends Daemon {
     
     if (!currentTServers.isEmpty()) {
       Map<KeyExtent,TServerInstance> assignedOut = new HashMap<KeyExtent,TServerInstance>();
+      final StringBuilder builder = new StringBuilder(64);
       this.master.tabletBalancer.getAssignments(Collections.unmodifiableSortedMap(currentTServers),
Collections.unmodifiableMap(unassigned), assignedOut);
       for (Entry<KeyExtent,TServerInstance> assignment : assignedOut.entrySet()) {
         if (unassigned.containsKey(assignment.getKey())) {
@@ -730,13 +734,33 @@ class TabletGroupWatcher extends Daemon {
               Master.log.warn("balancer assigned " + assignment.getKey() + " to a tablet
server that is not current " + assignment.getValue() + " ignoring");
               continue;
             }
-            Master.log.debug(store.name() + " assigning tablet " + assignment);
+
+            if (builder.length() > 0) {
+              builder.append(ASSIGNMENT_BUFFER_SEPARATOR);
+            }
+
+            builder.append(assignment);
+
+            // Don't let the log message get too gigantic
+            if (builder.length() > ASSINGMENT_BUFFER_MAX_LENGTH) {
+              builder.append("]");
+              Master.log.debug(store.name() + " assigning tablets: [" + builder.toString());
+              builder.setLength(0);
+            }
+
             assignments.add(new Assignment(assignment.getKey(), assignment.getValue()));
           }
         } else {
           Master.log.warn(store.name() + " load balancer assigning tablet that was not nominated
for assignment " + assignment.getKey());
         }
       }
+
+      if (builder.length() > 0) {
+        // Make sure to log any leftover assignments
+        builder.append("]");
+        Master.log.debug(store.name() + " assigning tablets: [" + builder.toString());
+      }
+
       if (!unassigned.isEmpty() && assignedOut.isEmpty())
         Master.log.warn("Load balancer failed to assign any tablets");
     }


Mime
View raw message