a6d808ca6d71379192e29f762610107a3772e43f
[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 org.onap.policy.common.im.StandbyStatusException;
26 import org.onap.policy.common.im.StateManagement;
27 import org.onap.policy.drools.properties.Lockable;
28 import org.onap.policy.drools.utils.OrderedService;
29 import org.onap.policy.drools.utils.OrderedServiceImpl;
30
31 /**
32  * This interface provides a way to invoke optional features at various
33  * points in the code. At appropriate points in the
34  * application, the code iterates through this list, invoking these optional
35  * methods. Most of the methods here are notification only -- these tend to
36  * return a 'void' value. In other cases, such as 'activatePolicySession',
37  * may 
38  */
39 public interface StateManagementFeatureAPI extends OrderedService, Lockable
40 {
41         
42         public static final String LOCKED               = StateManagement.LOCKED;
43           public static final String UNLOCKED             = StateManagement.UNLOCKED;
44           public static final String ENABLED              = StateManagement.ENABLED;
45           public static final String DISABLED             = StateManagement.DISABLED;
46           public static final String ENABLE_NOT_FAILED    = StateManagement.ENABLE_NOT_FAILED;
47           public static final String DISABLE_FAILED       = StateManagement.DISABLE_FAILED;
48           public static final String FAILED               = StateManagement.FAILED;
49           public static final String DEPENDENCY           = StateManagement.DEPENDENCY;
50           public static final String DEPENDENCY_FAILED    = StateManagement.DEPENDENCY_FAILED;
51           public static final String DISABLE_DEPENDENCY   = StateManagement.DISABLE_DEPENDENCY;
52           public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY;
53           public static final String NULL_VALUE           = StateManagement.NULL_VALUE;
54           public static final String LOCK                 = StateManagement.LOCK;
55           public static final String UNLOCK               = StateManagement.UNLOCK;
56           public static final String PROMOTE              = StateManagement.PROMOTE;
57           public static final String DEMOTE               = StateManagement.DEMOTE;
58           public static final String HOT_STANDBY          = StateManagement.HOT_STANDBY;
59           public static final String COLD_STANDBY         = StateManagement.COLD_STANDBY;
60           public static final String PROVIDING_SERVICE    = StateManagement.PROVIDING_SERVICE;
61           
62           public static final String ADMIN_STATE     = StateManagement.ADMIN_STATE;
63           public static final String OPERATION_STATE = StateManagement.OPERATION_STATE;
64           public static final String AVAILABLE_STATUS= StateManagement.AVAILABLE_STATUS;
65           public static final String STANDBY_STATUS  = StateManagement.STANDBY_STATUS;
66           
67           public static final int SEQ_NUM = 0;
68   /**
69    * 'FeatureAPI.impl.getList()' returns an ordered list of objects
70    * implementing the 'FeatureAPI' interface.
71    */
72   static public OrderedServiceImpl<StateManagementFeatureAPI> impl =
73         new OrderedServiceImpl<StateManagementFeatureAPI>(StateManagementFeatureAPI.class);
74
75   /**
76    * This method is called to add an Observer to receive notifications of state changes
77    * 
78    * @param stateChangeObserver
79    */
80   public void addObserver(Observer stateChangeObserver);
81
82   /**
83    * This method returns the X.731 Administrative State for this resource
84    * 
85    * @return String (locked, unlocked)
86    */
87   public String getAdminState();
88   
89   /**
90    * This method returns the X.731 Operational State for this resource
91    * 
92    * @return String (enabled, disabled)
93    */
94   public String getOpState();
95   
96   /**
97    * This method returns the X.731 Availability Status for this resource
98    * 
99    * @return String (failed; dependency; dependency,failed)
100    */
101   public String getAvailStatus();
102     
103   /**
104    * This method returns the X.731 Standby Status for this resource
105    * 
106    * @return String (providingservice, hotstandby or coldstandby)
107    */
108   public String getStandbyStatus();
109   
110   /**
111    * This method returns the X.731 Standby Status for the named resource
112    * @param String (resourceName)
113    * @return String (providingservice, hotstandby or coldstandby)
114    */
115   public String getStandbyStatus(String resourceName);
116   
117   /**
118    * This method moves the X.731 Operational State for the named resource
119    * into a value of disabled and the Availability Status to a value of failed.
120    * As a consequence the Standby Status value will take a value of coldstandby.
121    * 
122    * @param String (resourceName)
123    * @throws Exception 
124    */
125   public void disableFailed(String resourceName) throws Exception;
126   
127   /**
128    * This method moves the X.731 Operational State for this resource
129    * into a value of disabled and the Availability Status to a value of failed.
130    * As a consequence the Standby Status value will take a value of coldstandby.
131    * 
132    * @param String (resourceName)
133    * @throws Exception 
134    */
135   public void disableFailed() throws Exception;
136   
137   /**
138    * This method moves the X.731 Standby Status for this resource from hotstandby 
139    * to providingservice. If the current value is coldstandby, no change is made.
140    * If the current value is null, it will move to providingservice assuming the
141    * Operational State is enabled and Administrative State is unlocked.
142    * @throws Exception 
143    * @throws StandbyStatusException 
144    */
145   public void promote() throws StandbyStatusException, Exception;
146   
147   /**
148    * This method moves the X.731 Standby Status for this resource from providingservice 
149    * to hotstandby. If the current value is null, it will move to hotstandby assuming the
150    * Operational State is enabled and Administrative State is unlocked. Else, it will move
151    * to coldstandby
152    * @throws Exception 
153    */
154   public void demote() throws Exception;
155   
156   /**
157    * This method returns the resourceName associated with this instance of the StateManagementFeature 
158    * @return String (resourceName)
159    */
160   public String getResourceName();
161
162   /**
163    * This Lockable method will lock the StateManagement object Admin state
164    * @return true if successfull, false otherwise
165    */
166   @Override
167   public boolean lock();
168   
169   /**
170    * This Lockable method will unlock the StateManagement object Admin state
171    * @return true if successfull, false otherwise
172    */
173   @Override
174   public boolean unlock();
175
176   /**
177    * This Lockable method indicates the Admin state StateManagement object 
178    * @return true if locked, false otherwise
179    */
180   @Override
181   public boolean isLocked();
182 }