final String columns[] = columnsTmp;
final FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
Instance instance = opts.getInstance();
final ServerConfiguration sconf = new ServerConfiguration(instance);
String tableId = Tables.getNameToIdMap(instance).get(opts.tableName);
if (tableId == null) {
log.error("Unable to find table named " + opts.tableName);
System.exit(-1);
}
Map<KeyExtent,String> locations = new HashMap<KeyExtent,String>();
List<KeyExtent> candidates = findTablets(!opts.selectFarTablets, CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), opts.tableName, instance, locations);
if (candidates.size() < opts.numThreads) {
System.err.println("ERROR : Unable to find " + opts.numThreads + " " + (opts.selectFarTablets ? "far" : "local") + " tablets");
System.exit(-1);
}
List<KeyExtent> tabletsToTest = selectRandomTablets(opts.numThreads, candidates);
Map<KeyExtent,List<String>> tabletFiles = new HashMap<KeyExtent,List<String>>();
for (KeyExtent ke : tabletsToTest) {
List<String> files = getTabletFiles(CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), opts.getInstance(), tableId, ke);
tabletFiles.put(ke, files);
}
System.out.println();
System.out.println("run location : " + InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress());
System.out.println("num threads : " + opts.numThreads);
System.out.println("table : " + opts.tableName);
System.out.println("table id : " + tableId);
for (KeyExtent ke : tabletsToTest) {
System.out.println("\t *** Information about tablet " + ke.getUUID() + " *** ");
System.out.println("\t\t# files in tablet : " + tabletFiles.get(ke).size());
System.out.println("\t\ttablet location : " + locations.get(ke));
reportHdfsBlockLocations(tabletFiles.get(ke));
}
System.out.println("%n*** RUNNING TEST ***%n");
ExecutorService threadPool = Executors.newFixedThreadPool(opts.numThreads);
for (int i = 0; i < opts.iterations; i++) {
ArrayList<Test> tests = new ArrayList<Test>();
for (final KeyExtent ke : tabletsToTest) {
final List<String> files = tabletFiles.get(ke);
Test test = new Test(ke) {
public int runTest() throws Exception {
return readFiles(fs, sconf.getConfiguration(), files, ke, columns);
}
};
tests.add(test);