コード例 #1
0
  /** Calls the user implementation of the <CODE>SnmpInformHandler</CODE> interface. */
  private void handleInternalError(String msg) {

    setRequestStatus(stInternalError);
    if (reason == null) reason = msg;

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
      SNMP_ADAPTOR_LOGGER.logp(
          Level.FINEST,
          SnmpInformRequest.class.getName(),
          "handleInternalError",
          "Snmp error/index = "
              + snmpErrorToString(errorStatus)
              + "/"
              + errorIndex
              + ". Invoking internal error user defined callback...\n"
              + getVarBindList());
    }

    deleteRequest();
    notifyClient();

    requestPdu = null;
    responsePdu = null;
    internalVarBind = null;

    try {
      if (callback != null) callback.processSnmpInternalError(this, reason);
    } catch (Exception e) { // catch any exception a user might not handle.
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "handleInternalError",
            "Exception generated by user callback",
            e);
      }
    } catch (OutOfMemoryError ome) {
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "handleInternalError",
            "OutOfMemory Error generated by user callback",
            ome);
      }
      Thread.currentThread().yield();
    }
  }
コード例 #2
0
  /** Calls the user implementation of the <CODE>SnmpInformHandler</CODE> interface. */
  private void handleSuccess() {

    setRequestStatus(stResultsAvailable);

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
      SNMP_ADAPTOR_LOGGER.logp(
          Level.FINER,
          SnmpInformRequest.class.getName(),
          "handleSuccess",
          "Invoking user defined callback...");
    }

    deleteRequest(); // delete only non-poll request.
    notifyClient();

    requestPdu = null;
    // responsePdu = null;
    internalVarBind = null;

    try { // catch all user exception which may happen in callback.
      if (callback != null)
        callback.processSnmpPollData(this, errorStatus, errorIndex, getVarBindList());
    } catch (Exception e) {
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "handleSuccess",
            "Exception generated by user callback",
            e);
      }
    } catch (OutOfMemoryError ome) {
      if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(
            Level.FINEST,
            SnmpInformRequest.class.getName(),
            "handleSuccess",
            "OutOfMemory Error generated by user callback",
            ome);
      }
      Thread.currentThread().yield();
    }
    return;
  }
コード例 #3
0
 /** Cancels the active inform request and removes itself from the polling list. */
 public final void cancelRequest() {
   errorStatus = snmpReqAborted;
   stopRequest();
   deleteRequest();
   notifyClient();
 }