summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2012-11-21 11:38:44 -0800
committerShaun Verch <shaun.verch@10gen.com>2012-11-21 16:10:16 -0800
commit319c7f0ced3935dd9d28ed89895112e6504612cd (patch)
tree833c229a58b44a57dfc6b43aa00bfffbf33ccf40
parent219eaa7361faa9a516d2201c9d766ea8285a83e0 (diff)
downloadmongo-319c7f0ced3935dd9d28ed89895112e6504612cd.tar.gz
SERVER-939 Added field type constants for config.changelog collection
-rw-r--r--src/mongo/s/cluster_constants.cpp18
-rw-r--r--src/mongo/s/cluster_constants.h28
-rw-r--r--src/mongo/s/config.cpp14
3 files changed, 39 insertions, 21 deletions
diff --git a/src/mongo/s/cluster_constants.cpp b/src/mongo/s/cluster_constants.cpp
index 05a6ba87ff0..463c22db4ec 100644
--- a/src/mongo/s/cluster_constants.cpp
+++ b/src/mongo/s/cluster_constants.cpp
@@ -72,17 +72,17 @@ namespace mongo {
BSONField<int> SettingFields::UNHOOKED_name("_id");
BSONField<string> SettingFields::UNHOOKED_value("value");
- const string ConfigNS::changelog = "config.changelog";
- BSONField<string> ChangelogFields::UNHOOKED_name("_id");
- BSONField<string> ChangelogFields::UNHOOKED_server("server");
- BSONField<string> ChangelogFields::UNHOOKED_clientAddr("clientAddr");
- BSONField<Date_t> ChangelogFields::UNHOOKED_time("time");
- BSONField<string> ChangelogFields::UNHOOKED_what("what");
- BSONField<string> ChangelogFields::UNHOOKED_ns("ns");
- BSONField<string> ChangelogFields::UNHOOKED_details("details");
-
// ============ below hooked ============
+ const string ConfigNS::changelog = "config.changelog";
+ BSONField<string> ChangelogFields::changeID("_id");
+ BSONField<string> ChangelogFields::server("server");
+ BSONField<string> ChangelogFields::clientAddr("clientAddr");
+ BSONField<Date_t> ChangelogFields::time("time");
+ BSONField<string> ChangelogFields::what("what");
+ BSONField<string> ChangelogFields::ns("ns");
+ BSONField<BSONObj> ChangelogFields::details("details");
+
const string ConfigNS::locks = "config.locks";
BSONField<string> LockFields::name("_id");
BSONField<int> LockFields::state("state");
diff --git a/src/mongo/s/cluster_constants.h b/src/mongo/s/cluster_constants.h
index 9f1750bf626..291a6e70125 100644
--- a/src/mongo/s/cluster_constants.h
+++ b/src/mongo/s/cluster_constants.h
@@ -146,13 +146,27 @@ namespace mongo {
* ChangelogFields holds all the field names and types for the changelog collection.
*/
struct ChangelogFields {
- static BSONField<string> UNHOOKED_name;
- static BSONField<string> UNHOOKED_server;
- static BSONField<string> UNHOOKED_clientAddr;
- static BSONField<Date_t> UNHOOKED_time;
- static BSONField<string> UNHOOKED_what;
- static BSONField<string> UNHOOKED_ns;
- static BSONField<string> UNHOOKED_details;
+
+ // id for this change "<hostname>-<current_time>-<increment>"
+ static BSONField<string> changeID;
+
+ // hostname of server that we are making the change on. Does not include port.
+ static BSONField<string> server;
+
+ // hostname:port of the client that made this change
+ static BSONField<string> clientAddr;
+
+ // time this change was made
+ static BSONField<Date_t> time;
+
+ // description of the change
+ static BSONField<string> what;
+
+ // database or collection this change applies to
+ static BSONField<string> ns;
+
+ // A BSONObj containing extra information about some operations
+ static BSONField<BSONObj> details;
};
/**
diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp
index 24fcfbb198b..de59334b10c 100644
--- a/src/mongo/s/config.cpp
+++ b/src/mongo/s/config.cpp
@@ -38,7 +38,6 @@ namespace mongo {
int ConfigServer::VERSION = 3;
Shard Shard::EMPTY;
- string ShardNS::mongos = "config.mongos";
string ShardNS::settings = "config.settings";
OID serverID;
@@ -993,8 +992,13 @@ namespace mongo {
// send a copy of the message to the log in case it doesn't manage to reach config.changelog
Client* c = currentClient.get();
- BSONObj msg = BSON( "_id" << changeID << "server" << getHostNameCached() << "clientAddr" << (c ? c->clientAddress(true) : "N/A")
- << "time" << DATENOW << "what" << what << "ns" << ns << "details" << detail );
+ BSONObj msg = BSON( ChangelogFields::changeID(changeID) <<
+ ChangelogFields::server(getHostNameCached()) <<
+ ChangelogFields::clientAddr((c ? c->clientAddress(true) : "N/A")) <<
+ ChangelogFields::time(jsTime()) <<
+ ChangelogFields::what(what) <<
+ ChangelogFields::ns(ns) <<
+ ChangelogFields::details(detail) );
log() << "about to log metadata event: " << msg << endl;
verify( _primary.ok() );
@@ -1006,7 +1010,7 @@ namespace mongo {
static bool createdCapped = false;
if ( ! createdCapped ) {
try {
- conn->get()->createCollection( "config.changelog" , 1024 * 1024 * 10 , true );
+ conn->get()->createCollection( ConfigNS::changelog , 1024 * 1024 * 10 , true );
}
catch ( UserException& e ) {
LOG(1) << "couldn't create changelog (like race condition): " << e << endl;
@@ -1015,7 +1019,7 @@ namespace mongo {
createdCapped = true;
}
- conn->get()->insert( "config.changelog" , msg );
+ conn->get()->insert( ConfigNS::changelog , msg );
conn->done();