Merge branch 'static_defaults' of bitbucket.org:bluetradesys/spark into sdk_doc

This commit is contained in:
Kevin Darby committed 2018-11-30 16:29:04 -05:00
commit d17c56b799
4 files changed
+33 -30

No files matched your search

+22
View File
@@ -54,6 +54,28 @@ if(NOT old_config_proto_str STREQUAL config_proto_str)
file(WRITE "${config_proto_file}" "${config_proto_str}")
endif()
# generate static defaults
set(config_defaults_file ${CMAKE_CURRENT_BINARY_DIR}/config_defaults.h)
# Defaults cannot be a single string because the compiler complains about a string longer than 65k
set(config_defaults_str "const char * config_static_defaults[] = { ")
foreach (cfg_file_path ${Conf_Defaults})
file(READ ${cfg_file_path} cfg_file_content)
string(REPLACE "\"" "\\\"" cfg_file_content_escaped ${cfg_file_content})
string(REPLACE "\n" ";" cfg_lines ${cfg_file_content_escaped})
foreach(line ${cfg_lines})
string(APPEND config_defaults_str "\n \"${line}\",")
endforeach(line)
endforeach(cfg_file_path)
string(APPEND config_defaults_str "};")
set(old_defaults_str "")
if(EXISTS ${config_defaults_file})
file(READ ${config_defaults_file} old_defaults_str)
endif()
if(NOT config_defaults_str STREQUAL old_defaults_str)
file(WRITE "${config_defaults_file}" "${config_defaults_str}")
endif()
# copy defaults to output directory
foreach (cfg_file_path ${Conf_Defaults})
get_filename_component(cfg_file_name ${cfg_file_path} NAME)
+11 -16
View File
@@ -38,6 +38,7 @@
#endif
#include "lib/config_proto_files.h"
#include "lib/config_defaults.h"
using namespace std;
@@ -77,12 +78,6 @@ ConfigurationState::~ConfigurationState(void)
{
}
std::string ConfigurationState::defaults_path()
{
std::string appdir = os::get_install_path();
return appdir + "/defaults/";
}
std::string get_command_argument(const char* key)
{
std::vector<std::string> cmd_line = os::get_command_line();
@@ -127,18 +122,18 @@ void ConfigurationState::initialize_defaults(IConfigLog& log)
std::shared_ptr<proto::Message> new_message(_prototype->New());
ErrorsOnlyLog elog(log);
load_message(defaults_path(), *new_message.get(), elog, *_deferred_queue.get());
std::string defaults;
for (const char* str : config_static_defaults) {
defaults += str;
defaults += "\n";
}
proto::io::ArrayInputStream input_stream(defaults.c_str(), (int)defaults.length());
parse_stream("static_defaults.conf", input_stream, *new_message.get(), elog, *_deferred_queue.get());
_defaults = new_message;
// If defaults has an include process that now
// FEATURE: Unlike settings loaded from ~/sparkdata/ these includes
// take precedence over the settings in the file which includes them.
// While this seems backwards it is always the behavior you want
std::string include = get_include(*_defaults.get());
if (!include.empty())
{
load(include, "", log);
}
// do not process 'include' for static defaults
_is_initialized = true;
}
-1
View File
@@ -81,7 +81,6 @@ namespace internal {
void generate_all_config_proto(IConfigLog&);
const proto::Message* try_get_value(const std::string& field_name, const proto::Message& message) const;
std::string defaults_path();
std::string settings_path();
bool _is_initialized;
-13
View File
@@ -1,13 +0,0 @@
ExecutorCfg
{
value
{
# executor for latency sensitive code
executor { affinity: 0 yield_cpu: false }
# normal executor
executor { affinity: -1 yield_cpu: true }
}
}