You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2021/11/11 07:46:20 UTC

[camel] branch main updated: CAMEL-17121: final cleanups

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new b281d36  CAMEL-17121: final cleanups
b281d36 is described below

commit b281d36ec4ed98f7d1ea475a4a556cef5e8ca470
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Wed Nov 10 18:54:13 2021 +0100

    CAMEL-17121: final cleanups
    
    - Added documentation details
    - Fixed typos
    - Fixed/improved log messages
    - Used final for a few variables
---
 .../java/org/apache/camel/support/task/BackgroundTask.java   |  4 ++--
 .../org/apache/camel/support/task/budget/BudgetBuilder.java  |  2 +-
 .../java/org/apache/camel/support/task/budget/Budgets.java   |  2 +-
 .../camel/support/task/budget/IterationBoundedBudget.java    |  6 ++++++
 .../apache/camel/support/task/budget/IterationBudget.java    |  2 +-
 .../support/task/budget/IterationTimeBoundedBudget.java      | 12 ++++++++++--
 .../apache/camel/support/task/budget/TimeBoundedBudget.java  |  5 ++++-
 .../org/apache/camel/support/task/budget/TimeBudget.java     |  2 +-
 8 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/BackgroundTask.java b/core/camel-support/src/main/java/org/apache/camel/support/task/BackgroundTask.java
index 1cf0738..48567b1 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/BackgroundTask.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/BackgroundTask.java
@@ -55,7 +55,7 @@ public class BackgroundTask implements BlockingTask {
         }
 
         /**
-         * Sets a executor service manager for managing the threads
+         * Sets an executor service manager for managing the threads
          *
          * @param  service an instance of an executor service to use
          * @return
@@ -155,7 +155,7 @@ public class BackgroundTask implements BlockingTask {
                 if (!latch.await(budget.maxDuration(), TimeUnit.MILLISECONDS)) {
                     LOG.debug("Timeout out waiting for the completion of the task");
                 } else {
-                    LOG.info("The task is complete after iterations and the code is ready to continue");
+                    LOG.debug("The task has finished the execution and it is ready to continue");
 
                     completed = true;
                 }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/BudgetBuilder.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/BudgetBuilder.java
index bf77d0b..d24b2ae 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/BudgetBuilder.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/BudgetBuilder.java
@@ -26,7 +26,7 @@ public interface BudgetBuilder<T extends Budget> {
     /**
      * Build the budget
      * 
-     * @return
+     * @return the budget that was built
      */
     T build();
 }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/Budgets.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/Budgets.java
index 8d02a90..e21ba68 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/Budgets.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/Budgets.java
@@ -82,7 +82,7 @@ public final class Budgets {
     }
 
     /**
-     * Some components use 0 to disable retring the task. This sanitizes it to run at least once
+     * Some components use 0 to disable retrying the task. This sanitizes it to run at least once
      * 
      * @param  iterations the number of iterations
      * @return            an integer greater than or equal to 1 equivalent to the maximum number of iterations allowed
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBoundedBudget.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBoundedBudget.java
index 6cf3574..4ee42db 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBoundedBudget.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBoundedBudget.java
@@ -20,7 +20,13 @@ package org.apache.camel.support.task.budget;
 import org.apache.camel.support.task.budget.backoff.BackOffStrategy;
 import org.apache.camel.support.task.budget.backoff.FixedBackOffStrategy;
 
+/**
+ * This task budget limits the execution by a given number of iterations or an unlimited number if configured to do so.
+ */
 public class IterationBoundedBudget implements IterationBudget {
+    /**
+     * Defines an "unlimited" number of iterations
+     */
     public static final int UNLIMITED_ITERATIONS = -1;
 
     private final long initialDelay;
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBudget.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBudget.java
index 497e8af..0e4d730 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBudget.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationBudget.java
@@ -25,7 +25,7 @@ public interface IterationBudget extends Budget {
     /**
      * The maximum number of iterations
      * 
-     * @return
+     * @return the maximum number of iterations
      */
     int maxIterations();
 
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationTimeBoundedBudget.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationTimeBoundedBudget.java
index 702bc28..30de527 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationTimeBoundedBudget.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/IterationTimeBoundedBudget.java
@@ -17,9 +17,17 @@
 
 package org.apache.camel.support.task.budget;
 
+/**
+ * This task budget limits the execution by both a given number of iterations or a maximum amount of time for the
+ * execution. When evaluating the budget, the iteration takes precedence over the time budget (hence why: Iteration Time
+ * Budget).
+ *
+ * @see IterationBudget
+ * @see TimeBoundedBudget
+ */
 public class IterationTimeBoundedBudget implements IterationBudget, TimeBudget {
-    private IterationBudget iterationBudget;
-    private TimeBoundedBudget timeBoundedBudget;;
+    private final IterationBudget iterationBudget;
+    private final TimeBoundedBudget timeBoundedBudget;
 
     public IterationTimeBoundedBudget(long initialDelay, long interval, int maxIterations, long maxDuration) {
         iterationBudget = new IterationBoundedBudget(initialDelay, interval, maxIterations);
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBoundedBudget.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBoundedBudget.java
index 5a4e6cf..493d412 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBoundedBudget.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBoundedBudget.java
@@ -20,6 +20,9 @@ package org.apache.camel.support.task.budget;
 import java.time.Duration;
 import java.time.Instant;
 
+/**
+ * This task budget limits the execution by both a maximum amount of time for the execution.
+ */
 public class TimeBoundedBudget implements TimeBudget {
     public static final long UNLIMITED_DURATION = -1;
 
@@ -52,7 +55,7 @@ public class TimeBoundedBudget implements TimeBudget {
 
     @Override
     public boolean canContinue() {
-        // ... the time budget is exhausted
+        // ... if time budget is NOT exhausted
         if (Duration.between(startTime, Instant.now()).toMillis() >= maxDuration) {
             return false;
         }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBudget.java b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBudget.java
index 430fff3..8e490a6 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBudget.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/task/budget/TimeBudget.java
@@ -18,7 +18,7 @@
 package org.apache.camel.support.task.budget;
 
 /**
- * Defines a budge that limits the task execution to certain length of time
+ * Defines a budget that limits the task execution to certain length of time
  */
 public interface TimeBudget extends Budget {