use of es.bsc.compss.types.uri.MultiURI in project compss by bsc-wdc.
the class ImmediateCopy method perform.
public void perform() {
Resource targetHost = ((LinkedList<Resource>) tgtLoc.getHosts()).getFirst();
LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - Copy file " + getName() + " to " + tgtLoc);
synchronized (srcData) {
if (tgtData != null) {
MultiURI u;
if ((u = srcData.alreadyAvailable(targetHost)) != null) {
setFinalTarget(u.getPath());
end(DataOperation.OpEndState.OP_OK);
LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - A copy of " + getName() + " is already present at " + targetHost + " on path " + u.getPath());
return;
}
Copy copyInProgress = null;
if ((copyInProgress = srcData.alreadyCopying(tgtLoc)) != null) {
String path = copyInProgress.tgtLoc.getURIInHost(targetHost).getPath();
setFinalTarget(path);
// The same operation is already in progress - no need to repeat it
end(DataOperation.OpEndState.OP_IN_PROGRESS);
// This group must be notified as well when the operation finishes
synchronized (copyInProgress.getEventListeners()) {
copyInProgress.addEventListeners(getEventListeners());
}
LOGGER.debug("THREAD " + Thread.currentThread().getName() + " - A copy to " + path + " is already in progress, skipping replication");
return;
}
}
srcData.startCopy(this, tgtLoc);
}
try {
LOGGER.debug("[InmediateCopy] Performing Inmediate specific Copy for " + getName());
specificCopy();
} catch (CopyException e) {
end(DataOperation.OpEndState.OP_FAILED, e);
return;
} finally {
DataLocation actualLocation;
synchronized (srcData) {
actualLocation = srcData.finishedCopy(this);
}
if (tgtData != null) {
synchronized (tgtData) {
tgtData.addLocation(actualLocation);
}
}
}
String path = tgtLoc.getURIInHost(targetHost).getPath();
setFinalTarget(path);
synchronized (srcData) {
end(DataOperation.OpEndState.OP_OK);
}
LOGGER.debug("[InmediateCopy] Inmediate Copy for " + getName() + " performed.");
}
use of es.bsc.compss.types.uri.MultiURI in project compss by bsc-wdc.
the class NIOWorkerNode method orderCopy.
private void orderCopy(DeferredCopy c) {
LOGGER.info("Order Copy for " + c.getSourceData());
Resource tgtRes = ((LinkedList<Resource>) c.getTargetLoc().getHosts()).getFirst();
LogicalData ld = c.getSourceData();
String path;
synchronized (ld) {
if (c.getTargetData() != null) {
MultiURI u = ld.alreadyAvailable(tgtRes);
if (u != null) {
path = u.getPath();
} else {
path = c.getTargetLoc().getURIInHost(tgtRes).getPath();
}
} else {
path = c.getTargetLoc().getURIInHost(tgtRes).getPath();
}
c.setProposedSource(new Data(ld));
LOGGER.debug("Setting final target in deferred copy " + path);
c.setFinalTarget(path);
// TODO: MISSING CHECK IF FILE IS ALREADY BEEN COPIED IN A SHARED LOCATION
ld.startCopy(c, c.getTargetLoc());
commManager.registerCopy(c);
}
c.end(DataOperation.OpEndState.OP_OK);
}
use of es.bsc.compss.types.uri.MultiURI in project compss by bsc-wdc.
the class NIOAdaptor method getObject.
@Override
public Object getObject(String name) throws SerializedObjectException {
LogicalData ld = Comm.getData(name);
Object o = ld.getValue();
// Check if the object has been serialized meanwhile
if (o == null) {
for (MultiURI loc : ld.getURIs()) {
if (!loc.getProtocol().equals(Protocol.OBJECT_URI) && loc.getHost().equals(Comm.getAppHost())) {
// The object is null because it has been serialized by the master, raise exception
throw new SerializedObjectException(name);
}
}
}
// 2- The object is really null (no exception thrown)
return o;
}
use of es.bsc.compss.types.uri.MultiURI in project compss by bsc-wdc.
the class LogicalData method loadFromStorage.
/**
* Loads the value of the LogicalData from a file
*
* @throws CannotLoadException
* @throws IOException
* @throws ClassNotFoundException
* @throws StorageException
* @throws UnstartedNodeException
*
* @throws Exception
*/
public synchronized void loadFromStorage() throws CannotLoadException {
if (value != null) {
// Value is already loaded in memory
return;
}
for (DataLocation loc : this.locations) {
switch(loc.getType()) {
case PRIVATE:
case SHARED:
// Get URI and deserialize object if possible
MultiURI u = loc.getURIInHost(Comm.getAppHost());
if (u == null) {
continue;
}
String path = u.getPath();
if (path.startsWith(File.separator)) {
try {
this.value = Serializer.deserialize(path);
} catch (ClassNotFoundException | IOException e) {
// Check next location since deserialization was invalid
this.value = null;
continue;
}
String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
SimpleURI uri = new SimpleURI(targetPath);
try {
DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
addLocation(tgtLoc);
} catch (IOException e) {
// Check next location since location was invalid
this.value = null;
continue;
}
}
return;
case PERSISTENT:
PersistentLocation pLoc = (PersistentLocation) loc;
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.Event.STORAGE_GETBYID.getId(), Tracer.Event.STORAGE_GETBYID.getType());
}
try {
this.value = StorageItf.getByID(pLoc.getId());
this.id = pLoc.getId();
} catch (StorageException se) {
// Check next location since cannot retrieve the object from the storage Back-end
continue;
} finally {
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.EVENT_END, Tracer.Event.STORAGE_GETBYID.getType());
}
}
String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
SimpleURI uri = new SimpleURI(targetPath);
try {
DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
addLocation(tgtLoc);
} catch (IOException e) {
// Check next location since location was invalid
this.value = null;
continue;
}
return;
}
}
// Any location has been able to load the value
throw new CannotLoadException("Object has not any valid location available in the master");
}
use of es.bsc.compss.types.uri.MultiURI in project compss by bsc-wdc.
the class Comm method dataDump.
/**
* Dumps the stored data (only for testing)
*
* @return
*/
public static synchronized String dataDump() {
StringBuilder sb = new StringBuilder("DATA DUMP\n");
for (Entry<String, LogicalData> lde : data.entrySet()) {
sb.append("\t *").append(lde.getKey()).append(":\n");
LogicalData ld = lde.getValue();
for (MultiURI u : ld.getURIs()) {
sb.append("\t\t + ").append(u.toString()).append("\n");
for (String adaptor : adaptors.keySet()) {
Object internal = null;
try {
internal = u.getInternalURI(adaptor);
if (internal != null) {
sb.append("\t\t\t - ").append(internal.toString()).append("\n");
}
} catch (UnstartedNodeException une) {
// Node was not started. Cannot print internal object.
}
}
}
}
return sb.toString();
}
Aggregations