use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.
the class RMTestUser method connect.
public void connect(TestUsers user, String rmUrl) throws RMException, KeyException, LoginException, ActiveObjectCreationException, NodeException {
this.connectedUserName = user.username;
this.connectedUserPassword = user.password;
this.rmUrl = rmUrl;
disconnectFromRM();
if (rmProxy == null) {
monitorsHandler = new RMMonitorsHandler();
RMMonitorEventReceiver passiveEventReceiver = new RMMonitorEventReceiver(monitorsHandler);
rmProxy = PAActiveObject.turnActive(passiveEventReceiver);
RMTHelper.log("RM Proxy initialized : " + PAActiveObject.getUrl(rmProxy));
}
RMTHelper.log("Connecting user " + connectedUserName + " to the Resource Manager at " + rmUrl);
CredData credData = new CredData(CredData.parseLogin(connectedUserName), CredData.parseDomain(connectedUserName), connectedUserPassword);
// this is to prevent starting working with the rmProxy on the calling
// thread whereas it has not finished to be initialized
PAFuture.waitFor(rmProxy.init(rmUrl, credData));
}
use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.
the class TerminationDataTest method testHandleTerminationForTaskNormalTermination.
@Test
public void testHandleTerminationForTaskNormalTermination() throws RMProxyCreationException, IOException, ClassNotFoundException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NORMAL, null);
terminationData.handleTermination(service);
Mockito.verify(proxiesManager, Mockito.times(1)).getUserRMProxy("user", null);
Mockito.verify(rmProxy, Mockito.times(1)).releaseNodes(org.mockito.Matchers.any(NodeSet.class), org.mockito.Matchers.any(org.ow2.proactive.scripting.Script.class), Mockito.any(VariablesMap.class), Mockito.any(HashMap.class), Mockito.any(TaskId.class), Mockito.any(Credentials.class));
}
use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelper method recoverJobTasks.
private void recoverJobTasks(InternalJob job, List<InternalTask> tasks, RMProxy rmProxy, ExecutorService recoverRunningTasksThreadPool) {
TaskStatusCounter counter = new TaskStatusCounter();
for (InternalTask task : tasks) {
// pending task
if ((task.getStatus() == TaskStatus.RUNNING || task.getStatus() == TaskStatus.PAUSED) && task.getExecuterInformation() != null) {
recoverRunningTaskAsynchronously(rmProxy, recoverRunningTasksThreadPool, counter, task);
} else {
recoverTaskOtherThanRunning(counter, task);
}
logger.debug("Task " + task.getId() + " status is " + task.getStatus().name());
}
this.jobsToUpdate.put(job.getId(), counter);
}
use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelper method recover.
public RecoveredSchedulerState recover(long loadJobPeriod, RMProxy rmProxy) {
List<InternalJob> notFinishedJobs = dbManager.loadNotFinishedJobs(true);
Vector<InternalJob> pendingJobs = new Vector<>();
Vector<InternalJob> runningJobs = new Vector<>();
ExecutorService recoverRunningTasksThreadPool = Executors.newFixedThreadPool(PASchedulerProperties.SCHEDULER_PARALLEL_SCHEDULER_STATE_RECOVER_NBTHREAD.getValueAsInt());
for (InternalJob job : notFinishedJobs) {
recoverJob(rmProxy, pendingJobs, runningJobs, job, recoverRunningTasksThreadPool);
}
recoverRunningTasksThreadPool.shutdown();
boolean terminatedWithoutTimeout;
try {
terminatedWithoutTimeout = recoverRunningTasksThreadPool.awaitTermination(PASchedulerProperties.SCHEDULER_PARALLEL_SCHEDULER_STATE_RECOVER_TIMEOUT.getValueAsInt(), TimeUnit.MINUTES);
} catch (InterruptedException e) {
logger.error("Interrupted while waiting for the Scheduler state to be recovered", e);
Thread.currentThread().interrupt();
throw new SchedulerStateNotRecoveredException(e);
}
failIfSchedulerStateRecoveryTimeout(terminatedWithoutTimeout);
applyJobUpdates(notFinishedJobs);
Vector<InternalJob> finishedJobs = new Vector<>();
for (Iterator<InternalJob> iterator = runningJobs.iterator(); iterator.hasNext(); ) {
InternalJob job = iterator.next();
try {
List<InternalTask> tasksList = copyAndSort(job.getITasks());
// simulate the running execution to recreate the tree.
for (InternalTask task : tasksList) {
job.recoverTask(task.getId());
}
if (job.getStatus() == JobStatus.PAUSED) {
job.setStatus(JobStatus.STALLED);
job.setPaused();
// update the count of pending and running task.
job.setNumberOfPendingTasks(job.getNumberOfPendingTasks() + job.getNumberOfRunningTasks());
job.setNumberOfRunningTasks(0);
}
} catch (Exception e) {
logger.error("Failed to recover job " + job.getId() + " " + job.getName() + " job might be in a inconsistent state", e);
jobLogger.error(job.getId(), "Failed to recover job, job might be in an inconsistent state", e);
// partially cancel job (not tasks) and move it to finished jobs to avoid running it
iterator.remove();
job.setStatus(JobStatus.CANCELED);
finishedJobs.add(job);
dbManager.updateJobAndTasksState(job);
}
}
finishedJobs.addAll(dbManager.loadFinishedJobs(false, loadJobPeriod));
logger.info("[Recovering counters] " + " Pending: " + pendingJobs.size() + " Running: " + runningJobs.size() + " Finished: " + finishedJobs.size());
return new RecoveredSchedulerState(pendingJobs, runningJobs, finishedJobs);
}
use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.
the class TestRMProxy method requestTooManyNodes.
private void requestTooManyNodes(RMProxy proxy, ResourceManager rm) throws Exception {
log("Request more nodes than RM has");
Criteria criteria = new Criteria(NODES_NUMBER + 1);
criteria.setBestEffort(false);
NodeSet nodeSet = proxy.getNodes(criteria);
PAFuture.waitFor(nodeSet);
assertEquals(0, nodeSet.size());
assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Aggregations