use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBean in project scheduling by ow2-proactive.
the class SchedulerRuntimeDataMBeanTest method checkJobData.
private void checkJobData(RuntimeDataMBean bean, JobId jobId) throws Exception {
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
long pendingTime = bean.getJobPendingTime(jobId.value());
long runningTime = bean.getJobRunningTime(jobId.value());
assertEquals("Unexpected pending time", jobState.getStartTime() - jobState.getSubmittedTime(), pendingTime);
assertEquals("Unexpected running time", jobState.getFinishedTime() - jobState.getStartTime(), runningTime);
assertEquals("Unexpected nodes number", 1, bean.getTotalNumberOfNodesUsed(jobId.value()));
bean.getMeanTaskPendingTime(jobId.value());
bean.getMeanTaskRunningTime(jobId.value());
}
use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBean in project scheduling by ow2-proactive.
the class SchedulerRuntimeDataMBeanTest method testAsAdmin.
private void testAsAdmin() throws Exception {
final SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
final HashMap<String, Object> env = new HashMap<>(1);
env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.DEMO.username, TestUsers.DEMO.password });
JMXConnector adminJmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI)), env);
List<JobInfo> existingFinishedJobs = schedulerHelper.getSchedulerInterface().getJobs(0, 1000, new JobFilterCriteria(false, false, true, true), null).getList();
int nbFinishedTasks = 0;
int nbTotalTasks = 0;
for (JobInfo existingFinishedJob : existingFinishedJobs) {
nbFinishedTasks += existingFinishedJob.getNumberOfFinishedTasks();
nbTotalTasks += existingFinishedJob.getTotalNumberOfTasks();
}
try {
MBeanServerConnection connection = adminJmxConnector.getMBeanServerConnection();
final ObjectName beanName = new ObjectName(SchedulerJMXHelper.RUNTIMEDATA_MBEAN_NAME);
RuntimeDataMBean bean = JMX.newMXBeanProxy(connection, beanName, RuntimeDataMBean.class);
checkDataConsistent(bean);
JobId jobId;
jobId = schedulerHelper.submitJob(createJobWithFailingTask());
schedulerHelper.waitForEventTaskWaitingForRestart(jobId, "task1");
checkDataConsistent(bean);
schedulerHelper.waitForEventTaskWaitingForRestart(jobId, "task1");
checkDataConsistent(bean);
schedulerHelper.waitForEventJobFinished(jobId, 60000);
checkDataConsistent(bean);
checkTasksData(bean, 0, 0, 1 + nbFinishedTasks, 1 + nbTotalTasks);
checkJobData(bean, jobId);
jobId = schedulerHelper.submitJob(createJobWithMultinodeTask(100));
Thread.sleep(5000);
checkDataConsistent(bean);
checkTasksData(bean, 1, 0, 1 + nbFinishedTasks, 2 + nbTotalTasks);
schedulerHelper.getSchedulerInterface().killJob(jobId);
checkDataConsistent(bean);
checkTasksData(bean, 0, 0, 1 + nbFinishedTasks, 2 + nbTotalTasks);
} finally {
adminJmxConnector.close();
}
}
Aggregations