写了一个subagent的测试类但是注册上后只能正常发通知,从master端的GET ,GETNEXT这类的操作完全感知不到不知道是为什么?
MYSUBAGENTX类
MYSUBAGENTX类
- package org.snmp4j.agent.agentx.subagent.test.me;
- import org.snmp4j.agent.agentx.subagent.AgentXSubagent;
- import org.snmp4j.smi.OID;
- import org.snmp4j.agent.agentx.AgentX;
- import org.snmp4j.smi.OctetString;
- import org.snmp4j.agent.agentx.AgentXMessageDispatcherImpl;
- import org.snmp4j.agent.agentx.AgentXMessageDispatcher;
- import org.snmp4j.agent.agentx.AgentXResponseEvent;
- import org.snmp4j.smi.Address;
- import org.snmp4j.smi.TcpAddress;
- import org.snmp4j.smi.VariableBinding;
- import org.snmp4j.agent.agentx.AgentXSession;
- import org.snmp4j.agent.DefaultMOServer;
- import org.snmp4j.agent.MOServer;
- import org.snmp4j.agent.DuplicateRegistrationException;
- import org.apache.log4j.BasicConfigurator;
- import org.snmp4j.log.LogFactory;
- import org.snmp4j.log.Log4jLogFactory;
- import org.snmp4j.agent.agentx.AgentXProtocol;
- import java.io.*;
- import org.snmp4j.transport.ConnectionOrientedTransportMapping;
- import org.snmp4j.transport.TransportStateListener;
- import org.snmp4j.transport.TransportStateEvent;
- import java.util.List;
- import org.snmp4j.log.LogAdapter;
- import org.snmp4j.mp.SnmpConstants;
- import org.snmp4j.util.ThreadPool;
- import org.snmp4j.agent.mo.snmp.SNMPv2MIB.SysUpTimeImpl;
- import org.snmp4j.smi.TimeTicks;
- // revised by muning
- import java.net.InetAddress;
- /**
- * @author huangxf
- */
- public class MySubagent implements Runnable, TransportStateListener {
- static {
- LogFactory.setLogFactory(new Log4jLogFactory());
- }
- private static final LogAdapter LOGGER = LogFactory
- .getLogger(MySubagent.class);
- public static final OID SUBAGENT_ID = new OID();
- private AgentXSubagent subagent;
- private AgentX agentX;
- private AgentXMessageDispatcher dispatcher;
- private Address masterAddress;
- private Address localAddress;
- private AgentXSession session;
- private int sessionID = 0;
- private MOServer server;
- private MyMib mymib;
- private SysUpTimeImpl sessionContextUpTime = new SysUpTimeImpl();
- public MySubagent(Address masterAddress, Address localAddress) {
- this.masterAddress = masterAddress;
- this.localAddress = localAddress;
- this.dispatcher = new AgentXMessageDispatcherImpl();
- this.agentX =