Add sibling prefix lookup methods to RadixTrie and HashMapDb
[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 org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
15
16 public interface ILispDAO {
17
18     /**
19      * Put a entry into the DAO.
20      *
21      * @param key
22      *            The entry's key.
23      * @param values
24      *            The entry's value.
25      */
26     void put(Object key, MappingEntry<?>... values);
27
28     /**
29      * Get a specific value from the DAO.
30      *
31      * @param key
32      *            The key of the value to fetch
33      * @param valueKey
34      *            The value to fetch
35      * @return The value from the DAO.
36      */
37     Object getSpecific(Object key, String valueKey);
38
39     /**
40      * Get the entries from the DAO.
41      *
42      * @param key
43      *            The key to be looked up as exact match.
44      * @return The value from the DAO.
45      */
46     Map<String, Object> get(Object key);
47
48     /**
49      * Get value for longest prefix match from the DAO.
50      *
51      * @param key
52      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
53      * @return The value from the DAO.
54      */
55     Map<String, Object> getBest(Object key);
56
57     /**
58      * Get longest prefix match and value from the DAO.
59      *
60      * @param key
61      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized
62      * @return The best match and value pair from the DAO.
63      */
64     SimpleImmutableEntry<Eid, Map<String, ?>> getBestPair(Object key);
65
66     /**
67      * Get parent prefix.
68      *
69      * @param key
70      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
71      * @return The parent prefix of the longest prefix match for the key.
72      */
73     Eid getParentPrefix(Eid key);
74
75     /**
76      * Get sibling prefix.
77      *
78      * @param key
79      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
80      * @return The sibling prefix of the longest prefix match for the key.
81      */
82     Eid getSiblingPrefix(Eid key);
83
84     /**
85      * Get widest negative prefix.
86      *
87      * @param key
88      *            The eid prefix, IPv4 or IPv6, to be looked up. Key must be normalized.
89      * @return The widest negative prefix found.
90      */
91     Eid getWidestNegativePrefix(Eid key);
92
93     /**
94      * Enumerate all the entries from the DAO.
95      *
96      * @param visitor
97      *            The visitor object.
98      */
99     void getAll(IRowVisitor visitor);
100
101     /**
102      * Remove an entry from the DAO.
103      *
104      * @param key
105      *            The key of the entry to delete
106      */
107     void remove(Object key);
108
109     /**
110      * Remove an entry from the DAO.
111      *
112      * @param key
113      *            The key of the entry
114      * @param valueKey
115      *            The value to delete
116      */
117     void removeSpecific(Object key, String valueKey);
118
119     /**
120      * Clear the DAO and remove all of the entries.
121      */
122     void removeAll();
123
124     /**
125      * Insert a new table for given key.
126      *
127      * @param key
128      *            The key for the table
129      * @return The inserted table
130      */
131     ILispDAO putTable(String key);
132
133     /**
134      * Inserts a new, nested table for given key and subkey. Also acts as factory method.
135      *
136      * @param key
137      *              The key for which a new table is linked in
138      * @param valueKey
139      *              The subkey under which to insert the new table
140      * @return The inserted table
141      */
142     ILispDAO putNestedTable(Object key, String valueKey);
143 }