use of es.bsc.comm.Connection in project compss by bsc-wdc.
the class NIOWorker method tryNofiyDataReceived.
private boolean tryNofiyDataReceived(CommandDataReceived cdr) {
Connection c = TM.startConnection(masterNode);
c.sendCommand(cdr);
c.finishConnection();
return true;
}
use of es.bsc.comm.Connection in project compss by bsc-wdc.
the class NIOAgent method requestTransfers.
/**
* Check if receive slots available
*/
public void requestTransfers() {
DataRequest dr = null;
synchronized (pendingRequests) {
if (!pendingRequests.isEmpty() && tryAcquireReceiveSlot()) {
dr = pendingRequests.remove();
}
}
while (dr != null) {
Data source = dr.getSource();
NIOURI uri = source.getFirstURI();
if (NIOTracer.isActivated()) {
NIOTracer.emitDataTransferEvent(source.getName());
}
NIONode nn = uri.getHost();
if (nn.getIp() == null) {
nn = masterNode;
}
Connection c = null;
try {
c = TM.startConnection(nn);
LOGGER.debug("Connection " + c.hashCode() + " will be used to acquire data " + dr.getTarget() + " stored in " + nn + " with name " + dr.getSource().getName());
Data remoteData = new Data(source.getName(), uri);
CommandDataDemand cdd = new CommandDataDemand(this, remoteData, tracingID);
ongoingTransfers.put(c, dr.getSource().getName());
c.sendCommand(cdd);
if (NIOTracer.isActivated()) {
c.receive();
}
if (dr.getType() == DataType.FILE_T) {
c.receiveDataFile(dr.getTarget());
} else {
c.receiveDataObject();
}
} catch (Exception e) {
e.printStackTrace(System.err);
} finally {
if (c != null) {
c.finishConnection();
}
}
synchronized (pendingRequests) {
if (!pendingRequests.isEmpty() && tryAcquireReceiveSlot()) {
dr = pendingRequests.remove();
} else {
dr = null;
}
}
if (NIOTracer.isActivated()) {
NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
}
}
}
use of es.bsc.comm.Connection in project compss by bsc-wdc.
the class NIOWorkerNode method submitTask.
public void submitTask(NIOJob job, List<String> obsolete) throws UnstartedNodeException {
if (node == null) {
throw new UnstartedNodeException();
}
NIOTask t = job.prepareJob();
CommandNewTask cmd = new CommandNewTask(t, obsolete);
Connection c = NIOAgent.getTransferManager().startConnection(node);
c.sendCommand(cmd);
c.finishConnection();
}
use of es.bsc.comm.Connection in project compss by bsc-wdc.
the class NIOWorkerNode method generatePackage.
@Override
public boolean generatePackage() {
if (started) {
LOGGER.debug("Sending command to generated tracing package for " + this.getHost());
if (node == null) {
LOGGER.error("ERROR: Package generation for " + this.getHost() + " has failed.");
return false;
} else {
Connection c = NIOAgent.getTransferManager().startConnection(node);
CommandGeneratePackage cmd = new CommandGeneratePackage();
c.sendCommand(cmd);
c.receive();
c.finishConnection();
commManager.waitUntilTracingPackageGenerated();
LOGGER.debug("Tracing Package generated");
return true;
}
} else {
LOGGER.debug("Worker " + this.getHost() + " not started. No tracing package generated");
return false;
}
}
Aggregations