Bug 9116: SMR children of a prefix too
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mappingservice / IMappingService.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.mappingservice;
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.SiteId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
19
20 /**
21  * Mapping Service Java API.
22  *
23  * @author Florin Coras
24  *
25  */
26
27 public interface IMappingService {
28
29     enum LookupPolicy { NB_FIRST, NB_AND_SB }
30
31     /**
32      * Add mapping.
33      *
34      * @param origin
35      *            Table where mapping should be added
36      * @param key
37      *            Key of the mapping
38      * @param siteId
39      *            Site that stores the mapping
40      * @param mapping
41      *            Mapping to be stored
42      */
43     void addMapping(MappingOrigin origin, Eid key, SiteId siteId, MappingData mapping);
44
45     /**
46      * Generate and add a negative mapping entry originated from the southbound, and return the generated mapping.
47      *
48      * @param key
49      *            Key of the mapping
50      * @return Returns the generated negative mapping (which is never null).
51      */
52     MappingData addNegativeMapping(Eid key);
53
54     /**
55      * Retrieves mapping with given origin for the provided key. The lookup policy for the key is defined in the Mapping
56      * System.
57      *
58      * @param origin
59      *            Table where the mapping should be looked up.
60      * @param key
61      *            Key to be looked up
62      * @return Returns the mapping found in the Mapping System or null if nothing is found.
63      */
64     MappingData getMapping(MappingOrigin origin, Eid key);
65
66     /**
67      * Retrieves mapping for given key.The lookup policy for the key is defined in the Mapping
68      * System.
69      *
70      * @param key
71      *            Key to be looked up
72      * @return Returns the mapping found in the Mapping System or null if nothing is found.
73      */
74     MappingData getMapping(Eid key);
75
76     /**
77      * Retrieves mapping with a Source/Dest policy. This method is meant to avoid the overhead of building
78      * LcafSourceDest addresses.
79      *
80      * @param srcKey
81      *            Source key being looked up
82      * @param dstKey
83      *            Destination key being looked up
84      * @return Returns the mapping found in the Mapping System or null if nothing is found.
85      */
86     MappingData getMapping(Eid srcKey, Eid dstKey);
87
88     /**
89      * Retrieves widest negative prefix found in the Mapping System for given key.
90      *
91      * @param key
92      *            Key being looked up
93      * @return Returns the widest negative prefix or null if nothing is found.
94      */
95     Eid getWidestNegativePrefix(Eid key);
96
97     /**
98      * Retrieves the subtree of a maskable prefix from the given map-cache.
99      *
100      * @param origin
101      *            Table where the key should be looked up
102      * @param key
103      *            Key to be looked up
104      * @return The child prefixes of the prefix, including the prefix itself if present
105      */
106     Set<Eid> getSubtree(MappingOrigin origin, Eid key);
107
108     /**
109      * Refresh southbound mapping registration timestamp.
110      *
111      * @param key
112      *            The EID whose registration must be refreshed
113      * @param xtrId
114      *            xTR-ID of the mapping to be refreshed
115      * @param timestamp
116      *            New timestamp for the mapping
117      */
118     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
119
120     /**
121      * Remove mapping.
122      *
123      * @param origin
124      *            Table from where the mapping should be removed
125      * @param key
126      *            Key to be removed
127      */
128     void removeMapping(MappingOrigin origin, Eid key);
129
130     /**
131      * Add authentication key.
132      *
133      * @param key
134      *            The key for which the authentication key is added
135      * @param authKey
136      *            The authentication key
137      */
138     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
139
140
141     /**
142      * Subscribe a Subscriber to receive updates about mapping changes for an EID.
143      *
144      * @param subscriber
145      *            The Subscriber object with information about the subscriber
146      * @param subscribedEid
147      *            The EID for which the subscriber will receive updates
148      */
149     void subscribe(Subscriber subscriber, Eid subscribedEid);
150
151     /**
152      * Retrieves the subscribers for an EID.
153      *
154      * @param eid
155      *            The EID to be looked up
156      * @return
157      *            The set of subscribers for the EID
158      */
159     Set<Subscriber> getSubscribers(Eid eid);
160
161     /**
162      * Retrieve authentication key.
163      *
164      * @param key
165      *            The key for which the authentication key is being looked up.
166      * @return The authentication key.
167      */
168     MappingAuthkey getAuthenticationKey(Eid key);
169
170     /**
171      * Remove authentication key.
172      *
173      * @param key
174      *            Key for which the authentication key should be removed.
175      */
176     void removeAuthenticationKey(Eid key);
177
178     /**
179      * Generic addition of data. Not stored in MD-SAL datastore!
180      *
181      * @param origin
182      *            Table where data should be inserted
183      * @param key
184      *            The key where data should be inserted
185      * @param subKey
186      *            The subKey where data should be inserted
187      * @param data
188      *            The data to be stored
189      */
190     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
191
192     /**
193      * Generic retrieval of data.
194      *
195      * @param origin
196      *            Table from where the data should be read
197      * @param key
198      *            The key where the data is stored
199      * @param subKey
200      *            The subKey where data is stored
201      * @return The data
202      */
203     Object getData(MappingOrigin origin, Eid key, String subKey);
204
205     /**
206      * Generic removal of data.
207      *
208      * @param origin
209      *            The table from where the data should be removed
210      * @param key
211      *            The key of the data to be removed
212      * @param subKey
213      *            The subKey of the data to be removed
214      */
215     void removeData(MappingOrigin origin, Eid key, String subKey);
216
217     /**
218      * Returns the parent prefix for given key.
219      *
220      * @param key
221      *            The key which parent is to be returned.
222      * @return The parent perfix of a specific key.
223      */
224     Eid getParentPrefix(Eid key);
225
226     /**
227      * Configures Mapping Service mapping merge option. If set to false, mappings with the same key are overwritten,
228      * otherwise, mappings with the same key but from different xTR-IDs are all stored.
229      *
230      * @param mappingMerge
231      *            enables or disables mapping merge
232      */
233     void setMappingMerge(boolean mappingMerge);
234
235     /**
236      * Configures Mapping Service mapping lookup policy option.
237      *
238      * @param policy
239      *            the policy to be activated
240      */
241     void setLookupPolicy(LookupPolicy policy);
242
243     /**
244      * Print all mappings. Used for testing, debugging and the karaf shell.
245      *
246      * @return String consisting of all mappings
247      */
248     String printMappings();
249
250     /**
251      * Print mappings in cache in a human friendly format.
252      *
253      * @return a String consisting of all the mappings in the cache
254      */
255     String prettyPrintMappings();
256
257     /**
258      * Print all authentication keys. Used for testing, debugging and the karaf shell.
259      *
260      * @return String consisting of all mappings
261      */
262     String printKeys();
263
264     /**
265      * Print keys in cache in a human friendly format.
266      *
267      * @return a String consisting of all the keys in the cache
268      */
269     String prettyPrintKeys();
270
271     /**
272      * Cleans all cached mappings.Used for testing.
273      */
274     void cleanCachedMappings();
275
276     /**
277      * Set cluster master status.
278      *
279      * @param isMaster
280      *            is|isn't master
281      */
282     void setIsMaster(boolean isMaster);
283
284     /**
285      * Get cluster master status.
286      *
287      * @return isMaster
288      *            is|isn't master
289      */
290     boolean isMaster();
291 }