PresenceUpdateHandler.java 27.8 KB
Newer Older
1 2 3 4 5
/**
 * $RCSfile: PresenceUpdateHandler.java,v $
 * $Revision: 3125 $
 * $Date: 2005-11-30 15:14:14 -0300 (Wed, 30 Nov 2005) $
 *
6
 * Copyright (C) 2005-2008 Jive Software. All rights reserved.
7
 *
8 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
19 20
 */

21
package org.jivesoftware.openfire.handler;
22

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.locks.Lock;

import org.jivesoftware.openfire.ChannelHandler;
import org.jivesoftware.openfire.OfflineMessage;
import org.jivesoftware.openfire.OfflineMessageStore;
import org.jivesoftware.openfire.PacketDeliverer;
import org.jivesoftware.openfire.PacketException;
import org.jivesoftware.openfire.PresenceManager;
import org.jivesoftware.openfire.RoutingTable;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
39
import org.jivesoftware.openfire.auth.UnauthorizedException;
40 41
import org.jivesoftware.openfire.cluster.ClusterEventListener;
import org.jivesoftware.openfire.cluster.ClusterManager;
42 43 44 45
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.roster.Roster;
import org.jivesoftware.openfire.roster.RosterItem;
import org.jivesoftware.openfire.roster.RosterManager;
46
import org.jivesoftware.openfire.session.ClientSession;
47
import org.jivesoftware.openfire.session.LocalSession;
48 49 50
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
51
import org.jivesoftware.util.LocaleUtils;
52 53
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory;
54 55 56 57 58 59 60
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.Presence;
61 62 63 64

/**
 * Implements the presence protocol. Clients use this protocol to
 * update presence and roster information.
65
 * <p>
66 67 68 69
 * The handler must properly detect the presence type, update the user's roster,
 * and inform presence subscribers of the session's updated presence
 * status. Presence serves many purposes in Jabber so this handler will
 * likely be the most complex of all handlers in the server.
70 71
 * </p>
 * <p>
72
 * There are four basic types of presence updates:
73
 * </p>
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
 * <ul>
 * <li>Simple presence updates - addressed to the server (or to address), these updates
 * are properly addressed by the server, and multicast to
 * interested subscribers on the user's roster. An empty, missing,
 * or "unavailable" type attribute indicates a simple update (there
 * is no "available" type although it should be accepted by the server.
 * <li>Directed presence updates - addressed to particular jabber entities,
 * these presence updates are properly addressed and directly delivered
 * to the entity without broadcast to roster subscribers. Any update type
 * is possible except those reserved for subscription requests.
 * <li>Subscription requests - these updates request presence subscription
 * status changes. Such requests always affect the roster.  The server must:
 * <ul>
 * <li>update the roster with the proper subscriber info
 * <li>push the roster changes to the user
 * <li>forward the update to the correct parties.
 * </ul>
 * The valid types include "subscribe", "subscribed", "unsubscribed",
 * and "unsubscribe".
 * <li>XMPPServer probes - Provides a mechanism for servers to query the presence
 * status of users on another server. This allows users to immediately
 * know the presence status of users when they come online rather than way
 * for a presence update broadcast from the other server or tracking them
 * as they are received.  Requires S2S capabilities.
 * </ul>
 *
 * @author Iain Shigeoka
 */
102
public class PresenceUpdateHandler extends BasicModule implements ChannelHandler, ClusterEventListener {
103

104 105
	private static final Logger Log = LoggerFactory.getLogger(PresenceUpdateHandler.class);

106
    public static final String PRESENCE_CACHE_NAME = "Directed Presences";
107 108 109 110 111 112 113 114 115 116 117 118 119 120

    /**
     * Keeps track of entities that sent directed presences to other entities. In this map
     * we keep track of every directed presence no matter if the recipient was hosted in
     * this JVM or another cluster node.
     *
     * Key: sender, Value: list of DirectedPresences
     */
    private Cache<String, Collection<DirectedPresence>> directedPresencesCache;
    /**
     * Same as the directedPresencesCache but only keeps directed presences sent from
     * users connected to this JVM.
     */
    private Map<String, Collection<DirectedPresence>> localDirectedPresences;
121

Gaston Dombiak's avatar
Gaston Dombiak committed
122
    private RoutingTable routingTable;
123 124 125 126 127 128
    private RosterManager rosterManager;
    private XMPPServer localServer;
    private PresenceManager presenceManager;
    private PacketDeliverer deliverer;
    private OfflineMessageStore messageStore;
    private SessionManager sessionManager;
129
    private UserManager userManager;
130 131 132

