use of es.bsc.compss.types.resources.Resource 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.");
}
use of es.bsc.compss.types.resources.Resource 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.resources.Resource 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;
}
use of es.bsc.compss.types.resources.Resource in project compss by bsc-wdc.
the class LogicalData method writeToStorage.
/**
* Writes memory value to file
*
* @throws Exception
*/
public synchronized void writeToStorage() throws IOException {
if (this.id != null) {
// It is a persistent object that is already persisted
// Nothing to do
// If the PSCO is not persisted we treat it as a normal object
} else {
// The object must be written to file
String targetPath = Comm.getAppHost().getWorkingDirectory() + this.name;
Serializer.serialize(value, targetPath);
String targetPathWithSchema = Protocol.FILE_URI.getSchema() + targetPath;
SimpleURI targetURI = new SimpleURI(targetPathWithSchema);
DataLocation loc = DataLocation.createLocation(Comm.getAppHost(), targetURI);
this.isBeingSaved = false;
this.locations.add(loc);
for (Resource r : loc.getHosts()) {
switch(loc.getType()) {
case PRIVATE:
r.addLogicalData(this);
break;
case SHARED:
SharedDiskManager.addLogicalData(loc.getSharedDisk(), this);
break;
case PERSISTENT:
// Nothing to do
break;
}
}
}
}
use of es.bsc.compss.types.resources.Resource in project compss by bsc-wdc.
the class LogicalData method addLocation.
/*
* Setters
*/
/**
* Adds a new location
*
* @param loc
*/
public synchronized void addLocation(DataLocation loc) {
this.isBeingSaved = false;
this.locations.add(loc);
for (Resource r : loc.getHosts()) {
switch(loc.getType()) {
case PRIVATE:
r.addLogicalData(this);
break;
case SHARED:
SharedDiskManager.addLogicalData(loc.getSharedDisk(), this);
break;
case PERSISTENT:
this.id = ((PersistentLocation) loc).getId();
break;
}
}
}
Aggregations