use of org.corfudb.protocols.wireprotocol.WriteRequest in project CorfuDB by CorfuDB.
the class QuorumReplicationProtocolAdditionalTests method checkRecoveryWriteTriggeredFromReadRecoversDataWhenTheQuorumIsLost.
@Test
@SuppressWarnings("unchecked")
public void checkRecoveryWriteTriggeredFromReadRecoversDataWhenTheQuorumIsLost() throws Exception {
//configure the layout accordingly
CorfuRuntime r = getDefaultRuntime();
LogUnitServer u0 = getLogUnit(SERVERS.PORT_0);
LogUnitServer u1 = getLogUnit(SERVERS.PORT_1);
LogUnitServer u2 = getLogUnit(SERVERS.PORT_2);
final long ADDRESS_0 = 0L;
//write at 0
ByteBuf b = Unpooled.buffer();
Serializers.CORFU.serialize("0".getBytes(), b);
WriteRequest m = WriteRequest.builder().writeMode(WriteMode.NORMAL).data(new LogData(DataType.DATA, b)).build();
m.setGlobalAddress(ADDRESS_0);
m.setRank(new IMetadata.DataRank(0));
m.setBackpointerMap(Collections.emptyMap());
sendMessage(u1, CorfuMsgType.WRITE.payloadMsg(m));
sendMessage(u2, CorfuMsgType.WRITE.payloadMsg(m));
u2.setShutdown(true);
u2.shutdown();
LogUnitServerAssertions.assertThat(u0).isEmptyAtAddress(ADDRESS_0);
assertThat(r.getAddressSpaceView().read(0L).getPayload(getRuntime())).isEqualTo("0".getBytes());
LogUnitServerAssertions.assertThat(u1).matchesDataAtAddress(ADDRESS_0, "0".getBytes());
LogUnitServerAssertions.assertThat(u0).matchesDataAtAddress(ADDRESS_0, "0".getBytes());
}
Aggregations