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