Search in sources :

Example 16 with LogicalData

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

the class NIOWorkerNode method orderCopy.

private void orderCopy(DeferredCopy c) {
    LOGGER.info("Order Copy for " + c.getSourceData());
    Resource tgtRes = ((LinkedList<Resource>) c.getTargetLoc().getHosts()).getFirst();
    LogicalData ld = c.getSourceData();
    String path;
    synchronized (ld) {
        if (c.getTargetData() != null) {
            MultiURI u = ld.alreadyAvailable(tgtRes);
            if (u != null) {
                path = u.getPath();
            } else {
                path = c.getTargetLoc().getURIInHost(tgtRes).getPath();
            }
        } else {
            path = c.getTargetLoc().getURIInHost(tgtRes).getPath();
        }
        c.setProposedSource(new Data(ld));
        LOGGER.debug("Setting final target in deferred copy " + path);
        c.setFinalTarget(path);
        // TODO: MISSING CHECK IF FILE IS ALREADY BEEN COPIED IN A SHARED LOCATION
        ld.startCopy(c, c.getTargetLoc());
        commManager.registerCopy(c);
    }
    c.end(DataOperation.OpEndState.OP_OK);
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) MultiURI(es.bsc.compss.types.uri.MultiURI) Resource(es.bsc.compss.types.resources.Resource) LogicalData(es.bsc.compss.types.data.LogicalData) Data(es.bsc.compss.nio.commands.Data) LinkedList(java.util.LinkedList)

Example 17 with LogicalData

use of es.bsc.compss.types.data.LogicalData 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 18 with LogicalData

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

the class NIOAdaptor method getObject.

@Override
public Object getObject(String name) throws SerializedObjectException {
    LogicalData ld = Comm.getData(name);
    Object o = ld.getValue();
    // Check if the object has been serialized meanwhile
    if (o == null) {
        for (MultiURI loc : ld.getURIs()) {
            if (!loc.getProtocol().equals(Protocol.OBJECT_URI) && loc.getHost().equals(Comm.getAppHost())) {
                // The object is null because it has been serialized by the master, raise exception
                throw new SerializedObjectException(name);
            }
        }
    }
    // 2- The object is really null (no exception thrown)
    return o;
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) MultiURI(es.bsc.compss.types.uri.MultiURI) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException)

Example 19 with LogicalData

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

Example 20 with LogicalData

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

the class Score method calculateDataLocalityScore.

/**
 * Calculates the number of Parameters in @params located in a given worker
 *
 * @w.
 *
 * @param params
 * @param w
 * @return
 */
public static long calculateDataLocalityScore(TaskDescription params, Worker<?> w) {
    long resourceScore = 0;
    if (params != null) {
        Parameter[] parameters = params.getParameters();
        // are located in the host
        for (Parameter p : parameters) {
            if (p instanceof DependencyParameter && p.getDirection() != Direction.OUT) {
                DependencyParameter dp = (DependencyParameter) p;
                DataInstanceId dId = null;
                switch(dp.getDirection()) {
                    case IN:
                        DataAccessId.RAccessId raId = (DataAccessId.RAccessId) dp.getDataAccessId();
                        dId = raId.getReadDataInstance();
                        break;
                    case INOUT:
                        DataAccessId.RWAccessId rwaId = (DataAccessId.RWAccessId) dp.getDataAccessId();
                        dId = rwaId.getReadDataInstance();
                        break;
                    case OUT:
                        // Cannot happen because of previous if
                        break;
                }
                // Get hosts for resource score
                if (dId != null) {
                    LogicalData dataLD = Comm.getData(dId.getRenaming());
                    if (dataLD != null) {
                        Set<Resource> hosts = dataLD.getAllHosts();
                        for (Resource host : hosts) {
                            if (host == w) {
                                resourceScore++;
                            }
                        }
                    }
                }
            }
        }
    }
    return resourceScore;
}
Also used : Resource(es.bsc.compss.types.resources.Resource) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) DataInstanceId(es.bsc.compss.types.data.DataInstanceId) LogicalData(es.bsc.compss.types.data.LogicalData) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) Parameter(es.bsc.compss.types.parameter.Parameter) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Aggregations

LogicalData (es.bsc.compss.types.data.LogicalData)27 DataLocation (es.bsc.compss.types.data.location.DataLocation)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 SimpleURI (es.bsc.compss.types.uri.SimpleURI)6 MultiURI (es.bsc.compss.types.uri.MultiURI)5 Semaphore (java.util.concurrent.Semaphore)5 InitNodeException (es.bsc.compss.exceptions.InitNodeException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)3 Copy (es.bsc.compss.types.data.operation.copy.Copy)3 Resource (es.bsc.compss.types.resources.Resource)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 Data (es.bsc.compss.nio.commands.Data)2 DataRequest (es.bsc.compss.nio.dataRequest.DataRequest)2 MasterDataRequest (es.bsc.compss.nio.dataRequest.MasterDataRequest)2 DataAccessId (es.bsc.compss.types.data.DataAccessId)2 TracingCopyListener (es.bsc.compss.types.data.listener.TracingCopyListener)2 TracingCopyTransferable (es.bsc.compss.types.data.transferable.TracingCopyTransferable)2 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)2 Parameter (es.bsc.compss.types.parameter.Parameter)2