use of es.bsc.compss.types.data.AccessParams.AccessMode in project compss by bsc-wdc.
the class COMPSsRuntimeImpl method openFile.
/*
* ***********************************************************************************************************
* COMMON IN BOTH APIs
* ********************************************************************************************************
*/
/**
* Returns the renaming of the file version opened
*/
@Override
public String openFile(String fileName, Direction mode) {
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.Event.OPEN_FILE.getId(), Tracer.Event.OPEN_FILE.getType());
}
LOGGER.info("Opening " + fileName + " in mode " + mode);
// Parse arguments to internal structures
DataLocation loc;
try {
loc = createLocation(fileName);
} catch (IOException ioe) {
ErrorManager.fatal(ERROR_FILE_NAME, ioe);
return null;
}
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
String finalPath;
switch(loc.getType()) {
case PRIVATE:
case SHARED:
finalPath = mainAccessToFile(fileName, loc, am, null);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("File target Location: " + finalPath);
}
break;
case PERSISTENT:
finalPath = mainAccessToExternalObject(fileName, loc);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("External Object target Location: " + finalPath);
}
break;
default:
finalPath = null;
ErrorManager.error("ERROR: Unrecognised protocol requesting openFile " + fileName);
}
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.EVENT_END, Tracer.getRuntimeEventsType());
}
return finalPath;
}
use of es.bsc.compss.types.data.AccessParams.AccessMode 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