    public PresenceUpdateHandler() {
        super("Presence update handler");
133
        localDirectedPresences = new ConcurrentHashMap<String, Collection<DirectedPresence>>();
134 135
    }

136
    public void process(Packet packet) throws UnauthorizedException, PacketException {
137
        process((Presence) packet, sessionManager.getSession(packet.getFrom()));
138 139
    }

140
    private void process(Presence presence, ClientSession session) throws UnauthorizedException, PacketException {
141 142 143 144
        try {
            Presence.Type type = presence.getType();
            // Available
            if (type == null) {
145 146 147 148
                if (session != null && session.getStatus() == Session.STATUS_CLOSED) {
                    Log.warn("Rejected available presence: " + presence + " - " + session);
                    return;
                }
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
                broadcastUpdate(presence.createCopy());
                if (session != null) {
                    session.setPresence(presence);
                    if (!session.isInitialized()) {
                        initSession(session);
                        session.setInitialized(true);
                    }
                }
                // Notify the presence manager that the user is now available. The manager may
                // remove the last presence status sent by the user when he went offline.
                presenceManager.userAvailable(presence);
            }
            else if (Presence.Type.unavailable == type) {
                broadcastUpdate(presence.createCopy());
                broadcastUnavailableForDirectedPresences(presence);
                if (session != null) {
                    session.setPresence(presence);
                }
                // Notify the presence manager that the user is now unavailable. The manager may
                // save the last presence status sent by the user and keep track when the user
                // went offline.
                presenceManager.userUnavailable(presence);
            }
            else {
                presence = presence.createCopy();
                if (session != null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
175
                    presence.setFrom(new JID(null, session.getServerName(), null, true));
176 177 178 179 180 181 182 183 184 185 186 187 188
                    presence.setTo(session.getAddress());
                }
                else {
                    JID sender = presence.getFrom();
                    presence.setFrom(presence.getTo());
                    presence.setTo(sender);
                }
                presence.setError(PacketError.Condition.bad_request);
                deliverer.deliver(presence);
            }

        }
        catch (Exception e) {
189
            Log.error(LocaleUtils.getLocalizedString("admin.error") + ". Triggered by packet: " + presence, e);
190 191 192 193 194 195 196
        }
    }

    /**
     * Handle presence updates that affect roster subscriptions.
     *
     * @param presence The presence presence to handle
197
     * @throws PacketException if the packet is null or the packet could not be routed.
198 199 200 201 202 203 204
     */
    public void process(Presence presence) throws PacketException {
        try {
            process((Packet)presence);
        }
        catch (UnauthorizedException e) {
            try {
205
                LocalSession session = (LocalSession) sessionManager.getSession(presence.getFrom());
206 207
                presence = presence.createCopy();
                if (session != null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
208
                    presence.setFrom(new JID(null, session.getServerName(), null, true));
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
                    presence.setTo(session.getAddress());
                }
                else {
                    JID sender = presence.getFrom();
                    presence.setFrom(presence.getTo());
                    presence.setTo(sender);
                }
                presence.setError(PacketError.Condition.not_authorized);
                deliverer.deliver(presence);
            }
            catch (Exception err) {
                Log.error(LocaleUtils.getLocalizedString("admin.error"), err);
            }
        }
    }

    /**
     * A session that has transitioned to available status must be initialized.
     * This includes:
     * <ul>
     * <li>Sending all offline presence subscription requests</li>
     * <li>Sending offline messages</li>
     * </ul>
     *
     * @param session The session being updated
     * @throws UserNotFoundException If the user being updated does not exist
     */
236
    private void initSession(ClientSession session) throws UserNotFoundException {
237 238

        // Only user sessions need to be authenticated
239
        if (userManager.isRegisteredUser(session.getAddress().getNode())) {
240
            String username = session.getAddress().getNode();
241 242 243 244 245 246

            // Send pending subscription requests to user if roster service is enabled
            if (RosterManager.isRosterServiceEnabled()) {
                Roster roster = rosterManager.getRoster(username);
                for (RosterItem item : roster.getRosterItems()) {
                    if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
247
                        session.process(createSubscribePresence(item.getJid(),
248
                                session.getAddress().asBareJID(), true));
249 250
                    } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                        session.process(createSubscribePresence(item.getJid(),
251
                                session.getAddress().asBareJID(), false));
252 253 254 255 256
                    }
                    if (item.getSubStatus() == RosterItem.SUB_TO
                            || item.getSubStatus() == RosterItem.SUB_BOTH) {
                        presenceManager.probePresence(session.getAddress(), item.getJid());
                    }
257 258 259 260 261 262 263 264 265 266 267 268
                }
            }
            if (session.canFloodOfflineMessages()) {
                // deliver offline messages if any
                Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
                for (Message message : messages) {
                    session.process(message);
                }
            }
        }
    }

