io.atomix.protocols.raft.protocol.ResetRequest Java Examples
The following examples show how to use
io.atomix.protocols.raft.protocol.ResetRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalRaftClientProtocol.java From submarine with Apache License 2.0 | 5 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { members.forEach(nodeId -> { LocalRaftServerProtocol server = server(nodeId); if (server != null) { server.reset(request.session(), encode(request)); } }); }
Example #2
Source File: RaftServerMessagingProtocol.java From submarine with Apache License 2.0 | 5 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { messagingService.registerHandler(String.format("reset-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
Example #3
Source File: LocalRaftClientProtocol.java From zeppelin with Apache License 2.0 | 5 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { members.forEach(nodeId -> { LocalRaftServerProtocol server = server(nodeId); if (server != null) { server.reset(request.session(), encode(request)); } }); }
Example #4
Source File: RaftServerMessagingProtocol.java From zeppelin with Apache License 2.0 | 5 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { messagingService.registerHandler(String.format("reset-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
Example #5
Source File: LocalRaftClientProtocol.java From atomix with Apache License 2.0 | 5 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { members.forEach(nodeId -> { LocalRaftServerProtocol server = server(nodeId); if (server != null) { server.reset(request.session(), encode(request)); } }); }
Example #6
Source File: LocalRaftServerProtocol.java From atomix with Apache License 2.0 | 4 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { resetListeners.put(sessionId.id(), request -> executor.execute(() -> listener.accept(request))); }
Example #7
Source File: RaftClientMessagingProtocol.java From submarine with Apache License 2.0 | 4 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { for (MemberId memberId : members) { sendAsync(memberId, String.format("reset-%d", request.session()), request); } }
Example #8
Source File: LocalRaftServerProtocol.java From atomix with Apache License 2.0 | 4 votes |
void reset(long sessionId, byte[] request) { Consumer<ResetRequest> listener = resetListeners.get(sessionId); if (listener != null) { listener.accept(decode(request)); } }
Example #9
Source File: RaftServerMessagingProtocol.java From atomix with Apache License 2.0 | 4 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { messagingService.registerHandler(String.format("reset-%d", sessionId.id()), (e, p) -> { listener.accept(serializer.decode(p)); }, executor); }
Example #10
Source File: RaftClientMessagingProtocol.java From atomix with Apache License 2.0 | 4 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { for (MemberId memberId : members) { sendAsync(memberId, String.format("reset-%d", request.session()), request); } }
Example #11
Source File: RaftClientCommunicator.java From atomix with Apache License 2.0 | 4 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { clusterCommunicator.multicast(context.resetSubject(request.session()), request, serializer::encode, members); }
Example #12
Source File: RaftServerCommunicator.java From atomix with Apache License 2.0 | 4 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { clusterCommunicator.subscribe(context.resetSubject(sessionId.id()), serializer::decode, listener, executor); }
Example #13
Source File: RaftSessionListener.java From atomix with Apache License 2.0 | 4 votes |
/** * Handles a publish request. * * @param request The publish request to handle. */ @SuppressWarnings("unchecked") private void handlePublish(PublishRequest request) { log.trace("Received {}", request); // If the request is for another session ID, this may be a session that was previously opened // for this client. if (request.session() != state.getSessionId().id()) { log.trace("Inconsistent session ID: {}", request.session()); return; } // Store eventIndex in a local variable to prevent multiple volatile reads. long eventIndex = state.getEventIndex(); // If the request event index has already been processed, return. if (request.eventIndex() <= eventIndex) { log.trace("Duplicate event index {}", request.eventIndex()); return; } // If the request's previous event index doesn't equal the previous received event index, // respond with an undefined error and the last index received. This will cause the cluster // to resend events starting at eventIndex + 1. if (request.previousIndex() != eventIndex) { log.trace("Inconsistent event index: {}", request.previousIndex()); ResetRequest resetRequest = ResetRequest.builder() .withSession(state.getSessionId().id()) .withIndex(eventIndex) .build(); log.trace("Sending {}", resetRequest); protocol.reset(memberSelector.members(), resetRequest); return; } // Store the event index. This will be used to verify that events are received in sequential order. state.setEventIndex(request.eventIndex()); sequencer.sequenceEvent(request, () -> { for (PrimitiveEvent event : request.events()) { Set<Consumer<PrimitiveEvent>> listeners = eventListeners.get(event.type()); if (listeners != null) { for (Consumer<PrimitiveEvent> listener : listeners) { listener.accept(event); } } } }); }
Example #14
Source File: LocalRaftServerProtocol.java From zeppelin with Apache License 2.0 | 4 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { resetListeners.put(sessionId.id(), request -> executor.execute(() -> listener.accept(request))); }
Example #15
Source File: LocalRaftServerProtocol.java From zeppelin with Apache License 2.0 | 4 votes |
void reset(long sessionId, byte[] request) { Consumer<ResetRequest> listener = resetListeners.get(sessionId); if (listener != null) { listener.accept(decode(request)); } }
Example #16
Source File: RaftClientMessagingProtocol.java From zeppelin with Apache License 2.0 | 4 votes |
@Override public void reset(Set<MemberId> members, ResetRequest request) { for (MemberId memberId : members) { sendAsync(memberId, String.format("reset-%d", request.session()), request); } }
Example #17
Source File: LocalRaftServerProtocol.java From submarine with Apache License 2.0 | 4 votes |
@Override public void registerResetListener(SessionId sessionId, Consumer<ResetRequest> listener, Executor executor) { resetListeners.put(sessionId.id(), request -> executor.execute(() -> listener.accept(request))); }
Example #18
Source File: LocalRaftServerProtocol.java From submarine with Apache License 2.0 | 4 votes |
void reset(long sessionId, byte[] request) { Consumer<ResetRequest> listener = resetListeners.get(sessionId); if (listener != null) { listener.accept(decode(request)); } }