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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations