MongoDB  2.6.0
Classes | Typedefs | Enumerations | Functions | Variables
mongo Namespace Reference

tools for working in parallel/sharded/clustered environment More...

Classes

class  PoolForHost
 not thread safe thread safety is handled by DBConnectionPool More...
 
class  DBConnectionHook
 
class  DBConnectionPool
 Database connection pool. More...
 
class  AScopedConnection
 
class  ScopedDbConnection
 Use to get a connection from the pool. More...
 
class  DBClientReplicaSet
 Use this class to connect to a replica set of servers. More...
 
class  TagSet
 A simple object for representing the list of tags requested by a $readPreference. More...
 
struct  ReadPreferenceSetting
 
class  DBClientCursorInterface
 for mock purposes only – do not create variants of DBClientCursor, nor hang code here More...
 
class  DBClientCursor
 Queries return a cursor object. More...
 
class  DBClientCursorBatchIterator
 iterate over objects in current batch only - will not cause a network call More...
 
class  ConnectionString
 ConnectionString handles parsing different ways to connect to mongo and determining method samples: server server:port foo/server:port,server:port SET server,server,server SYNC Warning - you usually don't want "SYNC", it's used for some special things such as sharding config servers. More...
 
class  Query
 Represents a Mongo query expression. More...
 
class  QuerySpec
 Represents a full query description, including all options required for the query to be passed on to other hosts. More...
 
class  DBConnector
 interface that handles communication with the db More...
 
class  DBClientInterface
 The interface that any db connection should implement. More...
 
class  DBClientWithCommands
 DB "commands" Basically just invocations of connection. More...
 
class  DBClientBase
 abstract class that implements the core db operations More...
 
class  ConnectException
 
class  DBClientConnection
 A basic connection to the database. More...
 
class  DBClientMockCursor
 
class  GridFSChunk
 
class  GridFS
 GridFS is for storing large file-style objects in MongoDB. More...
 
class  GridFile
 wrapper for a file stored in the Mongo database More...
 
class  ServerAndQuery
 holder for a server address and a query to run More...
 
class  CommandInfo
 
class  ParallelConnectionState
 
class  ParallelConnectionMetadata
 
class  ParallelSortClusteredCursor
 Runs a query in parallel across N servers, enforcing compatible chunk versions for queries across all shards. More...
 
class  FilteringClientCursor
 
class  Future
 Generally clients should be using Strategy::commandOp() wherever possible - the Future API does not handle versioning. More...
 
class  ReplicaSetMonitor
 Holds state about a replica set and provides a means to refresh the local view. More...
 
class  SaslClientSession
 Implementation of the client side of a SASL authentication conversation. More...
 
class  SyncClusterConnection
 This is a connection to a cluster of servers that operate as one for super high durability. More...
 
class  UpdateNotTheSame
 
class  JParse
 Parser class. More...
 
struct  BSONElementFieldNameCmp
 
class  BSONBuilderBase
 
class  BSONFieldValue
 A BSONField holds the name and the type intended for a given BSON element. More...
 
class  BSONField
 
class  BSONElement
 BSONElement represents an "element" in a BSONObj. More...
 
struct  BSONElementCmpWithoutField
 
class  BSONObjCmp
 
struct  GENOIDLabeler
 
struct  DateNowLabeler
 
struct  NullLabeler
 
struct  UndefinedLabeler
 
struct  MinKeyLabeler
 
struct  MaxKeyLabeler
 
class  Labeler
 
struct  BSONSymbol
 
struct  BSONCode
 
struct  BSONCodeWScope
 
struct  BSONRegEx
 
struct  BSONBinData
 
struct  BSONDBRef
 
class  BSONObjBuilderValueStream
 
class  BSONSizeTracker
 used in conjuction with BSONObjBuilder, allows for proper buffer size to prevent crazy memory usage More...
 
class  BSONObj
 C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representation. More...
 
struct  BSONArray
 
class  BSONObjBuilder
 Utility for creating a BSONObj. More...
 
class  BSONArrayBuilder
 
class  BSONObjIterator
 iterator for a BSONObj More...
 
class  BSONIteratorSorted
 Base class implementing ordered iteration through BSONElements. More...
 
class  BSONObjIteratorSorted
 Provides iteration of a BSONObj's BSONElements in lexical field order. More...
 
class  BSONArrayIteratorSorted
 Provides iteration of a BSONArray's BSONElements in numeric field order. More...
 
class  OID
 Object ID type. More...
 
struct  ClockSkewException
 
class  OpTime
 
class  Ordering
 A precomputation of a BSON index or sort key pattern. More...
 
struct  PackedDouble
 
class  StringBuilderImpl
 stringstream deals with locale so this is a lot faster than std::stringstream for UTF8 More...
 
class  TrivialAllocator
 
class  StackAllocator
 
class  _BufBuilder
 
class  StackBufBuilder
 The StackBufBuilder builds smaller datasets on the stack instead of using malloc. More...
 
class  AdminAccess
 
class  NoAdminAccess
 
class  AlignedBuilder
 a page-aligned BufBuilder. More...
 
class  FastArray
 
class  AssertionCount
 
struct  ExceptionInfo
 
class  ErrorMsg
 helper class that builds error strings. More...
 
class  DBException
 Most mongo exceptions inherit from this; this is commonly caught in most threads. More...
 
class  AssertionException
 
class  UserException
 
class  MsgAssertionException
 
class  BackgroundJob
 Background thread dispatching. More...
 
class  PeriodicTask
 these run "roughly" every minute instantiate statically class MyTask : public PeriodicTask { public: virtual std::string name() const { return "MyTask; " } virtual void doWork() { log() << "hi" << endl; } } myTask; More...
 
class  BufReader
 helper to read and parse a block of memory methods throw the eof exception if the operation would pass the end of the buffer with which we are working. More...
 
struct  Checksum
 a simple, rather dumb, but very fast checksum. More...
 
class  List1
 
struct  mapsf
 Thread safe map. More...
 
class  StaticObserver
 
class  mutex
 On pthread systems, it is an error to destroy a mutex while held (boost mutex may use pthread). More...
 
class  SimpleMutex
 The concept with SimpleMutex is that it is a basic lock/unlock with no special functionality (such as try and try timeout). More...
 
class  RecursiveMutex
 This can be used instead of boost recursive mutex. More...
 
class  MutexDebugger
 only used on _DEBUG builds. More...
 
class  MVar
 
class  QLock
 "Quad Lock" we want to be able to do semi-granular locking now, and read/write style locking for that. More...
 
class  RWLock
 
class  rwlock_try_write
 throws on failure to acquire in the specified time period. More...
 
class  rwlock_shared
 
class  rwlock
 
class  RWLockRecursive
 recursive on shared locks is ok for this implementation More...
 
class  RWLockRecursiveNongreedy
 
class  RWLockBase
 
class  SimpleRWLock
 separated out as later the implementation of this may be different than RWLock, depending on OS, as there is no upgrade etc. More...
 
class  SpinLock
 The spinlock currently requires late GCC support routines to be efficient. More...
 
class  scoped_spinlock
 
class  Notification
 
class  NotifyAll
 establishes a synchronization point between threads. More...
 
class  ThreadLocalValue
 
struct  TSP
 
class  TicketHolder
 
class  ScopedTicket
 
class  TicketHolderReleaser
 
class  Guarded
 declare that a variable that is "guarded" by a mutex. More...
 
class  DiagStr
 there is now one mutex per DiagStr. More...
 
class  BasicEstimators
 Collects count, minimum and maximum, calculates mean and standard deviation. More...
 
class  DistributionEstimators
 Computes 'NumQuantiles' quantiles. More...
 
class  SummaryEstimators
 Provides the funcionality of both BasicEstimators and DistributionEstimators. More...
 
class  ElapsedTracker
 Keep track of elapsed time. More...
 
class  EmbeddedBuilder
 
class  FailPoint
 A simple thread-safe fail point implementation that can be activated and deactivated, as well as embed temporary data into it. More...
 
class  ScopedFailPoint
 Helper class for making sure that FailPoint::shouldFailCloseBlock is called when FailPoint::shouldFailOpenBlock was called. More...
 
class  FailPointRegistry
 Class for storing FailPoint instances. More...
 
class  File
 
class  FileAllocator
 
class  ThreadSafeString
 this is a thread safe string you will never get a bad pointer, though data may be mungedd More...
 
struct  ptr
 A generic pointer type for function arguments. More...
 
class  Histogram
 A histogram for a 32-bit integer range. More...
 
class  IntrusiveCounter
 
class  IntrusiveCounterUnsigned
 
class  RefCountable
 This is an alternative base class to the above ones (will replace them eventually) More...
 
class  RCString
 This is an immutable reference-counted string. More...
 
struct  LogIndentLevel
 
class  LogFile
 
class  LRUishMap
 
class  MAdvise
 
class  LockMongoFilesShared
 
class  LockMongoFilesExclusive
 
class  MongoFile
 
class  MongoFileFinder
 look up a MMF by filename. More...
 
class  MemoryMappedFile
 
struct  MoveableBuffer
 this is a sort of smart pointer class where we can move where something is and all the pointers will adjust. More...
 
struct  HostAndPort
 helper for manipulating host:port connection endpoints. More...
 
class  HttpClient
 
class  Listener
 
class  ListeningSockets
 
struct  MSGHEADER
 
struct  MsgData
 
class  Message
 
class  AbstractMessagingPort
 
class  MessagingPort
 
class  MessageHandler
 
class  MessageServer
 
class  MiniWebServer
 
struct  SockAddr
 wrapped around os representation of network address More...
 
class  SocketException
 thrown by Socket and SockAddr More...
 
class  Socket
 thin wrapped around file descriptor and system calls todo: ssl More...
 
struct  SSLGlobalParams
 
struct  RelativePath
 this is very much like a boost::path. More...
 
class  ProcessInfo
 
class  ProgressMeter
 
class  ProgressMeterHolder
 
class  BlockingQueue
 Simple blocking queue with optional max size (by count or custom sizing function). More...
 
class  SafeNum
 SafeNum holds and does arithmetic on a number in a safe way, handling overflow and casting for the user. More...
 
class  RefToValue
 Transports a reference as a value Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard. More...
 
class  ScopeGuardImplBase
 ScopeGuard. More...
 
class  ScopeGuardImpl0
 
class  ScopeGuardImpl1
 
class  ScopeGuardImpl2
 
class  ScopeGuardImpl3
 
class  ObjScopeGuardImpl0
 
class  ObjScopeGuardImpl1
 
class  ObjScopeGuardImpl2
 
class  StartupTest
 
struct  StringMapDefaultEqual
 
struct  StringMapDefaultConvertor
 
struct  StringMapDefaultConvertorOther
 
class  StringMap
 
class  LexNumCmp
 Functor for combining lexical and numeric comparisons. More...
 
class  StringSplitter
 
struct  Date_t
 
class  Backoff
 
class  Timer
 Time tracking object. More...
 
class  Trace
 
struct  UnorderedFastKeyTable_LS_C
 
class  UnorderedFastKeyTable
 

Typedefs

typedef shared_ptr
< ReplicaSetMonitor
ReplicaSetMonitorPtr
 
typedef unsigned long long gridfs_offset
 
typedef shared_ptr
< ShardConnection > 
ShardConnectionPtr
 
typedef shared_ptr
< DBClientCursor
DBClientCursorPtr
 
typedef ParallelConnectionState PCState
 
typedef shared_ptr< PCStatePCStatePtr
 
typedef ParallelConnectionMetadata PCMData
 
typedef shared_ptr< PCMDataPCMDataPtr
 
typedef std::map< std::string,
BSONElement
BSONMap
 
typedef std::set< BSONElement,
BSONElementFieldNameCmp
BSONSortedElements
 
typedef std::set< BSONObj,
BSONObjCmp
BSONObjSet
 
typedef std::set< BSONElement,
BSONElementCmpWithoutField
BSONElementSet
 
typedef std::multiset
< BSONElement,
BSONElementCmpWithoutField
BSONElementMSet
 
typedef unsigned long long ReplTime
 
typedef _BufBuilder
< TrivialAllocator
BufBuilder
 
typedef StringBuilderImpl
< TrivialAllocator
StringBuilder
 
typedef StringBuilderImpl
< StackAllocator
StackStringBuilder
 
typedef mongo::mutex::scoped_lock scoped_lock
 
typedef uint64_t fileofs
 
typedef int HANDLE
 
typedef unsigned char md5digest [16]
 
typedef AtomicUInt MSGID
 
typedef int SOCKET
 
typedef long long NumberVal
 Get a sysctl string value by name. More...
 
typedef const ScopeGuardImplBaseScopeGuard
 See Andrei's and Petru Marginean's CUJ article http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm. More...
 
typedef StringData::Hasher StringMapDefaultHash
 

Enumerations

enum  ResultFlagType { ResultFlag_CursorNotFound = 1, ResultFlag_ErrSet = 2, ResultFlag_ShardConfigStale = 4, ResultFlag_AwaitCapable = 8 }
 
enum  FieldCompareResult {
  LEFT_SUBFIELD = -2, LEFT_BEFORE = -1, SAME = 0, RIGHT_BEFORE = 1,
  RIGHT_SUBFIELD = 2
}
 
enum  BSONType {
  MinKey =-1, EOO =0, NumberDouble =1, String =2,
  Object =3, Array =4, BinData =5, Undefined =6,
  jstOID =7, Bool =8, Date =9, jstNULL =10,
  RegEx =11, DBRef =12, Code =13, Symbol =14,
  CodeWScope =15, NumberInt = 16, Timestamp = 17, NumberLong = 18,
  JSTypeMax =18, MaxKey =127
}
 the complete list of valid BSON types see also bsonspec.org More...
 
enum  BinDataType {
  BinDataGeneral =0, Function =1, ByteArrayDeprecated =2, bdtUUID = 3,
  newUUID =4, MD5Type =5, bdtCustom =128
}
 
enum  JsonStringFormat { Strict, TenGen, JS }
 Formatting mode for generating JSON from BSON. More...
 
enum  CommonErrorCodes {
  OkCode = 0, DatabaseDifferCaseCode = 13297, SendStaleConfigCode = 13388, RecvStaleConfigCode = 9996,
  PrepareConfigsFailedCode = 13104, NotMasterOrSecondaryCode = 13436, NotMasterNoSlaveOkCode = 13435, NotMaster = 10107,
  IndexOptionsDiffer = 17427
}
 
enum  { ASSERT_ID_DUPKEY = 11000 }
 
enum  { DEBUG_BUILD = 0 }
 
