@Override protected void createConfigs() throws Exception { Configuration config1 = super.createDefaultConfig(); config1.setBindingsDirectory(config1.getBindingsDirectory() + "_backup"); config1.setJournalDirectory(config1.getJournalDirectory() + "_backup"); config1.getAcceptorConfigurations().clear(); config1.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(false)); config1.setSecurityEnabled(false); config1.setSharedStore(false); config1.setBackup(true); server1Service = super.createServer(true, config1); Configuration config0 = super.createDefaultConfig(); config0.getAcceptorConfigurations().clear(); config0.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true)); config0.getConnectorConfigurations().put("toBackup", getConnectorTransportConfiguration(false)); config0.setBackupConnectorName("toBackup"); config0.setSecurityEnabled(false); config0.setSharedStore(false); server0Service = super.createServer(true, config0); server1Service.start(); server0Service.start(); }
protected void createConfigs() throws Exception { nodeManager = new InVMNodeManager(); backupConfig = super.createDefaultConfig(); backupConfig.getAcceptorConfigurations().clear(); backupConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(false)); backupConfig.setSharedStore(true); backupConfig.setBackup(true); backupConfig.setClustered(true); TransportConfiguration liveConnector = getConnectorTransportConfiguration(true); TransportConfiguration backupConnector = getConnectorTransportConfiguration(false); backupConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector); backupConfig.getConnectorConfigurations().put(backupConnector.getName(), backupConnector); ReplicatedBackupUtils.createClusterConnectionConf( backupConfig, backupConnector.getName(), liveConnector.getName()); backupServer = createTestableServer(backupConfig); liveConfig = super.createDefaultConfig(); liveConfig.getAcceptorConfigurations().clear(); liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true)); liveConfig.setSharedStore(true); liveConfig.setClustered(true); ReplicatedBackupUtils.createClusterConnectionConf(liveConfig, liveConnector.getName()); liveConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector); liveServer = createTestableServer(liveConfig); }
protected void createLiveConfig(NodeManager nodeManager, int liveNode, int... otherLiveNodes) throws Exception { TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(liveNode, isNetty())); Configuration config0 = super.createDefaultConfig(); config0.getAcceptorConfigurations().clear(); config0 .getAcceptorConfigurations() .add(createTransportConfiguration(isNetty(), true, generateParams(liveNode, isNetty()))); config0.setSecurityEnabled(false); config0.setSharedStore(true); List<String> pairs = new ArrayList<String>(); for (int node : otherLiveNodes) { TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); config0.getConnectorConfigurations().put(otherLiveConnector.getName(), otherLiveConnector); pairs.add(otherLiveConnector.getName()); } basicClusterConnectionConfig(config0, liveConnector.getName(), pairs); config0.getConnectorConfigurations().put(liveConnector.getName(), liveConnector); config0.setBindingsDirectory(config0.getBindingsDirectory() + "_" + liveNode); config0.setJournalDirectory(config0.getJournalDirectory() + "_" + liveNode); config0.setPagingDirectory(config0.getPagingDirectory() + "_" + liveNode); config0.setLargeMessagesDirectory(config0.getLargeMessagesDirectory() + "_" + liveNode); servers.put( liveNode, new SameProcessHornetQServer( createInVMFailoverServer(true, config0, nodeManager, liveNode))); }
protected void createBackupConfig( NodeManager nodeManager, int liveNode, int nodeid, boolean createClusterConnections, int[] otherBackupNodes, int... otherClusterNodes) throws Exception { Configuration config1 = super.createDefaultConfig(); config1.getAcceptorConfigurations().clear(); config1 .getAcceptorConfigurations() .add(createTransportConfiguration(isNetty(), true, generateParams(nodeid, isNetty()))); config1.setSecurityEnabled(false); config1.setSharedStore(true); config1.setBackup(true); List<String> staticConnectors = new ArrayList<String>(); for (int node : otherBackupNodes) { TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); config1.getConnectorConfigurations().put(liveConnector.getName(), liveConnector); staticConnectors.add(liveConnector.getName()); } TransportConfiguration backupConnector = createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty())); config1.getConnectorConfigurations().put(backupConnector.getName(), backupConnector); List<String> clusterNodes = new ArrayList<String>(); for (int node : otherClusterNodes) { TransportConfiguration connector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); config1.getConnectorConfigurations().put(connector.getName(), connector); clusterNodes.add(connector.getName()); } basicClusterConnectionConfig(config1, backupConnector.getName(), clusterNodes); config1.setBindingsDirectory(config1.getBindingsDirectory() + "_" + liveNode); config1.setJournalDirectory(config1.getJournalDirectory() + "_" + liveNode); config1.setPagingDirectory(config1.getPagingDirectory() + "_" + liveNode); config1.setLargeMessagesDirectory(config1.getLargeMessagesDirectory() + "_" + liveNode); servers.put( nodeid, new SameProcessHornetQServer( createInVMFailoverServer(true, config1, nodeManager, liveNode))); }
/** @throws Exception */ protected void startServers() throws Exception { NodeManager nodeManager = new InVMNodeManager(false); 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); backupConf = createBasicConfig(0); backupConf.getAcceptorConfigurations().add(backupAcceptortc); backupConf.getConnectorConfigurations().put(livetc.getName(), livetc); backupConf.getConnectorConfigurations().put(backuptc.getName(), backuptc); basicClusterConnectionConfig(backupConf, backuptc.getName(), livetc.getName()); backupConf.setSecurityEnabled(false); backupConf.setJournalType(getDefaultJournalType()); backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1); backupConf .getAcceptorConfigurations() .add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)); backupConf.setBackup(true); backupConf.setSharedStore(true); backupConf.setBindingsDirectory(getBindingsDir()); backupConf.setJournalMinFiles(2); backupConf.setJournalDirectory(getJournalDir()); backupConf.setPagingDirectory(getPageDir()); backupConf.setLargeMessagesDirectory(getLargeMessagesDir()); backupConf.setPersistenceEnabled(true); backupService = new InVMNodeManagerServer(backupConf, nodeManager); backupJMSService = new JMSServerManagerImpl(backupService); backupJMSService.setContext(ctx2); backupJMSService.getHornetQServer().setIdentity("JMSBackup"); log.info("Starting backup"); backupJMSService.start(); liveConf = createBasicConfig(0); liveConf.setJournalDirectory(getJournalDir()); liveConf.setBindingsDirectory(getBindingsDir()); liveConf.setSecurityEnabled(false); liveConf.getAcceptorConfigurations().add(liveAcceptortc); basicClusterConnectionConfig(liveConf, livetc.getName()); liveConf.setSharedStore(true); liveConf.setJournalType(getDefaultJournalType()); liveConf.setBindingsDirectory(getBindingsDir()); liveConf.setJournalMinFiles(2); liveConf.setJournalDirectory(getJournalDir()); liveConf.setPagingDirectory(getPageDir()); liveConf.setLargeMessagesDirectory(getLargeMessagesDir()); liveConf.getConnectorConfigurations().put(livetc.getName(), livetc); liveConf.setPersistenceEnabled(true); liveService = new InVMNodeManagerServer(liveConf, nodeManager); liveJMSService = new JMSServerManagerImpl(liveService); liveJMSService.setContext(ctx1); liveJMSService.getHornetQServer().setIdentity("JMSLive"); log.info("Starting life"); liveJMSService.start(); JMSUtil.waitForServer(backupService); }