@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 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 createReplicatedConfigs() throws Exception {
    nodeManager = new InVMNodeManager();

    final TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
    final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    final TransportConfiguration backupAcceptor = getAcceptorTransportConfiguration(false);

    nodeManager = new InVMNodeManager();
    backupConfig = createDefaultConfig();
    liveConfig = createDefaultConfig();

    ReplicatedBackupUtils.configureReplicationPair(
        backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector);

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

    backupServer = createTestableServer(backupConfig);
    liveConfig.getAcceptorConfigurations().clear();
    liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));

    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)));
  }
  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);
  }
  private Configuration getConfiguration(
      String identity,
      BackupStrategy backupStrategy,
      TransportConfiguration liveConnector,
      TransportConfiguration liveAcceptor,
      TransportConfiguration... otherLiveNodes)
      throws Exception {
    Configuration configuration = createDefaultConfig();
    configuration.getAcceptorConfigurations().clear();
    configuration.getAcceptorConfigurations().add(liveAcceptor);
    configuration.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
    configuration.setJournalDirectory(configuration.getJournalDirectory() + identity);
    configuration.setBindingsDirectory(configuration.getBindingsDirectory() + identity);
    configuration.setLargeMessagesDirectory(configuration.getLargeMessagesDirectory() + identity);
    configuration.setPagingDirectory(configuration.getPagingDirectory() + identity);
    List<String> transportConfigurationList = new ArrayList<>();
    final HAPolicy haPolicy = new HAPolicy();
    for (TransportConfiguration otherLiveNode : otherLiveNodes) {
      configuration.getConnectorConfigurations().put(otherLiveNode.getName(), otherLiveNode);
      transportConfigurationList.add(otherLiveNode.getName());
      haPolicy.getRemoteConnectors().add(otherLiveNode.getName());
    }
    basicClusterConnectionConfig(
        configuration, liveConnector.getName(), transportConfigurationList);
    configuration
        .getQueueConfigurations()
        .add(new CoreQueueConfiguration("jms.queue.testQueue", "jms.queue.testQueue", null, true));

    haPolicy.setPolicyType(policyType);
    haPolicy.setBackupStrategy(backupStrategy);
    haPolicy.setBackupPortOffset(100);
    haPolicy.setBackupRequestRetries(-1);
    haPolicy.setBackupRequestRetryInterval(500);
    haPolicy.setMaxBackups(1);
    haPolicy.setRequestBackup(true);
    configuration.setHAPolicy(haPolicy);

    return configuration;
  }
  public void testGetAttributes() throws Exception {
    HornetQServerControl serverControl = createManagementControl();

    Assert.assertEquals(server.getVersion().getFullVersion(), serverControl.getVersion());

    Assert.assertEquals(conf.isClustered(), serverControl.isClustered());
    Assert.assertEquals(
        conf.isPersistDeliveryCountBeforeDelivery(),
        serverControl.isPersistDeliveryCountBeforeDelivery());
    Assert.assertEquals(conf.isBackup(), serverControl.isBackup());
    Assert.assertEquals(conf.isSharedStore(), serverControl.isSharedStore());
    Assert.assertEquals(
        conf.getScheduledThreadPoolMaxSize(), serverControl.getScheduledThreadPoolMaxSize());
    Assert.assertEquals(conf.getThreadPoolMaxSize(), serverControl.getThreadPoolMaxSize());
    Assert.assertEquals(
        conf.getSecurityInvalidationInterval(), serverControl.getSecurityInvalidationInterval());
    Assert.assertEquals(conf.isSecurityEnabled(), serverControl.isSecurityEnabled());
    Assert.assertEquals(
        conf.isAsyncConnectionExecutionEnabled(),
        serverControl.isAsyncConnectionExecutionEnabled());
    Assert.assertEquals(
        conf.getInterceptorClassNames().size(), serverControl.getInterceptorClassNames().length);
    Assert.assertEquals(conf.getConnectionTTLOverride(), serverControl.getConnectionTTLOverride());
    // Assert.assertEquals(conf.getBackupConnectorName(), serverControl.getBackupConnectorName());
    Assert.assertEquals(
        conf.getManagementAddress().toString(), serverControl.getManagementAddress());
    Assert.assertEquals(
        conf.getManagementNotificationAddress().toString(),
        serverControl.getManagementNotificationAddress());
    Assert.assertEquals(conf.getIDCacheSize(), serverControl.getIDCacheSize());
    Assert.assertEquals(conf.isPersistIDCache(), serverControl.isPersistIDCache());
    Assert.assertEquals(conf.getBindingsDirectory(), serverControl.getBindingsDirectory());
    Assert.assertEquals(conf.getJournalDirectory(), serverControl.getJournalDirectory());
    Assert.assertEquals(conf.getJournalType().toString(), serverControl.getJournalType());
    Assert.assertEquals(
        conf.isJournalSyncTransactional(), serverControl.isJournalSyncTransactional());
    Assert.assertEquals(
        conf.isJournalSyncNonTransactional(), serverControl.isJournalSyncNonTransactional());
    Assert.assertEquals(conf.getJournalFileSize(), serverControl.getJournalFileSize());
    Assert.assertEquals(conf.getJournalMinFiles(), serverControl.getJournalMinFiles());
    if (AsynchronousFileImpl.isLoaded()) {
      Assert.assertEquals(conf.getJournalMaxIO_AIO(), serverControl.getJournalMaxIO());
      Assert.assertEquals(conf.getJournalBufferSize_AIO(), serverControl.getJournalBufferSize());
      Assert.assertEquals(
          conf.getJournalBufferTimeout_AIO(), serverControl.getJournalBufferTimeout());
    }
    Assert.assertEquals(conf.isCreateBindingsDir(), serverControl.isCreateBindingsDir());
    Assert.assertEquals(conf.isCreateJournalDir(), serverControl.isCreateJournalDir());
    Assert.assertEquals(conf.getPagingDirectory(), serverControl.getPagingDirectory());
    Assert.assertEquals(
        conf.getLargeMessagesDirectory(), serverControl.getLargeMessagesDirectory());
    Assert.assertEquals(conf.isWildcardRoutingEnabled(), serverControl.isWildcardRoutingEnabled());
    Assert.assertEquals(conf.getTransactionTimeout(), serverControl.getTransactionTimeout());
    Assert.assertEquals(conf.isMessageCounterEnabled(), serverControl.isMessageCounterEnabled());
    Assert.assertEquals(
        conf.getTransactionTimeoutScanPeriod(), serverControl.getTransactionTimeoutScanPeriod());
    Assert.assertEquals(
        conf.getMessageExpiryScanPeriod(), serverControl.getMessageExpiryScanPeriod());
    Assert.assertEquals(
        conf.getMessageExpiryThreadPriority(), serverControl.getMessageExpiryThreadPriority());
    Assert.assertEquals(
        conf.getJournalCompactMinFiles(), serverControl.getJournalCompactMinFiles());
    Assert.assertEquals(
        conf.getJournalCompactPercentage(), serverControl.getJournalCompactPercentage());
    Assert.assertEquals(conf.isPersistenceEnabled(), serverControl.isPersistenceEnabled());
    Assert.assertEquals(
        conf.isFailoverOnServerShutdown(), serverControl.isFailoverOnServerShutdown());
  }