private boolean isMaxCollections() { int limit = this.collectionLimit.get().limit(); if (limit < 1) { log.warn("Ignoring max-concurrent-collections as its lower than 1. Current: {} Default {}", SafeArg.of("current", limit), SafeArg.of("default", PrometheusCollectionLimit.DEFAULT_MAX_COLLECTIONS)); COLLECTION_REQUESTS_MAX.set(PrometheusCollectionLimit.DEFAULT_MAX_COLLECTIONS); } else { COLLECTION_REQUESTS_MAX.set(limit); } return currentRequests.incrementAndGet() > COLLECTION_REQUESTS_MAX.get(); } }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { super.channelRegistered(ctx); activeConnections.inc(); if (activeConnections.get() > service.getConfiguration().getMaxConcurrentInboundConnections()) { ctx.close(); rejectedConnections.inc(); return; } }
log.error(TOO_MANY_REQUESTS_ERROR, SafeArg.of("current", currentRequests.get()), SafeArg.of("max", COLLECTION_REQUESTS_MAX.get()) ); throw TOO_MANY_REQUESTS;