65a4e748b45d14997b0d8ec3393da3106560300d
[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      * Get parent prefix.
69      *
70      * @param key
71      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
72      * @return The parent prefix of the longest prefix match for the key.
73      */
74     Eid getParentPrefix(Eid key);
75
76     /**
77      * Get sibling prefix.
78      *
79      * @param key
80      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
81      * @return The sibling prefix of the longest prefix match for the key.
82      */
83     Eid getSiblingPrefix(Eid key);
84
85     /**
86      * Get virtual parent sibling prefix.
87      *
88      * @param key
89      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
90      * @return The longest prefix match node's virtual parent's sibling or null if nothing is found.
91      */
92     Eid getVirtualParentSiblingPrefix(Eid key);
93
94     /**
95      * Get widest negative prefix.
96      *
97      * @param key
98      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
99      * @return The widest negative prefix found.
100      */
101     Eid getWidestNegativePrefix(Eid key);
102
103     /**
104      * Get the subtree of the given prefix.
105      *
106      * @param key
107      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
108      * @return The set of EIDs that part of the subtree of the given EID.
109      */
110     Set<Eid> getSubtree(Eid key);
111
112     /**
113      * Enumerate all the entries from the DAO.
114      *
115      * @param visitor
116      *            The visitor object.
117      */
118     void getAll(IRowVisitor visitor);
119
120     /**
121      * Remove an entry from the DAO.
122      *
123      * @param key
124      *            The key of the entry to delete
125      */
126     void remove(Object key);
127
128     /**
129      * Remove an entry from the DAO.
130      *
131      * @param key
132      *            The key of the entry
133      * @param valueKey
134      *            The value to delete
135      */
136     void removeSpecific(Object key, String valueKey);
137
138     /**
139      * Clear the DAO and remove all of the entries.
140      */
141     void removeAll();
142
143     /**
144      * Insert a new table for given key.
145      *
146      * @param key
147      *            The key for the table
148      * @return The inserted table
149      */
150     ILispDAO putTable(String key);
151
152     /**
153      * Inserts a new, nested table for given key and subkey. Also acts as factory method.
154      *
155      * @param key
156      *              The key for which a new table is linked in
157      * @param valueKey
158      *              The subkey under which to insert the new table
159      * @return The inserted table
160      */
161     ILispDAO putNestedTable(Object key, String valueKey);
162
163     /**
164      * Check if the DAO is empty.
165      *
166      * @return true if empty
167      */
168     boolean isEmpty();
169 }