6ffe803f46b7704474e21c40070cf494a89b36d7
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / mapcache / IMapCache.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.eid.container.Eid;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
13
14 /**
15  * Map-cache interface.
16  *
17  * @author Florin Coras
18  *
19  */
20
21 public interface IMapCache {
22     /**
23      * Add mapping.
24      *
25      * @param key
26      *            Key of the mapping
27      * @param data
28      *            Value to be stored
29      * @param shouldOverwrite
30      *            Select if mappings with the same key are overwritten
31      * @param merge
32      *            Select if mappings with the same key are merged
33      */
34     void addMapping(Eid key, Object data, boolean shouldOverwrite, boolean merge);
35
36     /**
37      * Retrieves mapping for the provided srcKey and dstKey.
38      *
39      * @param srcKey
40      *            Source Key to be looked up
41      * @param dstKey
42      *            Destination Key to be looked up
43      * @return Returns the object found in the cache or null if nothing is found.
44      */
45     Object getMapping(Eid srcKey, Eid dstKey);
46
47     /**
48      * Retrieves widest negative prefix.
49      *
50      * @param key
51      *            Source Key to be looked up
52      * @return Returns the widest negative prefix or null if nothing is found.
53      */
54     Eid getWidestNegativeMapping(Eid key);
55
56     /**
57      * Remove mapping.
58      *
59      * @param key
60      *            Key to be removed
61      * @param overwrite
62      *            Select if mappings with the same key were overwritten on store
63      *
64      */
65     void removeMapping(Eid key, boolean overwrite);
66
67     /**
68      * Add authentication key.
69      *
70      * @param key
71      *            The key for which the authentication key is added
72      * @param authKey
73      *            The authentication key
74      */
75     void addAuthenticationKey(Eid key, MappingAuthkey authKey);
76
77     /**
78      * Retrieve authentication key.
79      *
80      * @param key
81      *            The key for which the authentication key is being looked up.
82      * @return The authentication key.
83      */
84     MappingAuthkey getAuthenticationKey(Eid key);
85
86     /**
87      * Remove authentication key.
88      *
89      * @param key
90      *            Key for which the authentication key should be removed.
91      */
92     void removeAuthenticationKey(Eid key);
93
94     /**
95      * Update mapping registration.
96      *
97      * @param key
98      *            The EID whose registration must be updated
99      * @param timestamp
100      *            New timestamp for the mapping
101      */
102     void updateMappingRegistration(Eid key, Long timestamp);
103
104     /**
105      * Add data for key.
106      *
107      * @param key
108      *            The key for which data is inserted
109      * @param subKey
110      *            The subKey where data should be inserted
111      * @param data
112      *            The data to be stored
113      */
114     void addData(Eid key, String subKey, Object data);
115
116     /**
117      * Generic retrieval of data.
118      *
119      * @param key
120      *            The key where the data is stored
121      * @param subKey
122      *            The subKey where data is stored
123      * @return The data
124      */
125     Object getData(Eid key, String subKey);
126
127     /**
128      * Generic removal of data.
129      *
130      * @param key
131      *            The key of the data to be removed
132      * @param subKey
133      *            The subKey of the data to be removed
134      */
135     void removeData(Eid key, String subKey);
136
137     /**
138      * Print mappings in cache. Used for testing, debugging and the karaf shell.
139      *
140      * @return a String consisting of all the mappings in the cache
141      */
142     String printMappings();
143 }