Package org.snmp4j.agent.request

Examples of org.snmp4j.agent.request.SnmpRequest


    return requestPDU;
  }

  private void createRequestPDU() {
    AgentXPDU reqPDU = null;
    SnmpRequest request = (SnmpRequest)
        ((AgentXSetVB)vbs.get(0)).getReferenceSubRequest().getRequest();
    switch (request.getPhase()) {
      case Request.PHASE_INIT:
      case Request.PHASE_1PC:
      case Request.PHASE_2PC_PREPARE: {
        reqPDU =
            new AgentXTestSetPDU(request.getContext(), (VariableBinding[])
                                 vbs.toArray(new VariableBinding[vbs.size()]));
        break;
      }
      case Request.PHASE_2PC_COMMIT: {
        reqPDU = new AgentXCommitSetPDU();
        break;
      }
      case Request.PHASE_2PC_CLEANUP: {
        reqPDU = new AgentXCleanupSetPDU();
        break;
      }
      default: {
        reqPDU = new AgentXUndoSetPDU();
        break;
      }
    }
    reqPDU.setSessionID(session.getSessionID());
    reqPDU.setTransactionID(request.getTransactionID());
    this.requestPDU = reqPDU;
  }
View Full Code Here


  /**
   * Creates the AgentX request PDU from the search ranges.
   */
  private void createRequestPDU() {
    SnmpRequest request = (SnmpRequest)
        ((AgentXSearchRange) searchRanges.get(0))
        .getReferenceSubRequest().getRequest();
    PDU requestPDU = request.getInitiatingEvent().getPDU();
    switch (requestPDU.getType()) {
      case PDU.GETBULK: {
        short maxRep = getMaxRepetitions(request, requestPDU);
        agentXRequestPDU =
            new AgentXGetBulkPDU(request.getContext(),
                                 maxRep, nonRepeater,
                                 (MOScope[]) searchRanges.toArray(
                                     new MOScope[searchRanges.size()]));
        break;
      }
      case PDU.GET: {
        OID[] oids = new OID[searchRanges.size()];
        for (int i = 0; i < oids.length; i++) {
          AgentXSearchRange sr = (AgentXSearchRange) searchRanges.get(i);
          oids[i] = sr.getLowerBound();
        }
        agentXRequestPDU = new AgentXGetPDU(request.getContext(), oids);
        break;
      }
      case PDU.GETNEXT: {
        agentXRequestPDU =
            new AgentXGetNextPDU(request.getContext(),
                                 (MOScope[]) searchRanges.toArray(
                                     new MOScope[searchRanges.size()]));
        break;
      }
      default: {
View Full Code Here

  }

  public synchronized boolean add(VariableBinding vb,
                                  SnmpSubRequest subRequest,
                                  AgentXRegEntry entry) {
    SnmpRequest request = (SnmpRequest) subRequest.getRequest();
    AgentXPendingSet pending =
        (AgentXPendingSet) get(entry.getSession().getSessionID(),
                               request.getTransactionID());
    if (pending == null) {
      pending = new AgentXPendingSet(entry, subRequest.getSnmpRequest());
      insertIntoQueue(request.getTransactionID(), pending);
    }
    if (!pending.isPending()) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Variable binding " + vb +
                     " not addded because AgentX request " + pending +
View Full Code Here

    entry.addEntry(pending);
  }

  public synchronized boolean add(AgentXSearchRange searchRange,
                                  AgentXRegEntry entry, boolean repeater) {
    SnmpRequest request =
        (SnmpRequest) searchRange.getReferenceSubRequest().getRequest();
    AgentXPendingGet pending =
        (AgentXPendingGet) get(entry.getSession().getSessionID(),
                               request.getTransactionID());
    if (pending == null) {
      // optimize upper bound if server is set
      if ((servers != null) &&
          (request.getInitiatingEvent().getPDU().getType() == PDU.GETBULK)) {
        optimizeSearchRange(searchRange, entry);
      }
      pending = new AgentXPendingGet(entry, request, searchRange);
      insertIntoQueue(request.getTransactionID(), pending);
    }
    else if (pending.isPending()) {
      switch (request.getInitiatingEvent().getPDU().getType()) {
        case PDU.GETBULK: {
          for (Iterator it = pending.getSearchRanges().iterator(); it.hasNext();) {
            AgentXSearchRange psr = (AgentXSearchRange) it.next();
            if ((searchRange.getReferenceSubRequest().getIndex() -
                 psr.getReferenceSubRequest().getIndex()) %
                request.getRepeaterCount() == 0) {
              // this is a repetitions -> ignore it this time and send out
              // AgentX request
              if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Repetition not added because of pending AgentX"+
                             " processing of "+pending+" and repetition "+psr);
View Full Code Here

TOP

Related Classes of org.snmp4j.agent.request.SnmpRequest

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.