Search in sources :

Example 1 with GATInvocationException

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

the class GATJob method processMetricEvent.

// MetricListener interface implementation
@Override
public void processMetricEvent(MetricEvent value) {
    Job job = (Job) value.getSource();
    JobState newJobState = (JobState) value.getValue();
    JobDescription jd = (JobDescription) job.getJobDescription();
    SoftwareDescription sd = jd.getSoftwareDescription();
    Integer jobId = (Integer) sd.getAttributes().get("jobId");
    logger.debug("Processing job ID = " + jobId);
    /*
         * Check if either the job has finished or there has been a submission error. We don't care about other state
         * transitions
         */
    if (newJobState == JobState.STOPPED) {
        if (Tracer.isActivated()) {
            Integer slot = (Integer) sd.getAttributes().get("slot");
            String host = getResourceNode().getHost();
            Tracer.freeSlot(host, slot);
        }
        /*
             * We must check whether the chosen adaptor is globus In that case, since globus doesn't provide the exit
             * status of a job, we must examine the standard error file
             */
        try {
            if (usingGlobus) {
                File errFile = sd.getStderr();
                // Error file should always be in the same host as the IT
                File localFile = GAT.createFile(context, errFile.toGATURI());
                if (localFile.length() > 0) {
                    GATjob = null;
                    RUNNING_JOBS.remove(this);
                    ErrorManager.warn("Error when creating file.");
                    listener.jobFailed(this, JobEndStatus.EXECUTION_FAILED);
                } else {
                    if (!debug) {
                        localFile.delete();
                    }
                    RUNNING_JOBS.remove(this);
                    listener.jobCompleted(this);
                }
            } else {
                if (job.getExitStatus() == 0) {
                    RUNNING_JOBS.remove(this);
                    listener.jobCompleted(this);
                } else {
                    GATjob = null;
                    RUNNING_JOBS.remove(this);
                    listener.jobFailed(this, JobEndStatus.EXECUTION_FAILED);
                }
            }
        } catch (Exception e) {
            ErrorManager.fatal(CALLBACK_PROCESSING_ERR + ": " + this, e);
        }
    } else if (newJobState == JobState.SUBMISSION_ERROR) {
        if (Tracer.isActivated()) {
            Integer slot = (Integer) sd.getAttributes().get("slot");
            String host = getResourceNode().getHost();
            Tracer.freeSlot(host, slot);
        }
        try {
            if (usingGlobus && job.getInfo().get("resManError").equals("NO_ERROR")) {
                RUNNING_JOBS.remove(this);
                listener.jobCompleted(this);
            } else {
                GATjob = null;
                RUNNING_JOBS.remove(this);
                listener.jobFailed(this, JobEndStatus.SUBMISSION_FAILED);
            }
        } catch (GATInvocationException e) {
            ErrorManager.fatal(CALLBACK_PROCESSING_ERR + ": " + this, e);
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATInvocationException(org.gridlab.gat.GATInvocationException) JobState(org.gridlab.gat.resources.Job.JobState) Job(org.gridlab.gat.resources.Job) File(org.gridlab.gat.io.File) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) GATInvocationException(org.gridlab.gat.GATInvocationException)

Example 2 with GATInvocationException

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

the class GATCopy method specificCopy.

@Override
public void specificCopy() throws CopyException {
    LOGGER.debug(DBG_PREFIX + "Performing GAT Specific Copy for " + getName());
    // Fetch valid destination URIs
    List<MultiURI> targetURIs = tgtLoc.getURIs();
    List<URI> selectedTargetURIs = new LinkedList<>();
    for (MultiURI uri : targetURIs) {
        try {
            URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
            if (internalURI != null) {
                selectedTargetURIs.add(internalURI);
            }
        } catch (UnstartedNodeException une) {
            throw new GATCopyException(une);
        }
    }
    if (selectedTargetURIs.isEmpty()) {
        LOGGER.error(DBG_PREFIX + ERR_NO_TGT_URI);
        throw new GATCopyException(ERR_NO_TGT_URI);
    }
    LOGGER.debug(DBG_PREFIX + "Selected target URIs");
    // Fetch valid source URIs
    List<MultiURI> sourceURIs;
    List<URI> selectedSourceURIs = new LinkedList<>();
    synchronized (srcData) {
        if (srcLoc != null) {
            sourceURIs = srcLoc.getURIs();
            for (MultiURI uri : sourceURIs) {
                try {
                    URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
                    if (internalURI != null) {
                        selectedSourceURIs.add(internalURI);
                    }
                } catch (UnstartedNodeException une) {
                    LOGGER.error(DBG_PREFIX + "Exception selecting source URI");
                    throw new GATCopyException(une);
                }
            }
        }
        sourceURIs = srcData.getURIs();
        for (MultiURI uri : sourceURIs) {
            try {
                URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
                if (internalURI != null) {
                    selectedSourceURIs.add(internalURI);
                }
            } catch (UnstartedNodeException une) {
                LOGGER.error(DBG_PREFIX + "Exception selecting source URI for " + getName());
                throw new GATCopyException(une);
            }
        }
        if (selectedSourceURIs.isEmpty()) {
            if (srcData.isInMemory()) {
                LOGGER.debug("Data for " + getName() + " is in memory");
                try {
                    srcData.writeToStorage();
                    sourceURIs = srcData.getURIs();
                    for (MultiURI uri : sourceURIs) {
                        URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
                        if (internalURI != null) {
                            selectedSourceURIs.add(internalURI);
                        }
                    }
                } catch (Exception e) {
                    LOGGER.fatal("Exception writing object to file.", e);
                    throw new GATCopyException(ERR_NO_SRC_URI);
                }
            } else {
                LOGGER.error(DBG_PREFIX + ERR_NO_SRC_URI);
                throw new GATCopyException(ERR_NO_SRC_URI);
            }
        }
    }
    GATInvocationException exception = new GATInvocationException("default logical file");
    for (URI src : selectedSourceURIs) {
        for (URI tgt : selectedTargetURIs) {
            try {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("GATCopy From: " + src + " to " + tgt);
                }
                // Source and target URIs contain Runtime information (schema)
                // Convert it to GAT format
                URI gatSrc = new URI(DataLocation.Protocol.ANY_URI.getSchema() + src.getHost() + "/" + src.getPath());
                URI gatTgt = new URI(DataLocation.Protocol.ANY_URI.getSchema() + tgt.getHost() + "/" + tgt.getPath());
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("GATCopy From: " + gatSrc + " to " + gatTgt);
                }
                doCopy(gatSrc, gatTgt);
            // Try to copy from each location until successful
            } catch (Exception e) {
                exception.add("default logical file", e);
                LOGGER.warn("Error copying file", e);
                continue;
            }
            return;
        }
    }
    if (!(this.reason instanceof WorkersDebugInfoCopyTransferable)) {
        ErrorManager.error("File '" + srcData.getName() + "' could not be copied because it does not exist.", exception);
    }
    throw new GATCopyException(exception);
}
Also used : MultiURI(es.bsc.compss.types.uri.MultiURI) GATInvocationException(org.gridlab.gat.GATInvocationException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) GATCopyException(es.bsc.compss.gat.master.exceptions.GATCopyException) WorkersDebugInfoCopyTransferable(es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable) URI(org.gridlab.gat.URI) MultiURI(es.bsc.compss.types.uri.MultiURI) LinkedList(java.util.LinkedList) GATInvocationException(org.gridlab.gat.GATInvocationException) CopyException(es.bsc.compss.exceptions.CopyException) GATCopyException(es.bsc.compss.gat.master.exceptions.GATCopyException) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Example 3 with GATInvocationException

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

