Search in sources :

Example 1 with RemotingServiceImpl

use of org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl 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 RemotingServiceImpl

use of org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl in project activemq-artemis by apache.

the class RemotingServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    serviceRegistry = new ServiceRegistryImpl();
    configuration = new ConfigurationImpl();
    configuration.setAcceptorConfigurations(new HashSet<TransportConfiguration>());
    remotingService = new RemotingServiceImpl(null, configuration, null, null, null, null, null, serviceRegistry);
}
Also used : RemotingServiceImpl(org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl) ServiceRegistryImpl(org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) Before(org.junit.Before)

Example 3 with RemotingServiceImpl

use of org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl in project activemq-artemis by apache.

the class RemotingServiceImplTest method testInterceptorsAreAddedOnCreationOfServiceRegistry.

/**
 * Tests ensures that both interceptors from the service registry and also interceptors defined in the configuration
 * are added to the RemotingServiceImpl on creation
 */
@Test
public void testInterceptorsAreAddedOnCreationOfServiceRegistry() throws Exception {
    Field incomingInterceptors = RemotingServiceImpl.class.getDeclaredField("incomingInterceptors");
    Field outgoingInterceptors = RemotingServiceImpl.class.getDeclaredField("outgoingInterceptors");
    incomingInterceptors.setAccessible(true);
    outgoingInterceptors.setAccessible(true);
    serviceRegistry.addIncomingInterceptor(new FakeInterceptor());
    serviceRegistry.addOutgoingInterceptor(new FakeInterceptor());
    List<String> interceptorClassNames = new ArrayList<>();
    interceptorClassNames.add(FakeInterceptor.class.getCanonicalName());
    configuration.setIncomingInterceptorClassNames(interceptorClassNames);
    configuration.setOutgoingInterceptorClassNames(interceptorClassNames);
    remotingService = new RemotingServiceImpl(null, configuration, null, null, null, null, null, serviceRegistry);
    assertTrue(((List) incomingInterceptors.get(remotingService)).size() == 2);
    assertTrue(((List) outgoingInterceptors.get(remotingService)).size() == 2);
    assertTrue(((List) incomingInterceptors.get(remotingService)).contains(serviceRegistry.getIncomingInterceptors(null).get(0)));
    assertTrue(((List) outgoingInterceptors.get(remotingService)).contains(serviceRegistry.getOutgoingInterceptors(null).get(0)));
}
Also used : RemotingServiceImpl(org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl) Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FakeInterceptor(org.apache.activemq.artemis.tests.unit.core.remoting.server.impl.fake.FakeInterceptor) Test(org.junit.Test)

Example 4 with RemotingServiceImpl

use of org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl in project activemq-artemis by apache.

the class RemotingServiceImplTest method testPropagatingInterceptors.

/**
 * Tests that the service registry gets propaged into remotingService.
 */
@Test
public void testPropagatingInterceptors() throws Exception {
    for (int i = 0; i < 5; i++) {
        serviceRegistry.addIncomingInterceptor(new FakeInterceptor());
    }
    remotingService = new RemotingServiceImpl(null, configuration, null, null, null, null, null, serviceRegistry);
    assertTrue(remotingService.getIncomingInterceptors().size() == 5);
    assertTrue(remotingService.getIncomingInterceptors().get(0) instanceof FakeInterceptor);
    assertTrue(remotingService.getIncomingInterceptors().get(0) != remotingService.getIncomingInterceptors().get(1));
}
Also used : RemotingServiceImpl(org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl) FakeInterceptor(org.apache.activemq.artemis.tests.unit.core.remoting.server.impl.fake.FakeInterceptor) Test(org.junit.Test)

Aggregations

RemotingServiceImpl (org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl)4 FakeInterceptor (org.apache.activemq.artemis.tests.unit.core.remoting.server.impl.fake.FakeInterceptor)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)1 PostOfficeImpl (org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl)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 ClusterManager (org.apache.activemq.artemis.core.server.cluster.ClusterManager)1 ServiceRegistryImpl (org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl)1 ManagementServiceImpl (org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl)1 ReloadManagerImpl (org.apache.activemq.artemis.core.server.reload.ReloadManagerImpl)1 ResourceManagerImpl (org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl)1 Before (org.junit.Before)1