You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by tm...@apache.org on 2018/11/01 15:45:32 UTC

[sling-org-apache-sling-distribution-core] 01/01: SLING-8065 - Introduce ReadOnlyDistributionQueue API

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

tmaret pushed a commit to branch SLING-8065
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-core.git

commit 0065744d1e593f7774ce068e638987c772957a13
Author: tmaret <tm...@adobe.com>
AuthorDate: Thu Nov 1 16:44:37 2018 +0100

    SLING-8065 - Introduce ReadOnlyDistributionQueue API
---
 .../distribution/queue/spi/DistributionQueue.java  | 53 ++--------------------
 ...onQueue.java => ReadOnlyDistributionQueue.java} | 47 ++++---------------
 .../sling/distribution/queue/spi/package-info.java |  2 +-
 3 files changed, 14 insertions(+), 88 deletions(-)

diff --git a/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java b/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java
index 7cff77e..ec57523 100644
--- a/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java
+++ b/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java
@@ -30,6 +30,8 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
+ * An editable distribution queue holding {@link DistributionQueueEntry} distribution queue entries.
+ * <p/>
  * A queue is responsible for collecting the {@link DistributionPackage}s
  * exported by a {@link DistributionAgent} in
  * order to be able to process them also when there are multiple (concurrent)
@@ -40,15 +42,7 @@ import org.jetbrains.annotations.Nullable;
  * strategy or in parallel, or some other way, via {@link DistributionQueueProcessor}s.
  */
 @ConsumerType
