private void configureHttpMethod(
      boolean skipContentCache, CacheData cacheData, long onceTimeOut, HttpMethod httpMethod) {
    if (skipContentCache && null != cacheData) {
      if (null != cacheData.getLastModifiedHeader()
          && Constants.NULL != cacheData.getLastModifiedHeader()) {
        httpMethod.addRequestHeader(Constants.IF_MODIFIED_SINCE, cacheData.getLastModifiedHeader());
      }
      if (null != cacheData.getMd5() && Constants.NULL != cacheData.getMd5()) {
        httpMethod.addRequestHeader(Constants.CONTENT_MD5, cacheData.getMd5());
      }
    }

    httpMethod.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate");

    HttpMethodParams params = new HttpMethodParams();
    params.setSoTimeout((int) onceTimeOut);
    httpMethod.setParams(params);
    httpClient
        .getHostConfiguration()
        .setHost(
            diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
            diamondConfigure.getPort());
  }
  Set<String> checkUpdateDataIds(long timeout) {
    if (!isRun) {
      throw new RuntimeException("DiamondSubscriber is not running. checkUpdateDataIds return.");
    }
    if (MockServer.isTestMode()) {
      return testData();
    }
    long waitTime = 0;

    String probeUpdateString = getProbeUpdateString();
    if (StringUtils.isBlank(probeUpdateString)) {
      return null;
    }

    while (0 == timeout || timeout > waitTime) {
      long onceTimeOut = getOnceTimeOut(waitTime, timeout);
      waitTime += onceTimeOut;

      PostMethod postMethod = new PostMethod(Constants.HTTP_URI_FILE);

      postMethod.addParameter(Constants.PROBE_MODIFY_REQUEST, probeUpdateString);

      HttpMethodParams params = new HttpMethodParams();
      params.setSoTimeout((int) onceTimeOut);
      postMethod.setParams(params);

      try {
        httpClient
            .getHostConfiguration()
            .setHost(
                diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
                this.diamondConfigure.getPort());

        int httpStatus = httpClient.executeMethod(postMethod);

        switch (httpStatus) {
          case SC_OK:
            {
              Set<String> result = getUpdateDataIds(postMethod);
              return result;
            }

          case SC_SERVICE_UNAVAILABLE:
            {
              rotateToNextDomain();
            }
            break;

          default:
            {
              log.warn("checkUpdateDataIds HTTP State: " + httpStatus);
              rotateToNextDomain();
            }
        }
      } catch (HttpException e) {
        log.error("checkUpdateDataIds HttpException", e);
        rotateToNextDomain();
      } catch (IOException e) {
        log.error("checkUpdateDataIds IOException", e);
        rotateToNextDomain();
      } catch (Exception e) {
        log.error("checkUpdateDataIds Unknown Exception", e);
        rotateToNextDomain();
      } finally {
        postMethod.releaseConnection();
      }
    }
    throw new RuntimeException(
        "checkUpdateDataIds timeout "
            + diamondConfigure.getDomainNameList().get(this.domainNamePos.get())
            + ", timeout="
            + timeout);
  }
  @Override
  public BatchHttpResult getConfigureInformationBatch(
      List<String> dataIds, String group, int timeout) {
    if (dataIds == null) {
      log.error("dataId list cannot be null,group=" + group);
      return new BatchHttpResult(HttpStatus.SC_BAD_REQUEST);
    }
    if (group == null) {
      group = Constants.DEFAULT_GROUP;
    }

    StringBuilder dataIdBuilder = new StringBuilder();
    for (String dataId : dataIds) {
      dataIdBuilder.append(dataId).append(Constants.LINE_SEPARATOR);
    }
    String dataIdStr = dataIdBuilder.toString();

    PostMethod post = new PostMethod(Constants.HTTP_URI_FILE_BATCH);
    post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, timeout);

    BatchHttpResult response = null;
    try {
      NameValuePair dataIdValue = new NameValuePair("dataIds", dataIdStr);
      NameValuePair groupValue = new NameValuePair("group", group);

      post.setRequestBody(new NameValuePair[] {dataIdValue, groupValue});

      httpClient
          .getHostConfiguration()
          .setHost(
              diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
              this.diamondConfigure.getPort());
      int status = httpClient.executeMethod(post);
      String responseMsg = post.getResponseBodyAsString();

      if (status == HttpStatus.SC_OK) {
        String json = null;
        try {
          json = responseMsg;

          List<ConfigInfoEx> configInfoExList = new LinkedList<ConfigInfoEx>();
          Object resultObj =
              JSONUtils.deserializeObject(json, new TypeReference<List<ConfigInfoEx>>() {});
          if (!(resultObj instanceof List<?>)) {
            throw new RuntimeException(
                "batch query deserialize type error, not list, json=" + json);
          }
          List<ConfigInfoEx> resultList = (List<ConfigInfoEx>) resultObj;
          for (ConfigInfoEx configInfoEx : resultList) {
            configInfoExList.add(configInfoEx);
          }

          response = new BatchHttpResult(configInfoExList);
          log.info(
              "batch query success,dataIds=" + dataIdStr + ",group=" + group + ",json=" + json);
        } catch (Exception e) {
          response = new BatchHttpResult(Constants.BATCH_OP_ERROR);
          log.error(
              "batch query deserialize error,dataIdStr="
                  + dataIdStr
                  + ",group="
                  + group
                  + ",json="
                  + json,
              e);
        }

      } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) {
        response = new BatchHttpResult(HttpStatus.SC_REQUEST_TIMEOUT);
        log.error(
            "batch query timeout, socket timeout(ms):"
                + timeout
                + ",dataIds="
                + dataIdStr
                + ",group="
                + group);
      } else {
        response = new BatchHttpResult(status);
        log.error(
            "batch query fail, status:"
                + status
                + ", response:"
                + responseMsg
                + ",dataIds="
                + dataIdStr
                + ",group="
                + group);
      }
    } catch (HttpException e) {
      response = new BatchHttpResult(Constants.BATCH_HTTP_EXCEPTION);
      log.error("batch query http exception,dataIds=" + dataIdStr + ",group=" + group, e);
    } catch (IOException e) {
      response = new BatchHttpResult(Constants.BATCH_IO_EXCEPTION);
      log.error("batch query io exception, dataIds=" + dataIdStr + ",group=" + group, e);
    } finally {
      post.releaseConnection();
    }

    return response;
  }