Search in sources :

Example 11 with LogicalData

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

the class Resource method getData.

/**
 * Retrieves a given data
 *
 * @param dataId
 * @param tgtDataId
 * @param reason
 * @param listener
 */
public void getData(String dataId, String tgtDataId, Transferable reason, EventListener listener) {
    LogicalData srcData = Comm.getData(dataId);
    LogicalData tgtData = null;
    if (tgtDataId != null) {
        tgtData = Comm.getData(tgtDataId);
    }
    getData(srcData, dataId, tgtData, reason, listener);
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData)

Example 12 with LogicalData

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

the class Resource method getTracingPackageToMaster.

private void getTracingPackageToMaster() {
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    Semaphore sem = new Semaphore(0);
    String fileName = getName() + "_compss_trace.tar.gz";
    SimpleURI fileOriginURI = node.getCompletePath(DataType.FILE_T, fileName);
    if (DEBUG) {
        LOGGER.debug("Copying tracing package from : " + fileOriginURI.getPath() + ",to : " + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName);
    }
    TracingCopyListener tracingListener = new TracingCopyListener(sem);
    tracingListener.addOperation();
    // Source data location
    DataLocation source;
    try {
        source = DataLocation.createLocation(this, fileOriginURI);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + fileOriginURI.getPath(), e);
        return;
    }
    // Target data location
    DataLocation tgt;
    String targetPath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        tgt = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath);
        return;
    }
    // Ask for data
    masterNode.obtainData(new LogicalData("tracing" + this.getName()), source, tgt, new LogicalData("tracing" + this.getName()), new TracingCopyTransferable(), tracingListener);
    tracingListener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for tracing files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Removing " + this.getName() + " tracing temporary files");
    }
    File f = null;
    try {
        f = new File(source.getPath());
        if (!f.delete()) {
            LOGGER.error("Unable to remove tracing temporary files of node " + this.getName());
        }
    } catch (Exception e) {
        LOGGER.error("Unable to remove tracing temporary files of node " + this.getName(), e);
    }
}
Also used : TracingCopyTransferable(es.bsc.compss.types.data.transferable.TracingCopyTransferable) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) TracingCopyListener(es.bsc.compss.types.data.listener.TracingCopyListener) File(java.io.File) COMPSsNode(es.bsc.compss.types.COMPSsNode) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Example 13 with LogicalData

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

the class Resource method retrieveData.

/**
 * Retrieves all the data from the Resource
 *
 * @param saveUniqueData
 */
public void retrieveData(boolean saveUniqueData) {
    if (DEBUG) {
        LOGGER.debug("Retrieving data resource " + this.getName());
    }
    Semaphore sem = new Semaphore(0);
    SafeCopyListener listener = new SafeCopyListener(sem);
    Set<LogicalData> lds = getAllDataFromHost();
    Map<String, String> disks = SharedDiskManager.terminate(this);
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    for (LogicalData ld : lds) {
        ld.notifyToInProgressCopiesEnd(listener);
        DataLocation lastLoc = ld.removeHostAndCheckLocationToSave(this, disks);
        if (lastLoc != null && saveUniqueData) {
            listener.addOperation();
            DataLocation safeLoc = null;
            String safePath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + ld.getName();
            try {
                SimpleURI uri = new SimpleURI(safePath);
                safeLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
            } catch (Exception e) {
                ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + safePath, e);
            }
            masterNode.obtainData(ld, lastLoc, safeLoc, ld, new SafeCopyTransferable(), listener);
        }
    }
    if (DEBUG) {
        LOGGER.debug("Waiting for finishing saving copies for " + this.getName());
    }
    listener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Unique files saved for " + this.getName());
    }
    if (this.getType() != Type.SERVICE) {
        shutdownExecutionManager();
        if (Tracer.isActivated()) {
            if (node.generatePackage()) {
                getTracingPackageToMaster();
                if (DEBUG) {
                    LOGGER.debug("Tracing package obtained for " + this.getName());
                }
            }
        }
        if (DEBUG) {
            if (node.generateWorkersDebugInfo()) {
                getWorkersDebugInfo();
                LOGGER.debug("Workers Debug files obtained for " + this.getName());
            }
        }
    }
}
Also used : SafeCopyListener(es.bsc.compss.types.data.listener.SafeCopyListener) LogicalData(es.bsc.compss.types.data.LogicalData) SafeCopyTransferable(es.bsc.compss.types.data.transferable.SafeCopyTransferable) SimpleURI(es.bsc.compss.types.uri.SimpleURI) 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)

