2008-10-24 23:51:28 +02:00
|
|
|
// dbgrid/request.cpp
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (C) 2008 10gen Inc.
|
2008-12-29 02:28:49 +01:00
|
|
|
*
|
2008-10-24 23:51:28 +02: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-29 02:28:49 +01:00
|
|
|
*
|
2008-10-24 23:51:28 +02: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-29 02:28:49 +01:00
|
|
|
*
|
2008-10-24 23:51:28 +02: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-11-01 01:17:54 +01:00
|
|
|
#include "../client/connpool.h"
|
2008-10-24 23:51:28 +02:00
|
|
|
#include "../db/commands.h"
|
|
|
|
#include "gridconfig.h"
|
|
|
|
|
|
|
|
extern string ourHostname;
|
|
|
|
|
2008-12-29 02:28:49 +01:00
|
|
|
namespace dbgrid_cmds {
|
2008-10-24 23:51:28 +02:00
|
|
|
|
2008-12-29 02:28:49 +01:00
|
|
|
class NetStatCmd : public Command {
|
2008-10-24 23:51:28 +02:00
|
|
|
public:
|
2008-12-29 02:28:49 +01:00
|
|
|
virtual bool slaveOk() {
|
|
|
|
return true;
|
|
|
|
}
|
2008-10-24 23:51:28 +02:00
|
|
|
NetStatCmd() : Command("netstat") { }
|
2008-12-05 16:09:16 +01:00
|
|
|
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
2008-11-09 23:49:37 +01:00
|
|
|
result.append("griddb", gridDatabase.toString());
|
2008-10-24 23:51:28 +02:00
|
|
|
result.append("isdbgrid", 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} netstat;
|
|
|
|
|
2008-12-29 02:28:49 +01:00
|
|
|
class IsDbGridCmd : public Command {
|
2008-10-24 23:51:28 +02:00
|
|
|
public:
|
2008-12-29 02:28:49 +01:00
|
|
|
virtual bool slaveOk() {
|
|
|
|
return true;
|
|
|
|
}
|
2008-10-24 23:51:28 +02:00
|
|
|
IsDbGridCmd() : Command("isdbgrid") { }
|
2008-12-05 16:09:16 +01:00
|
|
|
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
2008-10-24 23:51:28 +02:00
|
|
|
result.append("isdbgrid", 1);
|
|
|
|
result.append("hostname", ourHostname);
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-29 02:28:49 +01:00
|
|
|
} isdbgrid;
|
2008-10-24 23:51:28 +02:00
|
|
|
|
2008-12-29 02:28:49 +01:00
|
|
|
class CmdIsMaster : public Command {
|
2008-10-24 23:51:28 +02:00
|
|
|
public:
|
2008-12-29 02:28:49 +01:00
|
|
|
virtual bool slaveOk() {
|
|
|
|
return true;
|
|
|
|
}
|
2008-10-24 23:51:28 +02:00
|
|
|
CmdIsMaster() : Command("ismaster") { }
|
2008-12-05 16:09:16 +01:00
|
|
|
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
2008-10-24 23:51:28 +02:00
|
|
|
result.append("ismaster", 0.0);
|
|
|
|
result.append("msg", "isdbgrid");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} ismaster;
|
|
|
|
|
|
|
|
}
|