@Override protected void createConfigs() throws Exception { nodeManager = new InVMNodeManager(false); TransportConfiguration liveConnector = getConnectorTransportConfiguration(true); TransportConfiguration backupConnector = getConnectorTransportConfiguration(false); backupConfig = super.createDefaultInVMConfig() .clearAcceptorConfigurations() .addAcceptorConfiguration(getAcceptorTransportConfiguration(false)) .setHAPolicyConfiguration( new SharedStoreSlavePolicyConfiguration().setAllowFailBack(false)) .addConnectorConfiguration(liveConnector.getName(), liveConnector) .addConnectorConfiguration(backupConnector.getName(), backupConnector) .addClusterConfiguration( basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName())); backupServer = createTestableServer(backupConfig); liveConfig = super.createDefaultInVMConfig() .clearAcceptorConfigurations() .addAcceptorConfiguration(getAcceptorTransportConfiguration(true)) .setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()) .addConnectorConfiguration(liveConnector.getName(), liveConnector) .addConnectorConfiguration(backupConnector.getName(), backupConnector) .addClusterConfiguration( basicClusterConnectionConfig(liveConnector.getName(), backupConnector.getName())); liveServer = createTestableServer(liveConfig); }
protected final void adaptLiveConfigForReplicatedFailBack(TestableServer server) { Configuration configuration = server.getServer().getConfiguration(); final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false); if (server.getServer().getHAPolicy().isSharedStore()) { ClusterConnectionConfiguration cc = configuration.getClusterConfigurations().get(0); Assert.assertNotNull("cluster connection configuration", cc); Assert.assertNotNull("static connectors", cc.getStaticConnectors()); cc.getStaticConnectors().add(backupConnector.getName()); // backupConnector is only necessary for fail-back tests configuration.getConnectorConfigurations().put(backupConnector.getName(), backupConnector); return; } ReplicatedPolicy haPolicy = (ReplicatedPolicy) server.getServer().getHAPolicy(); haPolicy.setCheckForLiveServer(true); }
private void startServer() throws Exception { liveTC = new TransportConfiguration(INVM_CONNECTOR_FACTORY); Map<String, TransportConfiguration> connectors = new HashMap<>(); connectors.put(liveTC.getName(), liveTC); List<String> connectorNames = new ArrayList<>(); connectorNames.add(liveTC.getName()); Configuration liveConf = createBasicConfig() .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)) .setConnectorConfigurations(connectors) .setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()); final long broadcastPeriod = 250; final String bcGroupName = "bc1"; final int localBindPort = 5432; BroadcastGroupConfiguration bcConfig1 = new BroadcastGroupConfiguration() .setName(bcGroupName) .setBroadcastPeriod(broadcastPeriod) .setConnectorInfos(connectorNames) .setEndpointFactory( new UDPBroadcastEndpointFactory() .setGroupAddress(groupAddress) .setGroupPort(groupPort) .setLocalBindPort(localBindPort)); List<BroadcastGroupConfiguration> bcConfigs1 = new ArrayList<>(); bcConfigs1.add(bcConfig1); liveConf.setBroadcastGroupConfigurations(bcConfigs1); liveService = addServer(ActiveMQServers.newActiveMQServer(liveConf, false)); liveService.start(); }
public void create() throws Exception { Map<String, Object> params0 = new HashMap<>(); params0.put(TransportConstants.SERVER_ID_PROP_NAME, id); liveConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params0, "in-vm-live"); Map<String, Object> params = new HashMap<>(); params.put(TransportConstants.SERVER_ID_PROP_NAME, id + ID_OFFSET); backupConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params, "in-vm-backup"); // live Configuration conf0 = createBasicConfig() .setJournalDirectory(getJournalDir(id, false)) .setBindingsDirectory(getBindingsDir(id, false)) .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params0)) .addConnectorConfiguration(liveConnector.getName(), liveConnector) .setHAPolicyConfiguration(new ReplicatedPolicyConfiguration()) .addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName())); ActiveMQServer server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, true)); liveContext = new InVMContext(); liveNode = new JMSServerManagerImpl(server0); liveNode.setRegistry(new JndiBindingRegistry(liveContext)); // backup Configuration config = createBasicConfig() .setJournalDirectory(getJournalDir(id, true)) .setBindingsDirectory(getBindingsDir(id, true)) .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params)) .addConnectorConfiguration(backupConnector.getName(), backupConnector) .addConnectorConfiguration(liveConnector.getName(), liveConnector) .setHAPolicyConfiguration(new ReplicaPolicyConfiguration()) .addClusterConfiguration( basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName())); ActiveMQServer backup = addServer(ActiveMQServers.newActiveMQServer(config, true)); Context context = new InVMContext(); backupNode = new JMSServerManagerImpl(backup); backupNode.setRegistry(new JndiBindingRegistry(context)); }