/** * Builds target resource. * @param context Process context */ private void buildTargetResource(ProcessContext context) { if((this.transportMapping == null) || !this.transportMapping.isListening() || (this.snmp == null)) { try { this.transportMapping = new DefaultUdpTransportMapping(); this.snmp = new Snmp(this.transportMapping); if("SNMPv3".equals(context.getProperty(SNMP_VERSION).getValue())) { USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); } this.transportMapping.listen(); } catch (Exception e) { throw new IllegalStateException("Failed to initialize UDP transport mapping", e); } } if (this.snmpTarget == null) { this.snmpTarget = this.createSnmpTarget(context); } if (this.targetResource == null) { this.targetResource = this.finishBuildingTargetResource(context); } }
private static void checkListening4ConfirmedPDU(PDU pdu, Address target, TransportMapping transport) { if ((transport != null) && (!transport.isListening())) { logger.warn("Sending confirmed PDU "+pdu+" to target "+target+ " although transport mapping "+transport+ " is not listening for a response"); } }
private static void checkListening4ConfirmedPDU(PDU pdu, Address target, TransportMapping<?> transport) { if ((transport != null) && (!transport.isListening())) { logger.warn("Sending confirmed PDU " + pdu + " to target " + target + " although transport mapping " + transport + " is not listening for a response"); } }
private static void checkListening4ConfirmedPDU(PDU pdu, Address target, TransportMapping transport) { if ((transport != null) && (!transport.isListening())) { logger.warn("Sending confirmed PDU "+pdu+" to target "+target+ " although transport mapping "+transport+ " is not listening for a response"); } }
/** * Closes a list of transport mappings. * @param transportMappings * a list of {@link TransportMapping} instances. * @throws IOException * if a transport cannot be closed. */ protected static void stopTransportMappings(Collection transportMappings) throws IOException { ArrayList l = new ArrayList(transportMappings); for (Iterator it = l.iterator(); it.hasNext();) { TransportMapping tm = (TransportMapping) it.next(); if (tm.isListening()) { tm.close(); } } }
/** * Puts a list of transport mappings into listen mode. * * @param transportMappings * a list of {@link TransportMapping} instances. * * @throws IOException * if a transport cannot listen to incoming messages. */ protected static void launchTransportMappings(Collection<? extends TransportMapping> transportMappings) throws IOException { ArrayList<? extends TransportMapping> l = new ArrayList<TransportMapping>(transportMappings); for (TransportMapping tm : l) { if (!tm.isListening()) { tm.listen(); } } }
/** * Puts a list of transport mappings into listen mode. * @param transportMappings * a list of {@link TransportMapping} instances. * @throws IOException * if a transport cannot listen to incoming messages. */ protected static void launchTransportMappings(Collection transportMappings) throws IOException { ArrayList l = new ArrayList(transportMappings); for (Iterator it = l.iterator(); it.hasNext();) { TransportMapping tm = (TransportMapping) it.next(); if (!tm.isListening()) { tm.listen(); } } }
@Override protected void doStop() throws Exception { // stop listening to the transport if (this.transport != null && this.transport.isListening()) { LOG.info("Stopping OID poller on {}", targetAddress); this.transport.close(); LOG.info("Stopped OID poller on {}", targetAddress); } super.doStop(); }
/** * Puts all associated transport mappings into listen mode. * @throws IOException * if a transport mapping throws an <code>IOException</code> when its * {@link TransportMapping#listen()} method has been called. */ public void listen() throws IOException { for (Iterator it = messageDispatcher.getTransportMappings().iterator(); it.hasNext(); ) { TransportMapping tm = (TransportMapping) it.next(); if (!tm.isListening()) { tm.listen(); } } }
/** * Puts all associated transport mappings into listen mode. * @throws IOException * if a transport mapping throws an <code>IOException</code> when its * {@link TransportMapping#listen()} method has been called. */ public void listen() throws IOException { for (TransportMapping tm : messageDispatcher.getTransportMappings()) { if (!tm.isListening()) { tm.listen(); } } }
@Override public synchronized void stop() throws Exception { // stop listening to the transport if (this.transport.isListening()) { this.transport.close(); } super.stop(); }
@Override protected void doStop() throws Exception { // stop listening to the transport if (this.transport != null && this.transport.isListening()) { if (LOG.isDebugEnabled()) { LOG.debug("Stopping trap consumer on {}", this.endpoint.getAddress()); } this.transport.close(); LOG.info("Stopped trap consumer on {}", this.endpoint.getAddress()); } super.doStop(); }
/** * Puts all associated transport mappings into listen mode. * * @throws IOException * if a transport mapping throws an <code>IOException</code> when its * {@link TransportMapping#listen()} method has been called. */ public void listen() throws IOException { for (TransportMapping<?> tm : messageDispatcher.getTransportMappings()) { if (!tm.isListening()) { tm.listen(); } } }
@Override public synchronized void stop() throws Exception { // stop listening only if the endpoint was initialized if (isEnabled()) { // stop listening to the transport if (this.transport.isListening()) { this.transport.close(); } } super.stop(); }
it.hasNext(); ) { TransportMapping tm = (TransportMapping) it.next(); if (tm.isListening()) { tm.close();
/** * Builds target resource. * @param context Process context */ private void buildTargetResource(ProcessContext context) { if((this.transportMapping == null) || !this.transportMapping.isListening() || (this.snmp == null)) { try { this.transportMapping = new DefaultUdpTransportMapping(); this.snmp = new Snmp(this.transportMapping); if("SNMPv3".equals(context.getProperty(SNMP_VERSION).getValue())) { USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); } this.transportMapping.listen(); } catch (Exception e) { throw new IllegalStateException("Failed to initialize UDP transport mapping", e); } } if (this.snmpTarget == null) { this.snmpTarget = this.createSnmpTarget(context); } if (this.targetResource == null) { this.targetResource = this.finishBuildingTargetResource(context); } }