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

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

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

Connection.addCloseListener介绍

[英]Add the CloseListener, which will be notified once Connection will be closed.
[中]添加CloseListener,一旦连接关闭,就会通知它。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

String graphAffinity = pathComponents[2];
request.getRequest().getConnection()
    .addCloseListener((closeable, iCloseType) -> {
      broker.removeSuspendedResponse(graphAffinity, response);
    });
      .addCloseListener((closeable, iCloseType) -> {
        broker.deletePriorityTask(task.taskId);
      });
request.getRequest().getConnection().addCloseListener((c, i) -> {
  broker.removeSinglePointChannel(graphAffinity, wr);
});

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

@Override
public void addCloseListener(final CloseListener closeListener) {
  final org.glassfish.tyrus.websockets.Connection webSocketConnection = this;
  connection.addCloseListener(new org.glassfish.grizzly.CloseListener() {
    @Override
    public void onClosed(Closeable closeable, ICloseType iCloseType) throws IOException {
      closeListener.onClose(webSocketConnection);
    }
  });
}

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

@Override
public void onConnectionAcceptEvent(Connection connection) {
  keepAliveConnectionsCount.incrementAndGet();
  connection.addCloseListener(new GenericCloseListener() {
    @Override
    public void onClosed(final Closeable closeable,
        final CloseType closeType) throws IOException {
      keepAliveConnectionsCount.decrementAndGet();
    }
  });
}

代码示例来源: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.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: io.gatling/async-http-client

static void set(final Connection c, final HttpTransactionContext httpTxContext) {
  c.addCloseListener(httpTxContext.listener);
  REQUEST_STATE_ATTR.set(c, httpTxContext);
}

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

public void offer(final Connection connection) {
  final SocketAddress remoteAddress = (SocketAddress) connection.getPeerAddress();
  final CacheRecord cacheRecord = obtainCacheRecord(remoteAddress);
  final int totalConnectionsN = totalCachedConnectionsCount.incrementAndGet();
  final int parallelConnectionN = cacheRecord.idleConnectionsCount.incrementAndGet();
  if (totalConnectionsN > highWaterMark ||
      parallelConnectionN > maxParallelConnections) {
    totalCachedConnectionsCount.decrementAndGet();
    cacheRecord.idleConnectionsCount.decrementAndGet();
  }
  connection.addCloseListener(removeCachedConnectionOnCloseListener);
  cacheRecord.connections.offer(connection);
  
  if (isClosed.get()) {
    // remove cache entry associated with the remoteAddress (only if we have the actual value)
    cache.remove(remoteAddress, cacheRecord);
    closeCacheRecord(cacheRecord);
  }
}

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

/**
 * The method attaches {@link Connection} to the pool.
 */
ConnectionInfo<E> attach0(final Connection connection) {
  poolSize++;
  final ConnectionInfo<E> info =
      new ConnectionInfo<E>(connection, this);
  connectionsMap.put(connection, info);
  
  if (connectionTTLMillis >= 0) {
    connectionTTLQueue.add(info,
        connectionTTLMillis, TimeUnit.MILLISECONDS);
  }
  connection.addCloseListener(closeListener);
  return info;
}

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

public void offer(final Connection connection) {
  final SocketAddress remoteAddress = (SocketAddress) connection.getPeerAddress();
  final CacheRecord cacheRecord = obtainCacheRecord(remoteAddress);
  final int totalConnectionsN = totalCachedConnectionsCount.incrementAndGet();
  final int parallelConnectionN = cacheRecord.idleConnectionsCount.incrementAndGet();
  if (totalConnectionsN > highWaterMark ||
      parallelConnectionN > maxParallelConnections) {
    totalCachedConnectionsCount.decrementAndGet();
    cacheRecord.idleConnectionsCount.decrementAndGet();
  }
  connection.addCloseListener(removeCachedConnectionOnCloseListener);
  cacheRecord.connections.offer(connection);
  
  if (isClosed.get()) {
    // remove cache entry associated with the remoteAddress (only if we have the actual value)
    cache.remove(remoteAddress, cacheRecord);
    closeCacheRecord(cacheRecord);
  }
}

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

/**
 * The method attaches {@link Connection} to the pool.
 */
ConnectionInfo<E> attach0(final Connection connection) {
  poolSize++;
  final ConnectionInfo<E> info =
      new ConnectionInfo<E>(connection, this);
  connectionsMap.put(connection, info);
  
  if (connectionTTLMillis >= 0) {
    connectionTTLQueue.add(info,
        connectionTTLMillis, TimeUnit.MILLISECONDS);
  }
  connection.addCloseListener(closeListener);
  return info;
}

代码示例来源:origin: org.glassfish.main.core/kernel

@Override
public void onConnectionAcceptEvent(final Connection connection) {
  grizzlyMonitoring.getKeepAliveProbeProvider().incrementCountConnectionsEvent(monitoringId);
  connection.addCloseListener(new Connection.CloseListener() {
    @Override
    public void onClosed(final Connection connection, Connection.CloseType closeType) throws IOException {
      grizzlyMonitoring.getKeepAliveProbeProvider().decrementCountConnectionsEvent(monitoringId);
    }
  });
}

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

public void completed(Connection connection) {
  future.setConnection(connection);
  provider.touchConnection(connection, request);
  if (wrappedHandler != null) {
    connection.addCloseListener(connectionMonitor);
    wrappedHandler.completed(connection);
  }
}

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

connection.addCloseListener(closeListener);

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

connection.addCloseListener(closeListener);

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

connection.addCloseListener(closeListener);

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

connection.addCloseListener(closeListener);

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

connection.addCloseListener(closeListener);

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

connection.addCloseListener(closeListener);

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-framework

connection.addCloseListener(closeListener);

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

connection.addCloseListener(closeListener);

相关文章