You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bh...@apache.org on 2014/03/18 21:32:53 UTC

[01/10] git commit: ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

Repository: accumulo
Updated Branches:
  refs/heads/1.4.5-SNAPSHOT 6df83da60 -> a4174248a
  refs/heads/1.5.2-SNAPSHOT 205f0dca8 -> 1f4cb4d5b
  refs/heads/1.6.0-SNAPSHOT 70d472662 -> 99b6e252d
  refs/heads/master 39807cb2a -> 7cd087516


ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

The Concurrent randomwalk test used to consider servers unbalanced if any server's
tablet count differed from the cluster average by more than a fifth of the average or
by one, whichever was larger. This would cause failures under typical balancings from
the default balancer.

This commit changes the criterion for an unbalanced server to be double the standard
deviation from the cluster average.


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

Branch: refs/heads/1.4.5-SNAPSHOT
Commit: a4174248a96cadcc79a9de4015c90c6618a96418
Parents: 6df83da
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 09:12:19 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:22:22 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a4174248/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
index d00e2b4..5d0b978 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.server.test.randomwalk.concurrent;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -57,9 +58,11 @@ public class CheckBalance extends Test {
       total += count.longValue();
     }
     final double average = total / counts.size();
-    
-    // Check for even # of tablets on each node
-    double maxDifference = Math.max(1, average / 5);
+    final double sd = stddev(counts.values(), average);
+    log.debug("average " + average + ", standard deviation " + sd);
+
+    // Check for balanced # of tablets on each node
+    double maxDifference = 2.0 * sd;
     String unbalancedLocation = null;
     long lastCount = 0L;
     boolean balanced = true;
@@ -94,4 +97,13 @@ public class CheckBalance extends Test {
     }
   }
   
+  private static double stddev(Collection<Long> samples, double avg) {
+    int num = samples.size();
+    double sqrtotal = 0.0;
+    for (Long s : samples) {
+      double diff = s.doubleValue() - avg;
+      sqrtotal += diff * diff;
+    }
+    return Math.sqrt(sqrtotal / (double) num);
+  }
 }


[09/10] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT

Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT


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

Branch: refs/heads/master
Commit: 99b6e252d4b68179927ae101f95ab1d72bbb6fe1
Parents: 70d4726 1f4cb4d
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:23:54 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:23:54 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/99b6e252/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------


[10/10] git commit: Merge branch '1.6.0-SNAPSHOT'

Posted by bh...@apache.org.
Merge branch '1.6.0-SNAPSHOT'


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

Branch: refs/heads/master
Commit: 7cd087516a80a92cbeb640c5877672050767f684
Parents: 39807cb 99b6e25
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:24:08 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:24:08 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7cd08751/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------


[08/10] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT

Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 99b6e252d4b68179927ae101f95ab1d72bbb6fe1
Parents: 70d4726 1f4cb4d
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:23:54 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:23:54 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/99b6e252/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------


[06/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT

Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT


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

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 1f4cb4d5bb9b8dc19df0cd1a6b6a95a44a9abeea
Parents: 205f0dc a417424
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:23:18 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:23:18 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1f4cb4d5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
index 698b0c0,0000000..a0dd37c
mode 100644,000000..100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
@@@ -1,98 -1,0 +1,110 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.test.randomwalk.concurrent;
 +
++import java.util.Collection;
 +import java.util.HashMap;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Properties;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.test.randomwalk.State;
 +import org.apache.accumulo.test.randomwalk.Test;
 +
 +/**
 + * 
 + */
 +public class CheckBalance extends Test {
 +  
 +  static final String LAST_UNBALANCED_TIME = "lastUnbalancedTime";
 +  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);
 +    for (Entry<Key,Value> entry : scanner) {
 +      String location = entry.getKey().getColumnQualifier().toString();
 +      Long count = counts.get(location);
 +      if (count == null)
 +        count = Long.valueOf(0);
 +      counts.put(location, count + 1);
 +    }
 +    double total = 0.;
 +    for (Long count : counts.values()) {
 +      total += count.longValue();
 +    }
 +    final double average = total / counts.size();
-     
-     // Check for even # of tablets on each node
-     double maxDifference = Math.max(1, average / 5);
++    final double sd = stddev(counts.values(), average);
++    log.debug("average " + average + ", standard deviation " + sd);
++
++    // Check for balanced # of tablets on each node
++    double maxDifference = 2.0 * sd;
 +    String unbalancedLocation = null;
 +    long lastCount = 0L;
 +    boolean balanced = true;
 +    for (Entry<String,Long> entry : counts.entrySet()) {
 +      long thisCount = entry.getValue().longValue();
 +      if (Math.abs(thisCount - average) > maxDifference) {
 +        balanced = false;
 +        log.debug("unbalanced: " + entry.getKey() + " has " + entry.getValue() + " tablets and the average is " + average);
 +        unbalancedLocation = entry.getKey();
 +        lastCount = thisCount;
 +      }
 +    }
 +    
 +    // 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 and it's been at least three checks.
 +    if (!balanced) {
 +      Long last = state.getLong(LAST_UNBALANCED_TIME);
 +      if (last != null && System.currentTimeMillis() - last > 15 * 60 * 1000) {
 +        Integer count = state.getInteger(UNBALANCED_COUNT);
 +        if (count == null)
 +          count = Integer.valueOf(0);
 +        if (count > 3)
 +          throw new Exception("servers are unbalanced! location " + unbalancedLocation + " count " + lastCount + " too far from average " + average);
 +        count++;
 +        state.set(UNBALANCED_COUNT, count);
 +      }
 +      if (last == null)
 +        state.set(LAST_UNBALANCED_TIME, System.currentTimeMillis());
 +    } else {
 +      state.remove(LAST_UNBALANCED_TIME);
 +      state.remove(UNBALANCED_COUNT);
 +    }
 +  }
 +  
