Search in sources :

Example 16 with LogData

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();
}
Also used : LogData(org.corfudb.protocols.wireprotocol.LogData) StreamLogFiles(org.corfudb.infrastructure.log.StreamLogFiles) ByteBuf(io.netty.buffer.ByteBuf) File(java.io.File) Before(org.junit.Before)

Example 17 with LogData

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"));
}
Also used : LogData(org.corfudb.protocols.wireprotocol.LogData) IMetadata(org.corfudb.protocols.wireprotocol.IMetadata) Test(org.junit.Test) AbstractCorfuTest(org.corfudb.AbstractCorfuTest)

Example 18 with LogData

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();
}
Also used : LogData(org.corfudb.protocols.wireprotocol.LogData) Test(org.junit.Test) AbstractCorfuTest(org.corfudb.AbstractCorfuTest)

Example 19 with LogData

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();
}
Also used : ILogData(org.corfudb.protocols.wireprotocol.ILogData) ILogData(org.corfudb.protocols.wireprotocol.ILogData) LogData(org.corfudb.protocols.wireprotocol.LogData)

Example 20 with LogData

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);
}
Also used : ILogData(org.corfudb.protocols.wireprotocol.ILogData) LogData(org.corfudb.protocols.wireprotocol.LogData) LogUnitServer(org.corfudb.infrastructure.LogUnitServer) UUID(java.util.UUID) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

LogData (org.corfudb.protocols.wireprotocol.LogData)45 Test (org.junit.Test)32 ILogData (org.corfudb.protocols.wireprotocol.ILogData)21 AbstractCorfuTest (org.corfudb.AbstractCorfuTest)18 ByteBuf (io.netty.buffer.ByteBuf)15 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)9 UUID (java.util.UUID)8 DataOutrankedException (org.corfudb.runtime.exceptions.DataOutrankedException)8 ExecutionException (java.util.concurrent.ExecutionException)5 ReadResponse (org.corfudb.protocols.wireprotocol.ReadResponse)5 IMetadata (org.corfudb.protocols.wireprotocol.IMetadata)4 ValueAdoptedException (org.corfudb.runtime.exceptions.ValueAdoptedException)4 Layout (org.corfudb.runtime.view.Layout)4 LogUnitServer (org.corfudb.infrastructure.LogUnitServer)3 AbstractViewTest (org.corfudb.runtime.view.AbstractViewTest)3 File (java.io.File)2 LogUnitClient (org.corfudb.runtime.clients.LogUnitClient)2 OverwriteException (org.corfudb.runtime.exceptions.OverwriteException)2 QuorumUnreachableException (org.corfudb.runtime.exceptions.QuorumUnreachableException)2 QuorumFuturesFactory (org.corfudb.runtime.view.QuorumFuturesFactory)2