Search in sources :

Example 6 with GATInvocationException

use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.

the class LoadLevelerFileAdaptor method listFiles.

/*
     * (non-Javadoc)
     * 
     * @see org.gridlab.gat.io.File#listFiles(java.io.FilenameFilter)
     */
public org.gridlab.gat.io.File[] listFiles(FilenameFilter arg0) throws GATInvocationException {
    File[] r = f.listFiles(arg0);
    ArrayList<File> l = new ArrayList<File>();
    for (int i = 0; i < r.length; i++) {
        if (!(ignoreHiddenFiles && r[i].isHidden())) {
            l.add(r[i]);
        }
    }
    org.gridlab.gat.io.File[] res = new org.gridlab.gat.io.File[r.length];
    for (int i = 0; i < res.length; i++) {
        try {
            res[i] = GAT.createFile(gatContext, localToURI(l.get(i).getPath()));
        } catch (Exception e) {
            throw new GATInvocationException("LoadLevelerFile", e);
        }
    }
    return res;
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) ArrayList(java.util.ArrayList) File(java.io.File) URISyntaxException(java.net.URISyntaxException) GATInvocationException(org.gridlab.gat.GATInvocationException) IOException(java.io.IOException) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException)

Example 7 with GATInvocationException

use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.

the class LoadLevelerFileAdaptor method move.

/*
     * (non-Javadoc)
     * 
     * @see org.gridlab.gat.io.File#move(java.net.URI)
     */
public void move(URI destination) throws GATInvocationException {
    destination = newcorrectURI(destination);
    String path = getPath();
    String destPath = destination.getPath();
    if (logger.isInfoEnabled()) {
        logger.info("move of " + path + " to " + destPath);
    }
    if (destPath.equals(path)) {
        if (logger.isInfoEnabled()) {
            logger.info("move, source is the same file as dest.");
        }
        return;
    }
    if (!exists()) {
        throw new GATInvocationException("the source file does not exist, path = " + path);
    }
    File tmp = new File(destPath);
    boolean res = f.renameTo(tmp);
    if (!res) {
        throw new GATInvocationException("Could not move file");
    }
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) File(java.io.File)

Example 8 with GATInvocationException

use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.

the class LoadLevelerJob method waitForTrigger.

// Wait for the creation of a special file (by the application).
void waitForTrigger(JobState state) throws GATInvocationException {
    if (triggerDirectory == null) {
        return;
    }
    if (jobName == null) {
        return;
    }
    if (waiter == null) {
        try {
            waiter = FileWaiter.createFileWaiter(GAT.createFile(gatContext, triggerDirectory));
        } catch (GATObjectCreationException e) {
            throw new GATInvocationException("Could not create", e);
        }
    }
    String filename = jobName + "." + state.toString().substring(0, 3);
    File file;
    try {
        file = GAT.createFile(gatContext, triggerDirectory + "/" + filename);
    } catch (GATObjectCreationException e) {
        throw new GATInvocationException("Could not create");
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Waiting for " + filename + " in directory " + triggerDirectory);
    }
    waiter.waitFor(filename);
    if (logger.isDebugEnabled()) {
        logger.debug("Finished waiting for " + filename + " in directory " + triggerDirectory);
    }
    synchronized (this.getClass()) {
        if (!file.delete()) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not remove " + file.toGATURI());
            }
        }
    }
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) File(org.gridlab.gat.io.File)

Example 9 with GATInvocationException

use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.

the class LsfFileAdaptor method copy.

private static void copy(File in, File out) throws GATInvocationException {
    FileInputStream inBuf = null;
    FileOutputStream outBuf = null;
    try {
        out.createNewFile();
        // Copy source to destination
        inBuf = new FileInputStream(in);
        outBuf = new FileOutputStream(out);
    } catch (IOException e) {
        throw new GATInvocationException("LsfFile", e);
    }
    try {
        byte[] buf = new byte[8192];
        for (; ; ) {
            int len = inBuf.read(buf);
            if (len < 0) {
                break;
            }
            outBuf.write(buf, 0, len);
        }
    } catch (IOException e) {
        throw new GATInvocationException("LsfFile", e);
    } finally {
        if (outBuf != null) {
            try {
                outBuf.close();
            } catch (IOException e) {
                throw new GATInvocationException("LsfFile", e);
            }
        }
        if (inBuf != null) {
            try {
                inBuf.close();
            } catch (IOException e) {
                throw new GATInvocationException("LsfFile", e);
            }
        }
    }
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 10 with GATInvocationException

use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.

the class LsfFileAdaptor method move.

/*
     * (non-Javadoc)
     * 
     * @see org.gridlab.gat.io.File#move(java.net.URI)
     */
public void move(URI destination) throws GATInvocationException {
    destination = newcorrectURI(destination);
    String path = getPath();
    String destPath = destination.getPath();
    if (logger.isInfoEnabled()) {
        logger.info("move of " + path + " to " + destPath);
    }
    if (destPath.equals(path)) {
        if (logger.isInfoEnabled()) {
            logger.info("move, source is the same file as dest.");
        }
        return;
    }
    if (!exists()) {
        throw new GATInvocationException("the source file does not exist, path = " + path);
    }
    File tmp = new File(destPath);
    boolean res = f.renameTo(tmp);
    if (!res) {
        throw new GATInvocationException("Could not move file");
    }
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) File(java.io.File)

Aggregations

GATInvocationException (org.gridlab.gat.GATInvocationException)64 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)46 URISyntaxException (java.net.URISyntaxException)25 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)24 URI (org.gridlab.gat.URI)23 JobDescription (org.gridlab.gat.resources.JobDescription)23 File (java.io.File)22 IOException (java.io.IOException)21 Job (org.gridlab.gat.resources.Job)19 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)17 FileInterface (org.gridlab.gat.io.FileInterface)14 BufferedReader (java.io.BufferedReader)7 FileOutputStream (java.io.FileOutputStream)6 ArrayList (java.util.ArrayList)6 PrintWriter (java.io.PrintWriter)5 InputStreamReader (java.io.InputStreamReader)4 StringWriter (java.io.StringWriter)4 AdaptorNotApplicableException (org.gridlab.gat.AdaptorNotApplicableException)4 Preferences (org.gridlab.gat.Preferences)4 File (org.gridlab.gat.io.File)4