View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ehcache.distribution;
18  
19  import net.sf.ehcache.CacheException;
20  import net.sf.ehcache.Ehcache;
21  
22  import java.util.List;
23  
24  /***
25   * Provides a discovery service to locate {@link CachePeer} listener peers for a Cache.
26   * @author Greg Luck
27   * @version $Id: CacheManagerPeerProvider.html 13146 2011-08-01 17:12:39Z oletizi $
28   */
29  public interface CacheManagerPeerProvider {
30  
31      /***
32       * Register a new peer.
33       * @param nodeId Identifies a node in this replication scheme (ex: RMI URL)
34       */
35      void registerPeer(String nodeId);
36  
37      /***
38       * Unregisters a peer.
39       *
40       * @param nodeId Identifies a node in this replication scheme (ex: RMI URL)
41       */
42      void unregisterPeer(String nodeId);
43  
44      /***
45       * @return a list of {@link CachePeer} peers for the given cache, excluding the local peer.
46       */
47      List listRemoteCachePeers(Ehcache cache) throws CacheException;
48  
49      /***
50       * Notifies providers to initialise themselves.
51       * @throws CacheException
52       */
53      void init();
54  
55  
56      /***
57       * Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.
58       * @throws CacheException
59       */
60      void dispose() throws CacheException;
61  
62      /***
63       * Time for a cluster to form. This varies considerably, depending on the implementation.
64       * @return the time in ms, for a cluster to form
65       */
66      long getTimeForClusterToForm();
67  
68  
69      /***
70       * The replication scheme. Each peer provider has a scheme name, which can be used to specify
71       * the scheme for replication and bootstrap purposes. Each <code>CacheReplicator</code> should lookup
72       * the provider for its scheme type during replication. Similarly a <code>BootstrapCacheLoader</code>
73       * should also look up the provider for its scheme.
74       * <p/>
75       * @since 1.6 introduced to permit multiple distribution schemes to be used in the same CacheManager
76       * @return the well-known scheme name, which is determined by the replication provider author.
77       */
78      String getScheme();
79  
80  }