List of usage examples for org.apache.commons.httpclient.params HttpMethodParams SO_TIMEOUT
String SO_TIMEOUT
To view the source code for org.apache.commons.httpclient.params HttpMethodParams SO_TIMEOUT.
Click Source Link
From source file:com.taobao.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
private ContextResult processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context, String serverId) { ContextResult response = new ContextResult(); // //from w w w . j a v a 2 s . c om if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg(",serverId"); return response; } if (log.isDebugEnabled()) log.debug("processPulishAfterModifiedByDefinedServerId(" + dataId + "," + groupName + "," + context + "," + serverId + ")"); // dataId,groupName ContextResult result = null; result = queryByDataIdAndGroupName(dataId, groupName, serverId); if (null == result || !result.isSuccess()) { response.setSuccess(false); response.setStatusMsg("!"); log.warn("! dataId=" + dataId + ",group=" + groupName + ",serverId=" + serverId); return response; } // else { String postUrl = "/diamond-server/admin.do?method=updateConfig"; PostMethod post = new PostMethod(postUrl); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { NameValuePair dataId_value = new NameValuePair("dataId", dataId); NameValuePair group_value = new NameValuePair("group", groupName); NameValuePair content_value = new NameValuePair("content", context); // post.setRequestBody(new NameValuePair[] { dataId_value, group_value, content_value }); // ConfigInfo configInfo = new ConfigInfo(); configInfo.setDataId(dataId); configInfo.setGroup(groupName); configInfo.setContent(context); if (log.isDebugEnabled()) log.debug("ConfigInfo: " + configInfo); // response.setConfigInfo(configInfo); // http int status = client.executeMethod(post); response.setReceiveResult(post.getResponseBodyAsString()); response.setStatusCode(status); log.info("" + status + "," + post.getResponseBodyAsString()); if (status == HttpStatus.SC_OK) { response.setSuccess(true); response.setStatusMsg(""); log.info(""); } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg(":" + require_timeout + ""); log.error(":" + require_timeout + ", dataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId); } else { response.setSuccess(false); response.setStatusMsg( ",ContextResultgetReceiveResult()"); log.error(":" + response.getReceiveResult() + ",dataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("HttpException" + e.getMessage()); log.error( "processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context,String serverId)HttpExceptiondataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId, e); return response; } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("IOException" + e.getMessage()); log.error( "processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context,String serverId)IOExceptiondataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId, e); return response; } finally { // post.releaseConnection(); } return response; } }
From source file:cn.leancloud.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
private ContextResult processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context, String serverId) { ContextResult response = new ContextResult(); // /*from w ww. java2 s . co m*/ if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg(",??serverId"); return response; } if (log.isDebugEnabled()) log.debug("processPulishAfterModifiedByDefinedServerId(" + dataId + "," + groupName + "," + context + "," + serverId + ")?"); // ?dataId,groupName? ContextResult result = null; result = queryByDataIdAndGroupName(dataId, groupName, serverId); if (null == result || !result.isSuccess()) { response.setSuccess(false); response.setStatusMsg("????!"); log.warn("????! dataId=" + dataId + ",group=" + groupName + ",serverId=" + serverId); return response; } // ? else { String postUrl = "/diamond-server/admin.do?method=updateConfig"; PostMethod post = new PostMethod(postUrl); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { NameValuePair dataId_value = new NameValuePair("dataId", dataId); NameValuePair group_value = new NameValuePair("group", groupName); NameValuePair content_value = new NameValuePair("content", context); // ? post.setRequestBody(new NameValuePair[] { dataId_value, group_value, content_value }); // ? ConfigInfo configInfo = new ConfigInfo(); configInfo.setDataId(dataId); configInfo.setGroup(groupName); configInfo.setContent(context); if (log.isDebugEnabled()) log.debug("?ConfigInfo: " + configInfo); // ?? response.setConfigInfo(configInfo); // http?? int status = client.executeMethod(post); response.setReceiveResult(post.getResponseBodyAsString()); response.setStatusCode(status); log.info("??" + status + ",?" + post.getResponseBodyAsString()); if (status == HttpStatus.SC_OK) { response.setSuccess(true); response.setStatusMsg("???"); log.info("???"); } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg( "??:" + require_timeout + ""); log.error("??:" + require_timeout + ", dataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId); } else { response.setSuccess(false); response.setStatusMsg( "??,ContextResultgetReceiveResult()"); log.error("??:" + response.getReceiveResult() + ",dataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("??HttpException" + e.getMessage()); log.error( "?processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context,String serverId)?HttpExceptiondataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId, e); return response; } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("??IOException" + e.getMessage()); log.error( "?processPulishAfterModifiedByDefinedServerId(String dataId, String groupName, String context,String serverId)?IOExceptiondataId=" + dataId + ",group=" + groupName + ",content=" + context + ",serverId=" + serverId, e); return response; } finally { // ? post.releaseConnection(); } return response; } }
From source file:com.taobao.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
/** * httpclient/* w w w . java 2 s . co m*/ * * @return true:,false: */ private boolean login(String serverId) { // serverId if (StringUtils.isEmpty(serverId) || StringUtils.isBlank(serverId)) return false; DiamondSDKConf defaultConf = diamondSDKConfMaps.get(serverId); log.info("[login] serverId:" + serverId + "," + defaultConf); if (null == defaultConf) return false; RandomDiamondUtils util = new RandomDiamondUtils(); // util.init(defaultConf.getDiamondConfs()); if (defaultConf.getDiamondConfs().size() == 0) return false; boolean flag = false; log.info("[randomSequence] : " + util.getSequenceToString()); // diamondConf while (util.getRetry_times() < util.getMax_times()) { // diamondConf DiamondConf diamondConf = util.generatorOneDiamondConf(); log.info("" + util.getRetry_times() + ":" + diamondConf); if (diamondConf == null) break; client.getHostConfiguration().setHost(diamondConf.getDiamondIp(), Integer.parseInt(diamondConf.getDiamondPort()), "http"); PostMethod post = new PostMethod("/diamond-server/login.do?method=login"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); // NameValuePair username_value = new NameValuePair("username", diamondConf.getDiamondUsername()); NameValuePair password_value = new NameValuePair("password", diamondConf.getDiamondPassword()); // post.setRequestBody(new NameValuePair[] { username_value, password_value }); log.info("diamondIp: " + diamondConf.getDiamondIp() + ",diamondPort: " + diamondConf.getDiamondPort() + ",diamondUsername: " + diamondConf.getDiamondUsername() + ",diamondPassword: " + diamondConf.getDiamondPassword() + "diamondServerUrl: [" + diamondConf.getDiamondConUrl() + "]"); try { int state = client.executeMethod(post); log.info("" + state); // 200,true if (state == HttpStatus.SC_OK) { log.info("" + util.getRetry_times() + ""); flag = true; break; } } catch (HttpException e) { log.error("HttpException", e); } catch (IOException e) { log.error("IOException", e); } finally { post.releaseConnection(); } } if (flag == false) { log.error("logindiamondServerserverId=" + serverId); } return flag; }
From source file:cn.leancloud.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
/** * httpclient?//from w ww. ja v a2 s .co m * * @return true:?,false: */ private boolean login(String serverId) { // serverId if (StringUtils.isEmpty(serverId) || StringUtils.isBlank(serverId)) return false; DiamondSDKConf defaultConf = diamondSDKConfMaps.get(serverId); log.info("[login] serverId:" + serverId + "," + defaultConf); if (null == defaultConf) return false; RandomDiamondUtils util = new RandomDiamondUtils(); // ??? util.init(defaultConf.getDiamondConfs()); if (defaultConf.getDiamondConfs().size() == 0) return false; boolean flag = false; log.info("[randomSequence] ?: " + util.getSequenceToString()); // ???diamondConf while (util.getRetry_times() < util.getMax_times()) { // ??diamondConf DiamondConf diamondConf = util.generatorOneDiamondConf(); log.info("" + util.getRetry_times() + "?:" + diamondConf); if (diamondConf == null) break; client.getHostConfiguration().setHost(diamondConf.getDiamondIp(), Integer.parseInt(diamondConf.getDiamondPort()), "http"); PostMethod post = new PostMethod("/diamond-server/login.do?method=login"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); // ??? NameValuePair username_value = new NameValuePair("username", diamondConf.getDiamondUsername()); NameValuePair password_value = new NameValuePair("password", diamondConf.getDiamondPassword()); // post.setRequestBody(new NameValuePair[] { username_value, password_value }); log.info("diamondIp: " + diamondConf.getDiamondIp() + ",diamondPort: " + diamondConf.getDiamondPort() + ",diamondUsername: " + diamondConf.getDiamondUsername() + ",diamondPassword: " + diamondConf.getDiamondPassword() + "diamondServerUrl: [" + diamondConf.getDiamondConUrl() + "]"); try { int state = client.executeMethod(post); log.info("??" + state); // ??200?,true if (state == HttpStatus.SC_OK) { log.info("" + util.getRetry_times() + "??"); flag = true; break; } } catch (HttpException e) { log.error("?HttpException", e); } catch (IOException e) { log.error("?IOException", e); } finally { post.releaseConnection(); } } if (flag == false) { log.error( "?login?diamondServer?????serverId=" + serverId); } return flag; }
From source file:com.taobao.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
private void configureGetMethod(GetMethod method) { method.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate"); method.addRequestHeader("Accept", "application/json"); // /*from w w w . j a v a2 s . c om*/ method.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); }
From source file:cn.leancloud.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
private void configureGetMethod(GetMethod method) { method.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate"); method.addRequestHeader("Accept", "application/json"); // /*from w w w . j a v a 2s . c o m*/ method.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); }
From source file:com.taobao.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
@Override public BatchContextResult<ConfigInfoEx> batchQuery(String serverId, String groupName, List<String> dataIds) { // //from w w w .j ava 2s.c o m BatchContextResult<ConfigInfoEx> response = new BatchContextResult<ConfigInfoEx>(); // listnull if (dataIds == null) { log.error("dataId list cannot be null, serverId=" + serverId + ",group=" + groupName); response.setSuccess(false); response.setStatusMsg("dataId list cannot be null"); return response; } // dataIdlist StringBuilder dataIdBuilder = new StringBuilder(); for (String dataId : dataIds) { dataIdBuilder.append(dataId).append(Constants.LINE_SEPARATOR); } String dataIdStr = dataIdBuilder.toString(); // if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg("login fail, serverId=" + serverId); return response; } // HTTP method PostMethod post = new PostMethod("/diamond-server/admin.do?method=batchQuery"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { // NameValuePair dataId_value = new NameValuePair("dataIds", dataIdStr); NameValuePair group_value = new NameValuePair("group", groupName); post.setRequestBody(new NameValuePair[] { dataId_value, group_value }); // http int status = client.executeMethod(post); response.setStatusCode(status); String responseMsg = post.getResponseBodyAsString(); response.setResponseMsg(responseMsg); if (status == HttpStatus.SC_OK) { String json = null; try { json = responseMsg; // json, BatchContextResult 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.getResult().addAll(configInfoExList); // , response.setSuccess(true); response.setStatusMsg("batch query success"); log.info("batch query success, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName + ",json=" + json); } catch (Exception e) { response.setSuccess(false); response.setStatusMsg("batch query deserialize error"); log.error("batch query deserialize error, serverId=" + serverId + ",dataIdStr=" + dataIdStr + ",group=" + groupName + ",json=" + json, e); } } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg("batch query timeout, socket timeout(ms):" + require_timeout); log.error("batch query timeout, socket timeout(ms):" + require_timeout + ", serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } else { response.setSuccess(false); response.setStatusMsg("batch query fail, status:" + status); log.error("batch query fail, status:" + status + ", response:" + responseMsg + ",serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("batch query http exception" + e.getMessage()); log.error("batch query http exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("batch query io exception" + e.getMessage()); log.error("batch query io exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } finally { // post.releaseConnection(); } return response; }
From source file:com.mengka.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
public BatchContextResult<ConfigInfoEx> batchQuery(String serverId, String groupName, List<String> dataIds) { // /* w w w.jav a 2s.c om*/ BatchContextResult<ConfigInfoEx> response = new BatchContextResult<ConfigInfoEx>(); // list?null if (dataIds == null) { log.error("dataId list cannot be null, serverId=" + serverId + ",group=" + groupName); response.setSuccess(false); response.setStatusMsg("dataId list cannot be null"); return response; } // dataIdlist???? StringBuilder dataIdBuilder = new StringBuilder(); for (String dataId : dataIds) { dataIdBuilder.append(dataId).append(Constants.LINE_SEPARATOR); } String dataIdStr = dataIdBuilder.toString(); // if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg("login fail, serverId=" + serverId); return response; } // HTTP method PostMethod post = new PostMethod("/diamond-server/admin.do?method=batchQuery"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { // ? NameValuePair dataId_value = new NameValuePair("dataIds", dataIdStr); NameValuePair group_value = new NameValuePair("group", groupName); post.setRequestBody(new NameValuePair[] { dataId_value, group_value }); // http?? int status = client.executeMethod(post); response.setStatusCode(status); String responseMsg = post.getResponseBodyAsString(); response.setResponseMsg(responseMsg); if (status == HttpStatus.SC_OK) { String json = null; try { json = responseMsg; // ???json, ??BatchContextResult 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.getResult().addAll(configInfoExList); // ????, ?? response.setSuccess(true); response.setStatusMsg("batch query success"); log.info("batch query success, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName + ",json=" + json); } catch (Exception e) { response.setSuccess(false); response.setStatusMsg("batch query deserialize error"); log.error("batch query deserialize error, serverId=" + serverId + ",dataIdStr=" + dataIdStr + ",group=" + groupName + ",json=" + json, e); } } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg("batch query timeout, socket timeout(ms):" + require_timeout); log.error("batch query timeout, socket timeout(ms):" + require_timeout + ", serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } else { response.setSuccess(false); response.setStatusMsg("batch query fail, status:" + status); log.error("batch query fail, status:" + status + ", response:" + responseMsg + ",serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("batch query http exception" + e.getMessage()); log.error("batch query http exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("batch query io exception" + e.getMessage()); log.error("batch query io exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } finally { // ? post.releaseConnection(); } return response; }
From source file:cn.leancloud.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
@Override public BatchContextResult<ConfigInfoEx> batchQuery(String serverId, String groupName, List<String> dataIds) { // /*from w w w . jav a 2 s . c o m*/ BatchContextResult<ConfigInfoEx> response = new BatchContextResult<ConfigInfoEx>(); // list?null if (dataIds == null) { log.error("dataId list cannot be null, serverId=" + serverId + ",group=" + groupName); response.setSuccess(false); response.setStatusMsg("dataId list cannot be null"); return response; } // dataIdlist???? StringBuilder dataIdBuilder = new StringBuilder(); for (String dataId : dataIds) { dataIdBuilder.append(dataId).append(Constants.LINE_SEPARATOR); } String dataIdStr = dataIdBuilder.toString(); // if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg("login fail, serverId=" + serverId); return response; } // HTTP method PostMethod post = new PostMethod("/diamond-server/admin.do?method=batchQuery"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { // ? NameValuePair dataId_value = new NameValuePair("dataIds", dataIdStr); NameValuePair group_value = new NameValuePair("group", groupName); post.setRequestBody(new NameValuePair[] { dataId_value, group_value }); // http?? int status = client.executeMethod(post); response.setStatusCode(status); String responseMsg = post.getResponseBodyAsString(); response.setResponseMsg(responseMsg); if (status == HttpStatus.SC_OK) { String json = null; try { json = responseMsg; // ???json, ??BatchContextResult 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.getResult().addAll(configInfoExList); // ????, ?? response.setSuccess(true); response.setStatusMsg("batch query success"); log.info("batch query success, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName + ",json=" + json); } catch (Exception e) { response.setSuccess(false); response.setStatusMsg("batch query deserialize error"); log.error("batch query deserialize error, serverId=" + serverId + ",dataIdStr=" + dataIdStr + ",group=" + groupName + ",json=" + json, e); } } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg("batch query timeout, socket timeout(ms):" + require_timeout); log.error("batch query timeout, socket timeout(ms):" + require_timeout + ", serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } else { response.setSuccess(false); response.setStatusMsg("batch query fail, status:" + status); log.error("batch query fail, status:" + status + ", response:" + responseMsg + ",serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("batch query http exception" + e.getMessage()); log.error("batch query http exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("batch query io exception" + e.getMessage()); log.error("batch query io exception, serverId=" + serverId + ",dataIds=" + dataIdStr + ",group=" + groupName, e); } finally { // ? post.releaseConnection(); } return response; }
From source file:com.taobao.diamond.sdkapi.impl.DiamondSDKManagerImpl.java
@Override public BatchContextResult<ConfigInfoEx> batchAddOrUpdate(String serverId, String groupName, Map<String, String> dataId2ContentMap) { // /* w w w. ja v a2 s .c o m*/ BatchContextResult<ConfigInfoEx> response = new BatchContextResult<ConfigInfoEx>(); // mapnull if (dataId2ContentMap == null) { log.error("dataId2ContentMap cannot be null, serverId=" + serverId + " ,group=" + groupName); response.setSuccess(false); response.setStatusMsg("dataId2ContentMap cannot be null"); return response; } // dataIdcontentmap StringBuilder allDataIdAndContentBuilder = new StringBuilder(); for (String dataId : dataId2ContentMap.keySet()) { String content = dataId2ContentMap.get(dataId); allDataIdAndContentBuilder.append(dataId + Constants.WORD_SEPARATOR + content) .append(Constants.LINE_SEPARATOR); } String allDataIdAndContent = allDataIdAndContentBuilder.toString(); // if (!login(serverId)) { response.setSuccess(false); response.setStatusMsg("login fail, serverId=" + serverId); return response; } // HTTP method PostMethod post = new PostMethod("/diamond-server/admin.do?method=batchAddOrUpdate"); // post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, require_timeout); try { // NameValuePair dataId_value = new NameValuePair("allDataIdAndContent", allDataIdAndContent); NameValuePair group_value = new NameValuePair("group", groupName); post.setRequestBody(new NameValuePair[] { dataId_value, group_value }); // http int status = client.executeMethod(post); response.setStatusCode(status); String responseMsg = post.getResponseBodyAsString(); response.setResponseMsg(responseMsg); if (status == HttpStatus.SC_OK) { String json = null; try { json = responseMsg; // json, BatchContextResult List<ConfigInfoEx> configInfoExList = new LinkedList<ConfigInfoEx>(); Object resultObj = JSONUtils.deserializeObject(json, new TypeReference<List<ConfigInfoEx>>() { }); if (!(resultObj instanceof List<?>)) { throw new RuntimeException("batch write deserialize type error, not list, json=" + json); } List<ConfigInfoEx> resultList = (List<ConfigInfoEx>) resultObj; for (ConfigInfoEx configInfoEx : resultList) { configInfoExList.add(configInfoEx); } response.getResult().addAll(configInfoExList); // , response.setStatusMsg("batch write success"); log.info("batch write success,serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName + ",json=" + json); } catch (Exception e) { response.setSuccess(false); response.setStatusMsg("batch write deserialize error"); log.error("batch write deserialize error, serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName + ",json=" + json, e); } } else if (status == HttpStatus.SC_REQUEST_TIMEOUT) { response.setSuccess(false); response.setStatusMsg("batch write timeout, socket timeout(ms):" + require_timeout); log.error("batch write timeout, socket timeout(ms):" + require_timeout + ", serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName); } else { response.setSuccess(false); response.setStatusMsg("batch write fail, status:" + status); log.error("batch write fail, status:" + status + ", response:" + responseMsg + ",serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName); } } catch (HttpException e) { response.setSuccess(false); response.setStatusMsg("batch write http exception" + e.getMessage()); log.error("batch write http exception, serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName, e); } catch (IOException e) { response.setSuccess(false); response.setStatusMsg("batch write io exception" + e.getMessage()); log.error("batch write io exception, serverId=" + serverId + ",allDataIdAndContent=" + allDataIdAndContent + ",group=" + groupName, e); } finally { // post.releaseConnection(); } return response; }