This is an automated email from the ASF dual-hosted git repository.
saipranav pushed a commit to branch ResView
in repository https://gitbox.apache.org/repos/asf/incubator-resilientdb.git
The following commit(s) were added to refs/heads/ResView by this push:
new 292d9e89 "Crow service added"
292d9e89 is described below
commit 292d9e8945bc6727e433d2c9e48bbfe8d703a671
Author: Saipranav Kotamreddy <[email protected]>
AuthorDate: Fri Feb 23 20:02:10 2024 -0800
"Crow service added"
---
WORKSPACE | 21 +++++++++++++++++++++
monitoring/prometheus/prometheus.yml | 10 +++++-----
platform/statistic/BUILD | 3 ++-
platform/statistic/stats.cpp | 23 ++++++++++++++++++++++-
platform/statistic/stats.h | 4 ++++
third_party/BUILD | 7 +++++++
6 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/WORKSPACE b/WORKSPACE
index 317fefbf..177d8f26 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -224,3 +224,24 @@ http_archive(
strip_prefix = "json-3.9.1",
urls = ["https://github.com/nlohmann/json/archive/v3.9.1.tar.gz"],
)
+
+http_archive(
+ name = "com_crowcpp_crow",
+ build_file = "//third_party:crow.BUILD",
+ sha256 =
"f95128a8976fae6f2922823e07da59edae277a460776572a556a4b663ff5ee4b",
+ strip_prefix = "Crow-1.0-5",
+ url = "https://github.com/CrowCpp/Crow/archive/refs/tags/v1.0+5.zip",
+)
+
+bind(
+ name = "asio",
+ actual = "@com_chriskohlhoff_asio//:asio",
+)
+
+http_archive(
+ name = "com_chriskohlhoff_asio",
+ build_file = "//third_party:asio.BUILD",
+ sha256 =
"babcdfd2c744905a73d20de211b51367bda0d5200f11d654c4314b909d8c963c",
+ strip_prefix = "asio-asio-1-26-0",
+ url =
"https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-26-0.zip",
+)
\ No newline at end of file
diff --git a/monitoring/prometheus/prometheus.yml
b/monitoring/prometheus/prometheus.yml
index c0046d38..8463c696 100644
--- a/monitoring/prometheus/prometheus.yml
+++ b/monitoring/prometheus/prometheus.yml
@@ -25,19 +25,19 @@ scrape_configs:
- targets: ["localhost:9090"]
- job_name: "node_exporter1"
static_configs:
- - targets: ["172.31.52.247:9100"]
+ - targets: ["localhost:9100"]
- job_name: "node_exporter2"
static_configs:
- - targets: ["172.31.54.193:9100"]
+ - targets: ["localhost:9100"]
- job_name: "node_exporter3"
static_configs:
- - targets: ["172.31.55.48:9100"]
+ - targets: ["localhost:9100"]
- job_name: "node_exporter4"
static_configs:
- - targets: ["172.31.53.140:9100"]
+ - targets: ["localhost:9100"]
- job_name: "node_exporter5"
static_configs:
- - targets: ["172.31.57.186:9100"]
+ - targets: ["localhost:9100"]
- job_name: "cpp_client1"
static_configs:
- targets: ["172.31.52.247:8090"]
diff --git a/platform/statistic/BUILD b/platform/statistic/BUILD
index 88267d33..e20fd916 100644
--- a/platform/statistic/BUILD
+++ b/platform/statistic/BUILD
@@ -17,7 +17,8 @@ cc_library(
"//third_party:prometheus",
"//platform/common/network:tcp_socket",
"//common:asio",
- "//common:beast"
+ "//common:beast",
+ "//third_party:crow",
],
)
diff --git a/platform/statistic/stats.cpp b/platform/statistic/stats.cpp
index 16334ee4..68e1555a 100644
--- a/platform/statistic/stats.cpp
+++ b/platform/statistic/stats.cpp
@@ -95,6 +95,7 @@ Stats::~Stats() {
}
if(enable_resview && summary_thread_.joinable()){
summary_thread_.join();
+ crow_thread_.join();
}
if(enable_faulty_switch && faulty_thread_.joinable()){
faulty_thread_.join();
@@ -152,6 +153,22 @@ void Stats::SocketManagementRead(){
}
}
+void Stats::CrowRoute(){
+ crow::SimpleApp app;
+ while(!stop_){
+ try{
+ CROW_ROUTE(app, "/consensus_data")([this](){
+ LOG(ERROR)<<"API";
+ return consensus_history_.dump();
+ });
+ app.port(8500+transaction_summary_.port).multithreaded().run();
+ sleep(1);
+ }
+ catch( const std::exception& e){
+ }
+ }
+}
+
bool Stats::IsFaulty(){
return make_faulty_.load();
}
@@ -169,6 +186,7 @@ void Stats::SetProps(int replica_id, std::string ip, int
port, bool resview_flag
enable_faulty_switch=faulty_flag;
if(resview_flag){
summary_thread_ = std::thread(&Stats::SocketManagementWrite, this);
+ crow_thread_ = std::thread(&Stats::CrowRoute, this);
}
if(faulty_flag){
faulty_thread_ = std::thread(&Stats::SocketManagementRead, this);
@@ -198,6 +216,7 @@ void Stats::GetTransactionDetails(BatchUserRequest
batch_request){
if(!enable_resview){
return;
}
+ transaction_summary_.txn_number=batch_request.seq();
transaction_summary_.txn_command.clear();
transaction_summary_.txn_key.clear();
transaction_summary_.txn_value.clear();
@@ -231,7 +250,7 @@ void Stats::SendSummary(){
return;
}
transaction_summary_.execution_time=std::chrono::system_clock::now();
- transaction_summary_.txn_number=transaction_summary_.txn_number+1;
+ //transaction_summary_.txn_number=transaction_summary_.txn_number+1;
//Convert Transaction Summary to JSON
summary_json_["replica_id"]=transaction_summary_.replica_id;
@@ -259,6 +278,8 @@ void Stats::SendSummary(){
summary_json_["txn_values"].push_back(transaction_summary_.txn_value[i]);
}
+
consensus_history_[std::to_string(transaction_summary_.txn_number)]=summary_json_;
+
LOG(ERROR)<<summary_json_.dump();
//Send Summary via Websocket
diff --git a/platform/statistic/stats.h b/platform/statistic/stats.h
index 8cc8e95c..14e604ab 100644
--- a/platform/statistic/stats.h
+++ b/platform/statistic/stats.h
@@ -35,6 +35,7 @@
#include <nlohmann/json.hpp>
#include "boost/asio.hpp"
#include "boost/beast.hpp"
+#include <crow.h>
namespace asio = boost::asio;
namespace beast = boost::beast;
@@ -82,6 +83,7 @@ class Stats{
void SendSummary();
void SocketManagementWrite();
void SocketManagementRead();
+ void CrowRoute();
bool IsFaulty();
void ChangePrimary(int primary_id);
@@ -148,6 +150,7 @@ class Stats{
std::thread summary_thread_;
std::thread faulty_thread_;
+ std::thread crow_thread_;
bool enable_resview;
bool enable_faulty_switch;
VisualData transaction_summary_;
@@ -156,6 +159,7 @@ class Stats{
std::atomic<uint64_t> prev_num_prepare_;
std::atomic<uint64_t> prev_num_commit_;
nlohmann::json summary_json_;
+ nlohmann::json consensus_history_;
std::unique_ptr<PrometheusHandler> prometheus_;
};
diff --git a/third_party/BUILD b/third_party/BUILD
index 24eb61ae..b43e9230 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -45,3 +45,10 @@ cc_library(
"@eEVM",
],
)
+
+cc_library(
+ name = "crow",
+ deps = [
+ "@com_crowcpp_crow//:crow",
+ ],
+)
\ No newline at end of file