当前位置: 首页>>代码示例>>Java>>正文


Java ClusterManager.fireMarkedAsSeniorClusterMember方法代码示例

本文整理汇总了Java中org.jivesoftware.openfire.cluster.ClusterManager.fireMarkedAsSeniorClusterMember方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterManager.fireMarkedAsSeniorClusterMember方法的具体用法?Java ClusterManager.fireMarkedAsSeniorClusterMember怎么用?Java ClusterManager.fireMarkedAsSeniorClusterMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.openfire.cluster.ClusterManager的用法示例。


在下文中一共展示了ClusterManager.fireMarkedAsSeniorClusterMember方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: joinCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
private synchronized void joinCluster() {
    if (!isDone()) { // already joined
        return;
    }
    // Trigger events
    ClusterManager.fireJoinedCluster(false);
    addEntryListener(C2SCache, new CacheListener(this, C2SCache.getName()));
    addEntryListener(anonymousC2SCache, new CacheListener(this, anonymousC2SCache.getName()));
    addEntryListener(S2SCache, new S2SCacheListener());
    addEntryListener(componentsCache, new ComponentCacheListener());

    addEntryListener(sessionInfoCache, new CacheListener(this, sessionInfoCache.getName()));
    addEntryListener(componentSessionsCache, new CacheListener(this, componentSessionsCache.getName()));
    addEntryListener(multiplexerSessionsCache, new CacheListener(this, multiplexerSessionsCache.getName()));
    addEntryListener(incomingServerSessionsCache, new CacheListener(this, incomingServerSessionsCache.getName()));

    addEntryListener(directedPresencesCache, new DirectedPresenceListener());

    // Simulate insert events of existing cache content
    simulateCacheInserts(C2SCache);
    simulateCacheInserts(anonymousC2SCache);
    simulateCacheInserts(S2SCache);
    simulateCacheInserts(componentsCache);
    simulateCacheInserts(sessionInfoCache);
    simulateCacheInserts(componentSessionsCache);
    simulateCacheInserts(multiplexerSessionsCache);
    simulateCacheInserts(incomingServerSessionsCache);
    simulateCacheInserts(directedPresencesCache);

    
    if (CacheFactory.isSeniorClusterMember()) {
        seniorClusterMember = true;
        ClusterManager.fireMarkedAsSeniorClusterMember();
    }
    logger.info("Joined cluster as node: " + cluster.getLocalMember().getUuid() + ". Senior Member: " +
            (CacheFactory.isSeniorClusterMember() ? "YES" : "NO"));
    done = false;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:39,代码来源:ClusterListener.java

示例2: memberRemoved

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void memberRemoved(MembershipEvent event) {
    byte[] nodeID = StringUtils.getBytes(event.getMember().getUuid());

    if (event.getMember().localMember()) {
        logger.info("Leaving cluster: " + nodeID);
        // This node may have realized that it got kicked out of the cluster
        leaveCluster();
    } else {
        // Trigger event that a node left the cluster
        ClusterManager.fireLeftCluster(nodeID);

        // Clean up directed presences sent from entities hosted in the leaving node to local entities
        // Clean up directed presences sent to entities hosted in the leaving node from local entities
        cleanupDirectedPresences(NodeID.getInstance(nodeID));

        if (!seniorClusterMember && CacheFactory.isSeniorClusterMember()) {
            seniorClusterMember = true;
            ClusterManager.fireMarkedAsSeniorClusterMember();
        }
        cleanupNode(NodeID.getInstance(nodeID));
        
        // Remove traces of directed presences sent from local entities to handlers that no longer exist.
        // At this point c2s sessions are gone from the routing table so we can identify expired sessions
        XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
    }
    // Delete nodeID instance (release from memory)
    NodeID.deleteInstance(nodeID);
    clusterNodesInfo.remove(event.getMember().getUuid()); 
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:30,代码来源:ClusterListener.java

示例3: memberJoined

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void memberJoined(MemberEvent memberEvent) {
    if (memberEvent.isLocal()) {
        done = false;
        // We left and re-joined the cluster
        Log.info("Rejoining cluster as node: " + new UID(CacheFactory.getClusterMemberID()) + ". Senior Member: " +
                (CacheFactory.isSeniorClusterMember() ? "YES" : "NO"));
        // Simulate insert events of existing cache content
        simuateCacheInserts(C2SCache);
        simuateCacheInserts(anonymousC2SCache);
        simuateCacheInserts(S2SCache);
        simuateCacheInserts(componentsCache);
        simuateCacheInserts(componentSessionsCache);
        simuateCacheInserts(multiplexerSessionsCache);
        simuateCacheInserts(incomingServerSessionsCache);
        simuateCacheInserts(directedPresencesCache);
        // Set the new ID of this cluster node
        XMPPServer.getInstance().setNodeID(NodeID.getInstance(CacheFactory.getClusterMemberID()));
        // Trigger events
        ClusterManager.fireJoinedCluster(true);
        if (CacheFactory.isSeniorClusterMember()) {
            seniorClusterMember = true;
            ClusterManager.fireMarkedAsSeniorClusterMember();
        }
    }
    else {
        nodePresences.put(NodeID.getInstance(memberEvent.getMember().getUid().toByteArray()),
                new ConcurrentHashMap<String, Collection<String>>());
        // Trigger event that a new node has joined the cluster
        ClusterManager.fireJoinedCluster(memberEvent.getMember().getUid().toByteArray(), true);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:32,代码来源:ClusterListener.java

示例4: joinCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
private synchronized void joinCluster() {
if (!isDone()) { // already joined
	return;
}
// Trigger events
      ClusterManager.fireJoinedCluster(false);
      addEntryListener(C2SCache, new CacheListener(this, C2SCache.getName()));
      addEntryListener(anonymousC2SCache, new CacheListener(this, anonymousC2SCache.getName()));
      addEntryListener(S2SCache, new CacheListener(this, S2SCache.getName()));
      addEntryListener(componentsCache, new ComponentCacheListener());

      addEntryListener(sessionInfoCache, new CacheListener(this, sessionInfoCache.getName()));
      addEntryListener(componentSessionsCache, new CacheListener(this, componentSessionsCache.getName()));
      addEntryListener(multiplexerSessionsCache, new CacheListener(this, multiplexerSessionsCache.getName()));
      addEntryListener(incomingServerSessionsCache, new CacheListener(this, incomingServerSessionsCache.getName()));

      addEntryListener(directedPresencesCache, new DirectedPresenceListener());

      // Simulate insert events of existing cache content
      simulateCacheInserts(C2SCache);
      simulateCacheInserts(anonymousC2SCache);
      simulateCacheInserts(S2SCache);
      simulateCacheInserts(componentsCache);
      simulateCacheInserts(sessionInfoCache);
      simulateCacheInserts(componentSessionsCache);
      simulateCacheInserts(multiplexerSessionsCache);
      simulateCacheInserts(incomingServerSessionsCache);
      simulateCacheInserts(directedPresencesCache);

      
      if (CacheFactory.isSeniorClusterMember()) {
          seniorClusterMember = true;
          ClusterManager.fireMarkedAsSeniorClusterMember();
      }
      logger.info("Joined cluster as node: " + cluster.getLocalMember().getUuid() + ". Senior Member: " +
              (CacheFactory.isSeniorClusterMember() ? "YES" : "NO"));
      done = false;
  }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:39,代码来源:ClusterListener.java

示例5: memberRemoved

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void memberRemoved(MembershipEvent event) {
       byte[] nodeID = StringUtils.getBytes(event.getMember().getUuid());

       if (event.getMember().localMember()) {
           logger.info("Leaving cluster: " + nodeID);
           // This node may have realized that it got kicked out of the cluster
           leaveCluster();
       } else {
           // Trigger event that a node left the cluster
           ClusterManager.fireLeftCluster(nodeID);

           // Clean up directed presences sent from entities hosted in the leaving node to local entities
           // Clean up directed presences sent to entities hosted in the leaving node from local entities
           cleanupDirectedPresences(NodeID.getInstance(nodeID));

           if (!seniorClusterMember && CacheFactory.isSeniorClusterMember()) {
               seniorClusterMember = true;
               ClusterManager.fireMarkedAsSeniorClusterMember();
           }

           if (CacheFactory.isSeniorClusterMember()) {
               cleanupNode(NodeID.getInstance(nodeID));
           }
           // Remove traces of directed presences sent from local entities to handlers that no longer exist.
           // At this point c2s sessions are gone from the routing table so we can identify expired sessions
           XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
       }
       // Delete nodeID instance (release from memory)
       NodeID.deleteInstance(nodeID);
       clusterNodesInfo.remove(event.getMember().getUuid()); 
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:ClusterListener.java

示例6: startCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public boolean startCluster() {
    ClassLoader oldLoader = null;
    // Set that we are starting up the cluster service
    state = State.starting;
    try {
        // Store previous class loader (in case we change it)
        oldLoader = Thread.currentThread().getContextClassLoader();
        // See if the license allows for additional cluster members.
        int allowedMembers = getMaxClusterNodes();
        // If more than 1 cluster member is allowed...
        if (allowedMembers > 1) {
            ClassLoader loader = new ClusterClassLoader();
            Thread.currentThread().setContextClassLoader(loader);
            cluster = com.tangosol.net.CacheFactory.ensureCluster();
            // Make sure Coherence uses the correct class loader.
            cluster.setContextClassLoader(loader);
            int memberCount = cluster.getMemberSet().size();
            // See if adding this cluster bumps us over the allowed
            // number. If so, shut down the cluster and use local cache.
            if (memberCount > allowedMembers) {
                com.tangosol.net.CacheFactory.shutdown();
                cluster = null;
                Log.error("Error joining clustered cache: your "
                        + "license only allows for " + allowedMembers +
                        " cluster nodes. Using local cache instead.");
            }
            else {
                com.tangosol.net.CacheFactory.getCache("opt-$cacheStats");
                taskService = com.tangosol.net.CacheFactory.getInvocationService("OpenFire Cluster Service");

                // Update the running state of the cluster
                state = cluster != null ? State.started : State.stopped;

                Member localMember = cluster.getLocalMember();
                Member seniorMember = cluster.getOldestMember();

                // Set the ID of this cluster node
                XMPPServer.getInstance().setNodeID(NodeID.getInstance(getClusterMemberID()));
                // Trigger cluster events
                ClusterManager.fireJoinedCluster(false);
                // CacheFactory is now using clustered caches. We can add our listeners.
                clusterListener = new ClusterListener();
                taskService.addMemberListener(clusterListener);

                if (isSeniorClusterMember()) {
                    ClusterManager.fireMarkedAsSeniorClusterMember();
                }
                Log.info("Joining cluster as node: " + localMember.getUid() + ". Senior Member: " +
                        (localMember == seniorMember ? "YES" : "NO"));
            }
        }
        // Only 1 cluster member is allowed, so use local cache.
        else {
            Log.error("Error joining clustered cache: your " +
                    "license only allows for " + allowedMembers +
                    " cluster nodes. Using local cache instead.");
        }

        return cluster != null;
    }
    catch (Exception e) {
        Log.error("Unable to start clustering - continuing in local mode", e);
    }
    finally {
        if (oldLoader != null) {
            // Restore previous class loader
            Thread.currentThread().setContextClassLoader(oldLoader);
        }
    }
    // For some reason the cluster was not started so update the status
    state = State.stopped;
    return false;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:74,代码来源:CoherenceClusteredCacheFactory.java

示例7: memberLeft

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void memberLeft(MemberEvent memberEvent) {
    byte[] nodeID = memberEvent.getMember().getUid().toByteArray();

    if (memberEvent.isLocal()) {
        Log.info("Leaving cluster");
        // This node may have realized that it got kicked out of the cluster
        seniorClusterMember = false;
        // Clean up all traces. This will set all remote sessions as unavailable
        List<NodeID> nodeIDs = new ArrayList<NodeID>(nodeSessions.keySet());

        // Revert cluster caches to local caches
        CacheFactory.leftCluster();
        // Trigger event. Wait until the listeners have processed the event. Caches will be populated
        // again with local content.
        ClusterManager.fireLeftCluster();

        if (!XMPPServer.getInstance().isShuttingDown()) {
            for (NodeID key : nodeIDs) {
                // Clean up directed presences sent from entites hosted in the leaving node to local entities
                // Clean up directed presences sent to entites hosted in the leaving node from local entities
                cleanupDirectedPresences(key);
                // Clean up no longer valid sessions
                cleanupPresences(key);
            }
            // Remove traces of directed presences sent from local entities to handlers that no longer exist
            // At this point c2s sessions are gone from the routing table so we can identify expired sessions
            XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
        }

        // Mark that we are done with the clean up
        done = true;
    }
    else {
        // Trigger event that a node left the cluster
        ClusterManager.fireLeftCluster(nodeID);

        // Clean up directed presences sent from entites hosted in the leaving node to local entities
        // Clean up directed presences sent to entites hosted in the leaving node from local entities
        cleanupDirectedPresences(NodeID.getInstance(nodeID));

        if (!seniorClusterMember && CacheFactory.isSeniorClusterMember()) {
            seniorClusterMember = true;
            ClusterManager.fireMarkedAsSeniorClusterMember();
        }

        if (CacheFactory.isSeniorClusterMember()) {
            cleanupNode(NodeID.getInstance(nodeID));
        }
        // Remove traces of directed presences sent from local entities to handlers that no longer exist.
        // At this point c2s sessions are gone from the routing table so we can identify expired sessions
        XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
    }
    // Delete nodeID instance (release from memory)
    NodeID.deleteInstance(nodeID);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:56,代码来源:ClusterListener.java

示例8: startCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public boolean startCluster() {
    ClassLoader oldLoader = null;
    // Set that we are starting up the cluster service
    state = State.starting;
    // Set the serialization strategy to use for transmitting objects between node clusters
    serializationStrategy = ExternalizableUtil.getInstance().getStrategy();
    ExternalizableUtil.getInstance().setStrategy(new CoherenceExternalizableUtil());
    // Set session locator to use when in a cluster
    XMPPServer.getInstance().setRemoteSessionLocator(new RemoteSessionLocator());
    // Set packet router to use to deliver packets to remote cluster nodes
    XMPPServer.getInstance().getRoutingTable().setRemotePacketRouter(new CoherencePacketRouter());
    // Initialize the Coherence cluster configuration
    try {
        // Store previous class loader (in case we change it)
        oldLoader = Thread.currentThread().getContextClassLoader();
        // See if the license allows for additional cluster members.
        int allowedMembers = getMaxClusterNodes();
        // If more than 1 cluster member is allowed...
        if (allowedMembers > 1) {
            ClassLoader loader = new ClusterClassLoader();
            Thread.currentThread().setContextClassLoader(loader);
            cluster = com.tangosol.net.CacheFactory.ensureCluster();
            // Make sure Coherence uses the correct class loader.
            cluster.setContextClassLoader(loader);
            int memberCount = cluster.getMemberSet().size();
            // See if adding this cluster bumps us over the allowed
            // number. If so, shut down the cluster and use local cache.
            if (memberCount > allowedMembers) {
                com.tangosol.net.CacheFactory.shutdown();
                cluster = null;
                Log.error("Error joining clustered cache: your "
                        + "license only allows for " + allowedMembers +
                        " cluster nodes. Using local cache instead.");
            }
            else {
                com.tangosol.net.CacheFactory.getCache("opt-$cacheStats");
                taskService = (InvocationService) com.tangosol.net.CacheFactory.getService("OpenFire Cluster Service");

                // Update the running state of the cluster
                state = cluster != null ? State.started : State.stopped;

                Member localMember = cluster.getLocalMember();
                Member seniorMember = cluster.getOldestMember();

                // Set the ID of this cluster node
                XMPPServer.getInstance().setNodeID(NodeID.getInstance(getClusterMemberID()));
                // Trigger cluster events
                ClusterManager.fireJoinedCluster(false);
                // CacheFactory is now using clustered caches. We can add our listeners.
                clusterListener = new ClusterListener();
                taskService.addMemberListener(clusterListener);

                if (isSeniorClusterMember()) {
                    ClusterManager.fireMarkedAsSeniorClusterMember();
                }
                Log.info("Joining cluster as node: " + localMember.getUid() + ". Senior Member: " +
                        (localMember == seniorMember ? "YES" : "NO"));
            }
        }
        // Only 1 cluster member is allowed, so use local cache.
        else {
            Log.error("Error joining clustered cache: your " +
                    "license only allows for " + allowedMembers +
                    " cluster nodes. Using local cache instead.");
        }

        return cluster != null;
    }
    catch (Exception e) {
        Log.error("Unable to start clustering - continuing in local mode", e);
    }
    finally {
        if (oldLoader != null) {
            // Restore previous class loader
            Thread.currentThread().setContextClassLoader(oldLoader);
        }
    }
    // For some reason the cluster was not started so update the status
    state = State.stopped;
    return false;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:82,代码来源:ClusteredCacheFactory.java

示例9: memberLeft

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void memberLeft(MemberEvent memberEvent) {
    byte[] nodeID = memberEvent.getMember().getUid().toByteArray();

    if (memberEvent.isLocal()) {
        Log.info("Leaving cluster");
        // This node may have realized that it got kicked out of the cluster
        seniorClusterMember = false;
        // Clean up all traces. This will set all remote sessions as unavailable
        List<NodeID> nodeIDs = new ArrayList<NodeID>(nodeSessions.keySet());

        // Trigger event. Wait until the listeners have processed the event. Caches will be populated
        // again with local content.
        ClusterManager.fireLeftCluster();

        if (!XMPPServer.getInstance().isShuttingDown()) {
            for (NodeID key : nodeIDs) {
                // Clean up directed presences sent from entites hosted in the leaving node to local entities
                // Clean up directed presences sent to entites hosted in the leaving node from local entities
                cleanupDirectedPresences(key);
                // Clean up no longer valid sessions
                cleanupPresences(key);
            }
            // Remove traces of directed presences sent from local entities to handlers that no longer exist
            // At this point c2s sessions are gone from the routing table so we can identify expired sessions
            XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
        }

        // Mark that we are done with the clean up
        done = true;
    }
    else {
        // Trigger event that a node left the cluster
        ClusterManager.fireLeftCluster(nodeID);

        // Clean up directed presences sent from entites hosted in the leaving node to local entities
        // Clean up directed presences sent to entites hosted in the leaving node from local entities
        cleanupDirectedPresences(NodeID.getInstance(nodeID));

        if (!seniorClusterMember && CacheFactory.isSeniorClusterMember()) {
            seniorClusterMember = true;
            ClusterManager.fireMarkedAsSeniorClusterMember();
        }

        if (CacheFactory.isSeniorClusterMember()) {
            cleanupNode(NodeID.getInstance(nodeID));
        }
        // Remove traces of directed presences sent from local entities to handlers that no longer exist.
        // At this point c2s sessions are gone from the routing table so we can identify expired sessions
        XMPPServer.getInstance().getPresenceUpdateHandler().removedExpiredPresences();
    }
    // Delete nodeID instance (release from memory)
    NodeID.deleteInstance(nodeID);
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:54,代码来源:ClusterListener.java


注:本文中的org.jivesoftware.openfire.cluster.ClusterManager.fireMarkedAsSeniorClusterMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。