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


Java ClusterManager.isSeniorClusterMember方法代码示例

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


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

示例1: 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:idwanglu2010,项目名称:openfire,代码行数:17,代码来源:DefaultStatsViewer.java

示例2: 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:coodeer,项目名称:g3server,代码行数:19,代码来源:GroupConversationInterceptor.java

示例3: 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:coodeer,项目名称:g3server,代码行数:17,代码来源:GroupConversationInterceptor.java

示例4: 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

示例5: 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:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:ConversationManager.java

示例6: 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:idwanglu2010,项目名称:openfire,代码行数:26,代码来源:IQDiscoInfoHandler.java

示例7: run

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
@Override
public void run() {
    if (ClusterManager.isClusteringStarted() && !ClusterManager.isSeniorClusterMember()) {
        // Do nothing if we are in a cluster and this JVM is not the senior cluster member
        return;
    }
    try {
        localMUCRoomManager.cleanupRooms(getCleanupDate());
    }
    catch (Throwable e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:MultiUserChatServiceImpl.java

示例8: run

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
@Override
public void run() {
          if (ClusterManager.isClusteringStarted() && !ClusterManager.isSeniorClusterMember()) {
              // Do nothing if we are in a cluster and this JVM is not the senior cluster member
              return;
          }
          try {
              cleanupRooms();
          }
          catch (Throwable e) {
              Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
          }
      }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:14,代码来源:MultiUserChatServiceImpl.java

示例9: roomDestroyed

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void roomDestroyed(JID roomJID) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.roomConversationEnded(roomJID, new Date());
    }
    else {
        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.roomDestroyed(roomJID, new Date()));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:GroupConversationInterceptor.java

示例10: occupantJoined

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void occupantJoined(JID roomJID, JID user, String nickname) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.joinedGroupConversation(roomJID, user, nickname, new Date());
    }
    else {
        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.occupantJoined(roomJID, user, nickname, new Date()));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:GroupConversationInterceptor.java

示例11: getConversationCount

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
/**
 * Returns the count of active conversations.
 *
 * @return the count of active conversations.
 */
public int getConversationCount() {
    if (ClusterManager.isSeniorClusterMember()) {
        return conversations.size();
    }
    return (Integer) CacheFactory.doSynchronousClusterTask(new GetConversationCountTask(),
            ClusterManager.getSeniorClusterMember().toByteArray());
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:13,代码来源:ConversationManager.java

示例12: messageReceived

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void messageReceived(JID roomJID, JID user, String nickname, Message message) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.processRoomMessage(roomJID, user, nickname, message.getBody(), message.toXML(), new Date());
    }
    else {
        boolean withBody = conversationManager.isRoomArchivingEnabled() && (
                conversationManager.getRoomsArchived().isEmpty() ||
                        conversationManager.getRoomsArchived().contains(roomJID.getNode()));

        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.roomMessageReceived(roomJID, user, nickname, withBody ? message.getBody() : null, message.toXML(), new Date()));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:GroupConversationInterceptor.java

示例13: messageReceived

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void messageReceived(JID roomJID, JID user, String nickname, Message message) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.processRoomMessage(roomJID, user, nickname, message.getBody(), new Date());
    }
    else {
        boolean withBody = conversationManager.isRoomArchivingEnabled() && (
                conversationManager.getRoomsArchived().isEmpty() ||
                        conversationManager.getRoomsArchived().contains(roomJID.getNode()));

        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.roomMessageReceived(roomJID, user, nickname, withBody ? message.getBody() : null, new Date()));
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:16,代码来源:GroupConversationInterceptor.java

示例14: getConversationCount

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
/**
 * Returns the count of active conversations.
 *
 * @return the count of active conversations.
 */
public int getConversationCount() {
    if (ClusterManager.isSeniorClusterMember()) {
        return conversations.size();
    }
    return (Integer) CacheFactory.doSynchronousClusterTask(new GetConversationCountTask(), ClusterManager.getSeniorClusterMember().toByteArray());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:ConversationManager.java

示例15: interceptPacket

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
        throws PacketRejectedException
{
    // Ignore any packets that haven't already been processed by interceptors.
    if (!processed) {
        return;
    }
    if (packet instanceof Message) {
        // Ignore any outgoing messages (we'll catch them when they're incoming).
        if (!incoming) {
            return;
        }
        Message message = (Message) packet;
        // Ignore any messages that don't have a body so that we skip events.
        // Note: XHTML messages should always include a body so we should be ok. It's
        // possible that we may need special XHTML filtering in the future, however.
        if (message.getBody() != null) {
            // Only process messages that are between two users, group chat rooms, or gateways.
            if (conversationManager.isConversation(message)) {
                // Process this event in the senior cluster member or local JVM when not in a cluster
                if (ClusterManager.isSeniorClusterMember()) {
                    conversationManager.processMessage(message.getFrom(), message.getTo(), message.getBody(), new Date());
                }
                else {
                    JID sender = message.getFrom();
                    JID receiver = message.getTo();
                    ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
                    eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
                            ConversationEvent.chatMessageReceived(sender, receiver,
                                    conversationManager.isMessageArchivingEnabled() ? message.getBody() : null,
                                    new Date()));
                }
            }
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:37,代码来源:ArchiveInterceptor.java


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