This closes #1969
This commit is contained in:
commit
f36bcb6705
|
@ -63,6 +63,7 @@ import org.apache.activemq.artemis.core.config.ConfigurationUtils;
|
||||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||||
|
import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
||||||
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
|
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
|
||||||
|
@ -438,11 +439,22 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
||||||
if (!configuration.isPersistenceEnabled()) {
|
if (!configuration.isPersistenceEnabled()) {
|
||||||
manager = new InVMNodeManager(replicatingBackup);
|
manager = new InVMNodeManager(replicatingBackup);
|
||||||
} else if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) {
|
} else if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) {
|
||||||
|
final HAPolicyConfiguration.TYPE haType = configuration.getHAPolicyConfiguration() == null ? null : configuration.getHAPolicyConfiguration().getType();
|
||||||
|
if (haType == HAPolicyConfiguration.TYPE.SHARED_STORE_MASTER || haType == HAPolicyConfiguration.TYPE.SHARED_STORE_SLAVE) {
|
||||||
if (replicatingBackup) {
|
if (replicatingBackup) {
|
||||||
throw new IllegalArgumentException("replicatingBackup is not supported yet while using JDBC persistence");
|
throw new IllegalArgumentException("replicatingBackup is not supported yet while using JDBC persistence");
|
||||||
}
|
}
|
||||||
final DatabaseStorageConfiguration dbConf = (DatabaseStorageConfiguration) configuration.getStoreConfiguration();
|
final DatabaseStorageConfiguration dbConf = (DatabaseStorageConfiguration) configuration.getStoreConfiguration();
|
||||||
manager = JdbcNodeManager.with(dbConf, scheduledPool, executorFactory, shutdownOnCriticalIO);
|
manager = JdbcNodeManager.with(dbConf, scheduledPool, executorFactory, shutdownOnCriticalIO);
|
||||||
|
} else if (haType == null || haType == HAPolicyConfiguration.TYPE.LIVE_ONLY) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Detected no Shared Store HA options on JDBC store: will use InVMNodeManager");
|
||||||
|
}
|
||||||
|
//LIVE_ONLY should be the default HA option when HA isn't configured
|
||||||
|
manager = new InVMNodeManager(replicatingBackup);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("JDBC persistence allows only Shared Store HA options");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout());
|
manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||||
|
import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
|
||||||
|
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
||||||
|
@ -31,6 +33,7 @@ import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy
|
||||||
import org.apache.activemq.artemis.core.server.impl.Activation;
|
import org.apache.activemq.artemis.core.server.impl.Activation;
|
||||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||||
import org.apache.activemq.artemis.core.server.impl.ColocatedActivation;
|
import org.apache.activemq.artemis.core.server.impl.ColocatedActivation;
|
||||||
|
import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
|
||||||
import org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation;
|
import org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation;
|
||||||
import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation;
|
import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation;
|
||||||
import org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation;
|
import org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation;
|
||||||
|
@ -39,8 +42,24 @@ import org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation;
|
||||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
|
|
||||||
public class HAPolicyConfigurationTest extends ActiveMQTestBase {
|
public class HAPolicyConfigurationTest extends ActiveMQTestBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldNotUseJdbcNodeManagerWithoutHAPolicy() throws Exception {
|
||||||
|
Configuration configuration = createConfiguration("database-store-no-hapolicy-config.xml");
|
||||||
|
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
|
||||||
|
assertEquals(StoreConfiguration.StoreType.DATABASE, server.getConfiguration().getStoreConfiguration().getStoreType());
|
||||||
|
assertEquals(HAPolicyConfiguration.TYPE.LIVE_ONLY, server.getConfiguration().getHAPolicyConfiguration().getType());
|
||||||
|
try {
|
||||||
|
server.start();
|
||||||
|
assertThat(server.getNodeManager(), instanceOf(InVMNodeManager.class));
|
||||||
|
} finally {
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void liveOnlyTest() throws Exception {
|
public void liveOnlyTest() throws Exception {
|
||||||
Configuration configuration = createConfiguration("live-only-hapolicy-config.xml");
|
Configuration configuration = createConfiguration("live-only-hapolicy-config.xml");
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<configuration
|
||||||
|
xmlns="urn:activemq"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="urn:activemq ../../main/resources/schema/artemis-server.xsd">
|
||||||
|
<core xmlns="urn:activemq:core">
|
||||||
|
<store>
|
||||||
|
<database-store>
|
||||||
|
<jdbc-connection-url>jdbc:derby:target/derby/database-store;create=true</jdbc-connection-url>
|
||||||
|
<bindings-table-name>BINDINGS</bindings-table-name>
|
||||||
|
<message-table-name>MESSAGE</message-table-name>
|
||||||
|
<large-message-table-name>LARGE_MESSAGE</large-message-table-name>
|
||||||
|
<page-store-table-name>PAGE_STORE</page-store-table-name>
|
||||||
|
<jdbc-driver-class-name>org.apache.derby.jdbc.EmbeddedDriver</jdbc-driver-class-name>
|
||||||
|
</database-store>
|
||||||
|
</store>
|
||||||
|
</core>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue