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;
24 import javax.validation.constraints.NotNull;
25 import org.onap.policy.common.capabilities.Lockable;
26 import org.onap.policy.common.im.AllSeemsWellException;
27 import org.onap.policy.common.utils.services.OrderedService;
30 * This interface provides a way to invoke optional features at various points in the code. At
31 * appropriate points in the application, the code iterates through this list, invoking these
32 * optional methods. Most of the methods here are notification only -- these tend to return a 'void'
33 * value. In other cases, such as 'activatePolicySession', may
35 public interface StateManagementFeatureApi extends OrderedService, Lockable {
38 * ALL SEEMS/NOT WELL This interface is used to support the concept of All Seems/Not Well. It
39 * provides a way for client code to indicate to the DroolsPDPIntegrityMonitor that an event has
40 * occurred which is disabling (or enabling) for the Drools PDP. The call is actually
41 * implemented in the common modules IntegrityMonitor where it will cause the testTransaction to
42 * fail if any module has set the value ALLNOTWELL, stopping the forward progress counter and
43 * eventually causing the operational state to become disabled.
45 * <p>ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
46 * method when the client is disabled
48 * @param key - This should be a unique identifier for the entity making the call (e.g., class
50 * @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
51 * @param msg - A message is required. It should indicate why all is not well or a message
52 * indicating that a component has been restored to health (perhaps indicating the
53 * problem that has resolved).
54 * @throws AllSeemsWellException exception
56 public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
57 throws AllSeemsWellException;
60 * This method is called to add an Observer to receive notifications of state changes.
62 * @param stateChangeObserver observer
64 public void addObserver(Observer stateChangeObserver);
67 * Returns the X.731 Administrative State for this resource.
69 * @return String (locked, unlocked)
71 public String getAdminState();
74 * Returns the X.731 Operational State for this resource.
76 * @return String (enabled, disabled)
78 public String getOpState();
81 * Returns the X.731 Availability Status for this resource.
83 * @return String (failed; dependency; dependency,failed)
85 public String getAvailStatus();
88 * Returns the X.731 Standby Status for this resource.
90 * @return String (providingservice, hotstandby or coldstandby)
92 public String getStandbyStatus();
95 * Returns the X.731 Standby Status for the named resource
97 * @param resourceName the resource name
98 * @return String (providingservice, hotstandby or coldstandby)
100 public String getStandbyStatus(String resourceName);
103 * This method moves the X.731 Operational State for the named resource into a value of disabled
104 * and the Availability Status to a value of failed. As a consequence the Standby Status value
105 * will take a value of coldstandby.
107 * @param resourceName resource name
108 * @throws Exception exception
110 public void disableFailed(String resourceName) throws Exception;
113 * This method moves the X.731 Operational State for this resource into a value of disabled and
114 * the Availability Status to a value of failed. As a consequence the Standby Status value will
115 * take a value of coldstandby.
117 * @throws Exception exception
119 public void disableFailed() throws Exception;
122 * This method moves the X.731 Standby Status for this resource from hotstandby to
123 * providingservice. If the current value is coldstandby, no change is made. If the current
124 * value is null, it will move to providingservice assuming the Operational State is enabled and
125 * Administrative State is unlocked.
127 * @throws Exception exception
129 public void promote() throws Exception;
132 * This method moves the X.731 Standby Status for this resource from providingservice to
133 * hotstandby. If the current value is null, it will move to hotstandby assuming the Operational
134 * State is enabled and Administrative State is unlocked. Else, it will move to coldstandby
136 * @throws Exception exception
138 public void demote() throws Exception;
141 * Returns the resourceName associated with this instance of the
142 * StateManagementFeature.
144 * @return String (resourceName)
146 public String getResourceName();
149 * This Lockable method will lock the StateManagement object Admin state.
151 * @return true if successful, false otherwise
154 public boolean lock();
157 * This Lockable method will unlock the StateManagement object Admin state.
159 * @return true if successfull, false otherwise
162 public boolean unlock();
165 * This Lockable method indicates the Admin state StateManagement object.
167 * @return true if locked, false otherwise
170 public boolean isLocked();