HBASE-3904 Revert patch v6 from TRUNK

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1145906 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-07-13 08:47:41 +00:00
parent 1add4cc5d2
commit de919df41a
1 changed files with 40 additions and 44 deletions

View File

@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.client;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
@ -334,52 +333,49 @@ public class HBaseAdmin implements Abortable, Closeable {
} catch (SocketTimeoutException ste) { } catch (SocketTimeoutException ste) {
LOG.warn("Creating " + desc.getNameAsString() + " took too long", ste); LOG.warn("Creating " + desc.getNameAsString() + " took too long", ste);
} }
int numRegs = splitKeys == null ? 1 : splitKeys.length + 1; int numRegs = splitKeys == null ? 1 : splitKeys.length+1;
int prevRegCount = 0; for (int tries = 0; tries < numRetries; tries++) {
for (int tries = 0; tries < numRetries; ++tries) { try {
// Wait for new table to come on-line // Wait for new table to come on-line
final AtomicInteger actualRegCount = new AtomicInteger(0); final AtomicInteger actualRegCount = new AtomicInteger(0);
MetaScannerVisitor visitor = new MetaScannerVisitor() {
@Override MetaScannerVisitor visitor = new MetaScannerVisitor() {
public boolean processRow(Result rowResult) throws IOException { public boolean processRow(Result rowResult) throws IOException {
HRegionInfo info = Writables.getHRegionInfo( HRegionInfo info = Writables.getHRegionInfo(
rowResult.getValue(HConstants.CATALOG_FAMILY, rowResult.getValue(HConstants.CATALOG_FAMILY,
HConstants.REGIONINFO_QUALIFIER)); HConstants.REGIONINFO_QUALIFIER));
if (!(Bytes.equals(info.getTableName(), desc.getName()))) {
return false; if (!(Bytes.equals(info.getTableName(), desc.getName()))) {
return false;
}
String hostAndPort = null;
byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
HConstants.SERVER_QUALIFIER);
if (value != null && value.length > 0) {
hostAndPort = Bytes.toString(value);
}
if (!(info.isOffline() || info.isSplit()) && hostAndPort != null) {
actualRegCount.incrementAndGet();
}
return true;
} }
String hostAndPort = null;
byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY, };
HConstants.SERVER_QUALIFIER); MetaScanner.metaScan(conf, visitor, desc.getName());
// Make sure that regions are assigned to server if (actualRegCount.get() == numRegs)
if (value != null && value.length > 0) { break;
hostAndPort = Bytes.toString(value); } catch (RegionException e) {
}
if (!(info.isOffline() || info.isSplit()) && hostAndPort != null) {
actualRegCount.incrementAndGet();
}
return true;
}
};
MetaScanner.metaScan(conf, visitor, desc.getName());
if (actualRegCount.get() != numRegs) {
if (tries == numRetries - 1) { if (tries == numRetries - 1) {
throw new RegionOfflineException("Only " + actualRegCount.get() + // Ran out of tries
" of " + numRegs + " regions are online; retries exhausted."); throw e;
} }
try { // Sleep }
Thread.sleep(getPauseTime(tries)); try {
} catch (InterruptedException e) { Thread.sleep(getPauseTime(tries));
throw new InterruptedIOException("Interrupted when opening" + } catch (InterruptedException e) {
" regions; " + actualRegCount.get() + " of " + numRegs + // Just continue; ignore the interruption.
" regions processed so far");
}
if (actualRegCount.get() > prevRegCount) { // Making progress
prevRegCount = actualRegCount.get();
tries = -1;
}
} else {
return;
} }
} }
} }