@Override public Integer getValue() { return pool.queued().size(); } });
@Override public Integer getValue() { return pool.availables().size(); } });
@Override public Integer getValue() { return pool.inUse().size(); } });
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e->e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() != 1) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "%s valid endpoints available: %s", possibleEndpoints.size(), serverEndpoints )); } return possibleEndpoints.head(); }
MySqlConnectionPool(final MySQLConnectionFactory connFactory, final PoolConfiguration poolConfiguration, final MetricFactory metricFactory) { _pool = new ConnectionPool<>(connFactory, poolConfiguration, ScalaFutureHelper.ctx); this.metricFactory = metricFactory; if (metricFactory != null) { metricFactory.registerGauge("old_MysqlAsyncConnectionPool", "available", () -> _pool.availables().size()); metricFactory.registerGauge("old_MysqlAsyncConnectionPool", "waiting", () -> _pool.queued().size()); metricFactory.registerGauge("old_MysqlAsyncConnectionPool", "inUse", () -> _pool.inUse().size()); sendQueryCounter = metricFactory.createCounter("old_MysqlAsyncConnectionPool", "sendQueryCounter"); sendQueryTimer = metricFactory.createTimer("old_MysqlAsyncConnectionPool", "sendQueryTimer"); preparedStatementCounter = metricFactory.createCounter("old_MysqlAsyncConnectionPool", "preparedStatementCounter"); preparedStatementTimer = metricFactory.createTimer("old_MysqlAsyncConnectionPool", "preparedStatementTimer"); } else { sendQueryCounter = null; sendQueryTimer = null; preparedStatementCounter = null; preparedStatementTimer = null; } }
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e -> e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() == 0) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "no valid endpoints available. %s", serverEndpoints )); } else if (possibleEndpoints.size() == 1) { return possibleEndpoints.head(); } else { // TODO: the decision on which HTTP/2 endpoint to use should be based on config (e.g. maybe the user set // `akka.grpc.client."".use-tls` to false for gRPC so this should return the non-TLS HTTP/2 endpoint on the list. return possibleEndpoints.filter(endpoint -> endpoint.ssl().isDefined()).head(); } }