boolean isReady() { return server.getState().getLastAppliedIndex() >= placeHolderIndex; }
boolean isReady() { return server.getState().getLastAppliedIndex() >= placeHolderIndex; }
@Override public void close() throws IOException { stateMachineUpdater.stop(); LOG.info("{} closes. The last applied log index is {}", getSelfId(), getLastAppliedIndex()); log.close(); storage.close(); }
private void checkAndEvictCache() { if (server.isPresent() && cache.shouldEvict()) { // TODO if the cache is hitting the maximum size and we cannot evict any // segment's cache, should block the new entry appending or new segment // allocation. final RaftServerImpl s = server.get(); cache.evictCache(s.getFollowerNextIndices(), fileLogWorker.getFlushedIndex(), s.getState().getLastAppliedIndex()); } }
@Override public void close() throws IOException { try { stateMachineUpdater.stopAndJoin(); } catch (InterruptedException e) { LOG.warn(getSelfId() + ": Interrupted when joining stateMachineUpdater", e); } LOG.info("{} closes. The last applied log index is {}", getSelfId(), getLastAppliedIndex()); log.close(); storage.close(); }
private void checkAndEvictCache() { if (server != null && cache.shouldEvict()) { // TODO if the cache is hitting the maximum size and we cannot evict any // segment's cache, should block the new entry appending or new segment // allocation. cache.evictCache(server.getFollowerNextIndices(), fileLogWorker.getFlushedIndex(), server.getState().getLastAppliedIndex()); } }
cluster.getLeader().getState().getLastAppliedIndex());
LOG.info("last = " + ServerProtoUtils.toLogEntryString(last)); Assert.assertNotNull(last); Assert.assertTrue(last.getIndex() <= leaderState.getLastAppliedIndex());
public void assertServer(MiniRaftCluster cluster, ClientId clientId, long callId, long oldLastApplied) throws Exception { long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex(); // make sure retry cache has the entry for (RaftServerImpl server : cluster.iterateServerImpls()) { LOG.info("check server " + server.getId()); if (server.getState().getLastAppliedIndex() < leaderApplied) { Thread.sleep(1000); } Assert.assertEquals(2, RaftServerTestUtil.getRetryCacheSize(server)); Assert.assertNotNull(RaftServerTestUtil.getRetryEntry(server, clientId, callId)); // make sure there is only one log entry committed Assert.assertEquals(1, count(server.getState().getLog(), oldLastApplied + 1)); } }
Mockito.when(server.getState()).thenReturn(state); Mockito.when(server.getFollowerNextIndices()).thenReturn(new long[]{}); Mockito.when(state.getLastAppliedIndex()).thenReturn(0L); Mockito.when(state.getLastAppliedIndex()).thenReturn(35L); slist = TestSegmentedRaftLog.prepareRanges(maxCachedNum, maxCachedNum + 2, 7, 7 * maxCachedNum); entries = generateEntries(slist);
Mockito.when(server.getState()).thenReturn(state); Mockito.when(server.getFollowerNextIndices()).thenReturn(new long[]{}); Mockito.when(state.getLastAppliedIndex()).thenReturn(0L); Mockito.when(state.getLastAppliedIndex()).thenReturn(35L); slist = TestSegmentedRaftLog.prepareRanges(2, 7, 7 * maxCachedNum); entries = generateEntries(slist);
leader.getState().getLastAppliedIndex());
leader.getState().getLastAppliedIndex());
long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex(); long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex(); if (server.getState().getLastAppliedIndex() < leaderApplied) { Thread.sleep(1000); RaftServerTestUtil.getRetryEntry(server, client.getId(), callId)); Assert.assertEquals(oldLastApplied + 1, server.getState().getLastAppliedIndex());
long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex(); long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex(); if (server.getState().getLastAppliedIndex() < leaderApplied) { Thread.sleep(1000); server.getState().getLastAppliedIndex());
for (int i = 0; i < 10 && !catchup; i++) { Thread.sleep(500); lastAppliedIndex = cluster.getServer(followerId).getImpl().getState().getLastAppliedIndex(); catchup = lastAppliedIndex >= 20;
Assert.assertEquals(callId, reply.getCallId()); Assert.assertTrue(reply.isSuccess()); long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex(); cluster.getLeader().getState().getLastAppliedIndex()); client.close();
callId, seqNum, new SimpleMessage("message")); assertReply(rpc.sendRequest(r), client, callId); long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex();
long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex(); long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex(); if (server.getState().getLastAppliedIndex() < leaderApplied) { Thread.sleep(1000);
void runTestBasicRetry(CLUSTER cluster) throws Exception { RaftTestUtil.waitForLeader(cluster); final RaftPeerId leaderId = cluster.getLeaderAndSendFirstMessage(false).getId(); long oldLastApplied = cluster.getLeader().getState().getLastAppliedIndex(); final RaftClient client = cluster.createClient(leaderId); final RaftClientRpc rpc = client.getClientRpc(); final long callId = 999; final long seqNum = 111; RaftClientRequest r = cluster.newRaftClientRequest(client.getId(), leaderId, callId, seqNum, new SimpleMessage("message")); assertReply(rpc.sendRequest(r), client, callId); // retry with the same callId for (int i = 0; i < 5; i++) { assertReply(rpc.sendRequest(r), client, callId); } assertServer(cluster, client.getId(), callId, oldLastApplied); client.close(); }