• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MultiThreadedMessageDispatcher类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.snmp4j.util.MultiThreadedMessageDispatcher的典型用法代码示例。如果您正苦于以下问题:Java MultiThreadedMessageDispatcher类的具体用法?Java MultiThreadedMessageDispatcher怎么用?Java MultiThreadedMessageDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MultiThreadedMessageDispatcher类属于org.snmp4j.util包,在下文中一共展示了MultiThreadedMessageDispatcher类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startUp

点赞 3

import org.snmp4j.util.MultiThreadedMessageDispatcher; //导入依赖的package包/类
@Override
public void startUp() throws IOException {
	log.info("Snmp Trap Receiver Start");
	log.info("listened on " + Configure.getInstance().getUdpTrapIpPort());
	ThreadPool pool = ThreadPool.create(Const.THREAD_POOL_NAME, Const.AGENT_THREAD_NUM);
	MultiThreadedMessageDispatcher dispatcher = new MultiThreadedMessageDispatcher(pool, new MessageDispatcherImpl());
	Address listenAddress = GenericAddress.parse(Configure.getInstance().getUdpTrapIpPort());
	TransportMapping transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
	// ����SNMP������ʹ�俪ʼ����
	Snmp snmp = new Snmp(dispatcher, transport);
       snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
       snmp.listen();
       snmp.addCommandResponder(new CommandResponderImpl());
}
 

开发者ID:wangzijian777,
项目名称:snmpTool,
代码行数:15,
代码来源:SnmpReceiver.java

示例2: init

点赞 3

import org.snmp4j.util.MultiThreadedMessageDispatcher; //导入依赖的package包/类
private void init() throws UnknownHostException, IOException {
	threadPool = ThreadPool.create("Trap", 4);
	dispatcher = new MultiThreadedMessageDispatcher(threadPool,
			new MessageDispatcherImpl());

	listenAddress = GenericAddress.parse("udp:0.0.0.0/"
			+ SnmpPref.getTrapsPort());
	DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(
			(UdpAddress) listenAddress);
	snmp = new Snmp(dispatcher, transport);
	snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
	snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
	snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3());
	USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(
			MPv3.createLocalEngineID()), 0);
	SecurityModels.getInstance().addSecurityModel(usm);
	snmp.listen();
	logger.debug("Listening for traps on "
			+ transport.getListenAddress().toString());
}
 

开发者ID:ccascone,
项目名称:JNetMan,
代码行数:21,
代码来源:SnmpTrapReceiver.java

示例3: initReceiver

点赞 2

import org.snmp4j.util.MultiThreadedMessageDispatcher; //导入依赖的package包/类
public void initReceiver(String host) {
    Address address = new UdpAddress(host + "/" + _port);
    try {
        _transport = new DefaultUdpTransportMapping((UdpAddress) address);
    } catch (IOException e) {
        System.out.println("Unable to bind to local IP and port: " + e);
        System.exit(-1);
    }

    _threadPool = ThreadPool.create(this.getClass().getName(), _numThreads);

    MessageDispatcher mtDispatcher =
            new MultiThreadedMessageDispatcher(_threadPool, new MessageDispatcherImpl());

    // add message processing models
    mtDispatcher.addMessageProcessingModel(new MPv1());
    mtDispatcher.addMessageProcessingModel(new MPv2c());

    // add all security protocols
    SecurityProtocols.getInstance().addDefaultProtocols();

    snmp = new Snmp(mtDispatcher, _transport);
    if (snmp != null) {
        snmp.addCommandResponder(this);
    } else {
        System.out.println("Unable to create Target object");
        System.exit(-1);
    }

    if (version == SnmpConstants.version3) {
        mtDispatcher.addMessageProcessingModel(new MPv3());
        MPv3 mpv3 = (MPv3) snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);

        USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(mpv3.createLocalEngineID()), 0);

        SecurityModels.getInstance().addSecurityModel(usm);
        if (_authoritativeEngineID != null) {
            snmp.setLocalEngine(_authoritativeEngineID.getValue(), 0, 0);
        }
        this.addUsmUser(snmp);
    }
}
 

开发者ID:asdf2014,
项目名称:yuzhouwan,
代码行数:43,
代码来源:SnmpUtil.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)