2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 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 java.util.Observer;
25 import javax.validation.constraints.NotNull;
27 import org.onap.policy.common.capabilities.Lockable;
28 import org.onap.policy.common.im.AllSeemsWellException;
29 import org.onap.policy.common.im.StateManagement;
30 import org.onap.policy.common.utils.services.OrderedService;
31 import org.onap.policy.common.utils.services.OrderedServiceImpl;
34 * This interface provides a way to invoke optional features at various points in the code. At
35 * appropriate points in the application, the code iterates through this list, invoking these
36 * optional methods. Most of the methods here are notification only -- these tend to return a 'void'
37 * value. In other cases, such as 'activatePolicySession', may
39 public interface StateManagementFeatureAPI extends OrderedService, Lockable {
41 public static final String LOCKED = StateManagement.LOCKED;
42 public static final String UNLOCKED = StateManagement.UNLOCKED;
43 public static final String ENABLED = StateManagement.ENABLED;
44 public static final String DISABLED = StateManagement.DISABLED;
45 public static final String ENABLE_NOT_FAILED = StateManagement.ENABLE_NOT_FAILED;
46 public static final String DISABLE_FAILED = StateManagement.DISABLE_FAILED;
47 public static final String FAILED = StateManagement.FAILED;
48 public static final String DEPENDENCY = StateManagement.DEPENDENCY;
49 public static final String DEPENDENCY_FAILED = StateManagement.DEPENDENCY_FAILED;
50 public static final String DISABLE_DEPENDENCY = StateManagement.DISABLE_DEPENDENCY;
51 public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY;
52 public static final String NULL_VALUE = StateManagement.NULL_VALUE;
53 public static final String DO_LOCK = StateManagement.LOCK;
54 public static final String DO_UNLOCK = StateManagement.UNLOCK;
55 public static final String DO_PROMOTE = StateManagement.PROMOTE;
56 public static final String DO_DEMOTE = StateManagement.DEMOTE;
57 public static final String HOT_STANDBY = StateManagement.HOT_STANDBY;
58 public static final String COLD_STANDBY = StateManagement.COLD_STANDBY;
59 public static final String PROVIDING_SERVICE = StateManagement.PROVIDING_SERVICE;
61 public static final String ADMIN_STATE = StateManagement.ADMIN_STATE;
62 public static final String OPERATION_STATE = StateManagement.OPERATION_STATE;
63 public static final String AVAILABLE_STATUS = StateManagement.AVAILABLE_STATUS;
64 public static final String STANDBY_STATUS = StateManagement.STANDBY_STATUS;
66 public static final Boolean ALLSEEMSWELL_STATE = Boolean.TRUE;
67 public static final Boolean ALLNOTWELL_STATE = Boolean.FALSE;
69 public static final int SEQ_NUM = 0;
71 * 'FeatureAPI.impl.getList()' returns an ordered list of objects implementing the 'FeatureAPI'
74 public static OrderedServiceImpl<StateManagementFeatureAPI> impl =
75 new OrderedServiceImpl<>(StateManagementFeatureAPI.class);
78 * ALL SEEMS/NOT WELL This interface is used to support the concept of All Seems/Not Well. It
79 * provides a way for client code to indicate to the DroolsPDPIntegrityMonitor that an event has
80 * occurred which is disabling (or enabling) for the Drools PDP. The call is actually
81 * implemented in the common modules IntegrityMonitor where it will cause the testTransaction to
82 * fail if any module has set the value ALLNOTWELL, stopping the forward progress counter and
83 * eventually causing the operational state to become disabled.
85 * <p>ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
86 * method when the client is disabled
88 * @param key - This should be a unique identifier for the entity making the call (e.g., class
90 * @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
91 * @param msg - A message is required. It should indicate why all is not well or a message
92 * indicating that a component has been restored to health (perhaps indicating the
93 * problem that has resolved).
94 * @throws AllSeemsWellException exception
96 public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
97 throws AllSeemsWellException;
100 * This method is called to add an Observer to receive notifications of state changes.
102 * @param stateChangeObserver observer
104 public void addObserver(Observer stateChangeObserver);
107 * Returns the X.731 Administrative State for this resource.
109 * @return String (locked, unlocked)
111 public String getAdminState();
114 * Returns the X.731 Operational State for this resource.
116 * @return String (enabled, disabled)
118 public String getOpState();
121 * Returns the X.731 Availability Status for this resource.
123 * @return String (failed; dependency; dependency,failed)
125 public String getAvailStatus();
128 * Returns the X.731 Standby Status for this resource.
130 * @return String (providingservice, hotstandby or coldstandby)
132 public String getStandbyStatus();
135 * Returns the X.731 Standby Status for the named resource
137 * @param String (resourceName)
138 * @return String (providingservice, hotstandby or coldstandby)
140 public String getStandbyStatus(String resourceName);
143 * This method moves the X.731 Operational State for the named resource into a value of disabled
144 * and the Availability Status to a value of failed. As a consequence the Standby Status value
145 * will take a value of coldstandby.
147 * @param resourceName resource name
148 * @throws Exception exception
150 public void disableFailed(String resourceName) throws Exception;
153 * This method moves the X.731 Operational State for this resource into a value of disabled and
154 * the Availability Status to a value of failed. As a consequence the Standby Status value will
155 * take a value of coldstandby.
157 * @throws Exception exception
159 public void disableFailed() throws Exception;
162 * This method moves the X.731 Standby Status for this resource from hotstandby to
163 * providingservice. If the current value is coldstandby, no change is made. If the current
164 * value is null, it will move to providingservice assuming the Operational State is enabled and
165 * Administrative State is unlocked.
167 * @throws Exception exception
169 public void promote() throws Exception;
172 * This method moves the X.731 Standby Status for this resource from providingservice to
173 * hotstandby. If the current value is null, it will move to hotstandby assuming the Operational
174 * State is enabled and Administrative State is unlocked. Else, it will move to coldstandby
176 * @throws Exception exception
178 public void demote() throws Exception;
181 * Returns the resourceName associated with this instance of the
182 * StateManagementFeature.
184 * @return String (resourceName)
186 public String getResourceName();
189 * This Lockable method will lock the StateManagement object Admin state.
191 * @return true if successful, false otherwise
194 public boolean lock();
197 * This Lockable method will unlock the StateManagement object Admin state.
199 * @return true if successfull, false otherwise
202 public boolean unlock();
205 * This Lockable method indicates the Admin state StateManagement object.
207 * @return true if locked, false otherwise
210 public boolean isLocked();