• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClusterManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: canExecute

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
protected boolean canExecute() {
  if(ClusterManager.isClusteringEnabled()) {
    LOGGER.debug("canExecute : clustering is enabled");
    try {
      if(lock != null) {
        boolean result = lock.tryLock();
        LOGGER.trace("canExecute : tryLockResult={}", result);
        return result;
      } else {
        LOGGER.debug("canExecute : lock has not been set, cannot execute task");
        return false;
      }
    } catch (Exception e) {
      LOGGER.error("canExecute : error trying to acquire distributed lock", e);
      return false;
    }
  } else {
    LOGGER.debug("canExecute : clustering is disabled return true");
    return true;
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:22,代码来源:MMXClusterableTask.java


示例2: execute

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Executes the requested task considering that this JVM may still be joining the cluster.
 * This means that events regarding rooms that were not loaded yet will be stored for later
 * processing. Once the JVM is done joining the cluster queued tasks will be processed.
 *
 * @param runnable the task to execute.
 */
protected void execute(Runnable runnable) {
    // Check if we are joining a cluster
    boolean clusterStarting = ClusterManager.isClusteringStarting();
    try {
        // Check that the room exists
        getRoom();
        // Room was found so now execute the task
        runnable.run();
    }
    catch (IllegalArgumentException e) {
        // Room not found so check if we are still joining the cluster
        if (clusterStarting) {
            // Queue task in case the cluster
            QueuedTasksManager.getInstance().addTask(this);
        }
        else {
            // Task failed since room was not found
            Log.error(e.getMessage(), e);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:MUCRoomTask.java


示例3: start

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Called when manager starts up, to initialize things.
 */
@Override
public void start() {
    super.start();

    loadServices();

    for (MultiUserChatService service : mucServices.values()) {
        registerMultiUserChatService(service);
    }

    // Add statistics
    addTotalRoomStats();
    addTotalOccupantsStats();
    addTotalConnectedUsers();
    addNumberIncomingMessages();
    addNumberOutgoingMessages();

    ClusterManager.addListener(this);
    UserEventDispatcher.addListener(this);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:MultiUserChatManager.java


示例4: stop

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Called when manager is stopped, to clean things up.
 */
@Override
public void stop() {
    super.stop();

    ClusterManager.removeListener(this);
    UserEventDispatcher.removeListener(this);

    // Remove the statistics.
    StatisticsManager.getInstance().removeStatistic(roomsStatKey);
    StatisticsManager.getInstance().removeStatistic(occupantsStatKey);
    StatisticsManager.getInstance().removeStatistic(usersStatKey);
    StatisticsManager.getInstance().removeStatistic(incomingStatKey);
    StatisticsManager.getInstance().removeStatistic(outgoingStatKey);

    for (MultiUserChatService service : mucServices.values()) {
        unregisterMultiUserChatService(service.getServiceName());
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:MultiUserChatManager.java


示例5: addSession

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Add a new session to be managed. The session has been authenticated and resource
 * binding has been done.
 *
 * @param session the session that was authenticated.
 */
public void addSession(LocalClientSession session) {
    // Add session to the routing table (routing table will know session is not available yet)
    routingTable.addClientRoute(session.getAddress(), session);
    // Remove the pre-Authenticated session but remember to use the temporary ID as the key
    localSessionManager.getPreAuthenticatedSessions().remove(session.getStreamID().toString());
    SessionEventDispatcher.EventType event = session.getAuthToken().isAnonymous() ?
            SessionEventDispatcher.EventType.anonymous_session_created :
            SessionEventDispatcher.EventType.session_created;
    // Fire session created event.
    SessionEventDispatcher.dispatchEvent(session, event);
    if (ClusterManager.isClusteringStarted()) {
        // Track information about the session and share it with other cluster nodes
        sessionInfoCache.put(session.getAddress().toString(), new ClientSessionInfo(session));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:SessionManager.java


示例6: initialize

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
@Override
public void initialize(XMPPServer server) {
    super.initialize(server);
    localServer = server;
    rosterManager = server.getRosterManager();
    presenceManager = server.getPresenceManager();
    deliverer = server.getPacketDeliverer();
    messageStore = server.getOfflineMessageStore();
    sessionManager = server.getSessionManager();
    userManager = server.getUserManager();
    routingTable = server.getRoutingTable();
    directedPresencesCache = CacheFactory.createCache(PRESENCE_CACHE_NAME);
    // TODO Add as route listener (to remove direct presences info for removed routes). Mainly for c2s sessions which is uncommon.
    // Listen to cluster events
    ClusterManager.addListener(this);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:PresenceUpdateHandler.java


示例7: leftCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
@Override
public void leftCluster(byte[] nodeID) {
    if (ClusterManager.isSeniorClusterMember()) {
        NodeID leftNode = NodeID.getInstance(nodeID);
        for (Map.Entry<String, ClusteredServerItem> entry : serverItems.entrySet()) {
            String jid = entry.getKey();
            Lock lock = CacheFactory.getLock(jid, serverItems);
            try {
                lock.lock();
                ClusteredServerItem item = entry.getValue();
                if (item.nodes.remove(leftNode)) {
                    // Update the cache with latest info
                    if (item.nodes.isEmpty()) {
                        serverItems.remove(jid);
                    }
                    else {
                        serverItems.put(jid, item);
                    }
                }
            }
            finally {
                lock.unlock();
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:IQDiscoItemsHandler.java


示例8: leftCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
@Override
public void leftCluster(byte[] nodeID) {
    if (ClusterManager.isSeniorClusterMember()) {
        NodeID leftNode = NodeID.getInstance(nodeID);
        // Remove server features added by node that is gone
        for (Map.Entry<String, Set<NodeID>> entry : serverFeatures.entrySet()) {
            String namespace = entry.getKey();
            Lock lock = CacheFactory.getLock(namespace, serverFeatures);
            try {
                lock.lock();
                Set<NodeID> nodeIDs = entry.getValue();
                if (nodeIDs.remove(leftNode)) {
                    if (nodeIDs.isEmpty()) {
                        serverFeatures.remove(namespace);
                    }
                    else {
                        serverFeatures.put(namespace, nodeIDs);
                    }
                }
            }
            finally {
                lock.unlock();
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:IQDiscoInfoHandler.java


示例9: getCurrentValue

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
public double[] getCurrentValue(String key) {
    if (ClusterManager.isSeniorClusterMember()) {
        return new double[] { engine.getDefinition(key)[0].getLastSample() };
    }
    else {
        try {
            if (RrdSqlBackend.exists(key)) {
                RrdDb db = new RrdDb(key, true);
                return new double[] { db.getLastDatasourceValues()[0] };
            }
        } catch (Exception e) {
            Log.error("Error retrieving last sample value for: " + key, e);
        }
        return new double[] { 0 };
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:DefaultStatsViewer.java


示例10: occupantLeft

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
public void occupantLeft(JID roomJID, JID user) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.leftGroupConversation(roomJID, user, new Date());
        // If there are no more occupants then consider the group conversarion over
        MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
        if (mucRoom != null &&  mucRoom.getOccupantsCount() == 0) {
            conversationManager.roomConversationEnded(roomJID, new Date());
        }
    }
    else {
        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.occupantLeft(roomJID, user, new Date()));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:GroupConversationInterceptor.java


示例11: getConversations

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Returns the set of active conversations.
 *
 * @return the active conversations.
 */
public Collection<Conversation> getConversations() {
    if (ClusterManager.isSeniorClusterMember()) {
        List<Conversation> conversationList = new ArrayList<Conversation>(conversations.values());
        // Sort the conversations by creation date.
        Collections.sort(conversationList, new Comparator<Conversation>() {
            public int compare(Conversation c1, Conversation c2) {
                return c1.getStartDate().compareTo(c2.getStartDate());
            }
        });
        return conversationList;
    } else {
        // Get this info from the senior cluster member when running in a cluster
        return (Collection<Conversation>) CacheFactory.doSynchronousClusterTask(new GetConversationsTask(), ClusterManager
                .getSeniorClusterMember().toByteArray());
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:ConversationManager.java


示例12: nicknameChanged

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
public void nicknameChanged(JID roomJID, JID user, String oldNickname, String newNickname) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        occupantLeft(roomJID, user);
        // Sleep 1 millisecond so that there is a delay between logging out and logging in
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            // Ignore
        }
        occupantJoined(roomJID, user, newNickname);
    }
    else {
        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.nicknameChanged(roomJID, user, newNickname, new Date()));
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:19,代码来源:GroupConversationInterceptor.java


示例13: initializeClustering

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
private void initializeClustering() {
    logger.info("All plugins have initialized; initializing clustering");
    // Check if another cluster is installed and stop loading this plugin if found
    File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
    File[] jars = pluginDir.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            String fileName = pathname.getName().toLowerCase();
            return (fileName.equalsIgnoreCase("enterprise.jar") || 
                    fileName.equalsIgnoreCase("coherence.jar"));
        }
    });
    if (jars.length > 0) {
        // Do not load this plugin if a conflicting implementation exists
        logger.warn("Conflicting clustering plugins found; remove Coherence and/or Enterprise jar files");
        throw new IllegalStateException("Clustering plugin configuration conflict (Coherence)");
    }
    ClusterManager.startup();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:HazelcastPlugin.java


示例14: start

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
    * Called when manager starts up, to initialize things.
    */
   @Override
public void start() {
       super.start();

       loadServices();

       for (MultiUserChatService service : mucServices.values()) {
           registerMultiUserChatService(service);
       }

       // Add statistics
       addTotalRoomStats();
       addTotalOccupantsStats();
       addTotalConnectedUsers();
       addNumberIncomingMessages();
       addNumberOutgoingMessages();

       ClusterManager.addListener(this);
       UserEventDispatcher.addListener(this);
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:24,代码来源:MultiUserChatManager.java


示例15: stop

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
    * Called when manager is stopped, to clean things up.
    */
   @Override
public void stop() {
       super.stop();

       ClusterManager.removeListener(this);
       UserEventDispatcher.removeListener(this);

       // Remove the statistics.
       StatisticsManager.getInstance().removeStatistic(roomsStatKey);
       StatisticsManager.getInstance().removeStatistic(occupantsStatKey);
       StatisticsManager.getInstance().removeStatistic(usersStatKey);
       StatisticsManager.getInstance().removeStatistic(incomingStatKey);
       StatisticsManager.getInstance().removeStatistic(outgoingStatKey);

       for (MultiUserChatService service : mucServices.values()) {
           unregisterMultiUserChatService(service.getServiceName());
       }
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:22,代码来源:MultiUserChatManager.java


示例16: addSession

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Add a new session to be managed. The session has been authenticated and resource
 * binding has been done.
 *
 * @param session the session that was authenticated.
 */
public void addSession(LocalClientSession session) {
    // Remove the pre-Authenticated session but remember to use the temporary ID as the key
    localSessionManager.getPreAuthenticatedSessions().remove(session.getStreamID().toString());
    // Add session to the routing table (routing table will know session is not available yet)
    routingTable.addClientRoute(session.getAddress(), session);
    SessionEventDispatcher.EventType event = session.getAuthToken().isAnonymous() ?
            SessionEventDispatcher.EventType.anonymous_session_created :
            SessionEventDispatcher.EventType.session_created;
    // Fire session created event.
    SessionEventDispatcher.dispatchEvent(session, event);
    if (ClusterManager.isClusteringStarted()) {
        // Track information about the session and share it with other cluster nodes
        sessionInfoCache.put(session.getAddress().toString(), new ClientSessionInfo(session));
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:22,代码来源:SessionManager.java


示例17: initialize

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
@Override
public void initialize(XMPPServer server) {
       super.initialize(server);
       localServer = server;
       rosterManager = server.getRosterManager();
       presenceManager = server.getPresenceManager();
       deliverer = server.getPacketDeliverer();
       messageStore = server.getOfflineMessageStore();
       sessionManager = server.getSessionManager();
       userManager = server.getUserManager();
       routingTable = server.getRoutingTable();
       directedPresencesCache = CacheFactory.createCache(PRESENCE_CACHE_NAME);
       // TODO Add as route listener (to remove direct presences info for removed routes). Mainly for c2s sessions which is uncommon.
       // Listen to cluster events
       ClusterManager.addListener(this);
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:17,代码来源:PresenceUpdateHandler.java


示例18: leftCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
public void leftCluster(byte[] nodeID) {
    if (ClusterManager.isSeniorClusterMember()) {
        NodeID leftNode = NodeID.getInstance(nodeID);
        for (Map.Entry<String, ClusteredServerItem> entry : serverItems.entrySet()) {
            String jid = entry.getKey();
            Lock lock = CacheFactory.getLock(jid, serverItems);
            try {
                lock.lock();
                ClusteredServerItem item = entry.getValue();
                if (item.nodes.remove(leftNode)) {
                    // Update the cache with latest info
                    if (item.nodes.isEmpty()) {
                        serverItems.remove(jid);
                    }
                    else {
                        serverItems.put(jid, item);
                    }
                }
            }
            finally {
                lock.unlock();
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:26,代码来源:IQDiscoItemsHandler.java


示例19: leftCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
public void leftCluster(byte[] nodeID) {
    if (ClusterManager.isSeniorClusterMember()) {
        NodeID leftNode = NodeID.getInstance(nodeID);
        // Remove server features added by node that is gone
        for (Map.Entry<String, Set<NodeID>> entry : serverFeatures.entrySet()) {
            String namespace = entry.getKey();
            Lock lock = CacheFactory.getLock(namespace, serverFeatures);
            try {
                lock.lock();
                Set<NodeID> nodeIDs = entry.getValue();
                if (nodeIDs.remove(leftNode)) {
                    if (nodeIDs.isEmpty()) {
                        serverFeatures.remove(namespace);
                    }
                    else {
                        serverFeatures.put(namespace, nodeIDs);
                    }
                }
            }
            finally {
                lock.unlock();
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:26,代码来源:IQDiscoInfoHandler.java


示例20: getConversations

import org.jivesoftware.openfire.cluster.ClusterManager; //导入依赖的package包/类
/**
 * Returns the set of active conversations.
 *
 * @return the active conversations.
 */
public Collection<Conversation> getConversations() {
    if (ClusterManager.isSeniorClusterMember()) {
        List<Conversation> conversationList = new ArrayList<Conversation>(conversations.values());
        // Sort the conversations by creation date.
        Collections.sort(conversationList, new Comparator<Conversation>() {
            public int compare(Conversation c1, Conversation c2) {
                return c1.getStartDate().compareTo(c2.getStartDate());
            }
        });
        return conversationList;
    }
    else {
        // Get this info from the senior cluster member when running in a cluster
        return (Collection<Conversation>) CacheFactory.doSynchronousClusterTask(new GetConversationsTask(),
                ClusterManager.getSeniorClusterMember().toByteArray());
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:ConversationManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntArrayList类代码示例发布时间:2022-05-22
下一篇:
Java AbstractTableViewer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap