This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new e468239 [web] Dump configs on BE's website '/varz' (#3220)
e468239 is described below
commit e4682398bd489a12e457b4f6351637d8e095605c
Author: Yingchun Lai <[email protected]>
AuthorDate: Sat Mar 28 16:26:38 2020 +0800
[web] Dump configs on BE's website '/varz' (#3220)
Dump configs on BE's website '/varz'
Change NAVIGATION_BAR_PREFIX from 'Impala' to 'Doris'
Format the related files by clang-format
---
be/src/common/configbase.cpp | 110 ++++++++++++++++++----------------
be/src/common/configbase.h | 74 +++++++++++------------
be/src/http/default_path_handlers.cpp | 35 +++++------
be/src/http/web_page_handler.cpp | 86 +++++++++++++-------------
be/src/service/doris_main.cpp | 66 ++++++++++----------
be/test/common/CMakeLists.txt | 1 +
be/test/common/config_test.cpp | 74 +++++++++++++++++++++++
run-ut.sh | 1 +
8 files changed, 258 insertions(+), 189 deletions(-)
diff --git a/be/src/common/configbase.cpp b/be/src/common/configbase.cpp
index 3637e80..9f3673b 100644
--- a/be/src/common/configbase.cpp
+++ b/be/src/common/configbase.cpp
@@ -20,31 +20,33 @@
#include <cstring>
#include <fstream>
#include <iostream>
+#include <list>
+#include <map>
#include <sstream>
-#define __IN_CONFIGBASE_CPP__
+#define __IN_CONFIGBASE_CPP__
#include "common/config.h"
-#undef __IN_CONFIGBASE_CPP__
+#undef __IN_CONFIGBASE_CPP__
namespace doris {
namespace config {
-std::list<Register::Field>* Register::_s_fieldlist = NULL;
-std::map<std::string, std::string>* confmap = NULL;
+std::list<Register::Field>* Register::_s_fieldlist = nullptr;
+std::map<std::string, std::string>* confmap = nullptr;
Properties props;
// load conf file
bool Properties::load(const char* filename) {
// if filename is null, use the empty props
- if (filename == 0) {
+ if (filename == nullptr) {
return true;
}
// open the conf file
std::ifstream input(filename);
if (!input.is_open()) {
- std::cerr << "config::load() failed to open the file:" << filename <<
std::endl;
+ std::cerr << "config::load() failed to open the file:" << filename <<
std::endl;
return false;
}
@@ -62,14 +64,14 @@ bool Properties::load(const char* filename) {
// ignore comments
if (line.empty() || line[0] == '#') {
- continue;
+ continue;
}
// read key and value
splitkv(line, key, value);
trim(key);
trim(value);
-
+
// insert into propmap
propmap[key] = value;
}
@@ -83,9 +85,9 @@ bool Properties::load(const char* filename) {
template <typename T>
bool Properties::get(const char* key, const char* defstr, T& retval) const {
std::map<std::string, std::string>::const_iterator it =
propmap.find(std::string(key));
- std::string valstr = it != propmap.end() ? it->second: std::string(defstr);
+ std::string valstr = it != propmap.end() ? it->second :
std::string(defstr);
trim(valstr);
- if (!replaceenv(valstr)) {
+ if (!replaceenv(valstr)) {
return false;
}
return strtox(valstr, retval);
@@ -110,11 +112,14 @@ const std::map<std::string, std::string>&
Properties::getmap() const {
}
// trim string
-std::string& Properties::trim(std::string& s) {
+std::string& Properties::trim(std::string& s) {
// rtrim
- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int,
int>(std::isspace))).base(), s.end());
+ s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int,
int>(std::isspace)))
+ .base(),
+ s.end());
// ltrim
- s.erase(s.begin(), std::find_if(s.begin(), s.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
+ s.erase(s.begin(),
+ std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int,
int>(std::isspace))));
return s;
}
@@ -138,12 +143,12 @@ bool Properties::replaceenv(std::string& s) {
std::size_t start = 0;
while ((start = s.find("${", pos)) != std::string::npos) {
std::size_t end = s.find("}", start + 2);
- if (end == std::string::npos) {
+ if (end == std::string::npos) {
return false;
}
std::string envkey = s.substr(start + 2, end - start - 2);
const char* envval = std::getenv(envkey.c_str());
- if (envval == NULL) {
+ if (envval == nullptr) {
return false;
}
s.erase(start, end - start + 1);
@@ -164,9 +169,9 @@ bool Properties::strtox(const std::string& valstr, bool&
retval) {
return true;
}
-template<typename T>
+template <typename T>
bool Properties::strtointeger(const std::string& valstr, T& retval) {
- if (valstr.length() == 0) {
+ if (valstr.length() == 0) {
return false; // empty-string is only allowed for string type.
}
char* end;
@@ -174,7 +179,7 @@ bool Properties::strtointeger(const std::string& valstr, T&
retval) {
const char* valcstr = valstr.c_str();
int64_t ret64 = strtoll(valcstr, &end, 10);
if (errno || end != valcstr + strlen(valcstr)) {
- return false; // bad parse
+ return false; // bad parse
}
retval = static_cast<T>(ret64);
if (retval != ret64) {
@@ -196,15 +201,15 @@ bool Properties::strtox(const std::string& valstr,
int64_t& retval) {
}
bool Properties::strtox(const std::string& valstr, double& retval) {
- if (valstr.length() == 0) {
+ if (valstr.length() == 0) {
return false; // empty-string is only allowed for string type.
}
- char* end = NULL;
+ char* end = nullptr;
errno = 0;
const char* valcstr = valstr.c_str();
retval = strtod(valcstr, &end);
- if (errno || end != valcstr + strlen(valcstr)) {
- return false; // bad parse
+ if (errno || end != valcstr + strlen(valcstr)) {
+ return false; // bad parse
}
return true;
}
@@ -214,8 +219,8 @@ bool Properties::strtox(const std::string& valstr,
std::string& retval) {
return true;
}
-template<typename T>
-std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
+template <typename T>
+std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
size_t last = v.size() - 1;
for (size_t i = 0; i < v.size(); ++i) {
out << v[i];
@@ -226,46 +231,45 @@ std::ostream& operator<< (std::ostream& out, const
std::vector<T>& v) {
return out;
}
-#define SET_FIELD(FIELD, TYPE, FILL_CONFMAP)\
- if (strcmp((FIELD).type, #TYPE) == 0) {\
- if (!props.get((FIELD).name, (FIELD).defval,
*reinterpret_cast<TYPE*>((FIELD).storage))) {\
- std::cerr << "config field error: " << (FIELD).name <<
std::endl;\
- return false;\
- }\
- if (FILL_CONFMAP) {\
- std::ostringstream oss;\
- oss << (*reinterpret_cast<TYPE*>((FIELD).storage));\
- (*confmap)[(FIELD).name] = oss.str();\
- }\
- continue;\
- }
+#define SET_FIELD(FIELD, TYPE, FILL_CONFMAP)
\
+ if (strcmp((FIELD).type, #TYPE) == 0) {
\
+ if (!props.get((FIELD).name, (FIELD).defval,
*reinterpret_cast<TYPE*>((FIELD).storage))) { \
+ std::cerr << "config field error: " << (FIELD).name << std::endl;
\
+ return false;
\
+ }
\
+ if (FILL_CONFMAP) {
\
+ std::ostringstream oss;
\
+ oss << (*reinterpret_cast<TYPE*>((FIELD).storage));
\
+ (*confmap)[(FIELD).name] = oss.str();
\
+ }
\
+ continue;
\
+ }
// init conf fields
bool init(const char* filename, bool fillconfmap) {
// load properties file
- if (!props.load(filename)) {
+ if (!props.load(filename)) {
return false;
}
// fill confmap ?
- if (fillconfmap && confmap == NULL) {
+ if (fillconfmap && confmap == nullptr) {
confmap = new std::map<std::string, std::string>();
}
// set conf fields
- for (std::list<Register::Field>::iterator it =
Register::_s_fieldlist->begin();
- it != Register::_s_fieldlist->end(); ++it) {
- SET_FIELD(*it, bool, fillconfmap);
- SET_FIELD(*it, int16_t, fillconfmap);
- SET_FIELD(*it, int32_t, fillconfmap);
- SET_FIELD(*it, int64_t, fillconfmap);
- SET_FIELD(*it, double, fillconfmap);
- SET_FIELD(*it, std::string, fillconfmap);
- SET_FIELD(*it, std::vector<bool>, fillconfmap);
- SET_FIELD(*it, std::vector<int16_t>, fillconfmap);
- SET_FIELD(*it, std::vector<int32_t>, fillconfmap);
- SET_FIELD(*it, std::vector<int64_t>, fillconfmap);
- SET_FIELD(*it, std::vector<double>, fillconfmap);
- SET_FIELD(*it, std::vector<std::string>, fillconfmap);
+ for (const auto& it : *Register::_s_fieldlist) {
+ SET_FIELD(it, bool, fillconfmap);
+ SET_FIELD(it, int16_t, fillconfmap);
+ SET_FIELD(it, int32_t, fillconfmap);
+ SET_FIELD(it, int64_t, fillconfmap);
+ SET_FIELD(it, double, fillconfmap);
+ SET_FIELD(it, std::string, fillconfmap);
+ SET_FIELD(it, std::vector<bool>, fillconfmap);
+ SET_FIELD(it, std::vector<int16_t>, fillconfmap);
+ SET_FIELD(it, std::vector<int32_t>, fillconfmap);
+ SET_FIELD(it, std::vector<int64_t>, fillconfmap);
+ SET_FIELD(it, std::vector<double>, fillconfmap);
+ SET_FIELD(it, std::vector<std::string>, fillconfmap);
}
return true;
diff --git a/be/src/common/configbase.h b/be/src/common/configbase.h
index 4d40461..a4057c6 100644
--- a/be/src/common/configbase.h
+++ b/be/src/common/configbase.h
@@ -19,6 +19,7 @@
#define DORIS_BE_SRC_COMMON_CONFIGBASE_H
#include <stdint.h>
+
#include <list>
#include <map>
#include <vector>
@@ -33,11 +34,8 @@ public:
const char* name;
void* storage;
const char* defval;
- Field(const char* ftype, const char* fname, void* fstorage, const
char* fdefval) :
- type(ftype),
- name(fname),
- storage(fstorage),
- defval(fdefval) {}
+ Field(const char* ftype, const char* fname, void* fstorage, const
char* fdefval)
+ : type(ftype), name(fname), storage(fstorage), defval(fdefval)
{}
};
public:
@@ -51,53 +49,53 @@ public:
Field field(ftype, fname, fstorage, fdefval);
_s_fieldlist->push_back(field);
}
-};
+};
-#define DEFINE_FIELD(FIELD_TYPE, FIELD_NAME, FIELD_DEFAULT)\
- FIELD_TYPE FIELD_NAME;\
+#define DEFINE_FIELD(FIELD_TYPE, FIELD_NAME, FIELD_DEFAULT) \
+ FIELD_TYPE FIELD_NAME; \
static Register reg_##FIELD_NAME(#FIELD_TYPE, #FIELD_NAME, &FIELD_NAME,
FIELD_DEFAULT);
-#define DECLARE_FIELD(FIELD_TYPE, FIELD_NAME) extern FIELD_TYPE FIELD_NAME;
-
-#ifdef __IN_CONFIGBASE_CPP__
-#define CONF_Bool(name, defaultstr) DEFINE_FIELD(bool, name,
defaultstr)
-#define CONF_Int16(name, defaultstr) DEFINE_FIELD(int16_t, name,
defaultstr)
-#define CONF_Int32(name, defaultstr) DEFINE_FIELD(int32_t, name,
defaultstr)
-#define CONF_Int64(name, defaultstr) DEFINE_FIELD(int64_t, name,
defaultstr)
-#define CONF_Double(name, defaultstr) DEFINE_FIELD(double, name,
defaultstr)
-#define CONF_String(name, defaultstr) DEFINE_FIELD(std::string, name,
defaultstr)
-#define CONF_Bools(name, defaultstr) DEFINE_FIELD(std::vector<bool>,
name, defaultstr)
-#define CONF_Int16s(name, defaultstr) DEFINE_FIELD(std::vector<int16_t>,
name, defaultstr)
-#define CONF_Int32s(name, defaultstr) DEFINE_FIELD(std::vector<int32_t>,
name, defaultstr)
-#define CONF_Int64s(name, defaultstr) DEFINE_FIELD(std::vector<int64_t>,
name, defaultstr)
-#define CONF_Doubles(name, defaultstr) DEFINE_FIELD(std::vector<double>,
name, defaultstr)
-#define CONF_Strings(name, defaultstr)
DEFINE_FIELD(std::vector<std::string>, name, defaultstr)
+#define DECLARE_FIELD(FIELD_TYPE, FIELD_NAME) extern FIELD_TYPE FIELD_NAME;
+
+#ifdef __IN_CONFIGBASE_CPP__
+#define CONF_Bool(name, defaultstr) DEFINE_FIELD(bool, name, defaultstr)
+#define CONF_Int16(name, defaultstr) DEFINE_FIELD(int16_t, name, defaultstr)
+#define CONF_Int32(name, defaultstr) DEFINE_FIELD(int32_t, name, defaultstr)
+#define CONF_Int64(name, defaultstr) DEFINE_FIELD(int64_t, name, defaultstr)
+#define CONF_Double(name, defaultstr) DEFINE_FIELD(double, name, defaultstr)
+#define CONF_String(name, defaultstr) DEFINE_FIELD(std::string, name,
defaultstr)
+#define CONF_Bools(name, defaultstr) DEFINE_FIELD(std::vector<bool>, name,
defaultstr)
+#define CONF_Int16s(name, defaultstr) DEFINE_FIELD(std::vector<int16_t>, name,
defaultstr)
+#define CONF_Int32s(name, defaultstr) DEFINE_FIELD(std::vector<int32_t>, name,
defaultstr)
+#define CONF_Int64s(name, defaultstr) DEFINE_FIELD(std::vector<int64_t>, name,
defaultstr)
+#define CONF_Doubles(name, defaultstr) DEFINE_FIELD(std::vector<double>, name,
defaultstr)
+#define CONF_Strings(name, defaultstr) DEFINE_FIELD(std::vector<std::string>,
name, defaultstr)
#else
-#define CONF_Bool(name, defaultstr) DECLARE_FIELD(bool, name)
-#define CONF_Int16(name, defaultstr) DECLARE_FIELD(int16_t, name)
-#define CONF_Int32(name, defaultstr) DECLARE_FIELD(int32_t, name)
-#define CONF_Int64(name, defaultstr) DECLARE_FIELD(int64_t, name)
-#define CONF_Double(name, defaultstr) DECLARE_FIELD(double, name)
-#define CONF_String(name, defaultstr) DECLARE_FIELD(std::string, name)
-#define CONF_Bools(name, defaultstr) DECLARE_FIELD(std::vector<bool>,
name)
-#define CONF_Int16s(name, defaultstr)
DECLARE_FIELD(std::vector<int16_t>, name)
-#define CONF_Int32s(name, defaultstr)
DECLARE_FIELD(std::vector<int32_t>, name)
-#define CONF_Int64s(name, defaultstr)
DECLARE_FIELD(std::vector<int64_t>, name)
-#define CONF_Doubles(name, defaultstr) DECLARE_FIELD(std::vector<double>,
name)
-#define CONF_Strings(name, defaultstr)
DECLARE_FIELD(std::vector<std::string>, name)
+#define CONF_Bool(name, defaultstr) DECLARE_FIELD(bool, name)
+#define CONF_Int16(name, defaultstr) DECLARE_FIELD(int16_t, name)
+#define CONF_Int32(name, defaultstr) DECLARE_FIELD(int32_t, name)
+#define CONF_Int64(name, defaultstr) DECLARE_FIELD(int64_t, name)
+#define CONF_Double(name, defaultstr) DECLARE_FIELD(double, name)
+#define CONF_String(name, defaultstr) DECLARE_FIELD(std::string, name)
+#define CONF_Bools(name, defaultstr) DECLARE_FIELD(std::vector<bool>, name)
+#define CONF_Int16s(name, defaultstr) DECLARE_FIELD(std::vector<int16_t>, name)
+#define CONF_Int32s(name, defaultstr) DECLARE_FIELD(std::vector<int32_t>, name)
+#define CONF_Int64s(name, defaultstr) DECLARE_FIELD(std::vector<int64_t>, name)
+#define CONF_Doubles(name, defaultstr) DECLARE_FIELD(std::vector<double>, name)
+#define CONF_Strings(name, defaultstr) DECLARE_FIELD(std::vector<std::string>,
name)
#endif
class Properties {
public:
bool load(const char* filename);
- template<typename T>
+ template <typename T>
bool get(const char* key, const char* defstr, T& retval) const;
const std::map<std::string, std::string>& getmap() const;
private:
- template <typename T>
+ template <typename T>
static bool strtox(const std::string& valstr, std::vector<T>& retval);
- template<typename T>
+ template <typename T>
static bool strtointeger(const std::string& valstr, T& retval);
static bool strtox(const std::string& valstr, bool& retval);
static bool strtox(const std::string& valstr, int16_t& retval);
diff --git a/be/src/http/default_path_handlers.cpp
b/be/src/http/default_path_handlers.cpp
index 5207848..cdc3a31 100644
--- a/be/src/http/default_path_handlers.cpp
+++ b/be/src/http/default_path_handlers.cpp
@@ -17,19 +17,21 @@
#include "http/default_path_handlers.h"
-#include <sstream>
-#include <fstream>
+#include <gperftools/malloc_extension.h>
#include <sys/stat.h>
+
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
-#include <gperftools/malloc_extension.h>
+#include <fstream>
+#include <sstream>
+#include "common/configbase.h"
#include "common/logging.h"
+#include "http/web_page_handler.h"
#include "runtime/mem_tracker.h"
#include "util/debug_util.h"
#include "util/logging.h"
#include "util/pretty_printer.h"
-#include "http/web_page_handler.h"
namespace doris {
@@ -60,27 +62,27 @@ void logs_handler(const WebPageHandler::ArgumentMap& args,
std::stringstream* ou
}*/
(*output) << "<br/>Couldn't open INFO log file: ";
-
-
}
-// Registered to handle "/flags", and prints out all command-line flags and
their values
+// Registered to handle "/varz", and prints out all command-line flags and
their values
void config_handler(const WebPageHandler::ArgumentMap& args,
std::stringstream* output) {
- (*output) << "<h2>Command-line Flags</h2>";
- // (*output) << "<pre>" << google::CommandlineFlagsIntoString() <<
"</pre>";
+ (*output) << "<h2>Configurations</h2>";
+ (*output) << "<pre>";
+ for (const auto& it : *(config::confmap)) {
+ (*output) << it.first << "=" << it.second << std::endl;
+ }
+ (*output) << "</pre>";
}
// Registered to handle "/memz", and prints out memory allocation statistics.
void mem_usage_handler(MemTracker* mem_tracker, const
WebPageHandler::ArgumentMap& args,
- std::stringstream* output) {
+ std::stringstream* output) {
if (mem_tracker != NULL) {
(*output) << "<pre>"
- << "Mem Limit: "
- << PrettyPrinter::print(mem_tracker->limit(), TUnit::BYTES)
+ << "Mem Limit: " <<
PrettyPrinter::print(mem_tracker->limit(), TUnit::BYTES)
<< std::endl
<< "Mem Consumption: "
- << PrettyPrinter::print(mem_tracker->consumption(),
TUnit::BYTES)
- << std::endl
+ << PrettyPrinter::print(mem_tracker->consumption(),
TUnit::BYTES) << std::endl
<< "</pre>";
} else {
(*output) << "<pre>"
@@ -105,8 +107,7 @@ void add_default_path_handlers(WebPageHandler*
web_page_handler, MemTracker* pro
web_page_handler->register_page("/logs", logs_handler);
web_page_handler->register_page("/varz", config_handler);
web_page_handler->register_page(
- "/memz",
- boost::bind<void>(&mem_usage_handler, process_mem_tracker, _1,
_2));
+ "/memz", boost::bind<void>(&mem_usage_handler,
process_mem_tracker, _1, _2));
}
-}
+} // namespace doris
diff --git a/be/src/http/web_page_handler.cpp b/be/src/http/web_page_handler.cpp
index 80c6a54..2140b27 100644
--- a/be/src/http/web_page_handler.cpp
+++ b/be/src/http/web_page_handler.cpp
@@ -20,14 +20,14 @@
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
-#include "http/http_status.h"
-#include "http/http_request.h"
-#include "http/http_response.h"
+#include "http/ev_http_server.h"
#include "http/http_channel.h"
#include "http/http_headers.h"
-#include "http/ev_http_server.h"
-#include "util/debug_util.h"
+#include "http/http_request.h"
+#include "http/http_response.h"
+#include "http/http_status.h"
#include "util/cpu_info.h"
+#include "util/debug_util.h"
#include "util/disk_info.h"
#include "util/mem_info.h"
@@ -35,16 +35,13 @@ namespace doris {
static std::string s_html_content_type = "text/html";
-WebPageHandler::WebPageHandler(EvHttpServer* server) :
- _http_server(server) {
+WebPageHandler::WebPageHandler(EvHttpServer* server) : _http_server(server) {
PageHandlerCallback default_callback =
boost::bind<void>(boost::mem_fn(&WebPageHandler::root_handler),
this, _1, _2);
register_page("/", default_callback);
}
-void WebPageHandler::register_page(
- const std::string& path,
- const PageHandlerCallback& callback) {
+void WebPageHandler::register_page(const std::string& path, const
PageHandlerCallback& callback) {
// Put this handler to to s_handler_by_name
// because handler does't often new
// So we insert it to this set when everytime
@@ -57,7 +54,7 @@ void WebPageHandler::register_page(
_page_map[path].add_callback(callback);
}
-void WebPageHandler::handle(HttpRequest *req) {
+void WebPageHandler::handle(HttpRequest* req) {
// Should we render with css styles?
bool use_style = true;
auto& params = *req->params();
@@ -99,49 +96,48 @@ void WebPageHandler::handle(HttpRequest *req) {
#endif
}
-static const std::string PAGE_HEADER =
- "<!DOCTYPE html>"
- " <html>"
- " <head><title>Doris</title>"
- " <link href='www/bootstrap/css/bootstrap.min.css' rel='stylesheet'
media='screen'>"
- " <style>"
- " body {"
- " padding-top: 60px; "
- " }"
- " </style>"
- " </head>"
- " <body>";
+static const std::string PAGE_HEADER =
+ "<!DOCTYPE html>"
+ " <html>"
+ " <head><title>Doris</title>"
+ " <link href='www/bootstrap/css/bootstrap.min.css' rel='stylesheet'
media='screen'>"
+ " <style>"
+ " body {"
+ " padding-top: 60px; "
+ " }"
+ " </style>"
+ " </head>"
+ " <body>";
static const std::string PAGE_FOOTER = "</div></body></html>";
static const std::string NAVIGATION_BAR_PREFIX =
- "<div class='navbar navbar-inverse navbar-fixed-top'>"
- " <div class='navbar-inner'>"
- " <div class='container'>"
- " <a class='btn btn-navbar' data-toggle='collapse'
data-target='.nav-collapse'>"
- " <span class='icon-bar'></span>"
- " <span class='icon-bar'></span>"
- " <span class='icon-bar'></span>"
- " </a>"
- " <a class='brand' href='/'>Impala</a>"
- " <div class='nav-collapse collapse'>"
- " <ul class='nav'>";
+ "<div class='navbar navbar-inverse navbar-fixed-top'>"
+ " <div class='navbar-inner'>"
+ " <div class='container'>"
+ " <a class='btn btn-navbar' data-toggle='collapse'
data-target='.nav-collapse'>"
+ " <span class='icon-bar'></span>"
+ " <span class='icon-bar'></span>"
+ " <span class='icon-bar'></span>"
+ " </a>"
+ " <a class='brand' href='/'>Doris</a>"
+ " <div class='nav-collapse collapse'>"
+ " <ul class='nav'>";
static const std::string NAVIGATION_BAR_SUFFIX =
- " </ul>"
- " </div>"
- " </div>"
- " </div>"
- " </div>"
- " <div class='container'>";
+ " </ul>"
+ " </div>"
+ " </div>"
+ " </div>"
+ " </div>"
+ " <div class='container'>";
void WebPageHandler::bootstrap_page_header(std::stringstream* output) {
boost::mutex::scoped_lock lock(_map_lock);
(*output) << PAGE_HEADER;
(*output) << NAVIGATION_BAR_PREFIX;
for (auto& iter : _page_map) {
- (*output) << "<li><a href=\"" << iter.first << "\">" << iter.first
- << "</a></li>";
+ (*output) << "<li><a href=\"" << iter.first << "\">" << iter.first <<
"</a></li>";
}
(*output) << NAVIGATION_BAR_SUFFIX;
}
@@ -150,9 +146,7 @@ void
WebPageHandler::bootstrap_page_footer(std::stringstream* output) {
(*output) << PAGE_FOOTER;
}
-void WebPageHandler::root_handler(
- const ArgumentMap& args,
- std::stringstream* output) {
+void WebPageHandler::root_handler(const ArgumentMap& args, std::stringstream*
output) {
// _path_handler_lock already held by MongooseCallback
(*output) << "<h2>Version</h2>";
(*output) << "<pre>" << get_version_string(false) << "</pre>" << std::endl;
@@ -169,4 +163,4 @@ void WebPageHandler::root_handler(
}
}
-}
+} // namespace doris
diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp
index 0711f70..ee4a5ea 100644
--- a/be/src/service/doris_main.cpp
+++ b/be/src/service/doris_main.cpp
@@ -15,56 +15,58 @@
// specific language governing permissions and limitations
// under the License.
+#include <gperftools/malloc_extension.h>
#include <sys/file.h>
#include <unistd.h>
#include <boost/scoped_ptr.hpp>
-#include <boost/unordered_map.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
-#include <gperftools/malloc_extension.h>
+#include <boost/unordered_map.hpp>
#if defined(LEAK_SANITIZER)
#include <sanitizer/lsan_interface.h>
#endif
#include <curl/curl.h>
+#include <gperftools/profiler.h>
#include <thrift/TOutput.h>
-#include "common/logging.h"
-#include "common/daemon.h"
-#include "common/config.h"
-#include "common/status.h"
-#include "runtime/exec_env.h"
-#include "util/file_utils.h"
-#include "util/logging.h"
-#include "util/network_util.h"
-#include "util/thrift_util.h"
-#include "util/thrift_server.h"
-#include "util/debug_util.h"
#include "agent/heartbeat_server.h"
#include "agent/status.h"
#include "agent/topic_subscriber.h"
-#include "util/doris_metrics.h"
+#include "common/config.h"
+#include "common/daemon.h"
+#include "common/logging.h"
+#include "common/resource_tls.h"
+#include "common/status.h"
#include "olap/options.h"
#include "olap/storage_engine.h"
+#include "runtime/exec_env.h"
+#include "runtime/heartbeat_flags.h"
#include "service/backend_options.h"
#include "service/backend_service.h"
#include "service/brpc_service.h"
#include "service/http_service.h"
-#include <gperftools/profiler.h>
-#include "common/resource_tls.h"
+#include "util/debug_util.h"
+#include "util/doris_metrics.h"
+#include "util/file_utils.h"
+#include "util/logging.h"
+#include "util/network_util.h"
#include "util/thrift_rpc_helper.h"
+#include "util/thrift_server.h"
+#include "util/thrift_util.h"
#include "util/uid_util.h"
-#include "runtime/heartbeat_flags.h"
static void help(const char*);
#include <dlfcn.h>
-extern "C" { void __lsan_do_leak_check(); }
+extern "C" {
+void __lsan_do_leak_check();
+}
namespace doris {
extern bool k_doris_exit;
@@ -73,7 +75,7 @@ static void thrift_output(const char* x) {
LOG(WARNING) << "thrift internal message: " << x;
}
-}
+} // namespace doris
int main(int argc, char** argv) {
// check if print version or help
@@ -118,14 +120,14 @@ int main(int argc, char** argv) {
}
string conffile = string(getenv("DORIS_HOME")) + "/conf/be.conf";
- if (!doris::config::init(conffile.c_str(), false)) {
+ if (!doris::config::init(conffile.c_str(), true)) {
fprintf(stderr, "error read config file. \n");
return -1;
}
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) &&
!defined(THREAD_SANITIZER)
- MallocExtension::instance()->SetNumericProperty(
- "tcmalloc.aggressive_memory_decommit", 21474836480);
+
MallocExtension::instance()->SetNumericProperty("tcmalloc.aggressive_memory_decommit",
+ 21474836480);
#endif
std::vector<doris::StorePath> paths;
@@ -136,7 +138,7 @@ int main(int argc, char** argv) {
}
auto it = paths.begin();
- for (;it != paths.end();) {
+ for (; it != paths.end();) {
if (!doris::FileUtils::check_exist(it->path)) {
if (doris::config::ignore_broken_disk) {
LOG(WARNING) << "opendir failed, path=" << it->path;
@@ -191,10 +193,8 @@ int main(int argc, char** argv) {
doris::ThriftRpcHelper::setup(exec_env);
doris::ThriftServer* be_server = nullptr;
- EXIT_IF_ERROR(doris::BackendService::create_service(
- exec_env,
- doris::config::be_port,
- &be_server));
+ EXIT_IF_ERROR(
+ doris::BackendService::create_service(exec_env,
doris::config::be_port, &be_server));
Status status = be_server->start();
if (!status.ok()) {
LOG(ERROR) << "Doris Be server did not start correctly, exiting";
@@ -210,8 +210,8 @@ int main(int argc, char** argv) {
exit(1);
}
- doris::HttpService http_service(
- exec_env, doris::config::webserver_port,
doris::config::webserver_num_workers);
+ doris::HttpService http_service(exec_env, doris::config::webserver_port,
+ doris::config::webserver_num_workers);
status = http_service.start();
if (!status.ok()) {
LOG(ERROR) << "Doris Be http service did not start correctly, exiting";
@@ -223,11 +223,8 @@ int main(int argc, char** argv) {
// start heart beat server
doris::ThriftServer* heartbeat_thrift_server;
doris::AgentStatus heartbeat_status = doris::create_heartbeat_server(
- exec_env,
- doris::config::heartbeat_service_port,
- &heartbeat_thrift_server,
- doris::config::heartbeat_service_thread_count,
- master_info);
+ exec_env, doris::config::heartbeat_service_port,
&heartbeat_thrift_server,
+ doris::config::heartbeat_service_thread_count, master_info);
if (doris::AgentStatus::DORIS_SUCCESS != heartbeat_status) {
LOG(ERROR) << "Heartbeat services did not start correctly, exiting";
@@ -264,4 +261,3 @@ static void help(const char* progname) {
printf(" -v, --version output version information, then exit\n");
printf(" -?, --help show this help, then exit\n");
}
-
diff --git a/be/test/common/CMakeLists.txt b/be/test/common/CMakeLists.txt
index bfa958a..6589632 100644
--- a/be/test/common/CMakeLists.txt
+++ b/be/test/common/CMakeLists.txt
@@ -20,3 +20,4 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/test/common")
ADD_BE_TEST(resource_tls_test)
ADD_BE_TEST(status_test)
+ADD_BE_TEST(config_test)
diff --git a/be/test/common/config_test.cpp b/be/test/common/config_test.cpp
new file mode 100644
index 0000000..f17f0bf
--- /dev/null
+++ b/be/test/common/config_test.cpp
@@ -0,0 +1,74 @@
+// 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.
+
+#define __IN_CONFIGBASE_CPP__
+#include "common/configbase.h"
+#undef __IN_CONFIGBASE_CPP__
+
+#include <gtest/gtest.h>
+
+namespace doris {
+using namespace config;
+
+class ConfigTest : public testing::Test {
+ void SetUp() override { config::Register::_s_fieldlist->clear(); }
+};
+
+TEST_F(ConfigTest, DumpAllConfigs) {
+ CONF_Bool(cfg_bool_false, "false");
+ CONF_Bool(cfg_bool_true, "true");
+ CONF_Double(cfg_double, "123.456");
+ CONF_Int16(cfg_int16_t, "2561");
+ CONF_Int32(cfg_int32_t, "65536123");
+ CONF_Int64(cfg_int64_t, "4294967296123");
+ CONF_String(cfg_std_string, "doris_config_test_string");
+ CONF_Bools(cfg_std_vector_bool, "true,false,true");
+ CONF_Doubles(cfg_std_vector_double, "123.456,123.4567,123.45678");
+ CONF_Int16s(cfg_std_vector_int16_t, "2561,2562,2563");
+ CONF_Int32s(cfg_std_vector_int32_t, "65536123,65536234,65536345");
+ CONF_Int64s(cfg_std_vector_int64_t,
"4294967296123,4294967296234,4294967296345");
+ CONF_Strings(cfg_std_vector_std_string, "doris,config,test,string");
+
+ config::init(nullptr, true);
+ std::stringstream ss;
+ for (const auto& it : *(config::confmap)) {
+ ss << it.first << "=" << it.second << std::endl;
+ }
+ ASSERT_EQ(
+ R"*(cfg_bool_false=0
+cfg_bool_true=1
+cfg_double=123.456
+cfg_int16_t=2561
+cfg_int32_t=65536123
+cfg_int64_t=4294967296123
+cfg_std_string=doris_config_test_string
+cfg_std_vector_bool=1, 0, 1
+cfg_std_vector_double=123.456, 123.457, 123.457
+cfg_std_vector_int16_t=2561, 2562, 2563
+cfg_std_vector_int32_t=65536123, 65536234, 65536345
+cfg_std_vector_int64_t=4294967296123, 4294967296234, 4294967296345
+cfg_std_vector_std_string=doris, config, test, string
+)*",
+ ss.str());
+}
+
+} // namespace doris
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/run-ut.sh b/run-ut.sh
index 0b4b531..4639225 100755
--- a/run-ut.sh
+++ b/run-ut.sh
@@ -177,6 +177,7 @@ ${DORIS_TEST_BINARY_DIR}/util/thread_test
${DORIS_TEST_BINARY_DIR}/util/threadpool_test
# Running common Unittest
+${DORIS_TEST_BINARY_DIR}/common/config_test
${DORIS_TEST_BINARY_DIR}/common/resource_tls_test
## Running exprs unit test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]