Esempio n. 1
0
  public void beforeExecute(JoinPoint thisJoinPoint) {

    String serviceNM =
        AuditInfoCollector.getClassNm(thisJoinPoint.getTarget(), HOPCONS.PKG_PREFIX)
            + "."
            + thisJoinPoint.getSignature().getName();
    LOGGER.debug("Spring AOP ..... Touching " + HOPCONS.QUEUE_LOGGER_SEG + serviceNM);

    ReqNotes.setStatus(ReqNotes.STATUS_KEY.IS_AUDITED, ReqNotes.H_YES);

    if (isExcludedService(serviceNM)) {
      ReqNotes.setStatus(ReqNotes.STATUS_KEY.IS_EXCLUDED, ReqNotes.H_YES);
      return;
    } else {
      ReqNotes.setStatus(ReqNotes.STATUS_KEY.IS_EXCLUDED, ReqNotes.H_NO);
    }

    // Only record first including service into thread local
    if (ReqNotes.isInvokeEmpty()) {
      ReqNotes.ERRNotes.resetNotes();
      ReqNotes.SQLNotes.resetNotes();
      ReqNotes.setInvokeNotes(serviceNM, thisJoinPoint.hashCode(), System.currentTimeMillis());
      ReqNotes.setStatus(ReqNotes.STATUS_KEY.IS_INCLUDE_AUDITED, ReqNotes.H_YES);
      LOGGER.debug("Spring AOP  ..... Recording " + HOPCONS.QUEUE_LOGGER_SEG + serviceNM);
    }
  }
Esempio n. 2
0
  public void afterExecute(JoinPoint thisJoinPoint) {

    if (!ReqNotes.isInvokeEmpty()) {
      String sNM =
          AuditInfoCollector.getClassNm(thisJoinPoint.getTarget(), HOPCONS.PKG_PREFIX)
              + "."
              + thisJoinPoint.getSignature().getName();
      long bf = ReqNotes.getInvokeNotes().getStartTime();
      long af = System.currentTimeMillis();
      // To avoid any children service call statistics

      if (isExcludedService(sNM)) {
        if (!ReqNotes.getStatus(ReqNotes.STATUS_KEY.IS_INCLUDE_AUDITED)) {
          ReqNotes.resetEXNotes();
        }
        return;
      }

      if (!sNM.equals(ReqNotes.getInvokeNotes().getApiNM())) {
        return;
      } else {
        if (thisJoinPoint.hashCode() != ReqNotes.getJointHashCode()) {
          return;
        }
        try {
          InvokeSum.add(ReqNotes.getInvokeNotes().getApiNM(), af - bf);
        } catch (Exception e) {
          LOGGER.error("Can not set value into memory summary queue", e);
        } finally {
          ReqNotes.clearInvokeNotes();
          ReqNotes.resetEXNotes();
        }
      }
    }
  }
Esempio n. 3
0
  public void afterThrowing(JoinPoint thisJoinPoint, Exception ex) throws Exception {

    String sNM =
        AuditInfoCollector.getClassNm(thisJoinPoint.getTarget(), HOPCONS.PKG_PREFIX)
            + "."
            + thisJoinPoint.getSignature().getName();

    if (isExcludedService(sNM)) {
      return;
    }

    if (!sNM.equals(ReqNotes.getInvokeNotes().getApiNM())) {
      return;
    }

    if (thisJoinPoint.hashCode() != ReqNotes.getJointHashCode()) {
      return;
    }

    boolean isVIP = isVIP(sNM);
    boolean isTmpVIP = isTmpVIP(sNM);

    if (ex instanceof HOPException) {
      if (!isVIP && !isTmpVIP) {
        return;
      }
    }

    long bf = ReqNotes.getInvokeNotes().getStartTime();
    long af = System.currentTimeMillis();
    ExCaptureBean ecb = new ExCaptureBean();
    ecb.setServiceAPIName(sNM);
    ecb.setAppName(AuditInfoCollector.getAppNM());
    ecb.setActionName(ReqNotes.getReqInfo(REQ_KEY.HOP_ACTION));
    ecb.setNodeName(AuditInfoCollector.getServernm());
    ecb.setNodeIP(AuditInfoCollector.getServerip());
    ecb.setInputValue(ReqNotes.getReqInfo(REQ_KEY.HOP_BEAN));
    ecb.setInsight(ReqNotes.getInsight());
    SimpleDateFormat threadSafeDateFormat = (SimpleDateFormat) HOPCONS.SIMPLE_DATE_FORMAT.clone();
    ecb.setGmtCreate(threadSafeDateFormat.format(new Date(System.currentTimeMillis())));
    ecb.setExcuteTime(String.valueOf(af - bf));

    handleException(ex, ecb, isTmpVIP);
    excaptureSender.sendMsg(ecb);
  }