Search in sources :

Example 6 with RAccessId

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

the class AccessProcessor method mainAccessToFile.

/**
 * Notifies a main access to a given file @sourceLocation in mode @fap
 *
 * @param sourceLocation
 * @param fap
 * @param destDir
 * @return
 */
public DataLocation mainAccessToFile(DataLocation sourceLocation, AccessParams.FileAccessParams fap, String destDir) {
    boolean alreadyAccessed = alreadyAccessed(sourceLocation);
    if (!alreadyAccessed) {
        LOGGER.debug("File not accessed before, returning the same location");
        return sourceLocation;
    }
    // Tell the DM that the application wants to access a file.
    DataAccessId faId = registerDataAccess(fap);
    DataLocation tgtLocation = sourceLocation;
    if (fap.getMode() != AccessMode.W) {
        // Wait until the last writer task for the file has finished
        LOGGER.debug("File " + faId.getDataId() + " mode contains R, waiting until the last writer has finished");
        waitForTask(faId.getDataId(), AccessMode.R);
        if (destDir == null) {
            tgtLocation = transferFileOpen(faId);
        } else {
            DataInstanceId daId;
            if (fap.getMode() == AccessMode.R) {
                RAccessId ra = (RAccessId) faId;
                daId = ra.getReadDataInstance();
            } else {
                RWAccessId ra = (RWAccessId) faId;
                daId = ra.getReadDataInstance();
            }
            String rename = daId.getRenaming();
            String path = DataLocation.Protocol.FILE_URI.getSchema() + destDir + rename;
            try {
                SimpleURI uri = new SimpleURI(path);
                tgtLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
            } catch (Exception e) {
                ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
            }
            transferFileRaw(faId, tgtLocation);
        }
    }
    if (fap.getMode() != AccessMode.R) {
        // Mode contains W
        LOGGER.debug("File " + faId.getDataId() + " mode contains W, register new writer");
        DataInstanceId daId;
        if (fap.getMode() == AccessMode.RW) {
            RWAccessId ra = (RWAccessId) faId;
            daId = ra.getWrittenDataInstance();
        } else {
            WAccessId ra = (WAccessId) faId;
            daId = ra.getWrittenDataInstance();
        }
        String rename = daId.getRenaming();
        String path = DataLocation.Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + rename;
        try {
            SimpleURI uri = new SimpleURI(path);
            tgtLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
        } catch (Exception e) {
            ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
        }
        Comm.registerLocation(rename, tgtLocation);
    }
    if (DEBUG) {
        LOGGER.debug("File " + faId.getDataId() + " located on " + tgtLocation.toString());
    }
    return tgtLocation;
}
Also used : DataInstanceId(es.bsc.compss.types.data.DataInstanceId) RAccessId(es.bsc.compss.types.data.DataAccessId.RAccessId) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) WAccessId(es.bsc.compss.types.data.DataAccessId.WAccessId) DataAccessId(es.bsc.compss.types.data.DataAccessId) ShutdownException(es.bsc.compss.types.request.exceptions.ShutdownException) CannotLoadException(es.bsc.compss.exceptions.CannotLoadException)

Aggregations

RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)6 DataAccessId (es.bsc.compss.types.data.DataAccessId)4 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)4 DataType (es.bsc.compss.types.annotations.parameter.DataType)3 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)3 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)3 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)3 BasicTypeParameter (es.bsc.compss.types.parameter.BasicTypeParameter)3 Parameter (es.bsc.compss.types.parameter.Parameter)3 SimpleURI (es.bsc.compss.types.uri.SimpleURI)3 TaskDescription (es.bsc.compss.types.TaskDescription)2 DataLocation (es.bsc.compss.types.data.location.DataLocation)2 File (org.gridlab.gat.io.File)2 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)1 NIOParam (es.bsc.compss.nio.NIOParam)1 Data (es.bsc.compss.nio.commands.Data)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 FileTransferable (es.bsc.compss.types.data.operation.FileTransferable)1 OneOpWithSemListener (es.bsc.compss.types.data.operation.OneOpWithSemListener)1 AbstractMethodImplementation (es.bsc.compss.types.implementations.AbstractMethodImplementation)1