github-advanced-security[bot] commented on code in PR #18033:
URL: https://github.com/apache/druid/pull/18033#discussion_r2106752994
##########
services/src/main/java/org/apache/druid/cli/CliOverlord.java:
##########
@@ -542,4 +570,27 @@
server.setHandler(handlerList);
}
}
+
+ protected static boolean addQOSFiltering(ServletContextHandler root, int
threadsForOvelordWork)
+ {
+ if (threadsForOvelordWork >= ServerConfig.DEFAULT_NUM_PACKING_THREADS) {
+ log.info("Enabling QOS filter on overlord requests with limit [%d].",
threadsForOvelordWork);
+ JettyBindings.QosFilterHolder filterHolder = new
JettyBindings.QosFilterHolder(
+ new String[]{
+ "/druid-internal/v1/*",
+ "/druid/indexer/v1/*"
+ },
+ threadsForOvelordWork
+ );
+ JettyServerInitUtils.addFilters(root,
Collections.singleton(filterHolder));
+ return true;
+ } else {
+ log.info(
+ "QOS filter is disabled for the overlord requests." +
+ "Set `druid.server.http.numThread` to a value greater than %d to
enable QoSFilter.",
Review Comment:
## Missing space in string literal
This string appears to be missing a space after 'requests.'.
[Show more
details](https://github.com/apache/druid/security/code-scanning/9198)
##########
services/src/test/java/org/apache/druid/cli/CliOverlordTest.java:
##########
@@ -47,4 +48,32 @@
= overlordInjector.getInstance(SegmentsMetadataManager.class);
Assert.assertTrue(segmentsMetadataManager instanceof
SqlSegmentsMetadataManagerV2);
}
+
+ @Test
+ public void testQosFilteringEnabled()
+ {
+ ServletContextHandler handler = new ServletContextHandler();
+ final int threadsForOverlordWork = 30;
+
+ Assert.assertTrue(CliOverlord.addQOSFiltering(handler,
threadsForOverlordWork));
+
+ Assert.assertEquals(
+ threadsForOverlordWork,
+
Integer.parseInt(handler.getServletHandler().getFilters()[0].getInitParameters().get("maxRequests"))
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more
details](https://github.com/apache/druid/security/code-scanning/9197)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]