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 readStatisticsLogsClients(
      Integer numOfClients, List<ICreateTable> baseTables, String directory) {

    for (ICreateTable createTable : baseTables) {

      int x = 0;

      while (x < numOfClients) {

        Node node = NetworkConfig.CLIENTS.get(x % NetworkConfig.CLIENTS.size());
        log.info(
            this.getClass(),
            "reading statistics log of client "
                + "c"
                + (x + 1)
                + "-filltable-"
                + createTable.getName()
                + " on node: "
                + node);
        SSHService.retrieveFile(
            log,
            node.getSshConnection(),
            SystemConfig.DIRECTORY_VMSYSTEM + "/logs",
            directory + "",
            "c" + (x + 1) + "-filltable-" + createTable.getName() + ".log");
        x++;
      }
    }
  }
  private void readStatisticsLogsRegionServers(int numOfRs, String directory) {

    int x = 0;

    while (x < numOfRs) {

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

      log.info(
          this.getClass(),
          "reading statistics log of region server rs" + (x + 1) + " on node: " + node);
      SSHService.retrieveFile(
          log,
          node.getSshConnection(),
          SystemConfig.DIRECTORY_VMSYSTEM + "/logs",
          directory + "/regionserverStatistics",
          "rs" + (x + 1) + "-statistic.log");
      SSHService.retrieveFile(
          log,
          node.getSshConnection(),
          SystemConfig.DIRECTORY_VMSYSTEM + "/logs",
          directory + "/regionserverLogs",
          "rs" + (x + 1) + ".log");

      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");
  }
  public void createTable(int numOfClients, ICreateTable createTable) {

    log.info(this.getClass(), "");
    log.info(this.getClass(), "client nodes: " + numOfClients);
    log.info(this.getClass(), "creating table");
    log.info(this.getClass(), "name: " + createTable.getName());
    log.info(this.getClass(), "type: " + createTable.getType());

    Node node = NetworkConfig.CLIENTS.get(0);
    List<String> startupCommand = new ArrayList<String>();
    startupCommand.add("cd /");
    startupCommand.add("cd " + SystemConfig.DIRECTORY_VMSYSTEM);

    //		TableDefinition tableDefinition = DatabaseConfig.getTableDefinition(createTable.getName());

    //		if(tableDefinition == null){
    //			log.info(this.getClass(), "create standard table");
    //			startupCommand.add("nohup java -cp vmsystem.jar de.webdataplatform.client.ClientProcess
    // ccreatetable createtable "+createTable.getName()+" &");
    //
    //		}else{
    log.info(this.getClass(), "create split table");
    startupCommand.add(
        "java -cp vmsystem.jar de.webdataplatform.client.ClientProcess ccreatetable createsplittable "
            + createTable.getName()
            + " "
            + createTable.getNumOfRegions());

    //		}

    log.info(this.getClass(), "starting client:" + node);
    List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);

    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");
  }
  private void stopRegionServers(int numOfRs) {

    int x = 0;

    while (x < numOfRs) {

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

      log.info(this.getClass(), "stopping region server:" + node);

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

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

    int x = 0;

    while (x < numOfClients) {

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

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

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

      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), stopCommand);
      x++;
    }
    log.info(this.getClass(), "\n");
  }
  public void fillBaseTable(Integer numOfClients, CreateBaseTable createBaseTable) {

    log.info(this.getClass(), "filling base table " + createBaseTable);
    log.info(this.getClass(), "using  " + numOfClients + " client");
    log.info(
        this.getClass(),
        "" + (createBaseTable.getNumOfOperations() / numOfClients) + " operations per client");

    int x = 0;

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

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

      List<String> startupCommand = new ArrayList<String>();
      startupCommand.add("cd /");
      startupCommand.add("cd " + SystemConfig.DIRECTORY_VMSYSTEM);
      startupCommand.add(
          "java -cp vmsystem.jar de.webdataplatform.client.ClientProcess c"
              + (x + 1)
              + " filltable "
              + createBaseTable.getName()
              + " "
              + createBaseTable.getDistribution()
              + " "
              + (createBaseTable.getNumOfOperations() / numOfClients));

      log.info(this.getClass(), "starting client:" + node);
      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);
      x++;
      //			try {
      //				Thread.sleep(2000);
      //			} catch (InterruptedException e) {
      //
      //				e.printStackTrace();
      //			}

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

    log.info(this.getClass(), "");
    log.info(this.getClass(), "region server nodes: " + numOfRs);
    log.info(this.getClass(), "");

    int x = 0;

    while (x < numOfRs) {

      Node node = NetworkConfig.REGIONSERVERS.get(x % NetworkConfig.REGIONSERVERS.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.regionserver.TestRegionServer rs"
              + (x + 1)
              + " "
              + node.getIpAddress()
              + " "
              + node.getMessagePort());

      log.info(this.getClass(), "starting region server:" + node);
      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);

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

        e.printStackTrace();
      }

      x++;
    }

    log.info(this.getClass(), "\n");
  }
  public void queueMarkers(List<CreateBaseTable> createTables) {

    Node node = NetworkConfig.CLIENTS.get(0);

    for (CreateBaseTable createTable : createTables) {

      List<String> startupCommand = new ArrayList<String>();
      startupCommand.add("cd /");
      startupCommand.add("cd " + SystemConfig.DIRECTORY_VMSYSTEM);

      log.info(this.getClass(), "queue markers to base table");
      startupCommand.add(
          "java -cp vmsystem.jar de.webdataplatform.client.ClientProcess cqueuemarker queuefinishmarkers "
              + createTable.getName()
              + " "
              + createTable.getNumOfRegions());

      log.info(this.getClass(), "starting client:" + node);
      List<String> result = SSHService.sendCommand(log, node.getSshConnection(), startupCommand);

      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");
  }