You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/05/03 11:04:04 UTC
[10/13] camel git commit: CAMEL-8732: File consumer - Allow to sort
by random
CAMEL-8732: File consumer - Allow to sort by random
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0343c13
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0343c13
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0343c13
Branch: refs/heads/master
Commit: f0343c131ca8400ba04321812f07ed71d8c7e521
Parents: f24eee8
Author: Claus Ibsen <da...@apache.org>
Authored: Sun May 3 10:19:33 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 3 10:52:37 2015 +0200
----------------------------------------------------------------------
.../camel/component/file/GenericFileConsumer.java | 3 +++
.../camel/component/file/GenericFileEndpoint.java | 13 +++++++++++++
2 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f0343c13/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
index 00afddc..c188ebf 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
@@ -153,6 +153,9 @@ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsum
if (endpoint.getSortBy() != null) {
Collections.sort(exchanges, endpoint.getSortBy());
}
+ if (endpoint.isShuffle()) {
+ Collections.shuffle(exchanges);
+ }
// use a queue for the exchanges
Deque<Exchange> q = exchanges;
http://git-wip-us.apache.org/repos/asf/camel/blob/f0343c13/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
index 48512e9..80c597b 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
@@ -154,6 +154,8 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
protected Comparator<GenericFile<T>> sorter;
@UriParam(label = "consumer")
protected Comparator<Exchange> sortBy;
+ @UriParam(label = "consumer")
+ protected boolean shuffle;
@UriParam(label = "consumer", enums = "none,markerFile,fileLock,rename,changed,idempotent")
protected String readLock = "none";
@UriParam(label = "consumer", defaultValue = "1000")
@@ -722,6 +724,17 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
setSortBy(GenericFileDefaultSorter.sortByFileLanguage(getCamelContext(), expression, reverse));
}
+ public boolean isShuffle() {
+ return shuffle;
+ }
+
+ /**
+ * To shuffle the list of files (sort in random order)
+ */
+ public void setShuffle(boolean shuffle) {
+ this.shuffle = shuffle;
+ }
+
public String getTempPrefix() {
return tempPrefix;
}