use of com.sequenceiq.cloudbreak.reactor.api.event.stack.CleanupFreeIpaEvent in project cloudbreak by hortonworks.
the class CleanupFreeIpaHandlerTest method testEventSentOnErrorRecover.
@Test
public void testEventSentOnErrorRecover() {
Event<CleanupFreeIpaEvent> cleanupFreeIpaEvent = mock(Event.class);
when(cleanupFreeIpaEvent.getData()).thenReturn(new CleanupFreeIpaEvent(1L, Set.of(), Set.of(), true));
when(stackService.get(1L)).thenReturn(new Stack());
doThrow(new RuntimeException()).when(freeIpaCleanupService).cleanupOnRecover(any(Stack.class), anySet(), anySet());
underTest.accept(cleanupFreeIpaEvent);
verify(eventBus).notify(eq(CLEANUP_FREEIPA_FINISHED_EVENT.event()), any(Event.class));
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.CleanupFreeIpaEvent in project cloudbreak by hortonworks.
the class StackUpscaleActions method finishExtendHostMetadata.
@Bean(name = "EXTEND_HOST_METADATA_FINISHED_STATE")
public Action<?, ?> finishExtendHostMetadata() {
return new AbstractStackUpscaleAction<>(CleanupFreeIpaEvent.class) {
@Override
protected void doExecute(StackScalingFlowContext context, CleanupFreeIpaEvent payload, Map<Object, Object> variables) {
final Stack stack = context.getStack();
stackUpscaleService.finishExtendHostMetadata(stack);
final Set<String> newAddresses = payload.getIps();
final Map<String, String> newAddressesByFqdn = stack.getNotDeletedAndNotZombieInstanceMetaDataSet().stream().filter(instanceMetaData -> newAddresses.contains(instanceMetaData.getPrivateIp())).filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null).collect(Collectors.toMap(InstanceMetaData::getDiscoveryFQDN, InstanceMetaData::getPublicIpWrapper));
clusterPublicEndpointManagementService.upscale(stack, newAddressesByFqdn);
getMetricService().incrementMetricCounter(MetricType.STACK_UPSCALE_SUCCESSFUL, stack);
sendEvent(context);
}
@Override
protected Selectable createRequest(StackScalingFlowContext context) {
return new StackEvent(StackUpscaleEvent.UPSCALE_FINALIZED_EVENT.event(), context.getStack().getId());
}
};
}
Aggregations