use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent in project cloudbreak by hortonworks.
the class CertRotationActions method certRotationInProgressAction.
@Bean(name = "CERT_ROTATION_IN_PROGRESS_STATE")
public Action<?, ?> certRotationInProgressAction() {
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) {
LOGGER.info("Cert rotation is in progress. Start waiting to finish");
SdxCertRotationWaitEvent event = new SdxCertRotationWaitEvent(context);
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRotationFailedEvent(payload, ex);
}
};
}
use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent in project cloudbreak by hortonworks.
the class SdxCertRotationWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxCertRotationWaitEvent> event) {
SdxEvent sdxEvent = event.getData();
Long sdxId = sdxEvent.getResourceId();
String userId = sdxEvent.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack cert rotation process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
certRotationService.waitForCloudbreakClusterCertRotation(sdxId, pollingConfig);
response = new SdxEvent(SdxCertRotationEvent.CERT_ROTATION_FINISHED_EVENT.event(), sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Cert rotation polling exited before timeout. Cause: ", userBreakException);
response = new SdxCertRotationFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Cert rotation poller stopped for stack: {}", sdxId);
response = new SdxCertRotationFailedEvent(sdxId, userId, new PollerStoppedException("Datalake cert rotation timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Cert rotation polling failed for stack: {}", sdxId);
response = new SdxCertRotationFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent in project cloudbreak by hortonworks.
the class CertRotationActions method certRotationFinishedAction.
@Bean(name = "CERT_ROTATION_FINISHED_STATE")
public Action<?, ?> certRotationFinishedAction() {
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) {
LOGGER.info("Cert rotation is finished");
certRotationService.finalizeCertRotation(payload.getResourceId());
SdxEvent event = new SdxEvent(SdxCertRotationEvent.CERT_ROTATION_FINALIZED_EVENT.event(), context);
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRotationFailedEvent(payload, ex);
}
};
}
use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent in project cloudbreak by hortonworks.
the class CertRotationActions method starCertRotationAction.
@Bean(name = "START_CERT_ROTATION_STATE")
public Action<?, ?> starCertRotationAction() {
return new AbstractSdxAction<>(SdxStartCertRotationEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartCertRotationEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartCertRotationEvent payload, Map<Object, Object> variables) {
LOGGER.info("Start cert rotation with request: {}", payload.getRequest());
certRotationService.startCertRotation(context.getSdxId(), payload.getRequest());
SdxEvent sdxEvent = new SdxEvent(SdxCertRotationEvent.CERT_ROTATION_STARTED_EVENT.event(), payload.getResourceId(), payload.getUserId());
sendEvent(context, sdxEvent);
}
@Override
protected Object getFailurePayload(SdxStartCertRotationEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRotationFailedEvent(payload, ex);
}
};
}
Aggregations