Bug 9116: SMR children of a prefix too
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / dao / ILispDAO.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  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.dao;
10
11 import java.util.AbstractMap.SimpleImmutableEntry;
12 import java.util.Map;
13
14 import java.util.Set;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
16
17 public interface ILispDAO {
18
19     /**
20      * Put a entry into the DAO.
21      *
22      * @param key
23      *            The entry's key.
24      * @param values
25      *            The entry's value.
26      */
27     void put(Object key, MappingEntry<?>... values);
28
29     /**
30      * Get a specific value from the DAO.
31      *
32      * @param key
33      *            The key of the value to fetch
34      * @param valueKey
35      *            The value to fetch
36      * @return The value from the DAO.
37      */
38     Object getSpecific(Object key, String valueKey);
39
40     /**
41      * Get the entries from the DAO.
42      *
43      * @param key
44      *            The key to be looked up as exact match.
45      * @return The value from the DAO.
46      */
47     Map<String, Object> get(Object key);
48
49     /**
50      * Get value for longest prefix match from the DAO.
51      *
52      * @param key
53      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
54      * @return The value from the DAO.
55      */
56     Map<String, Object> getBest(Object key);
57
58     /**
59      * Get longest prefix match and value from the DAO.
60      *
61      * @param key
62      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized
63      * @return The best match and value pair from the DAO.
64      */
65     SimpleImmutableEntry<Eid, Map<String, ?>> getBestPair(Object key);
66
67     /**
68      * Look up the covering prefix for the argument, but exclude the argument itself, so the result is always less
69      * specific than the lookup key.
70      *
71      * @param key
72      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
73      * @return The covering prefix.
74      */
75     Eid getCoveringLessSpecific(Eid key);
76
77     /**
78      * Get parent prefix.
79      *
80      * @param key
81      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
82      * @return The parent prefix of the longest prefix match for the key.
83      */
84     Eid getParentPrefix(Eid key);
85
86     /**
87      * Get sibling prefix.
88      *
89      * @param key
90      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
91      * @return The sibling prefix of the longest prefix match for the key.
92      */
93     Eid getSiblingPrefix(Eid key);
94
95     /**
96      * Get virtual parent sibling prefix.
97      *
98      * @param key
99      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
100      * @return The longest prefix match node's virtual parent's sibling or null if nothing is found.
101      */
102     Eid getVirtualParentSiblingPrefix(Eid key);
103
104     /**
105      * Get widest negative prefix.
106      *
107      * @param key
108      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
109      * @return The widest negative prefix found.
110      */
111     Eid getWidestNegativePrefix(Eid key);
112
113     /**
114      * Get the subtree of the given prefix.
115      *
116      * @param key
117      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
118      * @return The set of EIDs that part of the subtree of the given EID.
119      */
120     Set<Eid> getSubtree(Eid key);
121
122     /**
123      * Enumerate all the entries from the DAO.
124      *
125      * @param visitor
126      *            The visitor object.
127      */
128     void getAll(IRowVisitor visitor);
129
130     /**
131      * Remove an entry from the DAO.
132      *
133      * @param key
134      *            The key of the entry to delete
135      */
136     void remove(Object key);
137
138     /**
139      * Remove an entry from the DAO.
140      *
141      * @param key
142      *            The key of the entry
143      * @param valueKey
144      *            The value to delete
145      */
146     void removeSpecific(Object key, String valueKey);
147
148     /**
149      * Clear the DAO and remove all of the entries.
150      */
151     void removeAll();
152
153     /**
154      * Insert a new table for given key.
155      *
156      * @param key
157      *            The key for the table
158      * @return The inserted table
159      */
160     ILispDAO putTable(String key);
161
162     /**
163      * Inserts a new, nested table for given key and subkey. Also acts as factory method.
164      *
165      * @param key
166      *              The key for which a new table is linked in
167      * @param valueKey
168      *              The subkey under which to insert the new table
169      * @return The inserted table
170      */
171     ILispDAO putNestedTable(Object key, String valueKey);
172
173     /**
174      * Check if the DAO is empty.
175      *
176      * @return true if empty
177      */
178     boolean isEmpty();
179 }