use of org.apache.activemq.artemis.core.server.NodeManager in project activemq-artemis by apache.
the class SharedNothingLiveActivation method close.
@Override
public void close(boolean permanently, boolean restarting) throws Exception {
replicationManager = null;
// To avoid a NPE cause by the stop
NodeManager nodeManagerInUse = activeMQServer.getNodeManager();
if (nodeManagerInUse != null) {
// todo does this actually make any difference, we only set a different flag in the lock file which replication doesn't use
if (permanently) {
nodeManagerInUse.crashLiveServer();
} else {
nodeManagerInUse.pauseLiveServer();
}
}
}
use of org.apache.activemq.artemis.core.server.NodeManager in project activemq-artemis by apache.
the class JMSFailoverTest method startServers.
/**
* @throws Exception
*/
protected void startServers() throws Exception {
final boolean sharedStore = true;
NodeManager nodeManager = new InVMNodeManager(!sharedStore);
backuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
livetc = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
liveAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);
backupAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf = createBasicConfig().addAcceptorConfiguration(backupAcceptortc).addConnectorConfiguration(livetc.getName(), livetc).addConnectorConfiguration(backuptc.getName(), backuptc).setSecurityEnabled(false).setJournalType(getDefaultJournalType()).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), livetc.getName()));
backupServer = addServer(new InVMNodeManagerServer(backupConf, nodeManager));
backupJMSServer = new JMSServerManagerImpl(backupServer);
backupJMSServer.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSServer.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup");
backupJMSServer.start();
liveConf = createBasicConfig().setJournalDirectory(getJournalDir()).setBindingsDirectory(getBindingsDir()).setSecurityEnabled(false).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));
liveServer = addServer(new InVMNodeManagerServer(liveConf, nodeManager));
liveJMSServer = new JMSServerManagerImpl(liveServer);
liveJMSServer.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSServer.getActiveMQServer().setIdentity("JMSLive");
log.info("Starting life");
liveJMSServer.start();
JMSUtil.waitForServer(backupServer);
}
use of org.apache.activemq.artemis.core.server.NodeManager in project activemq-artemis by apache.
the class BridgeReconnectTest method testFailoverDeploysBridge.
/**
* Backups must successfully deploy its bridges on fail-over.
*
* @see https://bugzilla.redhat.com/show_bug.cgi?id=900764
*/
@Test
public void testFailoverDeploysBridge() throws Exception {
NodeManager nodeManager = new InVMNodeManager(false);
server0 = createActiveMQServer(0, server0Params, isNetty(), nodeManager);
server2 = createBackupActiveMQServer(2, server2Params, isNetty(), 0, nodeManager);
TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params, "server0tc");
TransportConfiguration server2tc = new TransportConfiguration(getConnector(), server2Params, "server2tc");
connectors.put(server2tc.getName(), server2tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
server1.getConfiguration().setConnectorConfigurations(connectors);
server2.getConfiguration().setConnectorConfigurations(connectors);
reconnectAttempts = -1;
BridgeConfiguration bridgeConfiguration = createBridgeConfig();
bridgeConfiguration.setQueueName(queueName);
List<BridgeConfiguration> bridgeConfigs = new ArrayList<>();
bridgeConfigs.add(bridgeConfiguration);
server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
server2.getConfiguration().setBridgeConfigurations(bridgeConfigs);
CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName);
List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>();
queueConfigs0.add(queueConfig0);
server1.getConfiguration().setQueueConfigurations(queueConfigs0);
CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName);
List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>();
queueConfigs1.add(queueConfig1);
server0.getConfiguration().setQueueConfigurations(queueConfigs1);
server2.getConfiguration().setQueueConfigurations(queueConfigs1);
startServers();
waitForServerStart(server0);
server0.fail(true);
waitForServerStart(server2);
locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(server0tc, server2tc));
ClientSessionFactory csf0 = addSessionFactory(locator.createSessionFactory(server2tc));
session0 = csf0.createSession(false, true, true);
Map<String, Bridge> bridges = server2.getClusterManager().getBridges();
assertTrue("backup must deploy bridge on failover", !bridges.isEmpty());
}
use of org.apache.activemq.artemis.core.server.NodeManager in project activemq-artemis by apache.
the class NodeManagerTest method performWork.
public void performWork(NodeManagerAction... actions) throws Exception {
NodeManager nodeManager = new InVMNodeManager(false);
List<NodeRunner> nodeRunners = new ArrayList<>();
Thread[] threads = new Thread[actions.length];
for (NodeManagerAction action : actions) {
NodeRunner nodeRunner = new NodeRunner(nodeManager, action);
nodeRunners.add(nodeRunner);
}
for (int i = 0, nodeRunnersSize = nodeRunners.size(); i < nodeRunnersSize; i++) {
NodeRunner nodeRunner = nodeRunners.get(i);
threads[i] = new Thread(nodeRunner);
threads[i].start();
}
for (Thread thread : threads) {
try {
thread.join(5000);
} catch (InterruptedException e) {
//
}
if (thread.isAlive()) {
thread.interrupt();
fail("thread still running");
}
}
for (NodeRunner nodeRunner : nodeRunners) {
if (nodeRunner.e != null) {
nodeRunner.e.printStackTrace();
fail(nodeRunner.e.getMessage());
}
}
}
use of org.apache.activemq.artemis.core.server.NodeManager in project activemq-artemis by apache.
the class NettyFailoverTest method createTestableServer.
@Override
protected TestableServer createTestableServer(Configuration config) throws Exception {
final boolean isBackup = config.getHAPolicyConfiguration() instanceof ReplicaPolicyConfiguration || config.getHAPolicyConfiguration() instanceof SharedStoreSlavePolicyConfiguration;
NodeManager nodeManager = this.nodeManager;
// create a separate NodeManager for the backup
if (isBackup && nodeManagerType == NodeManagerType.Jdbc) {
nodeManager = createNodeManager();
}
return new SameProcessActiveMQServer(createInVMFailoverServer(true, config, nodeManager, isBackup ? 2 : 1));
}
Aggregations