Skip to content

Commit

Permalink
Resolves issue FoundationDB#146: Registered new command for hostInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
drkannan committed Aug 14, 2019
1 parent 239aa37 commit f23ceff
Show file tree
Hide file tree
Showing 6 changed files with 671 additions and 1 deletion.
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"
"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

0 comments on commit f23ceff

Please sign in to comment.