This is an automated email from the ASF dual-hosted git repository.

mpapirkovskyy pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new c48fb74  AMBARI-23492. Server should acknowledge api endpoint about 
host-component state before deletion. (mpapirkovskyy)
c48fb74 is described below

commit c48fb74402cef258aa8adec9dcd00e97cd71887b
Author: Myroslav Papirkovskyi <mpapirkovs...@apache.org>
AuthorDate: Fri Apr 6 15:17:52 2018 +0300

    AMBARI-23492. Server should acknowledge api endpoint about host-component 
state before deletion. (mpapirkovskyy)
---
 .../ambari/server/agent/stomp/TopologyHolder.java       |  1 +
 .../server/agent/stomp/dto/TopologyComponent.java       | 15 +++++++++++++++
 .../internal/DeleteHostComponentStatusMetaData.java     | 17 ++++++++++++++---
 .../state/svccomphost/ServiceComponentHostImpl.java     |  4 +++-
 .../ambari/server/topology/TopologyDeleteFormer.java    |  1 +
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
index 4856440..18294a1 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java
@@ -176,6 +176,7 @@ public class TopologyHolder extends 
AgentClusterDataHolder<TopologyUpdateEvent>
         for (TopologyComponent topologyComponent : 
topologyCluster.getTopologyComponents()) {
           topologyComponent.setHostNames(new HashSet<>());
           topologyComponent.setPublicHostNames(new HashSet<>());
+          topologyComponent.setLastComponentState(null);
         }
         if 
(topologyUpdateEvent.getEventType().equals(TopologyUpdateEvent.EventType.DELETE))
 {
           for (TopologyHost topologyHost : topologyCluster.getTopologyHosts()) 
{
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/dto/TopologyComponent.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/dto/TopologyComponent.java
index dc74c13..7db45da 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/dto/TopologyComponent.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/dto/TopologyComponent.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
 
+import org.apache.ambari.server.state.State;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
@@ -40,6 +41,7 @@ public class TopologyComponent {
   private Set<String> publicHostNames = new HashSet<>();
   private TreeMap<String, String> componentLevelParams = new TreeMap<>();
   private TreeMap<String, String> commandParams = new TreeMap<>();
+  private State lastComponentState;
 
   private TopologyComponent() {
   }
@@ -98,6 +100,11 @@ public class TopologyComponent {
       return this;
     }
 
+    public Builder setLastComponentState(State lastComponentState) {
+      TopologyComponent.this.setLastComponentState(lastComponentState);
+      return this;
+    }
+
     public TopologyComponent build() {
       return TopologyComponent.this;
     }
@@ -269,6 +276,14 @@ public class TopologyComponent {
     this.commandParams = commandParams;
   }
 
+  public State getLastComponentState() {
+    return lastComponentState;
+  }
+
+  public void setLastComponentState(State lastComponentState) {
+    this.lastComponentState = lastComponentState;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
index 4a65272..7237f5b 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
@@ -23,6 +23,7 @@ import java.util.Set;
 import javax.annotation.concurrent.NotThreadSafe;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.state.State;
 
 @NotThreadSafe
 public class DeleteHostComponentStatusMetaData extends DeleteStatusMetaData {
@@ -33,9 +34,9 @@ public class DeleteHostComponentStatusMetaData extends 
DeleteStatusMetaData {
   }
 
   public void addDeletedHostComponent(String componentName, String 
serviceName, String hostName, Long hostId,
-                                      String clusterId, String version) {
+                                      String clusterId, String version, State 
lastComponentState) {
     removedHostComponents.add(new HostComponent(componentName, serviceName, 
hostId,
-        hostName, clusterId, version));
+        hostName, clusterId, version, lastComponentState));
     addDeletedKey(componentName + "/" + hostName);
   }
 
@@ -58,15 +59,17 @@ public class DeleteHostComponentStatusMetaData extends 
DeleteStatusMetaData {
     private String hostName;
     private String clusterId;
     private String version;
+    private State lastComponentState;
 
     public HostComponent(String componentName, String serviceName, Long 
hostId, String hostName,
-                         String clusterId, String version) {
+                         String clusterId, String version, State 
lastComponentState) {
       this.componentName = componentName;
       this.serviceName = serviceName;
       this.hostId = hostId;
       this.hostName = hostName;
       this.clusterId = clusterId;
       this.version = version;
+      this.lastComponentState = lastComponentState;
     }
 
     public String getComponentName() {
@@ -116,5 +119,13 @@ public class DeleteHostComponentStatusMetaData extends 
DeleteStatusMetaData {
     public void setHostId(Long hostId) {
       this.hostId = hostId;
     }
+
+    public State getLastComponentState() {
+      return lastComponentState;
+    }
+
+    public void setLastComponentState(State lastComponentState) {
+      this.lastComponentState = lastComponentState;
+    }
   }
 }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
index b588355..5678c78 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
@@ -1387,6 +1387,7 @@ public class ServiceComponentHostImpl implements 
ServiceComponentHost {
       String serviceName = getServiceName();
       String componentName = getServiceComponentName();
       String hostName = getHostName();
+      State lastComponentState = getState();
       boolean recoveryEnabled = isRecoveryEnabled();
       boolean masterComponent = serviceComponent.isMasterComponent();
 
@@ -1400,7 +1401,8 @@ public class ServiceComponentHostImpl implements 
ServiceComponentHost {
           hostName,
           getHost().getHostId(),
           Long.toString(clusterId),
-          version);
+          version,
+          lastComponentState);
     }
   }
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyDeleteFormer.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyDeleteFormer.java
index a5953b9..c39fb14 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyDeleteFormer.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyDeleteFormer.java
@@ -78,6 +78,7 @@ public class TopologyDeleteFormer {
           .setVersion(hostComponent.getVersion())
           .setHostIds(new HashSet<>(Arrays.asList(hostComponent.getHostId())))
           .setHostNames(new 
HashSet<>(Arrays.asList(hostComponent.getHostName())))
+          .setLastComponentState(hostComponent.getLastComponentState())
           .build();
 
       String clusterId = hostComponent.getClusterId();

-- 
To stop receiving notification emails like this one, please contact
mpapirkovs...@apache.org.

Reply via email to