use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class Resource method getTracingPackageToMaster.
private void getTracingPackageToMaster() {
COMPSsNode masterNode = Comm.getAppHost().getNode();
Semaphore sem = new Semaphore(0);
String fileName = getName() + "_compss_trace.tar.gz";
SimpleURI fileOriginURI = node.getCompletePath(DataType.FILE_T, fileName);
if (DEBUG) {
LOGGER.debug("Copying tracing package from : " + fileOriginURI.getPath() + ",to : " + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName);
}
TracingCopyListener tracingListener = new TracingCopyListener(sem);
tracingListener.addOperation();
// Source data location
DataLocation source;
try {
source = DataLocation.createLocation(this, fileOriginURI);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + fileOriginURI.getPath(), e);
return;
}
// Target data location
DataLocation tgt;
String targetPath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName;
try {
SimpleURI uri = new SimpleURI(targetPath);
tgt = DataLocation.createLocation(Comm.getAppHost(), uri);
} catch (Exception e) {
ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath);
return;
}
// Ask for data
masterNode.obtainData(new LogicalData("tracing" + this.getName()), source, tgt, new LogicalData("tracing" + this.getName()), new TracingCopyTransferable(), tracingListener);
tracingListener.enable();
try {
sem.acquire();
} catch (InterruptedException ex) {
LOGGER.error("Error waiting for tracing files in resource " + getName() + " to get saved");
}
if (DEBUG) {
LOGGER.debug("Removing " + this.getName() + " tracing temporary files");
}
File f = null;
try {
f = new File(source.getPath());
if (!f.delete()) {
LOGGER.error("Unable to remove tracing temporary files of node " + this.getName());
}
} catch (Exception e) {
LOGGER.error("Unable to remove tracing temporary files of node " + this.getName(), e);
}
}
use of es.bsc.compss.types.data.location.DataLocation 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.data.location.DataLocation 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.location.DataLocation in project compss by bsc-wdc.
the class NIOAdaptor method receivedValue.
@Override
public void receivedValue(Destination type, String dataId, Object object, List<DataRequest> achievedRequests) {
for (DataRequest dr : achievedRequests) {
MasterDataRequest mdr = (MasterDataRequest) dr;
Copy c = (Copy) mdr.getOperation();
DataLocation actualLocation = c.getSourceData().finishedCopy(c);
LogicalData tgtData = c.getTargetData();
if (tgtData != null) {
tgtData.addLocation(actualLocation);
if (object != null) {
tgtData.setValue(object);
}
}
c.end(DataOperation.OpEndState.OP_OK);
}
if (NIOTracer.isActivated()) {
NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
}
}
use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.
the class NIOAdaptor method copiedData.
@Override
public void copiedData(int transferGroupId) {
LOGGER.debug("Notifying copied Data to master");
LinkedList<Copy> copies = GROUP_TO_COPY.remove(transferGroupId);
if (copies == null) {
LOGGER.debug("No copies to process");
return;
}
for (Copy c : copies) {
LOGGER.debug("Treating copy " + c.getName());
if (!c.isRegistered()) {
LOGGER.debug("No registered copy " + c.getName());
continue;
}
DataLocation actualLocation = c.getSourceData().finishedCopy(c);
if (actualLocation != null) {
LOGGER.debug("Actual Location " + actualLocation.getPath());
} else {
LOGGER.debug("Actual Location is null");
}
LogicalData tgtData = c.getTargetData();
if (tgtData != null) {
LOGGER.debug("targetData is not null");
switch(actualLocation.getType()) {
case PERSISTENT:
LOGGER.debug("Persistent location no need to update location for " + tgtData.getName());
break;
case PRIVATE:
LOGGER.debug("Adding location:" + actualLocation.getPath() + " to " + tgtData.getName());
tgtData.addLocation(actualLocation);
break;
case SHARED:
LOGGER.debug("Shared location no need to update location for " + tgtData.getName());
break;
}
LOGGER.debug("Locations for " + tgtData.getName() + " are: " + tgtData.getURIs());
} else {
LOGGER.warn("No target Data defined for copy " + c.getName());
}
}
}
Aggregations