Commit 4d0c825c authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-205: Avoid duplicate DB writes across cluster members for new subscriptions

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/pubsub_clustering@13289 b35dd754-fafc-0310-a699-88a17e54d16e
parent b7105340
......@@ -1759,7 +1759,7 @@ public abstract class Node {
}
}
void addAffiliate(NodeAffiliate affiliate) {
public void addAffiliate(NodeAffiliate affiliate) {
affiliates.add(affiliate);
}
......@@ -2072,9 +2072,8 @@ public abstract class Node {
subscription.sendAuthorizationRequest();
}
// Synchronous so the task can flush all other cluster nodes before
// the last item is retrieved.
CacheFactory.doSynchronousClusterTask(new NewSubscriptionTask(subscription), false);
// Update the other members with the new subscription
CacheFactory.doClusterTask(new NewSubscriptionTask(subscription));
// Send last published item (if node is leaf node and subscription status is ok)
if (isSendItemSubscribe() && subscription.isActive()) {
......
......@@ -40,7 +40,7 @@ public class NodeAffiliate {
private Affiliation affiliation;
NodeAffiliate(Node node, JID jid) {
public NodeAffiliate(Node node, JID jid) {
this.node = node;
this.jid = jid;
}
......@@ -57,7 +57,7 @@ public class NodeAffiliate {
return affiliation;
}
void setAffiliation(Affiliation affiliation) {
public void setAffiliation(Affiliation affiliation) {
this.affiliation = affiliation;
}
......
package org.jivesoftware.openfire.pubsub.cluster;
import org.jivesoftware.openfire.pubsub.Node;
import org.jivesoftware.openfire.pubsub.NodeAffiliate;
import org.jivesoftware.openfire.pubsub.NodeSubscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
public class NewSubscriptionTask extends SubscriptionTask
{
......@@ -33,7 +35,10 @@ public class NewSubscriptionTask extends SubscriptionTask
if (node.getAffiliate(getOwner()) == null)
{
node.addNoneAffiliation(getOwner());
// add the missing 'none' affiliation
NodeAffiliate affiliate = new NodeAffiliate(node, getOwner());
affiliate.setAffiliation(NodeAffiliate.Affiliation.none);
node.addAffiliate(affiliate);
}
node.addSubscription(getSubscription());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment