Files
mongo/db/replset.h
Dwight 5deec92469 endian check capability
repl work in progress
cleanup
2008-09-04 10:33:56 -04:00

54 lines
1.7 KiB
C++

/**
* 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
/* ReplSet is a pair of db servers replicating to one another and cooperating.
Only one member of the pair is active at a time; so this is a smart master/slave
configuration basically.
You may read from the slave at anytime though (if you don't mind the slight lag).
todo: Could be extended to be more than a pair, thus the name 'Set' -- for example,
a set of 3...
*/
class ReplSet {
public:
int remotePort;
string remoteHost;
string remote; // host:port if port specified.
ReplSet(const char *remoteEnd);
};
ReplSet::ReplSet(const char *remoteEnd) {
remote = remoteEnd;
remotePort = DBPort;
remoteHost = remoteEnd;
const char *p = strchr(remoteEnd, ':');
if( p ) {
remoteHost = string(remoteEnd, p-remoteEnd);
remotePort = atoi(p+1);
uassert("bad port #", remotePort > 0 && remotePort < 0x10000 );
if( remotePort == DBPort )
remote = remoteHost; // don't include ":27017" as it is default; in case ran in diff ways over time to normalizke the hostname format in sources collection
}
}