use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class SMRMultiLogunitTest method setRuntime.
@Before
public void setRuntime() {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
Layout layout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build();
bootstrapAllServers(layout);
runtime = getRuntime().connect();
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class LayoutViewTest method canSetLayout.
@Test
public void canSetLayout() throws Exception {
CorfuRuntime r = getDefaultRuntime().connect();
Layout l = new TestLayoutBuilder().setEpoch(1).addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addToSegment().addToLayout().build();
l.setRuntime(r);
l.moveServersToEpoch();
r.getLayoutView().updateLayout(l, 1L);
r.invalidateLayout();
assertThat(r.getLayoutView().getLayout().epoch).isEqualTo(1L);
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class ManagementViewTest method testSequencerFailover.
/**
* Scenario with 3 nodes: SERVERS.PORT_0, SERVERS.PORT_1 and SERVERS.PORT_2.
* We fail SERVERS.PORT_1 and then wait for one of the other two servers to
* handle this failure, propose a new layout and we assert on the epoch change.
* The failure is handled by ConserveFailureHandlerPolicy.
* No nodes are removed from the layout, but are marked unresponsive.
* A sequencer failover takes place where the next working sequencer is reset
* and made the primary.
*
* @throws Exception
*/
@Test
public void testSequencerFailover() throws Exception {
getManagementTestLayout();
final long beforeFailure = 5L;
final long afterFailure = 10L;
IStreamView sv = getCorfuRuntime().getStreamsView().get(CorfuRuntime.getStreamID("streamA"));
byte[] testPayload = "hello world".getBytes();
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
assertThat(getSequencer(SERVERS.PORT_1).getGlobalLogTail().get()).isEqualTo(beforeFailure);
assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(0L);
induceSequencerFailureAndWait();
// verify that a failover sequencer was started with the correct starting-tail
//
assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(beforeFailure);
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
sv.append(testPayload);
// verify the failover layout
//
Layout expectedLayout = new TestLayoutBuilder().setEpoch(2L).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_2).addToSegment().addToLayout().addUnresponsiveServer(SERVERS.PORT_1).build();
assertThat(getCorfuRuntime().getLayoutView().getLayout()).isEqualTo(expectedLayout);
// verify that the new sequencer is advancing the tail properly
assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(afterFailure);
// sanity check that no other sequencer is active
assertThat(getSequencer(SERVERS.PORT_2).getGlobalLogTail().get()).isEqualTo(0L);
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class QuorumReplicationProtocolAdditionalTests method before.
@Before
public void before() {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
layout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).buildSegment().setReplicationMode(Layout.ReplicationMode.QUORUM_REPLICATION).buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build();
bootstrapAllServers(layout);
getManagementServer(SERVERS.PORT_0).shutdown();
getManagementServer(SERVERS.PORT_1).shutdown();
getManagementServer(SERVERS.PORT_2).shutdown();
layout.getSegment(0L).setReplicationMode(Layout.ReplicationMode.QUORUM_REPLICATION);
corfuRuntime = new CorfuRuntime();
corfuRuntime.setCacheDisabled(true);
layout.getLayoutServers().forEach(corfuRuntime::addLayoutServer);
layout.getAllServers().forEach(serverEndpoint -> {
corfuRuntime.getRouter(serverEndpoint).setTimeoutConnect(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
corfuRuntime.getRouter(serverEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
corfuRuntime.getRouter(serverEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
});
corfuRuntime.connect();
}
Aggregations