Make 'mappings' CLI output user friendly
[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 org.opendaylight.lispflowmapping.lisp.type.MappingData;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
16
17 /**
18  * Mapping System interface.
19  *
20  * @author Florin Coras
21  *
22  */
23
24 public interface IMappingSystem {
25     /**
26      * Add mapping.
27      *
28      * @param origin
29      *            Table where mapping should be added
30      * @param key
31      *            Key of the mapping
32      * @param mapping
33      *            Mapping to be stored
34      */
35     void addMapping(MappingOrigin origin, Eid key, MappingData mapping);
36
37     /**
38      * Generate and add a negative mapping entry originated from the southbound, and return the generated mapping.
39      *
40      * @param key
41      *            Key of the mapping
42      * @return Returns the generated negative mapping (which is never null).
43      */
44     MappingData addNegativeMapping(Eid key);
45
46     /**
47      * Retrieves mapping for the provided src and dst key.
48      *
49      * @param src
50      *            Source Key to be looked up
51      * @param dst
52      *            Destination Key to be looked up
53      * @return Returns the mapping found in the MappingSystem or null if nothing is found.
54      */
55     MappingData getMapping(Eid src, Eid dst);
56
57     /**
58      * Retrieves mapping for the provided dst key.
59      *
60      * @param dst
61      *            Destination 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(Eid dst);
65
66     /**
67      * Retrieves mapping for the provided dst key for a particular xtr id.
68      * @param src
69      *            Source Key to be looked up.
70      * @param dst
71      *            Destination Key to be looked up.
72      * @param xtrId
73      *            Xtr Id for which this look to be done. If null, this method works like
74      *            regular getMapping(src, dst)
75      * @return Returns the mapping found in the simple map cache or null if nothing is found.
76      */
77     MappingData getMapping(Eid src, Eid dst, XtrId xtrId);
78
79     /**
80      * Retrieves mapping from table for provided key.
81      *
82      * @param origin
83      *            Table where mapping should be looked up
84      * @param key
85      *            Key to be looked up
86      * @return Returns the mapping found in the cache or null if nothing is found.
87      */
88     MappingData getMapping(MappingOrigin origin, Eid key);
89
90     /**
91      * Retrieves widest negative prefix from table for provided key.
92      *
93      * @param key
94      *            Key to be looked up
95      * @return Returns the prefix found in the cache or null if nothing is found.
96      */
97     Eid getWidestNegativePrefix(Eid key);
98
99     /**
100      * Refresh southbound mapping registration timestamp.
101      *
102      * @param key
103      *            The EID whose registration must be refreshed
104      * @param xtrId
105      *            xTR-ID of the mapping to be refreshed
106      * @param timestamp
107      *            New timestamp for the mapping
108      */
109     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
110
111     /**
112      * Remove mapping.
113      *
114      * @param origin
115      *            Table for mapping that should be removed
116      * @param key
117      *            Key to be removed
118      *
119      */
120     void removeMapping(MappingOrigin origin, Eid key);
121
122     /**
123      * Add authentication key.
124      *
125      * @param key
126      *            The key for which the authentication key is added
127      * @param authKey
128      *            The authentication key
129      */
130     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
131
132     /**
133      * Retrieve authentication key.
134      *
135      * @param key
136      *            The key for which the authentication key is being looked up.
137      * @return The authentication key.
138      */
139     MappingAuthkey getAuthenticationKey(Eid key);
140
141     /**
142      * Remove authentication key.
143      *
144      * @param key
145      *            Key for which the authentication key should be removed.
146      */
147     void removeAuthenticationKey(Eid key);
148
149
150     /**
151      * Add data for key.
152      *
153      * @param origin
154      *            Table for data that should be added
155      * @param key
156      *            The key for which data is inserted
157      * @param subKey
158      *            The subKey where data should be inserted
159      * @param data
160      *            The data to be stored
161      */
162     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
163
164     /**
165      * Generic retrieval of data.
166      *
167      * @param origin
168      *            Table from where data should be retrieved
169      * @param key
170      *            The key where the data is stored
171      * @param subKey
172      *            The subKey where data is stored
173      * @return The data
174      */
175     Object getData(MappingOrigin origin, Eid key, String subKey);
176
177
178     /**
179      * Generic removal of data.
180      *
181      * @param origin
182      *            Table from where data should be removed
183      * @param key
184      *            The key of the data to be removed
185      * @param subKey
186      *            The subKey of the data to be removed
187      */
188     void removeData(MappingOrigin origin, Eid key, String subKey);
189
190     /**
191      * Returns the parent prefix for given key.
192      *
193      * @param key
194      *            The key which parent is to be returned.
195      * @return The parent perfix of a specific key.
196      */
197     Eid getParentPrefix(Eid key);
198
199     /**
200      * Sets iterateMask. If set to true, longest prefix matching for IP keys is used.
201      *
202      * @param iterate
203      *            Value to configure
204      *
205      */
206     void setIterateMask(boolean iterate);
207
208     /**
209      * Configure merge policy. If set to true, mappings are merged.
210      *
211      * @param mappingMerge
212      *            Value to configure
213      */
214     void setMappingMerge(boolean mappingMerge);
215
216     /**
217      * Print all mappings. Used for testing, debugging and the karaf shell.
218      *
219      * @return String consisting of all mappings
220      */
221     String printMappings();
222
223     /**
224      * Print mappings in cache in a human friendly format.
225      *
226      * @return a String consisting of all the mappings in the cache
227      */
228     String prettyPrintMappings();
229
230     /**
231      * Print all authentication keys. Used for testing, debugging and the karaf shell.
232      *
233      * @return String consisting of all mappings
234      */
235     String printKeys();
236
237     /**
238      * Set cluster master status.
239      *
240      * @param isMaster
241      *            is|isn't master
242      */
243     void setIsMaster(boolean isMaster);
244
245     /**
246      * Get cluster master status.
247      *
248      * @return isMaster
249      *            is|isn't master
250      */
251     boolean isMaster();
252 }