Skip to content
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

Resolves #146: Registered new command for hostInfo #205

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ add_executable(fdbdoc
QLPredicate.h
QLTypes.cpp
QLTypes.h
version.cpp Constants.cpp Constants.h)
version.cpp Constants.cpp Constants.h HostInfo.cpp HostInfo.h)

set(ACTOR_FILES
BufferedConnection.actor.cpp
Expand Down
25 changes: 25 additions & 0 deletions src/ExtCmd.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ExtMsg.actor.h"
#include "ExtUtil.actor.h"

#include "HostInfo.h"
#include "QLPlan.actor.h"
#include "QLProjection.actor.h"

Expand Down Expand Up @@ -498,6 +499,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) {
diagnostics::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
Loading