org.infinispan.cacheviews
Class CacheViewsManagerImpl

java.lang.Object
  extended by org.infinispan.cacheviews.CacheViewsManagerImpl
All Implemented Interfaces:
CacheViewsManager

public class CacheViewsManagerImpl
extends Object
implements CacheViewsManager

CacheViewsManager implementation.

It uses CacheViewControlCommands to organize the installation of cache views in two phases.

There are three phases in installing a cache view:

  1. A node wants to start or stop the cache, sending a REQUEST_JOIN or a REQUEST_LEAVE. A node leaving the JGroups cluster is interpreted as a REQUEST_LEAVE for all its caches. The request will be broadcast to all the cluster members, as all the nodes need to stop sending requests to the leavers.
  2. For join requests, the cache views manager will wait for a short period of time to allow other members to join.
  3. The coordinator then sends a PREPARE_VIEW to all the nodes that have the cache started (or starting). Any node can veto the view by throwing an exception in this phase.
  4. The coordinator sends a COMMIT_VIEW to all the nodes that have the cache started.
  5. If a node threw an exception during PREPARE_VIEW, the coordinator will send a ROLLBACK_VIEW instead.
    After a configurable amount of time the coordinator may retry to install the view, but with a different view id (even if the members are the same; this makes it simpler to implement).

    Only the coordinator keeps the information about which nodes have requested to join, so when the coordinator changes the new coordinator will have to request state from all the members using the RECOVER_VIEW command. This also happens after a merge, even if the new coordinator was a coordinator in one of the partitions. For a full description of the view recovery algorithm see recoverViews()

    Since:
    5.1
    Author:
    Dan Berindei <dan@infinispan.org>

    Nested Class Summary
     class CacheViewsManagerImpl.ViewInstallationTask
              Executed on the coordinator to install a new view in the cluster.
     class CacheViewsManagerImpl.ViewListener
               
     class CacheViewsManagerImpl.ViewTriggerThread
              Executed on the coordinator to trigger the installation of new views.
     
    Field Summary
    static String DUMMY_CACHE_NAME_FOR_GLOBAL_COMMANDS
               
     
    Constructor Summary
    CacheViewsManagerImpl()
               
     
    Method Summary
     CacheView getCommittedView(String cacheName)
               
     Set<Address> getLeavers(String cacheName)
               
     CacheView getPendingView(String cacheName)
               
     void handleCommitView(String cacheName, int viewId)
               
     void handlePrepareView(String cacheName, CacheView pendingView, CacheView committedView)
               
     Map<String,CacheView> handleRecoverViews()
               
     void handleRequestJoin(Address sender, String cacheName)
              Handle a join request.
     void handleRequestLeave(Address sender, String cacheName)
               
     void handleRollbackView(String cacheName, int newViewId, int committedViewId)
               
     void init(CacheManagerNotifier cacheManagerNotifier, Transport transport, ExecutorService e, GlobalConfiguration globalConfiguration)
               
     boolean isRunning()
               
     void join(String cacheName, CacheViewListener listener)
              Start the cache.
     void leave(String cacheName)
              Stop the cache.
     void start()
               
     void stop()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    DUMMY_CACHE_NAME_FOR_GLOBAL_COMMANDS

    public static final String DUMMY_CACHE_NAME_FOR_GLOBAL_COMMANDS
    See Also:
    Constant Field Values
    Constructor Detail

    CacheViewsManagerImpl

    public CacheViewsManagerImpl()
    Method Detail

    init

    public void init(CacheManagerNotifier cacheManagerNotifier,
                     Transport transport,
                     ExecutorService e,
                     GlobalConfiguration globalConfiguration)

    start

    public void start()
               throws Exception
    Throws:
    Exception

    stop

    public void stop()

    getCommittedView

    public CacheView getCommittedView(String cacheName)
    Specified by:
    getCommittedView in interface CacheViewsManager
    Returns:
    The currently installed view for the given cache.

    getPendingView

    public CacheView getPendingView(String cacheName)
    Specified by:
    getPendingView in interface CacheViewsManager
    Returns:
    The pending view for the given cache.

    getLeavers

    public Set<Address> getLeavers(String cacheName)
    Specified by:
    getLeavers in interface CacheViewsManager
    Returns:
    The members which will (should) handle commands for a given cache.

    join

    public void join(String cacheName,
                     CacheViewListener listener)
              throws Exception
    Description copied from interface: CacheViewsManager
    Start the cache.

    Specified by:
    join in interface CacheViewsManager
    Throws:
    Exception

    leave

    public void leave(String cacheName)
    Description copied from interface: CacheViewsManager
    Stop the cache.

    Specified by:
    leave in interface CacheViewsManager

    handleRequestJoin

    public void handleRequestJoin(Address sender,
                                  String cacheName)
    Handle a join request. Even if this node is not the coordinator this method will still be called for local caches.

    Specified by:
    handleRequestJoin in interface CacheViewsManager

    handleRequestLeave

    public void handleRequestLeave(Address sender,
                                   String cacheName)
    Specified by:
    handleRequestLeave in interface CacheViewsManager

    handlePrepareView

    public void handlePrepareView(String cacheName,
                                  CacheView pendingView,
                                  CacheView committedView)
                           throws Exception
    Specified by:
    handlePrepareView in interface CacheViewsManager
    Throws:
    Exception

    handleCommitView

    public void handleCommitView(String cacheName,
                                 int viewId)
    Specified by:
    handleCommitView in interface CacheViewsManager

    handleRollbackView

    public void handleRollbackView(String cacheName,
                                   int newViewId,
                                   int committedViewId)
    Specified by:
    handleRollbackView in interface CacheViewsManager

    handleRecoverViews

    public Map<String,CacheView> handleRecoverViews()
    Specified by:
    handleRecoverViews in interface CacheViewsManager
    Returns:
    The last prepared view id for each cache that's running on this node.

    isRunning

    public boolean isRunning()

    -->

    Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.