d643135272430e11b388650a8c5d12f67a1b2a01
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.service.engine.runtime;
22
23 import java.util.Collection;
24
25 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
27 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
28 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
29
30 /**
31  * The administration interface for Apex engine users. Apex engine implementations expose this
32  * interface and external users use it to manage Apex engines.
33  *
34  * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
35  */
36 public interface EngineService {
37     /**
38      * A method to attach a listener to the engine.
39      *
40      * @param listenerName a unique name for the listener
41      * @param listener is a callback interface to the engine.
42      */
43     void registerActionListener(String listenerName, ApexEventListener listener);
44
45     /**
46      * A method to detach a listener from the engine.
47      *
48      * @param listenerName the unique name of the listener to deregister
49      */
50     void deregisterActionListener(String listenerName);
51
52     /**
53      * This method gets the current runtime information for the running Apex engines.
54      *
55      * @return the engine service event interface
56      */
57     EngineServiceEventInterface getEngineServiceEventInterface();
58
59     /**
60      * Gets the key of the engine service or worker.
61      *
62      * @return the key
63      */
64     AxArtifactKey getKey();
65
66     /**
67      * This method gets the keys of the engines on the engine service.
68      *
69      * @return the engine keys
70      */
71     Collection<AxArtifactKey> getEngineKeys();
72
73     /**
74      * The the key of the Apex model the engine service is running on.
75      *
76      * @return the Apex model key
77      */
78     AxArtifactKey getApexModelKey();
79
80     /**
81      * This method updates the Apex model on Apex execution engines using a string representation of
82      * the model.
83      *
84      * @param engineServiceKey The key of the engine service on which to update the model
85      * @param apexModelString the apex model string
86      * @param forceFlag if true, model updates will be executed even on incompatible models
87      *        (different model names) and versions (different model version)
88      * @throws ApexException on model update errors
89      */
90     void updateModel(AxArtifactKey engineServiceKey, String apexModelString, boolean forceFlag) throws ApexException;
91
92     /**
93      * This method updates the Apex model on Apex execution engines using a policy model as input.
94      *
95      * @param engineServiceKey The key of the engine service on which to update the model
96      * @param apexModel is a policy definition model
97      * @param forceFlag if true, model updates will be executed even on incompatible models
98      *        (different model names) and versions (different model version)
99      * @throws ApexException on model update errors
100      */
101     void updateModel(AxArtifactKey engineServiceKey, AxPolicyModel apexModel, boolean forceFlag) throws ApexException;
102
103     /**
104      * This method returns the state of an engine service or engine.
105      *
106      * @return The engine service or engine state
107      */
108     AxEngineState getState();
109
110     /**
111      * This method starts all Apex engines in the engine service.
112      *
113      * @throws ApexException on start errors
114      */
115     void startAll() throws ApexException;
116
117     /**
118      * This method starts an Apex engine in the engine service.
119      *
120      * @param engineKey The key of the Apex engine to start
121      * @throws ApexException on start errors
122      */
123     void start(AxArtifactKey engineKey) throws ApexException;
124
125     /**
126      * This method stops all Apex engines in the engine service.
127      *
128      * @throws ApexException on stop errors
129      */
130     void stop() throws ApexException;
131
132     /**
133      * This method stops an Apex engine in the engine service.
134      *
135      * @param engineKey The key of the Apex engine to stop
136      * @throws ApexException on stop errors
137      */
138     void stop(AxArtifactKey engineKey) throws ApexException;
139
140     /**
141      * This method checks if all Apex engines in the engine service are started.
142      * 
143      * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
144      * stopping
145      *
146      * @return true if all Apex engines in the engine service are started.
147      */
148     boolean isStarted();
149
150     /**
151      * This method checks if an Apex engine in the engine service is started.
152      * 
153      * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
154      * stopping
155      *
156      * @param engineKey The key of the Apex engine to check
157      * @return true if all Apex engines in the engine service are started.
158      */
159     boolean isStarted(AxArtifactKey engineKey);
160
161     /**
162      * This method checks if all Apex engines in the engine service are stopped.
163      * 
164      * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
165      * stopping
166      *
167      * @return true if all Apex engines in the engine service are stopped.
168      */
169     boolean isStopped();
170
171     /**
172      * This method checks if an Apex engine in the engine service is stopped.
173      * 
174      * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
175      * stopping
176      *
177      * @param engineKey The key of the Apex engine to check
178      * @return true if all Apex engines in the engine service are stopped.
179      */
180     boolean isStopped(AxArtifactKey engineKey);
181
182     /**
183      * This method starts periodic event generation.
184      *
185      * @param period The period in milliseconds between periodic events
186      * @throws ApexException On periodic event start errors
187      */
188     void startPeriodicEvents(long period) throws ApexException;
189
190     /**
191      * This method stops periodic event generation.
192      *
193      * @throws ApexException On periodic event stop errors
194      */
195     void stopPeriodicEvents() throws ApexException;
196
197     /**
198      * This method gets the status of an Apex engine in the engine service.
199      *
200      * @param engineKey the engine key
201      * @return the engine runtime information
202      * @throws ApexException on status read errors
203      */
204     String getStatus(AxArtifactKey engineKey) throws ApexException;
205
206     /**
207      * This method gets the runtime information of all Apex engines in the engine service.
208      *
209      * @param engineKey the engine key
210      * @return the engine runtime information
211      * @throws ApexException on runtime information read errors
212      */
213     String getRuntimeInfo(AxArtifactKey engineKey) throws ApexException;
214 }