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 * This method returns 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 checks if all Apex engines in the engine service are started.
143 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
146 * @return true if all Apex engines in the engine service are started.
151 * This method checks if an Apex engine in the engine service is started.
153 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
156 * @param engineKey The key of the Apex engine to check
157 * @return true if all Apex engines in the engine service are started.
159 boolean isStarted(AxArtifactKey engineKey);
162 * This method checks if all Apex engines in the engine service are stopped.
164 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
167 * @return true if all Apex engines in the engine service are stopped.
172 * This method checks if an Apex engine in the engine service is stopped.
174 * <p>Note: an engine can be both not stopped and not started, for example, when it is starting or
177 * @param engineKey The key of the Apex engine to check
178 * @return true if all Apex engines in the engine service are stopped.
180 boolean isStopped(AxArtifactKey engineKey);
183 * This method starts periodic event generation.
185 * @param period The period in milliseconds between periodic events
186 * @throws ApexException On periodic event start errors
188 void startPeriodicEvents(long period) throws ApexException;
191 * This method stops periodic event generation.
193 * @throws ApexException On periodic event stop errors
195 void stopPeriodicEvents() throws ApexException;
198 * This method gets the status of an Apex engine in the engine service.
200 * @param engineKey the engine key
201 * @return the engine runtime information
202 * @throws ApexException on status read errors
204 String getStatus(AxArtifactKey engineKey) throws ApexException;
207 * This method gets the runtime information of all Apex engines in the engine service.
209 * @param engineKey the engine key
210 * @return the engine runtime information
211 * @throws ApexException on runtime information read errors
213 String getRuntimeInfo(AxArtifactKey engineKey) throws ApexException;