use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class RelativePathTest method testRelativePath.
@Test
public void testRelativePath() throws Exception {
Configuration configuration = createDefaultConfig(false);
File instanceHome = new File(getTemporaryDir(), "artemisHome");
File dataHome = new File(instanceHome, "data");
// One folder up for testing
File bindingsHome = new File(instanceHome, "../binx");
System.out.println("InstanceHome->" + instanceHome);
instanceHome.mkdirs();
configuration.setBrokerInstance(instanceHome);
configuration.setJournalDirectory("./data");
configuration.setPagingDirectory("./paging");
configuration.setBindingsDirectory("../binx");
// one folder up from instance home
configuration.setLargeMessagesDirectory("./large");
ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
server.start();
server.stop();
checkData(dataHome, ".amq");
checkData(bindingsHome, ".bindings");
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ClusterTestBase method setupBackupServerWithDiscovery.
protected void setupBackupServerWithDiscovery(final int node, final int liveNode, final String groupAddress, final int port, final boolean fileStorage, final boolean netty, final boolean sharedStorage) throws Exception {
if (servers[node] != null) {
throw new IllegalArgumentException("Already a server at node " + node);
}
Map<String, Object> params = generateParams(node, netty);
TransportConfiguration connector = createTransportConfiguration(netty, false, params);
List<String> connectorPairs = new ArrayList<>();
connectorPairs.add(connector.getName());
UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(port);
BroadcastGroupConfiguration bcConfig = new BroadcastGroupConfiguration().setName("bg1").setBroadcastPeriod(1000).setConnectorInfos(connectorPairs).setEndpointFactory(endpoint);
DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(endpoint);
Configuration configuration = createBasicConfig(sharedStorage ? liveNode : node).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, params)).addConnectorConfiguration(connector.getName(), connector).addBroadcastGroupConfiguration(bcConfig).addDiscoveryGroupConfiguration(dcConfig.getName(), dcConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreSlavePolicyConfiguration() : new ReplicatedPolicyConfiguration());
ActiveMQServer server;
if (sharedStorage) {
server = createInVMFailoverServer(fileStorage, configuration, nodeManagers[liveNode], liveNode);
} else {
boolean enablePersistency = fileStorage ? configuration.isPersistenceEnabled() : false;
server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency));
}
servers[node] = server;
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ClusterTestBase method setupClusterConnection.
protected void setupClusterConnection(final String name, final String address, final MessageLoadBalancingType messageLoadBalancingType, final int maxHops, final boolean netty, final ClusterConfigCallback cb, final int nodeFrom, final int... nodesTo) {
ActiveMQServer serverFrom = servers[nodeFrom];
if (serverFrom == null) {
throw new IllegalStateException("No server at node " + nodeFrom);
}
TransportConfiguration connectorFrom = createTransportConfiguration(netty, false, generateParams(nodeFrom, netty));
serverFrom.getConfiguration().getConnectorConfigurations().put(connectorFrom.getName(), connectorFrom);
List<String> pairs = new ArrayList<>();
for (int element : nodesTo) {
TransportConfiguration serverTotc = createTransportConfiguration(netty, false, generateParams(element, netty));
serverFrom.getConfiguration().getConnectorConfigurations().put(serverTotc.getName(), serverTotc);
pairs.add(serverTotc.getName());
}
Configuration config = serverFrom.getConfiguration();
ClusterConnectionConfiguration clusterConf = createClusterConfig(name, address, messageLoadBalancingType, maxHops, connectorFrom, pairs);
if (cb != null) {
cb.configure(clusterConf);
}
config.getClusterConfigurations().add(clusterConf);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ClusterTestBase method setupClusterConnection.
protected void setupClusterConnection(final String name, final int nodeFrom, final int nodeTo, final String address, final MessageLoadBalancingType messageLoadBalancingType, final int maxHops, final boolean netty, final boolean allowDirectConnectionsOnly) {
ActiveMQServer serverFrom = servers[nodeFrom];
if (serverFrom == null) {
throw new IllegalStateException("No server at node " + nodeFrom);
}
TransportConfiguration connectorFrom = createTransportConfiguration(netty, false, generateParams(nodeFrom, netty));
serverFrom.getConfiguration().getConnectorConfigurations().put(name, connectorFrom);
List<String> pairs = null;
if (nodeTo != -1) {
TransportConfiguration serverTotc = createTransportConfiguration(netty, false, generateParams(nodeTo, netty));
serverFrom.getConfiguration().getConnectorConfigurations().put(serverTotc.getName(), serverTotc);
pairs = new ArrayList<>();
pairs.add(serverTotc.getName());
}
Configuration config = serverFrom.getConfiguration();
ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(name).setRetryInterval(100).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(1024).setStaticConnectors(pairs).setAllowDirectConnectionsOnly(allowDirectConnectionsOnly);
config.getClusterConfigurations().add(clusterConf);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ClusterTestBase method setupBackupServer.
/**
* Server lacks a {@link ClusterConnectionConfiguration} necessary for the remote (replicating)
* backup case.
* <br>
* Use
* {@link #setupClusterConnectionWithBackups(String, String, org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType, int, boolean, int, int[])}
* to add it.
*
* @param node
* @param liveNode
* @param fileStorage
* @param sharedStorage
* @param netty
* @throws Exception
*/
protected void setupBackupServer(final int node, final int liveNode, final boolean fileStorage, final boolean sharedStorage, final boolean netty) throws Exception {
if (servers[node] != null) {
throw new IllegalArgumentException("Already a server at node " + node);
}
TransportConfiguration liveConfig = createTransportConfiguration(netty, false, generateParams(liveNode, netty));
TransportConfiguration backupConfig = createTransportConfiguration(netty, false, generateParams(node, netty));
TransportConfiguration acceptorConfig = createTransportConfiguration(netty, true, generateParams(node, netty));
Configuration configuration = createBasicConfig(sharedStorage ? liveNode : node).clearAcceptorConfigurations().addAcceptorConfiguration(acceptorConfig).addConnectorConfiguration(liveConfig.getName(), liveConfig).addConnectorConfiguration(backupConfig.getName(), backupConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration());
ActiveMQServer server;
if (sharedStorage) {
server = createInVMFailoverServer(true, configuration, nodeManagers[liveNode], liveNode);
} else {
boolean enablePersistency = fileStorage ? true : configuration.isPersistenceEnabled();
server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency));
}
server.setIdentity(this.getClass().getSimpleName() + "/Backup(" + node + " of live " + liveNode + ")");
servers[node] = addServer(server);
}
Aggregations