Search in sources :

Example 1 with LogWriter

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));
}
Also used : QueryUtil(org.apache.accumulo.examples.dirlist.QueryUtil) LogWriter(org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter) MiniAccumuloClusterImpl(org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl) File(java.io.File) TableToFile(org.apache.accumulo.examples.mapreduce.TableToFile) InterferenceTest(org.apache.accumulo.examples.isolation.InterferenceTest) Test(org.junit.Test)

Example 2 with LogWriter

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")));
}
Also used : LogWriter(org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

LogWriter (org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 QueryUtil (org.apache.accumulo.examples.dirlist.QueryUtil)1 InterferenceTest (org.apache.accumulo.examples.isolation.InterferenceTest)1 TableToFile (org.apache.accumulo.examples.mapreduce.TableToFile)1 MiniAccumuloClusterImpl (org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl)1 Test (org.junit.Test)1