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