blob: a7c3fb97b144043c753c3d4840a89bb59e725446 [file] [log] [blame]
Saryu Shah193da652017-11-10 22:28:49 +00001
2.. This work is licensed under a Creative Commons Attribution 4.0 International License.
3.. http://creativecommons.org/licenses/by/4.0
4
5**********************************
6Feature: Active/Standby Management
7**********************************
8
9.. contents::
10 :depth: 3
11
12Summary
13^^^^^^^
14When the Feature Session Persistence is enabled, there can only be one active/providing service Drools PDP due to the behavior of Drools persistence. The Active/Standby Management Feature controls the selection of the Drools PDP that is providing service. It utilizes its own database and the State Management Feature database in the election algorithm. All Drools PDP nodes periodically run the election algorithm and, since they all use the same data, all nodes come to the same conclusion with the "elected" node assuming an active/providingservice state. Thus, the algorithm is distributed and has no single point of failure - assuming the database is configured for high availability.
15
16When the algorithm selects a Drools PDP to be active/providing service the controllers and topic endpoints are unlocked and allowed to process transactions. When a Drools PDP transitions to a hotstandby or coldstandby state, the controllers and topic endpoints are locked, preventing the Drools PDP from handling transactions.
17
18
19Usage
20^^^^^
21
22Enabling and Disabling Feature State Management
23-----------------------------------------------
24
25The Active/Standby Management Feature is enabled from the command line when logged in as policy after configuring the feature properties file (see Description Details section). From the command line:
26
27- > features status - Lists the status of features
28- > features enable active-standby-management - Enables the Active-Standby Management Feature
29- > features disable active-standby-management - Disables the Active-Standby Management Feature
30
31The Drools PDP must be stopped prior to enabling/disabling features and then restarted after the features have been enabled/disabled.
32
33 .. code-block:: bash
34 :caption: Enabling Active/Standby Management Feature
35
36 policy@hyperion-4:/opt/app/policy$ policy stop
37 [drools-pdp-controllers]
38 L []: Stopping Policy Management... Policy Management (pid=354) is stopping... Policy Management has stopped.
39 policy@hyperion-4:/opt/app/policy$ features enable active-standby-management
40 name version status
41 ---- ------- ------
42 controlloop-utils 1.1.0-SNAPSHOT disabled
43 healthcheck 1.1.0-SNAPSHOT disabled
44 test-transaction 1.1.0-SNAPSHOT disabled
45 eelf 1.1.0-SNAPSHOT disabled
46 state-management 1.1.0-SNAPSHOT disabled
47 active-standby-management 1.1.0-SNAPSHOT enabled
48 session-persistence 1.1.0-SNAPSHOT disabled
49
50
51Description Details
52^^^^^^^^^^^^^^^^^^^
53
54Election Algorithm
55------------------
56
57The election algorithm selects the active/providingservice Drools PDP. The algorithm on each node reads the *standbystatus* from the *StateManagementEntity* table for all other nodes to determine if they are providingservice or in a hotstandby state and able to assume an active status. It uses the *DroolsPdpEntity* table to verify that other node election algorithms are currently functioning and when the other nodes were last designated as the active Drools PDP.
58
59In general terms, the election algorithm periodically gathers the standbystatus and designation status for all the Drools PDPs. If the node which is currently designated as providingservice is "current" in updating its status, no action is required. If the designated node is either not current or has a standbystatus other than providingservice, it is time to choose another designated *DroolsPDP*. The algorithm will build a list of all DroolsPDPs that are current and have a *standbystatus* of *hotstandby*. It will then give preference to DroolsPDPs within the same site, choosing the DroolsPDP with the lowest lexicographic value to the droolsPdpId (resourceName). If the chosen DroolsPDP is itself, it will promote its standbystatus from hotstandby to providingservice. If the chosen DroolsPDP is other than itself, it will do nothing.
60
61When the DroolsPDP promotes its *standbystatus* from hotstandby to providing service, a state change notification will occur and the Standby State Change Handler will take appropriate action.
62
63
64Standby State Change Handler
65----------------------------
66
67The Standby State Change Handler (*PMStandbyStateChangeHandler* class) extends the IntegrityMonitor StateChangeNotifier class which implements the Observer class. When the DroolsPDP is constructed, an instance of the handler is constructed and registered with StateManagement. Whenever StateManagement implements a state transition, it calls the *handleStateChange()* method of the handler. If the StandbyStatus transitions to hot or cold standby, the handler makes a call into the lower level management layer to lock the application controllers and topic endpoints, preventing it from handling transactions. If the StandbyStatus transitions to providingservice, the handler makes a call into the lower level management layer to unlock the application controllers and topic endpoints, allowing it to handle transactions.
68
69
70Database
71--------
72
73The Active/Standby Feature creates a database named activestandbymanagement with a single table, **droolspdpentity**. The election handler uses that table to determine which DroolsPDP was/is designated as the active DroolsPDP and which DroolsPDP election handlers are healthy enough to periodically update their status.
74
75The **droolspdpentity** table has the following columns:
76 - **pdpId** - The unique indentifier for the DroolsPDP. It is the same as the resourceName
77 - **designated** - Has a value of 1 if the DroolsPDP is designated as active/providingservice. It has a value of 0 otherwise
78 - **priority** - Indicates the priority level of the DroolsPDP for the election handler. In general, this is ignore and all have the same priority.
79 - **updatedDate** - This is the timestamp for the most recent update of the record.
80 - **designatedDate** - This is the timestamp that indicates when the designated column was most recently set to a value of 1
81 - **site** - This is the name of the site
82
83Properties
84----------
85
86The properties are found in the feature-active-standby-management.properties file. In general, the properties are adequately described in the properties file. Parameters which must be replaced prior to usage are indicated thus: ${{parameter to be replaced}}
87
88 .. code-block:: bash
89 :caption: feature-active-standby-mangement.properties
90
91 # DB properties
92 javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
93 javax.persistence.jdbc.url=jdbc:mariadb://${{SQL_HOST}}:3306/activestandbymanagement
94 javax.persistence.jdbc.user=${{SQL_USER}}
95 javax.persistence.jdbc.password=${{SQL_PASSWORD}}
96
97 # Must be unique across the system
98 resource.name=pdp1
99 # Name of the site in which this node is hosted
100 site_name=site1
101
102 # Needed by DroolsPdpsElectionHandler
103 pdp.checkInterval=1500 # The interval in ms between updates of the updatedDate
104 pdp.updateInterval=1000 # The interval in ms between executions of the election handler
105 #pdp.timeout=3000
106 # Need long timeout, because testTransaction is only run every 10 seconds.
107 pdp.timeout=15000
108 #how long do we wait for the pdp table to populate on initial startup
109 pdp.initialWait=20000
110
111
112End of Document
113
114.. SSNote: Wiki page ref. https://wiki.onap.org/pages/viewpage.action?pageId=16005790
115
116