Search in sources :

Example 1 with RemoveReplicationAgreementsRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest in project cloudbreak by hortonworks.

the class RemoveReplicationAgreementsHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<RemoveReplicationAgreementsRequest> event) {
    RemoveReplicationAgreementsRequest request = event.getData();
    try {
        Long stackId = request.getResourceId();
        Stack stack = stackService.getStackById(stackId);
        freeIpaTopologyService.updateReplicationTopologyWithRetry(stack, request.getHosts());
        return new RemoveReplicationAgreementsResponse(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("Downscale removing replication agreements failed", e);
        return new DownscaleFailureEvent(REMOVE_REPLICATION_AGREEMENTS_FAILED_EVENT.event(), request.getResourceId(), "Downscale Remove Replication Agreements", Set.of(), Map.of(), e);
    }
}
Also used : RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) RemoveReplicationAgreementsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsResponse) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 2 with RemoveReplicationAgreementsRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest in project cloudbreak by hortonworks.

the class RemoveReplicationAgreementsHandlerTest method testRemoveReplicationAgreementsFailure.

@Test
void testRemoveReplicationAgreementsFailure() {
    CleanupEvent cleanupEvent = new CleanupEvent(STACK_ID, USERS, HOSTS, ROLES, IPS, STATES_TO_SKIP, ACCOUNT_ID, OPERATION_ID, CLUSTER_NAME, ENVIRONMENT_CRN);
    RemoveReplicationAgreementsRequest request = new RemoveReplicationAgreementsRequest(cleanupEvent);
    when(stackService.getStackById(any())).thenThrow(new RuntimeException("expected exception"));
    underTest.accept(new Event<>(request));
    verify(eventBus).notify(eq("REMOVE_REPLICATION_AGREEMENTS_FAILED_EVENT"), ArgumentMatchers.<Event>any());
}
Also used : RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Test(org.junit.jupiter.api.Test)

Example 3 with RemoveReplicationAgreementsRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest in project cloudbreak by hortonworks.

the class RemoveReplicationAgreementsHandlerTest method testRemoveReplicationAgreementsSuccess.

@Test
void testRemoveReplicationAgreementsSuccess() throws FreeIpaClientException {
    CleanupEvent cleanupEvent = new CleanupEvent(STACK_ID, USERS, HOSTS, ROLES, IPS, STATES_TO_SKIP, ACCOUNT_ID, OPERATION_ID, CLUSTER_NAME, ENVIRONMENT_CRN);
    RemoveReplicationAgreementsRequest request = new RemoveReplicationAgreementsRequest(cleanupEvent);
    Stack stack = mock(Stack.class);
    when(stackService.getStackById(any())).thenReturn(stack);
    underTest.accept(new Event<>(request));
    verify(freeIpaTopologyService).updateReplicationTopologyWithRetry(any(), any());
    verify(eventBus).notify(eq("REMOVEREPLICATIONAGREEMENTSRESPONSE"), ArgumentMatchers.<Event>any());
}
Also used : RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 4 with RemoveReplicationAgreementsRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest 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)

Aggregations

RemoveReplicationAgreementsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest)4 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)3 Stack (com.sequenceiq.freeipa.entity.Stack)2 Test (org.junit.jupiter.api.Test)2 DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)1 RemoveReplicationAgreementsResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsResponse)1 RemoveServersResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1