Search in sources :

Example 16 with Layout

use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.

the class LayoutClientTest method commitReturnsAck.

@Test
public void commitReturnsAck() throws Exception {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    long epoch = layout.getEpoch();
    assertThat(client.bootstrapLayout(layout).get()).isEqualTo(true);
    assertThat(client.prepare(epoch, RANK_HIGH).get() != null).isEqualTo(true);
    final long TEST_EPOCH = 777;
    layout.setEpoch(TEST_EPOCH);
    assertThat(client.committed(TEST_EPOCH, layout).get()).isEqualTo(true);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 17 with Layout

use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.

the class LayoutClientTest method proposeRejectsLowerRanks.

@Test
public void proposeRejectsLowerRanks() throws Exception {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    long epoch = layout.getEpoch();
    assertThat(client.bootstrapLayout(layout).get()).isEqualTo(true);
    assertThat(client.prepare(epoch, RANK_HIGH).get() != null).isEqualTo(true);
    assertThatThrownBy(() -> {
        client.propose(epoch, RANK_LOW, layout).get();
    }).hasCauseInstanceOf(OutrankedException.class);
    assertThat(client.propose(epoch, RANK_HIGH, TestLayoutBuilder.single(SERVERS.PORT_0)).get()).isEqualTo(true);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 18 with Layout

use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.

the class LayoutClientTest method proposeRejectsAlreadyProposed.

@Test
public void proposeRejectsAlreadyProposed() throws Exception {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    long epoch = layout.getEpoch();
    assertThat(client.bootstrapLayout(layout).get()).isEqualTo(true);
    assertThat(client.prepare(epoch, RANK_HIGH).get() != null).isEqualTo(true);
    client.propose(epoch, RANK_HIGH, layout).get();
    assertThatThrownBy(() -> {
        client.propose(epoch, RANK_LOW, layout).get();
    }).hasCauseInstanceOf(OutrankedException.class);
    assertThatThrownBy(() -> {
        client.propose(epoch, RANK_HIGH, layout).get();
    }).hasCauseInstanceOf(OutrankedException.class);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 19 with Layout

use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.

the class SealIT method RuntimeWithWrongEpochGetUpdated.

@Test
public void RuntimeWithWrongEpochGetUpdated() throws Exception {
    Process corfuProcess = new CorfuServerRunner().setHost(corfuSingleNodeHost).setPort(corfuSingleNodePort).runServer();
    CorfuRuntime cr1 = createDefaultRuntime();
    CorfuRuntime cr2 = createDefaultRuntime();
    Long beforeAddress = cr2.getSequencerView().nextToken(new HashSet<>(), 1).getToken().getTokenValue();
    /* We will trigger a Paxos round, this is what will happen:
         *   1. Set our layout (same than before) with a new Epoch
         *   2. Seal the server(s)
         *   3. Propose the new layout by driving paxos.
         */
    Layout currentLayout = cr1.getLayoutView().getCurrentLayout();
    /* 1 */
    currentLayout.setEpoch(currentLayout.getEpoch() + 1);
    /* 2 */
    currentLayout.moveServersToEpoch();
    /* 3 */
    cr1.getLayoutView().updateLayout(currentLayout, 0);
    /* Now cr2 is still stuck in the previous epoch. The next time it will ask for a token,
         * emit a read or a write (msgs type that validate the epoch on the server side) it should
         * receive a WrongEpochException. This exception is taken care of by the AbstractView class in
         * the layoutHelper function.
         *
         * Upon receiving a wrong epoch, the new epoch will be set internally, and it will invalidate
         * the layout.
         *
         * These steps get cr2 in the new epoch.
         */
    Long afterAddress = cr2.getSequencerView().nextToken(new HashSet<>(), 1).getToken().getTokenValue();
    assertThat(cr2.getLayoutView().getCurrentLayout().getEpoch()).isEqualTo(cr1.getLayoutView().getCurrentLayout().getEpoch());
    assertThat(afterAddress).isEqualTo(beforeAddress + 1);
    assertThat(shutdownCorfuServer(corfuProcess)).isTrue();
}
Also used : Layout(org.corfudb.runtime.view.Layout) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Test(org.junit.Test)

Example 20 with Layout

use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.

the class AbstractReplicationProtocolTest method readOnlyCommitted.

/** Check to make sure reads never return empty in
     * the case of an unwritten address.
     */
@Test
@SuppressWarnings("unchecked")
public void readOnlyCommitted() throws Exception {
    setupNodes();
    //begin tests
    final CorfuRuntime r = getDefaultRuntime();
    final IReplicationProtocol rp = getProtocol();
    final Layout layout = r.getLayoutView().getLayout();
    ILogData read = rp.read(layout, 0);
    assertThat(read.getType()).isNotEqualTo(DataType.EMPTY);
    read = rp.read(layout, 1);
    assertThat(read.getType()).isNotEqualTo(DataType.EMPTY);
}
Also used : ILogData(org.corfudb.protocols.wireprotocol.ILogData) Layout(org.corfudb.runtime.view.Layout) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Test(org.junit.Test) AbstractViewTest(org.corfudb.runtime.view.AbstractViewTest)

Aggregations

Layout (org.corfudb.runtime.view.Layout)44 Test (org.junit.Test)29 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)10 ILogData (org.corfudb.protocols.wireprotocol.ILogData)5 AbstractViewTest (org.corfudb.runtime.view.AbstractViewTest)5 LogData (org.corfudb.protocols.wireprotocol.LogData)4 HashSet (java.util.HashSet)3 ExecutionException (java.util.concurrent.ExecutionException)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 ArrayList (java.util.ArrayList)2 FailureDetectorMsg (org.corfudb.protocols.wireprotocol.FailureDetectorMsg)2 LayoutMsg (org.corfudb.protocols.wireprotocol.LayoutMsg)2 OutrankedException (org.corfudb.runtime.exceptions.OutrankedException)2 com.google.common.collect (com.google.common.collect)1 TypeToken (com.google.common.reflect.TypeToken)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ByteBuf (io.netty.buffer.ByteBuf)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 java.lang.invoke (java.lang.invoke)1