Search in sources :

Example 11 with DataAccessId

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

the class AccessProcessor method mainAcessToExternalObject.

/**
 * Notifies a main access to an external object {@code id}
 *
 * @param fileName
 * @param id
 * @param hashCode
 * @return
 */
public String mainAcessToExternalObject(String id, int hashCode) {
    if (DEBUG) {
        LOGGER.debug("Requesting main access to external object with hash code " + hashCode);
    }
    // Tell the DIP that the application wants to access an object
    AccessParams.ObjectAccessParams oap = new AccessParams.ObjectAccessParams(AccessMode.RW, id, hashCode);
    DataAccessId oaId = registerDataAccess(oap);
    DataInstanceId wId = ((DataAccessId.RWAccessId) oaId).getWrittenDataInstance();
    String wRename = wId.getRenaming();
    // Wait until the last writer task for the object has finished
    if (DEBUG) {
        LOGGER.debug("Waiting for last writer of " + oaId.getDataId() + " with renaming " + wRename);
    }
    waitForTask(oaId.getDataId(), AccessMode.RW);
    // TODO: Check if the object was already piggybacked in the task notification
    String lastRenaming = ((DataAccessId.RWAccessId) oaId).getReadDataInstance().getRenaming();
    String newId = Comm.getData(lastRenaming).getId();
    return Protocol.PERSISTENT_URI.getSchema() + newId;
}
Also used : DataInstanceId(es.bsc.compss.types.data.DataInstanceId) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) FileAccessParams(es.bsc.compss.types.data.AccessParams.FileAccessParams) AccessParams(es.bsc.compss.types.data.AccessParams) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Example 12 with DataAccessId

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

the class DataInfoProvider method getAccess.

private DataAccessId getAccess(AccessMode mode, DataInfo di) {
    // Version management
    DataAccessId daId = null;
    DataVersion currentInstance = di.getCurrentDataVersion();
    if (currentInstance != null) {
        switch(mode) {
            case R:
                daId = new RAccessId(currentInstance);
                break;
            case W:
                daId = new WAccessId(di.getCurrentDataVersion());
                break;
            case RW:
                DataVersion readInstance = di.getPreviousDataVersion();
                if (readInstance != null) {
                    daId = new RWAccessId(readInstance, currentInstance);
                } else {
                    LOGGER.warn("Previous instance for data" + di.getDataId() + " is null.");
                }
                break;
        }
    } else {
        LOGGER.warn("Current instance for data" + di.getDataId() + " is null.");
    }
    return daId;
}
Also used : DataAccessId(es.bsc.compss.types.data.DataAccessId)

Example 13 with DataAccessId

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

the class DataInfoProvider method transferObjectValue.

/**
 * Transfers the value of an object
 *
 * @param toRequest
 * @return
 */
public LogicalData transferObjectValue(TransferObjectRequest toRequest) {
    Semaphore sem = toRequest.getSemaphore();
    DataAccessId daId = toRequest.getDaId();
    RWAccessId rwaId = (RWAccessId) daId;
    String sourceName = rwaId.getReadDataInstance().getRenaming();
    // String targetName = rwaId.getWrittenDataInstance().getRenaming();
    if (DEBUG) {
        LOGGER.debug("Requesting getting object " + sourceName);
    }
    LogicalData ld = Comm.getData(sourceName);
    if (ld == null) {
        ErrorManager.error("Unregistered data " + sourceName);
        return null;
    }
    if (ld.isInMemory()) {
        // Write to storage (if needed)
        try {
            ld.writeToStorage();
        } catch (IOException e) {
            ErrorManager.error("Exception writing object to file.", e);
        }
        // Clear value
        ld.removeValue();
        // Set response
        toRequest.setResponse(ld.getValue());
        toRequest.setTargetData(ld);
        toRequest.getSemaphore().release();
    } else {
        if (DEBUG) {
            LOGGER.debug("Object " + sourceName + " not in memory. Requesting tranfers to " + Comm.getAppHost().getName());
        }
        DataLocation targetLocation = null;
        String path = DataLocation.Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + sourceName;
        try {
            SimpleURI uri = new SimpleURI(path);
            targetLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
        } catch (Exception e) {
            ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
        }
        Comm.getAppHost().getData(sourceName, targetLocation, new ObjectTransferable(), new OneOpWithSemListener(sem));
    }
    return ld;
}
Also used : ObjectTransferable(es.bsc.compss.types.data.operation.ObjectTransferable) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) IOException(java.io.IOException) OneOpWithSemListener(es.bsc.compss.types.data.operation.OneOpWithSemListener) DataAccessId(es.bsc.compss.types.data.DataAccessId) StorageException(storage.StorageException) IOException(java.io.IOException)

Example 14 with DataAccessId

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

the class ExecutionAction method transferJobData.

// Private method that performs data transfers
private final void transferJobData(DependencyParameter param, JobTransfersListener listener) {
    Worker<? extends WorkerResourceDescription> w = getAssignedResource().getResource();
    DataAccessId access = param.getDataAccessId();
    if (access instanceof DataAccessId.WAccessId) {
        String tgtName = ((DataAccessId.WAccessId) access).getWrittenDataInstance().getRenaming();
        if (DEBUG) {
            JOB_LOGGER.debug("Setting data target job transfer: " + w.getCompleteRemotePath(param.getType(), tgtName));
        }
        param.setDataTarget(w.getCompleteRemotePath(param.getType(), tgtName).getPath());
        return;
    }
    listener.addOperation();
    if (access instanceof DataAccessId.RAccessId) {
        String srcName = ((DataAccessId.RAccessId) access).getReadDataInstance().getRenaming();
        w.getData(srcName, srcName, param, listener);
    } else {
        // Is RWAccess
        String srcName = ((DataAccessId.RWAccessId) access).getReadDataInstance().getRenaming();
        String tgtName = ((DataAccessId.RWAccessId) access).getWrittenDataInstance().getRenaming();
        w.getData(srcName, tgtName, (LogicalData) null, param, listener);
    }
}
Also used : DataAccessId(es.bsc.compss.types.data.DataAccessId)

Aggregations

DataAccessId (es.bsc.compss.types.data.DataAccessId)14 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)5 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)5 Parameter (es.bsc.compss.types.parameter.Parameter)5 DataType (es.bsc.compss.types.annotations.parameter.DataType)4 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)4 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)4 BasicTypeParameter (es.bsc.compss.types.parameter.BasicTypeParameter)3 TaskDescription (es.bsc.compss.types.TaskDescription)2 AccessParams (es.bsc.compss.types.data.AccessParams)2 FileAccessParams (es.bsc.compss.types.data.AccessParams.FileAccessParams)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2 DataLocation (es.bsc.compss.types.data.location.DataLocation)2 ExternalObjectParameter (es.bsc.compss.types.parameter.ExternalObjectParameter)2 FileParameter (es.bsc.compss.types.parameter.FileParameter)2 ObjectParameter (es.bsc.compss.types.parameter.ObjectParameter)2 SimpleURI (es.bsc.compss.types.uri.SimpleURI)2 Semaphore (java.util.concurrent.Semaphore)2 File (org.gridlab.gat.io.File)2 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)1