Search in sources :

Example 31 with Connection

use of org.ow2.proactive.authentication.Connection 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

SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)9 KeyException (java.security.KeyException)6 LoginException (javax.security.auth.login.LoginException)6 Test (org.junit.Test)6 CredData (org.ow2.proactive.authentication.crypto.CredData)5 Credentials (org.ow2.proactive.authentication.crypto.Credentials)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)4 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)4 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)3 PublicKey (java.security.PublicKey)3 JMXConnector (javax.management.remote.JMXConnector)3 JMXServiceURL (javax.management.remote.JMXServiceURL)3 RMException (org.ow2.proactive.resourcemanager.exception.RMException)3 JobId (org.ow2.proactive.scheduler.common.job.JobId)3 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)2 File (java.io.File)2 MBeanServerConnection (javax.management.MBeanServerConnection)2