2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.drools.statemanagement;
23 import java.util.Observer;
25 import javax.validation.constraints.NotNull;
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;
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',
41 public interface StateManagementFeatureAPI extends OrderedService, Lockable
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;
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;
69 public static final Boolean ALLSEEMSWELL_STATE = Boolean.TRUE;
70 public static final Boolean ALLNOTWELL_STATE = Boolean.FALSE;
72 public static final int SEQ_NUM = 0;
74 * 'FeatureAPI.impl.getList()' returns an ordered list of objects
75 * implementing the 'FeatureAPI' interface.
77 public static OrderedServiceImpl<StateManagementFeatureAPI> impl =
78 new OrderedServiceImpl<>(StateManagementFeatureAPI.class);
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
90 * ALLSEEMSWELL is passed to the method when the client is healthy
91 * ALLNOTWELL is passed to the method when the client is disabled
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
99 public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
100 throws AllSeemsWellException;
103 * This method is called to add an Observer to receive notifications of state changes
105 * @param stateChangeObserver
107 public void addObserver(Observer stateChangeObserver);
110 * This method returns the X.731 Administrative State for this resource
112 * @return String (locked, unlocked)
114 public String getAdminState();
117 * This method returns the X.731 Operational State for this resource
119 * @return String (enabled, disabled)
121 public String getOpState();
124 * This method returns the X.731 Availability Status for this resource
126 * @return String (failed; dependency; dependency,failed)
128 public String getAvailStatus();
131 * This method returns the X.731 Standby Status for this resource
133 * @return String (providingservice, hotstandby or coldstandby)
135 public String getStandbyStatus();
138 * This method returns the X.731 Standby Status for the named resource
139 * @param String (resourceName)
140 * @return String (providingservice, hotstandby or coldstandby)
142 public String getStandbyStatus(String resourceName);
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.
149 * @param String (resourceName)
152 public void disableFailed(String resourceName) throws Exception;
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.
159 * @param String (resourceName)
162 public void disableFailed() throws Exception;
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.
171 public void promote() throws Exception;
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
180 public void demote() throws Exception;
183 * This method returns the resourceName associated with this instance of the StateManagementFeature
184 * @return String (resourceName)
186 public String getResourceName();
189 * This Lockable method will lock the StateManagement object Admin state
190 * @return true if successfull, false otherwise
193 public boolean lock();
196 * This Lockable method will unlock the StateManagement object Admin state
197 * @return true if successfull, false otherwise
200 public boolean unlock();
203 * This Lockable method indicates the Admin state StateManagement object
204 * @return true if locked, false otherwise
207 public boolean isLocked();