Ejemplo n.º 1
0
  /** Calls the user implementation of the <CODE>SnmpInformHandler</CODE> interface. */
  private void handleError(String msg) {

    setRequestStatus(stResultsAvailable);

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

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

    try {
      if (callback != null)
        callback.processSnmpPollData(this, getErrorStatus(), getErrorIndex(), getVarBindList());
    } 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(),
            "handleError",
            "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(),
            "handleError",
            "OutOfMemory Error generated by user callback",
            ome);
      }
      Thread.currentThread().yield();
    }
  }
Ejemplo n.º 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;
  }