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-17878. after upgrade is finalized add service operation hang in Preparing to execute Set Keytab (dlysnichenko)
Date Mon, 25 Jul 2016 16:14:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 1cc6b9095 -> 78f3a060a
  refs/heads/trunk c5b1285ef -> 8b041be4a


AMBARI-17878. after upgrade is finalized add service operation hang in Preparing to execute
Set Keytab (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 8b041be4a1f38069b72bcd8269cec9b8e9cd6e3e
Parents: c5b1285
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Mon Jul 25 19:13:26 2016 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Mon Jul 25 19:13:26 2016 +0300

----------------------------------------------------------------------
 .../server/actionmanager/ActionScheduler.java   | 42 +++++++++++---------
 .../apache/ambari/server/agent/ActionQueue.java |  1 +
 .../actionmanager/TestActionScheduler.java      | 31 +++++++++++++++
 3 files changed, 56 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8b041be4/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 90ffa5b..cc168fd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -1038,18 +1038,21 @@ class ActionScheduler implements Runnable {
    */
   void cancelHostRoleCommands(Collection<HostRoleCommand> hostRoleCommands, String
reason) {
     for (HostRoleCommand hostRoleCommand : hostRoleCommands) {
-      if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED) {
-        // Dequeue all tasks that have been already scheduled for sending to agent
-        actionQueue.dequeue(hostRoleCommand.getHostName(),
-                hostRoleCommand.getExecutionCommandWrapper().
-                        getExecutionCommand().getCommandId());
-      }
-      if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED ||
-            hostRoleCommand.getStatus() == HostRoleStatus.IN_PROGRESS) {
-        CancelCommand cancelCommand = new CancelCommand();
-        cancelCommand.setTargetTaskId(hostRoleCommand.getTaskId());
-        cancelCommand.setReason(reason);
-        actionQueue.enqueue(hostRoleCommand.getHostName(), cancelCommand);
+      // There are no server actions in actionQueue
+      if (!Role.AMBARI_SERVER_ACTION.equals(hostRoleCommand.getRole())) {
+        if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED) {
+          // Dequeue all tasks that have been already scheduled for sending to agent
+          actionQueue.dequeue(hostRoleCommand.getHostName(),
+              hostRoleCommand.getExecutionCommandWrapper().
+              getExecutionCommand().getCommandId());
+        }
+        if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED ||
+              hostRoleCommand.getStatus() == HostRoleStatus.IN_PROGRESS) {
+          CancelCommand cancelCommand = new CancelCommand();
+          cancelCommand.setTargetTaskId(hostRoleCommand.getTaskId());
+          cancelCommand.setReason(reason);
+          actionQueue.enqueue(hostRoleCommand.getHostName(), cancelCommand);
+        }
       }
 
       if (hostRoleCommand.getStatus().isHoldingState()) {
@@ -1069,12 +1072,15 @@ class ActionScheduler implements Runnable {
   }
   void cancelCommandOnTimeout(Collection<HostRoleCommand> hostRoleCommands) {
     for (HostRoleCommand hostRoleCommand : hostRoleCommands) {
-      if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED ||
-            hostRoleCommand.getStatus() == HostRoleStatus.IN_PROGRESS) {
-        CancelCommand cancelCommand = new CancelCommand();
-        cancelCommand.setTargetTaskId(hostRoleCommand.getTaskId());
-        cancelCommand.setReason("");
-        actionQueue.enqueue(hostRoleCommand.getHostName(), cancelCommand);
+      // There are no server actions in actionQueue
+      if (!Role.AMBARI_SERVER_ACTION.equals(hostRoleCommand.getRole())) {
+        if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED ||
+              hostRoleCommand.getStatus() == HostRoleStatus.IN_PROGRESS) {
+          CancelCommand cancelCommand = new CancelCommand();
+          cancelCommand.setTargetTaskId(hostRoleCommand.getTaskId());
+          cancelCommand.setReason("");
+          actionQueue.enqueue(hostRoleCommand.getHostName(), cancelCommand);
+        }
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8b041be4/ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java
index 24640d3..6c7803e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java
@@ -56,6 +56,7 @@ public class ActionQueue {
    * Adds command to queue for given hostname
    * @param hostname - hostname of node
    * @param cmd - command to add to queue
+   * @throws NullPointerException - if hostname is {@code}null{@code}
    */
   public void enqueue(String hostname, AgentCommand cmd) {
     Queue<AgentCommand> q = getQueue(hostname);

http://git-wip-us.apache.org/repos/asf/ambari/blob/8b041be4/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index 0b24765..cb803ef 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -2503,6 +2503,37 @@ public class TestActionScheduler {
 
   }
 
+  @Test
+  public void testAbortAmbariServerAction() {
+    UnitOfWork unitOfWork = EasyMock.createMock(UnitOfWork.class);
+    ActionDBAccessor db = EasyMock.createMock(ActionDBAccessor.class);
+    ActionQueue aq = new ActionQueue();
+    Clusters fsm = EasyMock.createMock(Clusters.class);
+    Configuration conf = new Configuration(new Properties());
+    HostEntity hostEntity1 = new HostEntity();
+    hostEntity1.setHostName("h1");
+    hostDAO.merge(hostEntity1);
+
+    EasyMock.replay(db);
+
+    ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
+        new HostsMap((String) null),
+        unitOfWork, null, conf);
+
+    HostRoleCommand hrc1 = hostRoleCommandFactory.create("h1", Role.NAMENODE, null, RoleCommand.EXECUTE);
+    hrc1.setStatus(HostRoleStatus.COMPLETED);
+    HostRoleCommand hrc3 = hostRoleCommandFactory.create(null, Role.AMBARI_SERVER_ACTION,
null, RoleCommand.CUSTOM_COMMAND);
+    hrc3.setStatus(HostRoleStatus.IN_PROGRESS);
+    HostRoleCommand hrc4 = hostRoleCommandFactory.create("h1", Role.FLUME_HANDLER, null,
RoleCommand.EXECUTE);
+    hrc4.setStatus(HostRoleStatus.PENDING);
+
+    List<HostRoleCommand> hostRoleCommands = Arrays.asList(hrc1, hrc3, hrc4);
+
+    scheduler.cancelHostRoleCommands(hostRoleCommands, "foo");
+
+    EasyMock.verify(db);
+  }
+
   /**
    * Tests that command failures in skippable stages do not cause the request to
    * be aborted.


Mime
View raw message