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