Search in sources :

Example 1 with ResourceManagerImpl

use of org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl 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 ResourceManagerImpl

use of org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl in project activemq-artemis by apache.

the class DuplicateDetectionUnitTest method testReloadDuplication.

// Public --------------------------------------------------------
@Test
public void testReloadDuplication() throws Exception {
    JournalStorageManager journal = null;
    try {
        clearDataRecreateServerDirs();
        SimpleString ADDRESS = new SimpleString("address");
        Configuration configuration = createDefaultInVMConfig();
        PostOffice postOffice = new FakePostOffice();
        ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory());
        journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
        journal.start();
        journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
        HashMap<SimpleString, List<Pair<byte[], Long>>> mapDups = new HashMap<>();
        FakePagingManager pagingManager = new FakePagingManager();
        journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
        Assert.assertEquals(0, mapDups.size());
        DuplicateIDCacheImpl cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
        for (int i = 0; i < 100; i++) {
            cacheID.addToCache(RandomUtil.randomBytes());
        }
        journal.stop();
        journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
        journal.start();
        journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
        journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
        Assert.assertEquals(1, mapDups.size());
        List<Pair<byte[], Long>> values = mapDups.get(ADDRESS);
        Assert.assertEquals(10, values.size());
        cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
        cacheID.load(values);
        for (int i = 0; i < 100; i++) {
            cacheID.addToCache(RandomUtil.randomBytes(), null);
        }
        journal.stop();
        mapDups.clear();
        journal = new JournalStorageManager(configuration, EmptyCriticalAnalyzer.getInstance(), factory, factory);
        journal.start();
        journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
        journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null));
        Assert.assertEquals(1, mapDups.size());
        values = mapDups.get(ADDRESS);
        Assert.assertEquals(10, values.size());
        scheduledThreadPool.shutdown();
    } finally {
        if (journal != null) {
            try {
                journal.stop();
            } catch (Throwable ignored) {
            }
        }
    }
}
Also used : PostOfficeJournalLoader(org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader) GroupingInfo(org.apache.activemq.artemis.core.persistence.GroupingInfo) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) HashMap(java.util.HashMap) ResourceManagerImpl(org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) FakePostOffice(org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice) PostOffice(org.apache.activemq.artemis.core.postoffice.PostOffice) QueueBindingInfo(org.apache.activemq.artemis.core.persistence.QueueBindingInfo) FakePostOffice(org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) DuplicateIDCacheImpl(org.apache.activemq.artemis.core.postoffice.impl.DuplicateIDCacheImpl) FakePagingManager(org.apache.activemq.artemis.tests.unit.util.FakePagingManager) ArrayList(java.util.ArrayList) List(java.util.List) AddressBindingInfo(org.apache.activemq.artemis.core.persistence.AddressBindingInfo) Pair(org.apache.activemq.artemis.api.core.Pair) Test(org.junit.Test)

Aggregations

ResourceManagerImpl (org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)1 Pair (org.apache.activemq.artemis.api.core.Pair)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 AddressBindingInfo (org.apache.activemq.artemis.core.persistence.AddressBindingInfo)1 GroupingInfo (org.apache.activemq.artemis.core.persistence.GroupingInfo)1 QueueBindingInfo (org.apache.activemq.artemis.core.persistence.QueueBindingInfo)1 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)1 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)1 DuplicateIDCacheImpl (org.apache.activemq.artemis.core.postoffice.impl.DuplicateIDCacheImpl)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 BackupManager (org.apache.activemq.artemis.core.server.cluster.BackupManager)1