Search in sources :

Example 1 with WriteRequest

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());
}
Also used : ILogData(org.corfudb.protocols.wireprotocol.ILogData) LogData(org.corfudb.protocols.wireprotocol.LogData) IMetadata(org.corfudb.protocols.wireprotocol.IMetadata) WriteRequest(org.corfudb.protocols.wireprotocol.WriteRequest) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) LogUnitServer(org.corfudb.infrastructure.LogUnitServer) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test) AbstractViewTest(org.corfudb.runtime.view.AbstractViewTest)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 LogUnitServer (org.corfudb.infrastructure.LogUnitServer)1 ILogData (org.corfudb.protocols.wireprotocol.ILogData)1 IMetadata (org.corfudb.protocols.wireprotocol.IMetadata)1 LogData (org.corfudb.protocols.wireprotocol.LogData)1 WriteRequest (org.corfudb.protocols.wireprotocol.WriteRequest)1 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)1 AbstractViewTest (org.corfudb.runtime.view.AbstractViewTest)1 Test (org.junit.Test)1