HBASE-640 TestMigrate failing on hudson

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@661211 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-05-29 04:54:27 +00:00
parent d5b3dd2cd0
commit f4d0096a06
5 changed files with 57 additions and 26 deletions

View File

@ -28,6 +28,7 @@ Hbase Change Log
write-ahead-log edits
HBASE-646 EOFException opening HStoreFile info file (spin on HBASE-645and 550)
HBASE-648 If mapfile index is empty, run repair
HBASE-640 TestMigrate failing on hudson
IMPROVEMENTS
HBASE-559 MR example job to count table rows

View File

@ -69,7 +69,7 @@ public class HConnectionManager implements HConstants {
// Note that although the Map is synchronized, the objects it contains
// are mutable and hence require synchronized access to them
private static final Map<String, TableServers> HBASE_INSTANCES =
Collections.synchronizedMap(new HashMap<String, TableServers>());
new ConcurrentHashMap<String, TableServers>();
/**
* Get the connection object for the instance specified by the configuration
@ -81,9 +81,7 @@ public class HConnectionManager implements HConstants {
TableServers connection;
synchronized (HBASE_INSTANCES) {
String instanceName = conf.get(HBASE_DIR);
connection = HBASE_INSTANCES.get(instanceName);
if (connection == null) {
connection = new TableServers(conf);
HBASE_INSTANCES.put(instanceName, connection);
@ -121,11 +119,12 @@ public class HConnectionManager implements HConstants {
private volatile HBaseConfiguration conf;
// Known region HServerAddress.toString() -> HRegionInterface
private Map<String, HRegionInterface> servers;
private final Map<String, HRegionInterface> servers =
new ConcurrentHashMap<String, HRegionInterface>();
private HRegionLocation rootRegionLocation;
private Map<Integer, SoftSortedMap<byte [], HRegionLocation>>
private final Map<Integer, SoftSortedMap<byte [], HRegionLocation>>
cachedRegionLocations = Collections.synchronizedMap(
new HashMap<Integer, SoftSortedMap<byte [], HRegionLocation>>());
@ -156,7 +155,6 @@ public class HConnectionManager implements HConstants {
this.master = null;
this.masterChecked = false;
this.servers = new ConcurrentHashMap<String, HRegionInterface>();
}
/** {@inheritDoc} */
@ -596,15 +594,12 @@ public class HConnectionManager implements HConstants {
}
/** {@inheritDoc} */
public HRegionInterface getHRegionConnection(
HServerAddress regionServer)
public HRegionInterface getHRegionConnection(HServerAddress regionServer)
throws IOException {
HRegionInterface server;
synchronized (this.servers) {
// See if we already have a connection
server = this.servers.get(regionServer.toString());
if (server == null) { // Get a connection
long versionId = 0;
try {
@ -643,11 +638,8 @@ public class HConnectionManager implements HConstants {
*/
private HRegionLocation locateRootRegion()
throws IOException {
getMaster();
HServerAddress rootRegionAddress = null;
for (int tries = 0; tries < numRetries; tries++) {
int localTimeouts = 0;
@ -669,12 +661,12 @@ public class HConnectionManager implements HConstants {
localTimeouts++;
}
}
if (rootRegionAddress == null) {
throw new NoServerForRegionException(
"Timed out trying to locate root region");
}
// get a connection to the region server
HRegionInterface server = getHRegionConnection(rootRegionAddress);

View File

@ -92,7 +92,7 @@ public interface HRegionInterface extends VersionedProtocol {
public Cell[] get(final byte [] regionName, final byte [] row,
final byte [] column, final long timestamp, final int numVersions)
throws IOException;
/**
* Get all the data for the specified row at a given timestamp
*
@ -213,7 +213,7 @@ public interface HRegionInterface extends VersionedProtocol {
* @throws IOException
*/
public long openScanner(final byte [] regionName, final byte [][] columns,
final byte []startRow, long timestamp, RowFilterInterface filter)
final byte [] startRow, long timestamp, RowFilterInterface filter)
throws IOException;
/**

View File

@ -1307,7 +1307,7 @@ public class HStore implements HConstants {
/**
* Get the value for the indicated HStoreKey. Grab the target value and the
* previous 'numVersions-1' values, as well.
* previous <code>numVersions - 1</code> values, as well.
*
* Use {@link HConstants.ALL_VERSIONS} to retrieve all versions.
* @param key

View File

@ -130,10 +130,13 @@ public class TestMigrate extends HBaseTestCase {
// created earlier when no master was around. The fact that there was no
// master gets cached. Need to delete so we go get master afresh.
HConnectionManager.deleteConnection(this.conf);
LOG.info("Start a cluster against migrated FS");
// Up number of retries. Needed while cluster starts up. Its been set to 1
// above.
this.conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER_KEY, 3);
final int retries = 5;
this.conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER_KEY, retries);
MiniHBaseCluster cluster = new MiniHBaseCluster(this.conf, 1);
try {
HBaseAdmin hb = new HBaseAdmin(this.conf);
@ -147,15 +150,11 @@ public class TestMigrate extends HBaseTestCase {
}
}
assertTrue(foundTable);
LOG.info(TABLENAME + " exists. Creating an HTable to go against " +
TABLENAME + " and master " + this.conf.get(HConstants.MASTER_ADDRESS));
LOG.info(TABLENAME + " exists. Now waiting till startcode " +
"changes before opening a scanner");
waitOnStartCodeChange(retries);
HTable t = new HTable(this.conf, TABLENAME);
int count = 0;
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOG.info("OPENING SCANNER");
Scanner s = t.getScanner(TABLENAME_COLUMNS);
try {
@ -177,6 +176,45 @@ public class TestMigrate extends HBaseTestCase {
}
}
/*
* Wait till the startcode changes before we put up a scanner. Otherwise
* we tend to hang, at least on hudson and I've had it time to time on
* my laptop. The hang is down in RPC Client doing its call. It
* never returns though the socket has a read timeout of 60 seconds by
* default. St.Ack
* @param retries How many retries to run.
* @throws IOException
*/
private void waitOnStartCodeChange(final int retries) throws IOException {
HTable m = new HTable(this.conf, HConstants.META_TABLE_NAME);
// This is the start code that is in the old data.
long oldStartCode = 1199736332062L;
// This is the first row for the TestTable that is in the old data.
byte [] row = Bytes.toBytes("TestUpgrade,,1199736362468");
long pause = conf.getLong("hbase.client.pause", 5 * 1000);
long startcode = -1;
boolean changed = false;
for (int i = 0; i < retries; i++) {
startcode = Writables.cellToLong(m.get(row, HConstants.COL_STARTCODE));
if (startcode != oldStartCode) {
changed = true;
break;
}
if ((i + 1) != retries) {
try {
Thread.sleep(pause);
} catch (InterruptedException e) {
// continue
}
}
}
// If after all attempts startcode has not changed, fail.
if (!changed) {
throw new IOException("Startcode didn't change after " + retries +
" attempts");
}
}
private void unzip(ZipInputStream zip, FileSystem dfs, Path root)
throws IOException {
ZipEntry e = null;