269
    public Presence createSubscribePresence(JID senderAddress, JID targetJID, boolean isSubscribe) {
270 271
        Presence presence = new Presence();
        presence.setFrom(senderAddress);
272
        presence.setTo(targetJID);
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
        if (isSubscribe) {
            presence.setType(Presence.Type.subscribe);
        }
        else {
            presence.setType(Presence.Type.unsubscribe);
        }
        return presence;
    }

    /**
     * Broadcast the given update to all subscribers. We need to:
     * <ul>
     * <li>Query the roster table for subscribers</li>
     * <li>Iterate through the list and send the update to each subscriber</li>
     * </ul>
     * <p/>
     * Is there a safe way to cache the query results while maintaining
     * integrity with roster changes?
     *
     * @param update The update to broadcast
     */
294
    private void broadcastUpdate(Presence update) {
295 296 297 298
        if (update.getFrom() == null) {
            return;
        }
        if (localServer.isLocal(update.getFrom())) {
299 300 301 302
            // Do nothing if roster service is disabled
            if (!RosterManager.isRosterServiceEnabled()) {
                return;
            }
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
            // Local updates can simply run through the roster of the local user
            String name = update.getFrom().getNode();
            try {
                if (name != null && !"".equals(name)) {
                    Roster roster = rosterManager.getRoster(name);
                    roster.broadcastPresence(update);
                }
            }
            catch (UserNotFoundException e) {
                Log.warn("Presence being sent from unknown user " + name, e);
            }
            catch (PacketException e) {
                Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
            }
        }
        else {
            // Foreign updates will do a reverse lookup of entries in rosters
            // on the server
            Log.warn("Presence requested from server "
322
                    + localServer.getServerInfo().getXMPPDomain()
323 324 325 326 327 328 329 330 331 332 333
                    + " by unknown user: " + update.getFrom());
        }
    }

    /**
     * Notification method sent to this handler when a user has sent a directed
     * presence to an entity. If the sender of the presence is local (to this server)
     * and the target entity does not belong to the user's roster then update the
     * registry of sent directed presences by the user.
     *
     * @param update  the directed Presence sent by the user to an entity.
Gaston Dombiak's avatar
Gaston Dombiak committed
334 335
     * @param handlerJID the JID of the handler that will receive/handle/process the sent packet.
     * @param jid     the receipient specified in the packet to handle.
336
     */
