Thread t = new Thread() {
@Override
public void run() {
String scanner;
try {
Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
scanner = client2.createScanner(creds, "slow", null);
client2.nextK(scanner, 10);
client2.closeScanner(scanner);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
t.start();
// look for the scan many times
List<ActiveScan> scans = new ArrayList<ActiveScan>();
for (int i = 0; i < 100 && scans.isEmpty(); i++) {
for (String tserver : client.getTabletServers(creds)) {
List<ActiveScan> scansForServer = client.getActiveScans(creds, tserver);
for (ActiveScan scan : scansForServer) {
if ("root".equals(scan.getUser())) {
scans.add(scan);
}
}
if (!scans.isEmpty())
break;
UtilWaitThread.sleep(100);
}
}
t.join();
assertFalse(scans.isEmpty());
boolean found = false;
Map<String,String> map = null;
for (int i = 0; i < scans.size() && !found; i++) {
ActiveScan scan = scans.get(i);
if ("root".equals(scan.getUser())) {
assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
assertEquals(ScanType.SINGLE, scan.getType());
assertEquals("slow", scan.getTable());
map = client.tableIdMap(creds);
assertEquals(map.get("slow"), scan.getExtent().tableId);
assertTrue(scan.getExtent().endRow == null);
assertTrue(scan.getExtent().prevEndRow == null);
found = true;
}
}
assertTrue("Could not find a scan against the 'slow' table", found);
// start a compaction
t = new Thread() {
@Override
public void run() {
try {
Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
client2.compactTable(creds, "slow", null, null, null, true, true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};