Fixed Group and meter id bugs
[controller.git] / opendaylight / clustering / services / src / main / java / org / opendaylight / controller / clustering / services / IClusterServicesCommon.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 /**
11  * @file   IClusterServicesCommon.java
12  *
13  * @brief  : Set of services an application will expect from the
14  * clustering services provider. This interface is going to be the
15  * base for per-container and Global services and so the container
16  * parameter is omitted but who uses knows about it
17  *
18  * Contract between the applications and the clustering service
19  * providers. Common version
20  */
21
22 package org.opendaylight.controller.clustering.services;
23
24 import java.net.InetAddress;
25 import java.util.List;
26 import java.util.Properties;
27 import java.util.Set;
28 import java.util.concurrent.ConcurrentMap;
29
30 import javax.transaction.HeuristicMixedException;
31 import javax.transaction.HeuristicRollbackException;
32 import javax.transaction.NotSupportedException;
33 import javax.transaction.RollbackException;
34 import javax.transaction.SystemException;
35 import javax.transaction.Transaction;
36
37 /**
38  * This WILL NOT BE USED DIRECTLY, but VIA SUBCLASS
39  *
40  * Set of services and application will expect from the clustering services
41  * provider. This interface is going to be the base for per-container and Global
42  * services and so the container parameter is omitted but who uses knows about
43  * it
44  *
45  */
46 public interface IClusterServicesCommon {
47     /**
48      * Method that will create a new named cache. The data
49      * structure if already present will cause an exception to be
50      * thrown to the caller.
51      *
52      * @param cacheName Name of the ConcurrentHashMap to create
53      * @param cMode Mode of the cache that need to be retrieved. This
54      * is a set such that more than one property can be provided, of
55      * course contrasting requirements will not be accepted and in
56      * that case an exception is thrown
57      *
58      * @return ConcurrentHashMap to be used to modify the data structure
59      */
60     ConcurrentMap<?, ?> createCache(String cacheName,
61             Set<IClusterServices.cacheMode> cMode) throws CacheExistException,
62             CacheConfigException;
63
64     /**
65      * Method that will retrieve and return the handle to modify a
66      * data structire distributed via clustering services. The
67      * datastructure shall already have been created else a null
68      * reference will be returned.
69      *
70      * @param cacheName Name of the ConcurrentHashMap to retrieve
71      *
72      * @return ConcurrentHashMap to be used to modify the data structure
73      */
74     ConcurrentMap<?, ?> getCache(String cacheName);
75
76     /**
77      * Destroy a cachename given cachename, if doesn't exist
78      * the function does nothing. If the datastructure exists, the
79      * whole cluster will destroy the instance
80      *
81      * @param cacheName Name of the ConcurrentHashMap to destroy
82      */
83     void destroyCache(String cacheName);
84
85     /**
86      * Function to test the existance of a cache with a given name already
87      *
88      * @param cacheName Name of the ConcurrentHashMap to destroy
89      *
90      * @return true if exists already, false otherwise
91      */
92     boolean existCache(String cacheName);
93
94     /**
95      * Return the list of all teh caches registered in the context of
96      * the called
97      *
98      *
99      * @return The set of names, expressed as strings
100      */
101     Set<String> getCacheList();
102
103     /**
104      * Return a list of properties that caracterize the cache
105      *
106      * @param cacheName Name of the cache
107      *
108      * @return The list of properties related to the cache
109      */
110     Properties getCacheProperties(String cacheName);
111
112     /**
113      * Begin a transaction covering with all the data structures/HW
114      * updates. One transaction per-thread can be opened at the
115      * most, that means if multiple thread are available, multiple
116      * transactions can be outstanding.
117      *
118      */
119     void tbegin() throws NotSupportedException, SystemException;
120
121     /**
122      * Commit a transaction covering all the data structures/HW updates.
123      */
124     void tcommit() throws RollbackException, HeuristicMixedException,
125             HeuristicRollbackException, java.lang.SecurityException,
126             java.lang.IllegalStateException, SystemException;
127
128     /**
129      * Rollback a transaction covering all the data structures/HW updates
130      */
131     void trollback() throws java.lang.IllegalStateException,
132             java.lang.SecurityException, SystemException;
133
134     /**
135      * Return the javax.transaction.Transaction associated with this thread
136      *
137      *
138      * @return Return the current transaction associated with this thread
139      */
140     Transaction tgetTransaction() throws SystemException;
141
142     /**
143      *
144      * Get the InetAddress of the coordinator controller in the cluster
145      *
146      * @return Address of the coordinator controller
147      */
148     InetAddress getCoordinatorAddress();
149
150     /**
151      * Get the InetAddress of the all the controllers that make up this
152      * Cluster
153      *
154      * @return List of InetAddress'es of all the controllers
155      */
156     List<InetAddress> getClusteredControllers();
157
158     /**
159      * Get the InetAddress of this Controller as seen by the Cluster Manager
160      *
161      * @return InetAddress of this Controller as seen by the Cluster Manager.
162      */
163     InetAddress getMyAddress();
164
165     /**
166      * Function that is used to know if the node on which is called is
167      * the cluster coordinator. The API is useful in scenario where
168      * the same logic is not worthed to be replicated on multiple
169      * nodes in the cluster and one can cook it up for all the
170      * others. In this scenario running the logic on the coordinator
171      * make sense, this of course implies logics that are not heavy
172      * and don't need to be scaled out linearly with the size of the
173      * cluster.
174      *
175      * @return true if the node on which the API is called is the
176      * coordinator for the cluster
177      */
178     boolean amICoordinator();
179 }