diff options
author | unknown <Administrator@.(none)> | 2008-11-09 17:49:37 -0500 |
---|---|---|
committer | unknown <Administrator@.(none)> | 2008-11-09 17:49:37 -0500 |
commit | 8beba2346ec0e4d917e64fa7a5ab32cb51a773f2 (patch) | |
tree | 22ee6d96b841e9dd850a8e218672bb274d1602ea /dbgrid | |
parent | c8315736840386d64e1e42ceb32b595446355618 (diff) | |
download | mongo-8beba2346ec0e4d917e64fa7a5ab32cb51a773f2.tar.gz |
checkpoint work
Diffstat (limited to 'dbgrid')
-rw-r--r-- | dbgrid/database.h | 12 | ||||
-rw-r--r-- | dbgrid/dbgrid.cpp | 2 | ||||
-rw-r--r-- | dbgrid/dbgrid.vcproj | 46 | ||||
-rw-r--r-- | dbgrid/dbgrid_commands.cpp | 2 | ||||
-rw-r--r-- | dbgrid/gridconfig.cpp | 1 | ||||
-rw-r--r-- | dbgrid/gridconfig.h | 11 | ||||
-rw-r--r-- | dbgrid/griddatabase.cpp (renamed from dbgrid/griddb.cpp) | 11 | ||||
-rw-r--r-- | dbgrid/griddatabase.h | 39 | ||||
-rw-r--r-- | dbgrid/request.cpp | 8 | ||||
-rw-r--r-- | dbgrid/shard.cpp (renamed from dbgrid/database.cpp) | 14 | ||||
-rw-r--r-- | dbgrid/shard.h | 36 |
11 files changed, 122 insertions, 60 deletions
diff --git a/dbgrid/database.h b/dbgrid/database.h deleted file mode 100644 index 97b553849fe..00000000000 --- a/dbgrid/database.h +++ /dev/null @@ -1,12 +0,0 @@ -// cbgrid/database.h - -/* DEPRECATED DELETE */ - -/* we create a database object for each client database -*/ -class Database { - static boost::mutex mutex; -public: - /* load list of databases from the grid db. */ - static void load(); -}; diff --git a/dbgrid/dbgrid.cpp b/dbgrid/dbgrid.cpp index e5cccc114c0..344e3ed7b2d 100644 --- a/dbgrid/dbgrid.cpp +++ b/dbgrid/dbgrid.cpp @@ -97,7 +97,7 @@ public: }; void start() { - gridDB.init(); + gridDatabase.init(); /* try { cout << "TEMP" << endl; diff --git a/dbgrid/dbgrid.vcproj b/dbgrid/dbgrid.vcproj index a734f114311..919645ac8f1 100644 --- a/dbgrid/dbgrid.vcproj +++ b/dbgrid/dbgrid.vcproj @@ -187,13 +187,17 @@ > </File> <File - RelativePath=".\griddb.cpp" + RelativePath=".\griddatabase.cpp" > </File> <File RelativePath=".\request.cpp" > </File> + <File + RelativePath=".\shard.cpp" + > + </File> </Filter> <Filter Name="Header Files" @@ -201,31 +205,15 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath=".\database.h" - > - </File> - <File - RelativePath="..\db\dbmessage.h" - > - </File> - <File - RelativePath="..\util\goodies.h" - > - </File> - <File RelativePath=".\gridconfig.h" > </File> <File - RelativePath="..\db\jsobj.h" - > - </File> - <File - RelativePath="..\db\json.h" + RelativePath=".\griddatabase.h" > </File> <File - RelativePath="..\stdafx.h" + RelativePath=".\shard.h" > </File> <Filter @@ -239,6 +227,26 @@ RelativePath="..\db\commands.h" > </File> + <File + RelativePath="..\db\dbmessage.h" + > + </File> + <File + RelativePath="..\util\goodies.h" + > + </File> + <File + RelativePath="..\db\jsobj.h" + > + </File> + <File + RelativePath="..\db\json.h" + > + </File> + <File + RelativePath="..\stdafx.h" + > + </File> </Filter> </Filter> <Filter diff --git a/dbgrid/dbgrid_commands.cpp b/dbgrid/dbgrid_commands.cpp index 74464b0851a..f3b34994cd9 100644 --- a/dbgrid/dbgrid_commands.cpp +++ b/dbgrid/dbgrid_commands.cpp @@ -44,7 +44,7 @@ class NetStatCmd : public Command { public: NetStatCmd() : Command("netstat") { } bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result) { - result.append("griddb", gridDB.toString()); + result.append("griddb", gridDatabase.toString()); result.append("isdbgrid", 1); return true; } diff --git a/dbgrid/gridconfig.cpp b/dbgrid/gridconfig.cpp index da915161386..57ca10a603e 100644 --- a/dbgrid/gridconfig.cpp +++ b/dbgrid/gridconfig.cpp @@ -19,7 +19,6 @@ #include "stdafx.h" #include "../grid/message.h" #include "../util/unittest.h" -#include "database.h" #include "../client/connpool.h" #include "../db/pdfile.h" #include "gridconfig.h" diff --git a/dbgrid/gridconfig.h b/dbgrid/gridconfig.h index 53db6380126..128752087ab 100644 --- a/dbgrid/gridconfig.h +++ b/dbgrid/gridconfig.h @@ -25,16 +25,7 @@ #include "../client/dbclient.h" #include "../client/model.h" - -class GridDB { -public: - DBClientPaired conn; - enum { Port = 27016 }; /* standard port # for a grid db */ - GridDB(); - void init(); - string toString() { return conn.toString(); } -}; -extern GridDB gridDB; +#include "griddatabase.h" /* Machine is the concept of a host that runs the db process. */ diff --git a/dbgrid/griddb.cpp b/dbgrid/griddatabase.cpp index 90fe44dcb90..2e4c71ea129 100644 --- a/dbgrid/griddb.cpp +++ b/dbgrid/griddatabase.cpp @@ -19,21 +19,20 @@ #include "stdafx.h" #include "../grid/message.h" #include "../util/unittest.h" -#include "database.h" #include "../client/connpool.h" #include "../db/pdfile.h" -#include "gridconfig.h" #include "../client/model.h" #include "../util/background.h" +#include "griddatabase.h" static boost::mutex griddb_mutex; -GridDB gridDB; -DBClientCommands *Model::globalConn = &gridDB.conn; +GridDatabase gridDatabase; +DBClientWithCommands *Model::globalConn = &gridDatabase.conn; string ourHostname; -GridDB::GridDB() { } +GridDatabase::GridDatabase() { } -void GridDB::init() { +void GridDatabase::init() { char buf[256]; int ec = gethostname(buf, 127); if( ec || *buf == 0 ) { diff --git a/dbgrid/griddatabase.h b/dbgrid/griddatabase.h new file mode 100644 index 00000000000..85d29443c3e --- /dev/null +++ b/dbgrid/griddatabase.h @@ -0,0 +1,39 @@ +/* griddatabase.h + + The grid database is where we get: + - name of each shard + - "home" shard for each client +*/ + +/** +* Copyright (C) 2008 10gen Inc. +* +* 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. +* +* 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. +* +* 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/>. +*/ + +#pragma once + +#include "shard.h" + +class GridDatabase { +public: + DBClientPaired conn; + enum { Port = 27016 }; /* standard port # for a grid db */ + GridDatabase(); + string toString() { return conn.toString(); } + + /* call at startup, this will initiate connection to the grid db */ + void init(); +}; +extern GridDatabase gridDatabase; + diff --git a/dbgrid/request.cpp b/dbgrid/request.cpp index 79082c40bd3..f43eef3c194 100644 --- a/dbgrid/request.cpp +++ b/dbgrid/request.cpp @@ -1,4 +1,7 @@ -// dbgrid/request.cpp +/* dbgrid/request.cpp + + Top level handling of requests (operations such as query, insert, ...) +*/ /** * Copyright (C) 2008 10gen Inc. @@ -17,6 +20,9 @@ */ /* TODO + _ GridD + + _ concurrency control. _ connection pool _ hostbyname_nonreentrant() problem diff --git a/dbgrid/database.cpp b/dbgrid/shard.cpp index 6a02596b999..d8dacfe083c 100644 --- a/dbgrid/database.cpp +++ b/dbgrid/shard.cpp @@ -1,4 +1,4 @@ -// database.cpp +// shard.cpp /** * Copyright (C) 2008 10gen Inc. @@ -16,14 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* DEPRECATED DELETE */ - - #include "stdafx.h" -#include "database.h" -#include "../db/dbclient.h" - -boost::mutex Database::mutex; +#include "shard.h" +#include "griddatabase.h" -void Database::load() { +DBClientWithCommands* Shard::conn() { + return &gridDatabase.conn; } diff --git a/dbgrid/shard.h b/dbgrid/shard.h new file mode 100644 index 00000000000..d6bf0424b6c --- /dev/null +++ b/dbgrid/shard.h @@ -0,0 +1,36 @@ +/* shard.h + + A "shard" is a database (replica pair typically) which represents + one partition of the overall database. +*/ + +/** +* Copyright (C) 2008 10gen Inc. +* +* 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. +* +* 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. +* +* 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/>. +*/ + +#pragma once + +#include "../client/dbclient.h" +#include "../client/model.h" + +class Shard : public Model { +public: + string name; // hostname (less -l, -r) + + virtual const char * getNS() { return "grid.shards"; } + virtual void serialize(BSONObjBuilder& to); + virtual void unserialize(BSONObj& from); + virtual DBClientWithCommands* conn(); +}; |