use of es.bsc.compss.exceptions.CopyException in project compss by bsc-wdc.
the class GATCopy method specificCopy.
@Override
public void specificCopy() throws CopyException {
LOGGER.debug(DBG_PREFIX + "Performing GAT Specific Copy for " + getName());
// Fetch valid destination URIs
List<MultiURI> targetURIs = tgtLoc.getURIs();
List<URI> selectedTargetURIs = new LinkedList<>();
for (MultiURI uri : targetURIs) {
try {
URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
if (internalURI != null) {
selectedTargetURIs.add(internalURI);
}
} catch (UnstartedNodeException une) {
throw new GATCopyException(une);
}
}
if (selectedTargetURIs.isEmpty()) {
LOGGER.error(DBG_PREFIX + ERR_NO_TGT_URI);
throw new GATCopyException(ERR_NO_TGT_URI);
}
LOGGER.debug(DBG_PREFIX + "Selected target URIs");
// Fetch valid source URIs
List<MultiURI> sourceURIs;
List<URI> selectedSourceURIs = new LinkedList<>();
synchronized (srcData) {
if (srcLoc != null) {
sourceURIs = srcLoc.getURIs();
for (MultiURI uri : sourceURIs) {
try {
URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
if (internalURI != null) {
selectedSourceURIs.add(internalURI);
}
} catch (UnstartedNodeException une) {
LOGGER.error(DBG_PREFIX + "Exception selecting source URI");
throw new GATCopyException(une);
}
}
}
sourceURIs = srcData.getURIs();
for (MultiURI uri : sourceURIs) {
try {
URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
if (internalURI != null) {
selectedSourceURIs.add(internalURI);
}
} catch (UnstartedNodeException une) {
LOGGER.error(DBG_PREFIX + "Exception selecting source URI for " + getName());
throw new GATCopyException(une);
}
}
if (selectedSourceURIs.isEmpty()) {
if (srcData.isInMemory()) {
LOGGER.debug("Data for " + getName() + " is in memory");
try {
srcData.writeToStorage();
sourceURIs = srcData.getURIs();
for (MultiURI uri : sourceURIs) {
URI internalURI = (URI) uri.getInternalURI(GATAdaptor.ID);
if (internalURI != null) {
selectedSourceURIs.add(internalURI);
}
}
} catch (Exception e) {
LOGGER.fatal("Exception writing object to file.", e);
throw new GATCopyException(ERR_NO_SRC_URI);
}
} else {
LOGGER.error(DBG_PREFIX + ERR_NO_SRC_URI);
throw new GATCopyException(ERR_NO_SRC_URI);
}
}
}
GATInvocationException exception = new GATInvocationException("default logical file");
for (URI src : selectedSourceURIs) {
for (URI tgt : selectedTargetURIs) {
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("GATCopy From: " + src + " to " + tgt);
}
// Source and target URIs contain Runtime information (schema)
// Convert it to GAT format
URI gatSrc = new URI(DataLocation.Protocol.ANY_URI.getSchema() + src.getHost() + "/" + src.getPath());
URI gatTgt = new URI(DataLocation.Protocol.ANY_URI.getSchema() + tgt.getHost() + "/" + tgt.getPath());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("GATCopy From: " + gatSrc + " to " + gatTgt);
}
doCopy(gatSrc, gatTgt);
// Try to copy from each location until successful
} catch (Exception e) {
exception.add("default logical file", e);
LOGGER.warn("Error copying file", e);
continue;
}
return;
}
}
if (!(this.reason instanceof WorkersDebugInfoCopyTransferable)) {
ErrorManager.error("File '" + srcData.getName() + "' could not be copied because it does not exist.", exception);
}
throw new GATCopyException(exception);
}
use of es.bsc.compss.exceptions.CopyException 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.");
}
Aggregations