jrushford commented on a change in pull request #8689:
URL: https://github.com/apache/trafficserver/pull/8689#discussion_r827395647



##########
File path: src/traffic_server/HostStatus.cc
##########
@@ -20,85 +20,32 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
+#include <fstream>
 #include "HostStatus.h"
 #include "ProcessManager.h"
 
 #include "tscore/BufferWriter.h"
 #include "rpc/jsonrpc/JsonRPC.h"
+#include "shared/rpc/RPCRequests.h"
 
-ts::Rv<YAML::Node> server_set_status(std::string_view const &id, YAML::Node 
const &params);
-
-inline void
-getStatName(std::string &stat_name, const std::string_view name)
-{
-  stat_name.clear();
-  stat_name.append(stat_prefix).append(name);
-}
-
-static void
-mgmt_host_status_up_callback(ts::MemSpan<void> span)
+namespace
 {
-  MgmtInt op;
-  MgmtMarshallString name;
-  MgmtMarshallInt down_time;
-  MgmtMarshallString reason_str;
-  std::string stat_name;
-  char buf[1024]                         = {0};
-  char *data                             = static_cast<char *>(span.data());
-  auto len                               = span.size();
-  static const MgmtMarshallType fields[] = {MGMT_MARSHALL_INT, 
MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING, MGMT_MARSHALL_INT};
-  Debug("host_statuses", "%s:%s:%d - data: %s, len: %ld\n", __FILE__, 
__func__, __LINE__, data, len);
-
-  if (mgmt_message_parse(data, len, fields, countof(fields), &op, &name, 
&reason_str, &down_time) == -1) {
-    Error("Plugin message - RPC parsing error - message discarded.");
-  }
-  Debug("host_statuses", "op: %ld, name: %s, down_time: %d, reason_str: %s", 
static_cast<long>(op), name,
-        static_cast<int>(down_time), reason_str);
+const std::string STATUS_LIST_KEY{"statusList"};
+const std::string ERROR_LIST_KEY{"errorList"};
+const std::string HOST_NAME_KEY{"hostname"};
+const std::string STATUS_KEY{"status"};
 
-  unsigned int reason = Reason::getReason(reason_str);
-
-  getStatName(stat_name, name);
-  if (data != nullptr) {
-    Debug("host_statuses", "marking up server %s", data);
-    HostStatus &hs = HostStatus::instance();
-    if (hs.getHostStat(stat_name, buf, 1024) == REC_ERR_FAIL) {
-      hs.createHostStat(name);
-    }
-    hs.setHostStatus(name, TSHostStatus::TS_HOST_STATUS_UP, down_time, reason);
-  }
-}
-
-static void
-mgmt_host_status_down_callback(ts::MemSpan<void> span)
-{
-  MgmtInt op;
-  MgmtMarshallString name;
-  MgmtMarshallInt down_time;
-  MgmtMarshallString reason_str;
-  std::string stat_name;
-  char *data                             = static_cast<char *>(span.data());
-  char buf[1024]                         = {0};
-  auto len                               = span.size();
-  static const MgmtMarshallType fields[] = {MGMT_MARSHALL_INT, 
MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING, MGMT_MARSHALL_INT};
-  Debug("host_statuses", "%s:%s:%d - data: %s, len: %ld\n", __FILE__, 
__func__, __LINE__, data, len);
-
-  if (mgmt_message_parse(data, len, fields, countof(fields), &op, &name, 
&reason_str, &down_time) == -1) {
-    Error("Plugin message - RPC parsing error - message discarded.");
-  }
-  Debug("host_statuses", "op: %ld, name: %s, down_time: %d, reason_str: %s", 
static_cast<long>(op), name,
-        static_cast<int>(down_time), reason_str);
+struct HostCmdInfo {
+  TSHostStatus type{TSHostStatus::TS_HOST_STATUS_INIT};
+  unsigned int reasonType{0};
+  std::vector<std::string> hosts;
+  int time{0};
+};
 
-  unsigned int reason = Reason::getReason(reason_str);
+} // namespace
 
-  if (data != nullptr) {
-    Debug("host_statuses", "marking down server %s", name);
-    HostStatus &hs = HostStatus::instance();
-    if (hs.getHostStat(stat_name, buf, 1024) == REC_ERR_FAIL) {
-      hs.createHostStat(name);
-    }
-    hs.setHostStatus(name, TSHostStatus::TS_HOST_STATUS_DOWN, down_time, 
reason);
-  }
-}
+ts::Rv<YAML::Node> server_get_status(std::string_view const &id, YAML::Node 
const &params);
+ts::Rv<YAML::Node> server_set_status(std::string_view const &id, YAML::Node 
const &params);

Review comment:
       @ywkaras okay, will pass by value.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to