Search in sources :

Example 6 with JobFilterCriteria

use of org.ow2.proactive.scheduler.common.JobFilterCriteria 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();
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JobFilterCriteria(org.ow2.proactive.scheduler.common.JobFilterCriteria) HashMap(java.util.HashMap) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) RuntimeDataMBean(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBean) ObjectName(javax.management.ObjectName) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JMXConnector(javax.management.remote.JMXConnector) MBeanServerConnection(javax.management.MBeanServerConnection) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JobFilterCriteria (org.ow2.proactive.scheduler.common.JobFilterCriteria)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)4 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)4 ArrayList (java.util.ArrayList)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)3 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)3 HashMap (java.util.HashMap)2 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)2 UserJobData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.UserJobData)2 MBeanServerConnection (javax.management.MBeanServerConnection)1 ObjectName (javax.management.ObjectName)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 GZIP (org.jboss.resteasy.annotations.GZIP)1 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)1