Search in sources :

Example 1 with ServerMutation

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

the class LogicalTimeTest method testSetUpdateTimes.

@Test
public void testSetUpdateTimes() {
    List<Mutation> ms = new java.util.ArrayList<>();
    ServerMutation m = createMock(ServerMutation.class);
    ServerMutation m2 = createMock(ServerMutation.class);
    m.setSystemTimestamp(1235L);
    replay(m);
    m2.setSystemTimestamp(1236L);
    replay(m2);
    ms.add(m);
    ms.add(m2);
    long currTime = ltime.setUpdateTimes(ms);
    assertEquals(TIME + 2L, currTime);
    verify(m);
    verify(m2);
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) Mutation(org.apache.accumulo.core.data.Mutation) Test(org.junit.Test)

Example 2 with ServerMutation

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

the class MillisTimeTest method testSetUpdateTimes.

@Test
public void testSetUpdateTimes() {
    List<Mutation> ms = new java.util.ArrayList<>();
    ServerMutation m = createMock(ServerMutation.class);
    m.setSystemTimestamp(anyLong());
    replay(m);
    ms.add(m);
    long currTime = mtime.setUpdateTimes(ms);
    assertTrue(currTime > TIME);
    verify(m);
}
Also used : ServerMutation(org.apache.accumulo.server.data.ServerMutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) Mutation(org.apache.accumulo.core.data.Mutation) Test(org.junit.Test)

Example 3 with ServerMutation

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

the class SortedLogRecoveryTest method testSimple.

@Test
public void testSimple() throws IOException {
    // Create a test log
    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(MUTATION, 2, 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)

Example 4 with ServerMutation

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

the class SortedLogRecoveryTest method testCompactionCrossesLogs4.

@Test
public void testCompactionCrossesLogs4() 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);
    Mutation m5 = new ServerMutation(new Text("row5"));
    m5.put(cf, cq, value);
    Mutation m6 = new ServerMutation(new Text("row6"));
    m6.put(cf, cq, value);
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(COMPACTION_START, 4, 1, "/t1/f1"), // createKeyValue(COMPACTION_FINISH, 5, 1, null),
    createKeyValue(MUTATION, 2, 1, m), createKeyValue(MUTATION, 3, 1, m2) };
    KeyValue[] entries2 = new KeyValue[] { createKeyValue(OPEN, 5, -1, "2"), createKeyValue(DEFINE_TABLET, 6, 1, extent), createKeyValue(MUTATION, 7, 1, m3), createKeyValue(MUTATION, 8, 1, m4) };
    KeyValue[] entries3 = new KeyValue[] { createKeyValue(OPEN, 9, -1, "3"), createKeyValue(DEFINE_TABLET, 10, 1, extent), // createKeyValue(COMPACTION_FINISH, 11, 1, null),
    createKeyValue(COMPACTION_START, 12, 1, "/t1/f1"), // createKeyValue(COMPACTION_FINISH, 19, 1, null),
    createKeyValue(MUTATION, 8, 1, m5), createKeyValue(MUTATION, 20, 1, m6) };
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    logs.put("entries2", entries2);
    logs.put("entries3", entries3);
    // Recover
    List<Mutation> mutations = recover(logs, extent);
    // Verify recovered data
    Assert.assertEquals(6, 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));
    Assert.assertEquals(m5, mutations.get(4));
    Assert.assertEquals(m6, mutations.get(5));
}
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 5 with ServerMutation

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

the class SortedLogRecoveryTest method testDoubleFinish.

@Test
public void testDoubleFinish() 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, new Value("123".getBytes()));
    KeyValue[] entries = new KeyValue[] { createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(COMPACTION_FINISH, 2, 1, null), createKeyValue(COMPACTION_START, 4, 1, "/t1/f1"), createKeyValue(COMPACTION_FINISH, 6, 1, null), createKeyValue(MUTATION, 3, 1, ignored), createKeyValue(MUTATION, 5, 1, m), createKeyValue(MUTATION, 7, 1, m2) };
    Map<String, KeyValue[]> logs = new TreeMap<>();
    logs.put("entries", entries);
    // Recover
    List<Mutation> mutations = recover(logs, extent);
    // Verify recovered data
    Assert.assertEquals(2, mutations.size());
    Assert.assertEquals(m, mutations.get(0));
    Assert.assertEquals(m2, mutations.get(1));
}
Also used : LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) Value(org.apache.accumulo.core.data.Value) 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