enum  ExitCode {
  EXIT_CLEAN = 0, EXIT_BADOPTIONS = 2, EXIT_REPLICATION_ERROR = 3, EXIT_NEED_UPGRADE = 4,
  EXIT_SHARDING_ERROR = 5, EXIT_KILL = 12, EXIT_ABRUPT = 14, EXIT_NTSERVICE_ERROR = 20,
  EXIT_JAVA = 21, EXIT_OOM_MALLOC = 42, EXIT_OOM_REALLOC = 43, EXIT_FS = 45,
  EXIT_CLOCK_SKEW = 47, EXIT_NET_ERROR = 48, EXIT_WINDOWS_SERVICE_STOP = 49, EXIT_POSSIBLE_CORRUPTION = 60,
  EXIT_UNCAUGHT = 100, EXIT_TEST = 101
}
 
enum  Operations {
  opReply = 1, dbMsg = 1000, dbUpdate = 2001, dbInsert = 2002,
  dbQuery = 2004, dbGetMore = 2005, dbDelete = 2006, dbKillCursors = 2007
}
 

Functions

void dbexit (ExitCode returnCode, const char *whyMsg)
 
bool inShutdown ()
 
string getDbContext ()
 
bool haveLocalShardingInfo (const string &ns)
 
DBClientBasecreateDirectClient ()
 
void assembleRequest (const string &ns, BSONObj query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, Message &toSend)
 
BSONElement getErrField (const BSONObj &o)
 
bool hasErrField (const BSONObj &o)
 
bool serverAlive (const string &uri)
 pings server to check if it's up
 
string nsGetDB (const string &ns)
 
string nsGetCollection (const string &ns)
 
string readPrefToString (ReadPreference pref)
 
MONGO_CLIENT_API std::ostream & operator<< (std::ostream &s, const Query &q)
 
LabeledLevel pc ("pcursor", 2)
 
Status saslExtractPayload (const BSONObj &cmdObj, std::string *payload, BSONType *type)
 Extracts the payload field from "cmdObj", and store it into "*payload". More...
 
MONGO_CLIENT_API BSONObj fromjson (const std::string &str)
 Create a BSONObj from a JSON http://www.json.org, http://www.ietf.org/rfc/rfc4627.txt string. More...
 
MONGO_CLIENT_API BSONObj fromjson (const char *str, int *len=NULL)
 
int compareElementValues (const BSONElement &l, const BSONElement &r)
 
void nested2dotted (BSONObjBuilder &b, const BSONObj &obj, const std::string &base="")
 
BSONObj nested2dotted (const BSONObj &obj)
 
void dotted2nested (BSONObjBuilder &b, const BSONObj &obj)
 
BSONObj dotted2nested (const BSONObj &obj)
 
BSONMap bson2map (const BSONObj &obj)
 
BSONSortedElements bson2set (const BSONObj &obj)
 
std::ostream & operator<< (std::ostream &s, const BSONObj &o)
 
std::ostream & operator<< (std::ostream &s, const BSONElement &e)
 
StringBuilderoperator<< (StringBuilder &s, const BSONObj &o)
 
StringBuilderoperator<< (StringBuilder &s, const BSONElement &e)
 
std::string escape (const std::string &s, bool escape_slash=false)
 
template<>
bool BSONElement::coerce< std::string > (std::string *out) const
 
template<>
bool BSONElement::coerce< std::vector< std::string > > (std::vector< std::string > *out) const
 
Status validateBSON (const char *buf, uint64_t maxLength)
 
int getGtLtOp (const BSONElement &e)
 
FieldCompareResult compareDottedFieldNames (const std::string &l, const std::string &r, const LexNumCmp &cmp)
 
BSONObj OR (const BSONObj &a, const BSONObj &b)
 
BSONObj OR (const BSONObj &a, const BSONObj &b, const BSONObj &c)
 
BSONObj OR (const BSONObj &a, const BSONObj &b, const BSONObj &c, const BSONObj &d)
 
BSONObj OR (const BSONObj &a, const BSONObj &b, const BSONObj &c, const BSONObj &d, const BSONObj &e)
 
BSONObj OR (const BSONObj &a, const BSONObj &b, const BSONObj &c, const BSONObj &d, const BSONObj &e, const BSONObj &f)
 
bool fieldsMatch (const BSONObj &lhs, const BSONObj &rhs)
 
template<class L >
BSONObjBuilder_appendIt (BSONObjBuilder &_this, const StringData &fieldName, const L &vals)
 
template<class L >
BSONArrayBuilder_appendArrayIt (BSONArrayBuilder &_this, const L &vals)
 
const char * typeName (BSONType type)
 returns the name of the argument's type defined in jsobj.cpp
 
int canonicalizeBSONType (BSONType type)
 Returns a number for where a given type falls in the sort order. More...
 
void prefetch (void *p)
 
ostream & operator<< (ostream &s, const OID &o)
 
std::ostream & operator<< (std::ostream &s, const OID &o)
 
StringBuilderoperator<< (StringBuilder &s, const OID &o)
 
struct MONGO_COMPILER_ALIGN_TYPE (4) AtomicUInt
 An unsigned integer supporting atomic read-modify-write operations. More...
 
Status bsonExtractField (const BSONObj &object, const StringData &fieldName, BSONElement *outElement)
 Finds an element named "fieldName" in "object". More...
 
Status bsonExtractTypedField (const BSONObj &object, const StringData &fieldName, BSONType type, BSONElement *outElement)
 Finds an element named "fieldName" in "object". More...
 
Status bsonExtractBooleanField (const BSONObj &object, const StringData &fieldName, bool *out)
 Finds a bool-like element named "fieldName" in "object". More...
 
Status bsonExtractBooleanFieldWithDefault (const BSONObj &object, const StringData &fieldName, bool defaultValue, bool *out)
 Finds a bool-like element named "fieldName" in "object". More...
 
Status bsonExtractStringField (const BSONObj &object, const StringData &fieldName, std::string *out)
 Finds a string-typed element named "fieldName" in "object" and stores its value in "out". More...
 
Status bsonExtractStringFieldWithDefault (const BSONObj &object, const StringData &fieldName, const StringData &defaultValue, std::string *out)
 Finds a string element named "fieldName" in "object". More...
 
Status bsonExtractIntegerField (const BSONObj &object, const StringData &fieldName, long long *out)
 Finds an element named "fieldName" in "object" that represents an integral value. More...
 
Status bsonExtractIntegerFieldWithDefault (const BSONObj &object, const StringData &fieldName, long long defaultValue, long long *out)
 Finds an element named "fieldName" in "object" that represents an integral value. More...
 
 TEST (Builder, String1)
 
int strnlen (const char *s, int n)
 
 BOOST_STATIC_ASSERT (sizeof(void *)==sizeof(size_t))
 
void * ourmalloc (size_t size)
 
void * ourrealloc (void *ptr, size_t size)
 
NOINLINE_DECL void wasserted (const char *msg, const char *file, unsigned line)
 
NOINLINE_DECL void verifyFailed (const char *msg, const char *file, unsigned line)
 
NOINLINE_DECL void invariantFailed (const char *msg, const char *file, unsigned line)
 
NOINLINE_DECL void fassertFailed (int msgid)
 
NOINLINE_DECL void fassertFailedNoTrace (int msgid)
 
MONGO_COMPILER_NORETURN void fassertFailedWithStatus (int msgid, const Status &status)
 
void uasserted (int msgid, const string &msg)
 
NOINLINE_DECL void uasserted (int msgid, const char *msg)
 a "user assertion". More...
 
void msgasserted (int msgid, const string &msg)
 
NOINLINE_DECL void msgasserted (int msgid, const char *msg)
 
