Couldn't find wdiff. Falling back to builtin diff colouring...
| config.h | | config.h | |
|
| /* config.h. Generated from config.h.in by configure. */ | | // config.h | |
| /* config.h.in. Generated from configure.ac by autoheader. */ | | | |
| | | | |
|
| /* On Unix-like systems config.h.in is converted by "configure" into config
.h. | | /** | |
| Some other environments also support the use of "configure". PCRE is writte
n in | | * Copyright (C) 2008 10gen Inc. | |
| Standard C, but there are a few non-standard things it can cope with, allow
ing | | * | |
| it to run on SunOS4 and other "close to standard" systems. | | * 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 Licen
se | |
| | | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| | | */ | |
| | | | |
|
| If you are going to build PCRE "by hand" on a system without "configure" yo
u | | /* This file is things related to the "grid configuration": | |
| should copy the distributed config.h.generic to config.h, and then set up t
he | | - what machines make up the db component of our cloud | |
| macro definitions the way you need them. You must then add -DHAVE_CONFIG_H
to | | - where various ranges of things live | |
| all of your compile commands, so that config.h is included at the start of | | */ | |
| every source. | | | |
| | | | |
|
| Alternatively, you can avoid editing by using -D on the compiler command li
ne | | #pragma once | |
| to set the macro values. In this case, you do not have to set -DHAVE_CONFIG
_H. | | | |
| | | | |
|
| PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy()
if | | #include "../db/namespace.h" | |
| HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), s
et | | #include "../client/dbclient.h" | |
| them both to 0; an emulation function will be used. */ | | #include "../client/model.h" | |
| | | | |
|
| /* By default, the \R escape sequence matches any Unicode line ending | | #include "chunk.h" | |
| character or sequence of characters. If BSR_ANYCRLF is defined, this is | | #include "shard.h" | |
| changed so that backslash-R matches only CR, LF, or CRLF. The build- tim
e | | #include "shardkey.h" | |
| default can be overridden by the user of PCRE at runtime. On systems tha
t | | | |
| support it, "configure" can be used to override the default. */ | | | |
| /* #undef BSR_ANYCRLF */ | | | |
| | | | |
|
| /* If you are compiling for a system that uses EBCDIC instead of ASCII | | namespace mongo { | |
| character codes, define this macro as 1. On systems that can use | | | |
| "configure", this can be done via --enable-ebcdic. */ | | | |
| /* #undef EBCDIC */ | | | |
| | | | |
|
| /* Define to 1 if you have the `bcopy' function. */ | | struct ShardNS { | |
| #define HAVE_BCOPY 1 | | static string shard; | |
| | | | |
|
| /* Define to 1 if you have the <bits/type_traits.h> header file. */ | | static string database; | |
| /* #undef HAVE_BITS_TYPE_TRAITS_H */ | | static string collection; | |
| | | static string chunk; | |
| | | | |
|
| /* Define to 1 if you have the <dirent.h> header file. */ | | static string mongos; | |
| // #define HAVE_DIRENT_H 1 ERH | | static string settings; | |
| | | }; | |
| | | | |
|
| /* Define to 1 if you have the <dlfcn.h> header file. */ | | /** | |
| #define HAVE_DLFCN_H 1 | | * Field names used in the 'shards' collection. | |
| | | */ | |
| | | struct ShardFields { | |
| | | static BSONField<bool> draining; // is it draining chunks? | |
| | | static BSONField<long long> maxSize; // max allowed disk space usa
ge | |
| | | }; | |
| | | | |
|
| /* Define to 1 if you have the <inttypes.h> header file. */ | | class ConfigServer; | |
| #define HAVE_INTTYPES_H 1 | | | |
| | | | |
|
| /* Define to 1 if you have the <limits.h> header file. */ | | class DBConfig; | |
| #define HAVE_LIMITS_H 1 | | typedef boost::shared_ptr<DBConfig> DBConfigPtr; | |
| | | | |
|
| /* Define to 1 if the system has the type `long long'. */ | | extern DBConfigPtr configServerPtr; | |
| #define HAVE_LONG_LONG 1 | | extern ConfigServer& configServer; | |
| | | | |
|
| /* Define to 1 if you have the `memmove' function. */ | | /** | |
| #define HAVE_MEMMOVE 1 | | * top level configuration for a database | |
| | | */ | |
| | | class DBConfig { | |
| | | | |
|
| /* Define to 1 if you have the <memory.h> header file. */ | | struct CollectionInfo { | |
| #define HAVE_MEMORY_H 1 | | CollectionInfo() { | |
| | | _dirty = false; | |
| | | _dropped = false; | |
| | | } | |
| | | | |
|
| /* Define to 1 if you have the <stdint.h> header file. */ | | CollectionInfo( const BSONObj& in ); | |
| #define HAVE_STDINT_H 1 | | | |
| | | | |
|
| /* Define to 1 if you have the <stdlib.h> header file. */ | | bool isSharded() const { | |
| #define HAVE_STDLIB_H 1 | | return _cm.get(); | |
| | | } | |
| | | | |
|
| /* Define to 1 if you have the `strerror' function. */ | | ChunkManagerPtr getCM() const { | |
| #define HAVE_STRERROR 1 | | return _cm; | |
| | | } | |
| | | | |
|
| /* Define to 1 if you have the <string> header file. */ | | void resetCM( ChunkManager * cm ) { | |
| #define HAVE_STRING 1 | | assert(cm); | |
| | | assert(_cm); // this has to be already sharded | |
| | | _cm.reset( cm ); | |
| | | } | |
| | | | |
|
| /* Define to 1 if you have the <strings.h> header file. */ | | void shard( const string& ns , const ShardKeyPattern& key , boo
l unique ); | |
| #define HAVE_STRINGS_H 1 | | void unshard(); | |
| | | | |
|
| /* Define to 1 if you have the <string.h> header file. */ | | bool isDirty() const { return _dirty; } | |
| #define HAVE_STRING_H 1 | | bool wasDropped() const { return _dropped; } | |
| | | | |
|
| /* Define to 1 if you have the `strtoll' function. */ | | void save( const string& ns , DBClientBase* conn ); | |
| // dm: visual studio | | | |
| //#define HAVE_STRTOLL 1 | | | |
| | | | |
|
| /* Define to 1 if you have the `strtoq' function. */ | | bool unique() const { return _unqiue; } | |
| // dm: visual studio | | BSONObj key() const { return _key; } | |
| //#define HAVE_STRTOQ 1 | | | |
| | | | |
|
| /* Define to 1 if you have the <sys/stat.h> header file. */ | | private: | |
| #define HAVE_SYS_STAT_H 1 | | BSONObj _key; | |
| | | bool _unqiue; | |
| | | ChunkManagerPtr _cm; | |
| | | bool _dirty; | |
| | | bool _dropped; | |
| | | }; | |
| | | | |
|
| /* Define to 1 if you have the <sys/types.h> header file. */ | | typedef map<string,CollectionInfo> Collections; | |
| #define HAVE_SYS_TYPES_H 1 | | | |
| | | | |
|
| /* Define to 1 if you have the <type_traits.h> header file. */ | | public: | |
| /* #undef HAVE_TYPE_TRAITS_H */ | | | |
| | | | |
|
| /* Define to 1 if you have the <unistd.h> header file. */ | | DBConfig( string name ) | |
| //#define HAVE_UNISTD_H 1 ERH | | : _name( name ) , | |
| | | _primary("config","") , | |
| | | _shardingEnabled(false), | |
| | | _lock("DBConfig") { | |
| | | assert( name.size() ); | |
| | | } | |
| | | virtual ~DBConfig() {} | |
| | | | |
|
| /* Define to 1 if the system has the type `unsigned long long'. */ | | string getName() { return _name; }; | |
| #define HAVE_UNSIGNED_LONG_LONG 1 | | | |
| | | | |
|
| /* Define to 1 if you have the <windows.h> header file. */ | | /** | |
| /* #undef HAVE_WINDOWS_H */ | | * @return if anything in this db is partitioned or not | |
| | | */ | |
| | | bool isShardingEnabled() { | |
| | | return _shardingEnabled; | |
| | | } | |
| | | | |
|
| /* Define to 1 if you have the `_strtoi64' function. */ | | void enableSharding(); | |
| /* #undef HAVE__STRTOI64 */ | | ChunkManagerPtr shardCollection( const string& ns , ShardKeyPattern
fieldsAndOrder , bool unique ); | |
| // dm: visual studio | | | |
| #define HAVE__STRTOI64 1 | | | |
| | | | |
|
| /* The value of LINK_SIZE determines the number of bytes used to store link
s | | /** | |
| as offsets within the compiled regex. The default is 2, which allows for | | @return true if there was sharding info to remove | |
| compiled patterns up to 64K long. This covers the vast majority of cases
. | | */ | |
| However, PCRE can also be compiled to use 3 or 4 bytes instead. This all
ows | | bool removeSharding( const string& ns ); | |
| for longer patterns in extreme cases. On systems that support it, | | | |
| "configure" can be used to override this default. */ | | | |
| #define LINK_SIZE 2 | | | |
| | | | |
|
| /* The value of MATCH_LIMIT determines the default number of times the | | /** | |
| internal match() function can be called during a single execution of | | * @return whether or not the 'ns' collection is partitioned | |
| pcre_exec(). There is a runtime interface for setting a different limit. | | */ | |
| The limit exists in order to catch runaway regular expressions that take | | bool isSharded( const string& ns ); | |
| for ever to determine that they do not match. The default is set very la
rge | | | |
| so that it does not accidentally catch legitimate cases. On systems that | | | |
| support it, "configure" can be used to override this default default. */ | | | |
| #define MATCH_LIMIT 200000 | | | |
| | | | |
|
| /* The above limit applies to all calls of match(), whether or not they | | ChunkManagerPtr getChunkManager( const string& ns , bool reload = f
alse ); | |
| increase the recursion depth. In some environments it is desirable to li
mit | | ChunkManagerPtr getChunkManagerIfExists( const string& ns , bool re
load = false ); | |
| the depth of recursive calls of match() more strictly, in order to restr
ict | | | |
| the maximum amount of stack (or heap, if NO_RECURSE is defined) that is | | | |
| used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls
of | | | |
| match(). To have any useful effect, it must be less than the value of | | | |
| MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There
is | | | |
| a runtime method for setting a different limit. On systems that support
it, | | | |
| "configure" can be used to override the default. */ | | | |
| #define MATCH_LIMIT_RECURSION 4000 | | | |
| | | | |
|
| /* This limit is parameterized just in case anybody ever wants to change it
. | | /** | |
| Care must be taken if it is increased, because it guards against integer | | * @return the correct for shard for the ns | |
| overflow caused by enormously large patterns. */ | | * if the namespace is sharded, will return NULL | |
| #define MAX_NAME_COUNT 10000 | | */ | |
| | | const Shard& getShard( const string& ns ); | |
| | | | |
|
| /* This limit is parameterized just in case anybody ever wants to change it
. | | const Shard& getPrimary() const { | |
| Care must be taken if it is increased, because it guards against integer | | uassert( 8041 , (string)"no primary shard configured for db: "
+ _name , _primary.ok() ); | |
| overflow caused by enormously large patterns. */ | | return _primary; | |
| #define MAX_NAME_SIZE 32 | | } | |
| | | | |
|
| /* The value of NEWLINE determines the newline character sequence. On syste
ms | | void setPrimary( string s ); | |
| that support it, "configure" can be used to override the default, which
is | | | |
| 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or
-2 | | | |
| (ANYCRLF). */ | | | |
| #define NEWLINE 10 | | | |
| | | | |
|
| /* PCRE uses recursive function calls to handle backtracking while matching
. | | bool load(); | |
| This can sometimes be a problem on systems that have stacks of limited | | bool reload(); | |
| size. Define NO_RECURSE to get a version that doesn't use recursion in t
he | | | |
| match() function; instead it creates its own stack by steam using | | | |
| pcre_recurse_malloc() to obtain memory from the heap. For more detail, s
ee | | | |
| the comments and other stuff just above the match() function. On systems | | | |
| that support it, "configure" can be used to set this in the Makefile (us
e | | | |
| --disable-stack-for-recursion). */ | | | |
| /* #undef NO_RECURSE */ | | | |
| /* mongodb: don't recurse, don't want to use much stack or blow stack */ | | | |
| #define NO_RECURSE 1 | | | |
| | | | |
|
| /* Name of package */ | | bool dropDatabase( string& errmsg ); | |
| #define PACKAGE "pcre" | | | |
| | | | |
|
| /* Define to the address where bug reports for this package should be sent.
*/ | | // model stuff | |
| #define PACKAGE_BUGREPORT "" | | | |
| | | | |
|
| /* Define to the full name of this package. */ | | // lockless loading | |
| #define PACKAGE_NAME "PCRE" | | void serialize(BSONObjBuilder& to); | |
| | | | |
|
| /* Define to the full name and version of this package. */ | | void unserialize(const BSONObj& from); | |
| #define PACKAGE_STRING "PCRE 7.4" | | | |
| | | | |
|
| /* Define to the one symbol short name of this package. */ | | void getAllShards(set<Shard>& shards) const; | |
| #define PACKAGE_TARNAME "pcre" | | | |
| | | | |
|
| /* Define to the version of this package. */ | | protected: | |
| #define PACKAGE_VERSION "7.4" | | | |
| | | | |
|
| /* If you are compiling for a system other than a Unix-like system or | | /** | |
| Win32, and it needs some magic to be inserted before the definition | | lockless | |
| of a function that is exported by the library, define this macro to | | */ | |
| contain the relevant magic. If you do not define this macro, it | | bool _isSharded( const string& ns ); | |
| defaults to "extern" for a C compiler and "extern C" for a C++ | | | |
| compiler on non-Win32 systems. This macro apears at the start of | | | |
| every exported function that is part of the external API. It does | | | |
| not appear on functions that are "external" in the C sense, but | | | |
| which are internal to the library. */ | | | |
| /* #undef PCRE_EXP_DEFN */ | | | |
| | | | |
|
| /* Define if linking statically (TODO: make nice with Libtool) */ | | bool _dropShardedCollections( int& num, set<Shard>& allServers , st
ring& errmsg ); | |
| /* #undef PCRE_STATIC */ | | | |
| | | | |
|
| /* When calling PCRE via the POSIX interface, additional working storage is | | bool _load(); | |
| required for holding the pointers to capturing substrings because PCRE | | bool _reload(); | |
| requires three integers per substring, whereas the POSIX interface provi
des | | void _save( bool db = true, bool coll = true ); | |
| only two. If the number of expected substrings is small, the wrapper | | | |
| function uses space on the stack, because this is faster than using | | | |
| malloc() for each call. The threshold above which the stack is no longer | | | |
| used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it, | | | |
| "configure" can be used to override this default. */ | | | |
| #define POSIX_MALLOC_THRESHOLD 10 | | | |
| | | | |
|
| /* Define to 1 if you have the ANSI C header files. */ | | string _name; // e.g. "alleyinsider" | |
| #define STDC_HEADERS 1 | | Shard _primary; // e.g. localhost , mongo.foo.com:9999 | |
| | | bool _shardingEnabled; | |
| | | | |
|
| /* Define to enable support for Unicode properties */ | | //map<string,CollectionInfo> _sharded; // { "alleyinsider.blog.post
s" : { ts : 1 } , ... ] - all ns that are sharded | |
| /* #undef SUPPORT_UCP */ | | //map<string,ChunkManagerPtr> _shards; // this will only have entri
es for things that have been looked at | |
| | | | |
|
| /* Define to enable support for the UTF-8 Unicode encoding. */ | | Collections _collections; | |
| #if( !defined(SUPPORT_UTF8) ) | | | |
| #define SUPPORT_UTF8 | | | |
| #endif | | | |
| | | | |
|
| /* Version number of package */ | | mutable mongo::mutex _lock; // TODO: change to r/w lock ?? | |
| #define VERSION "7.4" | | }; | |
| | | | |
|
| /* Define to empty if `const' does not conform to ANSI C. */ | | class ConfigServer : public DBConfig { | |
| /* #undef const */ | | public: | |
| | | | |
|
| /* Define to `unsigned int' if <sys/types.h> does not define. */ | | ConfigServer(); | |
| /* #undef size_t */ | | ~ConfigServer(); | |
| | | | |
| | | bool ok( bool checkConsistency = false ); | |
| | | | |
| | | virtual string modelServer() { | |
| | | uassert( 10190 , "ConfigServer not setup" , _primary.ok() ); | |
| | | return _primary.getConnString(); | |
| | | } | |
| | | | |
| | | /** | |
| | | call at startup, this will initiate connection to the grid db | |
| | | */ | |
| | | bool init( vector<string> configHosts ); | |
| | | | |
| | | bool init( string s ); | |
| | | | |
| | | bool allUp(); | |
| | | bool allUp( string& errmsg ); | |
| | | | |
| | | int dbConfigVersion(); | |
| | | int dbConfigVersion( DBClientBase& conn ); | |
| | | | |
| | | void reloadSettings(); | |
| | | | |
| | | /** | |
| | | * @return 0 = ok, otherwise error # | |
| | | */ | |
| | | int checkConfigVersion( bool upgrade ); | |
| | | | |
| | | /** | |
| | | * Create a metadata change log entry in the config.changelog colle
ction. | |
| | | * | |
| | | * @param what e.g. "split" , "migrate" | |
| | | * @param ns to which collection the metadata change is being appli
ed | |
| | | * @param msg additional info about the metadata change | |
| | | * | |
| | | * This call is guaranteed never to throw. | |
| | | */ | |
| | | void logChange( const string& what , const string& ns , const BSONO
bj& detail = BSONObj() ); | |
| | | | |
| | | ConnectionString getConnectionString() const { | |
| | | return ConnectionString( _primary.getConnString() , ConnectionS
tring::SYNC ); | |
| | | } | |
| | | | |
| | | void replicaSetChange( const ReplicaSetMonitor * monitor ); | |
| | | | |
| | | static int VERSION; | |
| | | | |
| | | /** | |
| | | * check to see if all config servers have the same state | |
| | | * will try tries time to make sure not catching in a bad state | |
| | | */ | |
| | | bool checkConfigServersConsistent( string& errmsg , int tries = 4 )
const; | |
| | | | |
| | | private: | |
| | | string getHost( string name , bool withPort ); | |
| | | vector<string> _config; | |
| | | }; | |
| | | | |
| | | } // namespace mongo | |
| | | | |
End of changes. 53 change blocks. |
| 172 lines changed or deleted | | 149 lines changed or added | |
|
| queryoptimizer.h | | queryoptimizer.h | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 47 | |
| | | | |
| /** | | /** | |
| * @param originalFrsp - original constraints for this query clause
. If null, frsp will be used instead. | | * @param originalFrsp - original constraints for this query clause
. If null, frsp will be used instead. | |
| */ | | */ | |
| QueryPlan(NamespaceDetails *d, | | QueryPlan(NamespaceDetails *d, | |
| int idxNo, // -1 = no index | | int idxNo, // -1 = no index | |
| const FieldRangeSetPair &frsp, | | const FieldRangeSetPair &frsp, | |
| const FieldRangeSetPair *originalFrsp, | | const FieldRangeSetPair *originalFrsp, | |
| const BSONObj &originalQuery, | | const BSONObj &originalQuery, | |
| const BSONObj &order, | | const BSONObj &order, | |
|
| | | bool mustAssertOnYieldFailure = true, | |
| const BSONObj &startKey = BSONObj(), | | const BSONObj &startKey = BSONObj(), | |
| const BSONObj &endKey = BSONObj(), | | const BSONObj &endKey = BSONObj(), | |
| string special="" ); | | string special="" ); | |
| | | | |
| /** @return true iff no other plans should be considered. */ | | /** @return true iff no other plans should be considered. */ | |
| bool optimal() const { return _optimal; } | | bool optimal() const { return _optimal; } | |
| /* @return true iff this plan should not be considered at all. */ | | /* @return true iff this plan should not be considered at all. */ | |
| bool unhelpful() const { return _unhelpful; } | | bool unhelpful() const { return _unhelpful; } | |
| /** @return true iff ScanAndOrder processing will be required for r
esult set. */ | | /** @return true iff ScanAndOrder processing will be required for r
esult set. */ | |
| bool scanAndOrderRequired() const { return _scanAndOrderRequired; } | | bool scanAndOrderRequired() const { return _scanAndOrderRequired; } | |
| | | | |
| skipping to change at line 85 | | skipping to change at line 86 | |
| int idxNo() const { return _idxNo; } | | int idxNo() const { return _idxNo; } | |
| const char *ns() const { return _frs.ns(); } | | const char *ns() const { return _frs.ns(); } | |
| NamespaceDetails *nsd() const { return _d; } | | NamespaceDetails *nsd() const { return _d; } | |
| BSONObj originalQuery() const { return _originalQuery; } | | BSONObj originalQuery() const { return _originalQuery; } | |
| BSONObj simplifiedQuery( const BSONObj& fields = BSONObj() ) const
{ return _frs.simplifiedQuery( fields ); } | | BSONObj simplifiedQuery( const BSONObj& fields = BSONObj() ) const
{ return _frs.simplifiedQuery( fields ); } | |
| const FieldRange &range( const char *fieldName ) const { return _fr
s.range( fieldName ); } | | const FieldRange &range( const char *fieldName ) const { return _fr
s.range( fieldName ); } | |
| shared_ptr<FieldRangeVector> originalFrv() const { return _original
Frv; } | | shared_ptr<FieldRangeVector> originalFrv() const { return _original
Frv; } | |
| | | | |
| const FieldRangeSet &multikeyFrs() const { return _frsMulti; } | | const FieldRangeSet &multikeyFrs() const { return _frsMulti; } | |
| | | | |
|
| | | bool mustAssertOnYieldFailure() const { return _mustAssertOnYieldFa
ilure; } | |
| | | | |
| /** just for testing */ | | /** just for testing */ | |
| | | | |
| shared_ptr<FieldRangeVector> frv() const { return _frv; } | | shared_ptr<FieldRangeVector> frv() const { return _frv; } | |
| bool isMultiKey() const; | | bool isMultiKey() const; | |
| | | | |
| private: | | private: | |
| NamespaceDetails * _d; | | NamespaceDetails * _d; | |
| int _idxNo; | | int _idxNo; | |
| const FieldRangeSet &_frs; | | const FieldRangeSet &_frs; | |
| const FieldRangeSet &_frsMulti; | | const FieldRangeSet &_frsMulti; | |
| | | | |
| skipping to change at line 112 | | skipping to change at line 115 | |
| shared_ptr<FieldRangeVector> _frv; | | shared_ptr<FieldRangeVector> _frv; | |
| shared_ptr<FieldRangeVector> _originalFrv; | | shared_ptr<FieldRangeVector> _originalFrv; | |
| BSONObj _startKey; | | BSONObj _startKey; | |
| BSONObj _endKey; | | BSONObj _endKey; | |
| bool _endKeyInclusive; | | bool _endKeyInclusive; | |
| bool _unhelpful; | | bool _unhelpful; | |
| bool _impossible; | | bool _impossible; | |
| string _special; | | string _special; | |
| IndexType * _type; | | IndexType * _type; | |
| bool _startOrEndSpec; | | bool _startOrEndSpec; | |
|
| | | bool _mustAssertOnYieldFailure; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Inherit from this interface to implement a new query operation. | | * Inherit from this interface to implement a new query operation. | |
| * The query optimizer will clone the QueryOp that is provided, giving | | * The query optimizer will clone the QueryOp that is provided, giving | |
| * each clone its own query plan. | | * each clone its own query plan. | |
| * | | * | |
| * Normal sequence of events: | | * Normal sequence of events: | |
| * 1) A new QueryOp is generated using createChild(). | | * 1) A new QueryOp is generated using createChild(). | |
| * 2) A QueryPlan is assigned to this QueryOp with setQueryPlan(). | | * 2) A QueryPlan is assigned to this QueryOp with setQueryPlan(). | |
| | | | |
| skipping to change at line 259 | | skipping to change at line 263 | |
| typedef vector<QueryPlanPtr> PlanSet; | | typedef vector<QueryPlanPtr> PlanSet; | |
| | | | |
| /** | | /** | |
| * @param originalFrsp - original constraints for this query clause
; if null, frsp will be used. | | * @param originalFrsp - original constraints for this query clause
; if null, frsp will be used. | |
| */ | | */ | |
| QueryPlanSet( const char *ns, | | QueryPlanSet( const char *ns, | |
| auto_ptr<FieldRangeSetPair> frsp, | | auto_ptr<FieldRangeSetPair> frsp, | |
| auto_ptr<FieldRangeSetPair> originalFrsp, | | auto_ptr<FieldRangeSetPair> originalFrsp, | |
| const BSONObj &originalQuery, | | const BSONObj &originalQuery, | |
| const BSONObj &order, | | const BSONObj &order, | |
|
| | | bool mustAssertOnYieldFailure = true, | |
| const BSONElement *hint = 0, | | const BSONElement *hint = 0, | |
| bool honorRecordedPlan = true, | | bool honorRecordedPlan = true, | |
| const BSONObj &min = BSONObj(), | | const BSONObj &min = BSONObj(), | |
| const BSONObj &max = BSONObj(), | | const BSONObj &max = BSONObj(), | |
| bool bestGuessOnly = false, | | bool bestGuessOnly = false, | |
| bool mayYield = false); | | bool mayYield = false); | |
| | | | |
| /** @return number of candidate plans. */ | | /** @return number of candidate plans. */ | |
| int nPlans() const { return _plans.size(); } | | int nPlans() const { return _plans.size(); } | |
| | | | |
| | | | |
| skipping to change at line 375 | | skipping to change at line 380 | |
| BSONObj _order; | | BSONObj _order; | |
| long long _oldNScanned; | | long long _oldNScanned; | |
| bool _honorRecordedPlan; | | bool _honorRecordedPlan; | |
| BSONObj _min; | | BSONObj _min; | |
| BSONObj _max; | | BSONObj _max; | |
| string _special; | | string _special; | |
| bool _bestGuessOnly; | | bool _bestGuessOnly; | |
| bool _mayYield; | | bool _mayYield; | |
| ElapsedTracker _yieldSometimesTracker; | | ElapsedTracker _yieldSometimesTracker; | |
| shared_ptr<Runner> _runner; | | shared_ptr<Runner> _runner; | |
|
| | | bool _mustAssertOnYieldFailure; | |
| }; | | }; | |
| | | | |
| /** Handles $or type queries by generating a QueryPlanSet for each $or
clause. */ | | /** Handles $or type queries by generating a QueryPlanSet for each $or
clause. */ | |
| class MultiPlanScanner { | | class MultiPlanScanner { | |
| public: | | public: | |
| MultiPlanScanner( const char *ns, | | MultiPlanScanner( const char *ns, | |
| const BSONObj &query, | | const BSONObj &query, | |
| const BSONObj &order, | | const BSONObj &order, | |
| const BSONElement *hint = 0, | | const BSONElement *hint = 0, | |
| bool honorRecordedPlan = true, | | bool honorRecordedPlan = true, | |
| | | | |
End of changes. 5 change blocks. |
| 0 lines changed or deleted | | 6 lines changed or added | |
|
| rs.h | | rs.h | |
| | | | |
| skipping to change at line 61 | | skipping to change at line 61 | |
| extern bool replSet; // true if using repl sets | | extern bool replSet; // true if using repl sets | |
| extern class ReplSet *theReplSet; // null until initialized | | extern class ReplSet *theReplSet; // null until initialized | |
| extern Tee *rsLog; | | extern Tee *rsLog; | |
| | | | |
| /* member of a replica set */ | | /* member of a replica set */ | |
| class Member : public List1<Member>::Base { | | class Member : public List1<Member>::Base { | |
| private: | | private: | |
| ~Member(); // intentionally unimplemented as should never be called
-- see List1<>::Base. | | ~Member(); // intentionally unimplemented as should never be called
-- see List1<>::Base. | |
| Member(const Member&); | | Member(const Member&); | |
| public: | | public: | |
|
| Member(HostAndPort h, unsigned ord, const ReplSetConfig::MemberCfg
*c, bool self); | | Member(HostAndPort h, unsigned ord, ReplSetConfig::MemberCfg *c, bo
ol self); | |
| | | | |
| string fullName() const { return h().toString(); } | | string fullName() const { return h().toString(); } | |
| const ReplSetConfig::MemberCfg& config() const { return _config; } | | const ReplSetConfig::MemberCfg& config() const { return _config; } | |
|
| | | ReplSetConfig::MemberCfg& configw() { return _config; } | |
| const HeartbeatInfo& hbinfo() const { return _hbinfo; } | | const HeartbeatInfo& hbinfo() const { return _hbinfo; } | |
| HeartbeatInfo& get_hbinfo() { return _hbinfo; } | | HeartbeatInfo& get_hbinfo() { return _hbinfo; } | |
| string lhb() const { return _hbinfo.lastHeartbeatMsg; } | | string lhb() const { return _hbinfo.lastHeartbeatMsg; } | |
| MemberState state() const { return _hbinfo.hbstate; } | | MemberState state() const { return _hbinfo.hbstate; } | |
| const HostAndPort& h() const { return _h; } | | const HostAndPort& h() const { return _h; } | |
| unsigned id() const { return _hbinfo.id(); } | | unsigned id() const { return _hbinfo.id(); } | |
| | | | |
| bool potentiallyHot() const { return _config.potentiallyHot(); } //
not arbiter, not priority 0 | | bool potentiallyHot() const { return _config.potentiallyHot(); } //
not arbiter, not priority 0 | |
| void summarizeMember(stringstream& s) const; | | void summarizeMember(stringstream& s) const; | |
| | | | |
| private: | | private: | |
| friend class ReplSetImpl; | | friend class ReplSetImpl; | |
|
| const ReplSetConfig::MemberCfg _config; | | ReplSetConfig::MemberCfg _config; | |
| const HostAndPort _h; | | const HostAndPort _h; | |
| HeartbeatInfo _hbinfo; | | HeartbeatInfo _hbinfo; | |
| }; | | }; | |
| | | | |
| class Manager : public task::Server { | | class Manager : public task::Server { | |
| ReplSetImpl *rs; | | ReplSetImpl *rs; | |
| bool busyWithElectSelf; | | bool busyWithElectSelf; | |
| int _primary; | | int _primary; | |
| | | | |
| /** @param two - if true two primaries were seen. this can happen
transiently, in addition to our | | /** @param two - if true two primaries were seen. this can happen
transiently, in addition to our | |
| | | | |
| skipping to change at line 616 | | skipping to change at line 617 | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * does local authentication | | * does local authentication | |
| * directly authorizes against AuthenticationInfo | | * directly authorizes against AuthenticationInfo | |
| */ | | */ | |
| void replLocalAuth(); | | void replLocalAuth(); | |
| | | | |
| /** inlines ----------------- */ | | /** inlines ----------------- */ | |
| | | | |
|
| inline Member::Member(HostAndPort h, unsigned ord, const ReplSetConfig:
:MemberCfg *c, bool self) : | | inline Member::Member(HostAndPort h, unsigned ord, ReplSetConfig::Membe
rCfg *c, bool self) : | |
| _config(*c), _h(h), _hbinfo(ord) { | | _config(*c), _h(h), _hbinfo(ord) { | |
| assert(c); | | assert(c); | |
| if( self ) | | if( self ) | |
| _hbinfo.health = 1.0; | | _hbinfo.health = 1.0; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| rs_config.h | | rs_config.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| */ | | */ | |
| | | | |
| #pragma once | | #pragma once | |
| | | | |
| #include "../../util/net/hostandport.h" | | #include "../../util/net/hostandport.h" | |
| #include "../../util/concurrency/race.h" | | #include "../../util/concurrency/race.h" | |
| #include "health.h" | | #include "health.h" | |
| | | | |
| namespace mongo { | | namespace mongo { | |
|
| | | class Member; | |
| const string rsConfigNs = "local.system.replset"; | | const string rsConfigNs = "local.system.replset"; | |
| | | | |
| class ReplSetConfig { | | class ReplSetConfig { | |
| enum { EMPTYCONFIG = -2 }; | | enum { EMPTYCONFIG = -2 }; | |
| struct TagSubgroup; | | struct TagSubgroup; | |
| public: | | public: | |
| /** | | /** | |
| * This contacts the given host and tries to get a config from them
. | | * This contacts the given host and tries to get a config from them
. | |
| * | | * | |
| * This sends a test heartbeat to the host and, if all goes well an
d the | | * This sends a test heartbeat to the host and, if all goes well an
d the | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 64 | |
| struct MemberCfg { | | struct MemberCfg { | |
| MemberCfg() : _id(-1), votes(1), priority(1.0), arbiterOnly(fal
se), slaveDelay(0), hidden(false), buildIndexes(true) { } | | MemberCfg() : _id(-1), votes(1), priority(1.0), arbiterOnly(fal
se), slaveDelay(0), hidden(false), buildIndexes(true) { } | |
| int _id; /* ordinal */ | | int _id; /* ordinal */ | |
| unsigned votes; /* how many votes this node gets. default
1. */ | | unsigned votes; /* how many votes this node gets. default
1. */ | |
| HostAndPort h; | | HostAndPort h; | |
| double priority; /* 0 means can never be primary */ | | double priority; /* 0 means can never be primary */ | |
| bool arbiterOnly; | | bool arbiterOnly; | |
| int slaveDelay; /* seconds. int rather than unsigned for
convenient to/front bson conversion. */ | | int slaveDelay; /* seconds. int rather than unsigned for
convenient to/front bson conversion. */ | |
| bool hidden; /* if set, don't advertise to drives in i
sMaster. for non-primaries (priority 0) */ | | bool hidden; /* if set, don't advertise to drives in i
sMaster. for non-primaries (priority 0) */ | |
| bool buildIndexes; /* if false, do not create any non-_id in
dexes */ | | bool buildIndexes; /* if false, do not create any non-_id in
dexes */ | |
|
| set<string> tags; /* tagging for data center, rack, etc. */ | | map<string,string> tags; /* tagging for data center, rack,
etc. */ | |
| private: | | private: | |
| set<TagSubgroup*> _groups; // the subgroups this member belongs
to | | set<TagSubgroup*> _groups; // the subgroups this member belongs
to | |
| public: | | public: | |
| const set<TagSubgroup*>& groups() const { | | const set<TagSubgroup*>& groups() const { | |
| return _groups; | | return _groups; | |
| } | | } | |
|
| set<TagSubgroup*>& groupsw(ReplSetConfig *c) { | | set<TagSubgroup*>& groupsw() { | |
| assert(!c->_constructed); | | | |
| return _groups; | | return _groups; | |
| } | | } | |
| void check() const; /* check validity, assert if not. */ | | void check() const; /* check validity, assert if not. */ | |
| BSONObj asBson() const; | | BSONObj asBson() const; | |
| bool potentiallyHot() const { return !arbiterOnly && priority >
0; } | | bool potentiallyHot() const { return !arbiterOnly && priority >
0; } | |
| void updateGroups(const OpTime& last) { | | void updateGroups(const OpTime& last) { | |
| for (set<TagSubgroup*>::iterator it = _groups.begin(); it !
= _groups.end(); it++) { | | for (set<TagSubgroup*>::iterator it = _groups.begin(); it !
= _groups.end(); it++) { | |
| ((TagSubgroup*)(*it))->updateLast(last); | | ((TagSubgroup*)(*it))->updateLast(last); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 116 | | skipping to change at line 115 | |
| /** validate the settings. does not call check() on each member, yo
u have to do that separately. */ | | /** validate the settings. does not call check() on each member, yo
u have to do that separately. */ | |
| void checkRsConfig() const; | | void checkRsConfig() const; | |
| | | | |
| /** check if modification makes sense */ | | /** check if modification makes sense */ | |
| static bool legalChange(const ReplSetConfig& old, const ReplSetConf
ig& n, string& errmsg); | | static bool legalChange(const ReplSetConfig& old, const ReplSetConf
ig& n, string& errmsg); | |
| | | | |
| //static void receivedNewConfig(BSONObj); | | //static void receivedNewConfig(BSONObj); | |
| void saveConfigLocally(BSONObj comment); // to local db | | void saveConfigLocally(BSONObj comment); // to local db | |
| string saveConfigEverywhere(); // returns textual info on what happ
ened | | string saveConfigEverywhere(); // returns textual info on what happ
ened | |
| | | | |
|
| | | /** | |
| | | * Update members' groups when the config changes but members stay
the same. | |
| | | */ | |
| | | void updateMembers(List1<Member> &dest); | |
| | | | |
| BSONObj asBson() const; | | BSONObj asBson() const; | |
| | | | |
| bool _constructed; | | bool _constructed; | |
| private: | | private: | |
| bool _ok; | | bool _ok; | |
| void from(BSONObj); | | void from(BSONObj); | |
| void clear(); | | void clear(); | |
| | | | |
| struct TagClause; | | struct TagClause; | |
| | | | |
| /** | | /** | |
| * This is a logical grouping of servers. It is pointed to by a se
t of | | * This is a logical grouping of servers. It is pointed to by a se
t of | |
| * servers with a certain tag. | | * servers with a certain tag. | |
| * | | * | |
|
| * For example, suppose servers A, B, and C have the tag "dc.nyc".
If we | | * For example, suppose servers A, B, and C have the tag "dc" : "ny
c". If we | |
| * have a rule {"dc" : 2}, then we want A _or_ B _or_ C to have the | | * have a rule {"dc" : 2}, then we want A _or_ B _or_ C to have the | |
| * write for one of the "dc" critiria to be fulfilled, so all three
will | | * write for one of the "dc" critiria to be fulfilled, so all three
will | |
| * point to this subgroup. When one of their oplog-tailing cursors
is | | * point to this subgroup. When one of their oplog-tailing cursors
is | |
| * updated, this subgroup is updated. | | * updated, this subgroup is updated. | |
| */ | | */ | |
| struct TagSubgroup : boost::noncopyable { | | struct TagSubgroup : boost::noncopyable { | |
| ~TagSubgroup(); // never called; not defined | | ~TagSubgroup(); // never called; not defined | |
| TagSubgroup(string nm) : name(nm) { } | | TagSubgroup(string nm) : name(nm) { } | |
| const string name; | | const string name; | |
| OpTime last; | | OpTime last; | |
| | | | |
| skipping to change at line 166 | | skipping to change at line 170 | |
| bool operator() (TagSubgroup& lhs, TagSubgroup& rhs) const { | | bool operator() (TagSubgroup& lhs, TagSubgroup& rhs) const { | |
| return lhs.name < rhs.name; | | return lhs.name < rhs.name; | |
| } | | } | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An argument in a rule. For example, if we had the rule {dc : 2, | | * An argument in a rule. For example, if we had the rule {dc : 2, | |
| * machines : 3}, "dc" : 2 and "machines" : 3 would be two TagClaus
es. | | * machines : 3}, "dc" : 2 and "machines" : 3 would be two TagClaus
es. | |
| * | | * | |
| * Each tag clause has a set of associated subgroups. For example,
if | | * Each tag clause has a set of associated subgroups. For example,
if | |
|
| * we had "dc" : 2, our subgroups might be "dc.nyc", "dc.sf", and | | * we had "dc" : 2, our subgroups might be "nyc", "sf", and "hk". | |
| * "dc.hk". | | | |
| */ | | */ | |
| struct TagClause { | | struct TagClause { | |
| OpTime last; | | OpTime last; | |
| map<string,TagSubgroup*> subgroups; | | map<string,TagSubgroup*> subgroups; | |
| TagRule *rule; | | TagRule *rule; | |
| string name; | | string name; | |
| /** | | /** | |
| * If we have get a clause like {machines : 3} and this server
is | | * If we have get a clause like {machines : 3} and this server
is | |
| * tagged with "machines", then it's really {machines : 2}, as
we | | * tagged with "machines", then it's really {machines : 2}, as
we | |
| * will always be up-to-date. So, target would be 3 and | | * will always be up-to-date. So, target would be 3 and | |
| | | | |
| skipping to change at line 197 | | skipping to change at line 200 | |
| /** | | /** | |
| * Parses getLastErrorModes. | | * Parses getLastErrorModes. | |
| */ | | */ | |
| void parseRules(const BSONObj& modes); | | void parseRules(const BSONObj& modes); | |
| | | | |
| /** | | /** | |
| * Create a hash containing every possible clause that could be us
ed in a | | * Create a hash containing every possible clause that could be us
ed in a | |
| * rule and the servers related to that clause. | | * rule and the servers related to that clause. | |
| * | | * | |
| * For example, suppose we have the following servers: | | * For example, suppose we have the following servers: | |
|
| * A ["dc.ny.rk1"] | | * A {"dc" : "ny", "ny" : "rk1"} | |
| * B ["dc.ny.rk1"] | | * B {"dc" : "ny", "ny" : "rk1"} | |
| * C ["dc.ny.rk2"] | | * C {"dc" : "ny", "ny" : "rk2"} | |
| * D ["dc.sf.rk1"] | | * D {"dc" : "sf", "sf" : "rk1"} | |
| * E ["dc.sf.rk2"] | | * E {"dc" : "sf", "sf" : "rk2"} | |
| * | | * | |
| * This would give us the possible criteria: | | * This would give us the possible criteria: | |
|
| * "dc.ny.rk1" -> {A},{B} | | * "dc" -> {A, B, C},{D, E} | |
| * "dc.ny.rk2" -> {C} | | * "ny" -> {A, B},{C} | |
| * "dc.ny" -> {A,B},{C} | | * "sf" -> {D},{E} | |
| * "dc.sf.rk1" -> {D} | | | |
| * "dc.sf.rk2" -> {E} | | | |
| * "dc.sf" -> {D},{E} | | | |
| * "dc" -> {A,B,C},{D,E} | | | |
| */ | | */ | |
| void _populateTagMap(map<string,TagClause> &tagMap); | | void _populateTagMap(map<string,TagClause> &tagMap); | |
| | | | |
| public: | | public: | |
| struct TagRule { | | struct TagRule { | |
| vector<TagClause*> clauses; | | vector<TagClause*> clauses; | |
| OpTime last; | | OpTime last; | |
| | | | |
| void updateLast(const OpTime& op); | | void updateLast(const OpTime& op); | |
| string toString() const; | | string toString() const; | |
| | | | |
End of changes. 8 change blocks. |
| 19 lines changed or deleted | | 18 lines changed or added | |
|