New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osd,compressor: Expose compression algorithms via MOSDBoot. #20558
Merged
tchaikov
merged 1 commit into
ceph:master
from
chardan:jfw-wip-show_compression_methods-22420
Mar 27, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,21 @@ | |
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#include "acconfig.h" | ||
#include <unistd.h> | ||
|
||
#include <cerrno> | ||
#include <cctype> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <errno.h> | ||
#include <algorithm> | ||
|
||
#include <experimental/iterator> | ||
|
||
#include <unistd.h> | ||
|
||
#include <sys/stat.h> | ||
#include <signal.h> | ||
#include <ctype.h> | ||
#include <boost/scoped_ptr.hpp> | ||
|
||
#ifdef HAVE_SYS_PARAM_H | ||
|
@@ -47,6 +54,7 @@ | |
#include "common/io_priority.h" | ||
#include "common/pick_address.h" | ||
#include "common/SubProcess.h" | ||
#include "common/PluginRegistry.h" | ||
|
||
#include "os/ObjectStore.h" | ||
#ifdef HAVE_LIBFUSE | ||
|
@@ -55,7 +63,6 @@ | |
|
||
#include "PrimaryLogPG.h" | ||
|
||
|
||
#include "msg/Messenger.h" | ||
#include "msg/Message.h" | ||
|
||
|
@@ -5536,6 +5543,27 @@ void OSD::_send_boot() | |
set_state(STATE_BOOTING); | ||
} | ||
|
||
std::string OSD::_collect_compression_algorithms() | ||
{ | ||
using std::experimental::make_ostream_joiner; | ||
|
||
const auto& compression_algorithms = Compressor::compression_algorithms; | ||
const auto& plugin_registry = cct->get_plugin_registry()->plugins; | ||
|
||
if (plugin_registry.empty()) | ||
return {}; | ||
|
||
ostringstream os; | ||
|
||
copy_if(begin(compression_algorithms), end(compression_algorithms), | ||
make_ostream_joiner(os, ", "), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like this will print pairs instead of just the names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
[&plugin_registry](const auto& algorithm) { | ||
return plugin_registry.end() != plugin_registry.find(algorithm.first); | ||
}); | ||
|
||
return os.str(); | ||
} | ||
|
||
void OSD::_collect_metadata(map<string,string> *pm) | ||
{ | ||
// config info | ||
|
@@ -5566,6 +5594,10 @@ void OSD::_collect_metadata(map<string,string> *pm) | |
set<string> devnames; | ||
store->get_devices(&devnames); | ||
(*pm)["devices"] = stringify(devnames); | ||
|
||
// Other information: | ||
(*pm)["supported_compression_algorithms"] = _collect_compression_algorithms(); | ||
|
||
dout(10) << __func__ << " " << *pm << dendl; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i opened #21801 to make this a constexpr initializer_list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exposes
compression_algorithms
directly as an interface to determine which are enabled. consider extending the static functions to do this instead. for example:the caller can loop over
[0,COMP_ALG_LAST)
and callget_comp_alg_name(i)
to include the names of each algorithm enabled. these functions can be constexpr thanks to initializer_list and the constexpr constructors of std::optional and std::string_view. std::find_if() isn't constexpr until c++20, but a ranged-for loop would work instead(this would also address the comment
return "???"; // It would be nice to revise this...
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, 'return "???"' was what the prior code did, and frankly I'm not a fan of that. I decided to lift up only a single level of abstraction because I didn't know how much other code might be using it, but there's certainly no reason it can't be revisited! Thanks for your thoughtful comments.