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:43:59 UTC
svn commit: r1465065 -
/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
Author: ecn
Date: Fri Apr 5 17:43:59 2013
New Revision: 1465065
URL: http://svn.apache.org/r1465065
Log:
ACCUMULO-1239 make balance checker triple-check
Modified:
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java?rev=1465065&r1=1465064&r2=1465065&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java Fri Apr 5 17:43:59 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);
}
}