use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class logReaderTest method setUp.
@Before
public void setUp() {
File fDir = new File(LOG_PATH);
fDir.mkdirs();
StreamLogFiles logfile = new StreamLogFiles(getContext(), false);
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
Serializers.CORFU.serialize("Hello World".getBytes(), buf);
LogData data = new LogData(DataType.DATA, buf);
logfile.append(0, data);
buf.clear();
Serializers.CORFU.serialize("Happy Days".getBytes(), buf);
data = new LogData(DataType.DATA, buf);
logfile.append(1, data);
buf.clear();
Serializers.CORFU.serialize("Corfu test".getBytes(), buf);
data = new LogData(DataType.DATA, buf);
logfile.append(2, data);
logfile.close();
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method checkProposalIsIdempotent.
@Test
public void checkProposalIsIdempotent() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
IMetadata.DataRank sameRank = new IMetadata.DataRank(1);
writeToLog(log, address, DataType.DATA, "v-1", sameRank);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
writeToLog(log, address, DataType.DATA, "v-1", sameRank);
LogData value2 = log.read(address);
assertTrue(new String(value2.getData()).contains("v-1"));
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method testProposalsHigherRank.
@Test
public void testProposalsHigherRank() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
writeToLog(log, address, DataType.RANK_ONLY, "v-1", 1);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
writeToLog(log, address, DataType.RANK_ONLY, "v-2", 2);
LogData value2 = log.read(address);
assertTrue(new String(value2.getData()).contains("v-2"));
log.close();
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method createEmptyData.
private ILogData.SerializationHandle createEmptyData(long position, DataType type, IMetadata.DataRank rank) {
ILogData data = new LogData(type);
data.setRank(rank);
data.setGlobalAddress(position);
return data.getSerializedForm();
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class LogUnitClientTest method readingTrimmedAddress.
@Test
public void readingTrimmedAddress() throws Exception {
byte[] testString = "hello world".getBytes();
client.write(0, Collections.<UUID>emptySet(), null, testString, Collections.emptyMap()).get();
client.write(1, Collections.<UUID>emptySet(), null, testString, Collections.emptyMap()).get();
LogData r = client.read(0).get().getReadSet().get(0L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
r = client.read(1).get().getReadSet().get(1L);
assertThat(r.getType()).isEqualTo(DataType.DATA);
client.prefixTrim(0);
client.compact();
// For logunit cach flush
LogUnitServer server2 = new LogUnitServer(serverContext);
serverRouter.reset();
serverRouter.addServer(server2);
assertThatThrownBy(() -> client.read(0).get().getReadSet().get(0L)).isInstanceOf(ExecutionException.class).hasCauseInstanceOf(TrimmedException.class);
assertThat(r.getType()).isEqualTo(DataType.DATA);
}
Aggregations