Files
mongo/dbgrid/dbgrid_commands.cpp

88 lines
2.6 KiB
C++
Raw Normal View History

2008-10-24 17:51:28 -04:00
// dbgrid/request.cpp
/**
* Copyright (C) 2008 10gen Inc.
2008-12-28 20:28:49 -05:00
*
2008-10-24 17:51:28 -04:00
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
2008-12-28 20:28:49 -05:00
*
2008-10-24 17:51:28 -04:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2008-12-28 20:28:49 -05:00
*
2008-10-24 17:51:28 -04:00
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* TODO
_ concurrency control.
_ connection pool
_ hostbyname_nonreentrant() problem
_ gridconfig object which gets config from the grid db.
connect to iad-sb-grid
_ limit() works right?
_ KillCursors
later
_ secondary indexes
*/
#include "stdafx.h"
#include "../grid/message.h"
#include "../db/dbmessage.h"
2008-10-31 19:17:54 -05:00
#include "../client/connpool.h"
2008-10-24 17:51:28 -04:00
#include "../db/commands.h"
#include "gridconfig.h"
2009-01-14 17:09:51 -05:00
namespace mongo {
extern string ourHostname;
2008-10-24 17:51:28 -04:00
namespace dbgrid_cmds {
2008-10-24 17:51:28 -04:00
class NetStatCmd : public Command {
public:
virtual bool slaveOk() {
return true;
}
NetStatCmd() : Command("netstat") { }
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
result.append("griddb", gridDatabase.toString());
result.append("isdbgrid", 1);
return true;
}
} netstat;
2008-10-24 17:51:28 -04:00
class IsDbGridCmd : public Command {
public:
virtual bool slaveOk() {
return true;
}
IsDbGridCmd() : Command("isdbgrid") { }
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
result.append("isdbgrid", 1);
result.append("hostname", ourHostname);
return true;
}
} isdbgrid;
2008-10-24 17:51:28 -04:00
class CmdIsMaster : public Command {
public:
2009-01-18 20:37:17 -05:00
virtual bool requiresAuth() { return false; }
virtual bool slaveOk() {
return true;
}
CmdIsMaster() : Command("ismaster") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
result.append("ismaster", 0.0);
result.append("msg", "isdbgrid");
return true;
}
} ismaster;
2008-10-24 17:51:28 -04:00
}
2009-01-14 17:09:51 -05:00
} // namespace mongo