(Protocol<?> p, ProtocolFactoryHandle<?> factoryHandle)
| 204 | } |
| 205 | |
| 206 | public long processRequest(Protocol<?> p, ProtocolFactoryHandle<?> factoryHandle) { |
| 207 | return Task.call(() -> { |
| 208 | if (raft.waitLeaderReady()) { |
| 209 | UniqueRequestState state = raft.getLogSequence().tryGetRequestState(p); |
| 210 | if (state != null) { |
| 211 | if (state != UniqueRequestState.NOT_FOUND) { |
| 212 | if (state.isApplied()) { |
| 213 | p.SendResultCode(Procedure.RaftApplied, |
| 214 | state.getRpcResult().size() > 0 ? state.getRpcResult() : null); |
| 215 | return 0L; |
| 216 | } |
| 217 | p.SendResultCode(Procedure.DuplicateRequest); |
| 218 | return 0L; |
| 219 | } |
| 220 | return p.handle(this, factoryHandle); |
| 221 | } |
| 222 | p.SendResultCode(Procedure.RaftExpired); |
| 223 | return 0L; |
| 224 | } |
| 225 | trySendLeaderIs(p.getSender()); |
| 226 | return 0L; |
| 227 | }, p, Protocol::trySendResultCode); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Raft.Server的线程派发模式总是完全 |
no test coverage detected