use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class Tracer method transferMasterPackage.
private static void transferMasterPackage() {
if (DEBUG) {
LOGGER.debug("Tracing: Transferring master package");
}
// Create source and target locations for tar.gz file
String filename = "master_compss_trace.tar.gz";
DataLocation source = null;
String sourcePath = DataLocation.Protocol.FILE_URI.getSchema() + filename;
try {
SimpleURI uri = new SimpleURI(sourcePath);
source = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + sourcePath, e);
}
DataLocation target = null;
String targetPath = DataLocation.Protocol.FILE_URI.getSchema() + traceDirPath + filename;
try {
SimpleURI uri = new SimpleURI(targetPath);
target = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
}
// Ask for data
Semaphore sem = new Semaphore(0);
TracingCopyListener tracingListener = new TracingCopyListener(sem);
tracingListener.addOperation();
Comm.getAppHost().getNode().obtainData(new LogicalData("tracing master package"), source, target, new LogicalData("tracing master package"), new TracingCopyTransferable(), tracingListener);
// Wait for data
tracingListener.enable();
try {
sem.acquire();
} catch (InterruptedException ex) {
ErrorManager.warn("Error waiting for tracing files in master to get saved");
}
}
use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class Tracer method cleanMasterPackage.
private static void cleanMasterPackage() {
String filename = DataLocation.Protocol.FILE_URI.getSchema() + "master_compss_trace.tar.gz";
String filePath;
try {
SimpleURI uri = new SimpleURI(filename);
filePath = new File(uri.getPath()).getCanonicalPath();
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + filename, e);
return;
}
if (DEBUG) {
LOGGER.debug("Tracing: Removing tracing master package: " + filePath);
}
File f;
try {
f = new File(filePath);
boolean deleted = f.delete();
if (!deleted) {
ErrorManager.warn("Unable to remove tracing temporary files of master node.");
} else if (DEBUG) {
LOGGER.debug("Deleted master tracing package.");
}
} catch (Exception e) {
ErrorManager.warn("Exception while trying to remove tracing temporary " + "files of master node.", e);
}
}
use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class SimpleURITest method objectURIs.
@Test
public void objectURIs() {
logger.info("Begin Object URI Test");
SimpleURI fileURI = new SimpleURI("object://d1v1RAND.IT");
assertEquals("File Schema", fileURI.getSchema(), "object://");
assertEquals("File Host", fileURI.getHost(), "");
assertEquals("File Path", fileURI.getPath(), "d1v1RAND.IT");
SimpleURI fileURI2 = new SimpleURI("object://localhost@d1v1RAND.IT");
assertEquals("File Schema", fileURI2.getSchema(), "object://");
assertEquals("File Host", fileURI2.getHost(), "localhost");
assertEquals("File Path", fileURI2.getPath(), "d1v1RAND.IT");
}
use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class SimpleURITest method fileURIs.
/*
* ***************************************************************
* CONSTRUCTOR TESTS
* **************************************************************
*/
@Test
public void fileURIs() {
logger.info("Begin File URI Test");
SimpleURI fileURI = new SimpleURI("file:///home/compss/.COMPSs/file.IT");
assertEquals("File Schema", fileURI.getSchema(), "file://");
assertEquals("File Host", fileURI.getHost(), "");
assertEquals("File Path", fileURI.getPath(), "/home/compss/.COMPSs/file.IT");
SimpleURI fileURI2 = new SimpleURI("file://localhost@/home/compss/.COMPSs/remoteFile.IT");
assertEquals("File Schema", fileURI2.getSchema(), "file://");
assertEquals("File Host", fileURI2.getHost(), "localhost");
assertEquals("File Path", fileURI2.getPath(), "/home/compss/.COMPSs/remoteFile.IT");
}
use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.
the class LogicalData method writeToStorage.
/**
* Writes memory value to file
*
* @throws Exception
*/
public synchronized void writeToStorage() throws IOException {
if (this.id != null) {
// It is a persistent object that is already persisted
// Nothing to do
// If the PSCO is not persisted we treat it as a normal object
} else {
// The object must be written to file
String targetPath = Comm.getAppHost().getWorkingDirectory() + this.name;
Serializer.serialize(value, targetPath);
String targetPathWithSchema = Protocol.FILE_URI.getSchema() + targetPath;
SimpleURI targetURI = new SimpleURI(targetPathWithSchema);
DataLocation loc = DataLocation.createLocation(Comm.getAppHost(), targetURI);
this.isBeingSaved = false;
this.locations.add(loc);
for (Resource r : loc.getHosts()) {
switch(loc.getType()) {
case PRIVATE:
r.addLogicalData(this);
break;
case SHARED:
SharedDiskManager.addLogicalData(loc.getSharedDisk(), this);
break;
case PERSISTENT:
// Nothing to do
break;
}
}
}
}
Aggregations