use of org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter in project accumulo-examples by apache.
the class ExamplesIT method testDirList.
@Test
public void testDirList() throws Exception {
String[] names = getUniqueNames(3);
String dirTable = names[0], indexTable = names[1], dataTable = names[2];
String[] args;
String dirListDirectory;
switch(getClusterType()) {
case MINI:
dirListDirectory = ((MiniAccumuloClusterImpl) getCluster()).getConfig().getDir().getAbsolutePath();
break;
case STANDALONE:
dirListDirectory = ((StandaloneAccumuloCluster) getCluster()).getAccumuloHome();
break;
default:
throw new RuntimeException("Unknown cluster type");
}
assumeTrue(new File(dirListDirectory).exists());
// Index a directory listing on /tmp. If this is running against a standalone cluster, we can't guarantee Accumulo source will be there.
args = new String[] { "-c", getConnectionFile(), "--dirTable", dirTable, "--indexTable", indexTable, "--dataTable", dataTable, "--vis", visibility, "--chunkSize", Integer.toString(10000), dirListDirectory };
Entry<Integer, String> entry = getClusterControl().execWithStdout(Ingest.class, args);
assertEquals("Got non-zero return code. Stdout=" + entry.getValue(), 0, entry.getKey().intValue());
String expectedFile;
switch(getClusterType()) {
case MINI:
// Should be present in a minicluster dir
expectedFile = "accumulo-site.xml";
break;
case STANDALONE:
// Should be in place on standalone installs (not having to follow symlinks)
expectedFile = "LICENSE";
break;
default:
throw new RuntimeException("Unknown cluster type");
}
args = new String[] { "-c", getConnectionFile(), "-t", indexTable, "--auths", auths, "--search", "--path", expectedFile };
entry = getClusterControl().execWithStdout(QueryUtil.class, args);
if (ClusterType.MINI == getClusterType()) {
MiniAccumuloClusterImpl impl = (MiniAccumuloClusterImpl) cluster;
for (LogWriter writer : impl.getLogWriters()) {
writer.flush();
}
}
log.info("result " + entry.getValue());
assertEquals(0, entry.getKey().intValue());
assertTrue(entry.getValue().contains(expectedFile));
}
use of org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter in project accumulo by apache.
the class MiniAccumuloClusterControl method execWithStdout.
@Override
public Entry<Integer, String> execWithStdout(Class<?> clz, String[] args) throws IOException {
Process p = cluster.exec(clz, args);
int exitCode;
try {
exitCode = p.waitFor();
} catch (InterruptedException e) {
log.warn("Interrupted waiting for process to exit", e);
Thread.currentThread().interrupt();
throw new IOException(e);
}
for (LogWriter writer : cluster.getLogWriters()) {
writer.flush();
}
return Maps.immutableEntry(exitCode, readAll(new FileInputStream(cluster.getConfig().getLogDir() + "/" + clz.getSimpleName() + "_" + p.hashCode() + ".out")));
}
Aggregations