the class GATCopy method doCopy.

private void doCopy(org.gridlab.gat.URI src, org.gridlab.gat.URI dest) throws GATCopyException {
    // Try to copy from each location until successful
    FileInterface f = null;
    LOGGER.debug("RawPath: " + src.getRawPath());
    LOGGER.debug("isLocal: " + src.isLocal());
    if (src.isLocal() && !(new File(src.getRawPath())).exists()) {
        String errorMessage = null;
        if (this.reason instanceof WorkersDebugInfoCopyTransferable) {
            // Only warn, hide error to ErrorManager
            errorMessage = "Workers Debug Information not supported in GAT Adaptor";
            LOGGER.warn(errorMessage);
        } else {
            // Notify error to ErrorManager
            errorMessage = "File '" + src.toString() + "' could not be copied to '" + dest.toString() + "' because it does not exist.";
            ErrorManager.warn(errorMessage);
            LOGGER.warn(errorMessage);
        }
        throw new GATCopyException(errorMessage);
    }
    try {
        f = org.gridlab.gat.GAT.createFile(GATAdaptor.getTransferContext(), src).getFileInterface();
        f.copy(dest);
    } catch (GATObjectCreationException | GATInvocationException e) {
        throw new GATCopyException(e);
    }
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) WorkersDebugInfoCopyTransferable(es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable) GATCopyException(es.bsc.compss.gat.master.exceptions.GATCopyException) File(java.io.File)

Example 4 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.FileFilter)
     */
public org.gridlab.gat.io.File[] listFiles(FileFilter 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 5 with GATInvocationException

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

the class LoadLevelerFileAdaptor 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("LoadLevelerFile", 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("LoadLevelerFile", e);
    } finally {
        if (outBuf != null) {
            try {
                outBuf.close();
            } catch (IOException e) {
                throw new GATInvocationException("LoadLevelerFile", e);
            }
        }
        if (inBuf != null) {
            try {
                inBuf.close();
            } catch (IOException e) {
                throw new GATInvocationException("LoadLevelerFile", e);
            }
        }
    }
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

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