// Up number of retries. Needed while cluster starts up. Its been set to 1
// above.
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);
assertTrue(hb.isMasterRunning());
HTableDescriptor [] tables = hb.listTables();
boolean foundTable = false;
for (int i = 0; i < tables.length; i++) {
if (Bytes.equals(Bytes.toBytes(TABLENAME), tables[i].getName())) {
foundTable = true;
break;
}
}
assertTrue(foundTable);
LOG.info(TABLENAME + " exists. Now waiting till startcode " +
"changes before opening a scanner");
waitOnStartCodeChange(retries);
// Delete again so we go get it all fresh.
HConnectionManager.deleteConnectionInfo();
HTable t = new HTable(this.conf, TABLENAME);
int count = 0;
LOG.info("OPENING SCANNER");
Scanner s = t.getScanner(TABLENAME_COLUMNS);
try {
for (RowResult r: s) {
if (r == null || r.size() == 0) {
break;
}
count++;
if (count % 1000 == 0 && count > 0) {
LOG.info("Iterated over " + count + " rows.");
}
}
assertEquals(EXPECTED_COUNT, count);
} finally {
s.close();
}
} finally {
HConnectionManager.deleteConnectionInfo();
cluster.shutdown();
}
}