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 bafa182 AMBARI-23343. Server should acknowledge agent about received
reports. (mpapirkovskyy)
bafa182 is described below
commit bafa18256652258df3d19dd48ff101829e53580c
Author: Myroslav Papirkovskyi <[email protected]>
AuthorDate: Fri Mar 23 18:16:47 2018 +0200
AMBARI-23343. Server should acknowledge agent about received reports.
(mpapirkovskyy)
---
.../ambari/server/agent/HeartBeatResponse.java | 4 ++-
.../ambari/server/agent/RegistrationResponse.java | 3 +-
.../server/agent/stomp/AgentReportsController.java | 12 ++++---
.../ambari/server/agent/stomp/ReportsResponse.java | 24 +++++++++++++
.../ambari/server/agent/stomp/StompResponse.java | 42 ++++++++++++++++++++++
5 files changed, 79 insertions(+), 6 deletions(-)
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
index b32c974..67e5850 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
@@ -21,6 +21,8 @@ package org.apache.ambari.server.agent;
import java.util.ArrayList;
import java.util.List;
+import org.apache.ambari.server.agent.stomp.StompResponse;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.annotations.SerializedName;
@@ -29,7 +31,7 @@ import com.google.gson.annotations.SerializedName;
* Controller to Agent response data model.
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class HeartBeatResponse {
+public class HeartBeatResponse extends StompResponse {
@SerializedName("responseId")
@com.fasterxml.jackson.annotation.JsonProperty("id")
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
index 20ce499..a46ff08 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.ambari.server.agent.stomp.StompResponse;
import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -33,7 +34,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
*
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class RegistrationResponse {
+public class RegistrationResponse extends StompResponse {
@JsonProperty("response")
@JsonIgnore
private RegistrationStatus response;
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
index ccfbc75..885b308 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
@@ -62,7 +62,7 @@ public class AgentReportsController {
}
@MessageMapping("/component_status")
- public void handleComponentReportStatus(@Header String simpSessionId,
ComponentStatusReports message)
+ public ReportsResponse handleComponentReportStatus(@Header String
simpSessionId, ComponentStatusReports message)
throws WebApplicationException, InvalidStateTransitionException,
AmbariException {
List<ComponentStatus> statuses = new ArrayList<>();
for (Map.Entry<String, List<ComponentStatusReport>> clusterReport :
message.getComponentStatusReports().entrySet()) {
@@ -78,10 +78,11 @@ public class AgentReportsController {
agentReportsProcessor.addAgentReport(new
AgentReport(agentSessionManager.getHost(simpSessionId).getHostName(),
statuses, null, null));
+ return new ReportsResponse();
}
@MessageMapping("/commands_status")
- public void handleCommandReportStatus(@Header String simpSessionId,
CommandStatusReports message)
+ public ReportsResponse handleCommandReportStatus(@Header String
simpSessionId, CommandStatusReports message)
throws WebApplicationException, InvalidStateTransitionException,
AmbariException {
List<CommandReport> statuses = new ArrayList<>();
for (Map.Entry<String, List<CommandReport>> clusterReport :
message.getClustersComponentReports().entrySet()) {
@@ -90,20 +91,23 @@ public class AgentReportsController {
agentReportsProcessor.addAgentReport(new
AgentReport(agentSessionManager.getHost(simpSessionId).getHostName(),
null, statuses, null));
+ return new ReportsResponse();
}
@MessageMapping("/host_status")
- public void handleHostReportStatus(@Header String simpSessionId,
HostStatusReport message) throws AmbariException {
+ public ReportsResponse handleHostReportStatus(@Header String simpSessionId,
HostStatusReport message) throws AmbariException {
agentReportsProcessor.addAgentReport(new
AgentReport(agentSessionManager.getHost(simpSessionId).getHostName(),
null, null, message));
+ return new ReportsResponse();
}
@MessageMapping("/alerts_status")
- public void handleAlertsStatus(@Header String simpSessionId, Alert[]
message) throws AmbariException {
+ public ReportsResponse handleAlertsStatus(@Header String simpSessionId,
Alert[] message) throws AmbariException {
String hostName = agentSessionManager.getHost(simpSessionId).getHostName();
List<Alert> alerts = Arrays.asList(message);
LOG.info("Handling {} alerts status for host {}", alerts.size(), hostName);
hh.getHeartbeatProcessor().processAlerts(hostName, alerts);
+ return new ReportsResponse();
}
}
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/ReportsResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/ReportsResponse.java
new file mode 100644
index 0000000..dcb18ca
--- /dev/null
+++
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/ReportsResponse.java
@@ -0,0 +1,24 @@
+/*
+ * 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.agent.stomp;
+
+/**
+ * Agent report default response. Contains status only.
+ */
+public class ReportsResponse extends StompResponse {
+}
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/StompResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/StompResponse.java
new file mode 100644
index 0000000..cfac00f
--- /dev/null
+++
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/StompResponse.java
@@ -0,0 +1,42 @@
+/*
+ * 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.agent.stomp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Default stomp topic response. Minimal response is
{#StompResponseStatus.OK}, also is used to return correlation id to agent.
+ */
+public class StompResponse {
+
+ @JsonProperty("status")
+ private StompResponseStatus status = StompResponseStatus.OK;
+
+ public StompResponseStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(StompResponseStatus status) {
+ this.status = status;
+ }
+
+ public enum StompResponseStatus {
+ OK,
+ FAILED
+ }
+}
--
To stop receiving notification emails like this one, please contact
[email protected].