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));
}
}
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));
}
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));
}
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));
}
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));
}
Aggregations