org.glassfish.grizzly.Connection.close()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(219)

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

Connection.close介绍

[英]Gracefully close the Connection
[中]优雅地关闭连接

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
public void close() {
  try {
    super.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    removeChannelIfDisconnected(connection);
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    if (logger.isInfoEnabled()) {
      logger.info("Close grizzly channel " + connection);
    }
    connection.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public void close() {
  try {
    super.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    removeChannelIfDisconnected(connection);
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    if (logger.isInfoEnabled()) {
      logger.info("Close grizzly channel " + connection);
    }
    connection.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public void close(CloseReason reason) {
    grizzlyConnection.close();
  }
});

代码示例来源:origin: org.shoal/shoal-gms-impl

private void closeCacheRecord(final CacheRecord cacheRecord) {
  if (cacheRecord == null) return;
  Connection connection;
  while ((connection = cacheRecord.connections.poll()) != null) {
    cacheRecord.idleConnectionsCount.decrementAndGet();
    connection.close();
  }
}

代码示例来源:origin: io.gatling/async-http-client

void destroy() {
  for (Connection c : queue) {
    c.close();
  }
  queue.clear();
  queues.remove(this);
}

代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl

private void closeCacheRecord(final CacheRecord cacheRecord) {
  if (cacheRecord == null) return;
  Connection connection;
  while ((connection = cacheRecord.connections.poll()) != null) {
    cacheRecord.idleConnectionsCount.decrementAndGet();
    connection.close();
  }
}

代码示例来源:origin: org.shoal/shoal-gms-impl

void close() {
  if (!isClosed.getAndSet(true)) {
    for (Iterator<Connection> it = connections.keySet().iterator(); it.hasNext(); ) {
      final Connection connection = it.next();
      it.remove();
      connection.close();
    }
  }
}

代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl

void register(final Connection connection) {
  if (connections.putIfAbsent(connection, System.currentTimeMillis()) == null) {
    connection.addCloseListener(closeListener);
    if (isClosed.get()) {
      connection.close();
    }
  }
}

代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl

void close() {
  if (!isClosed.getAndSet(true)) {
    for (Iterator<Connection> it = connections.keySet().iterator(); it.hasNext(); ) {
      final Connection connection = it.next();
      it.remove();
      connection.close();
    }
  }
}

代码示例来源:origin: org.shoal/shoal-gms-impl

void register(final Connection connection) {
  if (connections.putIfAbsent(connection, System.currentTimeMillis()) == null) {
    connection.addCloseListener(closeListener);
    if (isClosed.get()) {
      connection.close();
    }
  }
}

代码示例来源:origin: org.glassfish.grizzly/connection-pool

@Override
  public boolean doWork(final ConnectionInfo ci) {
    if (LOGGER.isLoggable(Level.FINEST)) {
      LOGGER.log(Level.FINEST, "Connection {0} TTL expired",
          ci.connection);
    }
    
    synchronized(ci.endpointPool.poolSync) {
      if (ci.isReady()) {
        ci.connection.close();
      } else {
        ci.endpointPool.detach(ci.connection);
      }
    }
    
    return true;
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  public boolean doWork(final ConnectionInfo ci) {
    if (LOGGER.isLoggable(Level.FINEST)) {
      LOGGER.log(Level.FINEST, "Connection {0} TTL expired",
          ci.connection);
    }
    
    synchronized(ci.endpointPool.poolSync) {
      if (ci.isReady()) {
        ci.connection.close();
      } else {
        ci.endpointPool.detach(ci.connection);
      }
    }
    
    return true;
  }
}

代码示例来源:origin: io.gatling/async-http-client

private void closeConnection() {
  if (connection != null && connection.isOpen()) {
    connection.close().markForRecycle(true);
  }
}

代码示例来源:origin: org.glassfish.shoal/shoal-gms-impl

@Override
  public NextAction handleRead(final FilterChainContext ctx)
      throws IOException {
    ctx.getConnection().close();
    
    return ctx.getStopAction();
  }
}

代码示例来源:origin: org.shoal/shoal-gms-impl

@Override
  public NextAction handleRead(final FilterChainContext ctx)
      throws IOException {
    ctx.getConnection().close();
    
    return ctx.getStopAction();
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly-client

@Override
  public void close() {
    super.close();
    try {
      if (sharedTransport) {
        connection.close();
      } else {
        connection.getTransport().shutdownNow();
      }
    } catch (IOException e) {
      Logger.getLogger(GrizzlyClientFilter.class.getName())
         .log(Level.INFO, "Exception thrown during shutdown.", e);
    }
  }
};

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public void close() {
    super.close();
    try {
      if (sharedTransport) {
        connection.close();
      } else {
        connection.getTransport().shutdownNow();
      }
    } catch (IOException e) {
      Logger.getLogger(GrizzlyClientFilter.class.getName())
         .log(Level.INFO, "Exception thrown during shutdown.", e);
    }
  }
};

代码示例来源:origin: com.alibaba/dubbo

@Override
public void close() {
  try {
    super.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    removeChannelIfDisconnected(connection);
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
  try {
    if (logger.isInfoEnabled()) {
      logger.info("Close grizzly channel " + connection);
    }
    connection.close();
  } catch (Exception e) {
    logger.warn(e.getMessage(), e);
  }
}

代码示例来源:origin: io.gatling/async-http-client

private static HttpTransactionContext cleanup(final FilterChainContext ctx,
                       final GrizzlyAsyncHttpProvider provider) {
  final Connection c = ctx.getConnection();
  final HttpTransactionContext context = HttpTransactionContext.remove(c);
  if (!context.provider.connectionManager.canReturnConnection(c)) {
    context.abort(new IOException("Maximum pooled connections exceeded"));
  } else {
    if (!context.provider.connectionManager.returnConnection(context.request, c)) {
      ctx.getConnection().close();
    }
  }
  return context;
}

代码示例来源:origin: org.forgerock.ce.opendj/opendj-ldap-sdk

@Override
public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
  final Connection<?> connection = ctx.getConnection();
  LDAPListenerOptions options = listener.getLDAPListenerOptions();
  configureConnection(connection, options.isTCPNoDelay(), options.isKeepAlive(), options
      .isReuseAddress(), options.getLinger());
  try {
    final ClientContextImpl clientContext = new ClientContextImpl(connection);
    final ServerConnection<Integer> serverConn =
        listener.getConnectionFactory().handleAccept(clientContext);
    clientContext.setServerConnection(serverConn);
    LDAP_CONNECTION_ATTR.set(connection, clientContext);
  } catch (final ErrorResultException e) {
    connection.close();
  }
  return ctx.getStopAction();
}

相关文章