NOINLINE_DECL void msgassertedNoTrace (int msgid, const char *msg)
 msgassert and massert are for errors that are internal but have a well defined error text std::string. More...
 
void msgassertedNoTrace (int msgid, const std::string &msg)
 
std::string causedBy (const char *e)
 
std::string causedBy (const DBException &e)
 
std::string causedBy (const std::exception &e)
 
std::string causedBy (const std::string &e)
 
std::string causedBy (const std::string *e)
 
std::string causedBy (const Status &e)
 
NOINLINE_DECL void streamNotGood (int code, const std::string &msg, std::ios &myios)
 
string errnoWithPrefix (const char *prefix)
 output the error # and error message with prefix. More...
 
string demangleName (const type_info &typeinfo)
 
MONGO_CLIENT_API
MONGO_COMPILER_NORETURN void 
uasserted (int msgid, const std::string &msg)
 
MONGO_CLIENT_API
MONGO_COMPILER_NORETURN void 
msgasserted (int msgid, const std::string &msg)
 
MONGO_CLIENT_API void fassert (int msgid, bool testOK)
 aborts on condition failure
 
MONGO_CLIENT_API void fassert (int msgid, const Status &status)
 
MONGO_CLIENT_API void uassertStatusOK (const Status &status)
 
void assertStreamGood (unsigned msgid, const std::string &msg, std::ios &myios)
 
std::string demangleName (const std::type_info &typeinfo)
 
template<typename T >
void bsonArrToNumVector (BSONElement el, vector< T > &results)
 
void rawCompress (const char *input, size_t input_length, char *compressed, size_t *compressed_length)
 
size_t maxCompressedLength (size_t source_len)
 
size_t compress (const char *input, size_t input_length, std::string *output)
 
bool uncompress (const char *compressed, size_t compressed_length, std::string *uncompressed)
 
boost::xtime incxtimemillis (long long s)
 
void setThreadName (StringData name)
 Sets the name of the current thread to "name".
 
const std::string & getThreadName ()
 Retrieves the name of the current thread, as previously set, or "" if no name was previously set.
 
void mongo_breakpoint ()
 
void setupSIGTRAPforGDB ()
 
void breakpoint ()
 
void setWindowsUnhandledExceptionFilter ()
 
 MONGO_FP_DECLARE (dummy)
 
scoped_ptr< FailPointRegistry_fpRegistry (NULL)
 
MONGO_INITIALIZER() FailPointRegistry (InitializerContext *context)
 
 MONGO_INITIALIZER_GENERAL (AllFailPointsRegistered, MONGO_NO_PREREQUISITES, MONGO_NO_DEPENDENTS)(InitializerContext *context)
 
FailPointRegistrygetGlobalFailPointRegistry ()
 
boost::filesystem::path ensureParentDirCreated (const boost::filesystem::path &p)
 Aliases for Win32 CRT functions.
 
string hexdump (const char *data, unsigned len)
 
template<class T >
string ToString (const T &t)
 
bool isPrime (int n)
 
int nextPrime (int n)
 
void dumpmemory (const char *data, int len)
 
bool startsWith (const char *str, const char *prefix)
 
bool startsWith (const std::string &s, const std::string &p)
 
bool endsWith (const char *p, const char *suffix)
 
unsigned long swapEndian (unsigned long x)
 
void strcpy_s (char *dst, unsigned len, const char *src)
 
std::ostream & operator<< (std::ostream &s, const ThreadSafeString &o)
 
template<typename T >
std::string integerToHexDef (T inInt)
 
template<>
std::string integerToHex< int > (int val)
 
template<>
std::string integerToHex< unsigned int > (unsigned int val)
 
template<>
std::string integerToHex< long > (long val)
 
template<>
std::string integerToHex< long long > (long long val)
 
int fromHex (char c)
 
char fromHex (const char *c)
 
char fromHex (const StringData &c)
 
std::string toHex (const void *inRaw, int len)
 
template<typename T >
std::string integerToHex (T val)
 
std::string toHexLower (const void *inRaw, int len)
 
const char * default_getcurns ()
 
bool rotateLogs ()
 Rotates the log files. More...
 
string errnoWithDescription (int x)
 
void logContext (const char *msg=NULL)
 Write the current context (backtrace), along with the optional "msg".
 
LogstreamBuilder severe ()
 Returns a LogstreamBuilder for logging a message with LogSeverity::Severe().
 
LogstreamBuilder error ()
 Returns a LogstreamBuilder for logging a message with LogSeverity::Error().
 
LogstreamBuilder warning ()
 Returns a LogstreamBuilder for logging a message with LogSeverity::Warning().
 
LogstreamBuilder log ()
 Returns a LogstreamBuilder for logging a message with LogSeverity::Log().
 
LogstreamBuilder out ()
 Synonym for log().
 
LogstreamBuilder problem ()
 
template<typename M , typename K , typename V >
mapFindWithDefault (const M &myMap, const K &key, const V &defaultValue)
 
void md5 (const void *buf, int nbytes, md5digest digest)
 
void md5 (const char *str, md5digest digest)
 
std::string digestToString (md5digest digest)
 
std::string md5simpledigest (const void *buf, int nbytes)
 
std::string md5simpledigest (const std::string &s)
 
 TEST (MD5, BuiltIn1)
 
void minOSPageSizeBytesTest (size_t minOSPageSizeBytes)
 
void nullFunc ()
 
void printMemInfo (const char *where)
 
void dataSyncFailedHandler ()
 
 __declspec (noinline) void makeChunkWritable(size_t chunkno)
 
vector< SockAddripToAddrs (const char *ips, int port, bool useUnixSockets)
 
int getMaxConnections ()
 
MSGID nextMessageId ()
 
bool doesOpGetAResponse (int op)
 
const char * opToString (int op)
 
bool opIsWrite (int op)
 
MessageServercreateServer (const MessageServer::Options &opts, MessageHandler *handler)
 
 MONGO_FP_DECLARE (throwSockExcep)
 
void enableIPv6 (bool state)
 
bool IPv6Enabled ()
 
void setSockTimeouts (int sock, double secs)
 
void disableNagle (int sock)
 
string getAddrInfoStrError (int code)
 
string makeUnixSockPath (int port)
 
string hostbyname (const char *hostname)
 
string getHostName ()
 this is not cache and does a syscall
 
string getHostNameCached ()
 we store our host name once More...
 
string prettyHostName ()
 
void closesocket (int s)
 
bool isPollSupported ()
 
int socketPoll (pollfd *fdarray, unsigned long nfds, int timeout)
 
const std::string getSSLVersion (const std::string &prefix, const std::string &suffix)
 
Status addSSLServerOptions (moe::OptionSection *options)
 
Status addSSLClientOptions (moe::OptionSection *options)
 
Status canonicalizeSSLServerOptions (moe::Environment *params)
 Canonicalize SSL options for the given environment that have different representations with the same logical meaning.
 
Status storeSSLServerOptions (const moe::Environment &params)
 
Status storeSSLClientOptions (const moe::Environment &params)
 
void exitCleanly (ExitCode ignored)
 
string askPassword ()
 
std::string createPasswordDigest (const StringData &username, const StringData &clearTextPassword)
 Hashes the password so that it can be stored in a user object or used for MONGODB-CR authentication.
 
void flushMyDirectory (const boost::filesystem::path &file)
 
dev_t getPartition (const string &path)
 
bool onSamePartition (const string &path1, const string &path2)
 
bool writePidFile (const string &path)
 
