com.unboundid.ldap.sdk.LDAPConnection.setDisconnectInfo()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(91)

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

LDAPConnection.setDisconnectInfo介绍

[英]Sets the disconnect info for this connection, if it is not already set.
[中]设置此连接的断开连接信息(如果尚未设置)。

代码示例

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Performs any necessary cleanup to ensure that this connection is properly
 * closed before it is garbage collected.
 *
 * @throws  Throwable  If the superclass finalizer throws an exception.
 */
@Override()
protected void finalize()
     throws Throwable
{
 super.finalize();
 setDisconnectInfo(DisconnectType.CLOSED_BY_FINALIZER, null, null);
 setClosed();
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
 * Performs any necessary cleanup to ensure that this connection is properly
 * closed before it is garbage collected.
 *
 * @throws  Throwable  If the superclass finalizer throws an exception.
 */
@Override()
protected void finalize()
     throws Throwable
{
 super.finalize();
 setDisconnectInfo(DisconnectType.CLOSED_BY_FINALIZER, null, null);
 setClosed();
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * {@inheritDoc}
 */
@Override()
protected void doHealthCheck()
{
 final Iterator<Map.Entry<Thread,LDAPConnection>> iterator =
    connections.entrySet().iterator();
 while (iterator.hasNext())
 {
  final Map.Entry<Thread,LDAPConnection> e = iterator.next();
  final Thread                           t = e.getKey();
  final LDAPConnection                   c = e.getValue();
  if (! t.isAlive())
  {
   c.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED, null,
             null);
   c.terminate(null);
   iterator.remove();
  }
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Performs the real work of terminating a defunct connection and replacing it
 * with a new connection if possible.
 *
 * @param  connection  The defunct connection to be replaced.
 */
private void handleDefunctConnection(final LDAPConnection connection)
{
 final Thread t = Thread.currentThread();
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null,
                null);
 connection.terminate(null);
 connections.remove(t);
 if (closed)
 {
  return;
 }
 try
 {
  final LDAPConnection conn = createConnection();
  connections.put(t, conn);
 }
 catch (LDAPException le)
 {
  debugException(le);
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
 * Unbinds from the server and closes the connection, optionally including
 * the provided set of controls in the unbind request.
 * <BR><BR>
 * If this method is invoked while any operations are in progress on this
 * connection, then the directory server may or may not abort processing for
 * those operations, depending on the type of operation and how far along the
 * server has already gotten while processing that operation.  It is
 * recommended that all active operations be abandoned, canceled, or allowed
 * to complete before attempting to close an active connection.
 *
 * @param  controls  The set of controls to include in the unbind request.  It
 *                   may be {@code null} if there are not to be any controls
 *                   sent in the unbind request.
 */
public void close(final Control[] controls)
{
 closeRequested = true;
 setDisconnectInfo(DisconnectType.UNBIND, null, null);
 if (connectionPool == null)
 {
  terminate(controls);
 }
 else
 {
  connectionPool.releaseDefunctConnection(this);
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Indicates that the provided connection should be removed from the pool,
 * and that no new connection should be created to take its place.  This may
 * be used to shrink the pool if such functionality is desired.
 *
 * @param  connection  The connection to be discarded.
 */
public void discardConnection(final LDAPConnection connection)
{
 if (connection == null)
 {
  return;
 }
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED,
    null, null);
 connection.terminate(null);
 poolStatistics.incrementNumConnectionsClosedUnneeded();
 if (availableConnections.remainingCapacity() > 0)
 {
  final int newReplaceCount = failedReplaceCount.incrementAndGet();
  if (newReplaceCount > numConnections)
  {
   failedReplaceCount.set(numConnections);
  }
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
 * Indicates that the provided connection should be removed from the pool,
 * and that no new connection should be created to take its place.  This may
 * be used to shrink the pool if such functionality is desired.
 *
 * @param  connection  The connection to be discarded.
 */
public void discardConnection(final LDAPConnection connection)
{
 if (connection == null)
 {
  return;
 }
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED,
    null, null);
 connection.terminate(null);
 poolStatistics.incrementNumConnectionsClosedUnneeded();
 if (availableConnections.remainingCapacity() > 0)
 {
  final int newReplaceCount = failedReplaceCount.incrementAndGet();
  if (newReplaceCount > numConnections)
  {
   failedReplaceCount.set(numConnections);
  }
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * {@inheritDoc}
 */
@Override()
public LDAPConnection replaceDefunctConnection(
              final LDAPConnection connection)
    throws LDAPException
{
 poolStatistics.incrementNumConnectionsClosedDefunct();
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null,
                null);
 connection.terminate(null);
 connections.remove(Thread.currentThread(), connection);
 if (closed)
 {
  throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get());
 }
 final LDAPConnection newConnection = createConnection();
 connections.put(Thread.currentThread(), newConnection);
 return newConnection;
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Unbinds from the server and closes the connection, optionally including
 * the provided set of controls in the unbind request.
 * <BR><BR>
 * If this method is invoked while any operations are in progress on this
 * connection, then the directory server may or may not abort processing for
 * those operations, depending on the type of operation and how far along the
 * server has already gotten while processing that operation.  It is
 * recommended that all active operations be abandoned, canceled, or allowed
 * to complete before attempting to close an active connection.
 *
 * @param  controls  The set of controls to include in the unbind request.  It
 *                   may be {@code null} if there are not to be any controls
 *                   sent in the unbind request.
 */
@ThreadSafety(level=ThreadSafetyLevel.METHOD_NOT_THREADSAFE)
public void close(final Control[] controls)
{
 closeRequested = true;
 setDisconnectInfo(DisconnectType.UNBIND, null, null);
 if (connectionPool == null)
 {
  terminate(controls);
 }
 else
 {
  connectionPool.releaseDefunctConnection(this);
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

conn.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null);
if (unbind)

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
 * {@inheritDoc}
 */
@Override()
public LDAPConnection replaceDefunctConnection(
              final LDAPConnection connection)
    throws LDAPException
{
 poolStatistics.incrementNumConnectionsClosedDefunct();
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null,
                null);
 connection.terminate(null);
 if (closed)
 {
  throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get());
 }
 return createConnection();
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * {@inheritDoc}
 */
@Override()
public LDAPConnection replaceDefunctConnection(
              final LDAPConnection connection)
    throws LDAPException
{
 poolStatistics.incrementNumConnectionsClosedDefunct();
 connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null,
                null);
 connection.terminate(null);
 if (closed)
 {
  throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get());
 }
 return createConnection();
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
  * Closes the connection.
  */
 public void run()
 {
  final AbstractConnectionPool pool = connection.getConnectionPool();
  if (pool != null)
  {
   final LDAPConnectionPoolStatistics stats =
      pool.getConnectionPoolStatistics();
   if (stats != null)
   {
    stats.incrementNumConnectionsClosedUnneeded();
   }
  }

  connection.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null);
  if (unbind)
  {
   connection.terminate(null);
  }
  else
  {
   connection.setClosed();
  }
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

setDisconnectInfo(DisconnectType.BIND_FAILED, null, le);
close();
throw le;

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

setDisconnectInfo(DisconnectType.BIND_FAILED, null, le);
close();
throw le;

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
  * Closes the connection.
  */
 public void run()
 {
  final AbstractConnectionPool pool = connection.getConnectionPool();
  if (pool != null)
  {
   final LDAPConnectionPoolStatistics stats =
      pool.getConnectionPoolStatistics();
   if (stats != null)
   {
    stats.incrementNumConnectionsClosedUnneeded();
   }
  }

  connection.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null);
  if (unbind)
  {
   connection.terminate(null);
  }
  else
  {
   connection.setClosed();
  }
 }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

connections.put(Thread.currentThread(), newConnection);
connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_EXPIRED,
   null, null);
connection.terminate(null);

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

getExceptionMessage(e));
conn.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, msg, e);
throw new LDAPException(ResultCode.SERVER_DOWN, msg, e);

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

setDisconnectInfo(DisconnectType.UNBIND, null, null);
if (debugEnabled(DebugType.LDAP))

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

setDisconnectInfo(DisconnectType.UNBIND, null, null);
if (debugEnabled(DebugType.LDAP))

相关文章

LDAPConnection类方法