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.cluster;
18
19 import java.util.Collection;
20 import java.util.List;
21
22 /***
23 * Allows you to explore the Terracotta cluster nodes and register for events about the cluster.
24 *
25 * @author Geert Bevin, Abhishek Sanoujam
26 * @since 2.0
27 */
28 public interface CacheCluster {
29
30 /***
31 * Get scheme name for this cluster info.
32 *
33 * @return a scheme name for the cluster information.
34 * Currently <code>TERRACOTTA</code> is the only scheme supported.
35 */
36 ClusterScheme getScheme();
37
38 /***
39 * Retrieves the {@code ClusterNode} instance that corresponds to the current node.
40 *
41 * @return the {@code ClusterNode} instance that corresponds to the current node
42 */
43 ClusterNode getCurrentNode();
44
45 /***
46 * Waits until the current node has successfully joined the cluster.
47 *
48 * @return the {@code ClusterNode} instance that corresponds to the current node
49 */
50 ClusterNode waitUntilNodeJoinsCluster();
51
52 /***
53 * Get all the nodes in the cluster
54 *
55 * @return information on all the nodes in the cluster, including ID, hostname, and IP address.
56 */
57 Collection<ClusterNode> getNodes();
58
59 /***
60 * Find out if the current node is connected to the cluster or not
61 *
62 * @return true if cluster is online otherwise false
63 */
64 boolean isClusterOnline();
65
66 /***
67 * Add a listener for cluster events
68 *
69 * @param listener Listener
70 * @return True if already listening
71 */
72 boolean addTopologyListener(ClusterTopologyListener listener);
73
74 /***
75 * Remove a listener for cluster events
76 *
77 * @param listener Listener
78 * @return True if not listening
79 */
80 boolean removeTopologyListener(ClusterTopologyListener listener);
81
82 /***
83 * Get all the topology listeners
84 *
85 * @return a list of all the topology listeners
86 */
87 List<ClusterTopologyListener> getTopologyListeners();
88 }