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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.service.engine.runtime;
23 import java.util.Collection;
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;
31 * The administration interface for Apex engine users. Apex engine implementations expose this
32 * interface and external users use it to manage Apex engines.
34 * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
36 public interface EngineService {
38 * A method to attach a listener to the engine.
40 * @param listenerName a unique name for the listener
41 * @param listener is a callback interface to the engine.
43 void registerActionListener(String listenerName, ApexEventListener listener);
46 * A method to detach a listener from the engine.
48 * @param listenerName the unique name of the listener to deregister
50 void deregisterActionListener(String listenerName);
53 * This method gets the current runtime information for the running Apex engines.
55 * @return the engine service event interface
57 EngineServiceEventInterface getEngineServiceEventInterface();
60 * Gets the key of the engine service or worker.
64 AxArtifactKey getKey();
67 * This method gets the keys of the engines on the engine service.
69 * @return the engine keys
71 Collection<AxArtifactKey> getEngineKeys();
74 * The the key of the Apex model the engine service is running on.
76 * @return the Apex model key
78 AxArtifactKey getApexModelKey();
81 * This method updates the Apex model on Apex execution engines using a string representation of
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
90 void updateModel(AxArtifactKey engineServiceKey, String apexModelString, boolean forceFlag) throws ApexException;
93 * This method updates the Apex model on Apex execution engines using a policy model as input.
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
101 void updateModel(AxArtifactKey engineServiceKey, AxPolicyModel apexModel, boolean forceFlag) throws ApexException;
104 * Return the state of an engine service or engine.
106 * @return The engine service or engine state
108 AxEngineState getState();
111 * This method starts all Apex engines in the engine service.
113 * @throws ApexException on start errors
115 void startAll() throws ApexException;
118 * This method starts an Apex engine in the engine service.
120 * @param engineKey The key of the Apex engine to start
121 * @throws ApexException on start errors
123 void start(AxArtifactKey engineKey) throws ApexException;
126 * This method stops all Apex engines in the engine service.
128 * @throws ApexException on stop errors
130 void stop() throws ApexException;
133 * This method stops an Apex engine in the engine service.
135 * @param engineKey The key of the Apex engine to stop
136 * @throws ApexException on stop errors
138 void stop(AxArtifactKey engineKey) throws ApexException;
141 * This method clears and uninitializes all Apex engines in the engine service.
143 * @throws ApexException on clear errors
145 void clear() throws ApexException;
148 * This method clears and uninitializes an Apex engine in the engine service.
150 * @param engineKey The key of the Apex engine to clear
151 * @throws ApexException on clear errors
153 void clear(AxArtifactKey engineKey) throws ApexException;
156 * This method checks if all Apex engines in the engine service are started.
158 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
161 * @return true if all Apex engines in the engine service are started.
166 * This method checks if an Apex engine in the engine service is started.
168 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
171 * @param engineKey The key of the Apex engine to check
172 * @return true if all Apex engines in the engine service are started.
174 boolean isStarted(AxArtifactKey engineKey);
177 * This method checks if all Apex engines in the engine service are stopped.
179 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
182 * @return true if all Apex engines in the engine service are stopped.
187 * This method checks if an Apex engine in the engine service is stopped.
189 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
192 * @param engineKey The key of the Apex engine to check
193 * @return true if all Apex engines in the engine service are stopped.
195 boolean isStopped(AxArtifactKey engineKey);
198 * This method starts periodic event generation.
200 * @param period The period in milliseconds between periodic events
201 * @throws ApexException On periodic event start errors
203 void startPeriodicEvents(long period) throws ApexException;
206 * This method stops periodic event generation.
208 * @throws ApexException On periodic event stop errors
210 void stopPeriodicEvents() throws ApexException;
213 * This method gets the status of an Apex engine in the engine service.
215 * @param engineKey the engine key
216 * @return the engine runtime information
217 * @throws ApexException on status read errors
219 String getStatus(AxArtifactKey engineKey) throws ApexException;
222 * This method gets the runtime information of all Apex engines in the engine service.
224 * @param engineKey the engine key
225 * @return the engine runtime information
226 * @throws ApexException on runtime information read errors
228 String getRuntimeInfo(AxArtifactKey engineKey) throws ApexException;