Example 14 with LogicalData

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

the class GATJob method prepareJob.

private JobDescription prepareJob() throws Exception {
    // Get the information related to the job
    logger.debug("Preparing GAT Job " + this.jobId);
    TaskDescription taskParams = this.taskParams;
    String targetPath = getResourceNode().getInstallDir();
    String targetHost = getResourceNode().getHost();
    String targetUser = getResourceNode().getUser();
    if (userNeeded && !targetUser.isEmpty()) {
        targetUser += "@";
    } else {
        targetUser = "";
    }
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable(targetPath + WORKER_SCRIPT_PATH + WORKER_SCRIPT_NAME);
    ArrayList<String> lArgs = new ArrayList<String>();
    // Common arguments: language working_dir lib_path num_obsolete [obs1... obsN] tracing [event_type task_id
    // slot_id]
    lArgs.add(LANG);
    lArgs.add(getResourceNode().getWorkingDir());
    lArgs.add(getResourceNode().getLibPath());
    LogicalData[] obsoleteFiles = getResource().pollObsoletes();
    if (obsoleteFiles != null) {
        lArgs.add("" + obsoleteFiles.length);
        for (LogicalData ld : obsoleteFiles) {
            String renaming = ld.getName();
            lArgs.add(renaming);
        }
    } else {
        lArgs.add("0");
    }
    // Check sandbox working dir
    boolean isSpecific = false;
    String sandboxDir = null;
    AbstractMethodImplementation absImpl = (AbstractMethodImplementation) this.impl;
    switch(absImpl.getMethodType()) {
        case BINARY:
            BinaryImplementation binaryImpl = (BinaryImplementation) absImpl;
            sandboxDir = binaryImpl.getWorkingDir();
            isSpecific = true;
            break;
        case MPI:
            MPIImplementation mpiImpl = (MPIImplementation) absImpl;
            sandboxDir = mpiImpl.getWorkingDir();
            isSpecific = true;
            break;
        case DECAF:
            DecafImplementation decafImpl = (DecafImplementation) absImpl;
            sandboxDir = decafImpl.getWorkingDir();
            isSpecific = true;
            break;
        case OMPSS:
            OmpSsImplementation ompssImpl = (OmpSsImplementation) absImpl;
            sandboxDir = ompssImpl.getWorkingDir();
            isSpecific = true;
            break;
        case OPENCL:
            OpenCLImplementation openclImpl = (OpenCLImplementation) absImpl;
            sandboxDir = openclImpl.getWorkingDir();
            isSpecific = true;
            break;
        case METHOD:
            sandboxDir = null;
            break;
    }
    if (sandboxDir == null || sandboxDir.isEmpty() || sandboxDir.equals(Constants.UNASSIGNED)) {
        sandboxDir = getResourceNode().getWorkingDir() + File.separator + "sandBox" + File.separator + "job_" + this.jobId;
        isSpecific = false;
    }
    // Processing parameters to get symlinks pairs to create (symlinks) and how to pass parameters in the GAT
    // Job(paramArgs)
    ArrayList<String> symlinks = new ArrayList<>();
    ArrayList<String> paramArgs = new ArrayList<>();
    processParameters(sandboxDir, symlinks, paramArgs);
    // Adding info to create symlinks between renamed files and original names
    lArgs.add(Boolean.toString(isSpecific));
    lArgs.add(sandboxDir);
    if (symlinks.size() > 0) {
        lArgs.add(String.valueOf(symlinks.size()));
        lArgs.addAll(symlinks);
    } else {
        lArgs.add("0");
    }
    lArgs.add(Boolean.toString(Tracer.isActivated()));
    lArgs.add(getHostName());
    if (debug) {
        logger.debug("hostName " + getHostName());
    }
    if (Tracer.isActivated()) {
        // event type
        lArgs.add(String.valueOf(Tracer.getTaskEventsType()));
        // task id
        lArgs.add(String.valueOf(this.taskParams.getId() + 1));
        int slot = Tracer.getNextSlot(targetHost);
        // slot id
        lArgs.add(String.valueOf(slot));
        sd.addAttribute("slot", slot);
    }
    // Language-dependent arguments: taskSandbox_dir app_dir classpath pythonpath debug storage_conf
    // method_impl_type method_impl_params
    // numSlaves [slave1,..,slaveN] numCus
    // has_target num_params par_type_1 par_1 ... par_type_n par_n
    lArgs.add(sandboxDir);
    lArgs.add(getResourceNode().getAppDir());
    lArgs.add(getClasspath());
    lArgs.add(getPythonpath());
    lArgs.add(String.valueOf(debug));
    lArgs.add(STORAGE_CONF);
    lArgs.add(String.valueOf(absImpl.getMethodType()));
    switch(absImpl.getMethodType()) {
        case METHOD:
            MethodImplementation methodImpl = (MethodImplementation) absImpl;
            lArgs.add(methodImpl.getDeclaringClass());
            String methodName = methodImpl.getAlternativeMethodName();
            if (methodName == null || methodName.isEmpty()) {
                methodName = taskParams.getName();
            }
            lArgs.add(methodName);
            break;
        case MPI:
            MPIImplementation mpiImpl = (MPIImplementation) absImpl;
            lArgs.add(mpiImpl.getMpiRunner());
            lArgs.add(mpiImpl.getBinary());
            break;
        case DECAF:
            DecafImplementation decafImpl = (DecafImplementation) absImpl;
            lArgs.add(targetPath + DecafImplementation.SCRIPT_PATH);
            String dfScript = decafImpl.getDfScript();
            if (!dfScript.startsWith(File.separator)) {
                String appPath = getResourceNode().getAppDir();
                dfScript = appPath + File.separator + dfScript;
            }
            lArgs.add(dfScript);
            String dfExecutor = decafImpl.getDfExecutor();
            if (dfExecutor == null || dfExecutor.isEmpty() || dfExecutor.equals(Constants.UNASSIGNED)) {
                dfExecutor = "executor.sh";
            }
            if (!dfExecutor.startsWith(File.separator) && !dfExecutor.startsWith("./")) {
                dfExecutor = "./" + dfExecutor;
            }
            lArgs.add(dfExecutor);
            String dfLib = decafImpl.getDfLib();
            if (dfLib == null || dfLib.isEmpty()) {
                dfLib = Constants.UNASSIGNED;
            }
            lArgs.add(dfLib);
            lArgs.add(decafImpl.getMpiRunner());
            break;
        case OMPSS:
            OmpSsImplementation ompssImpl = (OmpSsImplementation) absImpl;
            lArgs.add(ompssImpl.getBinary());
            break;
        case OPENCL:
            OpenCLImplementation openclImpl = (OpenCLImplementation) absImpl;
            lArgs.add(openclImpl.getKernel());
            break;
        case BINARY:
            BinaryImplementation binaryImpl = (BinaryImplementation) absImpl;
            lArgs.add(binaryImpl.getBinary());
            break;
    }
    // Slave nodes and cus description
    lArgs.add(String.valueOf(slaveWorkersNodeNames.size()));
    lArgs.addAll(slaveWorkersNodeNames);
    lArgs.add(String.valueOf(((MethodResourceDescription) this.impl.getRequirements()).getTotalCPUComputingUnits()));
    // Add parameter arguments already processed
    lArgs.addAll(paramArgs);
    // Conversion vector -> array
    String[] arguments = new String[lArgs.size()];
    arguments = lArgs.toArray(arguments);
    try {
        sd.setArguments(arguments);
    } catch (NullPointerException e) {
        StringBuilder sb = new StringBuilder("Null argument parameter of job " + this.jobId + " " + absImpl.getMethodDefinition() + "\n");
        int i = 0;
        for (Parameter param : taskParams.getParameters()) {
            sb.append("Parameter ").append(i).append("\n");
            DataType type = param.getType();
            sb.append("\t Type: ").append(param.getType()).append("\n");
            if (type == DataType.FILE_T || type == DataType.OBJECT_T) {
                DependencyParameter dPar = (DependencyParameter) param;
                DataAccessId dAccId = dPar.getDataAccessId();
                sb.append("\t Target: ").append(dPar.getDataTarget()).append("\n");
                if (type == DataType.OBJECT_T) {
                    if (dAccId instanceof RAccessId) {
                        sb.append("\t Direction: " + "R").append("\n");
                    } else {
                        // for the worker to know it must write the object to disk
                        sb.append("\t Direction: " + "W").append("\n");
                    }
                }
            } else if (type == DataType.STRING_T) {
                BasicTypeParameter btParS = (BasicTypeParameter) param;
                // Check spaces
                String value = btParS.getValue().toString();
                int numSubStrings = value.split(" ").length;
                sb.append("\t Num Substrings: " + Integer.toString(numSubStrings)).append("\n");
                sb.append("\t Value:" + value).append("\n");
            } else {
                // Basic types
                BasicTypeParameter btParB = (BasicTypeParameter) param;
                sb.append("\t Value: " + btParB.getValue().toString()).append("\n");
            }
            i++;
        }
        logger.error(sb.toString());
        listener.jobFailed(this, JobEndStatus.SUBMISSION_FAILED);
    }
    sd.addAttribute("jobId", jobId);
    // JEA Changed to allow execution in MN
    sd.addAttribute(SoftwareDescription.WALLTIME_MAX, absImpl.getRequirements().getWallClockLimit());
    if (absImpl.getRequirements().getHostQueues().size() > 0) {
        sd.addAttribute(SoftwareDescription.JOB_QUEUE, absImpl.getRequirements().getHostQueues().get(0));
    }
    sd.addAttribute("coreCount", absImpl.getRequirements().getTotalCPUComputingUnits());
    sd.addAttribute("gpuCount", absImpl.getRequirements().getTotalGPUComputingUnits());
    sd.addAttribute("fpgaCount", absImpl.getRequirements().getTotalFPGAComputingUnits());
    sd.addAttribute(SoftwareDescription.MEMORY_MAX, absImpl.getRequirements().getMemorySize());
    // sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, "/tmp/");
    sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, getResourceNode().getWorkingDir());
    sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
    sd.addAttribute(SoftwareDescription.SANDBOX_DELETE, "false");
    /*
         * sd.addAttribute(SoftwareDescription.SANDBOX_PRESTAGE_STDIN, "false");
         * sd.addAttribute(SoftwareDescription.SANDBOX_POSTSTAGE_STDOUT, "false");
         * sd.addAttribute(SoftwareDescription.SANDBOX_POSTSTAGE_STDERR, "false");
         */
    if (debug) {
        // Set standard output file for job
        File outFile = GAT.createFile(context, Protocol.ANY_URI.getSchema() + File.separator + JOBS_DIR + "job" + jobId + "_" + this.getHistory() + ".out");
        sd.setStdout(outFile);
    }
    if (debug || usingGlobus) {
        // Set standard error file for job
        File errFile = GAT.createFile(context, Protocol.ANY_URI.getSchema() + File.separator + JOBS_DIR + "job" + jobId + "_" + this.getHistory() + ".err");
        sd.setStderr(errFile);
    }
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(RES_ATTR, Protocol.ANY_URI.getSchema() + targetUser + targetHost);
    attributes.put("Jobname", "compss_remote_job_" + jobId);
    ResourceDescription rd = new HardwareResourceDescription(attributes);
    if (debug) {
        logger.debug("Ready to submit job " + jobId + ":");
        logger.debug("  * Host: " + targetHost);
        logger.debug("  * Executable: " + sd.getExecutable());
        StringBuilder sb = new StringBuilder("  - Arguments:");
        for (String arg : sd.getArguments()) {
            sb.append(" ").append(arg);
        }
        logger.debug(sb.toString());
    }
    JobDescription jd = new JobDescription(sd, rd);
    // jd.setProcessCount(method.getRequirements().getProcessorCoreCount());
    return jd;
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) AbstractMethodImplementation(es.bsc.compss.types.implementations.AbstractMethodImplementation) MPIImplementation(es.bsc.compss.types.implementations.MPIImplementation) RAccessId(es.bsc.compss.types.data.DataAccessId.RAccessId) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) BasicTypeParameter(es.bsc.compss.types.parameter.BasicTypeParameter) OpenCLImplementation(es.bsc.compss.types.implementations.OpenCLImplementation) JobDescription(org.gridlab.gat.resources.JobDescription) TaskDescription(es.bsc.compss.types.TaskDescription) DecafImplementation(es.bsc.compss.types.implementations.DecafImplementation) DataType(es.bsc.compss.types.annotations.parameter.DataType) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) BinaryImplementation(es.bsc.compss.types.implementations.BinaryImplementation) AbstractMethodImplementation(es.bsc.compss.types.implementations.AbstractMethodImplementation) HardwareResourceDescription(org.gridlab.gat.resources.HardwareResourceDescription) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) LogicalData(es.bsc.compss.types.data.LogicalData) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) HardwareResourceDescription(org.gridlab.gat.resources.HardwareResourceDescription) ResourceDescription(org.gridlab.gat.resources.ResourceDescription) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) BasicTypeParameter(es.bsc.compss.types.parameter.BasicTypeParameter) File(org.gridlab.gat.io.File) OmpSsImplementation(es.bsc.compss.types.implementations.OmpSsImplementation) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Example 15 with LogicalData

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

