use of es.bsc.compss.types.data.LogicalData in project compss by bsc-wdc.
the class NIOWorkerNode method orderStorageCopy.
private void orderStorageCopy(StorageCopy sc) {
LOGGER.info("Order PSCO Copy for " + sc.getSourceData().getName());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("LD Target " + sc.getTargetData());
LOGGER.debug("FROM: " + sc.getPreferredSource());
LOGGER.debug("TO: " + sc.getTargetLoc());
LOGGER.debug("MUST PRESERVE: " + sc.mustPreserveSourceData());
}
LogicalData source = sc.getSourceData();
LogicalData target = sc.getTargetData();
if (target != null) {
if (target.getName().equals(source.getName())) {
// The source and target are the same --> IN
newReplica(sc);
} else {
// The source and target are different --> OUT
newVersion(sc);
}
} else {
// Target doesn't exist yet --> INOUT
newVersion(sc);
}
}
use of es.bsc.compss.types.data.LogicalData in project compss by bsc-wdc.
the class NIOWorkerNode method sendData.
@Override
public void sendData(LogicalData ld, DataLocation source, DataLocation target, LogicalData tgtData, Transferable reason, EventListener listener) {
if (target.getHosts().contains(Comm.getAppHost())) {
// Order petition directly
if (tgtData != null) {
MultiURI u = ld.alreadyAvailable(Comm.getAppHost());
if (u != null) {
// Already present at the master
reason.setDataTarget(u.getPath());
listener.notifyEnd(null);
return;
}
}
Copy c = new DeferredCopy(ld, null, target, tgtData, reason, listener);
Data d = new Data(ld);
if (source != null) {
for (MultiURI uri : source.getURIs()) {
try {
NIOURI nURI = (NIOURI) uri.getInternalURI(NIOAdaptor.ID);
if (nURI != null) {
d.getSources().add(nURI);
}
} catch (UnstartedNodeException une) {
// Ignore internal URI
}
}
}
String path = target.getURIInHost(Comm.getAppHost()).getPath();
c.setFinalTarget(path);
ld.startCopy(c, c.getTargetLoc());
DataRequest dr = new MasterDataRequest(c, reason.getType(), d, path);
commManager.addTransferRequest(dr);
commManager.requestTransfers();
} else {
// Request to any other
orderCopy(new DeferredCopy(ld, source, target, tgtData, reason, listener));
}
}
use of es.bsc.compss.types.data.LogicalData in project compss by bsc-wdc.
the class NIOWorkerNode method newReplica.
private void newReplica(StorageCopy sc) {
String targetHostname = this.getName();
LogicalData srcLD = sc.getSourceData();
LogicalData targetLD = sc.getTargetData();
LOGGER.debug("Ask for new Replica of " + srcLD.getName() + " to " + targetHostname);
// Get the PSCO to replicate
String pscoId = srcLD.getId();
// Get the current locations
List<String> currentLocations = new LinkedList<>();
try {
currentLocations = StorageItf.getLocations(pscoId);
} catch (StorageException se) {
// Cannot obtain current locations from back-end
sc.end(OpEndState.OP_FAILED, se);
return;
}
if (!currentLocations.contains(targetHostname)) {
// Perform replica
LOGGER.debug("Performing new replica for PSCO " + pscoId);
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.Event.STORAGE_NEWREPLICA.getId(), NIOTracer.Event.STORAGE_NEWREPLICA.getType());
}
try {
// TODO: WARN New replica is NOT necessary because we can't prefetch data
// StorageItf.newReplica(pscoId, targetHostname);
} finally {
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.EVENT_END, NIOTracer.Event.STORAGE_NEWREPLICA.getType());
}
}
} else {
LOGGER.debug("PSCO " + pscoId + " already present. Skip replica.");
}
// Update information
sc.setFinalTarget(pscoId);
if (targetLD != null) {
targetLD.setId(pscoId);
}
// Notify successful end
sc.end(OpEndState.OP_OK);
}
use of es.bsc.compss.types.data.LogicalData in project compss by bsc-wdc.
the class NIOAdaptor method submitTask.
protected static void submitTask(NIOJob job) throws Exception {
LOGGER.debug("NIO submitting new job " + job.getJobId());
Resource res = job.getResource();
NIOWorkerNode worker = (NIOWorkerNode) res.getNode();
LogicalData[] obsoletes = res.pollObsoletes();
List<String> obsoleteRenamings = new LinkedList<>();
for (LogicalData ld : obsoletes) {
obsoleteRenamings.add(worker.getWorkingDir() + File.separator + ld.getName());
}
RUNNING_JOBS.put(job.getJobId(), job);
worker.submitTask(job, obsoleteRenamings);
}
use of es.bsc.compss.types.data.LogicalData in project compss by bsc-wdc.
the class Resource method getData.
/**
* Retrieves a given data
*
* @param dataId
* @param target
* @param reason
* @param listener
*/
public void getData(String dataId, DataLocation target, Transferable reason, EventListener listener) {
LogicalData srcData = Comm.getData(dataId);
getData(srcData, target, srcData, reason, listener);
}
Aggregations