You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2013/12/26 21:23:27 UTC
git commit: [JGroups] Added Javadoc.
Updated Branches:
refs/heads/master 7b51e4935 -> baeb7a049
[JGroups] Added Javadoc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/baeb7a04
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/baeb7a04
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/baeb7a04
Branch: refs/heads/master
Commit: baeb7a0492280437392d39f2b0fe295cec59c7e6
Parents: 7b51e49
Author: Henryk Konsek <he...@gmail.com>
Authored: Thu Dec 26 21:23:03 2013 +0100
Committer: Henryk Konsek <he...@gmail.com>
Committed: Thu Dec 26 21:23:03 2013 +0100
----------------------------------------------------------------------
.../apache/camel/component/jgroups/JGroupsFilters.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/baeb7a04/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsFilters.java
----------------------------------------------------------------------
diff --git a/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsFilters.java b/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsFilters.java
index a73ec25..ca1c8dc 100644
--- a/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsFilters.java
+++ b/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsFilters.java
@@ -18,15 +18,25 @@ package org.apache.camel.component.jgroups;
import org.apache.camel.Exchange;
import org.apache.camel.Predicate;
+import org.jgroups.Address;
import org.jgroups.View;
import static org.apache.camel.component.jgroups.JGroupsEndpoint.HEADER_JGROUPS_CHANNEL_ADDRESS;
public final class JGroupsFilters {
+ private static final int COORDINATOR_NODE_INDEX = 0;
+
private JGroupsFilters() {
}
+ /**
+ * Creates predicate rejecting messages that are instances of {@link org.jgroups.View}, but have not been received
+ * by the coordinator JGroups node. This filter is useful for keeping only view messages indicating that receiving
+ * endpoint is a master node.
+ *
+ * @return predicate filtering out non-coordinator view messages.
+ */
public static Predicate dropNonCoordinatorViews() {
return new Predicate() {
@Override
@@ -34,7 +44,8 @@ public final class JGroupsFilters {
Object body = exchange.getIn().getBody();
if (body instanceof View) {
View view = (View) body;
- return exchange.getIn().getHeader(HEADER_JGROUPS_CHANNEL_ADDRESS).equals(view.getMembers().get(0));
+ Address channelAddress = exchange.getIn().getHeader(HEADER_JGROUPS_CHANNEL_ADDRESS, Address.class);
+ return channelAddress.equals(view.getMembers().get(COORDINATOR_NODE_INDEX));
}
return true;
}