Gaston Dombiak's avatar
Gaston Dombiak committed
337
    public void directedPresenceSent(Presence update, JID handlerJID, String jid) {
338 339 340 341 342 343 344
        if (update.getFrom() == null) {
            return;
        }
        if (localServer.isLocal(update.getFrom())) {
            boolean keepTrack = false;
            String name = update.getFrom().getNode();
            if (name != null && !"".equals(name)) {
345 346 347 348 349
                // Keep track of all directed presences if roster service is disabled
                if (!RosterManager.isRosterServiceEnabled()) {
                    keepTrack = true;
                }
                else {
350
                    try {
351 352 353 354 355 356 357 358
                        Roster roster = rosterManager.getRoster(name);
                        // If the directed presence was sent to an entity that is not in the user's
                        // roster, keep a registry of this so that when the user goes offline we
                        // will be able to send the unavailable presence to the entity
                        RosterItem rosterItem = null;
                        try {
                            rosterItem = roster.getRosterItem(update.getTo());
                        }
359 360 361
                        catch (UserNotFoundException e) {
                            // Ignore
                        }
362 363 364 365 366
                        if (rosterItem == null ||
                                RosterItem.SUB_NONE == rosterItem.getSubStatus() ||
                                RosterItem.SUB_TO == rosterItem.getSubStatus()) {
                            keepTrack = true;
                        }
367
                    }
368 369 370 371 372
                    catch (UserNotFoundException e) {
                        Log.warn("Presence being sent from unknown user " + name, e);
                    }
                    catch (PacketException e) {
                        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
373 374 375 376 377 378 379 380
                    }
                }
            }
            else if (update.getFrom().getResource() != null){
                // Keep always track of anonymous users directed presences
                keepTrack = true;
            }
            if (keepTrack) {
Gaston Dombiak's avatar
Gaston Dombiak committed
381
                String sender = update.getFrom().toString();
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
                Lock lock = CacheFactory.getLock(sender, directedPresencesCache);
                try {
                    lock.lock();
                    Collection<DirectedPresence> directedPresences = directedPresencesCache.get(sender);
                    if (Presence.Type.unavailable.equals(update.getType())) {
                        if (directedPresences != null) {
                            // It's a directed unavailable presence
                            if (routingTable.hasClientRoute(handlerJID)) {
                                // Client sessions will receive only presences to the same JID (the
                                // address of the session) so remove the handler from the map
                                for (DirectedPresence directedPresence : directedPresences) {
                                    if (directedPresence.getHandler().equals(handlerJID)) {
                                        directedPresences.remove(directedPresence);
                                        break;
                                    }
397
                                }
Gaston Dombiak's avatar
Gaston Dombiak committed
398
                            }
399 400 401 402 403 404 405 406 407 408 409
                            else {
                                // A service may receive presences for many JIDs so in this case we
                                // just need to remove the jid that has received a directed
                                // unavailable presence
                                for (DirectedPresence directedPresence : directedPresences) {
                                    if (directedPresence.getHandler().equals(handlerJID)) {
                                        directedPresence.removeReceiver(jid);
                                        if (directedPresence.isEmpty()) {
                                            directedPresences.remove(directedPresence);
                                        }
                                        break;
Gaston Dombiak's avatar
Gaston Dombiak committed
410
                                    }
411 412
                                }
                            }
413 414 415 416 417 418 419 420 421 422
                            if (directedPresences.isEmpty()) {
                                // Remove the user from the registry since the list of directed
                                // presences is empty
                                directedPresencesCache.remove(sender);
                                localDirectedPresences.remove(sender);
                            }
                            else {
                                directedPresencesCache.put(sender, directedPresences);
                                localDirectedPresences.put(sender, directedPresences);
                            }
423
                        }
424 425 426 427 428 429 430 431
                    }
                    else {
                        if (directedPresences == null) {
                            // We are using a set to avoid duplicate jids in case the user
                            // sends several directed presences to the same handler. The Map also
                            // ensures that if the user sends several presences to the same handler
                            // we will have only one entry in the Map
                            directedPresences = new ConcurrentLinkedQueue<DirectedPresence>();
432
                        }
433 434 435 436 437 438 439 440 441
                        // Add the handler to the list of handler that processed the directed
                        // presence sent by the user. This handler will be used to send
                        // the unavailable presence when the user goes offline
                        DirectedPresence affectedDirectedPresence = null;
                        for (DirectedPresence directedPresence : directedPresences) {
                            if (directedPresence.getHandler().equals(handlerJID)) {
                                affectedDirectedPresence = directedPresence;
                                break;
                            }
442
                        }
443 444 445 446

                        if (affectedDirectedPresence == null) {
                            affectedDirectedPresence = new DirectedPresence(handlerJID);
                            directedPresences.add(affectedDirectedPresence);
447
                        }
448
                        affectedDirectedPresence.addReceiver(jid);
449

450 451
                        directedPresencesCache.put(sender, directedPresences);
                        localDirectedPresences.put(sender, directedPresences);
452
                    }
453 454
                } finally {
                    lock.unlock();
455 456 457 458 459 460 461 462 463 464 465 466
                }
            }
        }
    }

    /**
     * Sends an unavailable presence to the entities that received a directed (available) presence
     * by the user that is now going offline.
     *
     * @param update the unavailable presence sent by the user.
     */
    private void broadcastUnavailableForDirectedPresences(Presence update) {
467 468
        JID from = update.getFrom();
        if (from == null) {
469 470
            return;
        }
471
        if (localServer.isLocal(from)) {
472
            // Remove the registry of directed presences of this user
473 474 475 476 477 478 479 480 481 482
        	Collection<DirectedPresence> directedPresences = null;
        	
        	Lock lock = CacheFactory.getLock(from.toString(), directedPresencesCache);
        	try {
        		lock.lock();
        		directedPresences = directedPresencesCache.remove(from.toString());
        	} finally {
        		lock.unlock();
        	}
            
483
            if (directedPresences != null) {
484
                // Iterate over all the entities that the user sent a directed presence
485 486
                for (DirectedPresence directedPresence : directedPresences) {
                    for (String receiver : directedPresence.getReceivers()) {
487
                        Presence presence = update.createCopy();
488
                        presence.setTo(receiver);
489
                        localServer.getPresenceRouter().route(presence);
490 491
                    }
                }
492
                localDirectedPresences.remove(from.toString());
493 494 495 496
            }
        }
    }

