@Override public String getGroupId() { return RaftServerImpl.this.getGroupId().toString(); }
@Override public String getGroupId() { return RaftServerImpl.this.getGroupId().toString(); }
AppendEntriesRequestProto newAppendEntriesRequestProto(RaftPeerId targetId, TermIndex previous, List<LogEntryProto> entries, boolean initializing, long callId) { return ServerProtoUtils.toAppendEntriesRequestProto(server.getId(), targetId, server.getGroupId(), currentTerm, entries, raftLog.getLastCommittedIndex(), initializing, previous, server.getCommitInfos(), callId); }
AppendEntriesRequestProto newAppendEntriesRequestProto(RaftPeerId targetId, TermIndex previous, List<LogEntryProto> entries, boolean initializing, long callId) { return ServerProtoUtils.toAppendEntriesRequestProto(server.getId(), targetId, server.getGroupId(), currentTerm, entries, raftLog.getLastCommittedIndex(), initializing, previous, server.getCommitInfos(), callId); }
public String printServers(RaftGroupId groupId) { final StringBuilder b = new StringBuilder("printing "); if (groupId != null) { b.append(groupId); } else { b.append("ALL groups"); } getServers().stream().filter( s -> { if (groupId == null) { return true; } try { return groupId.equals(s.getImpl().getGroupId()); } catch (IOException e) { return false; } }) .forEach(s -> b.append("\n ").append(s)); return b.toString(); }
public RaftServerImpl getLeader(RaftGroupId groupId) { Stream<RaftServerImpl> stream = getServerAliveStream(); if (groupId != null) { stream = stream.filter(s -> groupId.equals(s.getGroupId())); } return getLeader(stream); }
void start() { lifeCycle.transition(STARTING); state.start(); RaftConfiguration conf = getRaftConf(); if (conf != null && conf.contains(getId())) { LOG.debug("{} starts as a follower, conf={}", getId(), conf); startAsFollower(); } else { LOG.debug("{} starts with initializing state, conf={}", getId(), conf); startInitializing(); } registerMBean(getId(), getGroupId(), jmxAdapter, jmxAdapter); }
boolean start() { if (!lifeCycle.compareAndTransition(NEW, STARTING)) { return false; } LOG.info("{}: start {}", getId(), groupId); RaftConfiguration conf = getRaftConf(); if (conf != null && conf.contains(getId())) { LOG.debug("{} starts as a follower, conf={}", getId(), conf); startAsFollower(); } else { LOG.debug("{} starts with initializing state, conf={}", getId(), conf); startInitializing(); } registerMBean(getId(), getGroupId(), jmxAdapter, jmxAdapter); state.start(); return true; }
public void failClientRequest(LogEntryProto logEntry) { if (logEntry.getLogEntryBodyCase() == LogEntryProto.LogEntryBodyCase.SMLOGENTRY) { final ClientId clientId = ClientId.valueOf(logEntry.getClientId()); final RetryCache.CacheEntry cacheEntry = getRetryCache().get(clientId, logEntry.getCallId()); if (cacheEntry != null) { final RaftClientReply reply = new RaftClientReply(clientId, getId(), getGroupId(), logEntry.getCallId(), false, null, generateNotLeaderException(), getCommitInfos()); cacheEntry.failWithReply(reply); } } }
public void failClientRequest(LogEntryProto logEntry) { if (logEntry.hasStateMachineLogEntry()) { final StateMachineLogEntryProto smLog = logEntry.getStateMachineLogEntry(); final ClientId clientId = ClientId.valueOf(smLog.getClientId()); final long callId = smLog.getCallId(); final RetryCache.CacheEntry cacheEntry = getRetryCache().get(clientId, callId); if (cacheEntry != null) { final RaftClientReply reply = new RaftClientReply(clientId, getId(), getGroupId(), callId, false, null, generateNotLeaderException(), logEntry.getIndex(), getCommitInfos()); cacheEntry.failWithReply(reply); } } }