Package models.data

Examples of models.data.NodeReqResponse


    // data.
    try {

      for (String fqdn : nodeGroupSourceMetadata.getNodeList()) {

        NodeReqResponse nodeReqResponse = new NodeReqResponse();
        nodeReqResponse.setDefaultReqestContent(requestContent);
        AgentDataProviderHelper.updateAgentDataForNode(ngdm, fqdn,
            nodeReqResponse, agentCommandType);
      }

      boolean copyRequestContentOnly = true;
View Full Code Here


      } else {
        // deep copy
        NodeData nodeDataInProgressClone = new NodeData(
            nodeDataInProgress);

        NodeReqResponse nrr = nodeDataInProgressClone.getDataMap().get(
            agentCommandType);
        // replace with the new data
        if (nodeDataMapValid != null && fqdn != null && nrr != null) {

          // check if the valid has nodeData too?
          if (nodeDataMapValid.containsKey(fqdn)) {
            NodeData nodeDataValid = nodeDataMapValid.get(fqdn);

            if (!copyRequestContentOnly) {

              // this will replace the nodeDataValid
              nodeDataValid.getDataMap().put(agentCommandType,
                  nrr);

              // only copy the request content.
            } else {
              // check if valid nodeData have this
              // agentCommandType in dataMap?

              if (nodeDataValid.getDataMap().containsKey(
                  agentCommandType)) {
                // just copy the requestParameters
                nodeDataValid.getDataMap()
                    .get(agentCommandType)
                    .getRequestParameters().clear();
                nodeDataValid.getDataMap()
                    .get(agentCommandType)
                    .getRequestParameters();

                for (Entry<String, String> entryLocal : nrr
                    .getRequestParameters().entrySet()) {

                  // replacement from inProgress Clone to
                  // valid
                  nodeDataValid
View Full Code Here

        // bad entry; skip
        models.utils.LogUtils.printLogError("NodeData is NULL!! in filterUnsafeRequest");
        continue;
      }

      NodeReqResponse nrr = nd.getDataMap().get(agentCommandType);
      if (nrr == null) {
        models.utils.LogUtils.printLogError("nrr is NULL!! in filterUnsafeRequest");
        continue;
      }
      // now get the content.
      Map<String, String> map = nrr.getRequestParameters();
      if (map == null) {
         models.utils.LogUtils.printLogError
             ("nrr.getRequestParameters is NULL!! in filterUnsafeRequest");
        continue;
      }
View Full Code Here

          .get(nodeGroupType);
      if (ngdm != null) {
        NodeData nodeData = ngdm.getNodeDataMapValid().get(fqdn);

        if (nodeData != null) {
          NodeReqResponse nrr = nodeData.getDataMap().get(
              agentCommandType);
          ResponseContent responseContent = new ResponseContent(gap);
          nrr.setResponseContent(responseContent);

        } else {
           models.utils.LogUtils.printLogError
               ("ERROR nodeData is null in updateResponseFromAgentGenericResponse");
        }
View Full Code Here

            .getNodeDataMapValid().containsKey(fqdn)) {
          continue;
        }

        // Hahh.. catch NPE !!
        NodeReqResponse nrrSource = adp.allAgentData
            .get(nodeGroupTypeSource).getNodeDataMapValid()
            .get(fqdn).getDataMap().get(agentCommandType);
        // deep copy
        NodeReqResponse nrrNew = new NodeReqResponse(nrrSource);

        // TODO: not tested target must already have NodeData
       
        if(! adp.allAgentData.get(nodeGroupTypeTarget).getNodeDataMapValid()
            .containsKey(fqdn)){
           NodeData nd = new NodeData(fqdn);
           adp.allAgentData.get(nodeGroupTypeTarget).getNodeDataMapValid()
            .put(fqdn, nd);
        }
       
        adp.allAgentData.get(nodeGroupTypeTarget).getNodeDataMapValid()
        .get(fqdn).getDataMap().put(agentCommandType, nrrNew);
       
       
       
        // now copy the inProgress;
       

        // Hahh.. catch NPE !!
        NodeReqResponse nrrSourceInProgress = adp.allAgentData
            .get(nodeGroupTypeSource).getNodeDataMapInProgress()
            .get(fqdn).getDataMap().get(agentCommandType);
        // deep copy
        NodeReqResponse nrrNewInProgress = new NodeReqResponse(nrrSourceInProgress);
        // TODO: not tested target must already have NodeData
       
        if(! adp.allAgentData.get(nodeGroupTypeTarget).getNodeDataMapInProgress()
            .containsKey(fqdn)){
           NodeData nd = new NodeData(fqdn);
View Full Code Here

        .entrySet()) {

      NodeData nodeData = entry.getValue();
      if (nodeData.getDataMap().containsKey(agentCommand)) {

        NodeReqResponse nodeReqResponse = nodeData.getDataMap().get(
            agentCommand);

        if (nodeReqResponse == null) {
          nodeReqResponse = new NodeReqResponse();
          nodeReqResponse.setDefaultEmptyReqestContent();

          nodeData.getDataMap().put(agentCommand, nodeReqResponse);
        }

        // Safeguard!! When the wisbVarValue is "NA" (e.g. fail to get
        // the wisb) should alert that
        // Safeguard: if NA, then dont run it!
        if (replaceVarKey.equalsIgnoreCase(VarUtils.NA)) {

          if (varReplacementType == VarUtils.VAR_REPLACEMENT_TYPE.ADHOC_FROM_API) {
            models.utils.LogUtils
                .printLogNormal("Get an invalid var value as NA."
                    + DateUtils.getNowDateTimeStrSdsm());

            // 20130731: add error msg
            nodeReqResponse
                .getRequestParameters()
                .put(VarUtils.NODE_REQUEST_EXECUTE_MSG,
                    VarUtils.NODE_REQUEST_EXECUTE_MSG_DETAIL_REPLACEMENT_VAR_VALUE_NA);

          }

          nodeReqResponse.getRequestParameters().put(
              VarUtils.NODE_REQUEST_WILL_EXECUTE,
              new Boolean(false).toString());

          /**
           * 20130828: make it generic to check NULL KEY/VALUE
           */
        } else if (replaceVarKey == null || replaceVarValue == null) {
          models.utils.LogUtils
              .printLogNormal("Get NULL repalceVarKey or value.."
                  + DateUtils.getNowDateTimeStrSdsm());

          // 20130731: add error msg
          nodeReqResponse
              .getRequestParameters()
              .put(VarUtils.NODE_REQUEST_EXECUTE_MSG,
                  VarUtils.NODE_REQUEST_EXECUTE_MSG_DETAIL_REPLACEMENT_VAR_KEY_OR_VALUE_NULL);

          nodeReqResponse.getRequestParameters().put(
              VarUtils.NODE_REQUEST_WILL_EXECUTE,
              new Boolean(false).toString());

        } else {
          nodeReqResponse.getRequestParameters().put(
              VarUtils.NODE_REQUEST_PREFIX_REPLACE_VAR
                  + replaceVarKey, replaceVarValue);

          // CAREFUL! This is added to prevent a last time run
          // "NOT EXECUTE" to continue to be effective this time.
          // Since the whole nodeReqResponse will not replaced
          // everytime
          nodeReqResponse.getRequestParameters().put(
              VarUtils.NODE_REQUEST_WILL_EXECUTE,
              new Boolean(true).toString());

        }

View Full Code Here

        String replaceVarValue = entryReplaceMap.getValue();

        NodeData nodeData = entry.getValue();
        if (nodeData.getDataMap().containsKey(agentCommand)) {

          NodeReqResponse nodeReqResponse = nodeData.getDataMap()
              .get(agentCommand);

          if (nodeReqResponse == null) {
            nodeReqResponse = new NodeReqResponse();
            nodeReqResponse.setDefaultEmptyReqestContent();

            nodeData.getDataMap()
                .put(agentCommand, nodeReqResponse);
          }

          // Safeguard!! When the wisbVarValue is "NA" (e.g. fail to
          // get
          // the wisb) should alert that
          // Safeguard: if NA, then dont run it!
          if (replaceVarKey.equalsIgnoreCase(VarUtils.NA)) {

            if (varReplacementType == VarUtils.VAR_REPLACEMENT_TYPE.WISB_SREPO) {
              models.utils.LogUtils
                  .printLogNormal("Wisb fail to get wisbVarValue"
                      + DateUtils.getNowDateTimeStrSdsm());
              // 20130731: add error msg
              nodeReqResponse
                  .getRequestParameters()
                  .put(VarUtils.NODE_REQUEST_EXECUTE_MSG,
                      VarUtils.NODE_REQUEST_EXECUTE_MSG_DETAIL_TYPE_WISB_NOT_EXIST);
            } else if (varReplacementType == VarUtils.VAR_REPLACEMENT_TYPE.ADHOC_FROM_API) {
              models.utils.LogUtils
                  .printLogNormal("Get an invalid var value as NA."
                      + DateUtils.getNowDateTimeStrSdsm());

              // 20130731: add error msg
              nodeReqResponse
                  .getRequestParameters()
                  .put(VarUtils.NODE_REQUEST_EXECUTE_MSG,
                      VarUtils.NODE_REQUEST_EXECUTE_MSG_DETAIL_REPLACEMENT_VAR_VALUE_NA);

            }

            nodeReqResponse.getRequestParameters().put(
                VarUtils.NODE_REQUEST_WILL_EXECUTE,
                new Boolean(false).toString());

            /**
             * 20130828: make it generic to check NULL KEY/VALUE
             */
          } else if (replaceVarKey == null || replaceVarValue == null) {
            models.utils.LogUtils
                .printLogNormal("Get NULL repalceVarKey or value.."
                    + DateUtils.getNowDateTimeStrSdsm());

            // 20130731: add error msg
            nodeReqResponse
                .getRequestParameters()
                .put(VarUtils.NODE_REQUEST_EXECUTE_MSG,
                    VarUtils.NODE_REQUEST_EXECUTE_MSG_DETAIL_REPLACEMENT_VAR_KEY_OR_VALUE_NULL);

            nodeReqResponse.getRequestParameters().put(
                VarUtils.NODE_REQUEST_WILL_EXECUTE,
                new Boolean(false).toString());

          } else {
            nodeReqResponse.getRequestParameters().put(
                VarUtils.NODE_REQUEST_PREFIX_REPLACE_VAR
                    + replaceVarKey, replaceVarValue);

            // CAREFUL! This is added to prevent a last time run
            // "NOT EXECUTE" to continue to be effective this time.
            // Since the whole nodeReqResponse will not replaced
            // everytime

            /*
             * 20131205: to prevent this overwrite when there is a
             * NA field passed in. This will check
             */
            if (replacementVarMapForThisNode.getMap().keySet()
                .contains(VarUtils.NA)) {
              nodeReqResponse.getRequestParameters().put(
                  VarUtils.NODE_REQUEST_WILL_EXECUTE,
                  new Boolean(false).toString());
            } else {
              nodeReqResponse.getRequestParameters().put(
                  VarUtils.NODE_REQUEST_WILL_EXECUTE,
                  new Boolean(true).toString());
            }

          }
View Full Code Here

        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;
 
View Full Code Here

TOP

Related Classes of models.data.NodeReqResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.