Search in sources :

Example 1 with DataType

use of es.bsc.compss.types.annotations.parameter.DataType in project compss by bsc-wdc.

the class NIOJob method addParams.

private LinkedList<NIOParam> addParams() {
    LinkedList<NIOParam> params = new LinkedList<>();
    for (Parameter param : taskParams.getParameters()) {
        DataType type = param.getType();
        NIOParam np;
        switch(type) {
            case FILE_T:
            case OBJECT_T:
            case PSCO_T:
            case EXTERNAL_OBJECT_T:
                DependencyParameter dPar = (DependencyParameter) param;
                DataAccessId dAccId = dPar.getDataAccessId();
                Object value = dPar.getDataTarget();
                boolean preserveSourceData = true;
                if (dAccId instanceof RAccessId) {
                    // Parameter is a R, has sources
                    preserveSourceData = ((RAccessId) dAccId).isPreserveSourceData();
                } else if (dAccId instanceof RWAccessId) {
                    // Parameter is a RW, has sources
                    preserveSourceData = ((RWAccessId) dAccId).isPreserveSourceData();
                } else {
                    // Parameter is a W, it has no sources
                    preserveSourceData = false;
                }
                // Workaround for Python PSCOs in return
                // Check if the parameter has a valid PSCO and change its type
                String renaming;
                DataAccessId faId = dPar.getDataAccessId();
                if (faId instanceof WAccessId) {
                    // Write mode
                    WAccessId waId = (WAccessId) faId;
                    renaming = waId.getWrittenDataInstance().getRenaming();
                } else if (faId instanceof RWAccessId) {
                    // Read write mode
                    RWAccessId rwaId = (RWAccessId) faId;
                    renaming = rwaId.getWrittenDataInstance().getRenaming();
                } else {
                    // Read only mode
                    RAccessId raId = (RAccessId) faId;
                    renaming = raId.getReadDataInstance().getRenaming();
                }
                String pscoId = Comm.getData(renaming).getId();
                if (pscoId != null && type.equals(DataType.FILE_T)) {
                    param.setType(DataType.EXTERNAL_OBJECT_T);
                    type = param.getType();
                }
                // Create the NIO Param
                // Only store W and RW
                boolean writeFinalValue = !(dAccId instanceof RAccessId);
                np = new NIOParam(type, param.getStream(), param.getPrefix(), preserveSourceData, writeFinalValue, value, (Data) dPar.getDataSource(), dPar.getOriginalName());
                break;
            default:
                BasicTypeParameter btParB = (BasicTypeParameter) param;
                value = btParB.getValue();
                // Basic parameters are not preserved on Worker
                preserveSourceData = false;
                // Basic parameters are not stored on Worker
                writeFinalValue = false;
                np = new NIOParam(type, param.getStream(), param.getPrefix(), preserveSourceData, writeFinalValue, value, null, DependencyParameter.NO_NAME);
                break;
        }
        params.add(np);
    }
    return params;
}
Also used : RAccessId(es.bsc.compss.types.data.DataAccessId.RAccessId) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) Data(es.bsc.compss.nio.commands.Data) LinkedList(java.util.LinkedList) BasicTypeParameter(es.bsc.compss.types.parameter.BasicTypeParameter) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) BasicTypeParameter(es.bsc.compss.types.parameter.BasicTypeParameter) DataType(es.bsc.compss.types.annotations.parameter.DataType) WAccessId(es.bsc.compss.types.data.DataAccessId.WAccessId) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) DataAccessId(es.bsc.compss.types.data.DataAccessId) NIOParam(es.bsc.compss.nio.NIOParam)

Example 2 with DataType

use of es.bsc.compss.types.annotations.parameter.DataType in project compss by bsc-wdc.

the class TaskResultReader method processEndTaskTag.

