use of com.sequenceiq.datalake.flow.SdxEvent 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.SdxEvent 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.SdxEvent 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());
}
};
}
use of com.sequenceiq.datalake.flow.SdxEvent 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.SdxEvent in project cloudbreak by hortonworks.
the class SdxCreateActions method storageValidation.
@Bean(name = "SDX_CREATION_STORAGE_VALIDATION_STATE")
public Action<?, ?> storageValidation() {
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 {
// When SDX is created as part of re-size flow chain, SDX in payload will not have the correct ID.
setCorrectSdxIdIfNecessary(context, payload);
StorageValidationRequest req = new StorageValidationRequest(context);
sendEvent(context, req.selector(), req);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return SdxCreateFailedEvent.from(payload, ex);
}
};
}
Aggregations