use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class AddressSpaceViewTest method ensureStripingReadAllWorks.
@Test
@SuppressWarnings("unchecked")
public void ensureStripingReadAllWorks() throws Exception {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
bootstrapAllServers(new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_1).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build());
//configure the layout accordingly
CorfuRuntime r = getRuntime().connect();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
final long ADDRESS_0 = 0;
final long ADDRESS_1 = 1;
final long ADDRESS_2 = 3;
Token token = new Token(ADDRESS_0, r.getLayoutView().getLayout().getEpoch());
r.getAddressSpaceView().write(token, testPayload);
assertThat(r.getAddressSpaceView().read(ADDRESS_0).getPayload(getRuntime())).isEqualTo("hello world".getBytes());
r.getAddressSpaceView().write(new Token(ADDRESS_1, r.getLayoutView().getLayout().getEpoch()), "1".getBytes());
r.getAddressSpaceView().write(new Token(ADDRESS_2, r.getLayoutView().getLayout().getEpoch()), "3".getBytes());
List<Long> rs = new ArrayList<>();
rs.add(ADDRESS_0);
rs.add(ADDRESS_1);
rs.add(ADDRESS_2);
Map<Long, ILogData> m = r.getAddressSpaceView().read(rs);
assertThat(m.get(ADDRESS_0).getPayload(getRuntime())).isEqualTo("hello world".getBytes());
assertThat(m.get(ADDRESS_1).getPayload(getRuntime())).isEqualTo("1".getBytes());
assertThat(m.get(ADDRESS_2).getPayload(getRuntime())).isEqualTo("3".getBytes());
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class AddressSpaceViewTest method ensureStripingWorks.
@Test
@SuppressWarnings("unchecked")
public void ensureStripingWorks() throws Exception {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
//configure the layout accordingly
bootstrapAllServers(new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_1).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build());
CorfuRuntime r = getRuntime().connect();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
final long epoch = r.getLayoutView().getLayout().getEpoch();
r.getAddressSpaceView().write(new TokenResponse(0, epoch, Collections.singletonMap(streamA, Address.NO_BACKPOINTER)), "hello world".getBytes());
assertThat(r.getAddressSpaceView().read(0L).getPayload(getRuntime())).isEqualTo("hello world".getBytes());
assertThat(r.getAddressSpaceView().read(0L).containsStream(streamA)).isTrue();
// Ensure that the data was written to each logunit.
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_0)).matchesDataAtAddress(0, testPayload);
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_1)).isEmptyAtAddress(0);
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_2)).isEmptyAtAddress(0);
r.getAddressSpaceView().write(new TokenResponse(1, epoch, Collections.singletonMap(streamA, Address.NO_BACKPOINTER)), "1".getBytes());
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_0)).matchesDataAtAddress(0, testPayload);
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_1)).matchesDataAtAddress(1, "1".getBytes());
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_2)).isEmptyAtAddress(0);
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class ChainReplicationViewTest method ensureAllUnitsContainData.
@Test
@SuppressWarnings("unchecked")
public void ensureAllUnitsContainData() throws Exception {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
bootstrapAllServers(new TestLayoutBuilder().addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().setReplicationMode(Layout.ReplicationMode.CHAIN_REPLICATION).buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build());
//configure the layout accordingly
CorfuRuntime r = getRuntime().connect();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
r.getAddressSpaceView().write(new TokenResponse(0, 0, Collections.singletonMap(streamA, Address.NO_BACKPOINTER)), testPayload);
assertThat(r.getAddressSpaceView().read(0L).getPayload(getRuntime())).isEqualTo("hello world".getBytes());
assertThat(r.getAddressSpaceView().read(0L).containsStream(streamA));
// Ensure that the data was written to each logunit.
assertThat(getLogUnit(SERVERS.PORT_0)).matchesDataAtAddress(0, testPayload);
assertThat(getLogUnit(SERVERS.PORT_1)).matchesDataAtAddress(0, testPayload);
assertThat(getLogUnit(SERVERS.PORT_2)).matchesDataAtAddress(0, testPayload);
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class ChainReplicationViewTest method canReadWriteToMultiple.
@Test
@SuppressWarnings("unchecked")
public void canReadWriteToMultiple() throws Exception {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
bootstrapAllServers(new TestLayoutBuilder().addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().setReplicationMode(Layout.ReplicationMode.CHAIN_REPLICATION).buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build());
//configure the layout accordingly
CorfuRuntime r = getRuntime().connect();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
r.getAddressSpaceView().write(new TokenResponse(0, runtime.getLayoutView().getLayout().getEpoch(), Collections.singletonMap(streamA, Address.NO_BACKPOINTER)), testPayload);
assertThat(r.getAddressSpaceView().read(0L).getPayload(getRuntime())).isEqualTo("hello world".getBytes());
assertThat(r.getAddressSpaceView().read(0L).containsStream(streamA)).isTrue();
}
use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.
the class LayoutSealTest method getLayout.
/**
* Gets a layout with 5 Servers:
* PORT_0, PORT_1, PORT_2, PORT_3, PORT_4
* Sets the replication view as specified.
*
* @param replicationMode Replication view to set all segments in the layout with.
* @return Built layout with a connected runtime.
*/
public Layout getLayout(Layout.ReplicationMode replicationMode) {
addServer(SERVERS.PORT_0);
addServer(SERVERS.PORT_1);
addServer(SERVERS.PORT_2);
addServer(SERVERS.PORT_3);
addServer(SERVERS.PORT_4);
Layout l = new TestLayoutBuilder().setEpoch(1).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).buildSegment().setReplicationMode(replicationMode).buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().buildStripe().addLogUnit(SERVERS.PORT_3).addLogUnit(SERVERS.PORT_4).addToSegment().addToLayout().build();
bootstrapAllServers(l);
CorfuRuntime corfuRuntime = getRuntime(l).connect();
l.setRuntime(corfuRuntime);
setAggressiveTimeouts(l);
return l;
}
Aggregations