MONGO_INITIALIZER() SystemInfo (InitializerContext *context)
 
bool writePidFile (const std::string &path)
 
template<typename Variant >
Variant getSysctlByName (const char *sysctlName)
 
template<>
long long getSysctlByName< NumberVal > (const char *sysctlName)
 Get a sysctl integer value by name (specialization)
 
template<typename T >
int getSysctlByNameWithDefault (const char *sysctlName, const T &defaultValue, T *result)
 Get a sysctl string value by name. More...
 
template<>
int getSysctlByNameWithDefault< uintptr_t > (const char *sysctlName, const uintptr_t &defaultValue, uintptr_t *result)
 
template<>
int getSysctlByNameWithDefault< string > (const char *sysctlName, const string &defaultValue, string *result)
 
int _wconvertmtos (SIZE_T s)
 
template<typename T >
size_t _getSizeDefault (const T &t)
 
std::ostream & operator<< (std::ostream &os, const SafeNum &snum)
 
template<class T >
RefToValue< T > ByRef (T &t)
 RefToValue creator.
 
template<typename F >
ScopeGuardImpl0< F > MakeGuard (F fun)
 
template<typename F , typename P1 >
ScopeGuardImpl1< F, P1 > MakeGuard (F fun, P1 p1)
 
template<typename F , typename P1 , typename P2 >
ScopeGuardImpl2< F, P1, P2 > MakeGuard (F fun, P1 p1, P2 p2)
 
template<typename F , typename P1 , typename P2 , typename P3 >
ScopeGuardImpl3< F, P1, P2, P3 > MakeGuard (F fun, P1 p1, P2 p2, P3 p3)
 
template<class Obj , typename MemFun >
ObjScopeGuardImpl0< Obj, MemFun > MakeObjGuard (Obj &obj, MemFun memFun)
 
template<typename Ret , class Obj1 , class Obj2 >
ObjScopeGuardImpl0< Obj1, Ret(Obj2::*)()> MakeGuard (Ret(Obj2::*memFun)(), Obj1 &obj)
 
template<typename Ret , class Obj1 , class Obj2 >
ObjScopeGuardImpl0< Obj1, Ret(Obj2::*)()> MakeGuard (Ret(Obj2::*memFun)(), Obj1 *obj)
 
template<class Obj , typename MemFun , typename P1 >
ObjScopeGuardImpl1< Obj,
MemFun, P1 > 
MakeObjGuard (Obj &obj, MemFun memFun, P1 p1)
 
template<typename Ret , class Obj1 , class Obj2 , typename P1a , typename P1b >
ObjScopeGuardImpl1< Obj1, Ret(Obj2::*)(P1a),
P1b > 
MakeGuard (Ret(Obj2::*memFun)(P1a), Obj1 &obj, P1b p1)
 
template<typename Ret , class Obj1 , class Obj2 , typename P1a , typename P1b >
ObjScopeGuardImpl1< Obj1, Ret(Obj2::*)(P1a),
P1b > 
MakeGuard (Ret(Obj2::*memFun)(P1a), Obj1 *obj, P1b p1)
 
template<class Obj , typename MemFun , typename P1 , typename P2 >
ObjScopeGuardImpl2< Obj,
MemFun, P1, P2 > 
MakeObjGuard (Obj &obj, MemFun memFun, P1 p1, P2 p2)
 
template<typename Ret , class Obj1 , class Obj2 , typename P1a , typename P1b , typename P2a , typename P2b >
ObjScopeGuardImpl2< Obj1, Ret(Obj2::*)(P1a,
P2a), P1b, P2b > 
MakeGuard (Ret(Obj2::*memFun)(P1a, P2a), Obj1 &obj, P1b p1, P2b p2)
 
template<typename Ret , class Obj1 , class Obj2 , typename P1a , typename P1b , typename P2a , typename P2b >
ObjScopeGuardImpl2< Obj1, Ret(Obj2::*)(P1a,
P2a), P1b, P2b > 
MakeGuard (Ret(Obj2::*memFun)(P1a, P2a), Obj1 *obj, P1b p1, P2b p2)
 
template<typename C , typename T >
bool sequenceContains (const C &container, const T &value)
 Returns true if "container" contains "value".
 
void setupSignalHandlers ()
 Sets up handlers for signals and other events like terminate and new_handler. More...
 
void startSignalProcessingThread ()
 Starts the thread to handle asynchronous signals. More...
 
bool inConstructorChain (bool printOffending=false)
 checks up call tree if any method on top of me is a constructor, return true may do internal caching probably slow, use with care if not implemented for a platform, returns false
 
bool inConstructorChainSupported ()
 
void printStackTrace (std::ostream &os)
 Print a stack backtrace for the current thread to the specified ostream. More...
 
void splitStringDelim (const string &str, vector< string > *res, char delim)
 
void joinStringDelim (const vector< string > &strs, string *res, char delim)
 
int versionCmp (const StringData rhs, const StringData lhs)
 
void splitStringDelim (const std::string &str, std::vector< std::string > *res, char delim)
 
void joinStringDelim (const std::vector< std::string > &strs, std::string *res, char delim)
 
std::string tolowerString (StringData input)
 
 TEST (Comparison, Basic)
 
 TEST (LexNumCmp, Simple1)
 
void assertCmp (int expected, const StringData &s1, const StringData &s2, bool lexOnly=false)
 
 TEST (LexNumCmp, Simple2)
 
 TEST (LexNumCmp, LexOnly)
 
 TEST (LexNumCmp, Substring1)
 
 TEST (IntegerToHex, VariousConversions)
 
int leadingOnes (unsigned char c)
 
bool isValidUTF8 (const std::string &s)
 
bool isValidUTF8 (const char *s)
 
long long parseLL (const char *n)
 
std::string constructUtf8WindowsCommandLine (const std::vector< std::string > &argv)
 Construct a Windows command line string, UTF-8 encoded, from a vector of UTF-8 arguments, "argv". More...
 
void time_t_to_Struct (time_t t, struct tm *buf, bool local)
 
std::string time_t_to_String (time_t t)
 
std::string time_t_to_String_short (time_t t)
 
string terseCurrentTime (bool colonsOk)
 
string timeToISOString (time_t time)
 Formats "time" according to the ISO 8601 extended form standard, including date, and time, in the UTC timezone. More...
 
std::string dateToISOStringUTC (Date_t date)
 Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the UTC timezone. More...
 
std::string dateToISOStringLocal (Date_t date)
 Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the local timezone. More...
 
StatusWith< Date_tdateFromISOString (const StringData &dateString)
 Parses a Date_t from an ISO 8601 string representation. More...
 
std::string dateToCtimeString (Date_t date)
 Formats "date" in fixed width in the local time zone. More...
 
boost::gregorian::date currentDate ()
 
bool toPointInTime (const string &str, boost::posix_time::ptime *timeOfDay)
 
void sleepsecs (int s)
 
void sleepmicros (long long s)
 
void sleepmillis (long long s)
 
void jsTimeVirtualSkew (long long skew)
 
long long getJSTimeVirtualSkew ()
 
void jsTimeVirtualThreadSkew (long long skew)
 
long long getJSTimeVirtualThreadSkew ()
 
Date_t jsTime ()
 Date_t is milliseconds since epoch.
 
unsigned curTimeMicros ()
 warning this will wrap
 
unsigned long long curTimeMicros64 ()
 
unsigned long long curTimeMillis64 ()
 
bool toPointInTime (const std::string &str, boost::posix_time::ptime *timeOfDay)
 
