Search in sources :

Example 6 with URI

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

the class LoadLevelerFileAdaptor method getFile.

private File getFile(URI location) {
    File file;
    URI correctedURI = newcorrectURI(location);
    logger.debug("corrected uri '" + location + "' to '" + correctedURI + "'");
    if ((correctedURI.getPath() == null) || (correctedURI.getPath().equals(""))) {
        file = new File(".");
    } else {
        String path = correctedURI.getPath();
        if (java.io.File.separatorChar == '\\') {
            // This means we're on a Windows machine!
            if (path.startsWith("/")) {
                path = path.substring(1);
            }
            path = path.replace("/", "\\");
        }
        file = new File(path);
    }
    return file;
}
Also used : File(java.io.File) URI(org.gridlab.gat.URI)

Example 7 with URI

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

the class LoadLevelerFileAdaptor method renameTo.

/*
     * (non-Javadoc)
     * 
     * @see org.gridlab.gat.io.File#renameTo(java.io.File)
     */
public boolean renameTo(org.gridlab.gat.io.File arg0) throws GATInvocationException {
    URI arg = arg0.toGATURI();
    File tmp = getFile(arg);
    return f.renameTo(tmp);
}
Also used : URI(org.gridlab.gat.URI) File(java.io.File)

Example 8 with URI

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

the class LsfFileAdaptor method getFile.

private File getFile(URI location) {
    File file;
    URI correctedURI = newcorrectURI(location);
    logger.debug("corrected uri '" + location + "' to '" + correctedURI + "'");
    if ((correctedURI.getPath() == null) || (correctedURI.getPath().equals(""))) {
        file = new File(".");
    } else {
        String path = correctedURI.getPath();
        if (java.io.File.separatorChar == '\\') {
            // This means we're on a Windows machine!
            if (path.startsWith("/")) {
                path = path.substring(1);
            }
            path = path.replace("/", "\\");
        }
        file = new File(path);
    }
    return file;
}
Also used : File(java.io.File) URI(org.gridlab.gat.URI)

Example 9 with URI

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

the class LsfFileAdaptor method renameTo.

/*
     * (non-Javadoc)
     * 
     * @see org.gridlab.gat.io.File#renameTo(java.io.File)
     */
public boolean renameTo(org.gridlab.gat.io.File arg0) throws GATInvocationException {
    URI arg = arg0.toGATURI();
    File tmp = getFile(arg);
    return f.renameTo(tmp);
}
Also used : URI(org.gridlab.gat.URI) File(java.io.File)

Example 10 with URI

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

the class SshLSFJob method getJobState.

protected void getJobState(String jobID) throws GATInvocationException {
    synchronized (this) {
        while (jobStateBusy) {
            try {
                wait();
            } catch (InterruptedException e) {
            // ignored
            }
        }
        jobStateBusy = true;
    }
    JobState resultState;
    try {
        if (state == JobState.POST_STAGING || state == JobState.STOPPED || state == JobState.SUBMISSION_ERROR) {
            return;
        }
        logger.debug("Getting task status in setState()");
        // getting the status via ssh ... squeue
        java.io.File squeueResultFile = null;
        try {
            // Create qstat job
            SoftwareDescription sd = new SoftwareDescription();
            // Use /bin/sh, so that $USER gets expanded.
            sd.setExecutable("/bin/sh");
            sd.setArguments("-c", "bjobs -noheader " + jobID + " | awk {' print $3 '}");
            sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
            squeueResultFile = java.io.File.createTempFile("GAT", "tmp");
            try {
                sd.setStdout(GAT.createFile(subContext, new URI("file:///" + squeueResultFile.getAbsolutePath().replace(File.separatorChar, '/'))));
            } catch (Throwable e1) {
                throw new GATInvocationException("Could not create GAT object for temporary " + squeueResultFile.getAbsolutePath(), e1);
            }
            JobDescription jd = new JobDescription(sd);
            Job job = jobHelper.submitJob(jd, this, "job.status");
            synchronized (job) {
                while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
                    try {
                        job.wait();
                    } catch (InterruptedException e) {
                    // ignore
                    }
                }
            }
            if (job.getState() != Job.JobState.STOPPED || job.getExitStatus() != 0) {
                throw new GATInvocationException("Could not submit squeue job " + sd.toString());
            }
            // submit success.
            BufferedReader in = new BufferedReader(new FileReader(squeueResultFile.getAbsolutePath()));
            String status = in.readLine();
            // or finished. Set to "" in this case. --Ceriel
            if (status == null) {
                status = "";
            }
            if (logger.isDebugEnabled()) {
                logger.debug("squeue line: " + status);
            }
            resultState = mapLSFStatetoGAT(status);
        } catch (IOException e) {
            logger.debug("retrieving job status sshslurmjob failed", e);
            throw new GATInvocationException("Unable to retrieve the Job Status", e);
        } finally {
            squeueResultFile.delete();
        }
    } finally {
        synchronized (this) {
            jobStateBusy = false;
            notifyAll();
        }
    }
    if (resultState != JobState.STOPPED) {
        setState(resultState);
    } else {
        setState(JobState.POST_STAGING);
    }
}
Also used : IOException(java.io.IOException) URI(org.gridlab.gat.URI) File(java.io.File) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) JobDescription(org.gridlab.gat.resources.JobDescription) GATInvocationException(org.gridlab.gat.GATInvocationException) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) SshLSFJob(org.gridlab.gat.resources.cpi.sshlsf.SshLSFJob) Job(org.gridlab.gat.resources.Job)

Aggregations

URI (org.gridlab.gat.URI)53 URISyntaxException (java.net.URISyntaxException)28 JobDescription (org.gridlab.gat.resources.JobDescription)28 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)27 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)26 GATInvocationException (org.gridlab.gat.GATInvocationException)24 Job (org.gridlab.gat.resources.Job)23 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)19 Preferences (org.gridlab.gat.Preferences)11 BufferedReader (java.io.BufferedReader)8 File (java.io.File)8 IOException (java.io.IOException)8 GATContext (org.gridlab.gat.GATContext)8 File (org.gridlab.gat.io.File)8 InputStreamReader (java.io.InputStreamReader)5 LinkedList (java.util.LinkedList)4 AdvertService (org.gridlab.gat.advert.AdvertService)4 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)4 GATScriptExecutor (es.bsc.compss.gat.master.utils.GATScriptExecutor)3 MultiURI (es.bsc.compss.types.uri.MultiURI)3