@Override
  public int addZooKeeper(ZooKeeperCluster zooKeeperCluster) throws DaoException {
    if (null == zooKeeperCluster) return -1;

    try {
      String serverListString = CollectionUtil.toString(zooKeeperCluster.getServerList());

      String insertSql =
          StringUtil.replaceSequenced(
              SQL_ADD_ZOOKEEPER_CLUSTER,
              zooKeeperCluster.getClusterName(),
              serverListString,
              zooKeeperCluster.getDescription());
      int key = DbcpUtil.executeInsertAndReturnGeneratedKeys(insertSql);
      return key;
    } catch (Exception e) {
      throw new DaoException(
          "Error when add zooKeeperCluster" + zooKeeperCluster + ", Error: " + e.getMessage(), e);
    }
  }
  @Override
  public boolean updateZooKeeperSettingsByClusterId(ZooKeeperCluster zooKeeperCluster)
      throws DaoException {

    if (null == zooKeeperCluster) return false;

    // 从数据库中获取指定zookeeper集群中所有机器
    try {
      String serverListString = EMPTY_STRING;
      List<String> serverList = zooKeeperCluster.getServerList();
      if (null != serverList && !serverList.isEmpty()) {
        for (String server : serverList) {
          serverListString += server + COMMA;
        }
        serverListString = StringUtil.replaceLast(serverListString, COMMA, EMPTY_STRING);
      }

      String updateSql =
          StringUtil.replaceSequenced(
              SQL_UPDATE_ZOOKEEPER_CLUSTER_SETTINGS_BY_ID,
              zooKeeperCluster.getClusterName(),
              serverListString,
              zooKeeperCluster.getDescription(),
              zooKeeperCluster.getClusterId() + EMPTY_STRING);
      int num = DbcpUtil.executeUpdate(updateSql);
      if (1 == num) {
        return true;
      }
      return false;
    } catch (Exception e) {
      throw new DaoException(
          "Error when update zooKeeperCluster by cluster_id: "
              + zooKeeperCluster
              + ", Error: "
              + e.getMessage(),
          e);
    }
  }