public void removeArbitrator( Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { log.debug("removeArbitrator arbitrator.hashCode() " + arbitrator.hashCode()); if (p2PService.removeData(arbitrator)) { log.trace("Remove arbitrator from network was successful. Arbitrator = " + arbitrator); resultHandler.handleResult(); } else { errorMessageHandler.handleErrorMessage("Remove arbitrator failed"); } }
public Map<Address, Arbitrator> getArbitrators() { Set<Arbitrator> arbitratorSet = p2PService .getDataMap() .values() .stream() .filter(e -> e.expirablePayload instanceof Arbitrator) .map(e -> (Arbitrator) e.expirablePayload) .collect(Collectors.toSet()); Map<Address, Arbitrator> map = new HashMap<>(); for (Arbitrator arbitrator : arbitratorSet) { Address arbitratorAddress = arbitrator.getArbitratorAddress(); if (!map.containsKey(arbitratorAddress)) map.put(arbitratorAddress, arbitrator); else log.warn( "arbitratorAddress already exist in arbitrator map. Seems an arbitrator object is already registered with the same address."); } return map; }
public void addArbitrator( Arbitrator arbitrator, final ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode()); boolean result = p2PService.addData(arbitrator); if (result) { log.trace("Add arbitrator to network was successful. Arbitrator = " + arbitrator); resultHandler.handleResult(); } else { errorMessageHandler.handleErrorMessage("Add arbitrator failed"); } }