e3bf81e4c9722a08a1bc14485e47b28c0437d691
[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      * Refresh southbound mapping registration timestamp.
99      *
100      * @param key
101      *            The EID whose registration must be refreshed
102      * @param xtrId
103      *            xTR-ID of the mapping to be refreshed
104      * @param timestamp
105      *            New timestamp for the mapping
106      */
107     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
108
109     /**
110      * Remove mapping.
111      *
112      * @param origin
113      *            Table from where the mapping should be removed
114      * @param key
115      *            Key to be removed
116      */
117     void removeMapping(MappingOrigin origin, Eid key);
118
119     /**
120      * Add authentication key.
121      *
122      * @param key
123      *            The key for which the authentication key is added
124      * @param authKey
125      *            The authentication key
126      */
127     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
128
129
130     /**
131      * Subscribe a Subscriber to receive updates about mapping changes for an EID.
132      *
133      * @param subscriber
134      *            The Subscriber object with information about the subscriber
135      * @param subscribedEid
136      *            The EID for which the subscriber will receive updates
137      */
138     void subscribe(Subscriber subscriber, Eid subscribedEid);
139
140     /**
141      * Retrieves the subscribers for an EID.
142      *
143      * @param eid
144      *            The EID to be looked up
145      * @return
146      *            The set of subscribers for the EID
147      */
148     Set<Subscriber> getSubscribers(Eid eid);
149
150     /**
151      * Retrieve authentication key.
152      *
153      * @param key
154      *            The key for which the authentication key is being looked up.
155      * @return The authentication key.
156      */
157     MappingAuthkey getAuthenticationKey(Eid key);
158
159     /**
160      * Remove authentication key.
161      *
162      * @param key
163      *            Key for which the authentication key should be removed.
164      */
165     void removeAuthenticationKey(Eid key);
166
167     /**
168      * Generic addition of data. Not stored in MD-SAL datastore!
169      *
170      * @param origin
171      *            Table where data should be inserted
172      * @param key
173      *            The key where data should be inserted
174      * @param subKey
175      *            The subKey where data should be inserted
176      * @param data
177      *            The data to be stored
178      */
179     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
180
181     /**
182      * Generic retrieval of data.
183      *
184      * @param origin
185      *            Table from where the data should be read
186      * @param key
187      *            The key where the data is stored
188      * @param subKey
189      *            The subKey where data is stored
190      * @return The data
191      */
192     Object getData(MappingOrigin origin, Eid key, String subKey);
193
194     /**
195      * Generic removal of data.
196      *
197      * @param origin
198      *            The table from where the data should be removed
199      * @param key
200      *            The key of the data to be removed
201      * @param subKey
202      *            The subKey of the data to be removed
203      */
204     void removeData(MappingOrigin origin, Eid key, String subKey);
205
206     /**
207      * Returns the parent prefix for given key.
208      *
209      * @param key
210      *            The key which parent is to be returned.
211      * @return The parent perfix of a specific key.
212      */
213     Eid getParentPrefix(Eid key);
214
215     /**
216      * Configures Mapping Service mapping merge option. If set to false, mappings with the same key are overwritten,
217      * otherwise, mappings with the same key but from different xTR-IDs are all stored.
218      *
219      * @param mappingMerge
220      *            enables or disables mapping merge
221      */
222     void setMappingMerge(boolean mappingMerge);
223
224     /**
225      * Configures Mapping Service mapping lookup policy option.
226      *
227      * @param policy
228      *            the policy to be activated
229      */
230     void setLookupPolicy(LookupPolicy policy);
231
232     /**
233      * Print all mappings. Used for testing, debugging and the karaf shell.
234      *
235      * @return String consisting of all mappings
236      */
237     String printMappings();
238
239     /**
240      * Print mappings in cache in a human friendly format.
241      *
242      * @return a String consisting of all the mappings in the cache
243      */
244     String prettyPrintMappings();
245
246     /**
247      * Print all authentication keys. Used for testing, debugging and the karaf shell.
248      *
249      * @return String consisting of all mappings
250      */
251     String printKeys();
252
253     /**
254      * Print keys in cache in a human friendly format.
255      *
256      * @return a String consisting of all the keys in the cache
257      */
258     String prettyPrintKeys();
259
260     /**
261      * Cleans all cached mappings.Used for testing.
262      */
263     void cleanCachedMappings();
264
265     /**
266      * Set cluster master status.
267      *
268      * @param isMaster
269      *            is|isn't master
270      */
271     void setIsMaster(boolean isMaster);
272
273     /**
274      * Get cluster master status.
275      *
276      * @return isMaster
277      *            is|isn't master
278      */
279     boolean isMaster();
280 }