org.snmp4j.Snmp.close()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中org.snmp4j.Snmp.close()方法的一些代码示例,展示了Snmp.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Snmp.close()方法的具体详情如下:
包路径:org.snmp4j.Snmp
类名称:Snmp
方法名:close

Snmp.close介绍

[英]Closes the session and frees any allocated resources, i.e. sockets and the internal thread for processing request timeouts.

If there are any pending requests, the ResponseListener associated with the pending requests, will be called with a null response and a InterruptedException in the error member of the ResponseEvent returned.

After a Session has been closed it must not be used anymore.
[中]关闭会话并释放所有分配的资源,即套接字和内部线程,以处理请求超时。
如果有任何挂起的请求,将调用与挂起的请求关联的ResponseListener,并在返回的ResponseEvent的错误成员中使用null响应和InterruptedException。
Session关闭后,不得再使用。

代码示例

代码示例来源:origin: apache/nifi

/**
 * Closes {@link Snmp} created when instance of this class was created.
 */
@Override
public void close() throws TimeoutException, IOException {
  if (logger.isDebugEnabled()) {
    logger.debug("Closing SNMP connection");
  }
  this.snmp.close();
}

代码示例来源:origin: apache/nifi

/**
 * Will close current SNMP mapping.
 */
@OnStopped
public void close() {
  try {
    if (this.targetResource != null) {
      this.targetResource.close();
    }
  } catch (Exception e) {
    this.getLogger().warn("Failure while closing target resource " + this.targetResource, e);
  }
  this.targetResource = null;
  try {
    if (this.transportMapping != null) {
      this.transportMapping.close();
    }
  } catch (IOException e) {
    this.getLogger().warn("Failure while closing UDP transport mapping", e);
  }
  this.transportMapping = null;
  try {
    if (this.snmp != null) {
      this.snmp.close();
    }
  } catch (IOException e) {
    this.getLogger().warn("Failure while closing UDP transport mapping", e);
  }
  this.snmp = null;
}

代码示例来源:origin: pentaho/pentaho-kettle

try {
 if ( snmp != null ) {
  snmp.close();

代码示例来源:origin: org.openscada.atlantis/org.openscada.da.server.snmp

public void stop () throws IOException
{
  if ( this.snmp != null )
  {
    this.snmp.close ();
    this.snmp = null;
  }
}

代码示例来源:origin: org.opennms.lib.snmp/org.opennms.lib.snmp.snmp4j

protected void close() throws IOException {
    if (m_session != null) {
      m_session.close();
      m_session = null;
    }
  }
}

代码示例来源:origin: fbacchella/jrds

@Override
public final void stop() {
  try {
    snmp.close();
  } catch (IOException e) {
  }
}

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

/**
* Performs service shutdown by stopping SnmpTrapSession
**/
protected void stopService()
 throws Exception
{
  snmp.close();
}

代码示例来源:origin: com.rogueai/snmp2bean

public void close() throws IOException {
    snmp4J.close();
  }
}

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

/**
* Performs service shutdown by stopping SnmpTrapSession
**/
protected void stopService()
 throws Exception
{
  snmp.close();
}

代码示例来源:origin: com.addc/addc-alerts

@Override
  protected void finalize() throws Throwable {
    context.close();
    super.finalize();
  }
}

代码示例来源:origin: com.rogueai/snmp2bean

public void close() {
  try {
    snmp.close();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

代码示例来源:origin: org.apache.nifi/nifi-snmp-processors

/**
 * Closes {@link Snmp} created when instance of this class was created.
 */
@Override
public void close() throws TimeoutException, IOException {
  if (logger.isDebugEnabled()) {
    logger.debug("Closing SNMP connection");
  }
  this.snmp.close();
}

代码示例来源:origin: OpenNMS/opennms

/**
 * 
 */
public void stop() throws IOException {
  m_snmp.close();
}

代码示例来源:origin: OpenNMS/opennms

private static void closeQuietly(Snmp session) {
  if (session == null) {
    return;
  }
  
  try {
    session.close();
  } catch (IOException e) {
    LOG.error("error closing SNMP connection", e);
  } finally {
    Snmp4JStrategy.reapSession(session);
  }
}

代码示例来源:origin: org.opennms.core.snmp/org.opennms.core.snmp.implementations.snmp4j

private static void closeQuietly(Snmp session) {
  if (session == null) {
    return;
  }
  
  try {
    session.close();
  } catch (IOException e) {
    LOG.error("error closing SNMP connection", e);
  } finally {
    Snmp4JStrategy.reapSession(session);
  }
}

代码示例来源:origin: com.rogueai/snmp2bean

public void stop() throws Exception {
  snmp.close();
  threadPool.cancel();
}

代码示例来源:origin: OpenNMS/opennms

@Override
public void unregisterForTraps(final TrapNotificationListener listener, InetAddress address, int snmpTrapPort) throws IOException {
  final RegistrationInfo info = s_registrations.remove(listener);
  final Snmp session = info.getSession();
  try {
    session.close();
  } catch (final IOException e) {
    LOG.error("session error unregistering for traps", e);
    throw e;
  } finally {
    Snmp4JStrategy.reapSession(session);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
public void unregisterForTraps(final TrapNotificationListener listener, final int snmpTrapPort) throws IOException {
  final RegistrationInfo info = s_registrations.remove(listener);
  final Snmp session = info.getSession();
  try {
    session.close();
  } catch (final IOException e) {
    LOG.error("session error unregistering for traps", e);
    throw e;
  } finally {
    Snmp4JStrategy.reapSession(session);
  }
}

代码示例来源:origin: fbacchella/LogHub

@Override
public void close() {
  try {
    snmp.close();
  } catch (IOException e1) {
    logger.error("Failure on snmp close: {}", e1);
    logger.catching(e1);
  }
  super.close();
}

代码示例来源:origin: org.opennms.lib.snmp/org.opennms.lib.snmp.snmp4j

private void closeQuietly(Snmp session) {
    if (session == null) {
      return;
    }
    
    try {
      session.close();
    } catch (IOException e) {
      ThreadCategory.getInstance(Snmp4JStrategy.class).error("error closing SNMP connection: " + e, e);
    }
  }
}

相关文章