Search in sources :

Example 21 with ServerMutation

use of org.apache.accumulo.server.data.ServerMutation in project accumulo by apache.

the class SortedLogRecoveryTest method runPathTest.

private void runPathTest(boolean startMatches, String compactionStartFile, String... tabletFiles) throws IOException {
    Mutation m1 = new ServerMutation(new Text("row1"));
    m1.put("foo", "bar", "v1");
    Mutation m2 = new ServerMutation(new Text("row1"));
    m2.put("foo", "bar", "v2");
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 2, extent), createKeyValue(MUTATION, 2, 2, m1), createKeyValue(COMPACTION_START, 3, 2, compactionStartFile), createKeyValue(MUTATION, 4, 2, m2) };
    Arrays.sort(entries);
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    HashSet<String> filesSet = new HashSet<>();
    filesSet.addAll(Arrays.asList(tabletFiles));
    List<Mutation> mutations = recover(logs, filesSet, extent);
    if (!startMatches) {
        Assert.assertEquals(2, mutations.size());
        Assert.assertEquals(m1, mutations.get(0));
        Assert.assertEquals(m2, mutations.get(1));
    } else {
        Assert.assertEquals(1, mutations.size());
        Assert.assertEquals(m2, mutations.get(0));
    }
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Example 22 with ServerMutation

use of org.apache.accumulo.server.data.ServerMutation in project accumulo by apache.

the class SortedLogRecoveryTest method testCompactionCrossesLogs5.

@Test
public void testCompactionCrossesLogs5() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    Mutation m4 = new ServerMutation(new Text("row4"));
    m4.put(cf, cq, value);
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(COMPACTION_START, 3, 1, "/t1/f1"), createKeyValue(MUTATION, 2, 1, ignored), createKeyValue(MUTATION, 4, 1, ignored) };
    KeyValue[] entries2 = new KeyValue[] { createKeyValue(OPEN, 5, -1, "2"), createKeyValue(DEFINE_TABLET, 6, 1, extent), createKeyValue(MUTATION, 7, 1, ignored) };
    KeyValue[] entries3 = new KeyValue[] { createKeyValue(OPEN, 8, -1, "3"), createKeyValue(DEFINE_TABLET, 9, 1, extent), createKeyValue(COMPACTION_FINISH, 10, 1, "/t1/f1"), createKeyValue(COMPACTION_START, 12, 1, "/t1/f2"), createKeyValue(COMPACTION_FINISH, 13, 1, "/t1/f2"), // createKeyValue(COMPACTION_FINISH, 14, 1, null),
    createKeyValue(MUTATION, 11, 1, ignored), createKeyValue(MUTATION, 15, 1, m), createKeyValue(MUTATION, 16, 1, m2) };
    KeyValue[] entries4 = new KeyValue[] { createKeyValue(OPEN, 17, -1, "4"), createKeyValue(DEFINE_TABLET, 18, 1, extent), createKeyValue(COMPACTION_START, 20, 1, "/t1/f3"), createKeyValue(MUTATION, 19, 1, m3), createKeyValue(MUTATION, 21, 1, m4) };
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    logs.put("entries2", entries2);
    logs.put("entries3", entries3);
    logs.put("entries4", entries4);
    // Recover
    List<Mutation> mutations = recover(logs, extent);
    // Verify recovered data
    Assert.assertEquals(4, mutations.size());
    Assert.assertEquals(m, mutations.get(0));
    Assert.assertEquals(m2, mutations.get(1));
    Assert.assertEquals(m3, mutations.get(2));
    Assert.assertEquals(m4, mutations.get(3));
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 23 with ServerMutation

use of org.apache.accumulo.server.data.ServerMutation in project accumulo by apache.

the class SortedLogRecoveryTest method testNoFinish1.

@Test
public void testNoFinish1() throws Exception {
    // its possible that a minor compaction finishes successfully, but the process dies before writing the compaction event
    Mutation ignored = new ServerMutation(new Text("row1"));
    ignored.put("foo", "bar", "v1");
    Mutation m = new ServerMutation(new Text("row1"));
    m.put("foo", "bar", "v2");
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 2, extent), createKeyValue(MUTATION, 2, 2, ignored), createKeyValue(COMPACTION_START, 3, 2, "/t/f1"), createKeyValue(MUTATION, 4, 2, m) };
    Arrays.sort(entries);
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    List<Mutation> mutations = recover(logs, Collections.singleton("/t/f1"), extent);
    Assert.assertEquals(1, mutations.size());
    Assert.assertEquals(m, mutations.get(0));
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 24 with ServerMutation

use of org.apache.accumulo.server.data.ServerMutation in project accumulo by apache.

the class SortedLogRecoveryTest method testBug2.

@Test
public void testBug2() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(COMPACTION_START, 2, 1, "/t1/f1"), createKeyValue(COMPACTION_FINISH, 4, 1, null), createKeyValue(MUTATION, 3, 1, m) };
    KeyValue[] entries2 = new KeyValue[] { createKeyValue(OPEN, 5, -1, "1"), createKeyValue(DEFINE_TABLET, 6, 1, extent), createKeyValue(COMPACTION_START, 8, 1, "/t1/f1"), createKeyValue(MUTATION, 7, 1, m2), createKeyValue(MUTATION, 9, 1, m3) };
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    logs.put("entries2", entries2);
    // Recover
    List<Mutation> mutations = recover(logs, extent);
    // Verify recovered data
    Assert.assertEquals(3, mutations.size());
    Assert.assertEquals(m, mutations.get(0));
    Assert.assertEquals(m2, mutations.get(1));
    Assert.assertEquals(m3, mutations.get(2));
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 25 with ServerMutation

use of org.apache.accumulo.server.data.ServerMutation in project accumulo by apache.

the class SortedLogRecoveryTest method testSkipSuccessfulCompaction.

@Test
public void testSkipSuccessfulCompaction() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(COMPACTION_START, 3, 1, "/t1/f1"), createKeyValue(COMPACTION_FINISH, 4, 1, null), createKeyValue(MUTATION, 2, 1, ignored), createKeyValue(MUTATION, 5, 1, m) };
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("testlog", entries);
    // Recover
    List<Mutation> mutations = recover(logs, extent);
    // Verify recovered data
    Assert.assertEquals(1, mutations.size());
    Assert.assertEquals(m, mutations.get(0));
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

ServerMutation (org.apache.accumulo.server.data.ServerMutation)30 Test (org.junit.Test)26 Mutation (org.apache.accumulo.core.data.Mutation)24 Text (org.apache.hadoop.io.Text)22 TreeMap (java.util.TreeMap)17 LogFileKey (org.apache.accumulo.tserver.logger.LogFileKey)7 LogFileValue (org.apache.accumulo.tserver.logger.LogFileValue)7 DataOutputStream (java.io.DataOutputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 DataInputStream (java.io.DataInputStream)4 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)4 Value (org.apache.accumulo.core.data.Value)4 Status (org.apache.accumulo.server.replication.proto.Replication.Status)4 Path (org.apache.hadoop.fs.Path)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 HashMap (java.util.HashMap)3 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)3 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)3 ReplicationTarget (org.apache.accumulo.core.replication.ReplicationTarget)3