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);
}
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);
}
}
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;
}
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());
}
}
}
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;
}
Aggregations