Search in sources :

Example 21 with DataLocation

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

the class LogicalData method removeValue.

/**
 * Removes the object from master main memory and removes its location
 *
 * @return
 */
public synchronized Object removeValue() {
    DataLocation loc = null;
    String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        loc = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
    }
    Object val = this.value;
    this.value = null;
    // Removes only the memory location (no need to check private, shared,
    // persistent)
    this.locations.remove(loc);
    return val;
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) StorageException(storage.StorageException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException) IOException(java.io.IOException) CannotLoadException(es.bsc.compss.exceptions.CannotLoadException)

Example 22 with DataLocation

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

the class Resource method getWorkersDebugInfo.

private void getWorkersDebugInfo() {
    if (DEBUG) {
        LOGGER.debug("Copying Workers Information");
    }
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    Semaphore sem = new Semaphore(0);
    WorkersDebugInformationListener wdil = new WorkersDebugInformationListener(sem);
    // Get Worker output
    wdil.addOperation();
    String outFileName = "worker_" + getName() + ".out";
    SimpleURI outFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + outFileName);
    String outFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + outFileName;
    DataLocation outSource = null;
    try {
        outSource = DataLocation.createLocation(this, outFileOrigin);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileOrigin.toString(), e);
    }
    DataLocation outTarget = null;
    try {
        SimpleURI uri = new SimpleURI(outFileTarget);
        outTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileTarget);
    }
    LOGGER.debug("- Source: " + outFileOrigin);
    LOGGER.debug("- Target: " + outFileTarget);
    masterNode.obtainData(new LogicalData("workerOut" + this.getName()), outSource, outTarget, new LogicalData("workerOut" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
    // Get Worker error
    wdil.addOperation();
    String errFileName = "worker_" + getName() + ".err";
    SimpleURI errFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + errFileName);
    String errFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + errFileName;
    DataLocation errSource = null;
    try {
        errSource = DataLocation.createLocation(this, errFileOrigin);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileOrigin.toString(), e);
    }
    DataLocation errTarget = null;
    try {
        SimpleURI uri = new SimpleURI(errFileTarget);
        errTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileTarget);
    }
    LOGGER.debug("- Source: " + errFileOrigin);
    LOGGER.debug("- Target: " + errFileTarget);
    masterNode.obtainData(new LogicalData("workerErr" + this.getName()), errSource, errTarget, new LogicalData("workerErr" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
    // Wait transfers
    wdil.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for worker debug files in resource " + getName() + " to get saved");
    }
    LOGGER.debug("Worker files from resource " + getName() + "received");
}
Also used : WorkersDebugInformationListener(es.bsc.compss.types.data.listener.WorkersDebugInformationListener) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) WorkersDebugInfoCopyTransferable(es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable) 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 23 with DataLocation

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

the class Resource method getData.

/**
 * Retrieves a given data
 *
 * @param ld
 * @param newName
 * @param tgtData
 * @param reason
 * @param listener
 */
public void getData(LogicalData ld, String newName, LogicalData tgtData, Transferable reason, EventListener listener) {
    SimpleURI workingPath = node.getCompletePath(reason.getType(), newName);
    DataLocation target = null;
    try {
        target = DataLocation.createLocation(this, workingPath);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + workingPath.toString(), e);
    }
    getData(ld, target, tgtData, reason, listener);
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Example 24 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation 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)

Example 25 with DataLocation

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

the class COMPSsRuntimeImpl method closeFile.

@Override
public void closeFile(String fileName, Direction mode) {
    // if (Tracer.isActivated()) {
    // Tracer.emitEvent(Tracer.Event.CLOSE_FILE.getId(), Tracer.Event.CLOSE_FILE.getType());
    // }
    LOGGER.info("Closing " + fileName + " in mode " + mode);
    // Parse arguments to internal structures
    DataLocation loc;
    try {
        loc = createLocation(fileName);
    } catch (Exception e) {
        ErrorManager.fatal(ERROR_FILE_NAME, e);
        return;
    }
    AccessMode am = null;
    switch(mode) {
        case IN:
            am = AccessMode.R;
            break;
        case OUT:
            am = AccessMode.W;
            break;
        case INOUT:
            am = AccessMode.RW;
            break;
    }
    // Request AP that the application wants to access a FILE or a EXTERNAL_PSCO
    switch(loc.getType()) {
        case PRIVATE:
        case SHARED:
            finishAccessToFile(fileName, loc, am, null);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Closing file " + loc.getPath());
            }
            break;
        case PERSISTENT:
            // Nothing to do
            ErrorManager.warn("WARN: Cannot close file " + fileName + " with PSCO protocol");
            break;
        default:
            ErrorManager.error("ERROR: Unrecognised protocol requesting closeFile " + fileName);
    }
// if (Tracer.isActivated()) {
// Tracer.emitEvent(Tracer.EVENT_END, Tracer.getRuntimeEventsType());
// }
}
Also used : DataLocation(es.bsc.compss.types.data.location.DataLocation) AccessMode(es.bsc.compss.types.data.AccessParams.AccessMode) IOException(java.io.IOException)

Aggregations

DataLocation (es.bsc.compss.types.data.location.DataLocation)30 SimpleURI (es.bsc.compss.types.uri.SimpleURI)16 IOException (java.io.IOException)14 LogicalData (es.bsc.compss.types.data.LogicalData)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 InitNodeException (es.bsc.compss.exceptions.InitNodeException)5 MultiURI (es.bsc.compss.types.uri.MultiURI)5 Semaphore (java.util.concurrent.Semaphore)5 StorageException (storage.StorageException)5 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)4 File (java.io.File)4 DataAccessId (es.bsc.compss.types.data.DataAccessId)3 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)3 Copy (es.bsc.compss.types.data.operation.copy.Copy)3 Resource (es.bsc.compss.types.resources.Resource)3 AccessMode (es.bsc.compss.types.data.AccessParams.AccessMode)2 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)2 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2