use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class LogicalData method removeValue.
/**
* Removes the object from master main memory and removes its location
*
* @return
*/
public synchronized Object removeValue() {
DataLocation loc = null;
String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
try {
SimpleURI uri = new SimpleURI(targetPath);
loc = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
}
Object val = this.value;
this.value = null;
// Removes only the memory location (no need to check private, shared,
// persistent)
this.locations.remove(loc);
return val;
}
use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class Resource method getWorkersDebugInfo.
private void getWorkersDebugInfo() {
if (DEBUG) {
LOGGER.debug("Copying Workers Information");
}
COMPSsNode masterNode = Comm.getAppHost().getNode();
Semaphore sem = new Semaphore(0);
WorkersDebugInformationListener wdil = new WorkersDebugInformationListener(sem);
// Get Worker output
wdil.addOperation();
String outFileName = "worker_" + getName() + ".out";
SimpleURI outFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + outFileName);
String outFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + outFileName;
DataLocation outSource = null;
try {
outSource = DataLocation.createLocation(this, outFileOrigin);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileOrigin.toString(), e);
}
DataLocation outTarget = null;
try {
SimpleURI uri = new SimpleURI(outFileTarget);
outTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + outFileTarget);
}
LOGGER.debug("- Source: " + outFileOrigin);
LOGGER.debug("- Target: " + outFileTarget);
masterNode.obtainData(new LogicalData("workerOut" + this.getName()), outSource, outTarget, new LogicalData("workerOut" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
// Get Worker error
wdil.addOperation();
String errFileName = "worker_" + getName() + ".err";
SimpleURI errFileOrigin = node.getCompletePath(DataType.FILE_T, "log" + File.separator + "static_" + errFileName);
String errFileTarget = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getWorkersDirPath() + File.separator + errFileName;
DataLocation errSource = null;
try {
errSource = DataLocation.createLocation(this, errFileOrigin);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileOrigin.toString(), e);
}
DataLocation errTarget = null;
try {
SimpleURI uri = new SimpleURI(errFileTarget);
errTarget = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + errFileTarget);
}
LOGGER.debug("- Source: " + errFileOrigin);
LOGGER.debug("- Target: " + errFileTarget);
masterNode.obtainData(new LogicalData("workerErr" + this.getName()), errSource, errTarget, new LogicalData("workerErr" + this.getName()), new WorkersDebugInfoCopyTransferable(), wdil);
// Wait transfers
wdil.enable();
try {
sem.acquire();
} catch (InterruptedException ex) {
LOGGER.error("Error waiting for worker debug files in resource " + getName() + " to get saved");
}
LOGGER.debug("Worker files from resource " + getName() + "received");
}
use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class Resource method getData.
/**
* Retrieves a given data
*
* @param ld
* @param newName
* @param tgtData
* @param reason
* @param listener
*/
public void getData(LogicalData ld, String newName, LogicalData tgtData, Transferable reason, EventListener listener) {
SimpleURI workingPath = node.getCompletePath(reason.getType(), newName);
DataLocation target = null;
try {
target = DataLocation.createLocation(this, workingPath);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + workingPath.toString(), e);
}
getData(ld, target, tgtData, reason, listener);
}
use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class AccessProcessor method mainAccessToFile.
/**
* Notifies a main access to a given file @sourceLocation in mode @fap
*
* @param sourceLocation
* @param fap
* @param destDir
* @return
*/
public DataLocation mainAccessToFile(DataLocation sourceLocation, AccessParams.FileAccessParams fap, String destDir) {
boolean alreadyAccessed = alreadyAccessed(sourceLocation);
if (!alreadyAccessed) {
LOGGER.debug("File not accessed before, returning the same location");
return sourceLocation;
}
// Tell the DM that the application wants to access a file.
DataAccessId faId = registerDataAccess(fap);
DataLocation tgtLocation = sourceLocation;
if (fap.getMode() != AccessMode.W) {
// Wait until the last writer task for the file has finished
LOGGER.debug("File " + faId.getDataId() + " mode contains R, waiting until the last writer has finished");
waitForTask(faId.getDataId(), AccessMode.R);
if (destDir == null) {
tgtLocation = transferFileOpen(faId);
} else {
DataInstanceId daId;
if (fap.getMode() == AccessMode.R) {
RAccessId ra = (RAccessId) faId;
daId = ra.getReadDataInstance();
} else {
RWAccessId ra = (RWAccessId) faId;
daId = ra.getReadDataInstance();
}
String rename = daId.getRenaming();
String path = DataLocation.Protocol.FILE_URI.getSchema() + destDir + rename;
try {
SimpleURI uri = new SimpleURI(path);
tgtLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
}
transferFileRaw(faId, tgtLocation);
}
}
if (fap.getMode() != AccessMode.R) {
// Mode contains W
LOGGER.debug("File " + faId.getDataId() + " mode contains W, register new writer");
DataInstanceId daId;
if (fap.getMode() == AccessMode.RW) {
RWAccessId ra = (RWAccessId) faId;
daId = ra.getWrittenDataInstance();
} else {
WAccessId ra = (WAccessId) faId;
daId = ra.getWrittenDataInstance();
}
String rename = daId.getRenaming();
String path = DataLocation.Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + rename;
try {
SimpleURI uri = new SimpleURI(path);
tgtLocation = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
}
Comm.registerLocation(rename, tgtLocation);
}
if (DEBUG) {
LOGGER.debug("File " + faId.getDataId() + " located on " + tgtLocation.toString());
}
return tgtLocation;
}
use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class COMPSsRuntimeImpl method closeFile.
@Override
public void closeFile(String fileName, Direction mode) {
// if (Tracer.isActivated()) {
// Tracer.emitEvent(Tracer.Event.CLOSE_FILE.getId(), Tracer.Event.CLOSE_FILE.getType());
// }
LOGGER.info("Closing " + fileName + " in mode " + mode);
// Parse arguments to internal structures
DataLocation loc;
try {
loc = createLocation(fileName);
} catch (Exception e) {
ErrorManager.fatal(ERROR_FILE_NAME, e);
return;
}
AccessMode am = null;
switch(mode) {
case IN:
am = AccessMode.R;
break;
case OUT:
am = AccessMode.W;
break;
case INOUT:
am = AccessMode.RW;
break;
}
// Request AP that the application wants to access a FILE or a EXTERNAL_PSCO
switch(loc.getType()) {
case PRIVATE:
case SHARED:
finishAccessToFile(fileName, loc, am, null);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Closing file " + loc.getPath());
}
break;
case PERSISTENT:
// Nothing to do
ErrorManager.warn("WARN: Cannot close file " + fileName + " with PSCO protocol");
break;
default:
ErrorManager.error("ERROR: Unrecognised protocol requesting closeFile " + fileName);
}
// if (Tracer.isActivated()) {
// Tracer.emitEvent(Tracer.EVENT_END, Tracer.getRuntimeEventsType());
// }
}
Aggregations