You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/04/05 19:45:13 UTC

svn commit: r1465066 - in /accumulo/trunk: ./ assemble/ core/ examples/ fate/src/main/java/org/apache/accumulo/fate/ fate/src/main/java/org/apache/accumulo/fate/zookeeper/ server/ src/ test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/

Author: ecn
Date: Fri Apr  5 17:45:12 2013
New Revision: 1465066

URL: http://svn.apache.org/r1465066
Log:
ACCUMULO-1239 make balance checker triple-check

Modified:
    accumulo/trunk/   (props changed)
    accumulo/trunk/assemble/   (props changed)
    accumulo/trunk/core/   (props changed)
    accumulo/trunk/examples/   (props changed)
    accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java   (props changed)
    accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java   (props changed)
    accumulo/trunk/server/   (props changed)
    accumulo/trunk/src/   (props changed)
    accumulo/trunk/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java

Propchange: accumulo/trunk/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5:r1465065

Propchange: accumulo/trunk/assemble/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/assemble:r1465065

Propchange: accumulo/trunk/core/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/core:r1465065

Propchange: accumulo/trunk/examples/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/examples:r1465065

Propchange: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java:r1465065

Propchange: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java:r1465065

Propchange: accumulo/trunk/server/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/server:r1465065

Propchange: accumulo/trunk/src/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/src:r1465065

Modified: accumulo/trunk/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java?rev=1465066&r1=1465065&r2=1465066&view=diff
==============================================================================
--- accumulo/trunk/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java (original)
+++ accumulo/trunk/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java Fri Apr  5 17:45:12 2013
@@ -34,12 +34,14 @@ import org.apache.accumulo.test.randomwa
 public class CheckBalance extends Test {
   
   private static final String LAST_UNBALANCED_TIME = "lastUnbalancedTime";
+  private static final String UNBALANCED_COUNT = "unbalancedCount";
 
   /* (non-Javadoc)
    * @see org.apache.accumulo.test.randomwalk.Node#visit(org.apache.accumulo.test.randomwalk.State, java.util.Properties)
    */
   @Override
   public void visit(State state, Properties props) throws Exception {
+    log.debug("checking balance");
     Map<String,Long> counts = new HashMap<String,Long>();
     Scanner scanner = state.getConnector().createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
     scanner.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
@@ -61,21 +63,28 @@ public class CheckBalance extends Test {
     for (Entry<String,Long> entry : counts.entrySet()) {
       if (Math.abs(entry.getValue().longValue() - average) > Math.max(1, average / 5)) {
         balanced = false;
-        break;
+        log.debug("unbalanced: " + entry.getKey() + " has " + entry.getValue() + " tablets and the average is " + average);
       }
     }
     
     // It is expected that the number of tablets will be uneven for short
     // periods of time. Don't complain unless we've seen it only unbalanced
-    // over a 15 minute period.
+    // over a 15 minute period and it's been at least three checks.
     if (!balanced) {
       String last = props.getProperty(LAST_UNBALANCED_TIME);
       if (last != null && System.currentTimeMillis() - Long.parseLong(last) > 15 * 60 * 1000) {
-        throw new Exception("servers are unbalanced!");
+        String countString = props.getProperty(UNBALANCED_COUNT, "0");
+        int count = Integer.parseInt(countString);
+        if (count > 3)
+          throw new Exception("servers are unbalanced!");
+        count++;
+        props.setProperty(UNBALANCED_COUNT, "" + count);
       }
-      props.setProperty(LAST_UNBALANCED_TIME, Long.toString(System.currentTimeMillis()));
+      if (last == null)
+        props.setProperty(LAST_UNBALANCED_TIME, Long.toString(System.currentTimeMillis()));
     } else {
       props.remove(LAST_UNBALANCED_TIME);
+      props.remove(UNBALANCED_COUNT);
     }
   }