if (!nodeData.getDataMap().containsKey(
agentCommandMetadata.getAgentCommandType())) {
models.utils.LogUtils
.printLogError("HAS NOT GENERATED AGENT COMMAND before sending Command!");
NodeReqResponse nodeReqResponse = new NodeReqResponse();
nodeReqResponse.setDefaultEmptyReqestContent();
nodeData.getDataMap().put(
agentCommandMetadata.getAgentCommandType(),
nodeReqResponse);
}
NodeReqResponse nodeReqResponse = nodeData.getDataMap()
.get(agentCommandMetadata.getAgentCommandType());
// BECAREFUL NPE
final String requestContentOrig = (nodeReqResponse == null || nodeReqResponse
.getRequestParameters() == null) ? ""
: nodeReqResponse.getRequestParameters().get(
VarUtils.NODE_REQUEST_FULL_CONTENT_TYPE);
final String requestContent = NodeReqResponse
.replaceStrByMap(
nodeReqResponse.getRequestParameters(),
requestContentOrig);
String resourcePathBeforeEncoding = NodeReqResponse
.replaceStrByMap(
nodeReqResponse.getRequestParameters(),
resourcePathOrig);
final String resourcePath = URLEncoder.encode(
resourcePathBeforeEncoding, "UTF-8");
// 1st. add the static template part
final Map<String, String> httpHeaderMapLocal = MyHttpUtils
.getHttpHeaderMapCopyFromHeaderMetadataMapStatic(
httpHeaderType, requestProtocol);
// 2nd, add the dynamic part (hard coded) from this logic;
// based
// on different httpHeaderType
/*MyHttpUtils.addDynamicHeadersIntoHttpHeaderMap(
httpHeaderMapLocal, httpHeaderType);*/
// 3rd, add the dynamic part ; generic var based
// replacement.
// 20140310
/*MyHttpUtils.replaceHttpHeaderMapNodeSpecific(
httpHeaderMapLocal, httpHeaderType,
nodeReqResponse.getRequestParameters());*/
if (VarUtils.PRINT_HTTP_TRUE_HEADER_MAP) {
for (Entry<String, String> headerEntry : httpHeaderMapLocal
.entrySet()) {
String headerKey = headerEntry.getKey();
String headerValue = headerEntry.getValue();
nodeReqResponse
.getRequestParameters()
.put(VarUtils.REQUEST_PARAMETER_HTTP_HEADER_PREFIX
+ headerKey, headerValue);
}
}
String target_node_new_replacing_old = nodeReqResponse
.getRequestParameters()
.get(VarUtils.VAR_NAME_APIVARREPLACE_SUPERMANSPECIAL_TARGET_NODE_VAR_WHEN_CHECK);
if (target_node_new_replacing_old != null) {
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_TRUE_TARGET_NODE1,
target_node_new_replacing_old);
}
/**
* Some hard coded logic for LBMS/UDNS use slow client. TODO
*/
final String hostUniform = (target_node_new_replacing_old == null) ? null
: target_node_new_replacing_old;
// 20130511 replacement:
nodeReqResponse.getRequestParameters()
.put(VarUtils.NODE_REQUEST_TRUE_CONTENT1,
requestContent);
// put the one before encoding
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_TRUE_URL1, resourcePathBeforeEncoding);
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_TRUE_PORT1,
Integer.toString(requestPort));
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_HTTP_METHOD1, httpMethod);
if (requestProtocol.equalsIgnoreCase(RequestProtocol.SSH
.toString())) {
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_HTTP_HEADER_TYPE,
VarUtils.STR_SSH_PASSWORD_MASKED);
} else {
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_HTTP_HEADER_TYPE,
httpHeaderType);
}
long prepareRequestTime = System.currentTimeMillis();
String prepareRequestTimeStr = DateUtils
.getDateTimeStr(new Date(prepareRequestTime));
nodeReqResponse.getRequestParameters().put(
VarUtils.NODE_REQUEST_PREPARE_TIME1,
prepareRequestTimeStr);
final long shouldPauseTimeForThisNodeMillis = (long) sentRequestCounter
* pauseIntervalWorkerMillis;