Merge "JUnit test - MultiTableMapCacheTest"
[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.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
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.mappingservice.rev150906.MappingOrigin;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
15
16 /**
17  *
18  * Mapping Service Java API
19  *
20  * @author Florin Coras
21  *
22  */
23
24 public interface IMappingService {
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 siteId
33      *            Site that stores the mapping
34      * @param data
35      *            Value to be stored
36      */
37     void addMapping(MappingOrigin origin, Eid key, SiteId siteId, Object data);
38
39     /**
40      * Retrieves mapping with given origin for the provided key. The lookup policy for the key is defined in the Mapping
41      * System
42      *
43      * @param origin
44      *            Table where the mapping should be looked up.
45      * @param key
46      *            Key to be looked up
47      * @return Returns the object found in the Mapping System or null if nothing is found.
48      */
49     Object getMapping(MappingOrigin origin, Eid key);
50
51     /**
52      * Retrieves mapping for given key.The lookup policy for the key is defined in the Mapping
53      * System
54      *
55      * @param key
56      *            Key to be looked up
57      * @return Returns the object found in the Mapping System or null if nothing is found.
58      */
59     Object getMapping(Eid key);
60
61     /**
62      * Retrieves mapping with a Source/Dest policy. This method is meant to avoid the overhead of building
63      * LcafSourceDest addresses.
64      *
65      * @param srcKey
66      *            Source key being looked up
67      * @param dstKey
68      *            Destination key being looked up
69      * @return Returns the object found in the Mapping System or null if nothing is found.
70      */
71     Object getMapping(Eid srcKey, Eid dstKey);
72
73     /**
74      * Remove mapping
75      *
76      * @param origin
77      *            Table from where the mapping should be removed
78      * @param key
79      *            Key to be removed
80      */
81     void removeMapping(MappingOrigin origin, Eid key);
82
83     /**
84      * Add authentication key
85      *
86      * @param key
87      *            The key for which the authentication key is added
88      * @param authKey
89      *            The authentication key
90      */
91     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
92
93     /**
94      * Retrieve authentication key
95      *
96      * @param key
97      *            The key for which the authentication key is being looked up.
98      * @return The authentication key.
99      */
100     MappingAuthkey getAuthenticationKey(Eid key);
101
102     /**
103      * Remove authentication key
104      *
105      * @param key
106      *            Key for which the authentication key should be removed.
107      */
108     void removeAuthenticationKey(Eid key);
109
110     /**
111      * Generic addition of data. Not stored in MD-SAL datastore!
112      *
113      * @param origin
114      *            Table where data should be inserted
115      * @param key
116      *            The key where data should be inserted
117      * @param subKey
118      *            The subKey where data should be inserted
119      * @param data
120      *            The data to be stored
121      */
122     void addData(MappingOrigin origin, Eid key, String subKey, Object data);
123
124     /**
125      * Generic retrieval of data
126      *
127      * @param origin
128      *            Table from where the data should be read
129      * @param key
130      *            The key where the data is stored
131      * @param subKey
132      *            The subKey where data is stored
133      * @return The data
134      */
135     Object getData(MappingOrigin origin, Eid key, String subKey);
136
137     /**
138      * Generic removal of data
139      *
140      * @param origin
141      *            The table from where the data should be removed
142      * @param key
143      *            The key of the data to be removed
144      * @param subKey
145      *            The subKey of the data to be removed
146      */
147     void removeData(MappingOrigin origin, Eid key, String subKey);
148
149     /**
150      * Configures Mapping Service mapping overwrite option. If set to true, mappings with the same key are overwritten,
151      * otherwise, mappings with the same key but from different xTR-IDs are all stored
152      *
153      * @param overwrite
154      *            enables or disables mapping overwrite
155      */
156     void setMappingOverwrite(boolean overwrite);
157
158     /**
159      * Configures Mapping Service mapping lookup policy option.
160      *
161      * @param policy
162      *            the policy to be activated
163      */
164     void setLookupPolicy(int policy);
165
166     /**
167      * Print all mappings. Used for testing, debugging and the karaf shell
168      *
169      * @return String consisting of all mappings
170      */
171     String printMappings();
172
173     /**
174      * Cleans all cached mappings.Used for testing.
175      */
176     void cleanCachedMappings();
177 }