Search in sources :

Example 41 with ActiveMQServerImpl

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

the class HAPolicyConfigurationTest method liveOnlyTest2.

@Test
public void liveOnlyTest2() throws Exception {
    Configuration configuration = createConfiguration("live-only-hapolicy-config2.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof LiveOnlyActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof LiveOnlyPolicy);
        LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
        ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy();
        assertNotNull(scaleDownPolicy);
        assertFalse(scaleDownPolicy.isEnabled());
        assertEquals(scaleDownPolicy.getGroupName(), "boo!");
        assertEquals(scaleDownPolicy.getDiscoveryGroup(), null);
        List<String> connectors = scaleDownPolicy.getConnectors();
        assertNotNull(connectors);
        assertEquals(connectors.size(), 2);
        assertTrue(connectors.contains("sd-connector1"));
        assertTrue(connectors.contains("sd-connector2"));
    } finally {
        server.stop();
    }
}
Also used : LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) LiveOnlyPolicy(org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy) Test(org.junit.Test)

Example 42 with ActiveMQServerImpl

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

the class HAPolicyConfigurationTest method ReplicatedTest.

@Test
public void ReplicatedTest() throws Exception {
    Configuration configuration = createConfiguration("replicated-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedNothingLiveActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ReplicatedPolicy);
        ReplicatedPolicy replicatedPolicy = (ReplicatedPolicy) haPolicy;
        assertEquals(replicatedPolicy.getGroupName(), "purple");
        assertTrue(replicatedPolicy.isCheckForLiveServer());
        assertEquals(replicatedPolicy.getClusterName(), "abcdefg");
        assertEquals(replicatedPolicy.getInitialReplicationSyncTimeout(), 9876);
    } finally {
        server.stop();
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) ReplicatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) Test(org.junit.Test)

Example 43 with ActiveMQServerImpl

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

the class SuppliedThreadPoolTest method setup.

@Before
public void setup() throws Exception {
    serviceRegistry = new ServiceRegistryImpl();
    serviceRegistry.setExecutorService(Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()));
    serviceRegistry.setIOExecutorService(Executors.newFixedThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()));
    serviceRegistry.setScheduledExecutorService(Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()));
    server = new ActiveMQServerImpl(null, null, null, null, serviceRegistry);
    server.start();
    server.waitForActivation(100, TimeUnit.MILLISECONDS);
}
Also used : ServiceRegistryImpl(org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) Before(org.junit.Before)

Example 44 with ActiveMQServerImpl

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

the class BridgeTest method testInjectedTransformer.

@Test
public void testInjectedTransformer() throws Exception {
    final SimpleString ADDRESS = new SimpleString("myAddress");
    final SimpleString QUEUE = new SimpleString("myQueue");
    final String BRIDGE = "myBridge";
    ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl();
    Transformer transformer = new Transformer() {

        @Override
        public Message transform(Message message) {
            return null;
        }
    };
    serviceRegistry.addBridgeTransformer(BRIDGE, transformer);
    Configuration config = createDefaultInVMConfig().addConnectorConfiguration("in-vm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    ActiveMQServer server = addServer(new ActiveMQServerImpl(config, null, null, null, serviceRegistry));
    server.start();
    server.waitForActivation(100, TimeUnit.MILLISECONDS);
    server.createQueue(ADDRESS, RoutingType.ANYCAST, QUEUE, null, false, false);
    List<String> connectors = new ArrayList<>();
    connectors.add("in-vm");
    server.deployBridge(new BridgeConfiguration().setName(BRIDGE).setQueueName(QUEUE.toString()).setForwardingAddress(ADDRESS.toString()).setStaticConnectors(connectors));
    Bridge bridge = server.getClusterManager().getBridges().get(BRIDGE);
    assertNotNull(bridge);
    assertEquals(transformer, ((BridgeImpl) bridge).getTransformer());
}
Also used : ServiceRegistryImpl(org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl) AddHeadersTransformer(org.apache.activemq.artemis.core.server.transformer.AddHeadersTransformer) Transformer(org.apache.activemq.artemis.core.server.transformer.Transformer) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) SessionSendMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage) SessionSendContinuationMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendContinuationMessage) SessionSendLargeMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendLargeMessage) Message(org.apache.activemq.artemis.api.core.Message) TransformerConfiguration(org.apache.activemq.artemis.core.config.TransformerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) ArrayList(java.util.ArrayList) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Bridge(org.apache.activemq.artemis.core.server.cluster.Bridge) Test(org.junit.Test)

Example 45 with ActiveMQServerImpl

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

the class LocalTestServer method start.

@Override
public synchronized void start(final HashMap<String, Object> configuration, final boolean clearJournal) throws Exception {
    if (isStarted()) {
        return;
    }
    if (clearJournal) {
        // Delete the Journal environment
        File dir = new File("target/data");
        boolean deleted = LocalTestServer.deleteDirectory(dir);
        JmsTestLogger.LOGGER.info("Deleted dir: " + dir.getAbsolutePath() + " deleted: " + deleted);
    }
    javax.management.MBeanServer beanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
    FileConfiguration fileConfiguration = new FileConfiguration();
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    securityManager.getConfiguration().addUser("guest", "guest");
    securityManager.getConfiguration().setDefaultUser("guest");
    securityManager.getConfiguration().addRole("guest", "guest");
    ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(fileConfiguration, beanServer, securityManager);
    jmsServerManager = new JMSServerManagerImpl(activeMQServer);
    System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
    jmsServerManager.setRegistry(new JndiBindingRegistry(getInitialContext()));
    FileDeploymentManager deploymentManager = new FileDeploymentManager();
    deploymentManager.addDeployable(fileConfiguration).readConfiguration();
    jmsServerManager.start();
    started = true;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) File(java.io.File)

Aggregations

ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)49 Test (org.junit.Test)35 Configuration (org.apache.activemq.artemis.core.config.Configuration)28 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)19 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)16 Activation (org.apache.activemq.artemis.core.server.impl.Activation)16 SharedNothingBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)16 HAPolicy (org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy)15 ColocatedActivation (org.apache.activemq.artemis.core.server.impl.ColocatedActivation)15 LiveOnlyActivation (org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation)15 SharedNothingLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation)15 SharedStoreBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation)15 SharedStoreLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation)15 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)14 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)10 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)9 ScaleDownPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy)9 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8