++  private static double stddev(Collection<Long> samples, double avg) {
++    int num = samples.size();
++    double sqrtotal = 0.0;
++    for (Long s : samples) {
++      double diff = s.doubleValue() - avg;
++      sqrtotal += diff * diff;
++    }
++    return Math.sqrt(sqrtotal / (double) num);
++  }
 +}


[03/10] git commit: ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

Posted by bh...@apache.org.
ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

The Concurrent randomwalk test used to consider servers unbalanced if any server's
tablet count differed from the cluster average by more than a fifth of the average or
by one, whichever was larger. This would cause failures under typical balancings from
the default balancer.

This commit changes the criterion for an unbalanced server to be double the standard
deviation from the cluster average.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: a4174248a96cadcc79a9de4015c90c6618a96418
Parents: 6df83da
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 09:12:19 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:22:22 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a4174248/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
index d00e2b4..5d0b978 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.server.test.randomwalk.concurrent;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -57,9 +58,11 @@ public class CheckBalance extends Test {
       total += count.longValue();
     }
     final double average = total / counts.size();
-    
-    // Check for even # of tablets on each node
-    double maxDifference = Math.max(1, average / 5);
+    final double sd = stddev(counts.values(), average);
+    log.debug("average " + average + ", standard deviation " + sd);
+
+    // Check for balanced # of tablets on each node
+    double maxDifference = 2.0 * sd;
     String unbalancedLocation = null;
     long lastCount = 0L;
     boolean balanced = true;
@@ -94,4 +97,13 @@ public class CheckBalance extends Test {
     }
   }
   
+  private static double stddev(Collection<Long> samples, double avg) {
+    int num = samples.size();
+    double sqrtotal = 0.0;
+    for (Long s : samples) {
+      double diff = s.doubleValue() - avg;
+      sqrtotal += diff * diff;
+    }
+    return Math.sqrt(sqrtotal / (double) num);
+  }
 }


[04/10] git commit: ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

Posted by bh...@apache.org.
ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

The Concurrent randomwalk test used to consider servers unbalanced if any server's
tablet count differed from the cluster average by more than a fifth of the average or
by one, whichever was larger. This would cause failures under typical balancings from
the default balancer.

This commit changes the criterion for an unbalanced server to be double the standard
deviation from the cluster average.


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

Branch: refs/heads/master
Commit: a4174248a96cadcc79a9de4015c90c6618a96418
Parents: 6df83da
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 09:12:19 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:22:22 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a4174248/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
index d00e2b4..5d0b978 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.server.test.randomwalk.concurrent;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -57,9 +58,11 @@ public class CheckBalance extends Test {
       total += count.longValue();
     }
     final double average = total / counts.size();
-    
-    // Check for even # of tablets on each node
-    double maxDifference = Math.max(1, average / 5);
+    final double sd = stddev(counts.values(), average);
+    log.debug("average " + average + ", standard deviation " + sd);
+
+    // Check for balanced # of tablets on each node
+    double maxDifference = 2.0 * sd;
     String unbalancedLocation = null;
     long lastCount = 0L;
     boolean balanced = true;
