Skip to content

Commit

Permalink
ENG-3115: Add links for Cassandra, Redis and PGSQL API RPCs in progre…
Browse files Browse the repository at this point in the history
…ss at tserver debug utilities page.

Summary:
In the TServer Debug Utilities handler (http://:9000/utilz), we have the "RPCs in progress"
link which displays the active TServer level RPCs. This differential does the following:

a) Adds a new thumbnail for Redis RPCs in Progress (hyper linked to the appropriate port).
b) Adds a new thumbnail for Cassandra RPCs in Progress (hyper linked to the appropriate port).
c) Adds a new thumbnail for PGSQL RPCs in Progress (hyper linked to the appropriate port).

Test Plan:
Checked that the proper hyperlinks were generated in the UI and clicking on the thumbnail
accurately redirects the user to the correct page. Some screenshots of how the page is currently shown now:

{F8990}

{F8991}

{F8992}

Reviewers: kannan, bogdan

Reviewed By: bogdan

Subscribers: karthik, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D4583
  • Loading branch information
ayushsengupta1991 committed Apr 24, 2018
1 parent aad076c commit e0b4b5d
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 19 deletions.
34 changes: 22 additions & 12 deletions src/yb/server/server_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ using std::string;
using std::stringstream;
using std::vector;
using strings::Substitute;
using namespace std::placeholders;

