use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatahubHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnDatahubHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
// TODO action here
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.FINISH_UPGRADE_CCM_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("FINISH_UPGRADE_CCM_EVENT event sent");
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_DATAHUB_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_ON_DATAHUB_FAILED event sent");
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatalakeHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnDatalakeHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
LOGGER.debug("Calling Upgrade CCM endpoint on data lake service");
SdxCcmUpgradeResponse ccmUpgradeResponse = sdxService.upgradeCcm(environmentDto.getResourceCrn());
switch(ccmUpgradeResponse.getResponseType()) {
case ERROR:
String message = String.format("Upgrade CCM returned with reason: %s", ccmUpgradeResponse.getReason());
LOGGER.warn(message);
sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
return;
case TRIGGERED:
LOGGER.debug("Waiting for data lake Upgrade CCM flow to finish.");
pollerService.waitForUpgradeCcm(environmentDto.getId(), ccmUpgradeResponse.getResourceCrn());
break;
case SKIP:
LOGGER.debug("Upgrade CCM is skipped due to {}", ccmUpgradeResponse.getReason());
break;
default:
message = String.format("Unknown response type: %s", ccmUpgradeResponse.getResponseType());
LOGGER.warn(message);
sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
return;
}
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_DATAHUB_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_DATAHUB_EVENT event sent");
} catch (Exception e) {
sendFailedEvent(environmentDtoEvent, environmentDto, e);
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnFreeIpaHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
freeIpaService.describe(environmentDto.getResourceCrn()).ifPresentOrElse(freeIpa -> {
if (freeIpa.getStatus() == null || freeIpa.getAvailabilityStatus() == null) {
throw new FreeIpaOperationFailedException("FreeIPA status is unpredictable, upgrading of Cluster Connectivity Manager will be interrupted.");
} else if (!freeIpa.getStatus().isCcmUpgradeablePhase()) {
throw new FreeIpaOperationFailedException("FreeIPA is not in a valid state to upgrade Cluster Connectivity Manager. Current state is: " + freeIpa.getStatus().name());
} else {
LOGGER.info("CCM on FreeIPA will be upgraded.");
freeIpaPollerService.waitForCcmUpgrade(environmentDto.getId(), environmentDto.getResourceCrn());
}
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_TUNNEL_UPDATE_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_TUNNEL_UPDATE_EVENT event sent");
}, () -> {
throw new FreeIpaOperationFailedException(String.format("FreeIPA cannot be found for environment %s", environmentDto.getName()));
});
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_ON_FREEIPA_FAILED event sent");
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class ValidateUpgradeCcmHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In ValidateUpgradeCcmHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_FREEIPA_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_FREEIPA_EVENT event sent");
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_VALIDATION_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_VALIDATION_FAILED event sent");
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method upgradeCcmInFreeIpaAction.
@Bean(name = "UPGRADE_CCM_FREEIPA_STATE")
public Action<?, ?> upgradeCcmInFreeIpaAction() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmEvent.class) {
@Override
protected void doExecute(CommonContext context, UpgradeCcmEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_FREEIPA_STARTED, UpgradeCcmState.UPGRADE_CCM_FREEIPA_STATE);
sendEvent(context, UPGRADE_CCM_FREEIPA_HANDLER.selector(), envDto);
}
};
}
Aggregations