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 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;
 
  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',
 
  39 public interface StateManagementFeatureAPI extends OrderedService, Lockable
 
  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;
 
  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;
 
  67           public static final int SEQ_NUM = 0;
 
  69    * 'FeatureAPI.impl.getList()' returns an ordered list of objects
 
  70    * implementing the 'FeatureAPI' interface.
 
  72   static public OrderedServiceImpl<StateManagementFeatureAPI> impl =
 
  73         new OrderedServiceImpl<StateManagementFeatureAPI>(StateManagementFeatureAPI.class);
 
  76    * This method is called to add an Observer to receive notifications of state changes
 
  78    * @param stateChangeObserver
 
  80   public void addObserver(Observer stateChangeObserver);
 
  83    * This method returns the X.731 Administrative State for this resource
 
  85    * @return String (locked, unlocked)
 
  87   public String getAdminState();
 
  90    * This method returns the X.731 Operational State for this resource
 
  92    * @return String (enabled, disabled)
 
  94   public String getOpState();
 
  97    * This method returns the X.731 Availability Status for this resource
 
  99    * @return String (failed; dependency; dependency,failed)
 
 101   public String getAvailStatus();
 
 104    * This method returns the X.731 Standby Status for this resource
 
 106    * @return String (providingservice, hotstandby or coldstandby)
 
 108   public String getStandbyStatus();
 
 111    * This method returns the X.731 Standby Status for the named resource
 
 112    * @param String (resourceName)
 
 113    * @return String (providingservice, hotstandby or coldstandby)
 
 115   public String getStandbyStatus(String resourceName);
 
 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.
 
 122    * @param String (resourceName)
 
 125   public void disableFailed(String resourceName) throws Exception;
 
 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.
 
 132    * @param String (resourceName)
 
 135   public void disableFailed() throws Exception;
 
 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.
 
 143    * @throws StandbyStatusException 
 
 145   public void promote() throws StandbyStatusException, Exception;
 
 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
 
 154   public void demote() throws Exception;
 
 157    * This method returns the resourceName associated with this instance of the StateManagementFeature 
 
 158    * @return String (resourceName)
 
 160   public String getResourceName();
 
 163    * This Lockable method will lock the StateManagement object Admin state
 
 164    * @return true if successfull, false otherwise
 
 167   public boolean lock();
 
 170    * This Lockable method will unlock the StateManagement object Admin state
 
 171    * @return true if successfull, false otherwise
 
 174   public boolean unlock();
 
 177    * This Lockable method indicates the Admin state StateManagement object 
 
 178    * @return true if locked, false otherwise
 
 181   public boolean isLocked();