private void killViewManagers(Integer numOfKilledViewManagers) {

    log.info(this.getClass(), "viewmanager nodes: " + NetworkConfig.VIEWMANAGERS.size());
    log.info(this.getClass(), "Instances to kill: " + numOfKilledViewManagers);

    log.info(this.getClass(), "");

    int x = 0;

    //			int updatePort = vmUpdatePort;
    //			int messagePort = vmMessagePort;
    while (x < numOfKilledViewManagers) {

      Node node = NetworkConfig.VIEWMANAGERS.get(x % NetworkConfig.VIEWMANAGERS.size());

      List<String> startupCommand = new ArrayList<String>();

      startupCommand.add("pkill -9 -f vm" + (x + 1));
      log.info(this.getClass(), "killing viewmanager vm" + (x + 1) + " on node: " + node);
      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);

      x++;
    }

    log.info(this.getClass(), "\n");
  }
  private void readStatisticsLogsViewManagers(Integer viewManagerInstances, String directory) {

    int x = 0;

    while (x < viewManagerInstances) {

      Node node = NetworkConfig.VIEWMANAGERS.get(x % NetworkConfig.VIEWMANAGERS.size());

      log.info(
          this.getClass(),
          "reading statistics log of viewmanager vm" + (x + 1) + " on node: " + node);
      SSHService.retrieveFile(
          log,
          node.getSshConnection(),
          SystemConfig.DIRECTORY_VMSYSTEM + "/logs",
          directory + "/viewmanagerStatistics",
          "vm" + (x + 1) + "-statistic.log");
      SSHService.retrieveFile(
          log,
          node.getSshConnection(),
          SystemConfig.DIRECTORY_VMSYSTEM + "/logs",
          directory + "/viewmanagerLogs",
          "vm" + (x + 1) + ".log");

      x++;
    }

    log.info(this.getClass(), "\n");
  }
  private void startViewManagers(Integer viewManagerInstances) {

    Integer instancesPerNode = (viewManagerInstances / NetworkConfig.VIEWMANAGERS.size()) + 1;
    if (instancesPerNode == 0) instancesPerNode = 1;

    //		log.info(this.getClass(), "viewmanager nodes: "+NetworkConfig.VIEWMANAGERS.size());
    log.info(this.getClass(), "viewManagerInstances: " + viewManagerInstances);
    log.info(this.getClass(), "instancesPerNode: " + instancesPerNode);
    log.info(this.getClass(), "");

    int x = 0;

    //			int messagePort = vmMessagePort;
    while (x < viewManagerInstances) {

      Node node = NetworkConfig.VIEWMANAGERS.get(x % NetworkConfig.VIEWMANAGERS.size());
      int updatePort = node.getUpdatePort() + (x / NetworkConfig.VIEWMANAGERS.size());
      int messagePort = node.getMessagePort() + (x / NetworkConfig.VIEWMANAGERS.size());

      List<String> startupCommand = new ArrayList<String>();
      startupCommand.add("cd /");
      startupCommand.add("cd " + SystemConfig.DIRECTORY_VMSYSTEM);
      startupCommand.add(
          "java  -Xmx1000m -cp vmsystem.jar de.webdataplatform.viewmanager.TestViewManager vm"
              + (x + 1)
              + " "
              + node.getIpAddress()
              + " "
              + updatePort
              + " "
              + messagePort);
      log.info(
          this.getClass(),
          "starting viewmanager vm"
              + (x + 1)
              + " on node: "
              + node.getIpAddress()
              + " udpatePort:"
              + updatePort
              + ", messagePort:"
              + messagePort);
      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);

      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {

        e.printStackTrace();
      }
      x++;
    }

    log.info(this.getClass(), "\n");
  }
  private void stopViewManagers(int viewManagerInstances) {

    int x = 0;

    while (x < viewManagerInstances) {

      Node node = NetworkConfig.VIEWMANAGERS.get(x % NetworkConfig.VIEWMANAGERS.size());

      log.info(this.getClass(), "stopping view manager:" + node);

      List<String> stopCommand = new ArrayList<String>();
      stopCommand.add("pkill -9 -f TestViewManager");

      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), stopCommand);
      x++;
    }
    log.info(this.getClass(), "\n");
  }