char * asctime (const struct tm *tm)
 
char * ctime (const time_t *timep)
 
struct tm * gmtime (const time_t *timep)
 
struct tm * localtime (const time_t *timep)
 
void touch_pages (const char *buf, size_t length)
 
ostream & operator<< (ostream &s, const ThreadSafeString &o)
 
BSONArray toVersionArray (const char *version)
 
bool isSameMajorVersion (const char *version)
 
string mongodVersion ()
 
const char * gitVersion ()
 
const char * compiledJSEngine ()
 
const char * allocator ()
 
const char * loaderFlags ()
 
const char * compilerFlags ()
 
string sysInfo ()
 
void printGitVersion ()
 
const std::string openSSLVersion (const std::string &prefix, const std::string &suffix)
 
void printOpenSSLVersion ()
 
void printSysInfo ()
 
void printAllocator ()
 
void appendBuildInfo (BSONObjBuilder &result)
 
void printTargetMinOS ()
 
void show_warnings ()
 

Variables

const char * curNs = "in client mode"
 
bool dbexitCalled = false
 
DBConnectionPool pool
 
const char *const saslCommandUserSourceFieldName = "userSource"
 
const BSONObj getpreverrorcmdobj = fromjson("{getpreverror:1}")
 
BSONObj getnoncecmdobj = fromjson("{getnonce:1}")
 
BSONObj ismastercmdobj = fromjson("{\"ismaster\":1}")
 
BSONObj getprofilingcmdobj = fromjson("{\"profile\":-1}")
 
class MONGO_CLIENT_API DBClientBase
 
class MONGO_CLIENT_API DBClientConnection
 
const unsigned DEFAULT_CHUNK_SIZE = 255 * 1024
 
Status(* saslClientAuthenticate )(DBClientWithCommands *client, const BSONObj &saslParameters) = NULL
 Attempts to authenticate "client" using the SASL protocol. More...
 
const char *const saslStartCommandName = "saslStart"
 String name of the saslStart command.
 
const char *const saslContinueCommandName = "saslContinue"
 String name of the saslContinue command.
 
const char *const saslCommandAutoAuthorizeFieldName = "autoAuthorize"
 Name of the saslStart parameter indicating that the server should automatically grant the connection all privileges associated with the user after successful authentication. More...
 
const char *const saslCommandCodeFieldName = "code"
 Name of the field contain the status code in responses from the server.
 
const char *const saslCommandConversationIdFieldName = "conversationId"
 Name of the field containing the conversation identifier in server respones and saslContinue commands. More...
 
const char *const saslCommandDoneFieldName = "done"
 Name of the field that indicates whether or not the server believes authentication has completed successfully. More...
 
const char *const saslCommandErrmsgFieldName = "errmsg"
 Field in which to store error messages associated with non-success return codes.
 
const char *const saslCommandMechanismFieldName = "mechanism"
 Name of parameter to saslStart command indiciating the client's desired sasl mechanism.
 
const char *const saslCommandMechanismListFieldName = "supportedMechanisms"
 In the event that saslStart supplies an unsupported mechanism, the server responds with a field by this name, with a list of supported mechanisms. More...
 
const char *const saslCommandPasswordFieldName = "pwd"
 Field containing password information for saslClientAuthenticate().
 
const char *const saslCommandPayloadFieldName = "payload"
 Field containing sasl payloads passed to and from the server.
 
const char *const saslCommandUserDBFieldName = "db"
 Field containing the string identifier of the database containing credential information, or "$external" if the credential information is stored outside of the mongo cluster. More...
 
const char *const saslCommandUserFieldName = "user"
 Field containing the string identifier of the user to authenticate in saslClientAuthenticate(). More...
 
const char *const saslCommandServiceHostnameFieldName = "serviceHostname"
 Field overriding the FQDN of the hostname hosting the mongodb srevice in saslClientAuthenticate(). More...
 
const char *const saslCommandServiceNameFieldName = "serviceName"
 Field overriding the name of the mongodb service saslClientAuthenticate().
 
const char *const saslCommandDigestPasswordFieldName = "digestPassword"
 
const char *const saslDefaultDBName = "$external"
 Default database against which sasl authentication commands should run.
 
const char *const saslDefaultServiceName = "mongodb"
 Default sasl service name, "mongodb".
 
MONGO_CLIENT_API GENOIDLabeler GENOID
 
MONGO_CLIENT_API DateNowLabeler DATENOW
 
MONGO_CLIENT_API NullLabeler BSONNULL
 
MONGO_CLIENT_API UndefinedLabeler BSONUndefined
 
MONGO_CLIENT_API MinKeyLabeler MINKEY
 
MONGO_CLIENT_API MaxKeyLabeler MAXKEY
 
MONGO_CLIENT_API Labeler::Label GT
 
MONGO_CLIENT_API Labeler::Label GTE
 
MONGO_CLIENT_API Labeler::Label LT
 
MONGO_CLIENT_API Labeler::Label LTE
 
MONGO_CLIENT_API Labeler::Label NE
 
MONGO_CLIENT_API Labeler::Label NIN
 
MONGO_CLIENT_API Labeler::Label BSIZE
 
BSONObj maxKey
 
BSONObj minKey
 
mongo::TestOpTime testoptime
 
struct mongo::PackedDouble PACKED_DECL
 
const int BSONObjMaxUserSize = 16 * 1024 * 1024
 
const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 )
 
const int BufferMaxSize = 64 * 1024 * 1024
 
AssertionCount assertionCount
 
MutexDebuggermutexDebugger
 
const bool debug =false
 
int tlogLevel = 0
 For logging which we may not want during unit tests (dbtests) runs. More...
 
const char *(* getcurns )()=default_getcurns
 
Tee *const warnings = RamLog::get("warnings")
 
Tee *const startupWarningsLog = RamLog::get("startupWarnings")
 
mongo::LogfileTest __test
 
const size_t g_minOSPageSizeBytes = fetchMinOSPageSizeBytes()
 
mutex mapViewMutex ("mapView")
 
ourbitset writable
 
unsigned long long mapped = 0
 
SimpleMutex globalFlushMutex ("globalFlushMutex")
 
const int DEFAULT_MAX_CONN = 1000000
 
MSGID NextMsgId
 
const int MaxMessageSizeBytes = 48 * 1000 * 1000
 Maximum accepted message size on the wire protocol.
 
const int MsgDataHeaderSize = sizeof(MsgData) - 4
 
Ports & ports = *(new Ports())
 
SockAddr unknownAddress ("0.0.0.0", 0)
 
DiagStr_hostNameCached = *(new DiagStr)
 
const int portSendFlags = 0
 
const int portRecvFlags = 0
 
const int SOCK_FAMILY_UNKNOWN_ERROR =13078
 
const int INVALID_SOCKET = -1
 
SSLGlobalParams sslGlobalParams
 
class mongo::PidFileWiper pidFileWiper
 
mongo::TextUnitTest textUnitTest
 
long long jsTime_virtual_skew = 0
 
boost::thread_specific_ptr
< long long > 
jsTime_virtual_thread_skew
 
char _touch_pages_char_reader
 
mongo::UtilTest utilTest
 
const char versionString [] = "2.6.0"
 
const BSONArray versionArray = toVersionArray(versionString)
 

Detailed Description

tools for working in parallel/sharded/clustered environment

Copyright (c) 2012 10gen Inc.

Tools for working with in-process stack traces.

This file declares utility methods for operating on sequence containers, such as vectors, lists and deques.

