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/06/01 12:05:50 UTC
[ambari] branch trunk updated: AMBARI-24007. Components are getting
down immediately after autostart (#1437)
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 c043401 AMBARI-24007. Components are getting down immediately after autostart (#1437)
c043401 is described below
commit c043401740470f6930c230e66780ba2b30432b1b
Author: kasakrisz <33...@users.noreply.github.com>
AuthorDate: Fri Jun 1 14:05:46 2018 +0200
AMBARI-24007. Components are getting down immediately after autostart (#1437)
---
.../server/agent/stomp/HostLevelParamsHolder.java | 22 ++++++++++++++--------
.../ServiceComponentRecoveryChangedEvent.java | 19 +++++++++++++------
.../ambari/server/state/ServiceComponentImpl.java | 2 +-
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/HostLevelParamsHolder.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/HostLevelParamsHolder.java
index fbd26dd..8190130 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/HostLevelParamsHolder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/HostLevelParamsHolder.java
@@ -17,7 +17,6 @@
*/
package org.apache.ambari.server.agent.stomp;
-import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
@@ -27,6 +26,7 @@ import org.apache.ambari.server.agent.stomp.dto.HostLevelParamsCluster;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.events.ClusterComponentsRepoChangedEvent;
import org.apache.ambari.server.events.HostLevelParamsUpdateEvent;
+import org.apache.ambari.server.events.ServiceComponentRecoveryChangedEvent;
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
@@ -79,7 +79,7 @@ public class HostLevelParamsHolder extends AgentHostDataHolder<HostLevelParamsUp
return hostLevelParamsUpdateEvent;
}
- protected boolean handleUpdate(HostLevelParamsUpdateEvent update) throws AmbariException {
+ protected boolean handleUpdate(HostLevelParamsUpdateEvent update) {
boolean changed = false;
if (MapUtils.isNotEmpty(update.getHostLevelParamsClusters())) {
Long hostId = update.getHostId();
@@ -119,15 +119,21 @@ public class HostLevelParamsHolder extends AgentHostDataHolder<HostLevelParamsUp
@Subscribe
public void onClusterComponentsRepoUpdate(ClusterComponentsRepoChangedEvent clusterComponentsRepoChangedEvent) throws AmbariException {
- Long clusterId = clusterComponentsRepoChangedEvent.getClusterId();
+ updateDataOfCluster(clusterComponentsRepoChangedEvent.getClusterId());
+ }
+
+ @Subscribe
+ public void onServiceComponentRecoveryChanged(ServiceComponentRecoveryChangedEvent event) throws AmbariException {
+ updateDataOfCluster(event.getClusterId());
+ }
+ private void updateDataOfCluster(long clusterId) throws AmbariException {
Cluster cluster = clusters.getCluster(clusterId);
- Collection<Host> hosts = clusters.getCluster(clusterId).getHosts();
- for (Host host : hosts) {
+ for (Host host : cluster.getHosts()) {
HostLevelParamsUpdateEvent hostLevelParamsUpdateEvent = new HostLevelParamsUpdateEvent(Long.toString(clusterId),
- new HostLevelParamsCluster(
- m_ambariManagementController.get().retrieveHostRepositories(cluster, host),
- recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), host.getHostName())));
+ new HostLevelParamsCluster(
+ m_ambariManagementController.get().retrieveHostRepositories(cluster, host),
+ recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), host.getHostName())));
hostLevelParamsUpdateEvent.setHostId(host.getHostId());
updateData(hostLevelParamsUpdateEvent);
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/ServiceComponentRecoveryChangedEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/events/ServiceComponentRecoveryChangedEvent.java
index b1d67b1..c7049fb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/ServiceComponentRecoveryChangedEvent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/ServiceComponentRecoveryChangedEvent.java
@@ -24,20 +24,26 @@ package org.apache.ambari.server.events;
* component is enabled or disabled for auto start.
*/
public class ServiceComponentRecoveryChangedEvent extends AmbariEvent {
- private String m_clusterName;
- private String m_serviceName;
- private String m_componentName;
- private boolean m_recoveryEnabled;
+ private final long m_clusterId;
+ private final String m_clusterName;
+ private final String m_serviceName;
+ private final String m_componentName;
+ private final boolean m_recoveryEnabled;
public ServiceComponentRecoveryChangedEvent(
- String clusterName, String serviceName, String componentName, boolean recoveryEnabled) {
+ long clusterId, String clusterName, String serviceName, String componentName, boolean recoveryEnabled) {
super(AmbariEventType.SERVICE_COMPONENT_RECOVERY_CHANGED);
+ m_clusterId = clusterId;
m_clusterName = clusterName;
m_serviceName = serviceName;
m_componentName = componentName;
m_recoveryEnabled = recoveryEnabled;
}
+ public long getClusterId() {
+ return m_clusterId;
+ }
+
/**
* Get the cluster name
*
@@ -80,7 +86,8 @@ public class ServiceComponentRecoveryChangedEvent extends AmbariEvent {
@Override
public String toString() {
StringBuilder buffer = new StringBuilder("ServiceComponentRecoveryChangeEvent{");
- buffer.append("clusterName=").append(getClusterName());
+ buffer.append("clusterId=").append(getClusterId());
+ buffer.append(", clusterName=").append(getClusterName());
buffer.append(", serviceName=").append(getServiceName());
buffer.append(", componentName=").append(getComponentName());
buffer.append(", recoveryEnabled=").append(isRecoveryEnabled());
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 7efccd0..e9c2e77 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -248,7 +248,7 @@ public class ServiceComponentImpl implements ServiceComponent {
// broadcast the change
ServiceComponentRecoveryChangedEvent event = new ServiceComponentRecoveryChangedEvent(
- getClusterName(), getServiceName(), getName(), isRecoveryEnabled());
+ getClusterId(), getClusterName(), getServiceName(), getName(), isRecoveryEnabled());
eventPublisher.publish(event);
} else {
--
To stop receiving notification emails like this one, please contact
adoroszlai@apache.org.