use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RestSmartProxyImpl method uploadInputfiles.
/**
* @throws NotConnectedException
* @throws PermissionException
* @see AbstractSmartProxy#uploadInputfiles(TaskFlowJob, String)
*/
@Override
public boolean uploadInputfiles(TaskFlowJob job, String localInputFolderPath) throws NotConnectedException, PermissionException {
String userSpace = getLocalUserSpace();
String inputSpace = job.getInputSpace();
if (!inputSpace.startsWith(userSpace)) {
// NOTE: only works for USERSPACE urls
logger.warn("RestSmartProxy does not support data transfers outside USERSPACE.");
return false;
}
String remotePath = inputSpace.substring(userSpace.length() + (userSpace.endsWith("/") ? 0 : 1));
String jname = job.getName();
logger.debug("Pushing files for job " + jname + " from " + localInputFolderPath + " to " + remotePath);
TaskFlowJob tfj = job;
for (Task t : tfj.getTasks()) {
logger.debug("Pushing files for task " + t.getName());
List<String> includes = Lists.newArrayList();
List<String> excludes = Lists.newArrayList();
List<InputSelector> inputFilesList = t.getInputFilesList();
if (inputFilesList != null) {
for (InputSelector is : inputFilesList) {
addfileSelection(is.getInputFiles(), includes, excludes);
}
}
LocalDirSource source = new LocalDirSource(localInputFolderPath);
source.setIncludes(includes);
source.setExcludes(excludes);
RemoteDestination dest = new RemoteDestination(USER, remotePath);
restDataSpaceClient.upload(source, dest);
}
logger.debug("Finished push operation from " + localInputFolderPath + " to " + remotePath);
return true;
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RestSmartProxyImpl method createFolder.
@Override
protected void createFolder(String fUri) throws NotConnectedException, PermissionException {
RemoteSource remoteSource = new RemoteSource(USER, fUri);
remoteSource.setType(FileType.FOLDER);
restDataSpaceClient.create(remoteSource);
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RestSmartProxyImpl method removeJobIO.
@Override
protected void removeJobIO(Job job, String pushURL, String pullURL, String newFolderName) {
pushURL = pushURL + "/" + newFolderName;
RemoteSource remoteSource = new RemoteSource(IDataSpaceClient.Dataspace.USER, pushURL);
try {
restDataSpaceClient.delete(remoteSource);
} catch (NotConnectedException | PermissionException e) {
logger.debug("Error in removeJobIO push for job " + job.getName());
}
pullURL = pullURL + "/" + newFolderName;
remoteSource.setPath(pullURL);
try {
restDataSpaceClient.delete(remoteSource);
} catch (NotConnectedException | PermissionException e) {
logger.debug("Error in removeJobIO pull for job " + job.getName());
}
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RestSmartProxyTest method waitForJobFinishState.
private JobState waitForJobFinishState(String jobIdAsString) throws InterruptedException, NotConnectedException, UnknownJobException, PermissionException {
JobState jobState = restSmartProxy.getJobState(jobIdAsString);
Thread.sleep(ONE_SECOND);
while (jobState.getStatus().isJobAlive()) {
jobState = restSmartProxy.getJobState(jobIdAsString);
Thread.sleep(ONE_SECOND);
}
return jobState;
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMCore method setBusyNode.
/**
* Set a node state to busy. Set the node to busy, and move the node to the
* internal busy nodes list. An event informing the node state's change is
* thrown to RMMonitoring.
*
* @param owner
* @param nodeUrl node to set
*/
public void setBusyNode(final String nodeUrl, Client owner) throws NotConnectedException {
final RMNode rmNode = this.allNodes.get(nodeUrl);
if (rmNode == null) {
logger.error("Unknown node " + nodeUrl);
return;
}
if (!clients.containsKey(owner.getId())) {
logger.warn(nodeUrl + " cannot set busy as the client disconnected " + owner);
throw new NotConnectedException("Client " + owner + " is not connected to the resource manager");
}
// If the node is already busy no need to go further
if (rmNode.isBusy()) {
return;
}
// Get the previous state of the node needed for the event
final NodeState previousNodeState = rmNode.getState();
rmNode.setBusy(owner);
this.eligibleNodes.remove(rmNode);
persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
// create the event
this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, owner.getName()));
}
Aggregations