use of es.bsc.compss.types.data.DataAccessId in project compss by bsc-wdc.
the class AccessProcessor method mainAcessToExternalObject.
/**
* Notifies a main access to an external object {@code id}
*
* @param fileName
* @param id
* @param hashCode
* @return
*/
public String mainAcessToExternalObject(String id, int hashCode) {
if (DEBUG) {
LOGGER.debug("Requesting main access to external object with hash code " + hashCode);
}
// Tell the DIP that the application wants to access an object
AccessParams.ObjectAccessParams oap = new AccessParams.ObjectAccessParams(AccessMode.RW, id, hashCode);
DataAccessId oaId = registerDataAccess(oap);
DataInstanceId wId = ((DataAccessId.RWAccessId) oaId).getWrittenDataInstance();
String wRename = wId.getRenaming();
// Wait until the last writer task for the object has finished
if (DEBUG) {
LOGGER.debug("Waiting for last writer of " + oaId.getDataId() + " with renaming " + wRename);
}
waitForTask(oaId.getDataId(), AccessMode.RW);
// TODO: Check if the object was already piggybacked in the task notification
String lastRenaming = ((DataAccessId.RWAccessId) oaId).getReadDataInstance().getRenaming();
String newId = Comm.getData(lastRenaming).getId();
return Protocol.PERSISTENT_URI.getSchema() + newId;
}
use of es.bsc.compss.types.data.DataAccessId in project compss by bsc-wdc.
the class DataInfoProvider method getAccess.
private DataAccessId getAccess(AccessMode mode, DataInfo di) {
// Version management
DataAccessId daId = null;
DataVersion currentInstance = di.getCurrentDataVersion();
if (currentInstance != null) {
switch(mode) {
case R:
daId = new RAccessId(currentInstance);
break;
case W:
daId = new WAccessId(di.getCurrentDataVersion());
break;
case RW:
DataVersion readInstance = di.getPreviousDataVersion();
if (readInstance != null) {
daId = new RWAccessId(readInstance, currentInstance);
} else {
LOGGER.warn("Previous instance for data" + di.getDataId() + " is null.");
}
break;
}
} else {
LOGGER.warn("Current instance for data" + di.getDataId() + " is null.");
}
return daId;
}
use of es.bsc.compss.types.data.DataAccessId 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.data.DataAccessId in project compss by bsc-wdc.
the class ExecutionAction method transferJobData.
// Private method that performs data transfers
private final void transferJobData(DependencyParameter param, JobTransfersListener listener) {
Worker<? extends WorkerResourceDescription> w = getAssignedResource().getResource();
DataAccessId access = param.getDataAccessId();
if (access instanceof DataAccessId.WAccessId) {
String tgtName = ((DataAccessId.WAccessId) access).getWrittenDataInstance().getRenaming();
if (DEBUG) {
JOB_LOGGER.debug("Setting data target job transfer: " + w.getCompleteRemotePath(param.getType(), tgtName));
}
param.setDataTarget(w.getCompleteRemotePath(param.getType(), tgtName).getPath());
return;
}
listener.addOperation();
if (access instanceof DataAccessId.RAccessId) {
String srcName = ((DataAccessId.RAccessId) access).getReadDataInstance().getRenaming();
w.getData(srcName, srcName, param, listener);
} else {
// Is RWAccess
String srcName = ((DataAccessId.RWAccessId) access).getReadDataInstance().getRenaming();
String tgtName = ((DataAccessId.RWAccessId) access).getWrittenDataInstance().getRenaming();
w.getData(srcName, tgtName, (LogicalData) null, param, listener);
}
}
Aggregations