Search in sources :

Example 1 with CoreProtocolManagerFactory

use of org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory in project activemq-artemis by apache.

the class ClusterTestBase method setupLiveServer.

protected void setupLiveServer(final int node, final boolean fileStorage, final boolean sharedStorage, final boolean netty, boolean liveOnly) throws Exception {
    if (servers[node] != null) {
        throw new IllegalArgumentException("Already a server at node " + node);
    }
    HAPolicyConfiguration haPolicyConfiguration = null;
    if (liveOnly) {
        haPolicyConfiguration = new LiveOnlyPolicyConfiguration();
    } else {
        if (sharedStorage)
            haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
        else
            haPolicyConfiguration = new ReplicatedPolicyConfiguration();
    }
    Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).setThreadPoolMaxSize(10).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, generateParams(node, netty))).setHAPolicyConfiguration(haPolicyConfiguration).setResolveProtocols(isResolveProtocols());
    ActiveMQServer server;
    if (fileStorage) {
        if (sharedStorage) {
            server = createInVMFailoverServer(true, configuration, nodeManagers[node], node);
        } else {
            server = createServer(configuration);
        }
    } else {
        if (sharedStorage) {
            server = createInVMFailoverServer(false, configuration, nodeManagers[node], node);
        } else {
            server = createServer(false, configuration);
        }
    }
    server.addProtocolManagerFactory(new CoreProtocolManagerFactory());
    server.setIdentity(this.getClass().getSimpleName() + "/Live(" + node + ")");
    servers[node] = addServer(server);
}
Also used : HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) CoreProtocolManagerFactory(org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory)

Example 2 with CoreProtocolManagerFactory

use of org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory in project activemq-artemis by apache.

the class MessageJournalTest method testStoreCore.

@Test
public void testStoreCore() throws Throwable {
    ActiveMQServer server = createServer(true);
    server.start();
    CoreMessage message = new CoreMessage().initBuffer(10 * 1024).setDurable(true);
    message.setMessageID(333);
    CoreProtocolManagerFactory factory = (CoreProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("CORE");
    Assert.assertNotNull(factory);
    message.getBodyBuffer().writeByte((byte) 'Z');
    server.getStorageManager().storeMessage(message);
    server.getStorageManager().stop();
    JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
    List<RecordInfo> committedRecords = new LinkedList<>();
    List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
    TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {

        @Override
        public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
        }
    };
    try {
        journalStorageManager.getMessageJournal().start();
        journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
        Assert.assertEquals(1, committedRecords.size());
    } finally {
        journalStorageManager.getMessageJournal().stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) CoreProtocolManagerFactory(org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory) List(java.util.List) LinkedList(java.util.LinkedList) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) LinkedList(java.util.LinkedList) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Aggregations

CoreProtocolManagerFactory (org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)1 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)1 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)1 ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)1 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)1 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)1 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)1 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)1 TransactionFailureCallback (org.apache.activemq.artemis.core.journal.TransactionFailureCallback)1 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)1