Search in sources :

Example 26 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class SchedulerRuntimeDataMBeanTest method testAsUser.

private void testAsUser() throws Exception {
    final SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
    final HashMap<String, Object> env = new HashMap<>(1);
    env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.USER.username, TestUsers.USER.password });
    JMXConnector userJmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI)), env);
    try {
        MBeanServerConnection connection = userJmxConnector.getMBeanServerConnection();
        final ObjectName beanName = new ObjectName(SchedulerJMXHelper.RUNTIMEDATA_MBEAN_NAME);
        RuntimeDataMBean bean = JMX.newMXBeanProxy(connection, beanName, RuntimeDataMBean.class);
        checkDataConsistent(bean);
    } finally {
        userJmxConnector.close();
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) HashMap(java.util.HashMap) JMXConnector(javax.management.remote.JMXConnector) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) RuntimeDataMBean(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBean) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 27 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface 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)22 Credentials (org.ow2.proactive.authentication.crypto.Credentials)15 CredData (org.ow2.proactive.authentication.crypto.CredData)13 KeyException (java.security.KeyException)7 PublicKey (java.security.PublicKey)7 Test (org.junit.Test)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)6 LoginException (javax.security.auth.login.LoginException)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 HashMap (java.util.HashMap)3 JMXConnector (javax.management.remote.JMXConnector)3 JMXServiceURL (javax.management.remote.JMXServiceURL)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 MBeanServerConnection (javax.management.MBeanServerConnection)2 ObjectName (javax.management.ObjectName)2 UserData (org.ow2.proactive.authentication.UserData)2 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)2 ConnectionException (org.ow2.proactive.scheduler.common.exception.ConnectionException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2