use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getTaskState.
synchronized TaskState getTaskState(JobId jobId, TaskId taskId) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
if (jobsMap.get(jobId) == null) {
throw new UnknownJobException(jobId);
}
JobState jobState = jobsMap.get(jobId);
synchronized (jobState) {
TaskState ts = jobState.getHMTasks().get(taskId);
if (ts == null) {
throw new UnknownTaskException(taskId, jobId);
}
return ts;
}
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class AuthenticationTest method loginAsAdmin.
private void loginAsAdmin(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
log("Test 1");
log("Trying to authorized as an admin with correct user name and password");
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), pubKey);
Scheduler admin = auth.login(cred);
String userName = admin.getCurrentUser();
Assert.assertEquals(TestUsers.DEMO.username, userName);
UserData userData = admin.getCurrentUserData();
Assert.assertNotNull(userData);
Assert.assertNotNull(userData.getUserName());
Assert.assertNotNull(userData.getGroups());
Assert.assertTrue(userData.getGroups().contains("admin"));
admin.disconnect();
log("Passed: successful authentication");
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerUsageTest method fallbackToMyAccountUsage.
private void fallbackToMyAccountUsage(Scheduler scheduler) throws NotConnectedException, PermissionException {
List<JobUsage> asAUser = scheduler.getMyAccountUsage(new Date(0), new Date(0));
assertNotNull(asAUser);
// fallback to my account usage
List<JobUsage> forMyUser = scheduler.getAccountUsage(TestUsers.USER.username, new Date(0), new Date(0));
assertNotNull(forMyUser);
try {
scheduler.getAccountUsage(TestUsers.DEMO.username, new Date(0), new Date(0));
fail("Should throw permission exception");
} catch (PermissionException e) {
}
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class AbstractSmartProxy method syncAwaitedJob.
/**
* This method will synchronize this proxy with a remote Scheduler for the
* given job
*
* @param id job ID
*/
private void syncAwaitedJob(String id) {
AwaitedJob awaitedJob = jobTracker.getAwaitedJob(id);
try {
JobState js = getJobState(id);
for (TaskState ts : js.getTasks()) {
String tname = ts.getName();
AwaitedTask at = awaitedJob.getAwaitedTask(tname);
if ((at != null) && (!at.isTransferring())) {
TaskResult tres = null;
try {
tres = getTaskResult(id, tname);
if (tres != null) {
log.debug("Synchonizing task " + tname + " of job " + id);
taskStateUpdatedEvent(new NotificationData<>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, ts.getTaskInfo()));
}
} catch (NotConnectedException e) {
e.printStackTrace();
} catch (UnknownJobException e) {
log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
} catch (UnknownTaskException e) {
log.error("Could not retrieve output data for task " + tname + " of job " + id + " because this task is not known by the Scheduler. \n ", e);
} catch (Exception e) {
log.error("Unexpected error while getting the output data for task " + tname + " of job " + id, e);
}
}
}
if (js.isFinished()) {
jobStateUpdatedEvent(new NotificationData<>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, js.getJobInfo()));
}
} catch (NotConnectedException e) {
log.error("A connection error occured while trying to download output data of Job " + id + ". This job will remain in the list of awaited jobs. Another attempt to dowload the output data will be made next time the application is initialized. ", e);
} catch (UnknownJobException e) {
log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
log.warn("Job " + id + " will be removed from the known job list. The system will not attempt again to retrieve data for this job. You could try to manually copy the data from the location " + awaitedJob.getPullURL());
jobTracker.removeAwaitedJob(id);
} catch (PermissionException e) {
log.error("Could not retrieve output data for job " + id + " because you don't have permmission to access this job. You need to use the same connection credentials you used for submitting the job. \n Another attempt to dowload the output data for this job will be made next time the application is initialized. ", e);
}
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskIds.
@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
RestPageParameters params = new RestPageParameters(frontendState, "getTaskIds", from, to, mytasks, running, pending, finished, offset, limit, taskTag, SortSpecifierContainer.EMPTY_CONTAINER);
Page<TaskInfo> pTaskInfo;
pTaskInfo = dbManager.getTasks(params.getFrom(), params.getTo(), params.getTag(), params.getOffset(), params.getLimit(), params.getUserName(), params.isPending(), params.isRunning(), params.isFinished());
List<TaskId> lTaskId = new ArrayList<TaskId>(pTaskInfo.getList().size());
for (TaskInfo taskInfo : pTaskInfo.getList()) {
lTaskId.add(taskInfo.getTaskId());
}
return new Page<TaskId>(lTaskId, pTaskInfo.getSize());
}
Aggregations