Search in sources :

Example 6 with LiveOnlyPolicyConfiguration

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

the class ConfigurationImplTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    boolean b = RandomUtil.randomBoolean();
    conf.setHAPolicyConfiguration(new LiveOnlyPolicyConfiguration());
    int i = RandomUtil.randomInt();
    conf.setScheduledThreadPoolMaxSize(i);
    Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
    long l = RandomUtil.randomLong();
    conf.setSecurityInvalidationInterval(l);
    Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
    b = RandomUtil.randomBoolean();
    conf.setSecurityEnabled(b);
    Assert.assertEquals(b, conf.isSecurityEnabled());
    String s = RandomUtil.randomString();
    conf.setBindingsDirectory(s);
    Assert.assertEquals(s, conf.getBindingsDirectory());
    b = RandomUtil.randomBoolean();
    conf.setCreateBindingsDir(b);
    Assert.assertEquals(b, conf.isCreateBindingsDir());
    s = RandomUtil.randomString();
    conf.setJournalDirectory(s);
    Assert.assertEquals(s, conf.getJournalDirectory());
    b = RandomUtil.randomBoolean();
    conf.setCreateJournalDir(b);
    Assert.assertEquals(b, conf.isCreateJournalDir());
    i = RandomUtil.randomInt() % 2;
    JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
    conf.setJournalType(journal);
    Assert.assertEquals(journal, conf.getJournalType());
    b = RandomUtil.randomBoolean();
    conf.setJournalSyncTransactional(b);
    Assert.assertEquals(b, conf.isJournalSyncTransactional());
    b = RandomUtil.randomBoolean();
    conf.setJournalSyncNonTransactional(b);
    Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
    i = RandomUtil.randomInt();
    conf.setJournalFileSize(i);
    Assert.assertEquals(i, conf.getJournalFileSize());
    i = RandomUtil.randomInt();
    conf.setJournalMinFiles(i);
    Assert.assertEquals(i, conf.getJournalMinFiles());
    i = RandomUtil.randomInt();
    conf.setJournalMaxIO_AIO(i);
    Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalMaxIO_NIO(i);
    Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
    s = RandomUtil.randomString();
    conf.setManagementAddress(new SimpleString(s));
    Assert.assertEquals(s, conf.getManagementAddress().toString());
    i = RandomUtil.randomInt();
    conf.setMessageExpiryThreadPriority(i);
    Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
    l = RandomUtil.randomLong();
    conf.setMessageExpiryScanPeriod(l);
    Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
    b = RandomUtil.randomBoolean();
    conf.setPersistDeliveryCountBeforeDelivery(b);
    Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
    b = RandomUtil.randomBoolean();
    conf.setEnabledAsyncConnectionExecution(b);
    Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
    b = RandomUtil.randomBoolean();
    conf.setPersistenceEnabled(b);
    Assert.assertEquals(b, conf.isPersistenceEnabled());
    b = RandomUtil.randomBoolean();
    conf.setJMXManagementEnabled(b);
    Assert.assertEquals(b, conf.isJMXManagementEnabled());
    l = RandomUtil.randomLong();
    conf.setFileDeployerScanPeriod(l);
    Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
    l = RandomUtil.randomLong();
    conf.setConnectionTTLOverride(l);
    Assert.assertEquals(l, conf.getConnectionTTLOverride());
    i = RandomUtil.randomInt();
    conf.setThreadPoolMaxSize(i);
    Assert.assertEquals(i, conf.getThreadPoolMaxSize());
    SimpleString ss = RandomUtil.randomSimpleString();
    conf.setManagementNotificationAddress(ss);
    Assert.assertEquals(ss, conf.getManagementNotificationAddress());
    s = RandomUtil.randomString();
    conf.setClusterUser(s);
    Assert.assertEquals(s, conf.getClusterUser());
    i = RandomUtil.randomInt();
    conf.setIDCacheSize(i);
    Assert.assertEquals(i, conf.getIDCacheSize());
    b = RandomUtil.randomBoolean();
    conf.setPersistIDCache(b);
    Assert.assertEquals(b, conf.isPersistIDCache());
    i = RandomUtil.randomInt();
    conf.setJournalCompactMinFiles(i);
    Assert.assertEquals(i, conf.getJournalCompactMinFiles());
    i = RandomUtil.randomInt();
    conf.setJournalCompactPercentage(i);
    Assert.assertEquals(i, conf.getJournalCompactPercentage());
    i = RandomUtil.randomInt();
    conf.setJournalBufferSize_AIO(i);
    Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferTimeout_AIO(i);
    Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferSize_NIO(i);
    Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferTimeout_NIO(i);
    Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
    b = RandomUtil.randomBoolean();
    conf.setLogJournalWriteRate(b);
    Assert.assertEquals(b, conf.isLogJournalWriteRate());
    l = RandomUtil.randomLong();
    conf.setServerDumpInterval(l);
    Assert.assertEquals(l, conf.getServerDumpInterval());
    s = RandomUtil.randomString();
    conf.setPagingDirectory(s);
    Assert.assertEquals(s, conf.getPagingDirectory());
    s = RandomUtil.randomString();
    conf.setLargeMessagesDirectory(s);
    Assert.assertEquals(s, conf.getLargeMessagesDirectory());
    b = RandomUtil.randomBoolean();
    conf.setWildcardRoutingEnabled(b);
    Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
    l = RandomUtil.randomLong();
    conf.setTransactionTimeout(l);
    Assert.assertEquals(l, conf.getTransactionTimeout());
    b = RandomUtil.randomBoolean();
    conf.setMessageCounterEnabled(b);
    Assert.assertEquals(b, conf.isMessageCounterEnabled());
    l = RandomUtil.randomPositiveLong();
    conf.setMessageCounterSamplePeriod(l);
    Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
    i = RandomUtil.randomInt();
    conf.setMessageCounterMaxDayHistory(i);
    Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
    l = RandomUtil.randomLong();
    conf.setTransactionTimeoutScanPeriod(l);
    Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
    s = RandomUtil.randomString();
    conf.setClusterPassword(s);
    Assert.assertEquals(s, conf.getClusterPassword());
    conf.registerBrokerPlugin(new LoggingActiveMQServerPlugin());
    Assert.assertEquals("ensure one plugin registered", 1, conf.getBrokerPlugins().size());
    // This will use serialization to perform a deep copy of the object
    Configuration conf2 = conf.copy();
    Assert.assertTrue(conf.equals(conf2));
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JournalType(org.apache.activemq.artemis.core.server.JournalType) Test(org.junit.Test)

