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