the class NIOWorkerNode method newVersion.

private void newVersion(StorageCopy sc) {
    String targetHostname = this.getName();
    LogicalData srcLD = sc.getSourceData();
    LogicalData targetLD = sc.getTargetData();
    boolean preserveSource = sc.mustPreserveSourceData();
    if (DEBUG) {
        LOGGER.debug("Ask for new Version of " + srcLD.getName() + " with id " + srcLD.getId() + " to " + targetHostname + " with must preserve " + preserveSource);
    }
    // Get the PSCOId to replicate
    String pscoId = srcLD.getId();
    // Perform version
    LOGGER.debug("Performing new version for PSCO " + pscoId);
    if (NIOTracer.isActivated()) {
        NIOTracer.emitEvent(NIOTracer.Event.STORAGE_NEWVERSION.getId(), NIOTracer.Event.STORAGE_NEWVERSION.getType());
    }
    try {
        String newId = StorageItf.newVersion(pscoId, preserveSource, Comm.getAppHost().getName());
        LOGGER.debug("Register new new version of " + pscoId + " as " + newId);
        sc.setFinalTarget(newId);
        if (targetLD != null) {
            targetLD.setId(newId);
        }
    } catch (Exception e) {
        sc.end(OpEndState.OP_FAILED, e);
        return;
    } finally {
        if (NIOTracer.isActivated()) {
            NIOTracer.emitEvent(NIOTracer.EVENT_END, NIOTracer.Event.STORAGE_NEWVERSION.getType());
        }
    }
    // Notify successful end
    sc.end(OpEndState.OP_OK);
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) StorageException(storage.StorageException) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Aggregations

LogicalData (es.bsc.compss.types.data.LogicalData)27 DataLocation (es.bsc.compss.types.data.location.DataLocation)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 SimpleURI (es.bsc.compss.types.uri.SimpleURI)6 MultiURI (es.bsc.compss.types.uri.MultiURI)5 Semaphore (java.util.concurrent.Semaphore)5 InitNodeException (es.bsc.compss.exceptions.InitNodeException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)3 Copy (es.bsc.compss.types.data.operation.copy.Copy)3 Resource (es.bsc.compss.types.resources.Resource)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 Data (es.bsc.compss.nio.commands.Data)2 DataRequest (es.bsc.compss.nio.dataRequest.DataRequest)2 MasterDataRequest (es.bsc.compss.nio.dataRequest.MasterDataRequest)2 DataAccessId (es.bsc.compss.types.data.DataAccessId)2 TracingCopyListener (es.bsc.compss.types.data.listener.TracingCopyListener)2 TracingCopyTransferable (es.bsc.compss.types.data.transferable.TracingCopyTransferable)2 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)2 Parameter (es.bsc.compss.types.parameter.Parameter)2