Bug 9116: SMR children of a prefix too
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mapcache / IMappingSystem.java
1 /*
2  * Copyright (c) 2015, 2017 Cisco Systems, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.interfaces.mapcache;
10
11 import java.util.Set;
12 import org.opendaylight.lispflowmapping.interfaces.dao.Subscriber;
13 import org.opendaylight.lispflowmapping.lisp.type.MappingData;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
18
19 /**
20  * Mapping System interface.
21  *
22  * @author Florin Coras
23  *
24  */
25
26 public interface IMappingSystem {
27     /**
28      * Add mapping.
29      *
30      * @param origin
31      *            Table where mapping should be added
32      * @param key
33      *            Key of the mapping
34      * @param mapping
35      *            Mapping to be stored
36      */
37     void addMapping(MappingOrigin origin, Eid key, MappingData mapping);
38
39     /**
40      * Generate and add a negative mapping entry originated from the southbound, and return the generated mapping.
41      *
42      * @param key
43      *            Key of the mapping
44      * @return Returns the generated negative mapping (which is never null).
45      */
46     MappingData addNegativeMapping(Eid key);
47
48     /**
49      * Update mapping.
50      *
51      * @param origin
52      *            Table where mapping should be added
53      * @param key
54      *            Key of the mapping
55      * @param mapping
56      *            Mapping to be stored
57      */
58     void updateMapping(MappingOrigin origin, Eid key, MappingData mapping);
59
60     /**
61      * Retrieves mapping for the provided src and dst key.
62      *
63      * @param src
64      *            Source Key to be looked up
65      * @param dst
66      *            Destination Key to be looked up
67      * @return Returns the mapping found in the MappingSystem or null if nothing is found.
68      */
69     MappingData getMapping(Eid src, Eid dst);
70
71     /**
72      * Retrieves mapping for the provided dst key.
73      *
74      * @param dst
75      *            Destination Key to be looked up
76      * @return Returns the mapping found in the Mapping System or null if nothing is found.
77      */
78     MappingData getMapping(Eid dst);
79
80     /**
81      * Retrieves mapping for the provided dst key for a particular xtr id.
82      * @param src
83      *            Source Key to be looked up.
84      * @param dst
85      *            Destination Key to be looked up.
86      * @param xtrId
87      *            Xtr Id for which this look to be done. If null, this method works like
88      *            regular getMapping(src, dst)
89      * @return Returns the mapping found in the simple map cache or null if nothing is found.
90      */
91     MappingData getMapping(Eid src, Eid dst, XtrId xtrId);
92
93     /**
94      * Retrieves mapping from table for provided key.
95      *
96      * @param origin
97      *            Table where mapping should be looked up
98      * @param key
99      *            Key to be looked up
100      * @return Returns the mapping found in the cache or null if nothing is found.
101      */
102     MappingData getMapping(MappingOrigin origin, Eid key);
103
104     /**
105      * Retrieves widest negative prefix from table for provided key.
106      *
107      * @param key
108      *            Key to be looked up
109      * @return Returns the prefix found in the cache or null if nothing is found.
110      */
111     Eid getWidestNegativePrefix(Eid key);
112
113     /**
114      * Retrieves the subtree of a maskable prefix from the given map-cache.
115      *
116      * @param origin
117      *            Table where the key should be looked up
118      * @param key
119      *            Key to be looked up
120      * @return The child prefixes of the prefix, including the prefix itself if present
121      */
122     Set<Eid> getSubtree(MappingOrigin origin, Eid key);
123
124     /**
125      * Refresh southbound mapping registration timestamp.
126      *
127      * @param key
128      *            The EID whose registration must be refreshed
129      * @param xtrId
130      *            xTR-ID of the mapping to be refreshed
131      * @param timestamp
132      *            New timestamp for the mapping
133      */
134     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
135
136     /**
137      * Remove mapping.
138      *
139      * @param origin
140      *            Table for mapping that should be removed
141      * @param key
142      *            Key to be removed
143      *
144      */
145     void removeMapping(MappingOrigin origin, Eid key);
146
147     /**
148      * Subscribe a Subscriber to receive updates about mapping changes for an EID.
149      *
150      * @param subscriber
151      *            The Subscriber object with information about the subscriber
152      * @param subscribedEid
153      *            The EID for which the subscriber will receive updates
154      */
155     void subscribe(Subscriber subscriber, Eid subscribedEid);
156
157     /**
158      * Retrieves the subscribers for an EID.
159      *
160      * @param eid
161      *            The EID to be looked up
162      * @return
163      *            The set of subscribers for the EID
164      */
165     Set<Subscriber> getSubscribers(Eid eid);
166
167     /**
168      * Add authentication key.
169      *
170      * @param key
171      *            The key for which the authentication key is added
172      * @param authKey
173      *            The authentication key
174      */
175     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
176
177     /**
178      * Retrieve authentication key.
179      *
180      * @param key
181      *            The key for which the authentication key is being looked up.
182      * @return The authentication key.
183      */
184     MappingAuthkey getAuthenticationKey(Eid key);
185
186     /**
187      * Remove authentication key.
188      *
189      * @param key
190      *            Key for which the authentication key should be removed.
191      */
192     void removeAuthenticationKey(Eid key);
193
194
195     /**
196      * Add data for key.
197      *
198      * @param origin
199      *            Table for data that should be added
200      * @param key
201      *            The key for which data is inserted
202      * @param subKey
203      *            The subKey where data should be inserted
204      * @param data
205      *            The data to be stored
206      */
207     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
208
209     /**
210      * Generic retrieval of data.
211      *
212      * @param origin
213      *            Table from where data should be retrieved
214      * @param key
215      *            The key where the data is stored
216      * @param subKey
217      *            The subKey where data is stored
218      * @return The data
219      */
220     Object getData(MappingOrigin origin, Eid key, String subKey);
221
222
223     /**
224      * Generic removal of data.
225      *
226      * @param origin
227      *            Table from where data should be removed
228      * @param key
229      *            The key of the data to be removed
230      * @param subKey
231      *            The subKey of the data to be removed
232      */
233     void removeData(MappingOrigin origin, Eid key, String subKey);
234
235     /**
236      * Returns the parent prefix for given key.
237      *
238      * @param key
239      *            The key which parent is to be returned.
240      * @return The parent perfix of a specific key.
241      */
242     Eid getParentPrefix(Eid key);
243
244     /**
245      * Sets iterateMask. If set to true, longest prefix matching for IP keys is used.
246      *
247      * @param iterate
248      *            Value to configure
249      *
250      */
251     void setIterateMask(boolean iterate);
252
253     /**
254      * Configure merge policy. If set to true, mappings are merged.
255      *
256      * @param mappingMerge
257      *            Value to configure
258      */
259     void setMappingMerge(boolean mappingMerge);
260
261     /**
262      * Print all mappings. Used for testing, debugging and the karaf shell.
263      *
264      * @return String consisting of all mappings
265      */
266     String printMappings();
267
268     /**
269      * Print mappings in cache in a human friendly format.
270      *
271      * @return a String consisting of all the mappings in the cache
272      */
273     String prettyPrintMappings();
274
275     /**
276      * Print all authentication keys. Used for testing, debugging and the karaf shell.
277      *
278      * @return String consisting of all mappings
279      */
280     String printKeys();
281
282     /**
283      * Print keys in cache in a human friendly format.
284      *
285      * @return a String consisting of all the keys in the cache
286      */
287     String prettyPrintKeys();
288
289     /**
290      * Set cluster master status.
291      *
292      * @param isMaster
293      *            is|isn't master
294      */
295     void setIsMaster(boolean isMaster);
296
297     /**
298      * Get cluster master status.
299      *
300      * @return isMaster
301      *            is|isn't master
302      */
303     boolean isMaster();
304 }