Search in sources :

Example 1 with StubItf

use of storage.StubItf in project compss by bsc-wdc.

the class Comm method registerValue.

/**
 * Registers a new value @value for the data with id @dataId dataId must exist
 *
 * @param dataId
 * @param value
 * @return
 */
public static synchronized LogicalData registerValue(String dataId, Object value) {
    LOGGER.debug("Register value " + value + " for data " + dataId);
    String targetPath = Protocol.OBJECT_URI.getSchema() + dataId;
    DataLocation location = null;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        location = DataLocation.createLocation(appHost, uri);
    } catch (IOException e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
    }
    LogicalData logicalData = data.get(dataId);
    logicalData.addLocation(location);
    logicalData.setValue(value);
    // Register PSCO Location if needed it's PSCO and it's persisted
    if (value instanceof StubItf) {
        String id = ((StubItf) value).getID();
        if (id != null) {
            Comm.registerPSCO(dataId, id);
        }
    }
    return logicalData;
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) StubItf(storage.StubItf) DataLocation(es.bsc.compss.types.data.location.DataLocation) IOException(java.io.IOException)

Example 2 with StubItf

use of storage.StubItf in project compss by bsc-wdc.

the class Invoker method checkSCOPersistence.

private void checkSCOPersistence() {
    // Check all parameters and target
    for (int i = 0; i < this.numParams; i++) {
        if (this.canBePSCO[i] && this.writeFinalValue[i]) {
            // Get information as target or as normal parameter
            Object obj = null;
            if (this.hasTarget && i == this.numParams - 1) {
                obj = this.target.getValue();
            } else {
                obj = this.values[i];
            }
            // Check if it is a PSCO and has been persisted in task
            String id = null;
            try {
                StubItf psco = (StubItf) obj;
                id = psco.getID();
            } catch (Exception e) {
                // No need to raise an exception because normal objects are not PSCOs
                id = null;
            }
            // Update to PSCO if needed
            if (id != null) {
                // Object has been persisted, we store the PSCO and change the value to its ID
                this.nw.storePersistentObject(id, obj);
                if (this.hasTarget && i == this.numParams - 1) {
                    this.target.setValue(id);
                } else {
                    this.values[i] = id;
                }
                this.nt.getParams().get(i).setType(DataType.PSCO_T);
                this.nt.getParams().get(i).setValue(id);
                // We set it as non writable because we have already stored it
                this.writeFinalValue[i] = false;
            }
        }
    }
    // Check return
    if (this.hasReturn && this.retValue != null) {
        // Check if it is a PSCO and has been persisted in task
        String id = null;
        try {
            StubItf psco = (StubItf) this.retValue;
            id = psco.getID();
        } catch (Exception e) {
            // No need to raise an exception because normal objects are not PSCOs
            id = null;
        }
        // Update to PSCO if needed
        if (id != null) {
            // Object has been persisted
            this.nt.getParams().getLast().setType(DataType.PSCO_T);
            this.nt.getParams().getLast().setValue(id);
        }
    }
}
Also used : StubItf(storage.StubItf) JobExecutionException(es.bsc.compss.nio.exceptions.JobExecutionException) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) StorageException(storage.StorageException) IOException(java.io.IOException)

Example 3 with StubItf

use of storage.StubItf in project compss by bsc-wdc.

the class TaskAnalyser method processTask.

/**
 * Process the dependencies of a new task @currentTask
 *
 * @param currentTask
 */
