use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class DataInfoProvider method transferObjectValue.
/**
* Transfers the value of an object
*
* @param toRequest
* @return
*/
public LogicalData transferObjectValue(TransferObjectRequest toRequest) {
Semaphore sem = toRequest.getSemaphore();
DataAccessId daId = toRequest.getDaId();
RWAccessId rwaId = (RWAccessId) daId;
String sourceName = rwaId.getReadDataInstance().getRenaming();
// String targetName = rwaId.getWrittenDataInstance().getRenaming();
if (DEBUG) {
LOGGER.debug("Requesting getting object " + sourceName);
}
LogicalData ld = Comm.getData(sourceName);
if (ld == null) {
ErrorManager.error("Unregistered data " + sourceName);
return null;
}
if (ld.isInMemory()) {
// Write to storage (if needed)
try {
ld.writeToStorage();
} catch (IOException e) {
ErrorManager.error("Exception writing object to file.", e);
}
// Clear value
ld.removeValue();
// Set response
toRequest.setResponse(ld.getValue());
toRequest.setTargetData(ld);
toRequest.getSemaphore().release();
} else {
if (DEBUG) {
LOGGER.debug("Object " + sourceName + " not in memory. Requesting tranfers to " + Comm.getAppHost().getName());
}
DataLocation targetLocation = null;
String path = DataLocation.Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + sourceName;
try {
SimpleURI uri = new SimpleURI(path);
targetLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
}
Comm.getAppHost().getData(sourceName, targetLocation, new ObjectTransferable(), new OneOpWithSemListener(sem));
}
return ld;
}
use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class ExecutionAction method doOutputTransfers.
private final void doOutputTransfers(Job<?> job) {
// Job finished, update info about the generated/updated data
Worker<? extends WorkerResourceDescription> w = this.getAssignedResource().getResource();
for (Parameter p : job.getTaskParams().getParameters()) {
if (p instanceof DependencyParameter) {
// OUT or INOUT: we must tell the FTM about the
// generated/updated datum
DataInstanceId dId = null;
DependencyParameter dp = (DependencyParameter) p;
switch(p.getDirection()) {
case IN:
// FTM already knows about this datum
continue;
case OUT:
dId = ((DataAccessId.WAccessId) dp.getDataAccessId()).getWrittenDataInstance();
break;
case INOUT:
dId = ((DataAccessId.RWAccessId) dp.getDataAccessId()).getWrittenDataInstance();
if (job.getType() == TaskType.SERVICE) {
continue;
}
break;
}
String name = dId.getRenaming();
if (job.getType() == TaskType.METHOD) {
String targetProtocol = null;
switch(dp.getType()) {
case FILE_T:
targetProtocol = DataLocation.Protocol.FILE_URI.getSchema();
break;
case OBJECT_T:
targetProtocol = DataLocation.Protocol.OBJECT_URI.getSchema();
break;
case PSCO_T:
targetProtocol = DataLocation.Protocol.PERSISTENT_URI.getSchema();
break;
case EXTERNAL_OBJECT_T:
// Its value is the PSCO Id
targetProtocol = DataLocation.Protocol.PERSISTENT_URI.getSchema();
break;
default:
// Should never reach this point because only
// DependencyParameter types are treated
// Ask for any_uri just in case
targetProtocol = DataLocation.Protocol.ANY_URI.getSchema();
break;
}
DataLocation outLoc = null;
try {
SimpleURI targetURI = new SimpleURI(targetProtocol + dp.getDataTarget());
outLoc = DataLocation.createLocation(w, targetURI);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + dp.getDataTarget(), e);
}
Comm.registerLocation(name, outLoc);
} else {
// Service
Object value = job.getReturnValue();
Comm.registerValue(name, value);
}
}
}
}
Aggregations