- private Behavior<CandidateRegistryCommand> handleCandidateSync(final InitialCandidateSync command) {
- final Replicator.GetResponse<ORMap<DOMEntity, ORSet<String>>> response = command.getResponse();
- if (response instanceof Replicator.GetSuccess) {
- clearExistingCandidates((Replicator.GetSuccess<ORMap<DOMEntity, ORSet<String>>>) response);
- }
- // TODO implement other cases if needed, seems like only a retry would be needed here when we get a failure
- // from distributed data
- return switchToCandidateRegistry();
- }
-
- private void clearExistingCandidates(final Replicator.GetSuccess<ORMap<DOMEntity, ORSet<String>>> response) {
- final Map<DOMEntity, ORSet<String>> entitiesToCandidates = response.get(response.key()).getEntries();
+ private Behavior<CandidateRegistryCommand> onRemoveCandidates(final RemovePreviousCandidates command) {
+ LOG.debug("Sending RemovePreviousCandidates.");
+ getContext().ask(ClearCandidatesResponse.class,
+ ownerSupervisor, Duration.ofSeconds(5),
+ ref -> new ClearCandidatesForMember(ref, selfRole),
+ (response, throwable) -> {
+ if (response != null) {
+ return new CandidateRemovalFinished();
+ } else {
+ return new CandidateRemovalFailed(throwable);
+ }
+ });