use of com.sequenceiq.datalake.flow.create.event.StorageValidationRequest in project cloudbreak by hortonworks.
the class StorageValidationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StorageValidationRequest> event) {
StorageValidationRequest storageValidationRequest = event.getData();
Long sdxId = storageValidationRequest.getResourceId();
String userId = storageValidationRequest.getUserId();
try {
Optional<SdxCluster> sdxCluster = sdxClusterRepository.findById(sdxId);
if (sdxCluster.isPresent()) {
DetailedEnvironmentResponse env = environmentService.getDetailedEnvironmentResponseByName(sdxCluster.get().getEnvName());
stackRequestManifester.configureStackForSdxCluster(sdxCluster.get(), env);
return new StorageValidationSuccessEvent(sdxId, userId);
} else {
throw notFound("SDX cluster", sdxId).get();
}
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx storage validation phase", anotherException);
return new SdxCreateFailedEvent(sdxId, userId, anotherException);
}
}
use of com.sequenceiq.datalake.flow.create.event.StorageValidationRequest 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