SMR parent prefix
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mappingservice / IMappingService.java
1 /*
2  * Copyright (c) 2015 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      * Retrieves mapping with given origin for the provided key. The lookup policy for the key is defined in the Mapping
45      * System.
46      *
47      * @param origin
48      *            Table where the mapping should be looked up.
49      * @param key
50      *            Key to be looked up
51      * @return Returns the mapping found in the Mapping System or null if nothing is found.
52      */
53     MappingData getMapping(MappingOrigin origin, Eid key);
54
55     /**
56      * Retrieves mapping for given key.The lookup policy for the key is defined in the Mapping
57      * System.
58      *
59      * @param key
60      *            Key to be looked up
61      * @return Returns the mapping found in the Mapping System or null if nothing is found.
62      */
63     MappingData getMapping(Eid key);
64
65     /**
66      * Retrieves mapping with a Source/Dest policy. This method is meant to avoid the overhead of building
67      * LcafSourceDest addresses.
68      *
69      * @param srcKey
70      *            Source key being looked up
71      * @param dstKey
72      *            Destination key being looked up
73      * @return Returns the mapping found in the Mapping System or null if nothing is found.
74      */
75     MappingData getMapping(Eid srcKey, Eid dstKey);
76
77     /**
78      * Retrieves widest negative prefix found in the Mapping System for given key.
79      *
80      * @param key
81      *            Key being looked up
82      * @return Returns the widest negative prefix or null if nothing is found.
83      */
84     Eid getWidestNegativePrefix(Eid key);
85
86     /**
87      * Refresh southbound mapping registration timestamp.
88      *
89      * @param key
90      *            The EID whose registration must be refreshed
91      * @param xtrId
92      *            xTR-ID of the mapping to be refreshed
93      * @param timestamp
94      *            New timestamp for the mapping
95      */
96     void refreshMappingRegistration(Eid key, XtrId xtrId, Long timestamp);
97
98     /**
99      * Remove mapping.
100      *
101      * @param origin
102      *            Table from where the mapping should be removed
103      * @param key
104      *            Key to be removed
105      */
106     void removeMapping(MappingOrigin origin, Eid key);
107
108     /**
109      * Add authentication key.
110      *
111      * @param key
112      *            The key for which the authentication key is added
113      * @param authKey
114      *            The authentication key
115      */
116     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
117
118     /**
119      * Retrieve authentication key.
120      *
121      * @param key
122      *            The key for which the authentication key is being looked up.
123      * @return The authentication key.
124      */
125     MappingAuthkey getAuthenticationKey(Eid key);
126
127     /**
128      * Remove authentication key.
129      *
130      * @param key
131      *            Key for which the authentication key should be removed.
132      */
133     void removeAuthenticationKey(Eid key);
134
135     /**
136      * Generic addition of data. Not stored in MD-SAL datastore!
137      *
138      * @param origin
139      *            Table where data should be inserted
140      * @param key
141      *            The key where data should be inserted
142      * @param subKey
143      *            The subKey where data should be inserted
144      * @param data
145      *            The data to be stored
146      */
147     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
148
149     /**
150      * Generic retrieval of data.
151      *
152      * @param origin
153      *            Table from where the data should be read
154      * @param key
155      *            The key where the data is stored
156      * @param subKey
157      *            The subKey where data is stored
158      * @return The data
159      */
160     Object getData(MappingOrigin origin, Eid key, String subKey);
161
162     /**
163      * Generic removal of data.
164      *
165      * @param origin
166      *            The table from where the data should be removed
167      * @param key
168      *            The key of the data to be removed
169      * @param subKey
170      *            The subKey of the data to be removed
171      */
172     void removeData(MappingOrigin origin, Eid key, String subKey);
173
174     /**
175      * Returns the parent prefix for given key.
176      *
177      * @param key
178      *            The key which parent is to be returned.
179      * @return The parent perfix of a specific key.
180      */
181     Eid getParentPrefix(Eid key);
182
183     /**
184      * Configures Mapping Service mapping merge option. If set to false, mappings with the same key are overwritten,
185      * otherwise, mappings with the same key but from different xTR-IDs are all stored.
186      *
187      * @param mappingMerge
188      *            enables or disables mapping merge
189      */
190     void setMappingMerge(boolean mappingMerge);
191
192     /**
193      * Configures Mapping Service mapping lookup policy option.
194      *
195      * @param policy
196      *            the policy to be activated
197      */
198     void setLookupPolicy(LookupPolicy policy);
199
200     /**
201      * Print all mappings. Used for testing, debugging and the karaf shell.
202      *
203      * @return String consisting of all mappings
204      */
205     String printMappings();
206
207     /**
208      * Print all authentication keys. Used for testing, debugging and the karaf shell.
209      *
210      * @return String consisting of all mappings
211      */
212     String printKeys();
213
214     /**
215      * Cleans all cached mappings.Used for testing.
216      */
217     void cleanCachedMappings();
218
219     /**
220      * Set cluster master status.
221      *
222      * @param isMaster
223      *            is|isn't master
224      */
225     void setIsMaster(final boolean isMaster);
226
227     /**
228      * Get cluster master status.
229      *
230      * @return isMaster
231      *            is|isn't master
232      */
233     boolean isMaster();
234 }