当前位置: 首页>>代码示例>>Java>>正文


Java ResponseListener类代码示例

本文整理汇总了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);
}
 
开发者ID:asdf2014,项目名称:yuzhouwan,代码行数:49,代码来源:SnmpH3C.java

示例2: get

import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void get(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:3,代码来源:Snmp4jSession.java

示例3: set

import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void set(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:3,代码来源:Snmp4jSession.java

示例4: getNext

import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void getNext(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:3,代码来源:Snmp4jSession.java

示例5: getBulk

import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
void getBulk(PDU pdu, Target target, Object userHandle,
ResponseListener listener) throws IOException;
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:3,代码来源:Snmp4jSession.java

示例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);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:6,代码来源:SessionWrapper.java

示例7: cancel

import org.snmp4j.event.ResponseListener; //导入依赖的package包/类
@Override
public void cancel(PDU request, ResponseListener listener) {
  delegate.cancel(request, listener);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:5,代码来源:SessionWrapper.java

示例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);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:7,代码来源:SessionWrapper.java

示例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);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:7,代码来源:SessionWrapper.java

示例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);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:7,代码来源:SessionWrapper.java

示例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);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:7,代码来源:SessionWrapper.java

示例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;
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:7,代码来源:SessionWrapper.java


注:本文中的org.snmp4j.event.ResponseListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。