Search in sources :

Example 6 with Token

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

the class SequencerClientTest method checkTokenPositionWorks.

@Test
public void checkTokenPositionWorks() throws Exception {
    Token token = client.nextToken(Collections.<UUID>emptySet(), 1).get().getToken();
    Token token2 = client.nextToken(Collections.<UUID>emptySet(), 0).get().getToken();
    assertThat(token).isEqualTo(token2);
}
Also used : Token(org.corfudb.protocols.wireprotocol.Token) Test(org.junit.Test)

Example 7 with Token

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

the class SequencerViewTest method checkStreamTokensWork.

@Test
public void checkStreamTokensWork() {
    CorfuRuntime r = getDefaultRuntime();
    UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
    UUID streamB = UUID.nameUUIDFromBytes("stream B".getBytes());
    assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 1).getToken()).isEqualTo(new Token(0L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 0).getToken()).isEqualTo(new Token(0L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 1).getToken()).isEqualTo(new Token(1L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 0).getToken()).isEqualTo(new Token(1L, 0L));
    assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 0).getToken()).isEqualTo(new Token(0L, 0L));
}
Also used : CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Token(org.corfudb.protocols.wireprotocol.Token) UUID(java.util.UUID) Test(org.junit.Test)

Example 8 with Token

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

the class SequencerClientTest method tokensAreIncrementing.

@Test
public void tokensAreIncrementing() throws Exception {
    Token token = client.nextToken(Collections.<UUID>emptySet(), 1).get().getToken();
    Token token2 = client.nextToken(Collections.<UUID>emptySet(), 1).get().getToken();
    assertThat(token2.getTokenValue()).isGreaterThan(token.getTokenValue());
}
Also used : Token(org.corfudb.protocols.wireprotocol.Token) 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