You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2018/04/19 19:16:15 UTC
[ambari] branch trunk updated: AMBARI-23586. Cluster deployment
fails if agent started after cluster creation request (#1014)
This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 62941f8 AMBARI-23586. Cluster deployment fails if agent started after cluster creation request (#1014)
62941f8 is described below
commit 62941f89e34ca639f882ab6466174d2cc213d391
Author: kasakrisz <33...@users.noreply.github.com>
AuthorDate: Thu Apr 19 21:16:13 2018 +0200
AMBARI-23586. Cluster deployment fails if agent started after cluster creation request (#1014)
---
ambari-agent/src/main/python/ambari_agent/Constants.py | 4 ++--
.../src/main/python/ambari_agent/HeartbeatThread.py | 15 +++++++++------
.../apache/ambari/server/agent/stomp/TopologyHolder.java | 5 +++++
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ambari-agent/src/main/python/ambari_agent/Constants.py b/ambari-agent/src/main/python/ambari_agent/Constants.py
index 93c2a49..367e8c4 100644
--- a/ambari-agent/src/main/python/ambari_agent/Constants.py
+++ b/ambari-agent/src/main/python/ambari_agent/Constants.py
@@ -28,8 +28,8 @@ TOPOLOGIES_TOPIC = '/events/topologies'
SERVER_RESPONSES_TOPIC = '/user/'
AGENT_ACTIONS_TOPIC = '/user/agent_actions'
-PRE_REGISTRATION_TOPICS_TO_SUBSCRIBE = [SERVER_RESPONSES_TOPIC]
-POST_REGISTRATION_TOPICS_TO_SUBSCRIBE = [COMMANDS_TOPIC, CONFIGURATIONS_TOPIC, METADATA_TOPIC, TOPOLOGIES_TOPIC, HOST_LEVEL_PARAMS_TOPIC, ALERTS_DEFINITIONS_TOPIC, AGENT_ACTIONS_TOPIC]
+PRE_REGISTRATION_TOPICS_TO_SUBSCRIBE = [SERVER_RESPONSES_TOPIC, AGENT_ACTIONS_TOPIC]
+POST_REGISTRATION_TOPICS_TO_SUBSCRIBE = [COMMANDS_TOPIC]
TOPOLOGY_REQUEST_ENDPOINT = '/agents/topologies'
METADATA_REQUEST_ENDPOINT = '/agents/metadata'
diff --git a/ambari-agent/src/main/python/ambari_agent/HeartbeatThread.py b/ambari-agent/src/main/python/ambari_agent/HeartbeatThread.py
index 6a7fbb7..ae8e003 100644
--- a/ambari-agent/src/main/python/ambari_agent/HeartbeatThread.py
+++ b/ambari-agent/src/main/python/ambari_agent/HeartbeatThread.py
@@ -69,11 +69,11 @@ class HeartbeatThread(threading.Thread):
self.listeners = [self.server_responses_listener, self.commands_events_listener, self.metadata_events_listener, self.topology_events_listener, self.configuration_events_listener, self.host_level_params_events_listener, self.alert_definitions_events_listener, self.agent_actions_events_listener]
self.post_registration_requests = [
- (Constants.TOPOLOGY_REQUEST_ENDPOINT, initializer_module.topology_cache, self.topology_events_listener),
- (Constants.METADATA_REQUEST_ENDPOINT, initializer_module.metadata_cache, self.metadata_events_listener),
- (Constants.CONFIGURATIONS_REQUEST_ENDPOINT, initializer_module.configurations_cache, self.configuration_events_listener),
- (Constants.HOST_LEVEL_PARAMS_TOPIC_ENPOINT, initializer_module.host_level_params_cache, self.host_level_params_events_listener),
- (Constants.ALERTS_DEFINITIONS_REQUEST_ENDPOINT, initializer_module.alert_definitions_cache, self.alert_definitions_events_listener)
+ (Constants.TOPOLOGY_REQUEST_ENDPOINT, initializer_module.topology_cache, self.topology_events_listener, Constants.TOPOLOGIES_TOPIC),
+ (Constants.METADATA_REQUEST_ENDPOINT, initializer_module.metadata_cache, self.metadata_events_listener, Constants.METADATA_TOPIC),
+ (Constants.CONFIGURATIONS_REQUEST_ENDPOINT, initializer_module.configurations_cache, self.configuration_events_listener, Constants.CONFIGURATIONS_TOPIC),
+ (Constants.HOST_LEVEL_PARAMS_TOPIC_ENPOINT, initializer_module.host_level_params_cache, self.host_level_params_events_listener, Constants.HOST_LEVEL_PARAMS_TOPIC),
+ (Constants.ALERTS_DEFINITIONS_REQUEST_ENDPOINT, initializer_module.alert_definitions_cache, self.alert_definitions_events_listener, Constants.ALERTS_DEFINITIONS_TOPIC)
]
self.responseId = 0
self.file_cache = initializer_module.file_cache
@@ -129,7 +129,7 @@ class HeartbeatThread(threading.Thread):
self.handle_registration_response(response)
- for endpoint, cache, listener in self.post_registration_requests:
+ for endpoint, cache, listener, subscribe_to in self.post_registration_requests:
# should not hang forever on these requests
response = self.blocking_request({'hash': cache.hash}, endpoint, log_handler=listener.get_log_message)
try:
@@ -138,7 +138,10 @@ class HeartbeatThread(threading.Thread):
logger.exception("Exception while handing response to request at {0}. {1}".format(endpoint, response))
raise
+ self.subscribe_to_topics([subscribe_to])
+
self.subscribe_to_topics(Constants.POST_REGISTRATION_TOPICS_TO_SUBSCRIBE)
+
self.file_cache.reset()
self.initializer_module.is_registered = True
# now when registration is done we can expose connection to other threads.
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
index 18294a1..fe76c12 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
@@ -42,6 +42,8 @@ import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.StackId;
import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
@@ -50,6 +52,8 @@ import com.google.inject.Singleton;
@Singleton
public class TopologyHolder extends AgentClusterDataHolder<TopologyUpdateEvent> {
+ private final static Logger LOG = LoggerFactory.getLogger(TopologyHolder.class);
+
@Inject
private AmbariManagementControllerImpl ambariManagementController;
@@ -131,6 +135,7 @@ public class TopologyHolder extends AgentClusterDataHolder<TopologyUpdateEvent>
copiedUpdate.getEventType()
);
prepareAgentTopology(topologyAgentUpdateEvent);
+ LOG.debug("Publishing Topology Agent Update Event hash={}", topologyAgentUpdateEvent.getHash());
STOMPUpdatePublisher.publish(topologyAgentUpdateEvent);
}
--
To stop receiving notification emails like this one, please contact
adoroszlai@apache.org.