[39/50] [abbrv] ambari git commit: AMBARI-18907: Auto-start should respect maintenance mode on hosts and services
AMBARI-18907: Auto-start should respect maintenance mode on hosts and services Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82c13df4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82c13df4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82c13df4 Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 82c13df406b3e4d28e2b6242d29113fa96f015fe Parents: ae1a981 Author: Nahappan Somasundaram Authored: Wed Nov 16 14:30:37 2016 -0800 Committer: Nahappan Somasundaram Committed: Wed Nov 16 17:34:58 2016 -0800 -- .../server/agent/RecoveryConfigHelper.java | 71 +--- .../server/events/MaintenanceModeEvent.java | 30 +++-- .../ambari/server/state/host/HostImpl.java | 2 +- .../AlertMaintenanceModeListenerTest.java | 2 +- 4 files changed, 89 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/82c13df4/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java index 7d6a7f5..9d5bae7d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java @@ -35,7 +35,9 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.ConfigHelper; +import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.MaintenanceState; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.commons.lang.StringUtils; @@ -160,7 +162,7 @@ public class RecoveryConfigHelper { } /** - * Maintenance mode of a service component host changed. + * Maintenance mode of a host, service or service component host changed. * @param event * @throws AmbariException */ @@ -168,10 +170,44 @@ public class RecoveryConfigHelper { @AllowConcurrentEvents public void handleMaintenanceModeEvent(MaintenanceModeEvent event) throws AmbariException { -ServiceComponentHost sch = event.getServiceComponentHost(); +if (event.getHost() != null) { + /* + * If any one component in the host is recovery enabled, + * invalidate the host timestamp. + */ + Cluster cluster = clusters.getCluster(event.getClusterId()); + if (cluster == null) { +return; + } + + Host host = event.getHost(); + List scHosts = cluster.getServiceComponentHosts(host.getHostName()); + for (ServiceComponentHost sch : scHosts) { +if (sch.isRecoveryEnabled()) { + invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + break; +} + } +} +else if (event.getService() != null) { + /** + * Simply invalidate all the hosts in the cluster. + * The recovery config will be sent to all the hosts + * even if some of the hosts do not have components + * in recovery mode. + * Looping through all the hosts and its components + * to determine which host to send the recovery config + * may not be efficient. + */ + Service service = event.getService(); + invalidateRecoveryTimestamp(service.getCluster().getClusterName(), null); +} +else if (event.getServiceComponentHost() != null) { + ServiceComponentHost sch = event.getServiceComponentHost(); -if (sch != null && sch.isRecoveryEnabled()) { - invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + if (sch.isRecoveryEnabled()) { +invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + } } } @@ -281,14 +317,31 @@ public class RecoveryConfigHelper { * maintenance mode. * @return */ -private List getEnabledComponents(String hostname) { +private List getEnabledComponents(String hostname) throws AmbariException { List enabledComponents = new ArrayList<>(); - if (cluster != null) { -List scHosts = cluster.getServiceComponentHosts(hostname); + if (cluster == null) { +return enabledComponents; + } + + Host host = clusters.getHost(hostname); + if (host == null) { +return enabledComponents; + } + + // if host is in maintenance mode then ignore all the components for auto start + if (host.getMaintenanceState(cluster.getClusterId()) == MaintenanceState.ON) {
ambari git commit: AMBARI-18907: Auto-start should respect maintenance mode on hosts and services
Repository: ambari Updated Branches: refs/heads/trunk ae1a98198 -> 82c13df40 AMBARI-18907: Auto-start should respect maintenance mode on hosts and services Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82c13df4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82c13df4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82c13df4 Branch: refs/heads/trunk Commit: 82c13df406b3e4d28e2b6242d29113fa96f015fe Parents: ae1a981 Author: Nahappan Somasundaram Authored: Wed Nov 16 14:30:37 2016 -0800 Committer: Nahappan Somasundaram Committed: Wed Nov 16 17:34:58 2016 -0800 -- .../server/agent/RecoveryConfigHelper.java | 71 +--- .../server/events/MaintenanceModeEvent.java | 30 +++-- .../ambari/server/state/host/HostImpl.java | 2 +- .../AlertMaintenanceModeListenerTest.java | 2 +- 4 files changed, 89 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/82c13df4/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java index 7d6a7f5..9d5bae7d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java @@ -35,7 +35,9 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.ConfigHelper; +import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.MaintenanceState; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.commons.lang.StringUtils; @@ -160,7 +162,7 @@ public class RecoveryConfigHelper { } /** - * Maintenance mode of a service component host changed. + * Maintenance mode of a host, service or service component host changed. * @param event * @throws AmbariException */ @@ -168,10 +170,44 @@ public class RecoveryConfigHelper { @AllowConcurrentEvents public void handleMaintenanceModeEvent(MaintenanceModeEvent event) throws AmbariException { -ServiceComponentHost sch = event.getServiceComponentHost(); +if (event.getHost() != null) { + /* + * If any one component in the host is recovery enabled, + * invalidate the host timestamp. + */ + Cluster cluster = clusters.getCluster(event.getClusterId()); + if (cluster == null) { +return; + } + + Host host = event.getHost(); + List scHosts = cluster.getServiceComponentHosts(host.getHostName()); + for (ServiceComponentHost sch : scHosts) { +if (sch.isRecoveryEnabled()) { + invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + break; +} + } +} +else if (event.getService() != null) { + /** + * Simply invalidate all the hosts in the cluster. + * The recovery config will be sent to all the hosts + * even if some of the hosts do not have components + * in recovery mode. + * Looping through all the hosts and its components + * to determine which host to send the recovery config + * may not be efficient. + */ + Service service = event.getService(); + invalidateRecoveryTimestamp(service.getCluster().getClusterName(), null); +} +else if (event.getServiceComponentHost() != null) { + ServiceComponentHost sch = event.getServiceComponentHost(); -if (sch != null && sch.isRecoveryEnabled()) { - invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + if (sch.isRecoveryEnabled()) { +invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + } } } @@ -281,14 +317,31 @@ public class RecoveryConfigHelper { * maintenance mode. * @return */ -private List getEnabledComponents(String hostname) { +private List getEnabledComponents(String hostname) throws AmbariException { List enabledComponents = new ArrayList<>(); - if (cluster != null) { -List scHosts = cluster.getServiceComponentHosts(hostname); + if (cluster == null) { +return enabledComponents; + } + + Host host = clusters.getHost(hostname); + if (host == null) { +return enabledComponents; + } + + // if host is in maintenance mode then ignore all the components for auto start + if (host.getMaintena
ambari git commit: AMBARI-18907: Auto-start should respect maintenance mode on hosts and services
Repository: ambari Updated Branches: refs/heads/branch-2.5 4c2c50aa4 -> 6a58b4b40 AMBARI-18907: Auto-start should respect maintenance mode on hosts and services Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6a58b4b4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6a58b4b4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6a58b4b4 Branch: refs/heads/branch-2.5 Commit: 6a58b4b400303e93aefcceeccf0ebf8aef851a4d Parents: 4c2c50a Author: Nahappan Somasundaram Authored: Wed Nov 16 14:30:37 2016 -0800 Committer: Nahappan Somasundaram Committed: Wed Nov 16 15:43:21 2016 -0800 -- .../server/agent/RecoveryConfigHelper.java | 71 +--- .../server/events/MaintenanceModeEvent.java | 30 +++-- .../ambari/server/state/host/HostImpl.java | 2 +- .../AlertMaintenanceModeListenerTest.java | 2 +- 4 files changed, 89 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/6a58b4b4/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java index 7d6a7f5..9d5bae7d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java @@ -35,7 +35,9 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.ConfigHelper; +import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.MaintenanceState; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.commons.lang.StringUtils; @@ -160,7 +162,7 @@ public class RecoveryConfigHelper { } /** - * Maintenance mode of a service component host changed. + * Maintenance mode of a host, service or service component host changed. * @param event * @throws AmbariException */ @@ -168,10 +170,44 @@ public class RecoveryConfigHelper { @AllowConcurrentEvents public void handleMaintenanceModeEvent(MaintenanceModeEvent event) throws AmbariException { -ServiceComponentHost sch = event.getServiceComponentHost(); +if (event.getHost() != null) { + /* + * If any one component in the host is recovery enabled, + * invalidate the host timestamp. + */ + Cluster cluster = clusters.getCluster(event.getClusterId()); + if (cluster == null) { +return; + } + + Host host = event.getHost(); + List scHosts = cluster.getServiceComponentHosts(host.getHostName()); + for (ServiceComponentHost sch : scHosts) { +if (sch.isRecoveryEnabled()) { + invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + break; +} + } +} +else if (event.getService() != null) { + /** + * Simply invalidate all the hosts in the cluster. + * The recovery config will be sent to all the hosts + * even if some of the hosts do not have components + * in recovery mode. + * Looping through all the hosts and its components + * to determine which host to send the recovery config + * may not be efficient. + */ + Service service = event.getService(); + invalidateRecoveryTimestamp(service.getCluster().getClusterName(), null); +} +else if (event.getServiceComponentHost() != null) { + ServiceComponentHost sch = event.getServiceComponentHost(); -if (sch != null && sch.isRecoveryEnabled()) { - invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + if (sch.isRecoveryEnabled()) { +invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName()); + } } } @@ -281,14 +317,31 @@ public class RecoveryConfigHelper { * maintenance mode. * @return */ -private List getEnabledComponents(String hostname) { +private List getEnabledComponents(String hostname) throws AmbariException { List enabledComponents = new ArrayList<>(); - if (cluster != null) { -List scHosts = cluster.getServiceComponentHosts(hostname); + if (cluster == null) { +return enabledComponents; + } + + Host host = clusters.getHost(hostname); + if (host == null) { +return enabledComponents; + } + + // if host is in maintenance mode then ignore all the components for auto start + if (host.g