db7a9809b4a5dd05748927f8654e6c9a011a14b1
[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      * Retrieves mapping for the provided src and dst key.
50      *
51      * @param src
52      *            Source Key to be looked up
53      * @param dst
54      *            Destination Key to be looked up
55      * @return Returns the mapping found in the MappingSystem or null if nothing is found.
56      */
57     MappingData getMapping(Eid src, Eid dst);
58
59     /**
60      * Retrieves mapping for the provided dst key.
61      *
62      * @param dst
63      *            Destination Key to be looked up
64      * @return Returns the mapping found in the Mapping System or null if nothing is found.
65      */
66     MappingData getMapping(Eid dst);
67
68     /**
69      * Retrieves mapping for the provided dst key for a particular xtr id.
70      * @param src
71      *            Source Key to be looked up.
72      * @param dst
73      *            Destination Key to be looked up.
74      * @param xtrId
75      *            Xtr Id for which this look to be done. If null, this method works like
76      *            regular getMapping(src, dst)
77      * @return Returns the mapping found in the simple map cache or null if nothing is found.
78      */
79     MappingData getMapping(Eid src, Eid dst, XtrId xtrId);
80
81     /**
82      * Retrieves mapping from table for provided key.
83      *
84      * @param origin
85      *            Table where mapping should be looked up
86      * @param key
87      *            Key to be looked up
88      * @return Returns the mapping found in the cache or null if nothing is found.
89      */
90     MappingData getMapping(MappingOrigin origin, Eid key);
91
92     /**
93      * Retrieves widest negative prefix from table for provided key.
94      *
95      * @param key
96      *            Key to be looked up
97      * @return Returns the prefix found in the cache or null if nothing is found.
98      */
99     Eid getWidestNegativePrefix(Eid key);
100
101     /**
102      * Refresh southbound mapping registration timestamp.
103      *
104      * @param key
105      *            The EID whose registration must be refreshed
106      * @param xtrId
107      *            xTR-ID of the mapping to be refreshed
108      * @param timestamp
109      *            New timestamp for the mapping
110      */
111     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
112
113     /**
114      * Remove mapping.
115      *
116      * @param origin
117      *            Table for mapping that should be removed
118      * @param key
119      *            Key to be removed
120      *
121      */
122     void removeMapping(MappingOrigin origin, Eid key);
123
124     /**
125      * Subscribe a Subscriber to receive updates about mapping changes for an EID.
126      *
127      * @param subscriber
128      *            The Subscriber object with information about the subscriber
129      * @param subscribedEid
130      *            The EID for which the subscriber will receive updates
131      */
132     void subscribe(Subscriber subscriber, Eid subscribedEid);
133
134     /**
135      * Retrieves the subscribers for an EID.
136      *
137      * @param eid
138      *            The EID to be looked up
139      * @return
140      *            The set of subscribers for the EID
141      */
142     Set<Subscriber> getSubscribers(Eid eid);
143
144     /**
145      * Add authentication key.
146      *
147      * @param key
148      *            The key for which the authentication key is added
149      * @param authKey
150      *            The authentication key
151      */
152     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
153
154     /**
155      * Retrieve authentication key.
156      *
157      * @param key
158      *            The key for which the authentication key is being looked up.
159      * @return The authentication key.
160      */
161     MappingAuthkey getAuthenticationKey(Eid key);
162
163     /**
164      * Remove authentication key.
165      *
166      * @param key
167      *            Key for which the authentication key should be removed.
168      */
169     void removeAuthenticationKey(Eid key);
170
171
172     /**
173      * Add data for key.
174      *
175      * @param origin
176      *            Table for data that should be added
177      * @param key
178      *            The key for which data is inserted
179      * @param subKey
180      *            The subKey where data should be inserted
181      * @param data
182      *            The data to be stored
183      */
184     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
185
186     /**
187      * Generic retrieval of data.
188      *
189      * @param origin
190      *            Table from where data should be retrieved
191      * @param key
192      *            The key where the data is stored
193      * @param subKey
194      *            The subKey where data is stored
195      * @return The data
196      */
197     Object getData(MappingOrigin origin, Eid key, String subKey);
198
199
200     /**
201      * Generic removal of data.
202      *
203      * @param origin
204      *            Table from where data should be removed
205      * @param key
206      *            The key of the data to be removed
207      * @param subKey
208      *            The subKey of the data to be removed
209      */
210     void removeData(MappingOrigin origin, Eid key, String subKey);
211
212     /**
213      * Returns the parent prefix for given key.
214      *
215      * @param key
216      *            The key which parent is to be returned.
217      * @return The parent perfix of a specific key.
218      */
219     Eid getParentPrefix(Eid key);
220
221     /**
222      * Sets iterateMask. If set to true, longest prefix matching for IP keys is used.
223      *
224      * @param iterate
225      *            Value to configure
226      *
227      */
228     void setIterateMask(boolean iterate);
229
230     /**
231      * Configure merge policy. If set to true, mappings are merged.
232      *
233      * @param mappingMerge
234      *            Value to configure
235      */
236     void setMappingMerge(boolean mappingMerge);
237
238     /**
239      * Print all mappings. Used for testing, debugging and the karaf shell.
240      *
241      * @return String consisting of all mappings
242      */
243     String printMappings();
244
245     /**
246      * Print mappings in cache in a human friendly format.
247      *
248      * @return a String consisting of all the mappings in the cache
249      */
250     String prettyPrintMappings();
251
252     /**
253      * Print all authentication keys. Used for testing, debugging and the karaf shell.
254      *
255      * @return String consisting of all mappings
256      */
257     String printKeys();
258
259     /**
260      * Print keys in cache in a human friendly format.
261      *
262      * @return a String consisting of all the keys in the cache
263      */
264     String prettyPrintKeys();
265
266     /**
267      * Set cluster master status.
268      *
269      * @param isMaster
270      *            is|isn't master
271      */
272     void setIsMaster(boolean isMaster);
273
274     /**
275      * Get cluster master status.
276      *
277      * @return isMaster
278      *            is|isn't master
279      */
280     boolean isMaster();
281 }