瀏覽代碼

Revert "AMBARI-9405. RU YARN related pre-upgrade check UI shows unclear message (Yurii Shylov via ncole)"

This reverts commit 2e78ed709d82b6f1b19f881c6d1f29f8a32bf7b1.
Jonathan Hurley 10 年之前
父節點
當前提交
0cbc4f114c

+ 4 - 35
ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java

@@ -17,7 +17,8 @@
  */
 package org.apache.ambari.server.checks;
 
-import java.util.List;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -25,13 +26,9 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.stack.PrereqCheckType;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.PrereqCheckType;
 import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
-import org.apache.commons.lang.StringUtils;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
 
 /**
  * Describes prerequisite check.
@@ -91,32 +88,4 @@ public abstract class AbstractCheckDescriptor {
    * @throws AmbariException if server error happens
    */
   public abstract void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException;
-
-  /**
-   * Formats lists of given entities to human readable form:
-   * [entity1] -> {entity1} {noun}
-   * [entity1, entity2] -> {entity1} and {entity2} {noun}s
-   * [entity1, entity2, entity3] -> {entity1}, {entity2} and {entity3} {noun}s
-   * The noun for the entities is taken from check type, it may be cluster, service or host.
-   *
-   * @param entities list of entities to format
-   * @return formatted entity list
-   */
-  protected String formatEntityList(List<String> entities) {
-    if (entities == null || entities.isEmpty()) {
-      return "";
-    }
-    final StringBuilder formatted = new StringBuilder(StringUtils.join(entities, ", "));
-    if (entities.size() > 1) {
-      formatted.replace(formatted.lastIndexOf(","), formatted.lastIndexOf(",") + 1, " and");
-    }
-    if (type != null) {
-      formatted.append(" ").append(type.name().toLowerCase());
-      if (entities.size() > 1) {
-        formatted.append("s");
-      }
-    }
-    return formatted.toString();
-  }
-
-}
+}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/HostsHeartbeatCheck.java

@@ -54,7 +54,7 @@ public class HostsHeartbeatCheck extends AbstractCheckDescriptor {
     }
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must be heartbeating with the server");
+      prerequisiteCheck.setFailReason("Some hosts are not heartbeating with the server");
     }
   }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java

@@ -85,7 +85,7 @@ public class HostsMasterMaintenanceCheck extends AbstractCheckDescriptor {
     }
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must not be in in Maintenance Mode as they have master components installed");
+      prerequisiteCheck.setFailReason("Some hosts with master components are in Maintenance Mode");
     }
   }
 }

+ 2 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java

@@ -73,7 +73,8 @@ public class HostsRepositoryVersionCheck extends AbstractCheckDescriptor {
     }
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must have repository version " + request.getRepositoryVersion() + " installed");
+      prerequisiteCheck.setFailReason("Some hosts do not have repository version " + request.getRepositoryVersion() + " installed");
     }
+
   }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesDecommissionCheck.java

@@ -56,7 +56,7 @@ public class ServicesDecommissionCheck extends AbstractCheckDescriptor {
     }
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must not be in decommissioned or decommissioning state");
+      prerequisiteCheck.setFailReason("There are services in decommission or decommissioning state");
     }
   }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheck.java

@@ -53,7 +53,7 @@ public class ServicesMaintenanceModeCheck extends AbstractCheckDescriptor {
     }
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must not be in Maintenance Mode");
+      prerequisiteCheck.setFailReason("Some services are in Maintenance Mode");
     }
   }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java

@@ -57,7 +57,7 @@ public class ServicesNamenodeHighAvailabilityCheck extends AbstractCheckDescript
     if (!config.getProperties().containsKey("dfs.nameservices")) {
       prerequisiteCheck.getFailedOn().add("HDFS");
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("Namenode high availability is disabled. Verify that dfs.nameservices property is present in hdfs-site.xml");
+      prerequisiteCheck.setFailReason("Namenode high availability is disabled");
     }
   }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java

@@ -56,7 +56,7 @@ public class ServicesUpCheck extends AbstractCheckDescriptor {
 
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason(formatEntityList(prerequisiteCheck.getFailedOn()) + " must be STARTED");
+      prerequisiteCheck.setFailReason("Some services are down");
     }
   }
 }

+ 1 - 2
ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheck.java

@@ -65,8 +65,7 @@ public class ServicesYarnWorkPreservingCheck extends AbstractCheckDescriptor {
       !BooleanUtils.toBoolean(config.getProperties().get("yarn.resourcemanager.work-preserving-recovery.enabled"))) {
       prerequisiteCheck.getFailedOn().add("YARN");
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("YARN doesn't have work preserving restart. Verify that yarn.resourcemanager.work-preserving-recovery.enabled property"
-          + " is present in yarn-site.xml and is set to true");
+      prerequisiteCheck.setFailReason("YARN doesn't have work preserving restart, yarn.resourcemanager.work-preserving-recovery.enabled property is missing");
     }
   }
 }

+ 0 - 1
ambari-server/src/test/java/org/apache/ambari/server/api/services/GroupServiceTest.java

@@ -36,7 +36,6 @@ import java.util.Map;
  */
 public class GroupServiceTest extends BaseServiceTest {
 
-  @Override
   public List<ServiceTestInvocation> getTestInvocations() throws Exception {
     List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
 

+ 0 - 76
ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java

@@ -1,76 +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.ambari.server.checks;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.state.stack.PrereqCheckType;
-import org.apache.ambari.server.state.stack.PrerequisiteCheck;
-import org.junit.Test;
-
-/**
- * Unit tests for AbstractCheckDescriptor
- */
-public class AbstractCheckDescriptorTest {
-
-  private class TestCheckImpl extends AbstractCheckDescriptor {
-
-    public TestCheckImpl(String id, PrereqCheckType type, String description) {
-      super(id, type, description);
-    }
-
-    @Override
-    public void perform(PrerequisiteCheck prerequisiteCheck,
-        PrereqCheckRequest request) throws AmbariException {
-    }
-  }
-
-  @Test
-  public void testFormatEntityList() {
-    AbstractCheckDescriptor check = new TestCheckImpl(null, PrereqCheckType.HOST, null);
-
-    Assert.assertEquals("", check.formatEntityList(null));
-
-    final List<String> failedOn = new ArrayList<String>();
-    Assert.assertEquals("", check.formatEntityList(failedOn));
-
-    failedOn.add("host1");
-    Assert.assertEquals("host1 host", check.formatEntityList(failedOn));
-
-    failedOn.add("host2");
-    Assert.assertEquals("host1 and host2 hosts", check.formatEntityList(failedOn));
-
-    failedOn.add("host3");
-    Assert.assertEquals("host1, host2 and host3 hosts", check.formatEntityList(failedOn));
-
-    check = new TestCheckImpl(null, PrereqCheckType.CLUSTER, null);
-    Assert.assertEquals("host1, host2 and host3 clusters", check.formatEntityList(failedOn));
-
-    check = new TestCheckImpl(null, PrereqCheckType.SERVICE, null);
-    Assert.assertEquals("host1, host2 and host3 services", check.formatEntityList(failedOn));
-
-    check = new TestCheckImpl(null, null, null);
-    Assert.assertEquals("host1, host2 and host3", check.formatEntityList(failedOn));
-  }
-
-}