本文整理汇总了Java中org.snmp4j.util.ThreadPool类的典型用法代码示例。如果您正苦于以下问题:Java ThreadPool类的具体用法?Java ThreadPool怎么用?Java ThreadPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThreadPool类属于org.snmp4j.util包,在下文中一共展示了ThreadPool类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startUp
import org.snmp4j.util.ThreadPool; //导入依赖的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
import org.snmp4j.util.ThreadPool; //导入依赖的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
import org.snmp4j.util.ThreadPool; //导入依赖的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
示例4: MockSnmpAgent
import org.snmp4j.util.ThreadPool; //导入依赖的package包/类
public MockSnmpAgent(final File confFile, final URL moFile) {
super(BOOT_COUNT_FILE, confFile, new CommandProcessor(new OctetString(MPv3.createLocalEngineID(new OctetString("MOCKAGENT")))));
m_moLoader.set(new PropertiesBackedManagedObject());
m_moFile.set(moFile);
agent.setWorkerPool(ThreadPool.create("RequestPool", 4));
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:7,代码来源:MockSnmpAgent.java
示例5: SnmpmanAgent
import org.snmp4j.util.ThreadPool; //导入依赖的package包/类
/**
* Initializes a new instance of an SNMP agent.
*
* @param configuration the configuration for this agent
*/
public SnmpmanAgent(final AgentConfiguration configuration) {
super(SnmpmanAgent.getBootCounterFile(configuration), SnmpmanAgent.getConfigurationFile(configuration), new CommandProcessor(new OctetString(MPv3.createLocalEngineID())));
this.agent.setWorkerPool(ThreadPool.create("RequestPool", 3));
this.configuration = configuration;
}
开发者ID:1and1,项目名称:snmpman,代码行数:11,代码来源:SnmpmanAgent.java
示例6: MockSnmpAgent
import org.snmp4j.util.ThreadPool; //导入依赖的package包/类
public MockSnmpAgent(final File confFile, final Resource moFile) {
super(BOOT_COUNT_FILE, confFile, new CommandProcessor(new OctetString(MPv3.createLocalEngineID(new OctetString("MOCKAGENT")))));
m_moLoader = new PropertiesBackedManagedObject();
m_moFile = moFile;
agent.setWorkerPool(ThreadPool.create("RequestPool", 4));
}
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:7,代码来源:MockSnmpAgent.java
注:本文中的org.snmp4j.util.ThreadPool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论