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));
}
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));
}
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));
}
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);
}
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);
}
Aggregations