@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();
  }
Esempio n. 2
0
  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 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)));
  }
Esempio n. 4
0
  private void setupServer(boolean backup, String... interceptors) throws Exception {

    final TransportConfiguration liveConnector = TransportConfigurationUtils.getInVMConnector(true);
    final TransportConfiguration backupConnector =
        TransportConfigurationUtils.getInVMConnector(false);
    final TransportConfiguration backupAcceptor =
        TransportConfigurationUtils.getInVMAcceptor(false);

    Configuration backupConfig = createDefaultConfig();
    Configuration liveConfig = createDefaultConfig();

    backupConfig.setBackup(backup);

    final String suffix = "_backup";
    backupConfig.setBindingsDirectory(backupConfig.getBindingsDirectory() + suffix);
    backupConfig.setJournalDirectory(backupConfig.getJournalDirectory() + suffix);
    backupConfig.setPagingDirectory(backupConfig.getPagingDirectory() + suffix);
    backupConfig.setLargeMessagesDirectory(backupConfig.getLargeMessagesDirectory() + suffix);

    if (interceptors.length > 0) {
      List<String> interceptorsList = Arrays.asList(interceptors);
      backupConfig.setIncomingInterceptorClassNames(interceptorsList);
    }

    ReplicatedBackupUtils.configureReplicationPair(
        backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector);
    if (backup) {
      liveServer = createServer(liveConfig);
      liveServer.start();
      waitForComponent(liveServer);
    }

    backupServer = createServer(backupConfig);
    locator = createInVMNonHALocator();
    backupServer.start();
    if (backup) {
      ServiceTestBase.waitForRemoteBackup(null, 5, true, backupServer);
    }
    int count = 0;
    waitForReplication(count);
  }
  /** @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);
  }