use of es.bsc.compss.types.data.listener.SafeCopyListener in project compss by bsc-wdc.
the class Resource method retrieveData.
/**
* Retrieves all the data from the Resource
*
* @param saveUniqueData
*/
public void retrieveData(boolean saveUniqueData) {
if (DEBUG) {
LOGGER.debug("Retrieving data resource " + this.getName());
}
Semaphore sem = new Semaphore(0);
SafeCopyListener listener = new SafeCopyListener(sem);
Set<LogicalData> lds = getAllDataFromHost();
Map<String, String> disks = SharedDiskManager.terminate(this);
COMPSsNode masterNode = Comm.getAppHost().getNode();
for (LogicalData ld : lds) {
ld.notifyToInProgressCopiesEnd(listener);
DataLocation lastLoc = ld.removeHostAndCheckLocationToSave(this, disks);
if (lastLoc != null && saveUniqueData) {
listener.addOperation();
DataLocation safeLoc = null;
String safePath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + ld.getName();
try {
SimpleURI uri = new SimpleURI(safePath);
safeLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + safePath, e);
}
masterNode.obtainData(ld, lastLoc, safeLoc, ld, new SafeCopyTransferable(), listener);
}
}
if (DEBUG) {
LOGGER.debug("Waiting for finishing saving copies for " + this.getName());
}
listener.enable();
try {
sem.acquire();
} catch (InterruptedException ex) {
LOGGER.error("Error waiting for files in resource " + getName() + " to get saved");
}
if (DEBUG) {
LOGGER.debug("Unique files saved for " + this.getName());
}
if (this.getType() != Type.SERVICE) {
shutdownExecutionManager();
if (Tracer.isActivated()) {
if (node.generatePackage()) {
getTracingPackageToMaster();
if (DEBUG) {
LOGGER.debug("Tracing package obtained for " + this.getName());
}
}
}
if (DEBUG) {
if (node.generateWorkersDebugInfo()) {
getWorkersDebugInfo();
LOGGER.debug("Workers Debug files obtained for " + this.getName());
}
}
}
}
use of es.bsc.compss.types.data.listener.SafeCopyListener in project compss by bsc-wdc.
the class COMPSsMaster method waitForCopyTofinish.
private void waitForCopyTofinish(Copy copy) {
Semaphore sem = new Semaphore(0);
SafeCopyListener currentCopylistener = new SafeCopyListener(sem);
copy.addEventListener(currentCopylistener);
currentCopylistener.addOperation();
currentCopylistener.enable();
try {
sem.acquire();
} catch (InterruptedException ex) {
ErrorManager.warn("Error waiting for files in resource " + getName() + " to get saved");
Thread.currentThread().interrupt();
}
if (DEBUG) {
LOGGER.debug("Copy " + copy.getName() + "(id: " + copy.getId() + ") is finished");
}
}
Aggregations