use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method findFilesToCopyFromInput.
private Future<List<DataSpacesFileObject>> findFilesToCopyFromInput(final DataSpacesFileObject space, final String spaceName, final InputSelector inputSelector, final org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector) {
return executorTransfer.submit(new Callable<List<DataSpacesFileObject>>() {
@Override
public List<DataSpacesFileObject> call() throws Exception {
List<DataSpacesFileObject> results = new ArrayList<>();
if (!checkInputSpaceConfigured(space, spaceName, inputSelector)) {
return results;
}
logger.debug("Selector used is " + selector);
try {
Utils.findFiles(space, selector, results);
if (results.isEmpty()) {
// we detected that there was no new file in the list
String message = "No file is transferred from " + spaceName + " space at " + space.getRealURI() + " for selector " + inputSelector;
logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
logger.warn(message);
}
} catch (FileSystemException e) {
logger.warn("Error occurred while transferring files", e);
String message = "Could not contact " + spaceName + " space at " + space.getRealURI() + ". An error occurred while resolving selector " + inputSelector;
logDataspacesStatus(message, DataspacesStatusLevel.ERROR);
logDataspacesStatus(getStackTraceAsString(e), DataspacesStatusLevel.ERROR);
logger.error(message, e);
throw new FileSystemException(message);
} catch (NullPointerException e) {
// nothing to do
return results;
}
return results;
}
});
}
use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method copyScratchDataToOutput.
@Override
public void copyScratchDataToOutput(List<OutputSelector> outputSelectors) throws FileSystemException {
try {
if (outputSelectors == null) {
logger.debug("Output selector is empty, no file to copy");
return;
}
SCRATCH.refresh();
checkOutputSpacesConfigured(outputSelectors);
ArrayList<DataSpacesFileObject> results = new ArrayList<>();
FileSystemException toBeThrown = null;
for (OutputSelector os : outputSelectors) {
org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector();
selector.setIncludes(os.getOutputFiles().getIncludes());
selector.setExcludes(os.getOutputFiles().getExcludes());
switch(os.getMode()) {
case TransferToOutputSpace:
if (OUTPUT != null) {
toBeThrown = copyScratchDataToOutput(OUTPUT, "OUTPUT", os, selector, results);
}
break;
case TransferToGlobalSpace:
if (GLOBAL != null) {
toBeThrown = copyScratchDataToOutput(GLOBAL, "GLOBAL", os, selector, results);
}
break;
case TransferToUserSpace:
if (USER != null) {
toBeThrown = copyScratchDataToOutput(USER, "USER", os, selector, results);
break;
}
case none:
break;
}
results.clear();
}
if (toBeThrown != null) {
throw toBeThrown;
}
} finally {
// display dataspaces error and warns if any
displayDataspacesStatus();
}
}
use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method copyScratchDataToOutput.
private FileSystemException copyScratchDataToOutput(DataSpacesFileObject dataspace, String spaceName, OutputSelector outputSelector, org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector, List<DataSpacesFileObject> results) {
try {
int sizeBeforeHandlingOutput = results.size();
handleOutput(dataspace, spaceName, selector, results);
if (results.size() == sizeBeforeHandlingOutput) {
String message = "No file is transferred to " + spaceName + " space at " + dataspace.getRealURI() + " for selector " + outputSelector;
logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
logger.warn(message);
}
} catch (FileSystemException fse) {
String message = "Error while transferring to " + spaceName + " space at " + dataspace.getRealURI() + " for selector " + outputSelector;
logDataspacesStatus(message, DataspacesStatusLevel.ERROR);
logDataspacesStatus(getStackTraceAsString(fse), DataspacesStatusLevel.ERROR);
logger.error(message, fse);
return fse;
}
return null;
}
use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method initDataSpace.
private DataSpacesFileObject initDataSpace(Callable<DataSpacesFileObject> dataSpaceBuilder, String dataSpaceName, boolean input) throws Exception {
try {
DataSpacesFileObject result = dataSpaceBuilder.call();
result = resolveToExisting(result, dataSpaceName, input);
result = createTaskIdFolder(result, dataSpaceName);
// before the transfer
if (result != null) {
result.refresh();
}
return result;
} catch (FileSystemException fse) {
String message = dataSpaceName + " space is disabled";
logger.warn(message, fse);
logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
logDataspacesStatus(getStackTraceAsString(fse), DataspacesStatusLevel.WARNING);
}
return null;
}
use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method handleResultsWhileTransferringFile.
protected void handleResultsWhileTransferringFile(List<Future<Boolean>> transferFutures, String destinationSpaceName, long startTime) throws FileSystemException {
StringBuilder message = new StringBuilder();
String nl = System.lineSeparator();
for (Future<Boolean> future : transferFutures) {
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
logger.error("Exception while fetching dataspace transfer result ", e);
message.append(StackTraceUtil.getStackTrace(e)).append(nl);
}
}
logger.info("Time needed to copy files to " + destinationSpaceName + " : " + (System.currentTimeMillis() - startTime) + " ms");
if (message.length() > 0) {
throw new FileSystemException("Exception(s) occurred when transferring input file: " + nl + message.toString());
}
}
Aggregations