d2c7b390d1d5c85da055890c13a316aa08edab28
[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 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;
28
29 /**
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
34  */
35 public interface StateManagementFeatureApi extends OrderedService, Lockable {
36
37     /**
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.
44      *
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
47      *
48      * @param key - This should be a unique identifier for the entity making the call (e.g., class
49      *        name)
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
55      */
56     public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
57             throws AllSeemsWellException;
58
59     /**
60      * This method is called to add an Observer to receive notifications of state changes.
61      *
62      * @param stateChangeObserver observer
63      */
64     public void addObserver(Observer stateChangeObserver);
65
66     /**
67      * Returns the X.731 Administrative State for this resource.
68      *
69      * @return String (locked, unlocked)
70      */
71     public String getAdminState();
72
73     /**
74      * Returns the X.731 Operational State for this resource.
75      *
76      * @return String (enabled, disabled)
77      */
78     public String getOpState();
79
80     /**
81      * Returns the X.731 Availability Status for this resource.
82      *
83      * @return String (failed; dependency; dependency,failed)
84      */
85     public String getAvailStatus();
86
87     /**
88      * Returns the X.731 Standby Status for this resource.
89      *
90      * @return String (providingservice, hotstandby or coldstandby)
91      */
92     public String getStandbyStatus();
93
94     /**
95      * Returns the X.731 Standby Status for the named resource
96      *
97      * @param resourceName the resource name
98      * @return String (providingservice, hotstandby or coldstandby)
99      */
100     public String getStandbyStatus(String resourceName);
101
102     /**
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.
106      *
107      * @param resourceName resource name
108      * @throws Exception exception
109      */
110     public void disableFailed(String resourceName) throws Exception;
111
112     /**
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.
116      *
117      * @throws Exception exception
118      */
119     public void disableFailed() throws Exception;
120
121     /**
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.
126      *
127      * @throws Exception exception
128      */
129     public void promote() throws Exception;
130
131     /**
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
135      *
136      * @throws Exception exception
137      */
138     public void demote() throws Exception;
139
140     /**
141      * Returns the resourceName associated with this instance of the
142      * StateManagementFeature.
143      *
144      * @return String (resourceName)
145      */
146     public String getResourceName();
147
148     /**
149      * This Lockable method will lock the StateManagement object Admin state.
150      *
151      * @return true if successful, false otherwise
152      */
153     @Override
154     public boolean lock();
155
156     /**
157      * This Lockable method will unlock the StateManagement object Admin state.
158      *
159      * @return true if successfull, false otherwise
160      */
161     @Override
162     public boolean unlock();
163
164     /**
165      * This Lockable method indicates the Admin state StateManagement object.
166      *
167      * @return true if locked, false otherwise
168      */
169     @Override
170     public boolean isLocked();
171 }