use of org.apache.commons.vfs2.FileSystemException in project scheduling by ow2-proactive.
the class SmartProxyImpl method createFolder.
@Override
protected void createFolder(String fUri) throws NotConnectedException, PermissionException {
FileObject fo = null;
try {
fo = jobTracker.resolveFile(fUri);
fo.createFolder();
} catch (FileSystemException e) {
log.error("Error while creating folder: " + fo, e);
}
log.debug("Created remote folder: " + fUri);
}
use of org.apache.commons.vfs2.FileSystemException in project scheduling by ow2-proactive.
the class SmartProxyImpl method downloadTaskOutputFiles.
@Override
protected void downloadTaskOutputFiles(AwaitedJob awaitedjob, String jobId, String t_name, String localFolder) throws Exception {
AwaitedTask atask = awaitedjob.getAwaitedTask(t_name);
if (atask == null) {
throw new IllegalArgumentException("The task " + t_name + " does not belong to job " + jobId + " or has already been removed");
}
if (atask.isTransferring()) {
log.warn("The task " + t_name + " of job " + jobId + " is already transferring its output");
return;
}
String pull_URL = awaitedjob.getPullURL();
if (awaitedjob.isIsolateTaskOutputs()) {
pull_URL = pull_URL.replace(SchedulerConstants.TASKID_DIR_DEFAULT_NAME, SchedulerConstants.TASKID_DIR_DEFAULT_NAME + "/" + atask.getTaskId());
}
FileObject remotePullFolderFO;
FileObject localfolderFO;
try {
remotePullFolderFO = jobTracker.resolveFile(pull_URL);
localfolderFO = jobTracker.resolveFile(localFolder);
} catch (FileSystemException e) {
log.error("Could not retrieve data for job " + jobId, e);
throw new IllegalStateException("Could not retrieve data for job " + jobId, e);
}
String sourceUrl = remotePullFolderFO.getURL().toString();
String destUrl = localfolderFO.getURL().toString();
org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector fileSelector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector();
List<OutputSelector> ouputFileSelectors = atask.getOutputSelectors();
for (OutputSelector os : ouputFileSelectors) {
org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector fs = os.getOutputFiles();
if (!fs.getIncludes().isEmpty()) {
fileSelector.addIncludes(fs.getIncludes());
}
if (!fs.getExcludes().isEmpty()) {
fileSelector.addExcludes(fs.getExcludes());
}
}
if (log.isDebugEnabled()) {
log.debug("Looking at files in " + sourceUrl + " with " + fileSelector.getIncludes() + "-" + fileSelector.getExcludes());
boolean goon = true;
int cpt = 0;
FileObject[] fos = null;
while (goon) {
fos = remotePullFolderFO.findFiles(fileSelector);
goon = cpt < 50 && (fos == null || fos.length == 0);
cpt++;
if (goon) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
if (fos != null && fos.length > 0) {
for (FileObject fo : fos) {
log.debug("Found " + fo.getName());
}
} else {
log.warn("Couldn't find " + fileSelector.getIncludes() + "-" + fileSelector.getExcludes() + " in " + sourceUrl);
}
}
if (awaitedjob.isAutomaticTransfer()) {
DataTransferProcessor dtp = new DataTransferProcessor(remotePullFolderFO, localfolderFO, jobId, t_name, fileSelector);
jobTracker.setTaskTransferring(jobId, t_name, true);
threadPool.submit((Runnable) dtp);
} else {
log.debug("Copying files from " + sourceUrl + " to " + destUrl);
try {
localfolderFO.copyFrom(remotePullFolderFO, fileSelector);
} catch (FileSystemException e) {
log.error(e);
throw e;
} finally {
jobTracker.setTaskTransferring(jobId, t_name, false);
}
// task is removed from the job tracker only if the transfer is successful
jobTracker.removeAwaitedTask(jobId, t_name);
log.debug("Finished copying files from " + sourceUrl + " to " + destUrl);
// ok we can remove the task
}
}
use of org.apache.commons.vfs2.FileSystemException in project zeppelin by apache.
the class NotebookServer method createNote.
private void createNote(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message message) throws IOException {
AuthenticationInfo subject = new AuthenticationInfo(message.principal);
try {
Note note = null;
String defaultInterpreterId = (String) message.get("defaultInterpreterId");
if (!StringUtils.isEmpty(defaultInterpreterId)) {
List<String> interpreterSettingIds = new LinkedList<>();
interpreterSettingIds.add(defaultInterpreterId);
for (String interpreterSettingId : notebook.getInterpreterSettingManager().getDefaultInterpreterSettingList()) {
if (!interpreterSettingId.equals(defaultInterpreterId)) {
interpreterSettingIds.add(interpreterSettingId);
}
}
note = notebook.createNote(interpreterSettingIds, subject);
} else {
note = notebook.createNote(subject);
}
// it's an empty note. so add one paragraph
note.addParagraph(subject);
if (message != null) {
String noteName = (String) message.get("name");
if (StringUtils.isEmpty(noteName)) {
noteName = "Note " + note.getId();
}
note.setName(noteName);
}
note.persist(subject);
addConnectionToNote(note.getId(), (NotebookSocket) conn);
conn.send(serializeMessage(new Message(OP.NEW_NOTE).put("note", note)));
} catch (FileSystemException e) {
LOG.error("Exception from createNote", e);
conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", "Oops! There is something wrong with the notebook file system. " + "Please check the logs for more details.")));
return;
}
broadcastNoteList(subject, userAndRoles);
}
use of org.apache.commons.vfs2.FileSystemException in project jackrabbit by apache.
the class VFSBackend method getTouchFileObject.
/**
* Returns the touch file for the fileObject.
* If there's no corresponding touch file existing, then returns null when {@code create} is false.
* When {@code create} is true, it creates a new touch file if no corresponding touch file exists.
*
* @param fileObject file object
* @param create create a touch file if not existing
* @return touch file object
* @throws DataStoreException if any file system exception occurs
*/
protected FileObject getTouchFileObject(FileObject fileObject, boolean create) throws DataStoreException {
try {
FileObject folderObject = fileObject.getParent();
String touchFileName = fileObject.getName().getBaseName() + TOUCH_FILE_NAME_SUFFIX;
FileObject touchFileObject = folderObject.getChild(touchFileName);
if (touchFileObject == null && create) {
touchFileObject = folderObject.resolveFile(touchFileName);
touchFileObject.createFile();
touchFileObject = folderObject.getChild(touchFileName);
}
return touchFileObject;
} catch (FileSystemException e) {
throw new DataStoreException("Touch file object not resolved: " + fileObject.getName().getFriendlyURI(), e);
}
}
use of org.apache.commons.vfs2.FileSystemException in project jackrabbit by apache.
the class VFSBackend method deleteOlderRecursive.
/**
* Deletes any descendant record files under {@code folderObject} if the record files are older than {@code timestamp},
* and push all the deleted record identifiers into {@code deleteIdSet}.
* @param deleteIdSet set to store all the deleted record identifiers
* @param folderObject folder object to start with
* @param timestamp timestamp
* @throws FileSystemException if any file system exception occurs
* @throws DataStoreException if any file system exception occurs
*/
private void deleteOlderRecursive(Set<DataIdentifier> deleteIdSet, FileObject folderObject, long timestamp) throws FileSystemException, DataStoreException {
FileType type;
DataIdentifier identifier;
for (FileObject fileObject : VFSUtils.getChildFileOrFolders(folderObject)) {
type = fileObject.getType();
if (type == FileType.FOLDER) {
deleteOlderRecursive(deleteIdSet, fileObject, timestamp);
synchronized (this) {
if (!VFSUtils.hasAnyChildFileOrFolder(fileObject)) {
fileObject.delete();
}
}
} else if (type == FileType.FILE) {
long lastModified = getLastModifiedTime(fileObject);
if (lastModified < timestamp) {
identifier = new DataIdentifier(fileObject.getName().getBaseName());
if (getDataStore().confirmDelete(identifier)) {
getDataStore().deleteFromCache(identifier);
if (LOG.isInfoEnabled()) {
LOG.info("Deleting old file " + fileObject.getName().getFriendlyURI() + " modified: " + new Timestamp(lastModified).toString() + " length: " + fileObject.getContent().getSize());
}
if (deleteRecordFileObject(fileObject)) {
deleteIdSet.add(identifier);
} else {
LOG.warn("Failed to delete old file " + fileObject.getName().getFriendlyURI());
}
}
}
}
}
}
Aggregations