497 498 499 500 501
    public boolean hasDirectPresence(JID ownerJID, JID recipientJID) {
        if (recipientJID == null) {
            return false;
        }
        Collection<DirectedPresence> directedPresences = directedPresencesCache.get(ownerJID.toString());
502
        if (directedPresences != null) {
503
            String recipient = recipientJID.toBareJID();
504 505 506
            for (DirectedPresence directedPresence : directedPresences) {
                for (String receiver : directedPresence.getReceivers()) {
                    if (receiver.contains(recipient)) {
507 508 509 510 511 512 513 514
                        return true;
                    }
                }
            }
        }
        return false;
    }

515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
    /**
     * Removes directed presences sent to entities that are no longer available.
     */
    public void removedExpiredPresences() {
        Map<String, Collection<DirectedPresence>> copy =
                new HashMap<String, Collection<DirectedPresence>>(localDirectedPresences);
        for (Map.Entry<String, Collection<DirectedPresence>> entry : copy.entrySet()) {
            for (DirectedPresence directedPresence : entry.getValue()) {
                if (!routingTable.hasClientRoute(directedPresence.getHandler()) &&
                        !routingTable.hasComponentRoute(directedPresence.getHandler())) {
                    Collection<DirectedPresence> presences = localDirectedPresences.get(entry.getKey());
                    presences.remove(directedPresence);
                    if (presences.isEmpty()) {
                        localDirectedPresences.remove(entry.getKey());
                    }
                }
            }
        }
    }

535 536
    @Override
	public void initialize(XMPPServer server) {
537 538 539 540 541 542 543
        super.initialize(server);
        localServer = server;
        rosterManager = server.getRosterManager();
        presenceManager = server.getPresenceManager();
        deliverer = server.getPacketDeliverer();
        messageStore = server.getOfflineMessageStore();
        sessionManager = server.getSessionManager();
544
        userManager = server.getUserManager();
Gaston Dombiak's avatar
Gaston Dombiak committed
545
        routingTable = server.getRoutingTable();
546 547 548 549 550 551 552 553 554 555 556
        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);
    }

    public void joinedCluster() {
        // Populate directedPresencesCache with local content since when not in a cluster
        // we could still send directed presences to entities that when connected to a cluster
        // they will be replicated. An example would be MUC rooms.
        for (Map.Entry<String, Collection<DirectedPresence>> entry : localDirectedPresences.entrySet()) {
557 558 559 560 561
            if (entry.getValue().isEmpty()) {
                Log.warn("PresenceUpdateHandler - Skipping empty directed presences when joining cluster for sender: " +
                        entry.getKey());
                continue;
            }
562 563 564 565 566 567 568 569 570 571 572 573 574

        	// TODO perhaps we should not lock for every entry. Instead, lock it
			// once (using a LOCK_ALL global key), and handle iterations in
			// one go. We should first make sure that this doesn't lead to
			// deadlocks though! The tryLock() mechanism could be used to first
            // try one approach, but fall back on the other approach.
            Lock lock = CacheFactory.getLock(entry.getKey(), directedPresencesCache);
        	try {
        		lock.lock();
        		directedPresencesCache.put(entry.getKey(), entry.getValue());
        	} finally {
        		lock.unlock();
        	}
575
        }
576 577
    }

578 579 580 581 582 583 584 585
    public void joinedCluster(byte[] nodeID) {
        // Do nothing
    }

    public void leftCluster() {
        if (!XMPPServer.getInstance().isShuttingDown()) {
            // Populate directedPresencesCache with local content
            for (Map.Entry<String, Collection<DirectedPresence>> entry : localDirectedPresences.entrySet()) {
586 587 588 589 590
                if (entry.getValue().isEmpty()) {
                    Log.warn(
                            "PresenceUpdateHandler - Skipping empty directed presences when leaving cluster for sender: " +
                                    entry.getKey());
                    continue;
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
                }    

                
            	// TODO perhaps we should not lock for every entry. Instead, lock it
    			// once (using a LOCK_ALL global key), and handle iterations in
    			// one go. We should first make sure that this doesn't lead to
    			// deadlocks though! The tryLock() mechanism could be used to first
                // try one approach, but fall back on the other approach.
                Lock lock = CacheFactory.getLock(entry.getKey(), directedPresencesCache);
            	try {
            		lock.lock();
            		directedPresencesCache.put(entry.getKey(), entry.getValue());
            	} finally {
            		lock.unlock();
            	}
606 607 608 609 610 611 612 613 614 615 616
            }
        }
    }

    public void leftCluster(byte[] nodeID) {
        // Do nothing
    }

    public void markedAsSeniorClusterMember() {
        // Do nothing
    }
617
}