Example 7 with LiveOnlyPolicyConfiguration

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

the class ScaleDown3NodeTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    setupLiveServer(0, isFileStorage(), false, isNetty(), true);
    servers[0].getConfiguration().setSecurityEnabled(true);
    setupLiveServer(1, isFileStorage(), false, isNetty(), true);
    servers[1].getConfiguration().setSecurityEnabled(true);
    setupLiveServer(2, isFileStorage(), false, isNetty(), true);
    servers[2].getConfiguration().setSecurityEnabled(true);
    LiveOnlyPolicyConfiguration haPolicyConfiguration0 = (LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration();
    ScaleDownConfiguration scaleDownConfiguration0 = new ScaleDownConfiguration();
    haPolicyConfiguration0.setScaleDownConfiguration(scaleDownConfiguration0);
    LiveOnlyPolicyConfiguration haPolicyConfiguration1 = (LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration();
    ScaleDownConfiguration scaleDownConfiguration1 = new ScaleDownConfiguration();
    haPolicyConfiguration1.setScaleDownConfiguration(scaleDownConfiguration1);
    scaleDownConfiguration0.setGroupName("bill");
    scaleDownConfiguration1.setGroupName("bill");
    scaleDownConfiguration1.setEnabled(false);
    setupClusterConnection("cluster0", "testAddress", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
    setupClusterConnection("cluster0", "testAddress", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
    setupClusterConnection("cluster0", "testAddress", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
    String scaleDownConnector = servers[0].getConfiguration().getClusterConfigurations().get(0).getStaticConnectors().get(0);
    Assert.assertEquals(61617, servers[0].getConfiguration().getConnectorConfigurations().get(scaleDownConnector).getParams().get(TransportConstants.PORT_PROP_NAME));
    scaleDownConfiguration0.getConnectors().add(scaleDownConnector);
    startServers(0, 1, 2);
    setupSessionFactory(0, isNetty(), false, servers[0].getConfiguration().getClusterUser(), servers[0].getConfiguration().getClusterPassword());
    setupSessionFactory(1, isNetty(), false, servers[1].getConfiguration().getClusterUser(), servers[1].getConfiguration().getClusterPassword());
    setupSessionFactory(2, isNetty(), false, servers[2].getConfiguration().getClusterUser(), servers[2].getConfiguration().getClusterPassword());
    IntegrationTestLogger.LOGGER.info("===============================");
    IntegrationTestLogger.LOGGER.info("Node 0: " + servers[0].getClusterManager().getNodeId());
    IntegrationTestLogger.LOGGER.info("Node 1: " + servers[1].getClusterManager().getNodeId());
    IntegrationTestLogger.LOGGER.info("Node 2: " + servers[2].getClusterManager().getNodeId());
    IntegrationTestLogger.LOGGER.info("===============================");
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Before(org.junit.Before)

Example 8 with LiveOnlyPolicyConfiguration

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

the class ScaleDownTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    setupLiveServer(0, isFileStorage(), isNetty(), true);
    setupLiveServer(1, isFileStorage(), isNetty(), true);
    LiveOnlyPolicyConfiguration haPolicyConfiguration0 = (LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration();
    haPolicyConfiguration0.setScaleDownConfiguration(new ScaleDownConfiguration());
    LiveOnlyPolicyConfiguration haPolicyConfiguration1 = (LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration();
    haPolicyConfiguration1.setScaleDownConfiguration(new ScaleDownConfiguration());
    if (useScaleDownGroupName) {
        haPolicyConfiguration0.getScaleDownConfiguration().setGroupName("bill");
        haPolicyConfiguration1.getScaleDownConfiguration().setGroupName("bill");
    }
    setupClusterConnection("cluster0", "testAddress", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1);
    setupClusterConnection("cluster0", "testAddress", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0);
    haPolicyConfiguration0.getScaleDownConfiguration().getConnectors().addAll(servers[0].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
    haPolicyConfiguration1.getScaleDownConfiguration().getConnectors().addAll(servers[1].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
    servers[0].getConfiguration().getAddressesSettings().put("#", new AddressSettings().setRedistributionDelay(0));
    servers[1].getConfiguration().getAddressesSettings().put("#", new AddressSettings().setRedistributionDelay(0));
    startServers(0, 1);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) Before(org.junit.Before)

Example 9 with LiveOnlyPolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration 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)

Aggregations

LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 ScaleDownConfiguration (org.apache.activemq.artemis.core.config.ScaleDownConfiguration)4 Before (org.junit.Before)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)2 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)2 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)2 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)1 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)1 ConnectorServiceConfiguration (org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)1 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)1 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)1