class ClusterOperationService {

    public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) {
        if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) {
            throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items.");
        }
        if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) {
            return;
        }
        try {
            transactionService.required(() -> {
                Stack stack = stackService.findByCrn(crn);
                if (stack != null && !stack.getStatus().isInProgress()) {
                    handleHealthChange(failedNodes, newHealthyNodes, stack);
                } else {
                    LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus());
                }
                return null;
            });
        } catch (TransactionExecutionException e) {
            throw new TransactionRuntimeExecutionException(e);
        }
    }

}