Search in sources :

Example 1 with Token

use of org.corfudb.protocols.wireprotocol.Token in project CorfuDB by CorfuDB.

the class SequencerViewTest method canAcquireFirstToken.

@Test
public void canAcquireFirstToken() {
    CorfuRuntime r = getDefaultRuntime();
    assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
}
Also used : CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Token(org.corfudb.protocols.wireprotocol.Token) Test(org.junit.Test)

Example 2 with Token

use of org.corfudb.protocols.wireprotocol.Token in project CorfuDB by CorfuDB.

the class SequencerViewTest method tokensAreIncrementing.

@Test
public void tokensAreIncrementing() {
    CorfuRuntime r = getDefaultRuntime();
    assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(1L, 0L));
}
Also used : CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Token(org.corfudb.protocols.wireprotocol.Token) Test(org.junit.Test)

Example 3 with Token

use of org.corfudb.protocols.wireprotocol.Token in project CorfuDB by CorfuDB.

the class SequencerViewTest method checkTokenWorks.

@Test
public void checkTokenWorks() {
    CorfuRuntime r = getDefaultRuntime();
    assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 0).getToken()).isEqualTo(new Token(0L, 0L));
}
Also used : CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Token(org.corfudb.protocols.wireprotocol.Token) Test(org.junit.Test)

Example 4 with Token

use of org.corfudb.protocols.wireprotocol.Token in project CorfuDB by CorfuDB.

the class CmdletIT method testCorfuSequencerCmdlet.

/**
     * Testing corfu_sequencer next-token and latest
     *
     * @throws Exception
     */
@Test
public void testCorfuSequencerCmdlet() throws Exception {
    corfuServerProcess = new CorfuServerRunner().setPort(PORT).runServer();
    final String streamA = "streamA";
    CorfuRuntime runtime = createRuntime(ENDPOINT);
    String commandNextToken = CORFU_PROJECT_DIR + "bin/corfu_sequencer -i " + streamA + " -c " + ENDPOINT + " next-token 3";
    runCmdletGetOutput(commandNextToken);
    Token token = runtime.getSequencerView().nextToken(Collections.singleton(CorfuRuntime.getStreamID(streamA)), 0).getToken();
    String commandLatest = CORFU_PROJECT_DIR + "bin/corfu_sequencer -i " + streamA + " -c " + ENDPOINT + " latest";
    String output = runCmdletGetOutput(commandLatest);
    assertThat(output.contains(token.toString())).isTrue();
    shutdownCorfuServer(corfuServerProcess);
}
Also used : CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Token(org.corfudb.protocols.wireprotocol.Token) Test(org.junit.Test)

Example 5 with Token

use of org.corfudb.protocols.wireprotocol.Token in project CorfuDB by CorfuDB.

the class SequencerClientTest method perStreamTokensWork.

@Test
public void perStreamTokensWork() throws Exception {
    UUID streamA = UUID.nameUUIDFromBytes("streamA".getBytes());
    UUID streamB = UUID.nameUUIDFromBytes("streamB".getBytes());
    client.nextToken(Collections.singleton(streamA), 1).get();
    Token tokenA = client.nextToken(Collections.singleton(streamA), 1).get().getToken();
    Token tokenA2 = client.nextToken(Collections.singleton(streamA), 0).get().getToken();
    assertThat(tokenA).isEqualTo(tokenA2);
    Token tokenB = client.nextToken(Collections.singleton(streamB), 0).get().getToken();
    assertThat(tokenB).isNotEqualTo(tokenA2);
    Token tokenB2 = client.nextToken(Collections.singleton(streamB), 1).get().getToken();
    Token tokenB3 = client.nextToken(Collections.singleton(streamB), 0).get().getToken();
    assertThat(tokenB2).isEqualTo(tokenB3);
    Token tokenA3 = client.nextToken(Collections.singleton(streamA), 0).get().getToken();
    assertThat(tokenA3).isEqualTo(tokenA2);
}
Also used : Token(org.corfudb.protocols.wireprotocol.Token) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

Token (org.corfudb.protocols.wireprotocol.Token)8 Test (org.junit.Test)8 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)5 UUID (java.util.UUID)2