Search in sources :

Example 1 with RuntimeDataMBeanImpl

use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl in project scheduling by ow2-proactive.

the class RMJMXHelper method registerMBeans.

/**
 * {@inheritDoc}
 */
@Override
public void registerMBeans(final MBeanServer mbs) {
    // Register all mbeans into the server
    try {
        final RuntimeDataMBean anonymMBean = new RuntimeDataMBeanImpl(RMMonitoringImpl.rmStatistics);
        // Uniquely identify the MBean and register it to the MBeanServer
        final ObjectName name = new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME);
        mbs.registerMBean(anonymMBean, name);
        String dataBaseName = PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_RRD_DATABASE_NAME.getValueAsString());
        FileUtils.forceMkdir(new File(dataBaseName).getParentFile());
        setDataStore(new RRDDataStore((StandardMBean) anonymMBean, dataBaseName, PAResourceManagerProperties.RM_RRD_STEP.getValueAsInt(), Logger.getLogger(RMJMXHelper.class)));
    } catch (Exception e) {
        LOGGER.error("Unable to register the ResourceManagerRuntimeMBean", e);
    }
    // Register the MyAccount MBean into the MBean server
    try {
        final MyAccountMBeanImpl myAccountMBean = new MyAccountMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
        mbs.registerMBean(myAccountMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the MyAccountMBean", e);
    }
    // Register the ViewAccount MBean into the MBean server
    try {
        final AllAccountsMBeanImpl viewAccountMBean = new AllAccountsMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(RMJMXBeans.ALLACCOUNTS_MBEAN_NAME);
        mbs.registerMBean(viewAccountMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the AllAccountsMBean", e);
    }
    // Register the Management MBean into the MBean server
    try {
        final ManagementMBeanImpl managementMBean = new ManagementMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
        mbs.registerMBean(managementMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the ManagementMBean", e);
    }
}
Also used : AllAccountsMBeanImpl(org.ow2.proactive.resourcemanager.core.jmx.mbean.AllAccountsMBeanImpl) MyAccountMBeanImpl(org.ow2.proactive.resourcemanager.core.jmx.mbean.MyAccountMBeanImpl) RuntimeDataMBeanImpl(org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl) StandardMBean(javax.management.StandardMBean) ManagementMBeanImpl(org.ow2.proactive.resourcemanager.core.jmx.mbean.ManagementMBeanImpl) RRDDataStore(org.ow2.proactive.jmx.RRDDataStore) RuntimeDataMBean(org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBean) File(java.io.File) ObjectName(javax.management.ObjectName)

Example 2 with RuntimeDataMBeanImpl

use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendStateTest method getIdentifiedJobTest.

@Test
public void getIdentifiedJobTest() throws Exception {
    SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
    when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
    SchedulerStateImpl<ClientJobState> schedulerStateImpl = new SchedulerStateImpl<>();
    JobIdImpl jobId = new JobIdImpl(1234L, "job name");
    ClientJobState jobState = mock(ClientJobState.class);
    when(jobState.getId()).thenReturn(jobId);
    schedulerStateImpl.setFinishedJobs(new Vector(Lists.newArrayList(jobState)));
    final SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(schedulerStateImpl, mockJMX);
    assertEquals(schedulerFrontendState.getIdentifiedJob(jobId).getJobId(), (jobId));
}
Also used : SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Vector(java.util.Vector) Test(org.junit.Test)

Example 3 with RuntimeDataMBeanImpl

use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendStateTest method testLRUCache.

@Test
public void testLRUCache() throws Exception {
    SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
    when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
    SchedulerStateImpl<ClientJobState> schedulerStateImpl = new SchedulerStateImpl<>();
    final ClientJobState clientJobState0 = createClientJobState(10l);
    final ClientJobState clientJobState01 = createClientJobState(11l);
    final ClientJobState clientJobState1 = createClientJobState(1l);
    final ClientJobState clientJobState2 = createClientJobState(2l);
    schedulerStateImpl.setFinishedJobs(new Vector());
    schedulerStateImpl.setRunningJobs(new Vector(Lists.newArrayList(clientJobState1)));
    schedulerStateImpl.setPendingJobs(new Vector(Lists.newArrayList(clientJobState2)));
    SCHEDULER_FINISHED_JOBS_LRU_CACHE_SIZE.updateProperty("1");
    SchedulerDBManager dbManager = mock(SchedulerDBManager.class);
    SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(schedulerStateImpl, mockJMX, dbManager);
    InternalJob internalJob = spy(new InternalTaskFlowJob());
    JobInfoImpl jobInfo = mock(JobInfoImpl.class);
    doReturn(jobInfo).when(internalJob).getJobInfo();
    doReturn(clientJobState0.getId()).when(jobInfo).getJobId();
    doReturn(clientJobState0.getId()).when(internalJob).getId();
    doReturn(Collections.singletonList(internalJob)).when(dbManager).loadInternalJob(10l);
    InternalJob internalJob1 = spy(new InternalTaskFlowJob());
    JobInfoImpl jobInfo1 = mock(JobInfoImpl.class);
    doReturn(jobInfo1).when(internalJob1).getJobInfo();
    doReturn(clientJobState01.getId()).when(jobInfo1).getJobId();
    doReturn(clientJobState01.getId()).when(internalJob1).getId();
    doReturn(Collections.singletonList(internalJob1)).when(dbManager).loadInternalJob(11l);
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
    assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
    verify(dbManager, times(3)).loadInternalJob(anyLong());
}
Also used : SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) Vector(java.util.Vector) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Test(org.junit.Test)

Example 4 with RuntimeDataMBeanImpl

use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendStateTest method session_removal_should_not_throw_concurrent_modification_exception.

// SCHEDULING-2242
@Test
public void session_removal_should_not_throw_concurrent_modification_exception() throws Exception {
    PASchedulerProperties.SCHEDULER_USER_SESSION_TIME.updateProperty("1");
    SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
    when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
    final SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(new SchedulerStateImpl<ClientJobState>(), mockJMX);
    // create a bunch of active sessions, they will be removed in 1s
    for (int i = 0; i < 100; i++) {
        UserIdentificationImpl identification = new UserIdentificationImpl("john");
        identification.setHostName("localhost");
        schedulerFrontendState.connect(new UniqueID("abc" + i), identification, null);
    }
    // use the FrontendState continuously to query the active sessions
    ExecutorService executor = Executors.newFixedThreadPool(1);
    Future<Object> noException = executor.submit(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            for (; ; ) {
                schedulerFrontendState.getUsers();
            }
        }
    });
    try {
        noException.get(2, TimeUnit.SECONDS);
    } catch (ExecutionException e) {
        fail("Should exit with timeout exception " + e.getMessage());
    } catch (TimeoutException e) {
    // expected timeout exception after two seconds
    } finally {
        executor.shutdownNow();
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) ExecutorService(java.util.concurrent.ExecutorService) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 5 with RuntimeDataMBeanImpl

