Search in sources :

Example 1 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class CoreProtocolManager method createConnectionEntry.

@Override
public ConnectionEntry createConnectionEntry(final Acceptor acceptorUsed, final Connection connection) {
    final Configuration config = server.getConfiguration();
    Executor connectionExecutor = server.getExecutorFactory().getExecutor();
    final CoreRemotingConnection rc = new RemotingConnectionImpl(new ServerPacketDecoder(), connection, incomingInterceptors, outgoingInterceptors, config.isAsyncConnectionExecutionEnabled() ? connectionExecutor : null, server.getNodeID());
    Channel channel1 = rc.getChannel(CHANNEL_ID.SESSION.id, -1);
    ChannelHandler handler = new ActiveMQPacketHandler(this, server, channel1, rc);
    channel1.setHandler(handler);
    long ttl = ActiveMQClient.DEFAULT_CONNECTION_TTL;
    if (config.getConnectionTTLOverride() != -1) {
        ttl = config.getConnectionTTLOverride();
    }
    final ConnectionEntry entry = new ConnectionEntry(rc, connectionExecutor, System.currentTimeMillis(), ttl);
    final Channel channel0 = rc.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
    channel0.setHandler(new LocalChannelHandler(config, entry, channel0, acceptorUsed, rc));
    server.getClusterManager().addClusterChannelHandler(rc.getChannel(CHANNEL_ID.CLUSTER.id, -1), acceptorUsed, rc, server.getActivation());
    return entry;
}
Also used : Executor(java.util.concurrent.Executor) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConnectionEntry(org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry) CoreRemotingConnection(org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) ChannelHandler(org.apache.activemq.artemis.core.protocol.core.ChannelHandler) ServerPacketDecoder(org.apache.activemq.artemis.core.protocol.ServerPacketDecoder)

Example 2 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ReplicationEndpoint method start.

@Override
public synchronized void start() throws Exception {
    Configuration config = server.getConfiguration();
    try {
        storageManager = server.getStorageManager();
        storageManager.start();
        server.getManagementService().setStorageManager(storageManager);
        journalsHolder.put(JournalContent.BINDINGS, storageManager.getBindingsJournal());
        journalsHolder.put(JournalContent.MESSAGES, storageManager.getMessageJournal());
        for (JournalContent jc : EnumSet.allOf(JournalContent.class)) {
            filesReservedForSync.put(jc, new HashMap<Long, JournalSyncFile>());
            // We only need to load internal structures on the backup...
            journalLoadInformation[jc.typeByte] = journalsHolder.get(jc).loadSyncOnly(JournalState.SYNCING);
        }
        pageManager = new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(), config.getJournalBufferTimeout_NIO(), server.getScheduledPool(), server.getIOExecutorFactory(), config.isJournalSyncNonTransactional(), criticalErrorListener), server.getAddressSettingsRepository());
        pageManager.start();
        started = true;
    } catch (Exception e) {
        if (server.isStarted())
            throw e;
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) PagingStoreFactoryNIO(org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO) JournalContent(org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.JournalContent) PagingManagerImpl(org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) IOException(java.io.IOException)

Example 3 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ColocatedHAManager method activateSharedStoreBackup.

private synchronized boolean activateSharedStoreBackup(String journalDirectory, String bindingsDirectory, String largeMessagesDirectory, String pagingDirectory) throws Exception {
    Configuration configuration = server.getConfiguration().copy();
    ActiveMQServer backup = server.createBackupServer(configuration);
    try {
        int portOffset = haPolicy.getBackupPortOffset() * (backupServers.size() + 1);
        String name = "colocated_backup_" + backupServers.size() + 1;
        // make sure we don't restart as we are colocated
        haPolicy.getBackupPolicy().setRestartBackup(false);
        // set the backup policy
        backup.setHAPolicy(haPolicy.getBackupPolicy());
        updateSharedStoreConfiguration(configuration, name, portOffset, haPolicy.getExcludedConnectors(), journalDirectory, bindingsDirectory, largeMessagesDirectory, pagingDirectory, haPolicy.getBackupPolicy().getScaleDownPolicy() == null);
        backupServers.put(configuration.getName(), backup);
        backup.start();
    } catch (Exception e) {
        backup.stop();
        ActiveMQServerLogger.LOGGER.activateSharedStoreSlaveFailed(e);
        return false;
    }
    ActiveMQServerLogger.LOGGER.activatingSharedStoreSlave();
    return true;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 4 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ColocatedHAManager method activateReplicatedBackup.

/**
 * activate a backup server replicating from a specified node.
 *
 * decline and the requesting server can cast a re vote
 *
 * @param nodeID the id of the node to replicate from
 * @return true if the server was created and started
 * @throws Exception
 */
private synchronized boolean activateReplicatedBackup(SimpleString nodeID) throws Exception {
    Configuration configuration = server.getConfiguration().copy();
    ActiveMQServer backup = server.createBackupServer(configuration);
    try {
        TopologyMember member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeID.toString());
        int portOffset = haPolicy.getBackupPortOffset() * (backupServers.size() + 1);
        String name = "colocated_backup_" + backupServers.size() + 1;
        // make sure we don't restart as we are colocated
        haPolicy.getBackupPolicy().setRestartBackup(false);
        // set the backup policy
        backup.setHAPolicy(haPolicy.getBackupPolicy());
        updateReplicatedConfiguration(configuration, name, portOffset, haPolicy.getExcludedConnectors(), haPolicy.getBackupPolicy().getScaleDownPolicy() == null);
        backup.addActivationParam(ActivationParams.REPLICATION_ENDPOINT, member);
        backupServers.put(configuration.getName(), backup);
        backup.start();
    } catch (Exception e) {
        backup.stop();
        ActiveMQServerLogger.LOGGER.activateReplicatedBackupFailed(e);
        return false;
    }
    ActiveMQServerLogger.LOGGER.activatingReplica(nodeID);
    return true;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) TopologyMember(org.apache.activemq.artemis.api.core.client.TopologyMember) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 5 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class PersistentPushTopicConsumerTest method setup.

@BeforeClass
public static void setup() throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    server = ActiveMQServers.newActiveMQServer(configuration);
    server.start();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

Configuration (org.apache.activemq.artemis.core.config.Configuration)331 Test (org.junit.Test)143 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)120 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)109 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)108 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)101 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)93 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)90 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)78 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)78 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)72 Before (org.junit.Before)59 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)58 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)57 HashMap (java.util.HashMap)56 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)52 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)35 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)35 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)34