Search in sources :

Example 1 with Layout

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

the class ManagementServerTest method triggerFailureHandler.

/**
     * Triggering the failure handler with and without bootstrapping the server.
     */
@Test
public void triggerFailureHandler() {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    Set<String> set = new HashSet<>();
    set.add("key");
    sendMessage(CorfuMsgType.MANAGEMENT_FAILURE_DETECTED.payloadMsg(new FailureDetectorMsg(set)));
    assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.MANAGEMENT_NOBOOTSTRAP_ERROR);
    sendMessage(CorfuMsgType.MANAGEMENT_BOOTSTRAP_REQUEST.payloadMsg(layout));
    assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    sendMessage(CorfuMsgType.MANAGEMENT_FAILURE_DETECTED.payloadMsg(new FailureDetectorMsg(set)));
    assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
}
Also used : FailureDetectorMsg(org.corfudb.protocols.wireprotocol.FailureDetectorMsg) Layout(org.corfudb.runtime.view.Layout) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Layout

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

the class LayoutServerTest method proposeRejectsAlreadyProposed.

/**
     * Verifies that once a proposal has been accepted, the same proposal is not accepted again.
     * Note: This is in the scope of same epoch.
     */
@Test
public void proposeRejectsAlreadyProposed() {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    long epoch = layout.getEpoch();
    bootstrapServer(layout);
    sendPrepare(epoch, LOW_RANK);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
    sendPropose(epoch, LOW_RANK, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.ACK);
    sendPropose(epoch, LOW_RANK, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PROPOSE_REJECT);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 3 with Layout

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

the class LayoutWorkflowManagerTest method checkRemovalOfNodes.

/**
     * Tests the Layout Workflow manager by removing nodes.
     *
     * @throws LayoutModificationException Throws error if all layout, sequencer or
     *                                     logunit nodes removed. Invalid removal.
     */
@Test
public void checkRemovalOfNodes() throws LayoutModificationException, CloneNotSupportedException {
    Layout originalLayout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addLayoutServer(SERVERS.PORT_3).addLayoutServer(SERVERS.PORT_4).addSequencer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_1).addSequencer(SERVERS.PORT_2).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_2).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_3).addLogUnit(SERVERS.PORT_4).addToSegment().addToLayout().build();
    List<String> allNodes = new ArrayList<>();
    allNodes.add(TestLayoutBuilder.getEndpoint(SERVERS.PORT_0));
    allNodes.add(TestLayoutBuilder.getEndpoint(SERVERS.PORT_1));
    allNodes.add(TestLayoutBuilder.getEndpoint(SERVERS.PORT_2));
    allNodes.add(TestLayoutBuilder.getEndpoint(SERVERS.PORT_3));
    allNodes.add(TestLayoutBuilder.getEndpoint(SERVERS.PORT_4));
    Set<String> failedNodes = new HashSet<String>();
    LayoutWorkflowManager layoutWorkflowManager = new LayoutWorkflowManager(originalLayout);
    //Preparing failed nodes set.
    failedNodes.addAll(allNodes);
    /*
         * Invalid Removals
         */
    // Deleting all Layout Servers
    assertThatThrownBy(() -> layoutWorkflowManager.removeLayoutServers(failedNodes).build()).isInstanceOf(LayoutModificationException.class);
    //Deleting all Sequencer Servers
    assertThatThrownBy(() -> layoutWorkflowManager.removeSequencerServers(failedNodes).build()).isInstanceOf(LayoutModificationException.class);
    //Deleting all Log unit Servers
    assertThatThrownBy(() -> layoutWorkflowManager.removeLogunitServers(failedNodes).build()).isInstanceOf(LayoutModificationException.class);
    // Deleting all nodes in one stripe
    failedNodes.clear();
    failedNodes.add(allNodes.get(0));
    failedNodes.add(allNodes.get(2));
    assertThatThrownBy(() -> layoutWorkflowManager.removeLogunitServers(failedNodes).build()).isInstanceOf(LayoutModificationException.class);
    /*
         *  Valid Removal
         */
    // Deleting SERVERS.PORT_0 and SERVERS.PORT_4
    // Preparing new layout
    Layout expectedLayout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addLayoutServer(SERVERS.PORT_3).addSequencer(SERVERS.PORT_1).addSequencer(SERVERS.PORT_2).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_2).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_3).addToSegment().addToLayout().build();
    failedNodes.clear();
    failedNodes.add(allNodes.get(0));
    failedNodes.add(allNodes.get(SERVER_ENTRY_4));
    Layout actualLayout = layoutWorkflowManager.removeLayoutServers(failedNodes).removeLogunitServers(failedNodes).removeSequencerServers(failedNodes).build();
    Assertions.assertThat(actualLayout).isEqualTo(expectedLayout);
    /*
         * Deleting individual nodes
         */
    expectedLayout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_3).addSequencer(SERVERS.PORT_2).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_2).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_3).addToSegment().addToLayout().build();
    // Remove SERVERS.PORT_1 & SERVERS.PORT_2 from layout server
    layoutWorkflowManager.removeLayoutServer(allNodes.get(1));
    layoutWorkflowManager.removeLayoutServer(allNodes.get(2));
    // No effect on removing removed node
    layoutWorkflowManager.removeLayoutServer(allNodes.get(2));
    // Remove SERVERS.PORT_3 from layout server should throw error.
    assertThatThrownBy(() -> layoutWorkflowManager.removeLayoutServer(allNodes.get(SERVER_ENTRY_3))).isInstanceOf(LayoutModificationException.class);
    // Remove SERVERS.PORT_1 from sequencers
    layoutWorkflowManager.removeSequencerServer(allNodes.get(1));
    // No effect on removing removed node
    layoutWorkflowManager.removeSequencerServer(allNodes.get(1));
    // Remove SERVERS.PORT_2 from sequencer server should throw error.
    assertThatThrownBy(() -> layoutWorkflowManager.removeSequencerServer(allNodes.get(2))).isInstanceOf(LayoutModificationException.class);
    // Remove SERVERS.PORT_1 from logunits
    layoutWorkflowManager.removeLogunitServer(allNodes.get(1));
    // No effect on removing removed node
    layoutWorkflowManager.removeLogunitServer(allNodes.get(1));
    // Remove SERVERS.PORT_2 from logunit server should throw error.
    assertThatThrownBy(() -> layoutWorkflowManager.removeLogunitServer(allNodes.get(2))).isInstanceOf(LayoutModificationException.class);
    assertThat(layoutWorkflowManager.build()).isEqualTo(expectedLayout);
}
Also used : Layout(org.corfudb.runtime.view.Layout) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractCorfuTest(org.corfudb.AbstractCorfuTest)

Example 4 with Layout

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

the class LayoutServerTest method cannotBootstrapServerTwice.

/**
     * Verifies that a server cannot be bootstrapped multiple times.
     */
@Test
public void cannotBootstrapServerTwice() {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    bootstrapServer(layout);
    bootstrapServer(layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_ALREADY_BOOTSTRAP);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

Example 5 with Layout

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

the class LayoutServerTest method proposeRejectsLowerRanks.

/**
     * Verifies that once a prepare with a rank has been accepted,
     * any propose with a lower rank is rejected.
     * Note: This is in the scope of same epoch.
     */
@Test
public void proposeRejectsLowerRanks() {
    Layout layout = TestLayoutBuilder.single(SERVERS.PORT_0);
    long epoch = layout.getEpoch();
    bootstrapServer(layout);
    sendPrepare(epoch, HIGH_RANK);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PREPARE_ACK);
    sendPropose(epoch, LOW_RANK, layout);
    Assertions.assertThat(getLastMessage().getMsgType()).isEqualTo(CorfuMsgType.LAYOUT_PROPOSE_REJECT);
}
Also used : Layout(org.corfudb.runtime.view.Layout) Test(org.junit.Test)

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