use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method backpointersCanBeWrittenAndRead.
@Test
public void backpointersCanBeWrittenAndRead() throws Exception {
final long ADDRESS_0 = 1337L;
final long ADDRESS_1 = 1338L;
byte[] testString = "hello world".getBytes();
client.write(0, Collections.<UUID>emptySet(), null, testString, ImmutableMap.<UUID, Long>builder().put(CorfuRuntime.getStreamID("hello"), ADDRESS_0).put(CorfuRuntime.getStreamID("hello2"), ADDRESS_1).build()).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getBackpointerMap()).containsEntry(CorfuRuntime.getStreamID("hello"), ADDRESS_0);
assertThat(r.getBackpointerMap()).containsEntry(CorfuRuntime.getStreamID("hello2"), ADDRESS_1);
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method holeFillCannotBeOverwritten.
@Test
public void holeFillCannotBeOverwritten() throws Exception {
byte[] testString = "hello world".getBytes();
client.fillHole(0).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.HOLE);
assertThatThrownBy(() -> client.write(0, Collections.<UUID>emptySet(), null, testString, Collections.emptyMap()).get()).isInstanceOf(ExecutionException.class).hasCauseInstanceOf(OverwriteException.class);
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method canReadWrite.
@Test
public void canReadWrite() throws Exception {
byte[] testString = "hello world".getBytes();
client.write(0, Collections.<UUID>emptySet(), null, testString, Collections.emptyMap()).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
assertThat(r.getPayload(new CorfuRuntime())).isEqualTo(testString);
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method cannotOutrank.
@Test
public void cannotOutrank() throws ExecutionException, InterruptedException {
byte[] testString = "hello world".getBytes();
client.write(0, Collections.<UUID>emptySet(), new IMetadata.DataRank(2), testString, Collections.emptyMap()).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
assertThat(r.getPayload(new CorfuRuntime())).isEqualTo(testString);
byte[] testString2 = "hello world 2".getBytes();
try {
client.write(0, Collections.<UUID>emptySet(), new IMetadata.DataRank(1), testString2, Collections.emptyMap()).get();
fail();
} catch (ExecutionException e) {
// expected
assertEquals(DataOutrankedException.class, e.getCause().getClass());
}
r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
assertThat(r.getPayload(new CorfuRuntime())).isEqualTo(testString);
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method holeFillCannotOverwrite.
@Test
public void holeFillCannotOverwrite() throws Exception {
byte[] testString = "hello world".getBytes();
client.write(0, Collections.<UUID>emptySet(), null, testString, Collections.emptyMap()).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
assertThatThrownBy(() -> client.fillHole(0).get()).isInstanceOf(ExecutionException.class).hasCauseInstanceOf(OverwriteException.class);
}
Aggregations