c4ba8622fa9b0fcebd16e4ed4c7d6839fa4da28b
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-core
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.drools.statemanagement;
22
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;
30
31 /**
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
36  */
37 public interface StateManagementFeatureApi extends OrderedService, Lockable {
38
39     /**
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.
46      *
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
49      *
50      * @param key - This should be a unique identifier for the entity making the call (e.g., class
51      *        name)
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
57      */
58     void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
59             throws AllSeemsWellException;
60
61     /**
62      * This method is called to add an Observer to receive notifications of state changes.
63      *
64      * @param stateChangeObserver observer
65      */
66     void addObserver(StateChangeNotifier stateChangeObserver);
67
68     /**
69      * Returns the X.731 Administrative State for this resource.
70      *
71      * @return String (locked, unlocked)
72      */
73     String getAdminState();
74
75     /**
76      * Returns the X.731 Operational State for this resource.
77      *
78      * @return String (enabled, disabled)
79      */
80     String getOpState();
81
82     /**
83      * Returns the X.731 Availability Status for this resource.
84      *
85      * @return String (failed; dependency; dependency,failed)
86      */
87     String getAvailStatus();
88
89     /**
90      * Returns the X.731 Standby Status for this resource.
91      *
92      * @return String (providingservice, hotstandby or coldstandby)
93      */
94     String getStandbyStatus();
95
96     /**
97      * Returns the X.731 Standby Status for the named resource
98      *
99      * @param resourceName the resource name
100      * @return String (providingservice, hotstandby or coldstandby)
101      */
102     String getStandbyStatus(String resourceName);
103
104     /**
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.
108      *
109      * @param resourceName resource name
110      * @throws StateManagementException exception
111      */
112     void disableFailed(String resourceName) throws StateManagementException;
113
114     /**
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.
118      *
119      * @throws StateManagementException exception
120      */
121     void disableFailed() throws StateManagementException;
122
123     /**
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.
128      *
129      * @throws IntegrityMonitorException exception
130      */
131     void promote() throws IntegrityMonitorException;
132
133     /**
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
137      *
138      * @throws StateManagementException exception
139      */
140     void demote() throws StateManagementException;
141
142     /**
143      * Returns the resourceName associated with this instance of the
144      * StateManagementFeature.
145      *
146      * @return String (resourceName)
147      */
148     String getResourceName();
149
150     /**
151      * This Lockable method will lock the StateManagement object Admin state.
152      *
153      * @return true if successful, false otherwise
154      */
155     @Override
156     boolean lock();
157
158     /**
159      * This Lockable method will unlock the StateManagement object Admin state.
160      *
161      * @return true if successfull, false otherwise
162      */
163     @Override
164     boolean unlock();
165
166     /**
167      * This Lockable method indicates the Admin state StateManagement object.
168      *
169      * @return true if locked, false otherwise
170      */
171     @Override
172     boolean isLocked();
173 }