namespace yb {
namespace server {
Expand Down Expand Up @@ -424,9 +425,9 @@ std::string RpcAndWebServerBase::FooterHtml() const {
instance_pb_->permanent_uuid());
}

static void DisplayIconTile(std::stringstream* output, const string icon,
const string caption, const string url) {
*output << " <div class='col-sm-6 col-md-4 dbg-tile'>\n"
void RpcAndWebServerBase::DisplayIconTile(std::stringstream* output, const string icon,
const string caption, const string url) {
*output << " <div class='col-sm-4 col-md-4 dbg-tile'>\n"
<< " <a href='" << url << "' class='thumbnail'>\n"
<< " <div class='dbg-icon'>\n"
<< " <i class='fa " << icon << "' aria-hidden='true'></i>\n"
Expand All @@ -435,30 +436,38 @@ static void DisplayIconTile(std::stringstream* output, const string icon,
<< " <h3>" << caption << "</h3>\n"
<< " </div> <!-- caption -->\n"
<< " </a> <!-- thumbnail -->\n"
<< " </div> <!-- col-xs-6 col-md-3 -->\n";
<< " </div> <!-- col-sm-4 col-md-4 -->\n";
}

static void HandleDebugPage(const Webserver::WebRequest& req, stringstream* output) {
void RpcAndWebServerBase::DisplayRpcIcons(std::stringstream* output) {
// RPCs in Progress.
DisplayIconTile(output, "fa-tasks", "Server RPCs", "/rpcz");
}

Status RpcAndWebServerBase::HandleDebugPage(const Webserver::WebRequest& req,
stringstream* output) {
*output << "<h1>Debug Utilities</h1>\n";

*output << "<div class='row debug-tiles'>\n";

*output << "<h2> General Info </h2>";
// Logs.
DisplayIconTile(output, "fa-files-o", "Logs", "/logs");
// GFlags.
DisplayIconTile(output, "fa-flag-o", "GFlags", "/varz");
// Memory trackers.
DisplayIconTile(output, "fa-bar-chart", "Memory Breakdown", "/mem-trackers");
// Total memory.
DisplayIconTile(output, "fa-cog", "Total Memory", "/memz");
// Metrics.
DisplayIconTile(output, "fa-line-chart", "Metrics", "/metrics");
// RPCs in progress.
DisplayIconTile(output, "fa-tasks", "RPCs In Progress", "/rpcz");
// Threads.
DisplayIconTile(output, "fa-list-ul", "Threads", "/threadz");
// Total memory.
DisplayIconTile(output, "fa-cog", "Total Memory", "/memz");

*output << "</div> <!-- row -->\n";
*output << "<h2> RPCs In Progress </h2>";
*output << "<div class='row debug-tiles'>\n";
DisplayRpcIcons(output);
*output << "</div> <!-- row -->\n";
return Status::OK();
}

Status RpcAndWebServerBase::Start() {
Expand All @@ -468,7 +477,8 @@ Status RpcAndWebServerBase::Start() {
AddRpczPathHandlers(messenger_, web_server_.get());
RegisterMetricsJsonHandler(web_server_.get(), metric_registry_.get());
TracingPathHandlers::RegisterHandlers(web_server_.get());
web_server_->RegisterPathHandler("/utilz", "Utilities", HandleDebugPage,
web_server_->RegisterPathHandler("/utilz", "Utilities",
std::bind(&RpcAndWebServerBase::HandleDebugPage, this, _1, _2),
true, true, "fa fa-wrench");
web_server_->set_footer_html(FooterHtml());
RETURN_NOT_OK(web_server_->Start());
Expand Down
7 changes: 7 additions & 0 deletions src/yb/server/server_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ class RpcAndWebServerBase : public RpcServerBase {
rpc::ConnectionContextFactoryPtr connection_context_factory);
virtual ~RpcAndWebServerBase();

virtual Status HandleDebugPage(const Webserver::WebRequest& req, std::stringstream* output);

virtual void DisplayRpcIcons(std::stringstream* output);

static void DisplayIconTile(std::stringstream* output, const string icon, const string caption,
const string url);

CHECKED_STATUS Init();
CHECKED_STATUS Start();
void Shutdown();
Expand Down
38 changes: 38 additions & 0 deletions src/yb/tserver/tablet_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "yb/util/net/sockaddr.h"
#include "yb/util/size_literals.h"
#include "yb/util/status.h"
#include "yb/gutil/strings/split.h"

using std::make_shared;
using std::shared_ptr;
Expand Down Expand Up @@ -102,6 +103,15 @@ DEFINE_bool(enable_direct_local_tablet_server_call,
"Enable direct call to local tablet server");
TAG_FLAG(enable_direct_local_tablet_server_call, advanced);

DEFINE_string(redis_proxy_bind_address, "", "Address to bind the redis proxy to");
DEFINE_int32(redis_proxy_webserver_port, 0, "Webserver port for redis proxy");

DEFINE_string(cql_proxy_bind_address, "", "Address to bind the CQL proxy to");
DEFINE_int32(cql_proxy_webserver_port, 0, "Webserver port for CQL proxy");

DEFINE_string(pgsql_proxy_bind_address, "", "Address to bind the PostgreSQL proxy to");
DEFINE_int32(pgsql_proxy_webserver_port, 0, "Webserver port for PostgreSQL proxy");

DECLARE_int64(inbound_rpc_block_size);
DECLARE_int64(inbound_rpc_memory_limit);

Expand Down Expand Up @@ -299,5 +309,33 @@ TabletServiceImpl* TabletServer::tablet_server_service() {
return tablet_server_service_;
}

string GetDynamicUrlTile(const string path, const string host, const int port) {

vector<std::string> parsed_hostname = strings::Split(host, ":");
std::string link = strings::Substitute("http://$0:$1$2",
parsed_hostname[0], yb::ToString(port), path);
return link;
}

void TabletServer::DisplayRpcIcons(std::stringstream* output) {
// RPCs in Progress.
DisplayIconTile(output, "fa-tasks", "TServer RPCs", "/rpcz");
// Cassandra RPCs in Progress.
string cass_url = GetDynamicUrlTile("/rpcz", FLAGS_cql_proxy_bind_address,
FLAGS_cql_proxy_webserver_port);
DisplayIconTile(output, "fa-tasks", "Cassandra RPCs", cass_url);

// Redis RPCs in Progress.
string redis_url = GetDynamicUrlTile("/rpcz", FLAGS_redis_proxy_bind_address,
FLAGS_redis_proxy_webserver_port);
DisplayIconTile(output, "fa-tasks", "Redis RPCs", redis_url);

// PGSQL RPCs in Progress.
string sql_url = GetDynamicUrlTile("/rpcz", FLAGS_pgsql_proxy_bind_address,
FLAGS_pgsql_proxy_webserver_port);
DisplayIconTile(output, "fa-tasks", "SQL RPCs", sql_url);

}

} // namespace tserver
} // namespace yb
2 changes: 2 additions & 0 deletions src/yb/tserver/tablet_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class TabletServer : public server::RpcAndWebServerBase, public TabletServerIf {
protected:
friend class TabletServerTestBase;

void DisplayRpcIcons(std::stringstream* output) override;

CHECKED_STATUS ValidateMasterAddressResolution() const;

bool initted_;
Expand Down
18 changes: 11 additions & 7 deletions src/yb/tserver/tablet_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,31 @@ using yb::pgserver::PgServer;
using yb::pgserver::PgServerOptions;

DEFINE_bool(start_redis_proxy, true, "Starts a redis proxy along with the tablet server");
DEFINE_string(redis_proxy_bind_address, "", "Address to bind the redis proxy to");
DEFINE_int32(redis_proxy_webserver_port, 0, "Webserver port for redis proxy");

DEFINE_bool(start_cql_proxy, true, "Starts a CQL proxy along with the tablet server");
DEFINE_string(cql_proxy_broadcast_rpc_address, "",
"RPC address to broadcast to other nodes. This is the broadcast_address used in the"
" system.local table");
DEFINE_string(cql_proxy_bind_address, "", "Address to bind the CQL proxy to");
DEFINE_int32(cql_proxy_webserver_port, 0, "Webserver port for CQL proxy");

DEFINE_int64(tserver_tcmalloc_max_total_thread_cache_bytes, 256_MB, "Total number of bytes to "
"use for the thread cache for tcmalloc across all threads in the tserver.");
"use for the thread cache for tcmalloc across all threads in the tserver.");

DEFINE_bool(start_pgsql_proxy, true, "Starts a PostgreSQL proxy along with the tablet server");
DEFINE_string(pgsql_proxy_bind_address, "", "Address to bind the PostgreSQL proxy to");
DEFINE_int32(pgsql_proxy_webserver_port, 0, "Webserver port for PostgreSQL proxy");

DECLARE_string(rpc_bind_addresses);
DECLARE_bool(callhome_enabled);
DECLARE_int32(webserver_port);
DECLARE_int32(logbuflevel);

DECLARE_string(redis_proxy_bind_address);
DECLARE_int32(redis_proxy_webserver_port);

DECLARE_string(cql_proxy_bind_address);
DECLARE_int32(cql_proxy_webserver_port);

DECLARE_string(pgsql_proxy_bind_address);
DECLARE_int32(pgsql_proxy_webserver_port);

namespace yb {
namespace tserver {

Expand Down

0 comments on commit e0b4b5d

Please sign in to comment.