use of com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent in project cloudbreak by hortonworks.
the class CertRenewalActions method certRenewFinishedAction.
@Bean(name = "CERT_RENEWAL_FINISHED_STATE")
public Action<?, ?> certRenewFinishedAction() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Cert renewal is finished");
certRenewalService.finalizeCertRenewal(payload.getResourceId());
SdxEvent event = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINALIZED_EVENT.event(), context);
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent in project cloudbreak by hortonworks.
the class SdxCertRenewWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxCertRenewalWaitEvent> event) {
SdxEvent sdxEvent = event.getData();
Long sdxId = sdxEvent.getResourceId();
String userId = sdxEvent.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack cert renewal process.");
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
certRenewalService.waitForCloudbreakClusterCertRenewal(sdxId, pollingConfig);
response = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINISHED_EVENT.event(), sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Cert renewal polling exited before timeout. Cause: ", userBreakException);
response = new SdxCertRenewalFailedEvent(sdxId, userId, userBreakException.getMessage());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Cert renewal poller stopped.");
response = new SdxCertRenewalFailedEvent(sdxId, userId, "Datalake cert renewal timed out after " + durationInMinutes + " minutes");
} catch (PollerException exception) {
LOGGER.error("Cert renewal polling failed. Cause: ", exception);
response = new SdxCertRenewalFailedEvent(sdxId, userId, exception.getMessage());
}
return response;
}
use of com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent in project cloudbreak by hortonworks.
the class CertRenewalActions method startCertRenewAction.
@Bean(name = "START_CERT_RENEWAL_STATE")
public Action<?, ?> startCertRenewAction() {
return new AbstractSdxAction<>(SdxStartCertRenewalEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartCertRenewalEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartCertRenewalEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Start cert renewal.");
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
if (payload.isInternal()) {
certRenewalService.renewInternalCertificate(sdxCluster);
} else {
certRenewalService.renewCertificate(sdxCluster, payload.getUserId());
}
SdxEvent sdxEvent = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_STARTED_EVENT.event(), payload.getResourceId(), payload.getUserId());
sendEvent(context, sdxEvent);
}
@Override
protected Object getFailurePayload(SdxStartCertRenewalEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent in project cloudbreak by hortonworks.
the class CertRenewalActions method certRenewInProgressAction.
@Bean(name = "CERT_RENEWAL_IN_PROGRESS_STATE")
public Action<?, ?> certRenewInProgressAction() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Cert renewal is in progress. Start waiting to finish.");
sendEvent(context, new SdxCertRenewalWaitEvent(context));
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
Aggregations