return new ChildTrackerResponseProcessor(parentBuilder, builders, nonRepeaters, repeaters);
private ChildTrackerPduBuilder getChildBuilder(int zeroBasedIndex) { int canonicalIndex = getCanonicalIndex(zeroBasedIndex); for (ChildTrackerPduBuilder childBuilder : m_childPduBuilders) { if (childBuilder.isNonRepeater(canonicalIndex) || childBuilder.isRepeater(canonicalIndex)) { return childBuilder; } } throw new IllegalStateException("Unable to find childBuilder for index "+zeroBasedIndex); }
public boolean processErrors(int errorStatus, int errorIndex) { if (errorStatus == TOO_BIG_ERR) { int maxVarsPerPdu = m_pduBuilder.getMaxVarsPerPdu(); if (maxVarsPerPdu <= 1) { throw new IllegalArgumentException("Unable to handle tooBigError when maxVarsPerPdu = "+maxVarsPerPdu); } m_pduBuilder.setMaxVarsPerPdu(maxVarsPerPdu/2); reportTooBigErr("Reducing maxVarsPerPdu for this request to "+m_pduBuilder.getMaxVarsPerPdu()); return true; } else if (errorStatus == GEN_ERR) { return processChildError(errorStatus, errorIndex); } else if (errorStatus == NO_SUCH_NAME_ERR) { return processChildError(errorStatus, errorIndex); } else if (errorStatus != NO_ERR){ throw new IllegalArgumentException("Unrecognized errorStatus "+errorStatus); } else { // Continue on.. no need to retry return false; } } }
return new ChildTrackerResponseProcessor(this, parentBuilder, builders, nonRepeaters, repeaters);
@Override public boolean processErrors(int errorStatus, int errorIndex) throws SnmpException { //LOG.trace("processErrors: errorStatus={}, errorIndex={}", errorStatus, errorIndex); final ErrorStatus status = ErrorStatus.fromStatus(errorStatus); // handle special cases first if (status == ErrorStatus.TOO_BIG) { int maxVarsPerPdu = m_pduBuilder.getMaxVarsPerPdu(); if (maxVarsPerPdu <= 1) { throw new SnmpException("Unable to handle tooBigError when maxVarsPerPdu = "+maxVarsPerPdu); } m_pduBuilder.setMaxVarsPerPdu(maxVarsPerPdu/2); m_tracker.reportTooBigErr("Reducing maxVarsPerPDU for this request."); return true; } else if (status.isFatal()) { final ErrorStatusException ex = new ErrorStatusException(status); m_tracker.reportFatalErr(ex); throw ex; } else { return processChildError(errorStatus, errorIndex); } } }
public void processResponse(SnmpObjId snmpObjId, SnmpValue val) { ChildTrackerPduBuilder childBuilder = getChildBuilder(m_currResponseIndex++); childBuilder.getResponseProcessor().processResponse(snmpObjId, val); }
public boolean processChildError(int errorStatus, int errorIndex) { int canonicalIndex = getCanonicalIndex(errorIndex-1); ChildTrackerPduBuilder childBuilder = getChildBuilder(canonicalIndex); int childIndex = childBuilder.getChildIndex(canonicalIndex); return childBuilder.getResponseProcessor().processErrors(errorStatus, childIndex+1); }
private ChildTrackerPduBuilder getChildBuilder(int zeroBasedIndex) throws SnmpException { int canonicalIndex = getCanonicalIndex(zeroBasedIndex); for (ChildTrackerPduBuilder childBuilder : m_childPduBuilders) { if (childBuilder.isNonRepeater(canonicalIndex) || childBuilder.isRepeater(canonicalIndex)) { return childBuilder; } } throw new SnmpException("Unable to find childBuilder for index "+zeroBasedIndex); }
public boolean processChildError(int errorStatus, int errorIndex) throws SnmpException { int canonicalIndex = getCanonicalIndex(errorIndex-1); ChildTrackerPduBuilder childBuilder = getChildBuilder(canonicalIndex); int childIndex = childBuilder.getChildIndex(canonicalIndex); return childBuilder.getResponseProcessor().processErrors(errorStatus, childIndex+1); }
@Override public void processResponse(SnmpObjId snmpObjId, SnmpValue val) throws SnmpException { ChildTrackerPduBuilder childBuilder = getChildBuilder(m_currResponseIndex++); childBuilder.getResponseProcessor().processResponse(snmpObjId, val); }