Search in sources :

Example 11 with DataLocation

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

the class Resource method getTracingPackageToMaster.

private void getTracingPackageToMaster() {
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    Semaphore sem = new Semaphore(0);
    String fileName = getName() + "_compss_trace.tar.gz";
    SimpleURI fileOriginURI = node.getCompletePath(DataType.FILE_T, fileName);
    if (DEBUG) {
        LOGGER.debug("Copying tracing package from : " + fileOriginURI.getPath() + ",to : " + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName);
    }
    TracingCopyListener tracingListener = new TracingCopyListener(sem);
    tracingListener.addOperation();
    // Source data location
    DataLocation source;
    try {
        source = DataLocation.createLocation(this, fileOriginURI);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + fileOriginURI.getPath(), e);
        return;
    }
    // Target data location
    DataLocation tgt;
    String targetPath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        tgt = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath);
        return;
    }
    // Ask for data
    masterNode.obtainData(new LogicalData("tracing" + this.getName()), source, tgt, new LogicalData("tracing" + this.getName()), new TracingCopyTransferable(), tracingListener);
    tracingListener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for tracing files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Removing " + this.getName() + " tracing temporary files");
    }
    File f = null;
    try {
        f = new File(source.getPath());
        if (!f.delete()) {
            LOGGER.error("Unable to remove tracing temporary files of node " + this.getName());
        }
    } catch (Exception e) {
        LOGGER.error("Unable to remove tracing temporary files of node " + this.getName(), e);
    }
}
Also used : TracingCopyTransferable(es.bsc.compss.types.data.transferable.TracingCopyTransferable) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) TracingCopyListener(es.bsc.compss.types.data.listener.TracingCopyListener) File(java.io.File) COMPSsNode(es.bsc.compss.types.COMPSsNode) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Example 12 with DataLocation

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

the class ImmediateCopy method perform.

public void perform() {
    Resource targetHost = ((LinkedList<Resource>) tgtLoc.getHosts()).getFirst();
    LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - Copy file " + getName() + " to " + tgtLoc);
    synchronized (srcData) {
        if (tgtData != null) {
            MultiURI u;
            if ((u = srcData.alreadyAvailable(targetHost)) != null) {
                setFinalTarget(u.getPath());
                end(DataOperation.OpEndState.OP_OK);
                LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - A copy of " + getName() + " is already present at " + targetHost + " on path " + u.getPath());
                return;
            }
            Copy copyInProgress = null;
            if ((copyInProgress = srcData.alreadyCopying(tgtLoc)) != null) {
                String path = copyInProgress.tgtLoc.getURIInHost(targetHost).getPath();
                setFinalTarget(path);
                // The same operation is already in progress - no need to repeat it
                end(DataOperation.OpEndState.OP_IN_PROGRESS);
                // This group must be notified as well when the operation finishes
                synchronized (copyInProgress.getEventListeners()) {
                    copyInProgress.addEventListeners(getEventListeners());
                }
                LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - A copy to " + path + " is already in progress, skipping replication");
                return;
            }
        }
        srcData.startCopy(this, tgtLoc);
    }
    try {
        LOGGER.debug("[InmediateCopy] Performing Inmediate specific Copy for " + getName());
        specificCopy();
    } catch (CopyException e) {
        end(DataOperation.OpEndState.OP_FAILED, e);
        return;
    } finally {
        DataLocation actualLocation;
        synchronized (srcData) {
            actualLocation = srcData.finishedCopy(this);
        }
        if (tgtData != null) {
            synchronized (tgtData) {
                tgtData.addLocation(actualLocation);
            }
        }
    }
    String path = tgtLoc.getURIInHost(targetHost).getPath();
    setFinalTarget(path);
    synchronized (srcData) {
        end(DataOperation.OpEndState.OP_OK);
    }
    LOGGER.debug("[InmediateCopy] Inmediate Copy for " + getName() + " performed.");
}
Also used : MultiURI(es.bsc.compss.types.uri.MultiURI) CopyException(es.bsc.compss.exceptions.CopyException) Resource(es.bsc.compss.types.resources.Resource) DataLocation(es.bsc.compss.types.data.location.DataLocation) LinkedList(java.util.LinkedList)

Example 13 with DataLocation

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

the class Resource method retrieveData.

/**
 * Retrieves all the data from the Resource
 *
 * @param saveUniqueData
 */