Copyright (C) 2014 MongoDB Inc.

Copyright (C) 2013 MongoDB Inc.

Copyright 2012 10gen Inc.

posix

Copyright (c) 2011 10gen Inc.

Copyright 2009 10gen Inc.

Should NOT be included by other header files.

These classes provide online descriptive statistics estimator capable of computing the mean, standard deviation and quantiles.

Copyright (C) 2011 10gen Inc.

Copyright (C) 2012 10gen Inc.

Copyright (C) 2009 10gen Inc.

Copyright (C) 2010 10gen Inc.

Copyright (C) 2008 10gen Inc.

This module implements the client side of SASL authentication in MongoDB, in terms of the Cyrus SASL library.

This is an internal header.

This should only be included by replica_set_monitor.cpp and replica_set_monitor_test.cpp. This should never be included by any header.

See <sasl/sasl.h> and http://cyrusimap.web.cmu.edu/ for relevant documentation.

The primary entry point at runtime is saslClientAuthenticateImpl().

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/.

As a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file and distribute linked combinations including the program with the OpenSSL library. You must comply with the GNU Affero General Public License in all respects for all of the code used other than as permitted herein. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it in the license file.

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,b 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/.

As a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file and distribute linked combinations including the program with the OpenSSL library. You must comply with the GNU Affero General Public License in all respects for all of the code used other than as permitted herein. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it in the license file.

Exactness is traded for the ability to obtain reasonable estimates without the need to store all the samples or perform multiple passes over the data.

NOTEs on the estimator accessors provide information about accuracy of the approximation.

The implementation of the estimators is heavily inspired by the algorithms used in boost.accumulators (www.boost.org/libs/accumulators/). It differs by being tailored for typical descriptive statistics use cases thus providing a simpler (even though less flexible) interface.

Include only in source files.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Typedef Documentation

typedef long long mongo::NumberVal

Get a sysctl string value by name.

Use string specialization by default.

See Andrei's and Petru Marginean's CUJ article http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm.

Changes to the original code by Joshua Lehrer: http://www.lehrerfamily.com/scopeguard.html

Enumeration Type Documentation

the complete list of valid BSON types see also bsonspec.org

Enumerator
MinKey 

smaller than all other types

EOO 

end of object

NumberDouble 

double precision floating point value

String 

character string, stored in utf8

Object 

an embedded object

Array 

an embedded array

BinData 

binary data

Undefined 

Undefined type.

jstOID 

ObjectId.

Bool 

boolean type

Date 

date type

jstNULL 

null type

RegEx 

regular expression, a pattern with options

DBRef 

deprecated / will be redesigned

Code 

deprecated / use CodeWScope

Symbol 

a programming language (e.g., Python) symbol

CodeWScope 

javascript code that can execute on the database server, with SavedContext

NumberInt 

32 bit signed integer

Timestamp 

Updated to a Date with value next OpTime on insert.

NumberLong 

64 bit integer

JSTypeMax 

max type that is not MaxKey

MaxKey 

larger than all other types

Formatting mode for generating JSON from BSON.

See http://dochub.mongodb.org/core/mongodbextendedjson for details.

Enumerator
Strict 

strict RFC format

TenGen 

10gen format, which is close to JS format.

This form is understandable by javascript running inside the Mongo server via eval()

JS 

Javascript JSON compatible.

Function Documentation

Status mongo::bsonExtractBooleanField ( const BSONObj &  object,
const StringData &  fieldName,
bool *  out 
)

Finds a bool-like element named "fieldName" in "object".

Returns Status::OK() and sets *out to the found element's boolean value on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not Bool or a number type. For return values other than Status::OK(), the resulting value of "*out" is undefined.

Status mongo::bsonExtractBooleanFieldWithDefault ( const BSONObj &  object,
const StringData &  fieldName,
bool  defaultValue,
bool *  out 
)

Finds a bool-like element named "fieldName" in "object".

If a field named "fieldName" is present, and is either a number or boolean type, stores the truth value of the field into "*out". If no field named "fieldName" is present, sets "*out" to "defaultValue". In these cases, returns Status::OK().

If "fieldName" is present more than once, behavior is undefined. If the found field is not a boolean or number, returns ErrorCodes::TypeMismatch.

Status mongo::bsonExtractField ( const BSONObj &  object,
const StringData &  fieldName,
BSONElement *  outElement 
)

Finds an element named "fieldName" in "object".

Returns Status::OK() and sets "*outElement" to the found element on success. Returns ErrorCodes::NoSuchKey if there are no matches.

Status mongo::bsonExtractIntegerField ( const BSONObj &  object,
const StringData &  fieldName,
long long *  out 
)

Finds an element named "fieldName" in "object" that represents an integral value.

Returns Status::OK() and sets *out to the element's 64-bit integer value representation on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName". Returns ErrorCodes::TypeMismatch if the value of the matching element is not of a numeric type. Returns ErrorCodes::BadValue if the value does not have an exact 64-bit integer representation. For return values other than Status::OK(), the resulting value of "*out" is undefined.

Status mongo::bsonExtractIntegerFieldWithDefault ( const BSONObj &  object,
const StringData &  fieldName,
long long  defaultValue,
long long *  out 
)

Finds an element named "fieldName" in "object" that represents an integral value.

If a field named "fieldName" is present and is a value of numeric type with an exact 64-bit integer representation, returns that representation in *out and returns Status::OK(). If there is no field named "fieldName", stores defaultValue into *out and returns Status::OK(). If the field is found, but has non-numeric type, returns ErrorCodes::TypeMismatch. If the value has numeric type, but cannot be represented as a 64-bit integer, returns ErrorCodes::BadValue.

Status mongo::bsonExtractStringField ( const BSONObj &  object,
const StringData &  fieldName,
std::string *  out 
)

Finds a string-typed element named "fieldName" in "object" and stores its value in "out".

Returns Status::OK() and sets *out to the found element's string value on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not String. For return values other than Status::OK(), the resulting value of "*out" is undefined.

Status mongo::bsonExtractStringFieldWithDefault ( const BSONObj &  object,
const StringData &  fieldName,
const StringData &  defaultValue,
std::string *  out 
)

Finds a string element named "fieldName" in "object".

If a field named "fieldName" is present, and is a string, stores the value of the field into "*out". If no field named fieldName is present, sets "*out" to "defaultValue". In these cases, returns Status::OK().

If "fieldName" is present more than once, behavior is undefined. If the found field is not a string, returns ErrorCodes::TypeMismatch.

Status mongo::bsonExtractTypedField ( const BSONObj &  object,
const StringData &  fieldName,
BSONType  type,
BSONElement *  outElement 
)

Finds an element named "fieldName" in "object".

Returns Status::OK() and sets *outElement to the found element on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not "type". For return values other than Status::OK(), the resulting value of "*outElement" is undefined.

int mongo::canonicalizeBSONType ( BSONType  type)
inline

Returns a number for where a given type falls in the sort order.

Elements with the same return value should be compared for value equality. The return value is not a BSONType and should not be treated as one. Note: if the order changes, indexes have to be re-built or than can be corruption

std::string mongo::constructUtf8WindowsCommandLine ( const std::vector< std::string > &  argv)

Construct a Windows command line string, UTF-8 encoded, from a vector of UTF-8 arguments, "argv".

See "Parsing C++ Command-Line Arguments (C++)" http://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx

StatusWith< Date_t > mongo::dateFromISOString ( const StringData &  dateString)

Parses a Date_t from an ISO 8601 string representation.

