Search in sources :

Example 1 with ManagementServiceImpl

use of org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl in project activemq-artemis by apache.

the class ActiveMQServerImpl method initialisePart1.

/**
 * Starts everything apart from RemotingService and loading the data.
 * <p>
 * After optional intermediary steps, Part 1 is meant to be followed by part 2
 * {@link #initialisePart2(boolean)}.
 *
 * @param scalingDown
 */
synchronized boolean initialisePart1(boolean scalingDown) throws Exception {
    if (state == SERVER_STATE.STOPPED)
        return false;
    if (configuration.getJournalType() == JournalType.ASYNCIO) {
        if (!AIOSequentialFileFactory.isSupported()) {
            ActiveMQServerLogger.LOGGER.switchingNIO();
            configuration.setJournalType(JournalType.NIO);
        } else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) {
            ActiveMQServerLogger.LOGGER.switchingNIOonPath(configuration.getJournalLocation().getAbsolutePath());
            configuration.setJournalType(JournalType.NIO);
        }
    }
    managementService = new ManagementServiceImpl(mbeanServer, configuration);
    if (configuration.getMemoryMeasureInterval() != -1) {
        memoryManager = new MemoryManager(configuration.getMemoryWarningThreshold(), configuration.getMemoryMeasureInterval());
        memoryManager.start();
    }
    // Create the hard-wired components
    callPreActiveCallbacks();
    // startReplication();
    storageManager = createStorageManager();
    if (configuration.getClusterConfigurations().size() > 0 && ActiveMQDefaultConfiguration.getDefaultClusterUser().equals(configuration.getClusterUser()) && ActiveMQDefaultConfiguration.getDefaultClusterPassword().equals(configuration.getClusterPassword())) {
        ActiveMQServerLogger.LOGGER.clusterSecurityRisk();
    }
    securityStore = new SecurityStoreImpl(securityRepository, securityManager, configuration.getSecurityInvalidationInterval(), configuration.isSecurityEnabled(), configuration.getClusterUser(), configuration.getClusterPassword(), managementService);
    queueFactory = new QueueFactoryImpl(executorFactory, scheduledPool, addressSettingsRepository, storageManager, this);
    pagingManager = createPagingManager();
    resourceManager = new ResourceManagerImpl((int) (configuration.getTransactionTimeout() / 1000), configuration.getTransactionTimeoutScanPeriod(), scheduledPool);
    postOffice = new PostOfficeImpl(this, storageManager, pagingManager, queueFactory, managementService, configuration.getMessageExpiryScanPeriod(), configuration.getMessageExpiryThreadPriority(), configuration.getWildcardConfiguration(), configuration.getIDCacheSize(), configuration.isPersistIDCache(), addressSettingsRepository);
    // This can't be created until node id is set
    clusterManager = new ClusterManager(executorFactory, this, postOffice, scheduledPool, managementService, configuration, nodeManager, haPolicy.isBackup());
    backupManager = new BackupManager(this, executorFactory, scheduledPool, nodeManager, configuration, clusterManager);
    clusterManager.deploy();
    remotingService = new RemotingServiceImpl(clusterManager, configuration, this, managementService, scheduledPool, protocolManagerFactories, executorFactory.getExecutor(), serviceRegistry);
    messagingServerControl = managementService.registerServer(postOffice, securityStore, storageManager, configuration, addressSettingsRepository, securityRepository, resourceManager, remotingService, this, queueFactory, scheduledPool, pagingManager, haPolicy.isBackup());
    if (!scalingDown) {
        deployAddressSettingsFromConfiguration();
    }
    storageManager.start();
    postOffice.start();
    pagingManager.start();
    managementService.start();
    resourceManager.start();
    deploySecurityFromConfiguration();
    deployGroupingHandlerConfiguration(configuration.getGroupingHandlerConfiguration());
    this.reloadManager = new ReloadManagerImpl(getScheduledPool(), executorFactory.getExecutor(), configuration.getConfigurationFileRefreshPeriod());
    if (configuration.getConfigurationUrl() != null && getScheduledPool() != null) {
        reloadManager.addCallback(configuration.getConfigurationUrl(), new ConfigurationFileReloader());
    }
    return true;
}
Also used : ManagementServiceImpl(org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl) RemotingServiceImpl(org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl) ReloadManagerImpl(org.apache.activemq.artemis.core.server.reload.ReloadManagerImpl) ResourceManagerImpl(org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl) SecurityStoreImpl(org.apache.activemq.artemis.core.security.impl.SecurityStoreImpl) MemoryManager(org.apache.activemq.artemis.core.server.MemoryManager) ClusterManager(org.apache.activemq.artemis.core.server.cluster.ClusterManager) BackupManager(org.apache.activemq.artemis.core.server.cluster.BackupManager) PostOfficeImpl(org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl)

Example 2 with ManagementServiceImpl

use of org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl in project activemq-artemis by apache.

the class ManagementServiceImplTest method testGetResources.

@Test
public void testGetResources() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ManagementServiceImpl managementService = new ManagementServiceImpl(null, config);
    managementService.setStorageManager(new NullStorageManager());
    SimpleString address = RandomUtil.randomSimpleString();
    managementService.registerAddress(new AddressInfo(address));
    Queue queue = new FakeQueue(RandomUtil.randomSimpleString());
    managementService.registerQueue(queue, RandomUtil.randomSimpleString(), new FakeStorageManager());
    Object[] addresses = managementService.getResources(AddressControl.class);
    Assert.assertEquals(1, addresses.length);
    Assert.assertTrue(addresses[0] instanceof AddressControl);
    AddressControl addressControl = (AddressControl) addresses[0];
    Assert.assertEquals(address.toString(), addressControl.getAddress());
    Object[] queues = managementService.getResources(QueueControl.class);
    Assert.assertEquals(1, queues.length);
    Assert.assertTrue(queues[0] instanceof QueueControl);
    QueueControl queueControl = (QueueControl) queues[0];
    Assert.assertEquals(queue.getName().toString(), queueControl.getName());
}
Also used : ManagementServiceImpl(org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl) AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) FakeStorageManager(org.apache.activemq.artemis.tests.integration.server.FakeStorageManager) Configuration(org.apache.activemq.artemis.core.config.Configuration) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Queue(org.apache.activemq.artemis.core.server.Queue) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) QueueControl(org.apache.activemq.artemis.api.core.management.QueueControl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Aggregations

ManagementServiceImpl (org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AddressControl (org.apache.activemq.artemis.api.core.management.AddressControl)1 QueueControl (org.apache.activemq.artemis.api.core.management.QueueControl)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 NullStorageManager (org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager)1 PostOfficeImpl (org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl)1 RemotingServiceImpl (org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl)1 SecurityStoreImpl (org.apache.activemq.artemis.core.security.impl.SecurityStoreImpl)1 MemoryManager (org.apache.activemq.artemis.core.server.MemoryManager)1 Queue (org.apache.activemq.artemis.core.server.Queue)1 BackupManager (org.apache.activemq.artemis.core.server.cluster.BackupManager)1 ClusterManager (org.apache.activemq.artemis.core.server.cluster.ClusterManager)1 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1 ReloadManagerImpl (org.apache.activemq.artemis.core.server.reload.ReloadManagerImpl)1 ResourceManagerImpl (org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl)1 FakeStorageManager (org.apache.activemq.artemis.tests.integration.server.FakeStorageManager)1 FakeQueue (org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue)1 Test (org.junit.Test)1