Search in sources :

Example 1 with WorkersDebugInfoCopyTransferable

use of es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable 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 2 with WorkersDebugInfoCopyTransferable

use of es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable 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 3 with WorkersDebugInfoCopyTransferable

use of es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable in project compss by bsc-wdc.

the class Resource method getWorkersDebugInfo.

private void getWorkersDebugInfo() {
    if (DEBUG) {
        LOGGER.debug("Copying Workers Information");
    }
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    Semaphore sem = new Semaphore(0);
    WorkersDebugInformationListener wdil = new WorkersDebugInformationListener(sem);
    // Get Worker output
    wdil.addOperation();
    String outFileName = "worker_" + getName() + ".out";
    SimpleURI outFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + outFileName);
    String outFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + outFileName;
    DataLocation outSource = null;
    try {
        outSource = DataLocation.createLocation(this, outFileOrigin);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileOrigin.toString(), e);
    }
    DataLocation outTarget = null;
    try {
        SimpleURI uri = new SimpleURI(outFileTarget);
        outTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileTarget);
    }
    LOGGER.debug("- Source: " + outFileOrigin);
    LOGGER.debug("- Target: " + outFileTarget);
    masterNode.obtainData(new LogicalData("workerOut" + this.getName()), outSource, outTarget, new LogicalData("workerOut" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
    // Get Worker error
    wdil.addOperation();
    String errFileName = "worker_" + getName() + ".err";
    SimpleURI errFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + errFileName);
    String errFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + errFileName;
    DataLocation errSource = null;
    try {
        errSource = DataLocation.createLocation(this, errFileOrigin);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileOrigin.toString(), e);
    }
    DataLocation errTarget = null;
    try {
        SimpleURI uri = new SimpleURI(errFileTarget);
        errTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileTarget);
    }
    LOGGER.debug("- Source: " + errFileOrigin);
    LOGGER.debug("- Target: " + errFileTarget);
    masterNode.obtainData(new LogicalData("workerErr" + this.getName()), errSource, errTarget, new LogicalData("workerErr" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
    // Wait transfers
    wdil.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for worker debug files in resource " + getName() + " to get saved");
    }
    LOGGER.debug("Worker files from resource " + getName() + "received");
}
Also used : WorkersDebugInformationListener(es.bsc.compss.types.data.listener.WorkersDebugInformationListener) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) WorkersDebugInfoCopyTransferable(es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) COMPSsNode(es.bsc.compss.types.COMPSsNode) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Aggregations

WorkersDebugInfoCopyTransferable (es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable)3 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)2 GATCopyException (es.bsc.compss.gat.master.exceptions.GATCopyException)2 GATInvocationException (org.gridlab.gat.GATInvocationException)2 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)2 CopyException (es.bsc.compss.exceptions.CopyException)1 InitNodeException (es.bsc.compss.exceptions.InitNodeException)1 COMPSsNode (es.bsc.compss.types.COMPSsNode)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 WorkersDebugInformationListener (es.bsc.compss.types.data.listener.WorkersDebugInformationListener)1 DataLocation (es.bsc.compss.types.data.location.DataLocation)1 MultiURI (es.bsc.compss.types.uri.MultiURI)1 SimpleURI (es.bsc.compss.types.uri.SimpleURI)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 Semaphore (java.util.concurrent.Semaphore)1 URI (org.gridlab.gat.URI)1 FileInterface (org.gridlab.gat.io.FileInterface)1