2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.drools.statemanagement;
23 import javax.validation.constraints.NotNull;
24 import org.onap.policy.common.capabilities.Lockable;
25 import org.onap.policy.common.im.AllSeemsWellException;
26 import org.onap.policy.common.im.IntegrityMonitorException;
27 import org.onap.policy.common.im.StateChangeNotifier;
28 import org.onap.policy.common.im.StateManagementException;
29 import org.onap.policy.common.utils.services.OrderedService;
32 * This interface provides a way to invoke optional features at various points in the code. At
33 * appropriate points in the application, the code iterates through this list, invoking these
34 * optional methods. Most of the methods here are notification only -- these tend to return a 'void'
35 * value. In other cases, such as 'activatePolicySession', may
37 public interface StateManagementFeatureApi extends OrderedService, Lockable {
40 * ALL SEEMS/NOT WELL This interface is used to support the concept of All Seems/Not Well. It
41 * provides a way for client code to indicate to the DroolsPDPIntegrityMonitor that an event has
42 * occurred which is disabling (or enabling) for the Drools PDP. The call is actually
43 * implemented in the common modules IntegrityMonitor where it will cause the testTransaction to
44 * fail if any module has set the value ALLNOTWELL, stopping the forward progress counter and
45 * eventually causing the operational state to become disabled.
47 * <p>ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
48 * method when the client is disabled
50 * @param key - This should be a unique identifier for the entity making the call (e.g., class
52 * @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
53 * @param msg - A message is required. It should indicate why all is not well or a message
54 * indicating that a component has been restored to health (perhaps indicating the
55 * problem that has resolved).
56 * @throws AllSeemsWellException exception
58 void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
59 throws AllSeemsWellException;
62 * This method is called to add an Observer to receive notifications of state changes.
64 * @param stateChangeObserver observer
66 void addObserver(StateChangeNotifier stateChangeObserver);
69 * Returns the X.731 Administrative State for this resource.
71 * @return String (locked, unlocked)
73 String getAdminState();
76 * Returns the X.731 Operational State for this resource.
78 * @return String (enabled, disabled)
83 * Returns the X.731 Availability Status for this resource.
85 * @return String (failed; dependency; dependency,failed)
87 String getAvailStatus();
90 * Returns the X.731 Standby Status for this resource.
92 * @return String (providingservice, hotstandby or coldstandby)
94 String getStandbyStatus();
97 * Returns the X.731 Standby Status for the named resource
99 * @param resourceName the resource name
100 * @return String (providingservice, hotstandby or coldstandby)
102 String getStandbyStatus(String resourceName);
105 * This method moves the X.731 Operational State for the named resource into a value of disabled
106 * and the Availability Status to a value of failed. As a consequence the Standby Status value
107 * will take a value of coldstandby.
109 * @param resourceName resource name
110 * @throws StateManagementException exception
112 void disableFailed(String resourceName) throws StateManagementException;
115 * This method moves the X.731 Operational State for this resource into a value of disabled and
116 * the Availability Status to a value of failed. As a consequence the Standby Status value will
117 * take a value of coldstandby.
119 * @throws StateManagementException exception
121 void disableFailed() throws StateManagementException;
124 * This method moves the X.731 Standby Status for this resource from hotstandby to
125 * providingservice. If the current value is coldstandby, no change is made. If the current
126 * value is null, it will move to providingservice assuming the Operational State is enabled and
127 * Administrative State is unlocked.
129 * @throws IntegrityMonitorException exception
131 void promote() throws IntegrityMonitorException;
134 * This method moves the X.731 Standby Status for this resource from providingservice to
135 * hotstandby. If the current value is null, it will move to hotstandby assuming the Operational
136 * State is enabled and Administrative State is unlocked. Else, it will move to coldstandby
138 * @throws StateManagementException exception
140 void demote() throws StateManagementException;
143 * Returns the resourceName associated with this instance of the
144 * StateManagementFeature.
146 * @return String (resourceName)
148 String getResourceName();
151 * This Lockable method will lock the StateManagement object Admin state.
153 * @return true if successful, false otherwise
159 * This Lockable method will unlock the StateManagement object Admin state.
161 * @return true if successfull, false otherwise
167 * This Lockable method indicates the Admin state StateManagement object.
169 * @return true if locked, false otherwise