ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] ambari git commit: AMBARI-16953. Service name shown instead of Host name on popup (dlysnichenko)
Date Thu, 02 Jun 2016 15:31:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 07c9ce0a5 -> 7c1a37882
  refs/heads/trunk 0df919ade -> 57180810c


AMBARI-16953. Service name shown instead of Host name on popup (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/57180810
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/57180810
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/57180810

Branch: refs/heads/trunk
Commit: 57180810c5963c7f436370ac6e5983cf630e32ac
Parents: 0df919a
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Jun 2 18:30:03 2016 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Jun 2 18:30:30 2016 +0300

----------------------------------------------------------------------
 .../ambari/server/checks/CheckDescription.java  |  4 ++--
 .../checks/SecondaryNamenodeDeletedCheck.java   | 14 ++++++++-----
 .../checks/ServiceCheckValidityCheck.java       |  7 +++++++
 .../SecondaryNamenodeDeletedCheckTest.java      |  2 ++
 .../checks/ServiceCheckValidityCheckTest.java   | 22 ++++++++++++++++++++
 5 files changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/57180810/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
index 5899370..850b58a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
@@ -88,10 +88,10 @@ public enum CheckDescription {
           "Repository version {{version}} does not exist.");
       }}),
 
-  SECONDARY_NAMENODE_MUST_BE_DELETED(PrereqCheckType.SERVICE,
+  SECONDARY_NAMENODE_MUST_BE_DELETED(PrereqCheckType.HOST,
       "The SNameNode component must be deleted from all hosts",
       new HashMap<String, String>() {{
-        put(AbstractCheckDescriptor.DEFAULT, "The SNameNode component must be deleted from
host: {{fails}}.");
+        put(AbstractCheckDescriptor.DEFAULT, "The SNameNode component must be deleted from
host: %s.");
       }}),
 
   STORM_REST_API_MUST_BE_DELETED(PrereqCheckType.SERVICE,

http://git-wip-us.apache.org/repos/asf/ambari/blob/57180810/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
index 4893098..0dbb1b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
@@ -43,6 +43,8 @@ import com.google.inject.Singleton;
 @Singleton
 @UpgradeCheck(group = UpgradeCheckGroup.NAMENODE_HA, order = 16.0f)
 public class SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor {
+  private static final String HDFS_SERVICE_NAME = MasterHostResolver.Service.HDFS.name();
+
   @Inject
   HostComponentStateDAO hostComponentStateDao;
   /**
@@ -54,7 +56,7 @@ public class SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor
{
 
   @Override
   public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
-    if (!super.isApplicable(request, Arrays.asList("HDFS"), true)) {
+    if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) {
       return false;
     }
 
@@ -79,7 +81,7 @@ public class SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor
{
     final String clusterName = request.getClusterName();
     final Cluster cluster = clustersProvider.get().getCluster(clusterName);
     try {
-      ServiceComponent serviceComponent = cluster.getService(MasterHostResolver.Service.HDFS.name()).getServiceComponent(SECONDARY_NAMENODE);
+      ServiceComponent serviceComponent = cluster.getService(HDFS_SERVICE_NAME).getServiceComponent(SECONDARY_NAMENODE);
       if (serviceComponent != null) {
         hosts = serviceComponent.getServiceComponentHosts().keySet();
       }
@@ -92,16 +94,18 @@ public class SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor
{
     if (hosts.isEmpty()) {
       List<HostComponentStateEntity> allHostComponents = hostComponentStateDao.findAll();
       for(HostComponentStateEntity hc : allHostComponents) {
-        if (hc.getServiceName().equalsIgnoreCase(MasterHostResolver.Service.HDFS.name())
&& hc.getComponentName().equalsIgnoreCase(SECONDARY_NAMENODE)) {
+        if (hc.getServiceName().equalsIgnoreCase(HDFS_SERVICE_NAME) && hc.getComponentName().equalsIgnoreCase(SECONDARY_NAMENODE))
{
           hosts.add(hc.getHostName());
         }
       }
     }
 
     if (!hosts.isEmpty()) {
-      prerequisiteCheck.getFailedOn().add(SECONDARY_NAMENODE);
+      String foundHost = hosts.toArray(new String[hosts.size()])[0];
+      prerequisiteCheck.getFailedOn().add(HDFS_SERVICE_NAME);
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request));
+      String failReason = getFailReason(prerequisiteCheck, request);
+      prerequisiteCheck.setFailReason(String.format(failReason, foundHost));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/57180810/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
index 9abfa50..2bc22c9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
@@ -133,8 +133,10 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor
{
       String serviceName = serviceEntry.getKey();
       Long configTimestamp = serviceEntry.getValue();
 
+      boolean serviceCheckWasExecuted = false;
       for (HostRoleCommandEntity command : latestTimestamps.values()) {
         if (command.getCommandDetail().contains(serviceName)) {
+          serviceCheckWasExecuted = true;
           Long serviceCheckTimestamp = command.getStartTime();
 
           if (serviceCheckTimestamp < configTimestamp) {
@@ -146,6 +148,11 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor
{
           }
         }
       }
+
+      if (!serviceCheckWasExecuted) {
+        failedServiceNames.add(serviceName);
+        LOG.info("Service {} service check has never been executed", serviceName);
+      }
     }
 
     if (!failedServiceNames.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/57180810/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
index e2617bf..3ce9757 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
@@ -111,6 +111,8 @@ public class SecondaryNamenodeDeletedCheckTest {
     PrerequisiteCheck check = new PrerequisiteCheck(null, null);
     secondaryNamenodeDeletedCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+    Assert.assertEquals("HDFS", check.getFailedOn().toArray(new String[1])[0]);
+    Assert.assertEquals("The SNameNode component must be deleted from host: host.", check.getFailReason());
 
     Mockito.when(serviceComponent.getServiceComponentHosts()).thenReturn(Collections.<String,
ServiceComponentHost> emptyMap());
     check = new PrerequisiteCheck(null, null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/57180810/ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java
index 55429bd..8d72b96 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
@@ -126,6 +127,27 @@ public class ServiceCheckValidityCheckTest {
     Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
   }
 
+
+  @Test
+  public void testFailWhenServiceWithNoServiceCheckExists() throws AmbariException {
+    ServiceComponent serviceComponent = mock(ServiceComponent.class);
+    when(serviceComponent.isVersionAdvertised()).thenReturn(true);
+
+    when(service.getMaintenanceState()).thenReturn(MaintenanceState.OFF);
+    when(service.getServiceComponents()).thenReturn(ImmutableMap.of(SERVICE_COMPONENT_NAME,
serviceComponent));
+
+    ServiceConfigEntity serviceConfigEntity = new ServiceConfigEntity();
+    serviceConfigEntity.setServiceName(SERVICE_NAME);
+    serviceConfigEntity.setCreateTimestamp(CONFIG_CREATE_TIMESTAMP);
+
+    when(serviceConfigDAO.getLastServiceConfig(eq(CLUSTER_ID), eq(SERVICE_NAME))).thenReturn(serviceConfigEntity);
+    when(hostRoleCommandDAO.findAll(any(Request.class), any(Predicate.class))).thenReturn(Collections.<HostRoleCommandEntity>emptyList());
+
+    PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME);
+    serviceCheckValidityCheck.perform(check, new PrereqCheckRequest(CLUSTER_NAME));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+  }
+
   @Test
   public void testFailWhenServiceWithOutdatedServiceCheckExistsRepeated() throws AmbariException
{
     ServiceComponent serviceComponent = mock(ServiceComponent.class);


Mime
View raw message