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);
}
}
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());
}
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());
}
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);
}
};
}
Aggregations