コード例 #1
0
  @Monitor(
      server = DSM_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/commonServices.properties",
      serviceUrlKeys = "dsmServiceUrl")
  private DetectResult monitorDSMServer() {
    DetectResult result = new DetectResult();

    TnContext tc =
        BackendServerMonitorUtil.newTnContextBy(BackendServerMonitorUtil.createUserProfile());

    ContextMgrService cms = new ContextMgrService();
    ContextMgrStatus myStatus = null;
    try {
      myStatus = cms.updateContext(tc);

      if (myStatus == null || myStatus.getStatusCode() != Error.NO_ERROR) {
        logger.warn("DSM SERVER can not work.");
        result.isSuccess = false;
        result.errCode = myStatus.getStatusCode();
        result.msg = "Can not get response from DSM SERVER.";
      } else {
        result.isSuccess = true;
      }
    } catch (Exception e) {
      logger.fatal("Can not get response from DSM SERVER.", e);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when updateContext in DSM SERVER"
              + " \n Exception msg->"
              + ExceptionUtil.collectExceptionMsg(e);
    }

    return result;
  }
コード例 #2
0
  @Monitor(server = ACE_SERVER, parserClass = ServiceUrlParserFactory.CLASS_ACE)
  private DetectResult monitorAceServer() {
    DetectResult result = new DetectResult();

    try {
      GeoCodingProxy proxy = GeoCodingProxy.getInstance(BackendServerMonitorUtil.createTnContext());

      GeoCodeResponse geoCodeResponse = proxy.geoCode(BackendServerMonitorUtil.createAddress());
      if (geoCodeResponse != null && geoCodeResponse.getStatus().isSuccessful()) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.errCode = geoCodeResponse != null ? geoCodeResponse.getStatus().getStatusCode() : -1;
        result.msg = "Can not get response from ACE SERVER";
      }
    } catch (Exception e) {
      logger.warn("Throttling Exception occurs", e);
      result.isSuccess = false;
      result.msg = "Exception occurs->" + ExceptionUtil.collectExceptionMsg(e);
    }

    return result;
  }