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));
}
}
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);
}
}
Aggregations