From 27f37b6365d13cb26b33109ba4924cd2bd69b513 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Mon, 21 Jul 2008 21:54:44 +0000 Subject: [PATCH] HBASE-743 bin/hbase migrate upgrade fails when redo logs exists git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@678581 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../apache/hadoop/hbase/master/BaseScanner.java | 10 +--------- .../apache/hadoop/hbase/master/ServerManager.java | 15 +++++++++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e3e12369f97..1ae637091bd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -197,6 +197,7 @@ Trunk (unreleased changes) HBASE-424 Should be able to enable/disable .META. table HBASE-679 Regionserver addresses are still not right in the new tables page HBASE-758 Throwing IOE read-only when should be throwing NSRE + HBASE-743 bin/hbase migrate upgrade fails when redo logs exists IMPROVEMENTS HBASE-559 MR example job to count table rows diff --git a/src/java/org/apache/hadoop/hbase/master/BaseScanner.java b/src/java/org/apache/hadoop/hbase/master/BaseScanner.java index 0f75fc77d0f..22d900369a8 100644 --- a/src/java/org/apache/hadoop/hbase/master/BaseScanner.java +++ b/src/java/org/apache/hadoop/hbase/master/BaseScanner.java @@ -172,7 +172,7 @@ abstract class BaseScanner extends Chore implements HConstants { String serverName = Writables.cellToString(values.get(COL_SERVER)); long startCode = Writables.cellToLong(values.get(COL_STARTCODE)); if (LOG.isDebugEnabled()) { - LOG.debug(Thread.currentThread().getName() + info.toString() + + LOG.debug(Thread.currentThread().getName() + " " + info.toString() + "}, SERVER => '" + serverName + "', STARTCODE => " + startCode); } @@ -261,25 +261,17 @@ abstract class BaseScanner extends Chore implements HConstants { RowResult rowContent) throws IOException { boolean result = false; - boolean hasReferencesA = hasReferences(metaRegionName, srvr, parent.getRegionName(), rowContent, COL_SPLITA); boolean hasReferencesB = hasReferences(metaRegionName, srvr, parent.getRegionName(), rowContent, COL_SPLITB); - if (!hasReferencesA && !hasReferencesB) { LOG.info("Deleting region " + parent.getRegionNameAsString() + " because daughter splits no longer hold references"); HRegion.deleteRegion(master.fs, master.rootdir, parent); - HRegion.removeRegionFromMETA(srvr, metaRegionName, parent.getRegionName()); result = true; - } else if (LOG.isDebugEnabled()) { - // If debug, note we checked and current state of daughters. - LOG.debug("Checked " + parent.getRegionNameAsString() + - " for references: splitA: " + hasReferencesA + ", splitB: "+ - hasReferencesB); } return result; } diff --git a/src/java/org/apache/hadoop/hbase/master/ServerManager.java b/src/java/org/apache/hadoop/hbase/master/ServerManager.java index c9feac6ab58..e3094b22ca4 100644 --- a/src/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/src/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -73,6 +73,10 @@ class ServerManager implements HConstants { private HMaster master; private final Leases serverLeases; + + // Last time we logged average load. + private volatile long lastLogOfAverageLaod = 0; + private final long loggingPeriodForAverageLoad; /** * @param master @@ -82,6 +86,8 @@ class ServerManager implements HConstants { serverLeases = new Leases(master.leaseTimeout, master.getConfiguration().getInt("hbase.master.lease.thread.wakefrequency", 15 * 1000)); + this.loggingPeriodForAverageLoad = master.getConfiguration(). + getLong("hbase.master.avgload.logging.period", 15000); } /** @@ -557,18 +563,19 @@ class ServerManager implements HConstants { int totalLoad = 0; int numServers = 0; double averageLoad = 0.0; - synchronized (serversToLoad) { numServers = serversToLoad.size(); - for (HServerLoad load : serversToLoad.values()) { totalLoad += load.getNumberOfRegions(); } - averageLoad = Math.ceil((double)totalLoad / (double)numServers); - if (LOG.isDebugEnabled()) { + // Only log on a period, not on every invocation of this method. + long now = System.currentTimeMillis(); + if (LOG.isDebugEnabled() && + (now > (this.loggingPeriodForAverageLoad + this.lastLogOfAverageLaod))) { LOG.debug("Total Load: " + totalLoad + ", Num Servers: " + numServers + ", Avg Load: " + averageLoad); + this.lastLogOfAverageLaod = now; } } return averageLoad;