@@ -94,4 +97,13 @@ public class CheckBalance extends Test {
     }
   }
   
+  private static double stddev(Collection<Long> samples, double avg) {
+    int num = samples.size();
+    double sqrtotal = 0.0;
+    for (Long s : samples) {
+      double diff = s.doubleValue() - avg;
+      sqrtotal += diff * diff;
+    }
+    return Math.sqrt(sqrtotal / (double) num);
+  }
 }


[07/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT

Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT


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

Branch: refs/heads/master
Commit: 1f4cb4d5bb9b8dc19df0cd1a6b6a95a44a9abeea
Parents: 205f0dc a417424
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:23:18 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:23:18 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1f4cb4d5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
index 698b0c0,0000000..a0dd37c
mode 100644,000000..100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
@@@ -1,98 -1,0 +1,110 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.test.randomwalk.concurrent;
 +
++import java.util.Collection;
 +import java.util.HashMap;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Properties;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.test.randomwalk.State;
 +import org.apache.accumulo.test.randomwalk.Test;
 +
 +/**
 + * 
 + */
 +public class CheckBalance extends Test {
 +  
 +  static final String LAST_UNBALANCED_TIME = "lastUnbalancedTime";
 +  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);
 +    for (Entry<Key,Value> entry : scanner) {
 +      String location = entry.getKey().getColumnQualifier().toString();
 +      Long count = counts.get(location);
 +      if (count == null)
 +        count = Long.valueOf(0);
 +      counts.put(location, count + 1);
 +    }
 +    double total = 0.;
 +    for (Long count : counts.values()) {
 +      total += count.longValue();
 +    }
 +    final double average = total / counts.size();
-     
-     // Check for even # of tablets on each node
-     double maxDifference = Math.max(1, average / 5);
++    final double sd = stddev(counts.values(), average);
++    log.debug("average " + average + ", standard deviation " + sd);
++
++    // Check for balanced # of tablets on each node
++    double maxDifference = 2.0 * sd;
 +    String unbalancedLocation = null;
 +    long lastCount = 0L;
 +    boolean balanced = true;
 +    for (Entry<String,Long> entry : counts.entrySet()) {
 +      long thisCount = entry.getValue().longValue();
 +      if (Math.abs(thisCount - average) > maxDifference) {
 +        balanced = false;
 +        log.debug("unbalanced: " + entry.getKey() + " has " + entry.getValue() + " tablets and the average is " + average);
 +        unbalancedLocation = entry.getKey();
 +        lastCount = thisCount;
 +      }
 +    }
 +    
 +    // 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 and it's been at least three checks.
 +    if (!balanced) {
 +      Long last = state.getLong(LAST_UNBALANCED_TIME);
 +      if (last != null && System.currentTimeMillis() - last > 15 * 60 * 1000) {
 +        Integer count = state.getInteger(UNBALANCED_COUNT);
 +        if (count == null)
 +          count = Integer.valueOf(0);
 +        if (count > 3)
 +          throw new Exception("servers are unbalanced! location " + unbalancedLocation + " count " + lastCount + " too far from average " + average);
 +        count++;
 +        state.set(UNBALANCED_COUNT, count);
 +      }
 +      if (last == null)
 +        state.set(LAST_UNBALANCED_TIME, System.currentTimeMillis());
 +    } else {
 +      state.remove(LAST_UNBALANCED_TIME);
 +      state.remove(UNBALANCED_COUNT);
 +    }
 +  }
 +  
++  private static double stddev(Collection<Long> samples, double avg) {
++    int num = samples.size();
++    double sqrtotal = 0.0;
++    for (Long s : samples) {
++      double diff = s.doubleValue() - avg;
++      sqrtotal += diff * diff;
++    }
++    return Math.sqrt(sqrtotal / (double) num);
++  }
 +}


