本文整理汇总了Java中org.snmp4j.event.ResponseListener类的典型用法代码示例。如果您正苦于以下问题:Java ResponseListener类的具体用法?Java ResponseListener怎么用?Java ResponseListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResponseListener类属于org.snmp4j.event包,在下文中一共展示了ResponseListener类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendGetPDU
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
/**
* Send PDU to H3C, then waiting response event will be caught by listener.
*
* @param snmp
* @param userTarget
* @param pdu
* @throws IOException
* @throws InterruptedException
*/
private void sendGetPDU(Snmp snmp, UserTarget userTarget, ScopedPDU pdu)
throws IOException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
ResponseListener listener = new ResponseListener() {
@Override
public void onResponse(ResponseEvent event) {
((Snmp) event.getSource()).cancel(event.getRequest(), this);
PDU response = event.getResponse();
PDU request = event.getRequest();
LOG.debug("[request]: {}", request);
if (response == null) {
LOG.error("[ERROR]: response is null");
} else if (response.getErrorStatus() != 0) {
LOG.error("[ERROR]: response status {}, Text: {}",
response.getErrorStatus(),
response.getErrorStatusText());
} else {
LOG.debug("Received response Success!");
for (int i = 0; i < response.size(); i++) {
VariableBinding vb = response.get(i);
LOG.info("{} = {}",
vb.getOid(),
vb.getVariable());
}
LOG.debug("SNMP Async GetList OID finished. ");
latch.countDown();
}
}
};
snmp.send(pdu, userTarget, null, listener);
LOG.debug("async send pdu wait for response...");
boolean wait = latch.await(3, TimeUnit.SECONDS);
LOG.debug("latch.await =:" + wait);
}
示例2: get
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void get(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
示例3: set
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void set(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
示例4: getNext
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void getNext(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
示例5: getBulk
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void getBulk(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
示例6: send
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void send(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException {
send(pdu, target, null, userHandle, listener);
}
示例7: cancel
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void cancel(PDU request, ResponseListener listener) {
delegate.cancel(request, listener);
}
示例8: get
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void get(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException {
pdu.setType(PDU.GET);
send(pdu, target, userHandle, listener);
}
示例9: set
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void set(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException {
pdu.setType(PDU.SET);
send(pdu, target, userHandle, listener);
}
示例10: getNext
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void getNext(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException {
pdu.setType(PDU.GETNEXT);
send(pdu, target, userHandle, listener);
}
示例11: getBulk
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void getBulk(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException {
pdu.setType(PDU.GETBULK);
send(pdu, target, userHandle, listener);
}
示例12: AsynchronousRequest
import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
AsynchronousRequest(PDU request, Target target,
TransportMapping<?> transportMapping, Object userHandle,
int retries, long timeout, ResponseListener listener) {
super(request, target, transportMapping, userHandle, retries, timeout);
this.listener = listener;
}