private void processEndTaskTag(String[] line) {
    if (line.length < 3) {
        LOGGER.warn("WARN: Skipping endTask line because is malformed");
        return;
    }
    // Line of the form: "endTask" ID STATUS D paramType1 paramValue1 ... paramTypeD paramValueD
    Integer jobId = Integer.parseInt(line[1]);
    Integer exitValue = Integer.parseInt(line[2]);
    ExternalTaskStatus taskStatus = new ExternalTaskStatus(exitValue);
    // Process parameters if message contains them
    if (line.length > 3) {
        int numParams = Integer.parseInt(line[3]);
        if (4 + 2 * numParams != line.length) {
            LOGGER.warn("WARN: Skipping endTask parameters because of malformation.");
        } else {
            // Process parameters
            for (int i = 0; i < numParams; ++i) {
                int paramTypeOrdinalIndex = 0;
                try {
                    paramTypeOrdinalIndex = Integer.parseInt(line[4 + 2 * i]);
                } catch (NumberFormatException nfe) {
                    LOGGER.warn("WARN: Number format exception on " + line[4 + 2 * i] + ". Setting type 0", nfe);
                }
                DataType paramType = DataType.values()[paramTypeOrdinalIndex];
                String paramValue = line[5 + 2 * i];
                if (paramValue.equalsIgnoreCase("null")) {
                    paramValue = null;
                }
                taskStatus.addParameter(paramType, paramValue);
            }
        }
    } else {
        LOGGER.warn("WARN: endTask message does not have task result parameters");
    }
    // Add the task status to the set
    synchronized (jobIdsToStatus) {
        jobIdsToStatus.put(jobId, taskStatus);
    }
    // Optimization: Check directly if waiter has already registered
    LOGGER.debug("Read job " + jobId + " with status " + taskStatus);
    synchronized (jobIdsToWaiters) {
        Semaphore waiter = jobIdsToWaiters.get(jobId);
        if (waiter != null) {
            // Release waiter and clean structure
            waiter.release();
            jobIdsToWaiters.remove(jobId);
        }
    }
}
Also used : DataType(es.bsc.compss.types.annotations.parameter.DataType) Semaphore(java.util.concurrent.Semaphore)

Example 3 with DataType

use of es.bsc.compss.types.annotations.parameter.DataType in project compss by bsc-wdc.

the class ExternalTaskStatus method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("ExternalTaskStatus [ ");
    sb.append("ExitValue = ").append(this.exitValue).append(", ");
    sb.append("NumParameters = ").append(getNumParameters()).append(", ");
    sb.append("ParameterTypes = [");
    for (DataType type : this.updatedParameterTypes) {
        sb.append(type.ordinal()).append(" ");
    }
    sb.append("], ");
    sb.append("ParameterValues = [");
    for (String value : this.updatedParameterValues) {
        sb.append(value).append(" ");
    }
    sb.append("]");
    sb.append(" ]");
    return sb.toString();
}
Also used : DataType(es.bsc.compss.types.annotations.parameter.DataType)

Example 4 with DataType

use of es.bsc.compss.types.annotations.parameter.DataType in project compss by bsc-wdc.

the class AbstractMethodImplementation method getSignature.

public static String getSignature(String declaringClass, String methodName, boolean hasTarget, boolean hasReturn, Parameter[] parameters) {
    StringBuilder buffer = new StringBuilder();
    buffer.append(methodName).append("(");
    switch(LANG) {
        case JAVA:
        case C:
            int numPars = parameters.length;
            if (hasTarget) {
                numPars--;
            }
            if (hasReturn) {
                numPars--;
            }
            if (numPars > 0) {
                DataType type = parameters[0].getType();
                type = (type == DataType.PSCO_T) ? DataType.OBJECT_T : type;
                buffer.append(type);
                for (int i = 1; i < numPars; i++) {
                    type = parameters[i].getType();
                    type = (type == DataType.PSCO_T) ? DataType.OBJECT_T : type;
                    buffer.append(",").append(type);
                }
            }
            break;
        case PYTHON:
            // There is no function overloading in Python
            break;
    }
    buffer.append(")").append(declaringClass);
    return buffer.toString();
}
Also used : DataType(es.bsc.compss.types.annotations.parameter.DataType)

