049b2643375711d2156c452a99a0e7b4ed727c91
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-core
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
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 java.util.Observer;
24
25 import javax.validation.constraints.NotNull;
26
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;
32
33 /**
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
38  */
39 public interface StateManagementFeatureAPI extends OrderedService, Lockable {
40
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_ACTION;
46     public static final String DISABLE_FAILED = StateManagement.DISABLE_FAILED_ACTION;
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_ACTION;
51     public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY_ACTION;
52     public static final String NULL_VALUE = StateManagement.NULL_VALUE;
53     public static final String DO_LOCK = StateManagement.LOCK_ACTION;
54     public static final String DO_UNLOCK = StateManagement.UNLOCK_ACTION;
55     public static final String DO_PROMOTE = StateManagement.PROMOTE_ACTION;
56     public static final String DO_DEMOTE = StateManagement.DEMOTE_ACTION;
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;
60
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;
65
66     public static final Boolean ALLSEEMSWELL_STATE = Boolean.TRUE;
67     public static final Boolean ALLNOTWELL_STATE = Boolean.FALSE;
68
69     public static final int SEQ_NUM = 0;
70     /**
71      * 'FeatureAPI.impl.getList()' returns an ordered list of objects implementing the 'FeatureAPI'
72      * interface.
73      */
74     public static OrderedServiceImpl<StateManagementFeatureAPI> impl =
75             new OrderedServiceImpl<>(StateManagementFeatureAPI.class);
76
77     /**
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.
84      *
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
87      *
88      * @param key - This should be a unique identifier for the entity making the call (e.g., class
89      *        name)
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
95      */
96     public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
97             throws AllSeemsWellException;
98
99     /**
100      * This method is called to add an Observer to receive notifications of state changes.
101      *
102      * @param stateChangeObserver observer
103      */
104     public void addObserver(Observer stateChangeObserver);
105
106     /**
107      * Returns the X.731 Administrative State for this resource.
108      *
109      * @return String (locked, unlocked)
110      */
111     public String getAdminState();
112
113     /**
114      * Returns the X.731 Operational State for this resource.
115      *
116      * @return String (enabled, disabled)
117      */
118     public String getOpState();
119
120     /**
121      * Returns the X.731 Availability Status for this resource.
122      *
123      * @return String (failed; dependency; dependency,failed)
124      */
125     public String getAvailStatus();
126
127     /**
128      * Returns the X.731 Standby Status for this resource.
129      *
130      * @return String (providingservice, hotstandby or coldstandby)
131      */
132     public String getStandbyStatus();
133
134     /**
135      * Returns the X.731 Standby Status for the named resource
136      *
137      * @param String (resourceName)
138      * @return String (providingservice, hotstandby or coldstandby)
139      */
140     public String getStandbyStatus(String resourceName);
141
142     /**
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.
146      *
147      * @param resourceName resource name
148      * @throws Exception exception
149      */
150     public void disableFailed(String resourceName) throws Exception;
151
152     /**
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.
156      *
157      * @throws Exception exception
158      */
159     public void disableFailed() throws Exception;
160
161     /**
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.
166      *
167      * @throws Exception exception
168      */
169     public void promote() throws Exception;
170
171     /**
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
175      *
176      * @throws Exception exception
177      */
178     public void demote() throws Exception;
179
180     /**
181      * Returns the resourceName associated with this instance of the
182      * StateManagementFeature.
183      *
184      * @return String (resourceName)
185      */
186     public String getResourceName();
187
188     /**
189      * This Lockable method will lock the StateManagement object Admin state.
190      *
191      * @return true if successful, false otherwise
192      */
193     @Override
194     public boolean lock();
195
196     /**
197      * This Lockable method will unlock the StateManagement object Admin state.
198      *
199      * @return true if successfull, false otherwise
200      */
201     @Override
202     public boolean unlock();
203
204     /**
205      * This Lockable method indicates the Admin state StateManagement object.
206      *
207      * @return true if locked, false otherwise
208      */
209     @Override
210     public boolean isLocked();
211 }