1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
/*
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.policy.drools.system;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.capabilities.Lockable;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
/**
* Policy Engine, the top abstraction for the Drools PDP Policy Engine. It abstracts away a Drools
* PDP Engine from management purposes. This is the best place to looking at the code from a top
* down approach. Other managed entities can be obtained from the PolicyEngine, hierarchically. <br>
* PolicyEngine 1 --- * PolicyController 1 --- 1 DroolsController 1 --- 1 PolicyContainer 1 --- *
* PolicySession <br> PolicyEngine 1 --- 1 TopicEndpointManager 1 -- * TopicReader 1 --- 1
* UebTopicReader <br> PolicyEngine 1 --- 1 TopicEndpointManager 1 -- * TopicReader 1 --- 1
* DmaapTopicReader <br> PolicyEngine 1 --- 1 TopicEndpointManager 1 -- * TopicWriter 1 --- 1
* DmaapTopicWriter <br> PolicyEngine 1 --- 1 TopicEndpointManager 1 -- * TopicReader 1 --- 1
* RestTopicReader <br> PolicyEngine 1 --- 1 TopicEndpointManager 1 -- * TopicWriter 1 --- 1
* RestTopicWriter <br> PolicyEngine 1 --- 1 ManagementServer
*/
public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
* Boot the engine.
*
* @param cliArgs command line arguments
*/
void boot(String[] cliArgs);
/**
* configure the policy engine according to the given properties.
*
* @param properties Policy Engine properties
* @throws IllegalArgumentException when invalid or insufficient properties are provided
*/
void configure(Properties properties);
/**
* updates the Policy Engine with the given configuration.
*
* @param configuration the configuration
* @return success or failure
* @throws IllegalArgumentException if invalid argument provided
* @throws IllegalStateException if the system is in an invalid state
*/
boolean configure(PdpdConfiguration configuration);
/**
* open the Policy Engine to external configuration systems.
*
* @return success or failure
*/
boolean open();
/**
* configure the engine's environment. General lab installation configuration is made available
* to the Engine. Typically, custom lab installation that may be needed by arbitrary drools
* applications are made available, for example network component and database host addresses.
* Multiple environments can be passed in and tracked by the engine.
*
* @param properties an environment properties
*/
void setEnvironment(Properties properties);
/**
* gets the engine's environment.
*
* @return properties object
*/
Properties getEnvironment();
/**
* gets an environment's value, by 1) first from the engine's environment, and 2) from the OS
* environment.
*
* @param key environment key
* @return environment value or null if absent
*/
String getEnvironmentProperty(String key);
/**
* sets an engine's environment property.
*
* @param key key
* @param value value
* @return property string
*/
String setEnvironmentProperty(String key, String value);
/**
* registers a new Policy Controller with the Policy Engine initialized per properties.
*
* @param properties properties to initialize the Policy Controller
* @return the newly instantiated Policy Controller
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
* permitted.
*/
PolicyController createPolicyController(String name, Properties properties);
/**
* updates a set of Policy Controllers with configuration information.
*
* @param configuration list of configurations
* @return list of controllers
* @throws IllegalArgumentException exception
* @throws IllegalStateException exception
*/
List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configuration);
/**
* updates an already existing Policy Controller with configuration information.
*
* @param configuration configuration
* @return the updated Policy Controller
* @throws IllegalArgumentException in the configuration is invalid
* @throws IllegalStateException if the controller is in a bad state
* @throws Exception any other reason
*/
PolicyController updatePolicyController(ControllerConfiguration configuration);
/**
* removes the Policy Controller identified by its name from the Policy Engine.
*
* @param name name of the Policy Controller
*/
void removePolicyController(String name);
/**
* removes a Policy Controller from the Policy Engine.
*
* @param controller the Policy Controller to remove from the Policy Engine
*/
void removePolicyController(PolicyController controller);
/**
* returns a list of the available Policy Controllers.
*
* @return list of Policy Controllers
*/
List<PolicyController> getPolicyControllers();
/**
* get policy controller names.
*
* @return list of controller names
*/
List<String> getPolicyControllerIds();
/**
* get unmanaged sources.
*
* @return unmanaged sources
*/
List<TopicSource> getSources();
/**
* get unmanaged sinks.
*
* @return unmanaged sinks
*/
List<TopicSink> getSinks();
/**
* get unmmanaged http servers list.
*
* @return http servers
*/
List<HttpServletServer> getHttpServers();
/**
* get properties configuration.
*
* @return properties objects
*/
Properties getProperties();
/**
* get features attached to the Policy Engine.
*
* @return list of features
*/
List<PolicyEngineFeatureApi> getFeatureProviders();
/**
* get named feature attached to the Policy Engine.
*
* @return the feature
*/
PolicyEngineFeatureApi getFeatureProvider(String featureName);
/**
* get features attached to the Policy Engine.
*
* @return list of features
*/
List<String> getFeatures();
/**
* Attempts the dispatching of an "event" object.
*
* @param topic topic
* @param event the event object to send
* @return true if successful, false if a failure has occurred.
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
* permitted (ie. locked or stopped).
*/
boolean deliver(String topic, Object event);
/**
* Attempts the dispatching of an "event" object over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
* @return true if successful, false if a failure has occurred.
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
* permitted (ie. locked or stopped).
* @throws UnsupportedOperationException when the engine cannot deliver due to the functionality
* missing (ie. communication infrastructure not supported.
*/
boolean deliver(String busType, String topic, Object event);
/**
* Attempts the dispatching of an "event" object over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
* @return true if successful, false if a failure has occurred.
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
* permitted (ie. locked or stopped).
* @throws UnsupportedOperationException when the engine cannot deliver due to the functionality
* missing (ie. communication infrastructure not supported.
*/
boolean deliver(CommInfrastructure busType, String topic, Object event);
/**
* Attempts delivering of an String over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
* @return true if successful, false if a failure has occurred.
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
* permitted (ie. locked or stopped).
* @throws UnsupportedOperationException when the engine cannot deliver due to the functionality
* missing (ie. communication infrastructure not supported.
*/
boolean deliver(CommInfrastructure busType, String topic, String event);
/**
* Invoked when the host goes into the active state.
*/
void activate();
/**
* Invoked when the host goes into the standby state.
*/
void deactivate();
/**
* produces a default telemetry configuration.
*
* @return policy engine configuration
*/
Properties defaultTelemetryConfig();
}
|