use of org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl in project scheduling by ow2-proactive.

the class SchedulerJMXHelper method registerMBeans.

/**
 * {@inheritDoc}
 */
@Override
public void registerMBeans(final MBeanServer mbs) {
    // Register the Scheduler runtime MBean into the MBean server
    try {
        this.schedulerRuntimeMBean = new RuntimeDataMBeanImpl(dbManager);
        final ObjectName name = new ObjectName(RUNTIMEDATA_MBEAN_NAME);
        mbs.registerMBean(this.schedulerRuntimeMBean, name);
        String dataBaseName = PASchedulerProperties.SCHEDULER_HOME.getValueAsString() + System.getProperty("file.separator") + PASchedulerProperties.SCHEDULER_RRD_DATABASE_NAME.getValueAsString();
        FileUtils.forceMkdir(new File(dataBaseName).getParentFile());
        if (PASchedulerProperties.SCHEDULER_DB_HIBERNATE_DROPDB.getValueAsBoolean()) {
            // dropping the RDD data base
            File rrdDataBase = new File(dataBaseName);
            if (rrdDataBase.exists()) {
                rrdDataBase.delete();
            }
        }
        setDataStore(new RRDDataStore((StandardMBean) schedulerRuntimeMBean, dataBaseName, PASchedulerProperties.SCHEDULER_RRD_STEP.getValueAsInt(), Logger.getLogger(SchedulerJMXHelper.class)));
    } catch (Exception e) {
        LOGGER.error("Unable to register the RuntimeDataMBean", e);
    }
    // Register the MyAccount MBean into the MBean server
    try {
        final MyAccountMBeanImpl myAccountMBean = new MyAccountMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(MYACCOUNT_MBEAN_NAME);
        mbs.registerMBean(myAccountMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the MyAccountMBean", e);
    }
    // Register the ViewAccount MBean into the MBean server
    try {
        final AllAccountsMBeanImpl viewAccountMBean = new AllAccountsMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(ALLACCOUNTS_MBEAN_NAME);
        mbs.registerMBean(viewAccountMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the AllAccountsMBean", e);
    }
    // Register the Management MBean into the MBean server
    try {
        final ManagementMBeanImpl managementMBean = new ManagementMBeanImpl(this.accountsManager);
        final ObjectName name = new ObjectName(MANAGEMENT_MBEAN_NAME);
        mbs.registerMBean(managementMBean, name);
    } catch (Exception e) {
        LOGGER.error("Unable to register the ManagementMBean", e);
    }
}
Also used : AllAccountsMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.AllAccountsMBeanImpl) MyAccountMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.MyAccountMBeanImpl) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) StandardMBean(javax.management.StandardMBean) ManagementMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.ManagementMBeanImpl) RRDDataStore(org.ow2.proactive.jmx.RRDDataStore) File(java.io.File) ObjectName(javax.management.ObjectName)

Aggregations

RuntimeDataMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl)4 Test (org.junit.Test)3 SchedulerJMXHelper (org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper)3 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)3 File (java.io.File)2 Vector (java.util.Vector)2 ObjectName (javax.management.ObjectName)2 StandardMBean (javax.management.StandardMBean)2 RRDDataStore (org.ow2.proactive.jmx.RRDDataStore)2 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 UniqueID (org.objectweb.proactive.core.UniqueID)1 AllAccountsMBeanImpl (org.ow2.proactive.resourcemanager.core.jmx.mbean.AllAccountsMBeanImpl)1 ManagementMBeanImpl (org.ow2.proactive.resourcemanager.core.jmx.mbean.ManagementMBeanImpl)1 MyAccountMBeanImpl (org.ow2.proactive.resourcemanager.core.jmx.mbean.MyAccountMBeanImpl)1 RuntimeDataMBean (org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBean)1 RuntimeDataMBeanImpl (org.ow2.proactive.resourcemanager.core.jmx.mbean.RuntimeDataMBeanImpl)1 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)1 AllAccountsMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.AllAccountsMBeanImpl)1