Sample formats: "2013-07-23T18:42:14.072-05:00" "2013-07-23T18:42:14.072Z"

Local times are currently not supported.

std::string mongo::dateToCtimeString ( Date_t  date)

Formats "date" in fixed width in the local time zone.

Sample format: "Wed Oct 31 13:34:47.996"

std::string mongo::dateToISOStringLocal ( Date_t  date)

Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the local timezone.

Sample format: "2013-07-23T18:42:14.072-05:00"

std::string mongo::dateToISOStringUTC ( Date_t  date)

Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the UTC timezone.

Sample format: "2013-07-23T18:42:14.072Z"

string mongo::errnoWithPrefix ( const char *  prefix)

output the error # and error message with prefix.

handy for use as parm in uassert/massert.

MONGO_CLIENT_API BSONObj mongo::fromjson ( const std::string &  str)

Create a BSONObj from a JSON http://www.json.org, http://www.ietf.org/rfc/rfc4627.txt string.

In addition to the JSON extensions extensions described here http://dochub.mongodb.org/core/mongodbextendedjson, this function accepts unquoted field names and allows single quotes to optionally be used when specifying field names and string values instead of double quotes. JSON unicode escape sequences (of the form ) are converted to utf8.

Exceptions
MsgAssertionExceptionif parsing fails. The message included with this assertion includes the character offset where parsing failed.
MONGO_CLIENT_API BSONObj mongo::fromjson ( const char *  str,
int *  len = NULL 
)
Parameters
lenwill be size of JSON object in text chars.
FailPointRegistry * mongo::getGlobalFailPointRegistry ( )
Returns
the global fail point registry.
std::string mongo::getHostNameCached ( )

we store our host name once

this is cached, so if changes during the process lifetime will be stale

template<typename T >
int mongo::getSysctlByNameWithDefault ( const char *  sysctlName,
const T &  defaultValue,
T *  result 
)

Get a sysctl string value by name.

Use string specialization by default.

bool mongo::inConstructorChainSupported ( )
Returns
if supported on platform, compile options may still prevent it from working
struct mongo::MONGO_COMPILER_ALIGN_TYPE ( )

An unsigned integer supporting atomic read-modify-write operations.

Many operations on these types depend on natural alignment (4 byte alignment for 4-byte words, i.e.).

MONGO_CLIENT_API MONGO_COMPILER_NORETURN void mongo::msgassertedNoTrace ( int  msgid,
const char *  msg 
)

msgassert and massert are for errors that are internal but have a well defined error text std::string.

a stack trace is logged.

MONGO_CLIENT_API string mongo::nsGetCollection ( const string &  ns)
Returns
the collection name portion of an ns string
MONGO_CLIENT_API string mongo::nsGetDB ( const string &  ns)
Returns
the database name portion of an ns string
void mongo::printStackTrace ( std::ostream &  os)

Print a stack backtrace for the current thread to the specified ostream.

Parameters
osostream& to receive printed stack backtrace
bool mongo::rotateLogs ( )

Rotates the log files.

Returns true if all logs rotate successfully.

Status MONGO_CLIENT_API mongo::saslExtractPayload ( const BSONObj &  cmdObj,
std::string *  payload,
BSONType *  type 
)

Extracts the payload field from "cmdObj", and store it into "*payload".

Sets "*type" to the BSONType of the payload field in cmdObj.

If the type of the payload field is String, the contents base64 decodes and stores into "*payload". If the type is BinData, the contents are stored directly into "*payload". In all other cases, returns

void mongo::setupSignalHandlers ( )

Sets up handlers for signals and other events like terminate and new_handler.

This must be called very early in main, before runGlobalInitializers().

void mongo::startSignalProcessingThread ( )

Starts the thread to handle asynchronous signals.

This must be the first thread started from the main thread. Call this immediately after initializeServerGlobalState().

std::string mongo::timeToISOString ( time_t  time)

Formats "time" according to the ISO 8601 extended form standard, including date, and time, in the UTC timezone.

Sample format: "2013-07-23T18:42:14Z"

MONGO_CLIENT_API MONGO_COMPILER_NORETURN void mongo::uasserted ( int  msgid,
const char *  msg 
)

a "user assertion".

throws UserAssertion. logs. typically used for errors that a user could cause, such as duplicate key, disk full, etc.

Status mongo::validateBSON ( const char *  buf,
uint64_t  maxLength 
)
Parameters
buf- bson data
maxLength- maxLength of buffer this is NOT the bson size, but how far we know the buffer is valid

Variable Documentation

MONGO_CLIENT_API Status(* mongo::saslClientAuthenticate)(DBClientWithCommands *client, const BSONObj &saslParameters) = NULL

Attempts to authenticate "client" using the SASL protocol.

Do not use directly in client code. Use the DBClientWithCommands::auth(const BSONObj&) method, instead.

Test against NULL for availability. Client driver must be compiled with SASL support and client application must have successfully executed mongo::runGlobalInitializersOrDie() or its ilk to make this functionality available.

The "saslParameters" BSONObj should be initialized with zero or more of the fields below. Which fields are required depends on the mechanism. Consult the relevant IETF standards.

"mechanism": The string name of the sasl mechanism to use.  Mandatory.
"autoAuthorize": Truthy values tell the server to automatically acquire privileges on
    all resources after successful authentication, which is the default.  Falsey values
    instruct the server to await separate privilege-acquisition commands.
"user": The string name of the user to authenticate.
"db": The database target of the auth command, which identifies the location
    of the credential information for the user.  May be "$external" if credential
    information is stored outside of the mongo cluster.
"pwd": The password.
"serviceName": The GSSAPI service name to use.  Defaults to "mongodb".
"serviceHostname": The GSSAPI hostname to use.  Defaults to the name of the remote host.

Other fields in saslParameters are silently ignored.

Returns an OK status on success, and ErrorCodes::AuthenticationFailed if authentication is rejected. Other failures, all of which are tantamount to authentication failure, may also be returned.

MONGO_CLIENT_API const char *const mongo::saslCommandAutoAuthorizeFieldName = "autoAuthorize"

Name of the saslStart parameter indicating that the server should automatically grant the connection all privileges associated with the user after successful authentication.

MONGO_CLIENT_API const char *const mongo::saslCommandConversationIdFieldName = "conversationId"

Name of the field containing the conversation identifier in server respones and saslContinue commands.

MONGO_CLIENT_API const char *const mongo::saslCommandDoneFieldName = "done"

Name of the field that indicates whether or not the server believes authentication has completed successfully.

MONGO_CLIENT_API const char *const mongo::saslCommandMechanismListFieldName = "supportedMechanisms"

In the event that saslStart supplies an unsupported mechanism, the server responds with a field by this name, with a list of supported mechanisms.

MONGO_CLIENT_API const char *const mongo::saslCommandServiceHostnameFieldName = "serviceHostname"

Field overriding the FQDN of the hostname hosting the mongodb srevice in saslClientAuthenticate().

MONGO_CLIENT_API const char *const mongo::saslCommandUserDBFieldName = "db"

Field containing the string identifier of the database containing credential information, or "$external" if the credential information is stored outside of the mongo cluster.

MONGO_CLIENT_API const char *const mongo::saslCommandUserFieldName = "user"

Field containing the string identifier of the user to authenticate in saslClientAuthenticate().

int mongo::tlogLevel = 0

For logging which we may not want during unit tests (dbtests) runs.

Set tlogLevel to -1 to suppress MONGO_TLOG() output in a test program.