Search in sources :

Example 1 with FileSystem

use of com.sequenceiq.cloudbreak.cloud.model.FileSystem 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

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 FileSystemValidationRequest (com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationRequest)1 FileSystemValidationResult (com.sequenceiq.cloudbreak.cloud.event.validation.FileSystemValidationResult)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