blob: d774d3e53a138996f149951d3aa10aa9f64e3c90 [file] [log] [blame]
Thomas Vachuska96d55b12015-05-11 08:52:03 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska96d55b12015-05-11 08:52:03 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ray Milkeya4122362015-08-18 15:19:08 -070016package org.onosproject.net.config;
Thomas Vachuska96d55b12015-05-11 08:52:03 -070017
Thomas Vachuska0a400ea2015-09-04 11:25:03 -070018import com.fasterxml.jackson.databind.JsonNode;
Thomas Vachuska96d55b12015-05-11 08:52:03 -070019import org.onosproject.store.Store;
20
21import java.util.Set;
22
23/**
24 * Mechanism for distributing and storing network configuration information.
25 */
26public interface NetworkConfigStore extends Store<NetworkConfigEvent, NetworkConfigStoreDelegate> {
27
28 /**
29 * Adds a new configuration factory.
30 *
31 * @param configFactory configuration factory to add
32 */
33 void addConfigFactory(ConfigFactory configFactory);
34
35 /**
36 * Removes a configuration factory.
37 *
38 * @param configFactory configuration factory to remove
39 */
40 void removeConfigFactory(ConfigFactory configFactory);
41
42 /**
43 * Returns the configuration factory for the specified configuration class.
44 *
45 * @param configClass configuration class
46 * @param <S> type of subject
Thomas Vachuskad894b5d2015-07-30 11:59:07 -070047 * @param <C> type of configuration
Thomas Vachuska96d55b12015-05-11 08:52:03 -070048 * @return configuration factory or null
49 */
50 <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass);
51
52 /**
53 * Returns set of subjects of the specified class, which have some
54 * network configuration associated with them.
55 *
56 * @param subjectClass subject class
57 * @param <S> type of subject
58 * @return set of subject
59 */
60 <S> Set<S> getSubjects(Class<S> subjectClass);
61
62 /**
63 * Returns set of subjects of the specified class, which have the
64 * specified class of network configuration associated with them.
65 *
66 * @param subjectClass subject class
67 * @param configClass configuration class
68 * @param <S> type of subject
69 * @param <C> type of configuration
70 * @return set of subject
71 */
72 <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
73
74 /**
75 * Returns set of configuration classes available for the specified subject.
76 *
77 * @param subject configuration subject
78 * @param <S> type of subject
79 * @return set of configuration classes
80 */
81 <S> Set<Class<? extends Config<S>>> getConfigClasses(S subject);
82
83 /**
84 * Get the configuration of the given class and for the specified subject.
85 *
86 * @param subject configuration subject
87 * @param configClass configuration class
88 * @param <S> type of subject
89 * @param <C> type of configuration
90 * @return configuration object
91 */
92 <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
93
94 /**
95 * Creates a new configuration of the given class for the specified subject.
96 *
97 * @param subject configuration subject
98 * @param configClass configuration class
99 * @param <S> type of subject
100 * @param <C> type of configuration
101 * @return configuration object
102 */
103 <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass);
104
105 /**
106 * Applies configuration for the specified subject and configuration
107 * class using the raw JSON object. If configuration already exists, it
108 * will be updated.
109 *
110 * @param subject configuration subject
111 * @param configClass configuration class
112 * @param json raw JSON node containing the configuration data
113 * @param <S> type of subject
114 * @param <C> type of configuration
Thomas Vachuskad894b5d2015-07-30 11:59:07 -0700115 * @return configuration object
Thomas Vachuskace0bbb32015-11-18 16:56:10 -0800116 * @throws IllegalArgumentException if the supplied JSON node contains
117 * invalid data
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700118 */
119 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
Thomas Vachuska0a400ea2015-09-04 11:25:03 -0700120 JsonNode json);
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700121
122 /**
123 * Clears the configuration of the given class for the specified subject.
124 *
125 * @param subject configuration subject
126 * @param configClass configuration class
127 * @param <S> type of subject
128 * @param <C> type of configuration
129 */
130 <S, C extends Config<S>> void clearConfig(S subject, Class<C> configClass);
131
Thomas Vachuska6f350ed2016-01-08 09:53:03 -0800132 /**
133 * Queues pending configuration for the specified subject and configuration
134 * class using the raw JSON object.
135 *
136 * @param subject configuration subject
137 * @param configKey configuration key
138 * @param json raw JSON node containing the configuration data
139 * @param <S> type of subject
140 * @throws IllegalArgumentException if the supplied JSON node contains
141 * invalid data
142 */
143 <S> void queueConfig(S subject, String configKey, JsonNode json);
144
145 /**
146 * Clears the configuration of the given class for the specified subject.
147 *
148 * @param subject configuration subject
149 * @param configKey configuration key
150 * @param <S> type of subject
151 */
152 <S> void clearQueuedConfig(S subject, String configKey);
153
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700154}