This is an automated email from the ASF dual-hosted git repository.

smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new a244be4  KNOX-2410 - Handling the new 
'RestartWaitingForStalenessSuccess' CM audit event (#364)
a244be4 is described below

commit a244be45618f2f297d4def9953520eb3b4d37a13
Author: Sandor Molnar <[email protected]>
AuthorDate: Fri Jul 24 07:27:21 2020 +0200

    KNOX-2410 - Handling the new 'RestartWaitingForStalenessSuccess' CM audit 
event (#364)
---
 .../cm/monitor/PollingConfigurationAnalyzer.java          |  8 +++++---
 .../cm/monitor/PollingConfigurationAnalyzerTest.java      | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
index 2132d3f..8f2d4d0 100644
--- 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
+++ 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
@@ -76,12 +76,14 @@ public class PollingConfigurationAnalyzer implements 
Runnable {
 
   static final String ROLLING_RESTART_COMMAND = "RollingRestart";
 
+  static final String RESTART_WAITING_FOR_STALENESS_SUCCESS_COMMAND = 
"RestartWaitingForStalenessSuccess";
+
   static final String CM_SERVICE_TYPE = "ManagerServer";
   static final String CM_SERVICE      = "ClouderaManager";
 
   // Collection of those commands which represent the potential activation of 
service configuration changes
-  private static final Collection<String> ACTIVATION_COMMANDS =
-                          Arrays.asList(START_COMMAND, RESTART_COMMAND, 
ROLLING_RESTART_COMMAND);
+  private static final Collection<String> ACTIVATION_COMMANDS = 
Arrays.asList(START_COMMAND, RESTART_COMMAND, ROLLING_RESTART_COMMAND,
+      RESTART_WAITING_FOR_STALENESS_SUCCESS_COMMAND);
 
   // The format of the filter employed when start events are queried from 
ClouderaManager
   private static final String EVENTS_QUERY_FORMAT =
@@ -231,7 +233,7 @@ public class PollingConfigurationAnalyzer implements 
Runnable {
 
       if (CM_SERVICE_TYPE.equals(serviceType)) {
         if (CM_SERVICE.equals(re.getService())) {
-          // This is a rolling cluster restart event, so assume configuration 
has changed
+          // This is a 'rolling cluster restart' or 'restart waiting for 
staleness' event, so assume configuration has changed
           configHasChanged = true;
         }
       }
diff --git 
a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzerTest.java
 
b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzerTest.java
index 00f83a3..6f0a826 100644
--- 
a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzerTest.java
+++ 
b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzerTest.java
@@ -230,6 +230,21 @@ public class PollingConfigurationAnalyzerTest {
     assertTrue("Expected a change notification", listener.wasNotified(address, 
clusterName));
   }
 
+  /**
+   * Test the restart waiting for staleness, for which it should be assumed 
that configuration has changed.
+   */
+  @Test
+  public void testRestartWaitingForStalenessSuccessEvent() {
+    final String address = "http://host1:1234";;
+    final String clusterName = "Cluster 8";
+
+    // Simulate a successful restart waiting for staleness event
+    final ApiEvent rollingRestartEvent = createApiEvent(clusterName, 
PollingConfigurationAnalyzer.CM_SERVICE_TYPE, 
PollingConfigurationAnalyzer.CM_SERVICE,
+        
PollingConfigurationAnalyzer.RESTART_WAITING_FOR_STALENESS_SUCCESS_COMMAND, 
PollingConfigurationAnalyzer.SUCCEEDED_STATUS, "EV_CLUSTER_RESTARTED");
+
+    final ChangeListener listener = doTestEvent(rollingRestartEvent, address, 
clusterName, Collections.emptyMap(), Collections.emptyMap());
+    assertTrue("Expected a change notification", listener.wasNotified(address, 
clusterName));
+  }
 
   @Test
   public void 
testClusterConfigMonitorTerminationForNoLongerReferencedClusters() {

Reply via email to