[05/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT

Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 1f4cb4d5bb9b8dc19df0cd1a6b6a95a44a9abeea
Parents: 205f0dc a417424
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 16:23:18 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:23:18 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1f4cb4d5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
index 698b0c0,0000000..a0dd37c
mode 100644,000000..100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
@@@ -1,98 -1,0 +1,110 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.test.randomwalk.concurrent;
 +
++import java.util.Collection;
 +import java.util.HashMap;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Properties;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.test.randomwalk.State;
 +import org.apache.accumulo.test.randomwalk.Test;
 +
 +/**
 + * 
 + */
 +public class CheckBalance extends Test {
 +  
 +  static final String LAST_UNBALANCED_TIME = "lastUnbalancedTime";
 +  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);
 +    for (Entry<Key,Value> entry : scanner) {
 +      String location = entry.getKey().getColumnQualifier().toString();
 +      Long count = counts.get(location);
 +      if (count == null)
 +        count = Long.valueOf(0);
 +      counts.put(location, count + 1);
 +    }
 +    double total = 0.;
 +    for (Long count : counts.values()) {
 +      total += count.longValue();
 +    }
 +    final double average = total / counts.size();
-     
-     // Check for even # of tablets on each node
-     double maxDifference = Math.max(1, average / 5);
++    final double sd = stddev(counts.values(), average);
++    log.debug("average " + average + ", standard deviation " + sd);
++
++    // Check for balanced # of tablets on each node
++    double maxDifference = 2.0 * sd;
 +    String unbalancedLocation = null;
 +    long lastCount = 0L;
 +    boolean balanced = true;
 +    for (Entry<String,Long> entry : counts.entrySet()) {
 +      long thisCount = entry.getValue().longValue();
 +      if (Math.abs(thisCount - average) > maxDifference) {
 +        balanced = false;
 +        log.debug("unbalanced: " + entry.getKey() + " has " + entry.getValue() + " tablets and the average is " + average);
 +        unbalancedLocation = entry.getKey();
 +        lastCount = thisCount;
 +      }
 +    }
 +    
 +    // 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 and it's been at least three checks.
 +    if (!balanced) {
 +      Long last = state.getLong(LAST_UNBALANCED_TIME);
 +      if (last != null && System.currentTimeMillis() - last > 15 * 60 * 1000) {
 +        Integer count = state.getInteger(UNBALANCED_COUNT);
 +        if (count == null)
 +          count = Integer.valueOf(0);
 +        if (count > 3)
 +          throw new Exception("servers are unbalanced! location " + unbalancedLocation + " count " + lastCount + " too far from average " + average);
 +        count++;
 +        state.set(UNBALANCED_COUNT, count);
 +      }
 +      if (last == null)
 +        state.set(LAST_UNBALANCED_TIME, System.currentTimeMillis());
 +    } else {
 +      state.remove(LAST_UNBALANCED_TIME);
 +      state.remove(UNBALANCED_COUNT);
 +    }
 +  }
 +  
++  private static double stddev(Collection<Long> samples, double avg) {
++    int num = samples.size();
++    double sqrtotal = 0.0;
++    for (Long s : samples) {
++      double diff = s.doubleValue() - avg;
++      sqrtotal += diff * diff;
++    }
++    return Math.sqrt(sqrtotal / (double) num);
++  }
 +}


[02/10] git commit: ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

Posted by bh...@apache.org.
ACCUMULO-2488 Change criteria for unbalanced servers in concurrent randomwalk

The Concurrent randomwalk test used to consider servers unbalanced if any server's
tablet count differed from the cluster average by more than a fifth of the average or
by one, whichever was larger. This would cause failures under typical balancings from
the default balancer.

This commit changes the criterion for an unbalanced server to be double the standard
deviation from the cluster average.


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

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: a4174248a96cadcc79a9de4015c90c6618a96418
Parents: 6df83da
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Mar 18 09:12:19 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Mar 18 16:22:22 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/CheckBalance.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a4174248/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
index d00e2b4..5d0b978 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/CheckBalance.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.server.test.randomwalk.concurrent;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -57,9 +58,11 @@ public class CheckBalance extends Test {
       total += count.longValue();
     }
     final double average = total / counts.size();
-    
-    // Check for even # of tablets on each node
-    double maxDifference = Math.max(1, average / 5);
+    final double sd = stddev(counts.values(), average);
+    log.debug("average " + average + ", standard deviation " + sd);
+
+    // Check for balanced # of tablets on each node
+    double maxDifference = 2.0 * sd;
     String unbalancedLocation = null;
     long lastCount = 0L;
     boolean balanced = true;
@@ -94,4 +97,13 @@ public class CheckBalance extends Test {
     }
   }
   
+  private static double stddev(Collection<Long> samples, double avg) {
+    int num = samples.size();
+    double sqrtotal = 0.0;
+    for (Long s : samples) {
+      double diff = s.doubleValue() - avg;
+      sqrtotal += diff * diff;
+    }
+    return Math.sqrt(sqrtotal / (double) num);
+  }
 }