public void processTask(Task currentTask) {
    TaskDescription params = currentTask.getTaskDescription();
    LOGGER.info("New " + (params.getType() == TaskType.METHOD ? "method" : "service") + " task(" + params.getName() + "), ID = " + currentTask.getId());
    if (drawGraph) {
        addNewTask(currentTask);
    }
    // Update task count
    Integer methodId = params.getId();
    Integer actualCount = currentTaskCount.get(methodId);
    if (actualCount == null) {
        actualCount = 0;
    }
    currentTaskCount.put(methodId, actualCount + 1);
    // Update app id task count
    Long appId = currentTask.getAppId();
    Integer taskCount = appIdToTaskCount.get(appId);
    if (taskCount == null) {
        taskCount = 0;
    }
    taskCount++;
    appIdToTaskCount.put(appId, taskCount);
    Integer totalTaskCount = appIdToTotalTaskCount.get(appId);
    if (totalTaskCount == null) {
        totalTaskCount = 0;
    }
    totalTaskCount++;
    appIdToTotalTaskCount.put(appId, totalTaskCount);
    // Check scheduling enforcing data
    int constrainingParam = -1;
    if (params.getType() == TaskType.SERVICE && params.hasTargetObject()) {
        if (params.hasReturnValue()) {
            constrainingParam = params.getParameters().length - 2;
        } else {
            constrainingParam = params.getParameters().length - 1;
        }
    }
    Parameter[] parameters = params.getParameters();
    for (int paramIdx = 0; paramIdx < parameters.length; paramIdx++) {
        Parameter p = parameters[paramIdx];
        if (DEBUG) {
            LOGGER.debug("* Parameter : " + p);
        }
        // Conversion: direction -> access mode
        AccessMode am = AccessMode.R;
        switch(p.getDirection()) {
            case IN:
                am = AccessMode.R;
                break;
            case OUT:
                am = AccessMode.W;
                break;
            case INOUT:
                am = AccessMode.RW;
                break;
        }
        // Inform the Data Manager about the new accesses
        DataAccessId daId;
        switch(p.getType()) {
            case FILE_T:
                FileParameter fp = (FileParameter) p;
                daId = DIP.registerFileAccess(am, fp.getLocation());
                break;
            case PSCO_T:
                ObjectParameter pscop = (ObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                pscop.setType(DataType.PSCO_T);
                daId = DIP.registerObjectAccess(am, pscop.getValue(), pscop.getCode());
                break;
            case EXTERNAL_OBJECT_T:
                ExternalObjectParameter externalPSCOparam = (ExternalObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                externalPSCOparam.setType(DataType.EXTERNAL_OBJECT_T);
                daId = DIP.registerExternalObjectAccess(am, externalPSCOparam.getId(), externalPSCOparam.getCode());
                break;
            case OBJECT_T:
                ObjectParameter op = (ObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                if (op.getValue() instanceof StubItf && ((StubItf) op.getValue()).getID() != null) {
                    op.setType(DataType.PSCO_T);
                }
                daId = DIP.registerObjectAccess(am, op.getValue(), op.getCode());
                break;
            default:
                /*
                     * Basic types (including String). The only possible access mode is R (already checked by the API)
                     */
                continue;
        }
        // Add dependencies to the graph and register output values for future dependencies
        DependencyParameter dp = (DependencyParameter) p;
        dp.setDataAccessId(daId);
        switch(am) {
            case R:
                checkDependencyForRead(currentTask, dp);
                if (paramIdx == constrainingParam) {
                    DataAccessId.RAccessId raId = (DataAccessId.RAccessId) dp.getDataAccessId();
                    DataInstanceId dependingDataId = raId.getReadDataInstance();
                    if (dependingDataId != null) {
                        if (dependingDataId.getVersionId() > 1) {
                            currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
                        }
                    }
                }
                break;
            case RW:
                checkDependencyForRead(currentTask, dp);
                if (paramIdx == constrainingParam) {
                    DataAccessId.RWAccessId raId = (DataAccessId.RWAccessId) dp.getDataAccessId();
                    DataInstanceId dependingDataId = raId.getReadDataInstance();
                    if (dependingDataId != null) {
                        if (dependingDataId.getVersionId() > 1) {
                            currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
                        }
                    }
                }
                registerOutputValues(currentTask, dp);
                break;
            case W:
                registerOutputValues(currentTask, dp);
                break;
        }
    }
}
Also used : DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) DataInstanceId(es.bsc.compss.types.data.DataInstanceId) TaskDescription(es.bsc.compss.types.TaskDescription) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) StubItf(storage.StubItf) 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) FileParameter(es.bsc.compss.types.parameter.FileParameter) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Aggregations

StubItf (storage.StubItf)3 IOException (java.io.IOException)2 JobExecutionException (es.bsc.compss.nio.exceptions.JobExecutionException)1 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 TaskDescription (es.bsc.compss.types.TaskDescription)1 DataAccessId (es.bsc.compss.types.data.DataAccessId)1 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)1 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 DataLocation (es.bsc.compss.types.data.location.DataLocation)1 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)1 ExternalObjectParameter (es.bsc.compss.types.parameter.ExternalObjectParameter)1 FileParameter (es.bsc.compss.types.parameter.FileParameter)1 ObjectParameter (es.bsc.compss.types.parameter.ObjectParameter)1 Parameter (es.bsc.compss.types.parameter.Parameter)1 SimpleURI (es.bsc.compss.types.uri.SimpleURI)1 StorageException (storage.StorageException)1