use of org.apache.activemq.artemis.core.config.HAPolicyConfiguration in project wildfly by wildfly.
the class SharedStoreColocatedDefinition method buildConfiguration.
static HAPolicyConfiguration buildConfiguration(OperationContext context, ModelNode model) throws OperationFailedException {
ColocatedPolicyConfiguration haPolicyConfiguration = new ColocatedPolicyConfiguration().setRequestBackup(REQUEST_BACKUP.resolveModelAttribute(context, model).asBoolean()).setBackupRequestRetries(BACKUP_REQUEST_RETRIES.resolveModelAttribute(context, model).asInt()).setBackupRequestRetryInterval(BACKUP_REQUEST_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong()).setMaxBackups(MAX_BACKUPS.resolveModelAttribute(context, model).asInt()).setBackupPortOffset(BACKUP_PORT_OFFSET.resolveModelAttribute(context, model).asInt());
ModelNode masterConfigurationModel = model.get(CONFIGURATION, MASTER);
HAPolicyConfiguration masterConfiguration = SharedStoreMasterDefinition.buildConfiguration(context, masterConfigurationModel);
haPolicyConfiguration.setLiveConfig(masterConfiguration);
ModelNode slaveConfigurationModel = model.get(CONFIGURATION, SLAVE);
HAPolicyConfiguration slaveConfiguration = SharedStoreSlaveDefinition.buildConfiguration(context, slaveConfigurationModel);
haPolicyConfiguration.setBackupConfig(slaveConfiguration);
return haPolicyConfiguration;
}
use of org.apache.activemq.artemis.core.config.HAPolicyConfiguration in project activemq-artemis by apache.
the class MultipleServerFailoverTestBase method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
liveServers = new ArrayList<>();
backupServers = new ArrayList<>();
backupConfigs = new ArrayList<>();
liveConfigs = new ArrayList<>();
for (int i = 0; i < getLiveServerCount(); i++) {
HAPolicyConfiguration haPolicyConfiguration = null;
if (isSharedStore()) {
haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
} else {
haPolicyConfiguration = new ReplicatedPolicyConfiguration();
if (getNodeGroupName() != null) {
((ReplicatedPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i);
}
}
Configuration configuration = createDefaultConfig(isNetty()).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, i)).setHAPolicyConfiguration(haPolicyConfiguration);
if (!isSharedStore()) {
configuration.setBindingsDirectory(getBindingsDir(i, false));
configuration.setJournalDirectory(getJournalDir(i, false));
configuration.setPagingDirectory(getPageDir(i, false));
configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, false));
} else {
// todo
}
TransportConfiguration livetc = getConnectorTransportConfiguration(true, i);
configuration.addConnectorConfiguration(livetc.getName(), livetc);
List<String> connectors = new ArrayList<>();
for (int j = 0; j < getLiveServerCount(); j++) {
if (j != i) {
TransportConfiguration staticTc = getConnectorTransportConfiguration(true, j);
configuration.getConnectorConfigurations().put(staticTc.getName(), staticTc);
connectors.add(staticTc.getName());
}
}
String[] input = new String[connectors.size()];
connectors.toArray(input);
configuration.addClusterConfiguration(basicClusterConnectionConfig(livetc.getName(), input));
liveConfigs.add(configuration);
ActiveMQServer server = createServer(true, configuration);
TestableServer activeMQServer = new SameProcessActiveMQServer(server);
activeMQServer.setIdentity("Live-" + i);
liveServers.add(activeMQServer);
}
for (int i = 0; i < getBackupServerCount(); i++) {
HAPolicyConfiguration haPolicyConfiguration = null;
if (isSharedStore()) {
haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration();
} else {
haPolicyConfiguration = new ReplicaPolicyConfiguration();
if (getNodeGroupName() != null) {
((ReplicaPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i);
}
}
Configuration configuration = createDefaultConfig(isNetty()).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false, i)).setHAPolicyConfiguration(haPolicyConfiguration);
if (!isSharedStore()) {
configuration.setBindingsDirectory(getBindingsDir(i, true));
configuration.setJournalDirectory(getJournalDir(i, true));
configuration.setPagingDirectory(getPageDir(i, true));
configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, true));
} else {
// todo
}
TransportConfiguration backuptc = getConnectorTransportConfiguration(false, i);
configuration.addConnectorConfiguration(backuptc.getName(), backuptc);
List<String> connectors = new ArrayList<>();
for (int j = 0; j < getBackupServerCount(); j++) {
TransportConfiguration staticTc = getConnectorTransportConfiguration(true, j);
configuration.addConnectorConfiguration(staticTc.getName(), staticTc);
connectors.add(staticTc.getName());
}
for (int j = 0; j < getBackupServerCount(); j++) {
if (j != i) {
TransportConfiguration staticTc = getConnectorTransportConfiguration(false, j);
configuration.getConnectorConfigurations().put(staticTc.getName(), staticTc);
connectors.add(staticTc.getName());
}
}
String[] input = new String[connectors.size()];
connectors.toArray(input);
configuration.addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), input));
backupConfigs.add(configuration);
ActiveMQServer server = createServer(true, configuration);
TestableServer testableServer = new SameProcessActiveMQServer(server);
testableServer.setIdentity("Backup-" + i);
backupServers.add(testableServer);
}
}
use of org.apache.activemq.artemis.core.config.HAPolicyConfiguration in project activemq-artemis by apache.
the class HAAutomaticBackupSharedStoreTest method setUpHAPolicy.
private void setUpHAPolicy(int node) {
ActiveMQServer server = getServer(node);
ColocatedPolicyConfiguration haPolicyConfiguration = new ColocatedPolicyConfiguration();
HAPolicyConfiguration liveConfiguration = new SharedStoreMasterPolicyConfiguration();
haPolicyConfiguration.setLiveConfig(liveConfiguration);
HAPolicyConfiguration backupConfiguration = new SharedStoreSlavePolicyConfiguration();
haPolicyConfiguration.setBackupConfig(backupConfiguration);
server.getConfiguration().setHAPolicyConfiguration(haPolicyConfiguration);
}
use of org.apache.activemq.artemis.core.config.HAPolicyConfiguration in project activemq-artemis by apache.
the class FileConfigurationParserTest method testParsingHaSharedStoreWaitForActivation.
@Test
public void testParsingHaSharedStoreWaitForActivation() throws Exception {
FileConfigurationParser parser = new FileConfigurationParser();
String configStr = firstPart + "<ha-policy><shared-store><master><wait-for-activation>false</wait-for-activation></master></shared-store></ha-policy>" + lastPart;
ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));
Configuration config = parser.parseMainConfig(input);
HAPolicyConfiguration haConfig = config.getHAPolicyConfiguration();
assertTrue(haConfig instanceof SharedStoreMasterPolicyConfiguration);
SharedStoreMasterPolicyConfiguration masterConfig = (SharedStoreMasterPolicyConfiguration) haConfig;
assertFalse(masterConfig.isWaitForActivation());
}
use of org.apache.activemq.artemis.core.config.HAPolicyConfiguration 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);
}
Aggregations