本文整理了Java中org.snmp4j.Snmp.cancel()
方法的一些代码示例,展示了Snmp.cancel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Snmp.cancel()
方法的具体详情如下:
包路径:org.snmp4j.Snmp
类名称:Snmp
方法名:cancel
暂无
代码示例来源:origin: org.apache.camel/camel-snmp
public void onResponse(ResponseEvent event) {
// Always cancel async request when response has been received
// otherwise a memory leak is created! Not canceling a request
// immediately can be useful when sending a request to a broadcast address.
((Snmp)event.getSource()).cancel(event.getRequest(), this);
// check for valid response
if (event.getRequest() == null || event.getResponse() == null) {
// ignore null requests/responses
LOG.debug("Received invalid SNMP event. Request: " + event.getRequest() + " / Response: " + event.getResponse());
return;
}
PDU pdu = event.getResponse();
processPDU(pdu);
}
代码示例来源:origin: org.apache.servicemix/servicemix-snmp
public void onResponse(ResponseEvent event) {
// Always cancel async request when response has been received
// otherwise a memory leak is created! Not canceling a request
// immediately can be useful when sending a request to a broadcast
// address.
((Snmp)event.getSource()).cancel(event.getRequest(), this);
// check for valid response
if (event.getRequest() == null || event.getResponse() == null) {
// ignore null requests/responses
logger.debug("Received invalid snmp event. Request: {} / Response: {}", event.getRequest(),
event.getResponse());
return;
}
// now prepare the message and send it
sendSnmpDataMessage(event.getRequest(), event.getResponse());
}
代码示例来源:origin: OpenNMS/opennms
@Override
public void onResponse(ResponseEvent responseEvent) {
// need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure
m_session.cancel(responseEvent.getRequest(), this);
// Check to see if we got an interrupted exception
if (responseEvent.getError() instanceof InterruptedException) {
LOG.debug("Interruption event. We have probably tried to close the session due to an error", responseEvent.getError());
// Check to see if the response is null, indicating a timeout
} else if (responseEvent.getResponse() == null) {
handleTimeout(getName()+": snmpTimeoutError for: " + getAddress());
// Check to see if we got any kind of error
} else if (responseEvent.getError() != null){
handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError());
// If we have a PDU in the response, process it
} else {
try {
processResponse(responseEvent.getResponse());
} catch (final SnmpException e) {
handleFatalError(e);
}
}
}
代码示例来源:origin: org.opennms.core.snmp/org.opennms.core.snmp.implementations.snmp4j
@Override
public void onResponse(ResponseEvent responseEvent) {
// need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure
m_session.cancel(responseEvent.getRequest(), this);
// Check to see if we got an interrupted exception
if (responseEvent.getError() instanceof InterruptedException) {
LOG.debug("Interruption event. We have probably tried to close the session due to an error", responseEvent.getError());
// Check to see if the response is null, indicating a timeout
} else if (responseEvent.getResponse() == null) {
handleTimeout(getName()+": snmpTimeoutError for: " + getAddress());
// Check to see if we got any kind of error
} else if (responseEvent.getError() != null){
handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError());
// If we have a PDU in the response, process it
} else {
try {
processResponse(responseEvent.getResponse());
} catch (final SnmpException e) {
handleFatalError(e);
}
}
}
代码示例来源:origin: org.opennms.lib.snmp/org.opennms.lib.snmp.snmp4j
public void onResponse(ResponseEvent responseEvent) {
// need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure
m_session.cancel(responseEvent.getRequest(), this);
// Check to see if we got an interrupted exception
if (responseEvent.getError() instanceof InterruptedException) {
if (log().isDebugEnabled()) {
log().debug("Interruption event. We have probably tried to close the session due to an error: " + responseEvent.getError(), responseEvent.getError());
}
// Check to see if the response is null, indicating a timeout
} else if (responseEvent.getResponse() == null) {
handleTimeout(getName()+": snmpTimeoutError for: " + getAddress());
// Check to see if we got any kind of error
} else if (responseEvent.getError() != null){
handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError());
// If we have a PDU in the response, process it
} else {
processResponse(responseEvent.getResponse());
}
}
内容来源于网络,如有侵权,请联系作者删除!