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.StandbyStatusException;
29 import org.onap.policy.common.im.StateManagement;
30 import org.onap.policy.drools.properties.Lockable;
31 import org.onap.policy.drools.utils.OrderedService;
32 import org.onap.policy.drools.utils.OrderedServiceImpl;
35 * This interface provides a way to invoke optional features at various
36 * points in the code. At appropriate points in the
37 * application, the code iterates through this list, invoking these optional
38 * methods. Most of the methods here are notification only -- these tend to
39 * return a 'void' value. In other cases, such as 'activatePolicySession',
42 public interface StateManagementFeatureAPI extends OrderedService, Lockable
45 public static final String LOCKED = StateManagement.LOCKED;
46 public static final String UNLOCKED = StateManagement.UNLOCKED;
47 public static final String ENABLED = StateManagement.ENABLED;
48 public static final String DISABLED = StateManagement.DISABLED;
49 public static final String ENABLE_NOT_FAILED = StateManagement.ENABLE_NOT_FAILED;
50 public static final String DISABLE_FAILED = StateManagement.DISABLE_FAILED;
51 public static final String FAILED = StateManagement.FAILED;
52 public static final String DEPENDENCY = StateManagement.DEPENDENCY;
53 public static final String DEPENDENCY_FAILED = StateManagement.DEPENDENCY_FAILED;
54 public static final String DISABLE_DEPENDENCY = StateManagement.DISABLE_DEPENDENCY;
55 public static final String ENABLE_NO_DEPENDENCY = StateManagement.ENABLE_NO_DEPENDENCY;
56 public static final String NULL_VALUE = StateManagement.NULL_VALUE;
57 public static final String LOCK = StateManagement.LOCK;
58 public static final String UNLOCK = StateManagement.UNLOCK;
59 public static final String PROMOTE = StateManagement.PROMOTE;
60 public static final String DEMOTE = StateManagement.DEMOTE;
61 public static final String HOT_STANDBY = StateManagement.HOT_STANDBY;
62 public static final String COLD_STANDBY = StateManagement.COLD_STANDBY;
63 public static final String PROVIDING_SERVICE = StateManagement.PROVIDING_SERVICE;
65 public static final String ADMIN_STATE = StateManagement.ADMIN_STATE;
66 public static final String OPERATION_STATE = StateManagement.OPERATION_STATE;
67 public static final String AVAILABLE_STATUS= StateManagement.AVAILABLE_STATUS;
68 public static final String STANDBY_STATUS = StateManagement.STANDBY_STATUS;
70 static public final Boolean ALLSEEMSWELL = Boolean.TRUE;
71 static public final Boolean ALLNOTWELL = Boolean.FALSE;
73 public static final int SEQ_NUM = 0;
75 * 'FeatureAPI.impl.getList()' returns an ordered list of objects
76 * implementing the 'FeatureAPI' interface.
78 public static OrderedServiceImpl<StateManagementFeatureAPI> impl =
79 new OrderedServiceImpl<>(StateManagementFeatureAPI.class);
83 * This interface is used to support the concept of All Seems/Not Well. It provides
84 * a way for client code to indicate to the DroolsPDPIntegrityMonitor that an event
85 * has occurred which is disabling (or enabling) for the Drools PDP. The call is
86 * actually implemented in the common modules IntegrityMonitor where it will cause
87 * the testTransaction to fail if any module has set the value ALLNOTWELL, stopping
88 * the forward progress counter and eventually causing the operational state to
91 * ALLSEEMSWELL is passed to the method when the client is healthy
92 * ALLNOTWELL is passed to the method when the client is disabled
94 * @param key - This should be a unique identifier for the entity making the call (e.g., class name)
95 * @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
96 * @param msg - A message is required. It should indicate why all is not well or a message indicating
97 * that a component has been restored to health (perhaps indicating the problem that has resolved).
98 * @throws IllegalArgumentException
99 * @throws AllSeemsWellException
101 public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
102 throws IllegalArgumentException, AllSeemsWellException;
105 * This method is called to add an Observer to receive notifications of state changes
107 * @param stateChangeObserver
109 public void addObserver(Observer stateChangeObserver);
112 * This method returns the X.731 Administrative State for this resource
114 * @return String (locked, unlocked)
116 public String getAdminState();
119 * This method returns the X.731 Operational State for this resource
121 * @return String (enabled, disabled)
123 public String getOpState();
126 * This method returns the X.731 Availability Status for this resource
128 * @return String (failed; dependency; dependency,failed)
130 public String getAvailStatus();
133 * This method returns the X.731 Standby Status for this resource
135 * @return String (providingservice, hotstandby or coldstandby)
137 public String getStandbyStatus();
140 * This method returns the X.731 Standby Status for the named resource
141 * @param String (resourceName)
142 * @return String (providingservice, hotstandby or coldstandby)
144 public String getStandbyStatus(String resourceName);
147 * This method moves the X.731 Operational State for the named resource
148 * into a value of disabled and the Availability Status to a value of failed.
149 * As a consequence the Standby Status value will take a value of coldstandby.
151 * @param String (resourceName)
154 public void disableFailed(String resourceName) throws Exception;
157 * This method moves the X.731 Operational State for this resource
158 * into a value of disabled and the Availability Status to a value of failed.
159 * As a consequence the Standby Status value will take a value of coldstandby.
161 * @param String (resourceName)
164 public void disableFailed() throws Exception;
167 * This method moves the X.731 Standby Status for this resource from hotstandby
168 * to providingservice. If the current value is coldstandby, no change is made.
169 * If the current value is null, it will move to providingservice assuming the
170 * Operational State is enabled and Administrative State is unlocked.
172 * @throws StandbyStatusException
174 public void promote() throws StandbyStatusException, Exception;
177 * This method moves the X.731 Standby Status for this resource from providingservice
178 * to hotstandby. If the current value is null, it will move to hotstandby assuming the
179 * Operational State is enabled and Administrative State is unlocked. Else, it will move
183 public void demote() throws Exception;
186 * This method returns the resourceName associated with this instance of the StateManagementFeature
187 * @return String (resourceName)
189 public String getResourceName();
192 * This Lockable method will lock the StateManagement object Admin state
193 * @return true if successfull, false otherwise
196 public boolean lock();
199 * This Lockable method will unlock the StateManagement object Admin state
200 * @return true if successfull, false otherwise
203 public boolean unlock();
206 * This Lockable method indicates the Admin state StateManagement object
207 * @return true if locked, false otherwise
210 public boolean isLocked();