Search in sources :

Example 1 with UnstartedNodeException

use of es.bsc.compss.exceptions.UnstartedNodeException in project compss by bsc-wdc.

the class NIOWorkerNode method stop.

@Override
public void stop(ShutdownListener sl) {
    if (started) {
        LOGGER.debug("Shutting down " + this.getName());
        if (node == null) {
            sl.notifyFailure(new UnstartedNodeException());
            LOGGER.error("Shutdown has failed");
        }
        Connection c = NIOAgent.getTransferManager().startConnection(node);
        commManager.shuttingDown(this, c, sl);
        CommandShutdown cmd = new CommandShutdown(null, null);
        c.sendCommand(cmd);
        c.receive();
        c.finishConnection();
    } else {
        LOGGER.debug("Worker " + this.getName() + " has not started. Setting this to be stopped");
        workerStarter.setToStop();
        sl.notifyEnd();
    }
}
Also used : UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) Connection(es.bsc.comm.Connection) CommandShutdown(es.bsc.compss.nio.commands.CommandShutdown)

Example 2 with UnstartedNodeException

use of es.bsc.compss.exceptions.UnstartedNodeException in project compss by bsc-wdc.

the class NIOWorkerNode method shutdownExecutionManager.

@Override
public void shutdownExecutionManager(ExecutorShutdownListener esl) {
    if (started) {
        LOGGER.debug("Shutting down execution manager " + this.getName());
        if (node == null) {
            esl.notifyFailure(new UnstartedNodeException());
            LOGGER.error("Shutdown execution manager has failed");
        }
        Connection c = NIOAgent.getTransferManager().startConnection(node);
        commManager.shuttingDownEM(this, c, esl);
        CommandExecutorShutdown cmd = new CommandExecutorShutdown(null);
        c.sendCommand(cmd);
        c.receive();
        c.finishConnection();
    } else {
        LOGGER.debug("Worker " + this.getName() + " has not started. Considering execution manager stopped");
        esl.notifyEnd();
    }
}
Also used : CommandExecutorShutdown(es.bsc.compss.nio.commands.CommandExecutorShutdown) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) Connection(es.bsc.comm.Connection)

Example 3 with UnstartedNodeException

use of es.bsc.compss.exceptions.UnstartedNodeException in project compss by bsc-wdc.

the class NIOWorkerNode method sendData.

@Override
public void sendData(LogicalData ld, DataLocation source, DataLocation target, LogicalData tgtData, Transferable reason, EventListener listener) {
    if (target.getHosts().contains(Comm.getAppHost())) {
        // Order petition directly
        if (tgtData != null) {
            MultiURI u = ld.alreadyAvailable(Comm.getAppHost());
            if (u != null) {
                // Already present at the master
                reason.setDataTarget(u.getPath());
                listener.notifyEnd(null);
                return;
            }
        }
        Copy c = new DeferredCopy(ld, null, target, tgtData, reason, listener);
        Data d = new Data(ld);
        if (source != null) {
            for (MultiURI uri : source.getURIs()) {
                try {
                    NIOURI nURI = (NIOURI) uri.getInternalURI(NIOAdaptor.ID);
                    if (nURI != null) {
                        d.getSources().add(nURI);
                    }
                } catch (UnstartedNodeException une) {
                // Ignore internal URI
                }
            }
        }
        String path = target.getURIInHost(Comm.getAppHost()).getPath();
        c.setFinalTarget(path);
        ld.startCopy(c, c.getTargetLoc());
        DataRequest dr = new MasterDataRequest(c, reason.getType(), d, path);
        commManager.addTransferRequest(dr);
        commManager.requestTransfers();
    } else {
        // Request to any other
        orderCopy(new DeferredCopy(ld, source, target, tgtData, reason, listener));
    }
}
Also used : DeferredCopy(es.bsc.compss.types.data.operation.copy.DeferredCopy) MultiURI(es.bsc.compss.types.uri.MultiURI) DeferredCopy(es.bsc.compss.types.data.operation.copy.DeferredCopy) Copy(es.bsc.compss.types.data.operation.copy.Copy) StorageCopy(es.bsc.compss.types.data.operation.copy.StorageCopy) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) LogicalData(es.bsc.compss.types.data.LogicalData) Data(es.bsc.compss.nio.commands.Data) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest) NIOURI(es.bsc.compss.nio.NIOURI)

Example 4 with UnstartedNodeException

use of es.bsc.compss.exceptions.UnstartedNodeException 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 5 with UnstartedNodeException

use of es.bsc.compss.exceptions.UnstartedNodeException in project compss by bsc-wdc.

the class NIOWorkerNode method submitTask.

public void submitTask(NIOJob job, List<String> obsolete) throws UnstartedNodeException {
    if (node == null) {
        throw new UnstartedNodeException();
    }
    NIOTask t = job.prepareJob();
    CommandNewTask cmd = new CommandNewTask(t, obsolete);
    Connection c = NIOAgent.getTransferManager().startConnection(node);
    c.sendCommand(cmd);
    c.finishConnection();
}
Also used : NIOTask(es.bsc.compss.nio.NIOTask) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) Connection(es.bsc.comm.Connection) CommandNewTask(es.bsc.compss.nio.commands.CommandNewTask)

Aggregations

UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)7 Connection (es.bsc.comm.Connection)3 MultiURI (es.bsc.compss.types.uri.MultiURI)3 NIOURI (es.bsc.compss.nio.NIOURI)2 LogicalData (es.bsc.compss.types.data.LogicalData)2 CopyException (es.bsc.compss.exceptions.CopyException)1 GATCopyException (es.bsc.compss.gat.master.exceptions.GATCopyException)1 NIOTask (es.bsc.compss.nio.NIOTask)1 CommandExecutorShutdown (es.bsc.compss.nio.commands.CommandExecutorShutdown)1 CommandNewTask (es.bsc.compss.nio.commands.CommandNewTask)1 CommandShutdown (es.bsc.compss.nio.commands.CommandShutdown)1 Data (es.bsc.compss.nio.commands.Data)1 DataRequest (es.bsc.compss.nio.dataRequest.DataRequest)1 MasterDataRequest (es.bsc.compss.nio.dataRequest.MasterDataRequest)1 Copy (es.bsc.compss.types.data.operation.copy.Copy)1 DeferredCopy (es.bsc.compss.types.data.operation.copy.DeferredCopy)1 StorageCopy (es.bsc.compss.types.data.operation.copy.StorageCopy)1 WorkersDebugInfoCopyTransferable (es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable)1 LinkedList (java.util.LinkedList)1 GATInvocationException (org.gridlab.gat.GATInvocationException)1