Search in sources :

Example 1 with FileSystemValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult in project cloudbreak by hortonworks.

the class FileSystemValidationHandler method accept.

@Override
public void accept(Event<FileSystemValidationRequest> requestEvent) {
    LOGGER.info("Received event: {}", requestEvent);
    FileSystemValidationRequest request = requestEvent.getData();
    try {
        CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
        connector.setup().validateFileSystem(request.getCredential(), request.getFileSystem());
        request.getResult().onNext(new FileSystemValidationResult(request));
    } catch (Exception e) {
        request.getResult().onNext(new FileSystemValidationResult(e.getMessage(), e, request));
    }
}
Also used : FileSystemValidationResult(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult) FileSystemValidationRequest(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationRequest) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector)

Example 2 with FileSystemValidationResult

use of com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult in project cloudbreak by hortonworks.

the class FileSystemValidator method validateFileSystem.

public void validateFileSystem(String platform, CloudCredential cloudCredential, FileSystemRequest fileSystemRequest) {
    if (fileSystemRequest == null) {
        return;
    }
    validateFilesystemRequest(fileSystemRequest);
    LOGGER.debug("Sending fileSystemRequest to {} to validate the file system", platform);
    CloudContext cloudContext = new CloudContext(null, null, platform, null, null, null);
    FileSystem fileSystem = converter.convert(fileSystemRequest);
    FileSystemValidationRequest request = new FileSystemValidationRequest(fileSystem, cloudCredential, cloudContext);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    try {
        FileSystemValidationResult result = request.await();
        LOGGER.info("File system validation result: {}", result);
        Exception exception = result.getErrorDetails();
        if (exception != null) {
            throw new BadRequestException(result.getStatusReason(), exception);
        }
    } catch (InterruptedException e) {
        LOGGER.error("Error while sending the file system validation request", e);
        throw new OperationException(e);
    }
}
Also used : FileSystemValidationResult(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult) FileSystemValidationRequest(com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationRequest) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) FileSystem(com.sequenceiq.cloudbreak.cloud.model.FileSystem) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) IOException(java.io.IOException) ConstraintViolationException(javax.validation.ConstraintViolationException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

FileSystemValidationRequest (com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationRequest)2 FileSystemValidationResult (com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 FileSystem (com.sequenceiq.cloudbreak.cloud.model.FileSystem)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1 IOException (java.io.IOException)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1