Author: smohanty
Date: Sat Apr 13 04:39:34 2013
New Revision: 1467547
URL: http://svn.apache.org/r1467547
Log:
AMBARI-1919. JobTracker History Server failed to come up on 1.3.0 stack and the
request for service stall is stalled. (smohanty)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467547&r1=1467546&r2=1467547&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Apr 13 04:39:34 2013
@@ -713,6 +713,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1919. JobTracker History Server failed to come up on 1.3.0 stack
+ and the request for service stall is stalled. (smohanty)
+
AMBARI-1900. Update the DDL update script to modify the table to includei
ph_cpu_count. (smohanty)
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java?rev=1467547&r1=1467546&r2=1467547&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
Sat Apr 13 04:39:34 2013
@@ -102,12 +102,21 @@ public class ActionDBAccessorImpl implem
*/
@Override
public void abortOperation(long requestId) {
- Collection<HostRoleStatus> sourceStatuses =
- Arrays.asList(HostRoleStatus.QUEUED, HostRoleStatus.IN_PROGRESS,
- HostRoleStatus.PENDING);
- int result = hostRoleCommandDAO.updateStatusByRequestId(requestId,
- HostRoleStatus.ABORTED, sourceStatuses);
- LOG.info("Aborted {} commands " + result);
+ List<HostRoleCommandEntity> commands =
+ hostRoleCommandDAO.findByRequest(requestId);
+ for (HostRoleCommandEntity command : commands) {
+ if(command.getStatus() == HostRoleStatus.QUEUED ||
+ command.getStatus() == HostRoleStatus.IN_PROGRESS ||
+ command.getStatus() == HostRoleStatus.PENDING) {
+ command.setStatus(HostRoleStatus.ABORTED);
+ hostRoleCommandDAO.merge(command);
+ LOG.info("Aborting command. Hostname " + command.getHostName()
+ + " role " + command.getRole()
+ + " requestId " + command.getRequestId()
+ + " taskId " + command.getTaskId()
+ + " stageId " + command.getStageId());
+ }
+ }
}
/* (non-Javadoc)
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java?rev=1467547&r1=1467546&r2=1467547&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
Sat Apr 13 04:39:34 2013
@@ -30,6 +30,7 @@ import static org.apache.commons.lang.St
@Table(name = "host_role_command")
@Entity
+@Cacheable(false)
@TableGenerator(name = "host_role_command_id_generator",
table = "ambari_sequences", pkColumnName = "sequence_name",
valueColumnName = "value"
, pkColumnValue = "host_role_command_id_seq"
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java?rev=1467547&r1=1467546&r2=1467547&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
Sat Apr 13 04:39:34 2013
@@ -224,6 +224,65 @@ public class TestActionDBAccessorImpl {
assertEquals("Request IDs not matches", requestIds, requestIdsResult);
}
+ @Test
+ public void testAbortRequest() throws AmbariException {
+ Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor
test");
+ s.setStageId(stageId);
+
+ clusters.addHost("host2");
+ clusters.getHost("host2").persist();
+ clusters.addHost("host3");
+ clusters.getHost("host3").persist();
+ clusters.addHost("host4");
+ clusters.getHost("host4").persist();
+
+ s.addHostRoleExecutionCommand("host1", Role.HBASE_MASTER,
+ RoleCommand.START,
+ new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
+ "host1", System.currentTimeMillis(),
+ new HashMap<String, String>()), "cluster1", "HBASE");
+ s.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
+ RoleCommand.START,
+ new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
+ "host2", System.currentTimeMillis(),
+ new HashMap<String, String>()), "cluster1", "HBASE");
+ s.addHostRoleExecutionCommand(
+ "host3",
+ Role.HBASE_REGIONSERVER,
+ RoleCommand.START,
+ new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
+ .toString(), "host3", System.currentTimeMillis(),
+ new HashMap<String, String>()), "cluster1", "HBASE");
+ s.addHostRoleExecutionCommand(
+ "host4",
+ Role.HBASE_REGIONSERVER,
+ RoleCommand.START,
+ new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
+ .toString(), "host4", System.currentTimeMillis(),
+ new HashMap<String, String>()), "cluster1", "HBASE");
+ List<Stage> stages = new ArrayList<Stage>();
+ stages.add(s);
+ s.getOrderedHostRoleCommands().get(0).setStatus(HostRoleStatus.PENDING);
+
s.getOrderedHostRoleCommands().get(1).setStatus(HostRoleStatus.IN_PROGRESS);
+ s.getOrderedHostRoleCommands().get(2).setStatus(HostRoleStatus.QUEUED);
+
+ HostRoleCommand cmd = s.getOrderedHostRoleCommands().get(3);
+ String hostName = cmd.getHostName();
+ cmd.setStatus(HostRoleStatus.COMPLETED);
+
+ db.persistActions(stages);
+ db.abortOperation(requestId);
+
+ List<HostRoleCommand> commands = db.getRequestTasks(requestId);
+ for(HostRoleCommand command : commands) {
+ if(command.getHostName().equals(hostName)) {
+ assertEquals(HostRoleStatus.COMPLETED, command.getStatus());
+ } else {
+ assertEquals(HostRoleStatus.ABORTED, command.getStatus());
+ }
+ }
+ }
+
private void populateActionDB(ActionDBAccessor db, String hostname,
long requestId, long stageId) {
Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor
test");