Example 5 with DataType

use of es.bsc.compss.types.annotations.parameter.DataType in project compss by bsc-wdc.

the class TaskAnalyser method endTask.

/**
 * Registers the end of execution of task @task
 *
 * @param task
 */
public void endTask(Task task) {
    int taskId = task.getId();
    boolean isFree = task.isFree();
    TaskState taskState = task.getStatus();
    LOGGER.info("Notification received for task " + taskId + " with end status " + taskState);
    // Check status
    if (!isFree) {
        LOGGER.debug("Task " + taskId + " is not registered as free. Waiting for other executions to end");
        return;
    }
    if (taskState == TaskState.FAILED) {
        ErrorManager.error(TASK_FAILED + task);
        return;
    }
    /*
         * Treat end of task
         */
    LOGGER.debug("Ending task " + taskId);
    // Free dependencies
    Long appId = task.getAppId();
    Integer taskCount = appIdToTaskCount.get(appId) - 1;
    appIdToTaskCount.put(appId, taskCount);
    if (taskCount == 0) {
        // Remove the appId from the barrier flags (if existant, otherwise do nothing)
        appIdBarrierFlags.remove(appId);
        Semaphore sem = appIdToSemaphore.remove(appId);
        if (sem != null) {
            // App was synchornized on a barrier flag or a no more tasks
            // Release the application semaphore
            appIdToTaskCount.remove(appId);
            sem.release();
        }
    }
    // Check if task is being waited
    List<Semaphore> sems = waitedTasks.remove(task);
    if (sems != null) {
        for (Semaphore sem : sems) {
            sem.release();
        }
    }
    for (Parameter param : task.getTaskDescription().getParameters()) {
        DataType type = param.getType();
        if (type == DataType.FILE_T || type == DataType.OBJECT_T || type == DataType.PSCO_T || type == DataType.EXTERNAL_OBJECT_T) {
            DependencyParameter dPar = (DependencyParameter) param;
            DataAccessId dAccId = dPar.getDataAccessId();
            LOGGER.debug("Treating that data " + dAccId + " has been accessed at " + dPar.getDataTarget());
            DIP.dataHasBeenAccessed(dAccId);
        }
    }
    // Task generation is finished if we are on noMoreTasks but we are not on a barrier
    if (appIdToSemaphore.get(appId) != null && !appIdBarrierFlags.contains(appId)) {
        checkResultFileTransfer(task);
    }
    // Release data dependent tasks
    task.releaseDataDependents();
}
Also used : ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) DataType(es.bsc.compss.types.annotations.parameter.DataType) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) Semaphore(java.util.concurrent.Semaphore) TaskState(es.bsc.compss.types.Task.TaskState) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Aggregations

DataType (es.bsc.compss.types.annotations.parameter.DataType)14 Parameter (es.bsc.compss.types.parameter.Parameter)6 BasicTypeParameter (es.bsc.compss.types.parameter.BasicTypeParameter)5 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)5 DataAccessId (es.bsc.compss.types.data.DataAccessId)4 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)3 ExternalObjectParameter (es.bsc.compss.types.parameter.ExternalObjectParameter)3 FileParameter (es.bsc.compss.types.parameter.FileParameter)3 ObjectParameter (es.bsc.compss.types.parameter.ObjectParameter)3 Semaphore (java.util.concurrent.Semaphore)3 NIOParam (es.bsc.compss.nio.NIOParam)2 JobExecutionException (es.bsc.compss.nio.exceptions.JobExecutionException)2 Stream (es.bsc.compss.types.annotations.parameter.Stream)2 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)2 File (java.io.File)2 File (org.gridlab.gat.io.File)2 Data (es.bsc.compss.nio.commands.Data)1 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 ExternalTaskStatus (es.bsc.compss.nio.worker.util.ExternalTaskStatus)1 TaskState (es.bsc.compss.types.Task.TaskState)1