use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method removeReplicationAgreementsAction.
@Bean(name = "DOWNSCALE_REMOVE_REPLICATION_AGREEMENTS_STATE")
public Action<?, ?> removeReplicationAgreementsAction() {
return new AbstractDownscaleAction<>(RemoveServersResponse.class) {
@Override
protected void doExecute(StackContext context, RemoveServersResponse payload, Map<Object, Object> variables) {
CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Removing servers");
RemoveReplicationAgreementsRequest request = new RemoveReplicationAgreementsRequest(cleanupEvent);
sendEvent(context, request);
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse in project cloudbreak by hortonworks.
the class RemoveServersResponseToDownscaleFailureEventConverter method convert.
@Override
public DownscaleFailureEvent convert(Object payload) {
RemoveServersResponse removeServersResponse = (RemoveServersResponse) payload;
DownscaleFailureEvent event = new DownscaleFailureEvent(removeServersResponse.getResourceId(), "Server removal", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse in project cloudbreak by hortonworks.
the class ServerRemoveHandler method accept.
@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 (Exception 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));
}
}
Aggregations