From 6a2c7c615782f1198a84947c0af43062af914f6b Mon Sep 17 00:00:00 2001 From: zeroflag Date: Thu, 28 Sep 2023 15:16:48 +0200 Subject: [PATCH] KNOX-2959 - Auto discovery to support scaling scenarios --- ...ouderaManagerServiceDiscoveryMessages.java | 4 +- .../monitor/PollingConfigurationAnalyzer.java | 2 +- .../discovery/cm/monitor/RoleHostCache.java | 38 ------------------- 3 files changed, 3 insertions(+), 41 deletions(-) delete mode 100644 gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/RoleHostCache.java diff --git a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java index 0960e79a3e..ca331241d3 100644 --- a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java +++ b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java @@ -201,8 +201,8 @@ void queryingConfigActivationEventsFromCluster(String clusterName, @Message(level = MessageLevel.DEBUG, text = "Activation event relevance: {0} = {1} ({2} / {3} / {4} / {5})") void activationEventRelevance(String eventId, String relevance, String command, String status, String serviceType, boolean serviceModelGeneratorExists); - @Message(level = MessageLevel.DEBUG, text = "Deactivation event relevance: {0} = {1} ({2} / {3} / {4})") - void deactivationEventRelevance(String eventId, String relevance, String eventCode, String serviceType, boolean serviceModelGeneratorExists); + @Message(level = MessageLevel.DEBUG, text = "Scale event relevance: {0} = {1} ({2} / {3} / {4})") + void scaleEventRelevance(String eventId, String relevance, String eventCode, String serviceType, boolean serviceModelGeneratorExists); @Message(level = MessageLevel.DEBUG, text = "Activation event - {0} - has already been processed, skipping ...") void activationEventAlreadyProcessed(String eventId); 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 ae4689a588..c4e511d361 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 @@ -511,7 +511,7 @@ private boolean isScaleEvent(ApiEvent event) { final boolean serviceModelGeneratorExists = serviceModelGeneratorsHolder.getServiceModelGenerators(serviceType) != null; final boolean relevant = serviceModelGeneratorExists && (CREATED_EVENT_CODES.contains(eventCode) || DELETED_EVENT_CODES.contains(eventCode)); - log.deactivationEventRelevance(event.getId(), String.valueOf(relevant), eventCode, serviceType, relevant); + log.scaleEventRelevance(event.getId(), String.valueOf(relevant), eventCode, serviceType, relevant); return relevant; } diff --git a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/RoleHostCache.java b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/RoleHostCache.java deleted file mode 100644 index 085e142ef4..0000000000 --- a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/RoleHostCache.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.knox.gateway.topology.discovery.cm.monitor; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -public class RoleHostCache { - private final Map> hosts = new ConcurrentHashMap<>(); - - public void addHosts(String role, Set hosts) { - hosts(role).addAll(hosts); - } - - public void removeHosts(String role, Set hosts) { - hosts(role).removeAll(hosts); - } - - public Set hosts(String role) { - return hosts.computeIfAbsent(role, k -> new HashSet<>()); - } -}