You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/09/28 17:49:45 UTC
ambari git commit: AMBARI-18470. RU/EU cannot start because
ServiceCheckValidityCheck incorrectly calculates Service Checks that ran
(alejandro)
Repository: ambari
Updated Branches:
refs/heads/trunk 05e65e297 -> 84ecbb404
AMBARI-18470. RU/EU cannot start because ServiceCheckValidityCheck incorrectly calculates Service Checks that ran (alejandro)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/84ecbb40
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/84ecbb40
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/84ecbb40
Branch: refs/heads/trunk
Commit: 84ecbb404280b541f15e2b23068ecd449bdd930c
Parents: 05e65e2
Author: Alejandro Fernandez <af...@hortonworks.com>
Authored: Mon Sep 26 14:55:47 2016 -0700
Committer: Alejandro Fernandez <af...@hortonworks.com>
Committed: Wed Sep 28 10:55:19 2016 -0700
----------------------------------------------------------------------
.../server/checks/ServiceCheckValidityCheck.java | 16 +++++++++-------
.../checks/ServiceCheckValidityCheckTest.java | 4 ++--
2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/84ecbb40/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 2bc22c9..b77e1d5 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
@@ -19,6 +19,7 @@ package org.apache.ambari.server.checks;
import java.text.SimpleDateFormat;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -31,9 +32,12 @@ import org.apache.ambari.server.RoleCommand;
import org.apache.ambari.server.controller.PrereqCheckRequest;
import org.apache.ambari.server.controller.internal.PageRequestImpl;
import org.apache.ambari.server.controller.internal.RequestImpl;
+import org.apache.ambari.server.controller.internal.SortRequestImpl;
import org.apache.ambari.server.controller.internal.TaskResourceProvider;
import org.apache.ambari.server.controller.spi.PageRequest;
import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.SortRequest;
+import org.apache.ambari.server.controller.spi.SortRequestProperty;
import org.apache.ambari.server.controller.utilities.PredicateBuilder;
import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.orm.dao.ServiceConfigDAO;
@@ -65,8 +69,11 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor {
private static final Logger LOG = LoggerFactory.getLogger(ServiceCheckValidityCheck.class);
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
+ private static List<SortRequestProperty> sortRequestProperties =
+ Collections.singletonList(new SortRequestProperty(TaskResourceProvider.TASK_START_TIME_PROPERTY_ID, SortRequest.Order.DESC));
+ private static SortRequest sortRequest = new SortRequestImpl(sortRequestProperties);
private static final PageRequestImpl PAGE_REQUEST = new PageRequestImpl(PageRequest.StartingPoint.End, 1000, 0, null, null);
- private static final RequestImpl REQUEST = new RequestImpl(null, null, null, null, null, PAGE_REQUEST);
+ private static final RequestImpl REQUEST = new RequestImpl(null, null, null, null, sortRequest, PAGE_REQUEST);
private static final Predicate PREDICATE = new PredicateBuilder().property(TaskResourceProvider.TASK_COMMAND_PROPERTY_ID)
.equals(RoleCommand.SERVICE_CHECK.name()).toPredicate();
@@ -117,14 +124,9 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor {
for (HostRoleCommandEntity command : commands) {
Role role = command.getRole();
+ // Because results are already sorted by start_time desc, first occurrence is guaranteed to have max(start_time).
if (!latestTimestamps.containsKey(role)) {
latestTimestamps.put(role, command);
- } else {
- Long latest = latestTimestamps.get(role).getStartTime();
-
- if (command.getStartTime() > latest) {
- latestTimestamps.put(role, command);
- }
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/84ecbb40/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 8d72b96..dd843a8 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
@@ -169,7 +169,7 @@ public class ServiceCheckValidityCheckTest {
HostRoleCommandEntity hostRoleCommandEntity2 = new HostRoleCommandEntity();
hostRoleCommandEntity2.setRoleCommand(RoleCommand.SERVICE_CHECK);
hostRoleCommandEntity2.setCommandDetail(COMMAND_DETAIL);
- hostRoleCommandEntity2.setStartTime(SERVICE_CHECK_START_TIME + 3000L);
+ hostRoleCommandEntity2.setStartTime(CONFIG_CREATE_TIMESTAMP - 1L);
hostRoleCommandEntity2.setRole(Role.HDFS_SERVICE_CHECK);
when(serviceConfigDAO.getLastServiceConfig(eq(CLUSTER_ID), eq(SERVICE_NAME))).thenReturn(serviceConfigEntity);
@@ -177,6 +177,6 @@ public class ServiceCheckValidityCheckTest {
PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME);
serviceCheckValidityCheck.perform(check, new PrereqCheckRequest(CLUSTER_NAME));
- Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
}
}
\ No newline at end of file