-public interface DistributionQueue {
-
-    /**
-     * get this queue name
-     *
-     * @return the queue name
-     */
-    @NotNull
-    String getName();
+public interface DistributionQueue extends ReadOnlyDistributionQueue {
 
     /**
      * add a distribution item to this queue
@@ -61,34 +55,6 @@ public interface DistributionQueue {
     DistributionQueueEntry add(@NotNull DistributionQueueItem item);
 
     /**
-     * get the first item (in a FIFO strategy, the next to be processed) from the queue
-     *
-     * @return the first item into the queue or {@code null} if the queue is empty
-     */
-    @Nullable
-    DistributionQueueEntry getHead();
-
-    /**
-     * get all the items in the queue
-     *
-     * @param skip the number of items to skip
-     * @param limit the maximum number of items to return. use -1 to return all items.
-     * @return a {@link java.lang.Iterable} of {@link DistributionQueueItem}s
-     */
-    @NotNull
-    Iterable<DistributionQueueEntry> getItems(int skip, int limit);
-
-    /**
-     * gets an item from the queue by specifying its id
-     *
-     * @param itemId the id of the item as returned by {@link DistributionQueueItem#getPackageId()}
-     * @return the item, or {@code null} if the item with the given id
-     * doesn't exist
-     */
-    @Nullable
-    DistributionQueueEntry getItem(@NotNull String itemId);
-
-    /**
      * remove an item from the queue by specifying its id
      *
      * @param itemId the id the item as returned by {@link DistributionQueueItem#getPackageId()}
@@ -98,17 +64,4 @@ public interface DistributionQueue {
     @Nullable
     DistributionQueueEntry remove(@NotNull String itemId);
 
-    /**
-     * get the status of the queue
-     * @return the queue status
-     */
-    @NotNull
-    DistributionQueueStatus getStatus();
-
-    /**
-     * get the type of this queue
-     * @return the type
-     */
-    @NotNull
-    DistributionQueueType getType();
 }
diff --git a/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java b/src/main/java/org/apache/sling/distribution/queue/spi/ReadOnlyDistributionQueue.java
similarity index 56%
copy from src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java
copy to src/main/java/org/apache/sling/distribution/queue/spi/ReadOnlyDistributionQueue.java
index 7cff77e..753d54d 100644
--- a/src/main/java/org/apache/sling/distribution/queue/spi/DistributionQueue.java
+++ b/src/main/java/org/apache/sling/distribution/queue/spi/ReadOnlyDistributionQueue.java
@@ -19,28 +19,20 @@
 package org.apache.sling.distribution.queue.spi;
 
 import aQute.bnd.annotation.ConsumerType;
-import org.apache.sling.distribution.agent.spi.DistributionAgent;
-import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.queue.DistributionQueueEntry;
 import org.apache.sling.distribution.queue.DistributionQueueItem;
 import org.apache.sling.distribution.queue.DistributionQueueStatus;
 import org.apache.sling.distribution.queue.DistributionQueueType;
-import org.apache.sling.distribution.queue.impl.DistributionQueueProcessor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
- * A queue is responsible for collecting the {@link DistributionPackage}s
- * exported by a {@link DistributionAgent} in
- * order to be able to process them also when there are multiple (concurrent)
- * {@link org.apache.sling.distribution.DistributionRequest}s executed
- * on that same agent.
- * <p/>
- * The items (packages) in the queue can then get processed according to a FIFO
- * strategy or in parallel, or some other way, via {@link DistributionQueueProcessor}s.
+ * A read only distribution queue holding {@link DistributionQueueEntry} distribution queue entries.
+ *
+ * @since 0.1.0
  */
 @ConsumerType
-public interface DistributionQueue {
+public interface ReadOnlyDistributionQueue {
 
     /**
      * get this queue name
@@ -51,25 +43,15 @@ public interface DistributionQueue {
     String getName();
 
     /**
-     * add a distribution item to this queue
+     * get the first queue entry (in a FIFO strategy, the next to be processed) from the queue
      *
-     * @param item a distribution item, typically representing a {@link DistributionPackage}
-     *             to distribute
-     * @return the queue entry created for this item or {@code noll} if none is created
-     */
-    @Nullable
-    DistributionQueueEntry add(@NotNull DistributionQueueItem item);
-
-    /**
-     * get the first item (in a FIFO strategy, the next to be processed) from the queue
-     *
-     * @return the first item into the queue or {@code null} if the queue is empty
+     * @return the first entry into the queue or {@code null} if the queue is empty
      */
     @Nullable
     DistributionQueueEntry getHead();
 
     /**
-     * get all the items in the queue
+     * get all the entries in the queue
      *
      * @param skip the number of items to skip
      * @param limit the maximum number of items to return. use -1 to return all items.
@@ -79,26 +61,16 @@ public interface DistributionQueue {
     Iterable<DistributionQueueEntry> getItems(int skip, int limit);
 
     /**
-     * gets an item from the queue by specifying its id
+     * gets an entry from the queue by specifying its id
      *
      * @param itemId the id of the item as returned by {@link DistributionQueueItem#getPackageId()}
-     * @return the item, or {@code null} if the item with the given id
+     * @return the entry, or {@code null} if the entry with the given id
      * doesn't exist
      */
     @Nullable
     DistributionQueueEntry getItem(@NotNull String itemId);
 
     /**
-     * remove an item from the queue by specifying its id
-     *
-     * @param itemId the id the item as returned by {@link DistributionQueueItem#getPackageId()}
-     * @return the removed item, or {@code null} if the item with the given id
-     * doesn't exist
-     */
-    @Nullable
-    DistributionQueueEntry remove(@NotNull String itemId);
-
-    /**
      * get the status of the queue
      * @return the queue status
      */
@@ -111,4 +83,5 @@ public interface DistributionQueue {
      */
     @NotNull
     DistributionQueueType getType();
+
 }
diff --git a/src/main/java/org/apache/sling/distribution/queue/spi/package-info.java b/src/main/java/org/apache/sling/distribution/queue/spi/package-info.java
index 96aa8bd..3a80790 100644
--- a/src/main/java/org/apache/sling/distribution/queue/spi/package-info.java
+++ b/src/main/java/org/apache/sling/distribution/queue/spi/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("0.0.1")
+@Version("0.1.0")
 package org.apache.sling.distribution.queue.spi;
 
 import aQute.bnd.annotation.Version;