use of org.corfudb.protocols.wireprotocol.TokenResponse in project CorfuDB by CorfuDB.
the class ChainReplicationViewTest method canReadWriteToSingle.
@Test
@SuppressWarnings("unchecked")
public void canReadWriteToSingle() throws Exception {
CorfuRuntime r = getDefaultRuntime();
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.protocols.wireprotocol.TokenResponse in project CorfuDB by CorfuDB.
the class CheckpointWriter method startGlobalSnapshotTxn.
public static long startGlobalSnapshotTxn(CorfuRuntime rt) {
TokenResponse tokenResponse = rt.getSequencerView().nextToken(Collections.EMPTY_SET, 0);
long globalTail = tokenResponse.getToken().getTokenValue();
rt.getObjectsView().TXBuild().setType(TransactionType.SNAPSHOT).setSnapshot(globalTail).begin();
AbstractTransactionalContext context = TransactionalContext.getCurrentContext();
return context.getSnapshotTimestamp();
}
use of org.corfudb.protocols.wireprotocol.TokenResponse in project CorfuDB by CorfuDB.
the class QuorumReplicationProtocolAdditionalTests method ensureAllUnitsContainData.
@Test
@SuppressWarnings("unchecked")
public void ensureAllUnitsContainData() throws Exception {
//configure the layout accordingly
CorfuRuntime r = getDefaultRuntime();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
r.getAddressSpaceView().write(new TokenResponse(0, 1, 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.
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_0)).matchesDataAtAddress(0, testPayload);
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_1)).matchesDataAtAddress(0, testPayload);
LogUnitServerAssertions.assertThat(getLogUnit(SERVERS.PORT_2)).matchesDataAtAddress(0, testPayload);
}
Aggregations