@Override
    public void run() {
        // Note: this implementation should apply changes in-memory state only. It explicitly needs not update
        // persisted data storage, as this can be expected to be done by the cluster node that issued this task.
        // Applying such changes in this task would, at best, needlessly require resources.
        log.debug("[TASK] New affiliation : {}", toString());

        final Optional<Node> optNode = getNodeIfLoaded();

        // This will only occur if a PEP service is not loaded on this particular cluster node. We can safely do nothing
        // in this case since any changes that might have been applied here will also have been applied to the database
        // by the cluster node where this task originated, meaning that those changes get loaded from the database when
        // the pubsub node is retrieved from the database in the future (OF-2077)
        if (optNode.isEmpty()) {
            return;
        }

        final Node node = optNode.get();

        // Create a new affiliate if the entity is not an affiliate yet.
        NodeAffiliate affiliate = node.getAffiliate(jid);
        if (affiliate == null) {
            // No existing affiliate: create a new one.
            affiliate = new NodeAffiliate(node, jid);
            node.addAffiliate(affiliate);
        }

        affiliate.setAffiliation(affiliation);
    }
The new affiliation with a pubsub node.

@return a pubsub node affiliation.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/cluster/AffiliationTask.java