use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method testProposalWithLowerRankAgainstData.
@Test
public void testProposalWithLowerRankAgainstData() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
writeToLog(log, address, DataType.DATA, "v-1", 2);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
try {
writeToLog(log, address, DataType.RANK_ONLY, "v-2", 1);
fail();
} catch (DataOutrankedException e) {
// expected
}
LogData value2 = log.read(address);
assertTrue(new String(value2.getData()).contains("v-1"));
log.close();
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method testLowerRank.
@Test
public void testLowerRank() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
writeToLog(log, address, DataType.DATA, "v-1", 2);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
try {
writeToLog(log, address, DataType.DATA, "v-2", 1);
fail();
} catch (DataOutrankedException e) {
// expected
}
LogData value2 = log.read(address);
assertTrue(new String(value2.getData()).contains("v-1"));
log.close();
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method writeToLog.
private void writeToLog(StreamLog log, long address, DataType dataType, String payload, IMetadata.DataRank rank) {
ByteBuf b = Unpooled.buffer();
byte[] streamEntry = payload.getBytes();
Serializers.CORFU.serialize(streamEntry, b);
LogData data = new LogData(dataType, b);
data.setRank(rank);
log.append(address, data);
}
use of org.corfudb.protocols.wireprotocol.LogData in project CorfuDB by CorfuDB.
the class StreamLogWithRankedAddressSpaceTest method testHigherRank.
@Test
public void testHigherRank() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
writeToLog(log, address, DataType.DATA, "v-1", 1);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
writeToLog(log, address, DataType.DATA, "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 StreamLogWithRankedAddressSpaceTest method testProposalWithHigherRankAgainstData.
@Test
public void testProposalWithHigherRankAgainstData() {
StreamLogFiles log = new StreamLogFiles(getContext(), false);
long address = 0;
writeToLog(log, address, DataType.DATA, "v-1", 1);
LogData value1 = log.read(address);
assertTrue(new String(value1.getData()).contains("v-1"));
try {
writeToLog(log, address, DataType.RANK_ONLY, "v-2", 2);
fail();
} catch (ValueAdoptedException e) {
LogData logData = e.getReadResponse().getReadSet().get(0l);
assertTrue(new String(logData.getData()).contains("v-1"));
}
LogData value2 = log.read(address);
assertTrue(new String(value2.getData()).contains("v-1"));
log.close();
}
Aggregations