Search in sources :

Example 11 with TokenResponse

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();
}
Also used : TokenResponse(org.corfudb.protocols.wireprotocol.TokenResponse) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) UUID(java.util.UUID) Test(org.junit.Test)

Example 12 with TokenResponse

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();
}
Also used : TokenResponse(org.corfudb.protocols.wireprotocol.TokenResponse) AbstractTransactionalContext(org.corfudb.runtime.object.transactions.AbstractTransactionalContext)

Example 13 with TokenResponse

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);
}
Also used : TokenResponse(org.corfudb.protocols.wireprotocol.TokenResponse) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) UUID(java.util.UUID) Test(org.junit.Test) AbstractViewTest(org.corfudb.runtime.view.AbstractViewTest)

Aggregations

TokenResponse (org.corfudb.protocols.wireprotocol.TokenResponse)13 Test (org.junit.Test)10 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)9 UUID (java.util.UUID)8 AbstractViewTest (org.corfudb.runtime.view.AbstractViewTest)5 TestLayoutBuilder (org.corfudb.infrastructure.TestLayoutBuilder)2 IStreamView (org.corfudb.runtime.view.stream.IStreamView)2 LogUnitServer (org.corfudb.infrastructure.LogUnitServer)1 CheckpointEntry (org.corfudb.protocols.logprotocol.CheckpointEntry)1 MultiSMREntry (org.corfudb.protocols.logprotocol.MultiSMREntry)1 SMREntry (org.corfudb.protocols.logprotocol.SMREntry)1 ILogData (org.corfudb.protocols.wireprotocol.ILogData)1 AbstractTransactionalContext (org.corfudb.runtime.object.transactions.AbstractTransactionalContext)1 BackpointerStreamView (org.corfudb.runtime.view.stream.BackpointerStreamView)1