Search in sources :

Example 1 with RemoveServersResponse

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);
        }
    };
}
Also used : StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) RemoveServersResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse) RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with RemoveServersResponse

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;
}
Also used : RemoveServersResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)

Example 3 with RemoveServersResponse

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));
    }
}
Also used : RemoveServersRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersRequest) Set(java.util.Set) RemoveServersResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse) Event(reactor.bus.Event) Map(java.util.Map)

Aggregations

RemoveServersResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse)3 Map (java.util.Map)2 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)1 DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)1 RemoveReplicationAgreementsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest)1 RemoveServersRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersRequest)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 Set (java.util.Set)1 Bean (org.springframework.context.annotation.Bean)1 Event (reactor.bus.Event)1