Skip to content

[CLIPPER-57] Read existing configuration from Redis on startup#123

Merged
dcrankshaw merged 7 commits intoucbrise:developfrom
giulio-zhou:read-config-on-start
Apr 21, 2017
Merged

[CLIPPER-57] Read existing configuration from Redis on startup#123
dcrankshaw merged 7 commits intoucbrise:developfrom
giulio-zhou:read-config-on-start

Conversation

@giulio-zhou
Copy link
Contributor

  • Create two functions get_all_model_names() and
    get_all_application_names() which call the KEYS command with a
    wildcard (*) argument on the model and application table
  • Update query frontend to (1) add existing applications and
    (2) fill internal state with current model name and versions
    on startup

* Create two functions get_all_model_names() and
  get_all_application_names() which call the KEYS command with a
  wildcard (*) argument on the model and application table
* Update query frontend to (1) add existing applications and
  (2) fill internal state with current model name and versions
  on startup
@giulio-zhou giulio-zhou requested a review from dcrankshaw April 17, 2017 22:58
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@dcrankshaw
Copy link
Contributor

jenkins test this please

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Clipper-PRB/159/
Test FAILed.

Copy link
Contributor

@dcrankshaw dcrankshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I tested it locally and it seems to work. We should add unit tests for this though.

Add some tests to the query_frontend that first populate the application/model tables using Redis then create a new query frontend RequestHandler object and make sure it reads Redis correctly and adds the right models/versions and applications.

Note that when adding models you'll need explicitly set the current model version as well because the management frontend does that (https://github.com/ucbrise/clipper/blob/develop/src/management/src/management_frontend.hpp#L282-L314).

Make sure to have separate tests for models and applications.

// (1) Iterate through applications and set up predict/update endpoints.
for (std::string app_name :
clipper::redis::get_all_application_names(redis_connection_)) {
// Is there a way/need to not repeat these function calls? (from above)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeating them is fine. There's not much duplicate code.

std::vector<std::string> candidate_model_names =
clipper::redis::str_to_model_names(app_info["candidate_model_names"]);
InputType input_type = clipper::parse_input_type(app_info["input_type"]);
std::string policy = app_info["policy"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is based on an old commit. Update to the latest version. You'll notice that applications no longer have a policy field and now have a default_output field that needs to be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to include default_output.

clipper::redis::get_all_model_names(redis_connection_)) {
auto model_version = clipper::redis::get_current_model_version(
redis_connection_, model_name);
// Error handle model_version being < 0?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you should check for it. If it is < 0, log an error then throw a runtime exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked in new implementation with corresponding test.

// Read from Redis configuration tables and update models/applications
// (1) Iterate through applications and set up predict/update endpoints.
for (std::string app_name :
clipper::redis::get_all_application_names(redis_connection_)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you save the vector of existing app names and log them in a useful message. Something like "Found 3 existing applications registered in Clipper: app_name_1, app_name_2, app_name_3."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will do.

// Error handle model_version being < 0?
std::unique_lock<std::mutex> l(current_model_versions_mutex_);
current_model_versions_[model_name] = model_version;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After you've initialized the current_model_versions_ map in this for loop, can you log the results similar to the existing applications log message: "Found 3 models deployed to Clipper: model_a@v4, model_b@v7, model_c@v1"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dcrankshaw
Copy link
Contributor

jenkins test this please

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Clipper-PRB/168/
Test FAILed.

@dcrankshaw
Copy link
Contributor

jenkins test this please

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Clipper-PRB/171/
Test PASSed.

@dcrankshaw dcrankshaw merged commit 668bf05 into ucbrise:develop Apr 21, 2017
withsmilo added a commit to withsmilo/clipper that referenced this pull request Mar 14, 2018
Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving.
We need to upgrade this module to resolve some bugs and support keep-alive connection.
So we applied all patches except of below to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp).
Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo).

* applied patch list
  * Nov 7, 2016: [Fixes ucbrise#82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4)
  * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b)
  * Nov 23, 2016: [Fixes ucbrise#86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3)
  * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360)
  * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d)
  * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b)
  * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77)
  * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82)
  * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64)
  * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d)
  * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes ucbrise#100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Possible implementation for fixing ucbrise#106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 6, 2017: [Added support for request header Connection: keep-alive (see ucbrise#123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Finished query string parsing implementation (PR ucbrise#109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c)

* excluded patch list
  * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb)
  * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381)
  * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf)
withsmilo added a commit to withsmilo/clipper that referenced this pull request Mar 14, 2018
Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving.
We need to upgrade this module to resolve some bugs and support keep-alive connection.
So we applied all patches except of some to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp).
Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo).

* applied patch list
  * Nov 7, 2016: [Fixes ucbrise#82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4)
  * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b)
  * Nov 23, 2016: [Fixes ucbrise#86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3)
  * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360)
  * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d)
  * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b)
  * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77)
  * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82)
  * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64)
  * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d)
  * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes ucbrise#100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Possible implementation for fixing ucbrise#106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 6, 2017: [Added support for request header Connection: keep-alive (see ucbrise#123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Finished query string parsing implementation (PR ucbrise#109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c)

* excluded patch list
  * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb)
  * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381)
  * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf)
dcrankshaw pushed a commit that referenced this pull request Mar 15, 2018
* Upgrade SimpleWebServer to version 2.1.1

Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving.
We need to upgrade this module to resolve some bugs and support keep-alive connection.
So we applied all patches except of some to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp).
Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo).

* applied patch list
  * Nov 7, 2016: [Fixes #82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4)
  * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b)
  * Nov 23, 2016: [Fixes #86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3)
  * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360)
  * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d)
  * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b)
  * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77)
  * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82)
  * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e)
  * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64)
  * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d)
  * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes #100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Possible implementation for fixing #106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 6, 2017: [Added support for request header Connection: keep-alive (see #123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Finished query string parsing implementation (PR #109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c)
  * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c)

* excluded patch list
  * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb)
  * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381)
  * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf)

* Run format_code.sh

* format code

* Run run_unittests.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants