107b207e7082677e542c84ed45001ca71c34c1da
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-core
4  * ================================================================================
5  * Copyright (C) 2017 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.im.AllSeemsWellException;
28 import org.onap.policy.common.im.StateManagement;
29 import org.onap.policy.drools.properties.Lockable;
30 import org.onap.policy.drools.utils.OrderedService;
31 import org.onap.policy.drools.utils.OrderedServiceImpl;
32
33 /**
34  * This interface provides a way to invoke optional features at various
35  * points in the code. At appropriate points in the
36  * application, the code iterates through this list, invoking these optional
37  * methods. Most of the methods here are notification only -- these tend to
38  * return a 'void' value. In other cases, such as 'activatePolicySession',
39  * may 
40  */
41 public interface StateManagementFeatureAPI extends OrderedService, Lockable
42 {
43         
44           public static final String LOCKED               = StateManagement.LOCKED;
45           public static final String UNLOCKED             = StateManagement.UNLOCKED;
46           public static final String ENABLED              = StateManagement.ENABLED;
47           public static final String DISABLED             = StateManagement.DISABLED;
48           public static final String ENABLE_NOT_FAILED    = StateManagement.ENABLE_NOT_FAILED;
49           public static final String DISABLE_FAILED       = StateManagement.DISABLE_FAILED;
50           public static final String FAILED               = StateManagement.FAILED;
51           public static final String DEPENDENCY           = StateManagement.DEPENDENCY;
52           public static final String DEPENDENCY_FAILED    = StateManagement.DEPENDENCY_FAILED;
53           public static final String DISABLE_DEPENDENCY   = StateManagement.DISABLE_DEPENDENCY;
54           public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY;
55           public static final String NULL_VALUE           = StateManagement.NULL_VALUE;
56           public static final String DO_LOCK              = StateManagement.LOCK;
57           public static final String DO_UNLOCK            = StateManagement.UNLOCK;
58           public static final String DO_PROMOTE           = StateManagement.PROMOTE;
59           public static final String DO_DEMOTE            = StateManagement.DEMOTE;
60           public static final String HOT_STANDBY          = StateManagement.HOT_STANDBY;
61           public static final String COLD_STANDBY         = StateManagement.COLD_STANDBY;
62           public static final String PROVIDING_SERVICE    = StateManagement.PROVIDING_SERVICE;
63           
64           public static final String ADMIN_STATE     = StateManagement.ADMIN_STATE;
65           public static final String OPERATION_STATE = StateManagement.OPERATION_STATE;
66           public static final String AVAILABLE_STATUS= StateManagement.AVAILABLE_STATUS;
67           public static final String STANDBY_STATUS  = StateManagement.STANDBY_STATUS;
68           
69           public static final Boolean ALLSEEMSWELL_STATE  = Boolean.TRUE;
70           public static final Boolean ALLNOTWELL_STATE    = Boolean.FALSE;
71           
72           public static final int SEQ_NUM = 0;
73   /**
74    * 'FeatureAPI.impl.getList()' returns an ordered list of objects
75    * implementing the 'FeatureAPI' interface.
76    */
77   public static OrderedServiceImpl<StateManagementFeatureAPI> impl =
78         new OrderedServiceImpl<>(StateManagementFeatureAPI.class);
79
80   /**
81    * ALL SEEMS/NOT WELL
82    * This interface is used to support the concept of All Seems/Not Well.  It provides
83    * a way for client code to indicate to the DroolsPDPIntegrityMonitor that an event 
84    * has occurred which is disabling (or enabling) for the Drools PDP.  The call is
85    * actually implemented in the common modules IntegrityMonitor where it will cause
86    * the testTransaction to fail if any module has set the value ALLNOTWELL, stopping
87    * the forward progress counter and eventually causing the operational state to 
88    * become disabled.
89    * 
90    * ALLSEEMSWELL is passed to the method when the client is healthy
91    * ALLNOTWELL is passed to the method when the client is disabled
92    * 
93    * @param key - This should be a unique identifier for the entity making the call (e.g., class name)
94    * @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
95    * @param msg - A message is required.  It should indicate why all is not well or a message indicating
96    * that a component has been restored to health (perhaps indicating the problem that has resolved).
97    * @throws AllSeemsWellException
98    */
99   public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
100                   throws AllSeemsWellException;
101   
102   /**
103    * This method is called to add an Observer to receive notifications of state changes
104    * 
105    * @param stateChangeObserver
106    */
107   public void addObserver(Observer stateChangeObserver);
108
109   /**
110    * This method returns the X.731 Administrative State for this resource
111    * 
112    * @return String (locked, unlocked)
113    */
114   public String getAdminState();
115   
116   /**
117    * This method returns the X.731 Operational State for this resource
118    * 
119    * @return String (enabled, disabled)
120    */
121   public String getOpState();
122   
123   /**
124    * This method returns the X.731 Availability Status for this resource
125    * 
126    * @return String (failed; dependency; dependency,failed)
127    */
128   public String getAvailStatus();
129     
130   /**
131    * This method returns the X.731 Standby Status for this resource
132    * 
133    * @return String (providingservice, hotstandby or coldstandby)
134    */
135   public String getStandbyStatus();
136   
137   /**
138    * This method returns the X.731 Standby Status for the named resource
139    * @param String (resourceName)
140    * @return String (providingservice, hotstandby or coldstandby)
141    */
142   public String getStandbyStatus(String resourceName);
143   
144   /**
145    * This method moves the X.731 Operational State for the named resource
146    * into a value of disabled and the Availability Status to a value of failed.
147    * As a consequence the Standby Status value will take a value of coldstandby.
148    * 
149    * @param String (resourceName)
150    * @throws Exception 
151    */
152   public void disableFailed(String resourceName) throws Exception;
153   
154   /**
155    * This method moves the X.731 Operational State for this resource
156    * into a value of disabled and the Availability Status to a value of failed.
157    * As a consequence the Standby Status value will take a value of coldstandby.
158    * 
159    * @param String (resourceName)
160    * @throws Exception 
161    */
162   public void disableFailed() throws Exception;
163   
164   /**
165    * This method moves the X.731 Standby Status for this resource from hotstandby 
166    * to providingservice. If the current value is coldstandby, no change is made.
167    * If the current value is null, it will move to providingservice assuming the
168    * Operational State is enabled and Administrative State is unlocked.
169    * @throws Exception  
170    */
171   public void promote() throws Exception;
172   
173   /**
174    * This method moves the X.731 Standby Status for this resource from providingservice 
175    * to hotstandby. If the current value is null, it will move to hotstandby assuming the
176    * Operational State is enabled and Administrative State is unlocked. Else, it will move
177    * to coldstandby
178    * @throws Exception 
179    */
180   public void demote() throws Exception;
181   
182   /**
183    * This method returns the resourceName associated with this instance of the StateManagementFeature 
184    * @return String (resourceName)
185    */
186   public String getResourceName();
187
188   /**
189    * This Lockable method will lock the StateManagement object Admin state
190    * @return true if successfull, false otherwise
191    */
192   @Override
193   public boolean lock();
194   
195   /**
196    * This Lockable method will unlock the StateManagement object Admin state
197    * @return true if successfull, false otherwise
198    */
199   @Override
200   public boolean unlock();
201
202   /**
203    * This Lockable method indicates the Admin state StateManagement object 
204    * @return true if locked, false otherwise
205    */
206   @Override
207   public boolean isLocked();
208 }