use of com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest in project cloudbreak by hortonworks.
the class StackUpscaleActions method updateDomainDnsResolverAction.
@Bean(name = "UPDATE_DOMAIN_DNS_RESOLVER_STATE")
public Action<?, ?> updateDomainDnsResolverAction() {
return new AbstractStackUpscaleAction<>(StackScaleTriggerEvent.class) {
@Override
protected void prepareExecution(StackScaleTriggerEvent payload, Map<Object, Object> variables) {
variables.put(HOST_GROUP_WITH_ADJUSTMENT, payload.getHostGroupsWithAdjustment());
variables.put(HOST_GROUP_WITH_HOSTNAMES, payload.getHostGroupsWithHostNames());
variables.put(REPAIR, payload.isRepair());
if (payload.getTriggeredStackVariant() != null) {
variables.put(TRIGGERED_VARIANT, payload.getTriggeredStackVariant());
}
variables.put(NETWORK_SCALE_DETAILS, payload.getNetworkScaleDetails());
variables.put(ADJUSTMENT_WITH_THRESHOLD, payload.getAdjustmentTypeWithThreshold());
}
@Override
protected void doExecute(StackScalingFlowContext context, StackScaleTriggerEvent payload, Map<Object, Object> variables) {
if (context.isRepair()) {
LOGGER.debug("We do not need to update domainDnsResolver in case of repair activity, since it matters only in case of upscale activity.");
sendEvent(context, new UpdateDomainDnsResolverResult(context.getStack().getId()));
} else {
sendEvent(context, new UpdateDomainDnsResolverRequest(context.getStack().getId()));
}
}
@Override
protected Object getFailurePayload(StackScaleTriggerEvent payload, Optional<StackScalingFlowContext> flowContext, Exception ex) {
return new StackFailureEvent(EventSelectorUtil.failureSelector(UpdateDomainDnsResolverResult.class), payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest in project cloudbreak by hortonworks.
the class UpdateDomainDnsResolverHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpdateDomainDnsResolverRequest> updateDomainDnsResolverRequestHandlerEvent) {
UpdateDomainDnsResolverRequest event = updateDomainDnsResolverRequestHandlerEvent.getData();
try {
Stack stack = stackService.getByIdWithLists(event.getResourceId());
DnsResolverType actualDnsResolverType = targetedUpscaleSupportService.getActualDnsResolverType(stack);
if (!actualDnsResolverType.equals(stack.getDomainDnsResolver())) {
LOGGER.debug("New value of domainDnsResolver field for stack {} is {}", stack.getResourceCrn(), actualDnsResolverType);
stack.setDomainDnsResolver(actualDnsResolverType);
stackService.save(stack);
LOGGER.debug("domainDnsResolver field of stack {} has been successfully updated!", stack.getResourceCrn());
} else {
LOGGER.debug("Currently set and actual domainDnsResolverType is the same, not need for update, value {}", actualDnsResolverType);
}
} catch (Exception e) {
LOGGER.debug("We couldn't update domainDnsResolver field of stack, so we move on with current value of the field.", e);
}
return new UpdateDomainDnsResolverResult(event.getResourceId());
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest in project cloudbreak by hortonworks.
the class UpdateDomainDnsResolverHandlerTest method testUpdateIfThereIsErrorDuringUpdate.
@Test
public void testUpdateIfThereIsErrorDuringUpdate() {
when(stackService.getByIdWithLists(any())).thenReturn(new Stack());
when(targetedUpscaleSupportService.getActualDnsResolverType(any())).thenThrow(new RuntimeException("whatever"));
underTest.accept(new Event<>(new UpdateDomainDnsResolverRequest(1L)));
verify(stackService, times(1)).getByIdWithLists(any());
verify(stackService, times(0)).save(any());
verify(targetedUpscaleSupportService, times(1)).getActualDnsResolverType(any());
verify(eventBus, times(1)).notify(any(Object.class), any(Event.class));
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest in project cloudbreak by hortonworks.
the class UpdateDomainDnsResolverHandlerTest method testUpdateDuringUpscale.
@Test
public void testUpdateDuringUpscale() {
when(stackService.getByIdWithLists(any())).thenReturn(stack(DnsResolverType.FREEIPA_FOR_ENV));
when(targetedUpscaleSupportService.getActualDnsResolverType(any())).thenReturn(DnsResolverType.LOCAL_UNBOUND);
when(stackService.save(any())).thenReturn(new Stack());
underTest.accept(new Event<>(new UpdateDomainDnsResolverRequest(1L)));
verify(stackService, times(1)).getByIdWithLists(any());
verify(stackService, times(1)).save(any());
verify(targetedUpscaleSupportService, times(1)).getActualDnsResolverType(any());
verify(eventBus, times(1)).notify(any(Object.class), any(Event.class));
}
Aggregations