class ServerRemoveHandler implements EventHandler<RemoveServersRequest> {

    @Override
    public void accept(Event<RemoveServersRequest> event) {
        RemoveServersRequest request = event.getData();
        try {
            Set<String> hosts = request.getHosts();
            LOGGER.debug("Removing servers [{}]", hosts);
            Pair<Set<String>, Map<String, String>> removeServersResult =
                    cleanupService.removeServers(request.getResourceId(), hosts);
            RemoveServersResponse response = new RemoveServersResponse(request, removeServersResult.getFirst(), removeServersResult.getSecond());
            eventBus.notify(response.getServerCleanupFailed().isEmpty()
                            ? EventSelectorUtil.selector(RemoveServersResponse.class) : EventSelectorUtil.failureSelector(RemoveServersResponse.class),
                    new Event<>(event.getHeaders(), response));
        } catch (FreeIpaClientException e) {
            LOGGER.error("Removing failed for servers: [{}]", request.getHosts(), e);
            Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
            RemoveServersResponse response = new RemoveServersResponse(request, Collections.emptySet(), failureResult);
            eventBus.notify(EventSelectorUtil.failureSelector(RemoveServersResponse.class),
                    new Event<>(event.getHeaders(), response));
        }
    }

}