abhishekagarwal87 commented on code in PR #15409:
URL: https://github.com/apache/druid/pull/15409#discussion_r1400140265
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java:
##########
@@ -520,7 +521,10 @@ public boolean add(final Task task) throws
EntryExistsException
try {
Preconditions.checkState(active, "Queue is not active!");
Preconditions.checkNotNull(task, "task");
- Preconditions.checkState(tasks.size() < config.getMaxSize(), "Too many
tasks (max = %s)", config.getMaxSize());
+ if (tasks.size() >= config.getMaxSize()) {
+ throw new TooManyTasksException(StringUtils.format("Too many tasks
(maxQueueSize = %d), " +
Review Comment:
The "dropping" is misleading. We are not dropping anything, just rejecting
the extra task. So lets just say that and please add to "retry later or
increase the limit" in the error message.
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java:
##########
@@ -520,7 +521,10 @@ public boolean add(final Task task) throws
EntryExistsException
try {
Preconditions.checkState(active, "Queue is not active!");
Preconditions.checkNotNull(task, "task");
- Preconditions.checkState(tasks.size() < config.getMaxSize(), "Too many
tasks (max = %s)", config.getMaxSize());
+ if (tasks.size() >= config.getMaxSize()) {
+ throw new TooManyTasksException(StringUtils.format("Too many tasks
(maxQueueSize = %d), " +
Review Comment:
Instead of TooManyTasksException, you can create a failure type similar to
Forbidden. This failure type can be called TooManyRequests. The failure will
have an error code set to 429.
In here, you can create
DruidException.fromFailure(TooManyRequests).forPersona(Operator).message(<the
message>)
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java:
##########
@@ -520,7 +521,10 @@ public boolean add(final Task task) throws
EntryExistsException
try {
Preconditions.checkState(active, "Queue is not active!");
Preconditions.checkNotNull(task, "task");
- Preconditions.checkState(tasks.size() < config.getMaxSize(), "Too many
tasks (max = %s)", config.getMaxSize());
+ if (tasks.size() >= config.getMaxSize()) {
+ throw new TooManyTasksException(StringUtils.format("Too many tasks
(maxQueueSize = %d), " +
Review Comment:
Once you get rid of TooManyException class, the PR will also have less
changes IMO
--
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]