Skip to content

Resolves #146: Registered new command for hostInfo #205

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/ExtCmd.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,30 @@ struct RenameCollectionCmd {
};
REGISTER_CMD(RenameCollectionCmd, "renamecollection");

struct HostInfoCmd {
static const char* name;
static Future<Reference<ExtMsgReply>> call(Reference<ExtConnection> ec,
Reference<ExtMsgQuery> query,
Reference<ExtMsgReply> reply) {
bson::HOSTINFO hostInfo;
bson::BSONObj systemInfo = hostInfo.getSystemInfo();
bson::BSONObj osInfo = hostInfo.getOsInfo();
bson::BSONObj extraInfo = hostInfo.getExtraInfo();
try {
if (!systemInfo.isEmpty() || !osInfo.isEmpty() || !extraInfo.isEmpty()) {
reply->addDocument(
BSON("system" << systemInfo << "os" << osInfo << "extra" << extraInfo << "ok" << 1.0));
} else {
throw unable_to_fetch_the_hostinfo();
}
} catch (Error& e) {
reply->addDocument(BSON("$err" << e.what() << "code" << e.code() << "ok" << 1.0));
}
return Future<Reference<ExtMsgReply>>(reply);
}
};
REGISTER_CMD(HostInfoCmd, "hostinfo");

ACTOR static Future<Reference<ExtMsgReply>> getStreamCount(Reference<ExtConnection> ec,
Reference<ExtMsgQuery> query,
Reference<ExtMsgReply> reply) {
Expand Down
1 change: 1 addition & 0 deletions src/error_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ DOCLAYER_ERROR(multiple_index_construction, 20004, "tried to create multiple ind
DOCLAYER_ERROR(unique_index_background_construction, 20005, "tried to create unique indexes in background");
DOCLAYER_ERROR(empty_set_on_insert, 20009, "$setOnInsert is empty");
DOCLAYER_ERROR(cant_modify_id, 20010, "You may not modify '_id' in an update");
DOCLAYER_ERROR(unable_to_fetch_the_hostinfo, 20011, "Unable to fetch the HostInfo");

DOCLAYER_ERROR(update_operator_empty_parameter,
26840,
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/bson-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ add_library(bsoncpp
"util/hex.h"
"util/misc.h"
"util/optime.h"
"system_info.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't reviewed the complete code yet. One high level comment - we NEVER change any code in thirdparty directory for licensing reasons. It seems like the changes you made don't have to be in bson-cpp.

Choose a reason for hiding this comment

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

Sure @apkar, we shall move them out of thirdparty directory and raise a commit

"system_info.cpp"
"util/time_support.h"
)

Expand Down
3 changes: 2 additions & 1 deletion thirdparty/bson-cpp/bson.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@
#include "bsonobjbuilder.h"
#include "bsonobjiterator.h"
#include "bson-inl.h"
#include "bson_db.h"
#include "bson_db.h"
#include "system_info.h"
Loading