HBASE-4395 EnableTableHandler races with itself
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1171331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ee4df4fba8
commit
848748b1ae
|
@ -270,6 +270,7 @@ Release 0.91.0 - Unreleased
|
||||||
to contact the sink (JD and Lars Hofhansl)
|
to contact the sink (JD and Lars Hofhansl)
|
||||||
HBASE-4390 [replication] ReplicationSource's UncaughtExceptionHandler
|
HBASE-4390 [replication] ReplicationSource's UncaughtExceptionHandler
|
||||||
shouldn't join
|
shouldn't join
|
||||||
|
HBASE-4395 EnableTableHandler races with itself
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
|
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
|
||||||
|
|
|
@ -109,32 +109,28 @@ public class EnableTableHandler extends EventHandler {
|
||||||
// Set table enabling flag up in zk.
|
// Set table enabling flag up in zk.
|
||||||
this.assignmentManager.getZKTable().setEnablingTable(this.tableNameStr);
|
this.assignmentManager.getZKTable().setEnablingTable(this.tableNameStr);
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
while (true) {
|
|
||||||
// Get the regions of this table. We're done when all listed
|
// Get the regions of this table. We're done when all listed
|
||||||
// tables are onlined.
|
// tables are onlined.
|
||||||
List<HRegionInfo> regionsInMeta =
|
List<HRegionInfo> regionsInMeta =
|
||||||
MetaReader.getTableRegions(this.ct, tableName, true);
|
MetaReader.getTableRegions(this.ct, tableName, true);
|
||||||
int countOfRegionsInTable = regionsInMeta.size();
|
int countOfRegionsInTable = regionsInMeta.size();
|
||||||
List<HRegionInfo> regions = regionsToAssign(regionsInMeta);
|
List<HRegionInfo> regions = regionsToAssign(regionsInMeta);
|
||||||
if (regions.size() == 0) {
|
int regionsCount = regions.size();
|
||||||
|
if (regionsCount == 0) {
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
LOG.info("Table has " + countOfRegionsInTable + " regions of which " +
|
LOG.info("Table has " + countOfRegionsInTable + " regions of which " +
|
||||||
regions.size() + " are offline.");
|
regionsCount + " are offline.");
|
||||||
BulkEnabler bd = new BulkEnabler(this.server, regions,
|
BulkEnabler bd = new BulkEnabler(this.server, regions,
|
||||||
countOfRegionsInTable);
|
countOfRegionsInTable);
|
||||||
try {
|
try {
|
||||||
if (bd.bulkAssign()) {
|
if (bd.bulkAssign()) {
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.warn("Enable was interrupted");
|
LOG.warn("Enable was interrupted");
|
||||||
// Preserve the interrupt.
|
// Preserve the interrupt.
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Flip the table to enabled.
|
// Flip the table to enabled.
|
||||||
if (done) this.assignmentManager.getZKTable().setEnabledTable(
|
if (done) this.assignmentManager.getZKTable().setEnabledTable(
|
||||||
|
@ -191,10 +187,17 @@ public class EnableTableHandler extends EventHandler {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
long remaining = timeout;
|
long remaining = timeout;
|
||||||
List<HRegionInfo> regions = null;
|
List<HRegionInfo> regions = null;
|
||||||
|
int lastNumberOfRegions = this.countOfRegionsInTable;
|
||||||
while (!server.isStopped() && remaining > 0) {
|
while (!server.isStopped() && remaining > 0) {
|
||||||
Thread.sleep(waitingTimeForEvents);
|
Thread.sleep(waitingTimeForEvents);
|
||||||
regions = assignmentManager.getRegionsOfTable(tableName);
|
regions = assignmentManager.getRegionsOfTable(tableName);
|
||||||
if (isDone(regions)) break;
|
if (isDone(regions)) break;
|
||||||
|
|
||||||
|
// Punt on the timeout as long we make progress
|
||||||
|
if (regions.size() > lastNumberOfRegions) {
|
||||||
|
lastNumberOfRegions = regions.size();
|
||||||
|
timeout += waitingTimeForEvents;
|
||||||
|
}
|
||||||
remaining = timeout - (System.currentTimeMillis() - startTime);
|
remaining = timeout - (System.currentTimeMillis() - startTime);
|
||||||
}
|
}
|
||||||
return isDone(regions);
|
return isDone(regions);
|
||||||
|
|
Loading…
Reference in New Issue