Search in sources :

Example 6 with ProcessInfo

use of org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.ProcessInfo in project accumulo by apache.

the class GarbageCollectorIT method testInvalidDelete.

@Test
public void testInvalidDelete() throws Exception {
    killMacGc();
    try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
        String table = getUniqueNames(1)[0];
        c.tableOperations().create(table);
        try (BatchWriter bw = c.createBatchWriter(table)) {
            Mutation m1 = new Mutation("r1");
            m1.put("cf1", "cq1", "v1");
            bw.addMutation(m1);
        }
        c.tableOperations().flush(table, null, null, true);
        // ensure an invalid delete entry does not cause GC to go berserk ACCUMULO-2520
        c.securityOperations().grantTablePermission(c.whoami(), MetadataTable.NAME, TablePermission.WRITE);
        try (BatchWriter bw = c.createBatchWriter(MetadataTable.NAME)) {
            bw.addMutation(createDelMutation("", "", "", ""));
            bw.addMutation(createDelMutation("", "testDel", "test", "valueTest"));
            // path is invalid but value is expected - only way the invalid entry will come through
            // processing and
            // show up to produce error in output to allow while loop to end
            bw.addMutation(createDelMutation("/", "", "", SkewedKeyValue.STR_NAME));
        }
        ProcessInfo gc = cluster.exec(SimpleGarbageCollector.class);
        try {
            String output = "";
            while (!output.contains("Ignoring invalid deletion candidate")) {
                sleepUninterruptibly(250, TimeUnit.MILLISECONDS);
                try {
                    output = gc.readStdOut();
                } catch (UncheckedIOException ioe) {
                    log.error("Could not read all from cluster.", ioe);
                }
            }
        } finally {
            gc.getProcess().destroy();
        }
        try (Scanner scanner = c.createScanner(table, Authorizations.EMPTY)) {
            Iterator<Entry<Key, Value>> iter = scanner.iterator();
            assertTrue(iter.hasNext());
            Entry<Key, Value> entry = iter.next();
            assertEquals("r1", entry.getKey().getRow().toString());
            assertEquals("cf1", entry.getKey().getColumnFamily().toString());
            assertEquals("cq1", entry.getKey().getColumnQualifier().toString());
            assertEquals("v1", entry.getValue().toString());
            assertFalse(iter.hasNext());
        }
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Scanner(org.apache.accumulo.core.client.Scanner) Entry(java.util.Map.Entry) Value(org.apache.accumulo.core.data.Value) SkewedKeyValue(org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection.SkewedKeyValue) UncheckedIOException(java.io.UncheckedIOException) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) ProcessInfo(org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.ProcessInfo) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

ProcessInfo (org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.ProcessInfo)6 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)5 Test (org.junit.Test)5 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)2 BatchWriter (org.apache.accumulo.core.client.BatchWriter)2 Mutation (org.apache.accumulo.core.data.Mutation)2 TableId (org.apache.accumulo.core.data.TableId)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1 Scanner (org.apache.accumulo.core.client.Scanner)1 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 ExternalCompactionFinalState (org.apache.accumulo.core.metadata.schema.ExternalCompactionFinalState)1 ExternalCompactionId (org.apache.accumulo.core.metadata.schema.ExternalCompactionId)1 ExternalCompactionMetadata (org.apache.accumulo.core.metadata.schema.ExternalCompactionMetadata)1 SkewedKeyValue (org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection.SkewedKeyValue)1