Search in sources :

Example 26 with Layout

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

the class LayoutServerTest method commitReturnsAck.

private void commitReturnsAck(LayoutServer s1, Integer reboot, long baseEpoch) {
    long newEpoch = baseEpoch + reboot;
    sendMessage(new CorfuPayloadMsg<>(CorfuMsgType.SET_EPOCH, newEpoch));
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    layout.setEpoch(newEpoch);
    sendPrepare(newEpoch, HIGH_RANK);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
    sendPropose(newEpoch, HIGH_RANK, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    sendCommitted(newEpoch, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    sendCommitted(newEpoch, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    requestLayout(newEpoch);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_RESPONSE);
    Assertions.assertThat(((LayoutMsg) getLastMessage()).getLayout()).isEqualTo(layout);
}
Also used : LayoutMsg(org.corfudb.protocols.wireprotocol.LayoutMsg) Layout(org.corfudb.runtime.view.Layout)

Example 27 with Layout

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

the class LayoutServerTest method checkPaxosPhasesPersisted.

/**
     * The test verifies that the data in accepted phase1 and phase2 messages
     * is persisted to disk and survives layout server restarts.
     *
     * @throws Exception
     */
@Test
public void checkPaxosPhasesPersisted() throws Exception {
    String serviceDir = PARAMETERS.TEST_TEMP_DIR;
    LayoutServer s1 = getDefaultServer(serviceDir);
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    bootstrapServer(layout);
    long newEpoch = layout.getEpoch() + 1;
    Layout newLayout = TestLayoutBuilder.single(SERVERS.PORT_0);
    newLayout.setEpoch(newEpoch);
    setEpoch(newEpoch);
    // validate phase 1
    sendPrepare(newEpoch, 1);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
    assertThat(s1).isPhase1Rank(new Rank(1L, AbstractServerTest.testClientId));
    //shutdown this instance of server
    s1.shutdown();
    //bring up a new instance of server with the previously persisted data
    LayoutServer s2 = getDefaultServer(serviceDir);
    assertThat(s2).isInEpoch(newEpoch);
    assertThat(s2).isPhase1Rank(new Rank(1L, AbstractServerTest.testClientId));
    // validate phase2 data persistence
    sendPropose(newEpoch, 1, newLayout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    //shutdown this instance of server
    s2.shutdown();
    //bring up a new instance of server with the previously persisted data
    LayoutServer s3 = getDefaultServer(serviceDir);
    assertThat(s3).isInEpoch(newEpoch);
    assertThat(s3).isPhase1Rank(new Rank(1L, AbstractServerTest.testClientId));
    assertThat(s3).isPhase2Rank(new Rank(1L, AbstractServerTest.testClientId));
    assertThat(s3).isProposedLayout(newLayout);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 28 with Layout

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

the class LayoutServerTest method checkMessagesValidatedAgainstPhase1PersistedData.

/**
     * Validates that the layout server accept or rejects incoming phase1 messages based on
     * the last persisted phase1 rank.
     *
     * @throws Exception
     */
@Test
public void checkMessagesValidatedAgainstPhase1PersistedData() throws Exception {
    String serviceDir = PARAMETERS.TEST_TEMP_DIR;
    LayoutServer s1 = getDefaultServer(serviceDir);
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    bootstrapServer(layout);
    long newEpoch = layout.getEpoch() + 1;
    Layout newLayout = TestLayoutBuilder.single(SERVERS.PORT_0);
    newLayout.setEpoch(newEpoch);
    setEpoch(newEpoch);
    // validate phase 1
    sendPrepare(newEpoch, HIGH_RANK);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
    assertThat(s1).isInEpoch(newEpoch);
    assertThat(s1).isPhase1Rank(new Rank(HIGH_RANK, AbstractServerTest.testClientId));
    s1.shutdown();
    // reboot
    LayoutServer s2 = getDefaultServer(serviceDir);
    assertThat(s2).isInEpoch(newEpoch);
    assertThat(s2).isPhase1Rank(new Rank(HIGH_RANK, AbstractServerTest.testClientId));
    //new LAYOUT_PREPARE message with a lower phase1 rank should be rejected
    sendPrepare(newEpoch, HIGH_RANK - 1);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_REJECT);
    //new LAYOUT_PREPARE message with a higher phase1 rank should be accepted
    sendPrepare(newEpoch, HIGH_RANK + 1);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 29 with Layout

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

the class ManagementServerTest method bootstrapManagementServer.

/**
     * Bootstrapping the management server multiple times.
     */
@Test
public void bootstrapManagementServer() {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    sendMessage(CorfuMsgType.MANAGEMENT_BOOTSTRAP_REQUEST.payloadMsg(layout));
    assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    sendMessage(CorfuMsgType.MANAGEMENT_BOOTSTRAP_REQUEST.payloadMsg(layout));
    assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.MANAGEMENT_ALREADY_BOOTSTRAP_ERROR);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 30 with Layout

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

the class FailureHandlerDispatcherTest method updateLayoutOnFailure.

/**
     * triggers the handler with failure and checks for update in layout.
     */
@Test
public void updateLayoutOnFailure() {
    addServer(SERVERS.PORT_0);
    addServer(SERVERS.PORT_1);
    addServer(SERVERS.PORT_2);
    Layout originalLayout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_1).addSequencer(SERVERS.PORT_2).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build();
    bootstrapAllServers(originalLayout);
    CorfuRuntime corfuRuntime = new CorfuRuntime();
    corfuRuntime.addLayoutServer(getEndpoint(SERVERS.PORT_0));
    corfuRuntime.addLayoutServer(getEndpoint(SERVERS.PORT_1));
    corfuRuntime.addLayoutServer(getEndpoint(SERVERS.PORT_2));
    corfuRuntime.connect();
    Set<String> failedServers = new HashSet<>();
    failedServers.add(getEndpoint(SERVERS.PORT_2));
    FailureHandlerDispatcher failureHandlerDispatcher = new FailureHandlerDispatcher();
    IFailureHandlerPolicy failureHandlerPolicy = new PurgeFailurePolicy();
    failureHandlerDispatcher.dispatchHandler(failureHandlerPolicy, originalLayout, corfuRuntime, failedServers);
    Layout expectedLayout = new TestLayoutBuilder().setEpoch(2L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addSequencer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_1).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addToSegment().addToLayout().build();
    assertThat(getLayoutServer(SERVERS.PORT_0).getCurrentLayout()).isEqualTo(getLayoutServer(SERVERS.PORT_1).getCurrentLayout()).isEqualTo(expectedLayout);
}
Also used : Layout(org.corfudb.runtime.view.Layout) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) HashSet(java.util.HashSet) 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