public void retrieveData(boolean saveUniqueData) {
    if (DEBUG) {
        LOGGER.debug("Retrieving data resource " + this.getName());
    }
    Semaphore sem = new Semaphore(0);
    SafeCopyListener listener = new SafeCopyListener(sem);
    Set<LogicalData> lds = getAllDataFromHost();
    Map<String, String> disks = SharedDiskManager.terminate(this);
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    for (LogicalData ld : lds) {
        ld.notifyToInProgressCopiesEnd(listener);
        DataLocation lastLoc = ld.removeHostAndCheckLocationToSave(this, disks);
        if (lastLoc != null && saveUniqueData) {
            listener.addOperation();
            DataLocation safeLoc = null;
            String safePath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + ld.getName();
            try {
                SimpleURI uri = new SimpleURI(safePath);
                safeLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
            } catch (Exception e) {
                ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + safePath, e);
            }
            masterNode.obtainData(ld, lastLoc, safeLoc, ld, new SafeCopyTransferable(), listener);
        }
    }
    if (DEBUG) {
        LOGGER.debug("Waiting for finishing saving copies for " + this.getName());
    }
    listener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Unique files saved for " + this.getName());
    }
    if (this.getType() != Type.SERVICE) {
        shutdownExecutionManager();
        if (Tracer.isActivated()) {
            if (node.generatePackage()) {
                getTracingPackageToMaster();
                if (DEBUG) {
                    LOGGER.debug("Tracing package obtained for " + this.getName());
                }
            }
        }
        if (DEBUG) {
            if (node.generateWorkersDebugInfo()) {
                getWorkersDebugInfo();
                LOGGER.debug("Workers Debug files obtained for " + this.getName());
            }
        }
    }
}
Also used : SafeCopyListener(es.bsc.compss.types.data.listener.SafeCopyListener) LogicalData(es.bsc.compss.types.data.LogicalData) SafeCopyTransferable(es.bsc.compss.types.data.transferable.SafeCopyTransferable) SimpleURI(es.bsc.compss.types.uri.SimpleURI) 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 14 with DataLocation

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

the class NIOAdaptor method receivedValue.

@Override
public void receivedValue(Destination type, String dataId, Object object, List<DataRequest> achievedRequests) {
    for (DataRequest dr : achievedRequests) {
        MasterDataRequest mdr = (MasterDataRequest) dr;
        Copy c = (Copy) mdr.getOperation();
        DataLocation actualLocation = c.getSourceData().finishedCopy(c);
        LogicalData tgtData = c.getTargetData();
        if (tgtData != null) {
            tgtData.addLocation(actualLocation);
            if (object != null) {
                tgtData.setValue(object);
            }
        }
        c.end(DataOperation.OpEndState.OP_OK);
    }
    if (NIOTracer.isActivated()) {
        NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
    }
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) Copy(es.bsc.compss.types.data.operation.copy.Copy) DataLocation(es.bsc.compss.types.data.location.DataLocation) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest)

Example 15 with DataLocation

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

the class NIOAdaptor method copiedData.

@Override
public void copiedData(int transferGroupId) {
    LOGGER.debug("Notifying copied Data to master");
    LinkedList<Copy> copies = GROUP_TO_COPY.remove(transferGroupId);
    if (copies == null) {
        LOGGER.debug("No copies to process");
        return;
    }
    for (Copy c : copies) {
        LOGGER.debug("Treating copy " + c.getName());
        if (!c.isRegistered()) {
            LOGGER.debug("No registered copy " + c.getName());
            continue;
        }
        DataLocation actualLocation = c.getSourceData().finishedCopy(c);
        if (actualLocation != null) {
            LOGGER.debug("Actual Location " + actualLocation.getPath());
        } else {
            LOGGER.debug("Actual Location is null");
        }
        LogicalData tgtData = c.getTargetData();
        if (tgtData != null) {
            LOGGER.debug("targetData is not null");
            switch(actualLocation.getType()) {
                case PERSISTENT:
                    LOGGER.debug("Persistent location no need to update location for " + tgtData.getName());
                    break;
                case PRIVATE:
                    LOGGER.debug("Adding location:" + actualLocation.getPath() + " to " + tgtData.getName());
                    tgtData.addLocation(actualLocation);
                    break;
                case SHARED:
                    LOGGER.debug("Shared location no need to update location for " + tgtData.getName());
                    break;
            }
            LOGGER.debug("Locations for " + tgtData.getName() + " are: " + tgtData.getURIs());
        } else {
            LOGGER.warn("No target Data defined for copy " + c.getName());
        }
    }
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) Copy(es.bsc.compss.types.data.operation.copy.Copy) DataLocation(es.bsc.compss.types.data.location.DataLocation)

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