diff options
author | Ranjay Krishna <rak248@cornell.edu> | 2013-12-18 15:24:59 -0500 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2013-12-28 11:32:36 -0500 |
commit | 6c5777102a973d9b5e41619f2315b75da3be3084 (patch) | |
tree | b48935c1c54fa147de9608bca0d8f266e94ed54f | |
parent | e63ebb10569e05b65a34071f0a9360374b4d7139 (diff) | |
download | mongo-6c5777102a973d9b5e41619f2315b75da3be3084.tar.gz |
SERVER-3364 Label rest of client api with MONGO_CLIENT_API
build all the sharedclient programs using the new macro MONGO_CLIENT_API in mongo/client/export_macros.h
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
29 files changed, 209 insertions, 180 deletions
diff --git a/src/mongo/base/parse_number.h b/src/mongo/base/parse_number.h index 9a5d252f8d6..efe7247785f 100644 --- a/src/mongo/base/parse_number.h +++ b/src/mongo/base/parse_number.h @@ -21,6 +21,7 @@ #include "mongo/base/status.h" #include "mongo/base/string_data.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -42,7 +43,7 @@ namespace mongo { * See parse_number.cpp for the available instantiations, and add any new instantiations there. */ template <typename NumberType> - Status parseNumberFromStringWithBase(const StringData& stringValue, int base, NumberType* result); + MONGO_CLIENT_API Status parseNumberFromStringWithBase(const StringData& stringValue, int base, NumberType* result); template <typename NumberType> static Status parseNumberFromString(const StringData& stringValue, NumberType* result) { diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index d68e5d16ebc..a3dd39ee56d 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -23,6 +23,7 @@ #include "mongo/bson/bsontypes.h" #include "mongo/bson/oid.h" +#include "mongo/client/export_macros.h" #include "mongo/platform/cstdint.h" #include "mongo/platform/float_utils.h" @@ -58,7 +59,7 @@ namespace mongo { value() type() */ - class BSONElement { + class MONGO_CLIENT_API BSONElement { public: /** These functions, which start with a capital letter, throw a MsgAssertionException if the element is not of the required type. Example: @@ -78,8 +79,8 @@ namespace mongo { void OK() const { chk(ok()); } // throw MsgAssertionException if element DNE /** @return the embedded object associated with this field. - Note the returned object is a reference to within the parent bson object. If that - object is out of scope, this pointer will no longer be valid. Call getOwned() on the + Note the returned object is a reference to within the parent bson object. If that + object is out of scope, this pointer will no longer be valid. Call getOwned() on the returned BSONObj if you need your own copy. throws UserException if the element is not of type object. */ @@ -236,7 +237,7 @@ namespace mongo { } /** Size (length) of a string element. - You must assure of type String first. + You must assure of type String first. @return string size including terminating null */ int valuestrsize() const { diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h index 9e403bfd63b..f0bf0403f12 100644 --- a/src/mongo/bson/bsonmisc.h +++ b/src/mongo/bson/bsonmisc.h @@ -20,6 +20,7 @@ #include <memory> #include "mongo/bson/bsonelement.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -94,7 +95,7 @@ namespace mongo { Example: std::cout << BSON( "a" << BSONNULL ); // { a : null } */ - extern struct NullLabeler { } BSONNULL; + extern MONGO_CLIENT_API struct MONGO_CLIENT_API NullLabeler { } BSONNULL; /* Utility class to assign an Undefined value to a given attribute Example: @@ -191,7 +192,7 @@ namespace mongo { // definitions in bsonobjbuilder.h b/c of incomplete types // Utility class to implement BSON( key << val ) as described above. - class BSONObjBuilderValueStream : public boost::noncopyable { + class MONGO_CLIENT_API BSONObjBuilderValueStream : public boost::noncopyable { public: friend class Labeler; BSONObjBuilderValueStream( BSONObjBuilder * builder ); diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index ea8ac971a5d..ba2821b2be1 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -28,6 +28,7 @@ #include "mongo/base/string_data.h" #include "mongo/bson/util/atomic_int.h" #include "mongo/bson/util/builder.h" +#include "mongo/client/export_macros.h" #include "mongo/util/bufreader.h" namespace mongo { @@ -73,9 +74,9 @@ namespace mongo { Code With Scope: <total size><String><Object> \endcode */ - class BSONObj { + class MONGO_CLIENT_API BSONObj { public: - + /** Construct a BSONObj from data in the proper format. * Use this constructor when something else owns msgdata's buffer */ @@ -97,7 +98,7 @@ namespace mongo { static BSONObj make( const Record* r ); - ~BSONObj() { + ~BSONObj() { _objdata = 0; // defensive } @@ -131,7 +132,7 @@ namespace mongo { */ bool isOwned() const { return _holder.get() != 0; } - /** assure the data buffer is under the control of this BSONObj and not a remote buffer + /** assure the data buffer is under the control of this BSONObj and not a remote buffer @see isOwned() */ BSONObj getOwned() const; @@ -191,7 +192,7 @@ namespace mongo { */ BSONElement getField(const StringData& name) const; - /** Get several fields at once. This is faster than separate getField() calls as the size of + /** Get several fields at once. This is faster than separate getField() calls as the size of elements iterated can then be calculated only once each. @param n number of fieldNames, and number of elements in the fields array @param fields if a field is found its element is stored in its corresponding position in this array. @@ -227,7 +228,7 @@ namespace mongo { /** @return INT_MIN if not present - does some type conversions */ int getIntField(const StringData& name) const; - /** @return false if not present + /** @return false if not present @see BSONElement::trueValue() */ bool getBoolField(const StringData& name) const; @@ -383,15 +384,15 @@ namespace mongo { /** @return first field of the object */ BSONElement firstElement() const { return BSONElement(objdata() + 4); } - /** faster than firstElement().fieldName() - for the first element we can easily find the fieldname without + /** faster than firstElement().fieldName() - for the first element we can easily find the fieldname without computing the element size. */ - const char * firstElementFieldName() const { + const char * firstElementFieldName() const { const char *p = objdata() + 4; return *p == EOO ? "" : p+1; } - BSONType firstElementType() const { + BSONType firstElementType() const { const char *p = objdata() + 4; return (BSONType) *p; } diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index 51616fa8c28..f5292caf17a 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -33,6 +33,7 @@ #include "mongo/bson/bsonmisc.h" #include "mongo/bson/bson_builder_base.h" #include "mongo/bson/bson_field.h" +#include "mongo/client/export_macros.h" #if defined(_DEBUG) && defined(MONGO_EXPOSE_MACROS) #include "mongo/util/log.h" @@ -48,7 +49,7 @@ namespace mongo { /** Utility for creating a BSONObj. See also the BSON() and BSON_ARRAY() macros. */ - class BSONObjBuilder : public BSONBuilderBase, private boost::noncopyable { + class MONGO_CLIENT_API BSONObjBuilder : public BSONBuilderBase, private boost::noncopyable { public: /** @param initsize this is just a hint as to the final size of the object */ BSONObjBuilder(int initsize=512) : _b(_buf), _buf(initsize + sizeof(unsigned)), _offset( sizeof(unsigned) ), _s( this ) , _tracker(0) , _doneCalled(false) { @@ -362,7 +363,7 @@ namespace mongo { return appendCode(fieldName, code.code); } - /** Append a string element. + /** Append a string element. @param sz size includes terminating null character */ BSONObjBuilder& append(const StringData& fieldName, const char *str, int sz) { _b.appendNum((char) String); diff --git a/src/mongo/client/auth_helpers.h b/src/mongo/client/auth_helpers.h index d1b652a70bf..ca668f7bb6a 100644 --- a/src/mongo/client/auth_helpers.h +++ b/src/mongo/client/auth_helpers.h @@ -16,6 +16,7 @@ #pragma once #include "mongo/base/string_data.h" +#include "mongo/client/export_macros.h" namespace mongo { namespace auth { @@ -24,7 +25,7 @@ namespace auth { * Hashes the password so that it can be stored in a user object or used for MONGODB-CR * authentication. */ - std::string createPasswordDigest(const StringData& username, + std::string MONGO_CLIENT_API createPasswordDigest(const StringData& username, const StringData& clearTextPassword); } // namespace auth diff --git a/src/mongo/client/authlevel.h b/src/mongo/client/authlevel.h index b37b5b3293e..0a84f9213d5 100644 --- a/src/mongo/client/authlevel.h +++ b/src/mongo/client/authlevel.h @@ -19,6 +19,8 @@ #include <string> +#include "mongo/client/export_macros.h" + namespace mongo { /* @@ -28,7 +30,7 @@ namespace mongo { * 1 : read * 2 : write */ - struct Auth { + struct MONGO_CLIENT_API Auth { enum Level { NONE = 0 , READ = 1 , diff --git a/src/mongo/client/clientOnly-private.h b/src/mongo/client/clientOnly-private.h index 08a2ee5e7c3..419f385ba31 100644 --- a/src/mongo/client/clientOnly-private.h +++ b/src/mongo/client/clientOnly-private.h @@ -15,10 +15,12 @@ #pragma once +#include "mongo/client/export_macros.h" + namespace mongo { class mutex; namespace shell_utils { - extern mongo::mutex &mongoProgramOutputMutex; + extern MONGO_CLIENT_API mongo::mutex &mongoProgramOutputMutex; } } diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 30e78d2a2fd..694ce53d6dc 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -19,9 +19,10 @@ #include <stack> -#include "mongo/util/background.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" #include "mongo/platform/cstdint.h" +#include "mongo/util/background.h" namespace mongo { @@ -32,7 +33,7 @@ namespace mongo { * not thread safe * thread safety is handled by DBConnectionPool */ - class PoolForHost { + class MONGO_CLIENT_API PoolForHost { public: PoolForHost() : _created(0), _minValidCreationTimeMicroSec(0) {} @@ -64,7 +65,7 @@ namespace mongo { void done( DBConnectionPool * pool , DBClientBase * c ); void flush(); - + void getStaleConnections( vector<DBClientBase*>& stale ); /** @@ -99,7 +100,7 @@ namespace mongo { std::string _hostName; std::stack<StoredConnection> _pool; - + int64_t _created; uint64_t _minValidCreationTimeMicroSec; ConnectionString::ConnectionType _type; @@ -130,8 +131,8 @@ namespace mongo { c.conn()... } */ - class DBConnectionPool : public PeriodicTask { - + class MONGO_CLIENT_API DBConnectionPool : public PeriodicTask { + public: DBConnectionPool(); @@ -179,15 +180,15 @@ namespace mongo { }; virtual string taskName() const { return "DBConnectionPool-cleaner"; } - virtual void taskDoWork(); + virtual void taskDoWork(); private: DBConnectionPool( DBConnectionPool& p ); - + DBClientBase* _get( const string& ident , double socketTimeout ); DBClientBase* _finishCreate( const string& ident , double socketTimeout, DBClientBase* conn ); - + struct PoolKey { PoolKey( const std::string& i , double t ) : ident( i ) , timeout( t ) {} string ident; @@ -202,27 +203,27 @@ namespace mongo { mongo::mutex _mutex; string _name; - + PoolMap _pools; // pointers owned by me, right now they leak on shutdown // _hooks itself also leaks because it creates a shutdown race condition - list<DBConnectionHook*> * _hooks; + list<DBConnectionHook*> * _hooks; }; - extern DBConnectionPool pool; + extern MONGO_CLIENT_API DBConnectionPool pool; - class AScopedConnection : boost::noncopyable { + class MONGO_CLIENT_API AScopedConnection : boost::noncopyable { public: AScopedConnection() { _numConnections++; } virtual ~AScopedConnection() { _numConnections--; } - + virtual DBClientBase* get() = 0; virtual void done() = 0; virtual string getHost() const = 0; - - /** + + /** * @return true iff this has a connection to the db */ virtual bool ok() const = 0; @@ -240,7 +241,7 @@ namespace mongo { clean up nicely (i.e. the socket gets closed automatically when the scopeddbconnection goes out of scope). */ - class ScopedDbConnection : public AScopedConnection { + class MONGO_CLIENT_API ScopedDbConnection : public AScopedConnection { public: /** the main constructor you want to use throws UserException if can't connect diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h index 7bcd2cc2eeb..0ef57d42b55 100644 --- a/src/mongo/client/dbclient_rs.h +++ b/src/mongo/client/dbclient_rs.h @@ -25,6 +25,7 @@ #include <utility> #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" #include "mongo/util/net/hostandport.h" namespace mongo { @@ -42,7 +43,7 @@ namespace mongo { * one instance per process per replica set * TODO: we might be able to use a regular Node * to avoid _lock */ - class ReplicaSetMonitor { + class MONGO_CLIENT_API ReplicaSetMonitor { public: typedef boost::function1<void,const ReplicaSetMonitor*> ConfigChangeHook; @@ -266,7 +267,7 @@ namespace mongo { string getServerAddress() const; bool contains( const string& server ) const; - + void appendInfo( BSONObjBuilder& b ) const; /** @@ -416,7 +417,7 @@ namespace mongo { On a failover situation, expect at least one operation to return an error (throw an exception) before the failover is complete. Operations are not retried. */ - class DBClientReplicaSet : public DBClientBase { + class MONGO_CLIENT_API DBClientReplicaSet : public DBClientBase { public: using DBClientBase::query; using DBClientBase::update; @@ -604,7 +605,7 @@ namespace mongo { // Last used connection in a slaveOk query (can be a primary) boost::shared_ptr<DBClientConnection> _lastSlaveOkConn; boost::shared_ptr<ReadPreferenceSetting> _lastReadPref; - + double _so_timeout; // we need to store so that when we connect to a new node on failure @@ -635,7 +636,7 @@ namespace mongo { * A simple object for representing the list of tags. The initial state will * have a valid current tag as long as the list is not empty. */ - class TagSet { + class MONGO_CLIENT_API TagSet { public: /** * Creates an empty tag list that is initially exhausted. @@ -712,7 +713,7 @@ namespace mongo { scoped_ptr<BSONArrayIteratorSorted> _tagIterator; }; - struct ReadPreferenceSetting { + struct MONGO_CLIENT_API ReadPreferenceSetting { /** * @parm pref the read preference mode. * @param tag the tag set. Note that this object will have the diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h index 785734dac63..4ed29b0150a 100644 --- a/src/mongo/client/dbclientcursor.h +++ b/src/mongo/client/dbclientcursor.h @@ -22,6 +22,7 @@ #include <stack> #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/util/net/message.h" @@ -30,10 +31,10 @@ namespace mongo { class AScopedConnection; - /** for mock purposes only -- do not create variants of DBClientCursor, nor hang code here + /** for mock purposes only -- do not create variants of DBClientCursor, nor hang code here @see DBClientMockCursor */ - class DBClientCursorInterface : boost::noncopyable { + class MONGO_CLIENT_API DBClientCursorInterface : boost::noncopyable { public: virtual ~DBClientCursorInterface() {} virtual bool more() = 0; @@ -44,7 +45,7 @@ namespace mongo { }; /** Queries return a cursor object */ - class DBClientCursor : public DBClientCursorInterface { + class MONGO_CLIENT_API DBClientCursor : public DBClientCursorInterface { public: /** If true, safe to call next(). Requests more from server if necessary. */ bool more(); @@ -201,7 +202,7 @@ namespace mongo { void initLazy( bool isRetry = false ); bool initLazyFinish( bool& retry ); - class Batch : boost::noncopyable { + class Batch : boost::noncopyable { friend class DBClientCursor; auto_ptr<Message> m; int nReturned; @@ -217,7 +218,7 @@ namespace mongo { int nextBatchSize(); void _finishConsInit(); - + Batch batch; DBClientBase* _client; string _originalHost; @@ -255,7 +256,7 @@ namespace mongo { /** iterate over objects in current batch only - will not cause a network call */ - class DBClientCursorBatchIterator { + class MONGO_CLIENT_API DBClientCursorBatchIterator { public: DBClientCursorBatchIterator( DBClientCursor &c ) : _c( c ), _n() {} bool moreInCurrentBatch() { return _c.moreInCurrentBatch(); } diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index 13d2939fba8..eba2d0bdb43 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -24,6 +24,7 @@ #include <boost/function.hpp> +#include "mongo/client/export_macros.h" #include "mongo/db/jsobj.h" #include "mongo/logger/log_severity.h" #include "mongo/platform/atomic_word.h" @@ -33,7 +34,7 @@ namespace mongo { /** the query field 'options' can have these bits set: */ - enum QueryOptions { + enum MONGO_CLIENT_API QueryOptions { /** Tailable means cursor is not closed when the last data is retrieved. rather, the cursor marks the final object's position. you can resume using the cursor later, from where it was located, if more data were received. Set on dbQuery and dbGetMore. @@ -79,7 +80,7 @@ namespace mongo { /** When sharded, this means its ok to return partial results Usually we will fail a query if all required shards aren't up - If this is set, it'll be a partial result set + If this is set, it'll be a partial result set */ QueryOption_PartialResults = 1 << 7 , @@ -87,7 +88,7 @@ namespace mongo { }; - enum UpdateOptions { + enum MONGO_CLIENT_API UpdateOptions { /** Upsert - that is, insert the item if no matching item is found. */ UpdateOption_Upsert = 1 << 0, @@ -99,7 +100,7 @@ namespace mongo { UpdateOption_Broadcast = 1 << 2 }; - enum RemoveOptions { + enum MONGO_CLIENT_API RemoveOptions { /** only delete one option */ RemoveOption_JustOne = 1 << 0, @@ -107,11 +108,11 @@ namespace mongo { RemoveOption_Broadcast = 1 << 1 }; - - /** + + /** * need to put in DbMesssage::ReservedOptions as well */ - enum InsertOptions { + enum MONGO_CLIENT_API InsertOptions { /** With muli-insert keep processing inserts if one fails */ InsertOption_ContinueOnError = 1 << 0 }; @@ -119,7 +120,7 @@ namespace mongo { /** * Start from *top* of bits, these are generic write options that apply to all */ - enum WriteOptions { + enum MONGO_CLIENT_API WriteOptions { /** logical writeback option */ WriteOption_FromWriteback = 1 << 31 }; @@ -130,12 +131,12 @@ namespace mongo { // the api user, but we need these constants to disassemble/reassemble the messages correctly. // - enum ReservedOptions { + enum MONGO_CLIENT_API ReservedOptions { Reserved_InsertOption_ContinueOnError = 1 << 0 , Reserved_FromWriteback = 1 << 1 }; - enum ReadPreference { + enum MONGO_CLIENT_API ReadPreference { /** * Read from primary only. All operations produce an error (throw an * exception where applicable) if primary is unavailable. Cannot be @@ -167,8 +168,8 @@ namespace mongo { ReadPreference_Nearest, }; - class DBClientBase; - class DBClientConnection; + class MONGO_CLIENT_API DBClientBase; + class MONGO_CLIENT_API DBClientConnection; /** * ConnectionString handles parsing different ways to connect to mongo and determining method @@ -177,7 +178,7 @@ namespace mongo { * server:port * foo/server:port,server:port SET * server,server,server SYNC - * Warning - you usually don't want "SYNC", it's used + * Warning - you usually don't want "SYNC", it's used * for some special things such as sharding config servers. * See syncclusterconnection.h for more info. * @@ -187,7 +188,7 @@ namespace mongo { * if ( ! cs.isValid() ) throw "bad: " + errmsg; * DBClientBase * conn = cs.connect( errmsg ); */ - class ConnectionString { + class MONGO_CLIENT_API ConnectionString { public: enum ConnectionType { INVALID , MASTER , PAIR , SET , SYNC, CUSTOM }; @@ -228,7 +229,7 @@ namespace mongo { ConnectionString( const string& s , ConnectionType favoredMultipleType ) { _type = INVALID; - + _fillServers( s ); if ( _type != INVALID ) { // set already @@ -246,13 +247,13 @@ namespace mongo { bool isValid() const { return _type != INVALID; } string toString() const { return _string; } - + DBClientBase* connect( string& errmsg, double socketTimeout = 0 ) const; string getSetName() const { return _setName; } vector<HostAndPort> getServers() const { return _servers; } - + ConnectionType type() const { return _type; } /** @@ -311,7 +312,7 @@ namespace mongo { * controls how much a clients cares about writes * default is NORMAL */ - enum WriteConcern { + enum MONGO_CLIENT_API WriteConcern { W_NONE = 0 , // TODO: not every connection type fully supports this W_NORMAL = 1 // TODO SAFE = 2 @@ -327,7 +328,7 @@ namespace mongo { QUERY( "age" << 33 << "school" << "UCLA" ).sort("name") QUERY( "age" << GT << 30 << LT << 50 ) */ - class Query { + class MONGO_CLIENT_API Query { public: static const BSONField<BSONObj> ReadPrefField; static const BSONField<std::string> ReadPrefModeField; @@ -449,7 +450,7 @@ namespace mongo { * Represents a full query description, including all options required for the query to be passed on * to other hosts */ - class QuerySpec { + class MONGO_CLIENT_API QuerySpec { string _ns; int _ntoskip; @@ -460,7 +461,7 @@ namespace mongo { Query _queryObj; public: - + QuerySpec( const string& ns, const BSONObj& query, const BSONObj& fields, int ntoskip, int ntoreturn, int options ) @@ -482,21 +483,21 @@ namespace mongo { BSONObj* fieldsData() { return &_fields; } // don't love this, but needed downstrem - const BSONObj* fieldsPtr() const { return &_fields; } + const BSONObj* fieldsPtr() const { return &_fields; } string ns() const { return _ns; } int ntoskip() const { return _ntoskip; } int ntoreturn() const { return _ntoreturn; } int options() const { return _options; } - + void setFields( BSONObj& o ) { _fields = o.getOwned(); } string toString() const { - return str::stream() << "QSpec " << + return str::stream() << "QSpec " << BSON( "ns" << _ns << "n2skip" << _ntoskip << "n2return" << _ntoreturn << "options" << _options << "query" << _query << "fields" << _fields ); } - + }; @@ -507,15 +508,15 @@ namespace mongo { // Useful utilities for namespaces /** @return the database name portion of an ns string */ - string nsGetDB( const string &ns ); + MONGO_CLIENT_API string nsGetDB( const string &ns ); /** @return the collection name portion of an ns string */ - string nsGetCollection( const string &ns ); + MONGO_CLIENT_API string nsGetCollection( const string &ns ); /** interface that handles communication with the db */ - class DBConnector { + class MONGO_CLIENT_API DBConnector { public: virtual ~DBConnector() {} /** actualServer is set to the actual server where they call went if there was a choice (SlaveOk) */ @@ -534,7 +535,7 @@ namespace mongo { /** The interface that any db connection should implement */ - class DBClientInterface : boost::noncopyable { + class MONGO_CLIENT_API DBClientInterface : boost::noncopyable { public: virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ) = 0; @@ -562,8 +563,8 @@ namespace mongo { */ virtual BSONObj findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); - /** query N objects from the database into an array. makes sense mostly when you want a small number of results. if a huge number, use - query() and iterate the cursor. + /** query N objects from the database into an array. makes sense mostly when you want a small number of results. if a huge number, use + query() and iterate the cursor. */ void findN(vector<BSONObj>& out, const string&ns, Query query, int nToReturn, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); @@ -577,7 +578,7 @@ namespace mongo { DB "commands" Basically just invocations of connection.$cmd.findOne({...}); */ - class DBClientWithCommands : public DBClientInterface { + class MONGO_CLIENT_API DBClientWithCommands : public DBClientInterface { set<string> _seenIndexes; public: /** controls how chatty the client is about network errors & such. See log.h */ @@ -722,7 +723,7 @@ namespace mongo { */ virtual BSONObj getLastErrorDetailed(bool fsync = false, bool j = false, int w = 0, int wtimeout = 0); - /** Can be called with the returned value from getLastErrorDetailed to extract an error string. + /** Can be called with the returned value from getLastErrorDetailed to extract an error string. If all you need is the string, just call getLastError() instead. */ static string getLastErrorString( const BSONObj& res ); @@ -1022,7 +1023,7 @@ namespace mongo { /** abstract class that implements the core db operations */ - class DBClientBase : public DBClientWithCommands, public DBConnector { + class MONGO_CLIENT_API DBClientBase : public DBClientWithCommands, public DBConnector { protected: static AtomicInt64 ConnectionIdSequence; long long _connectionId; // unique connection id for this connection @@ -1136,9 +1137,9 @@ namespace mongo { virtual bool callRead( Message& toSend , Message& response ) = 0; // virtual bool callWrite( Message& toSend , Message& response ) = 0; // TODO: add this if needed - + virtual ConnectionString::ConnectionType type() const = 0; - + virtual double getSoTimeout() const = 0; virtual uint64_t getSockCreationMicroSec() const { @@ -1149,7 +1150,7 @@ namespace mongo { class DBClientReplicaSet; - class ConnectException : public UserException { + class MONGO_CLIENT_API ConnectException : public UserException { public: ConnectException(string msg) : UserException(9000,msg) { } }; @@ -1158,7 +1159,7 @@ namespace mongo { A basic connection to the database. This is the main entry point for talking to a simple Mongo setup */ - class DBClientConnection : public DBClientBase { + class MONGO_CLIENT_API DBClientConnection : public DBClientBase { public: using DBClientBase::query; @@ -1332,14 +1333,14 @@ namespace mongo { /** pings server to check if it's up */ - bool serverAlive( const string &uri ); + MONGO_CLIENT_API bool serverAlive( const string &uri ); - DBClientBase * createDirectClient(); + MONGO_CLIENT_API DBClientBase * createDirectClient(); - BSONElement getErrField( const BSONObj& result ); - bool hasErrField( const BSONObj& result ); + MONGO_CLIENT_API BSONElement getErrField( const BSONObj& result ); + MONGO_CLIENT_API bool hasErrField( const BSONObj& result ); - inline std::ostream& operator<<( std::ostream &s, const Query &q ) { + MONGO_CLIENT_API inline std::ostream& operator<<( std::ostream &s, const Query &q ) { return s << q.toString(); } diff --git a/src/mongo/client/dbclientmockcursor.h b/src/mongo/client/dbclientmockcursor.h index 41e0475a72e..0e60f0fc947 100644 --- a/src/mongo/client/dbclientmockcursor.h +++ b/src/mongo/client/dbclientmockcursor.h @@ -18,10 +18,11 @@ #pragma once #include "mongo/client/dbclientcursor.h" +#include "mongo/client/export_macros.h" namespace mongo { - class DBClientMockCursor : public DBClientCursorInterface { + class MONGO_CLIENT_API DBClientMockCursor : public DBClientCursorInterface { public: DBClientMockCursor( const BSONArray& mockCollection ) : _iter( mockCollection ) {} virtual ~DBClientMockCursor() {} diff --git a/src/mongo/client/distlock.h b/src/mongo/client/distlock.h index 798ffbda44c..b5e7b378749 100644 --- a/src/mongo/client/distlock.h +++ b/src/mongo/client/distlock.h @@ -19,6 +19,7 @@ #include "mongo/pch.h" #include "mongo/client/connpool.h" +#include "mongo/client/export_macros.h" #include "mongo/client/syncclusterconnection.h" #define LOCK_TIMEOUT (15 * 60 * 1000) @@ -39,7 +40,7 @@ namespace mongo { /** * Exception class to encapsulate exceptions while managing distributed locks */ - class LockException : public DBException { + class MONGO_CLIENT_API LockException : public DBException { public: LockException( const char * msg , int code ) : DBException( msg, code ) {} LockException( const string& msg, int code ) : DBException( msg, code ) {} @@ -49,7 +50,7 @@ namespace mongo { /** * Indicates an error in retrieving time values from remote servers. */ - class TimeNotFoundException : public LockException { + class MONGO_CLIENT_API TimeNotFoundException : public LockException { public: TimeNotFoundException( const char * msg , int code ) : LockException( msg, code ) {} TimeNotFoundException( const string& msg, int code ) : LockException( msg, code ) {} @@ -64,27 +65,27 @@ namespace mongo { * To be maintained, each taken lock needs to be revalidated ("pinged") within a pre-established amount of time. This * class does this maintenance automatically once a DistributedLock object was constructed. */ - class DistributedLock { + class MONGO_CLIENT_API DistributedLock { public: static LabeledLevel logLvl; struct PingData { - - PingData( const string& _id , Date_t _lastPing , Date_t _remote , OID _ts ) + + PingData( const string& _id , Date_t _lastPing , Date_t _remote , OID _ts ) : id(_id), lastPing(_lastPing), remote(_remote), ts(_ts){ } PingData() : id(""), lastPing(0), remote(0), ts(){ } - + string id; Date_t lastPing; Date_t remote; OID ts; }; - + class LastPings { public: LastPings() : _mutex( "DistributedLock::LastPings" ) {} @@ -192,11 +193,11 @@ namespace mongo { // Helper functions for tests, allows us to turn the creation of a lock pinger on and off. // *NOT* thread-safe - bool isLockPingerEnabled(); - void setLockPingerEnabled(bool enabled); + bool MONGO_CLIENT_API isLockPingerEnabled(); + void MONGO_CLIENT_API setLockPingerEnabled(bool enabled); - class dist_lock_try { + class MONGO_CLIENT_API dist_lock_try { public: dist_lock_try() : _lock(NULL), _got(false) {} @@ -277,7 +278,7 @@ namespace mongo { * the distributed lock are managed by this class, and the distributed lock is unlocked if * successfully acquired on object destruction. */ - class ScopedDistributedLock { + class MONGO_CLIENT_API ScopedDistributedLock { public: ScopedDistributedLock(const ConnectionString& conn, const string& name); diff --git a/src/mongo/client/gridfs.h b/src/mongo/client/gridfs.h index 089678893cf..003207ccb3f 100644 --- a/src/mongo/client/gridfs.h +++ b/src/mongo/client/gridfs.h @@ -20,6 +20,7 @@ #include "mongo/bson/bsonelement.h" #include "mongo/bson/bsonobj.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -28,7 +29,7 @@ namespace mongo { class GridFS; class GridFile; - class GridFSChunk { + class MONGO_CLIENT_API GridFSChunk { public: GridFSChunk( BSONObj data ); GridFSChunk( BSONObj fileId , int chunkNumber , const char * data , int len ); @@ -53,7 +54,7 @@ namespace mongo { GridFS is for storing large file-style objects in MongoDB. @see http://dochub.mongodb.org/core/gridfsspec */ - class GridFS { + class MONGO_CLIENT_API GridFS { public: /** * @param client - db connection @@ -136,7 +137,7 @@ namespace mongo { /** wrapper for a file stored in the Mongo database */ - class GridFile { + class MONGO_CLIENT_API GridFile { public: /** * @return whether or not this file exists diff --git a/src/mongo/client/parallel.h b/src/mongo/client/parallel.h index 86059fb922f..91c906d7370 100644 --- a/src/mongo/client/parallel.h +++ b/src/mongo/client/parallel.h @@ -21,6 +21,7 @@ #pragma once +#include "mongo/client/export_macros.h" #include "mongo/db/dbmessage.h" #include "mongo/db/matcher.h" #include "mongo/db/namespace_string.h" @@ -33,7 +34,7 @@ namespace mongo { /** * holder for a server address and a query to run */ - class ServerAndQuery { + class MONGO_CLIENT_API ServerAndQuery { public: ServerAndQuery( const string& server , BSONObj extra = BSONObj() , BSONObj orderObject = BSONObj() ) : _server( server ) , _extra( extra.getOwned() ) , _orderObject( orderObject.getOwned() ) { @@ -69,7 +70,7 @@ namespace mongo { * this is a cursor that works over a set of servers * can be used in serial/parallel as controlled by sub classes */ - class ClusteredCursor { + class MONGO_CLIENT_API ClusteredCursor { public: ClusteredCursor( const QuerySpec& q ); ClusteredCursor( QueryMessage& q ); @@ -124,7 +125,7 @@ namespace mongo { class ParallelConnectionMetadata; // TODO: We probably don't really need this as a separate class. - class FilteringClientCursor { + class MONGO_CLIENT_API FilteringClientCursor { public: FilteringClientCursor( const BSONObj filter = BSONObj() ); FilteringClientCursor( DBClientCursor* cursor , const BSONObj filter = BSONObj() ); @@ -160,7 +161,7 @@ namespace mongo { }; - class Servers { + class MONGO_CLIENT_API Servers { public: Servers() { } @@ -218,7 +219,7 @@ namespace mongo { * runs a query in serial across any number of servers * returns all results from 1 server, then the next, etc... */ - class SerialServerClusteredCursor : public ClusteredCursor { + class MONGO_CLIENT_API SerialServerClusteredCursor : public ClusteredCursor { public: SerialServerClusteredCursor( const set<ServerAndQuery>& servers , QueryMessage& q , int sortOrder=0); virtual bool more(); @@ -240,7 +241,7 @@ namespace mongo { - class CommandInfo { + class MONGO_CLIENT_API CommandInfo { public: string versionedNS; BSONObj cmdFilter; @@ -262,7 +263,7 @@ namespace mongo { class DBClientCursor; typedef shared_ptr<DBClientCursor> DBClientCursorPtr; - class ParallelConnectionState { + class MONGO_CLIENT_API ParallelConnectionState { public: ParallelConnectionState() : @@ -289,7 +290,7 @@ namespace mongo { typedef ParallelConnectionState PCState; typedef shared_ptr<PCState> PCStatePtr; - class ParallelConnectionMetadata { + class MONGO_CLIENT_API ParallelConnectionMetadata { public: ParallelConnectionMetadata() : @@ -328,7 +329,7 @@ namespace mongo { * stale configuration exceptions * 3) Command query, either enforcing compatible chunk versions or sent to particular shards. */ - class ParallelSortClusteredCursor : public ClusteredCursor { + class MONGO_CLIENT_API ParallelSortClusteredCursor : public ClusteredCursor { public: ParallelSortClusteredCursor( const QuerySpec& qSpec, const CommandInfo& cInfo = CommandInfo() ); @@ -411,7 +412,7 @@ namespace mongo { * right now uses underlying sync network ops and uses another thread * should be changed to use non-blocking io */ - class Future { + class MONGO_CLIENT_API Future { public: class CommandResult { public: @@ -457,7 +458,7 @@ namespace mongo { friend class Future; }; - + /** * @param server server name * @param db db name diff --git a/src/mongo/client/sasl_client_authenticate.h b/src/mongo/client/sasl_client_authenticate.h index 71f2a319480..3bc73f41672 100644 --- a/src/mongo/client/sasl_client_authenticate.h +++ b/src/mongo/client/sasl_client_authenticate.h @@ -18,6 +18,7 @@ #include "mongo/base/status.h" #include "mongo/bson/bsontypes.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" namespace mongo { class BSONObj; @@ -54,7 +55,7 @@ namespace mongo { * rejected. Other failures, all of which are tantamount to authentication failure, may also be * returned. */ - extern Status (*saslClientAuthenticate)(DBClientWithCommands* client, + extern MONGO_CLIENT_API Status (*saslClientAuthenticate)(DBClientWithCommands* client, const BSONObj& saslParameters); /** @@ -66,69 +67,69 @@ namespace mongo { * stores into "*payload". If the type is BinData, the contents are stored directly * into "*payload". In all other cases, returns */ - Status saslExtractPayload(const BSONObj& cmdObj, std::string* payload, BSONType* type); + Status MONGO_CLIENT_API saslExtractPayload(const BSONObj& cmdObj, std::string* payload, BSONType* type); // Constants /// String name of the saslStart command. - extern const char* const saslStartCommandName; + extern MONGO_CLIENT_API const char* const saslStartCommandName; /// String name of the saslContinue command. - extern const char* const saslContinueCommandName; + extern MONGO_CLIENT_API const char* const saslContinueCommandName; /// Name of the saslStart parameter indicating that the server should automatically grant the /// connection all privileges associated with the user after successful authentication. - extern const char* const saslCommandAutoAuthorizeFieldName; + extern MONGO_CLIENT_API const char* const saslCommandAutoAuthorizeFieldName; /// Name of the field contain the status code in responses from the server. - extern const char* const saslCommandCodeFieldName; + extern MONGO_CLIENT_API const char* const saslCommandCodeFieldName; /// Name of the field containing the conversation identifier in server respones and saslContinue /// commands. - extern const char* const saslCommandConversationIdFieldName; + extern MONGO_CLIENT_API const char* const saslCommandConversationIdFieldName; /// Name of the field that indicates whether or not the server believes authentication has /// completed successfully. - extern const char* const saslCommandDoneFieldName; + extern MONGO_CLIENT_API const char* const saslCommandDoneFieldName; /// Field in which to store error messages associated with non-success return codes. - extern const char* const saslCommandErrmsgFieldName; + extern MONGO_CLIENT_API const char* const saslCommandErrmsgFieldName; /// Name of parameter to saslStart command indiciating the client's desired sasl mechanism. - extern const char* const saslCommandMechanismFieldName; + extern MONGO_CLIENT_API const char* const saslCommandMechanismFieldName; /// In the event that saslStart supplies an unsupported mechanism, the server responds with a /// field by this name, with a list of supported mechanisms. - extern const char* const saslCommandMechanismListFieldName; + extern MONGO_CLIENT_API const char* const saslCommandMechanismListFieldName; /// Field containing password information for saslClientAuthenticate(). - extern const char* const saslCommandPasswordFieldName; + extern MONGO_CLIENT_API const char* const saslCommandPasswordFieldName; /// Field containing sasl payloads passed to and from the server. - extern const char* const saslCommandPayloadFieldName; + extern MONGO_CLIENT_API const char* const saslCommandPayloadFieldName; /// Field containing the string identifier of the user to authenticate in /// saslClientAuthenticate(). - extern const char* const saslCommandUserFieldName; + extern MONGO_CLIENT_API const char* const saslCommandUserFieldName; /// Field containing the string identifier of the database containing credential information, /// or "$external" if the credential information is stored outside of the mongo cluster. - extern const char* const saslCommandUserDBFieldName; + extern MONGO_CLIENT_API const char* const saslCommandUserDBFieldName; /// Field overriding the FQDN of the hostname hosting the mongodb srevice in /// saslClientAuthenticate(). - extern const char* const saslCommandServiceHostnameFieldName; + extern MONGO_CLIENT_API const char* const saslCommandServiceHostnameFieldName; /// Field overriding the name of the mongodb service saslClientAuthenticate(). - extern const char* const saslCommandServiceNameFieldName; + extern MONGO_CLIENT_API const char* const saslCommandServiceNameFieldName; /// Default database against which sasl authentication commands should run. - extern const char* const saslDefaultDBName; + extern MONGO_CLIENT_API const char* const saslDefaultDBName; /// Default sasl service name, "mongodb". - extern const char* const saslDefaultServiceName; + extern MONGO_CLIENT_API const char* const saslDefaultServiceName; // Field whose value should be set to true if the field in saslCommandPasswordFieldName needs to // be digested. - extern const char* const saslCommandDigestPasswordFieldName; + extern MONGO_CLIENT_API const char* const saslCommandDigestPasswordFieldName; } diff --git a/src/mongo/client/sasl_client_session.h b/src/mongo/client/sasl_client_session.h index 9316b7c84a1..776a3c02224 100644 --- a/src/mongo/client/sasl_client_session.h +++ b/src/mongo/client/sasl_client_session.h @@ -21,6 +21,7 @@ #include "mongo/base/disallow_copying.h" #include "mongo/base/status.h" #include "mongo/base/string_data.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -37,7 +38,7 @@ namespace mongo { * parameters must be UTF-8 encoded strings with no embedded NUL characters. The * parameterPassword parameter is not constrained. */ - class SaslClientSession { + class MONGO_CLIENT_API SaslClientSession { MONGO_DISALLOW_COPYING(SaslClientSession); public: /** diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h index 5994f8966cb..a74019c0318 100644 --- a/src/mongo/client/syncclusterconnection.h +++ b/src/mongo/client/syncclusterconnection.h @@ -22,6 +22,7 @@ #include "mongo/bson/bsonelement.h" #include "mongo/bson/bsonobj.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -39,7 +40,7 @@ namespace mongo { * The class checks if a command is read or write style, and sends to a single * node if a read lock command and to all in two phases with a write style command. */ - class SyncClusterConnection : public DBClientBase { + class MONGO_CLIENT_API SyncClusterConnection : public DBClientBase { public: using DBClientBase::query; @@ -138,7 +139,7 @@ namespace mongo { double _socketTimeout; }; - class UpdateNotTheSame : public UserException { + class MONGO_CLIENT_API UpdateNotTheSame : public UserException { public: UpdateNotTheSame( int code , const string& msg , const vector<string>& addrs , const vector<BSONObj>& lastErrors ) : UserException( code , msg ) , _addrs( addrs ) , _lastErrors( lastErrors ) { diff --git a/src/mongo/db/json.h b/src/mongo/db/json.h index d2d3b0a6f61..04c881fa77d 100644 --- a/src/mongo/db/json.h +++ b/src/mongo/db/json.h @@ -32,6 +32,7 @@ #include "mongo/bson/bsonobj.h" #include "mongo/base/status.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -48,10 +49,10 @@ namespace mongo { * @throws MsgAssertionException if parsing fails. The message included with * this assertion includes the character offset where parsing failed. */ - BSONObj fromjson(const std::string& str); + MONGO_CLIENT_API BSONObj fromjson(const std::string& str); /** @param len will be size of JSON object in text chars. */ - BSONObj fromjson(const char* str, int* len=NULL); + MONGO_CLIENT_API BSONObj fromjson(const char* str, int* len=NULL); /** * Parser class. A BSONObj is constructed incrementally by passing a diff --git a/src/mongo/logger/logger.h b/src/mongo/logger/logger.h index 11a739d7721..ca4821351da 100644 --- a/src/mongo/logger/logger.h +++ b/src/mongo/logger/logger.h @@ -15,6 +15,7 @@ #pragma once +#include "mongo/client/export_macros.h" #include "mongo/logger/message_log_domain.h" #include "mongo/logger/log_manager.h" #include "mongo/logger/rotatable_file_manager.h" @@ -30,7 +31,7 @@ namespace logger { /** * Gets a global singleton instance of LogManager. */ - LogManager* globalLogManager(); + MONGO_CLIENT_API LogManager* globalLogManager(); /** * Gets the global MessageLogDomain associated for the global log manager. diff --git a/src/mongo/logger/logstream_builder.h b/src/mongo/logger/logstream_builder.h index befd7bd19b3..9951b67abbe 100644 --- a/src/mongo/logger/logstream_builder.h +++ b/src/mongo/logger/logstream_builder.h @@ -20,6 +20,7 @@ #include <sstream> #include <string> +#include "mongo/client/export_macros.h" #include "mongo/logger/labeled_level.h" #include "mongo/logger/log_severity.h" #include "mongo/logger/message_log_domain.h" @@ -33,7 +34,7 @@ namespace logger { /** * Stream-ish object used to build and append log messages. */ - class LogstreamBuilder { + class MONGO_CLIENT_API LogstreamBuilder { public: static LogSeverity severityCast(int ll) { return LogSeverity::cast(ll); } static LogSeverity severityCast(LogSeverity ls) { return ls; } diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index e7ab0fd6777..2b3992cf584 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -66,7 +66,7 @@ namespace mongo { } void append( BSONObjBuilder& b , const char * m = "$err" , const char * c = "code" ) const ; std::string toString() const; - bool empty() const { return msg.empty(); } + bool empty() const { return msg.empty(); } void reset(){ msg = ""; code=-1; } std::string msg; int code; @@ -75,10 +75,10 @@ namespace mongo { /** helper class that builds error strings. lighter weight than a StringBuilder, albeit less flexible. NOINLINE_DECL used in the constructor implementations as we are assuming this is a cold code path when used. - example: + example: throw UserException(123, ErrorMsg("blah", num_val)); */ - class MONGO_CLIENT_API ErrorMsg { + class MONGO_CLIENT_API ErrorMsg { public: ErrorMsg(const char *msg, char ch); ErrorMsg(const char *msg, unsigned val); @@ -170,12 +170,13 @@ namespace mongo { MONGO_CLIENT_API MONGO_COMPILER_NORETURN void verifyFailed( const char *msg, const char *file, unsigned line); + MONGO_CLIENT_API MONGO_COMPILER_NORETURN void verifyFailed(const char *msg, const char *file, unsigned line); MONGO_CLIENT_API void wasserted(const char *msg, const char *file, unsigned line); MONGO_CLIENT_API MONGO_COMPILER_NORETURN void fassertFailed( int msgid ); MONGO_CLIENT_API MONGO_COMPILER_NORETURN void fassertFailedNoTrace( int msgid ); MONGO_CLIENT_API MONGO_COMPILER_NORETURN void fassertFailedWithStatus( int msgid, const Status& status); - + /** a "user assertion". throws UserAssertion. logs. typically used for errors that a user could cause, such as duplicate key, disk full, etc. */ @@ -186,8 +187,6 @@ namespace mongo { std::string. a stack trace is logged. */ MONGO_CLIENT_API MONGO_COMPILER_NORETURN void msgassertedNoTrace(int msgid, const char *msg); - MONGO_CLIENT_API MONGO_COMPILER_NORETURN void msgassertedNoTrace(int msgid, - const std::string& msg); MONGO_CLIENT_API MONGO_COMPILER_NORETURN void msgasserted(int msgid, const char *msg); MONGO_CLIENT_API MONGO_COMPILER_NORETURN void msgasserted(int msgid, const std::string &msg); diff --git a/src/mongo/util/concurrency/thread_name.h b/src/mongo/util/concurrency/thread_name.h index 4a32789dfef..850f3d1024b 100644 --- a/src/mongo/util/concurrency/thread_name.h +++ b/src/mongo/util/concurrency/thread_name.h @@ -18,6 +18,7 @@ #include <string> #include "mongo/base/string_data.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -30,6 +31,6 @@ namespace mongo { * Retrieves the name of the current thread, as previously set, or "" if no name was previously * set. */ - const std::string& getThreadName(); + MONGO_CLIENT_API const std::string& getThreadName(); } // namespace mongo diff --git a/src/mongo/util/logfile.h b/src/mongo/util/logfile.h index f2dcc29e663..62b3c2e9c4a 100644 --- a/src/mongo/util/logfile.h +++ b/src/mongo/util/logfile.h @@ -30,9 +30,11 @@ #pragma once +#include "mongo/client/export_macros.h" + namespace mongo { - class LogFile { + class MONGO_CLIENT_API LogFile { public: /** create the file and open. must not already exist. throws UserAssertion on i/o error diff --git a/src/mongo/util/mmap.h b/src/mongo/util/mmap.h index 3ae21857637..28b0cca861c 100644 --- a/src/mongo/util/mmap.h +++ b/src/mongo/util/mmap.h @@ -23,6 +23,7 @@ #include <boost/thread/xtime.hpp> +#include "mongo/client/export_macros.h" #include "mongo/util/concurrency/rwlock.h" #include "mongo/util/goodies.h" @@ -31,17 +32,17 @@ namespace mongo { extern const size_t g_minOSPageSizeBytes; void minOSPageSizeBytesTest(size_t minOSPageSizeBytes); // lame-o - class MAdvise { + class MAdvise { void *_p; unsigned _len; public: enum Advice { Sequential=1 , Random=2 }; - MAdvise(void *p, unsigned len, Advice a); + MAdvise(void *p, unsigned len, Advice a); ~MAdvise(); // destructor resets the range to MADV_NORMAL }; // lock order: lock dbMutex before this if you lock both - class LockMongoFilesShared { + class MONGO_CLIENT_API LockMongoFilesShared { friend class LockMongoFilesExclusive; static RWLockRecursiveNongreedy mmmutex; static unsigned era; @@ -49,10 +50,10 @@ namespace mongo { public: LockMongoFilesShared() : lk(mmmutex) { } - /** era changes anytime memory maps come and go. thus you can use this as a cheap way to check - if nothing has changed since the last time you locked. Of course you must be shared locked - at the time of this call, otherwise someone could be in progress. - + /** era changes anytime memory maps come and go. thus you can use this as a cheap way to check + if nothing has changed since the last time you locked. Of course you must be shared locked + at the time of this call, otherwise someone could be in progress. + This is used for yielding; see PageFaultException::touch(). */ static unsigned getEra() { return era; } @@ -61,10 +62,10 @@ namespace mongo { static void assertAtLeastReadLocked() { mmmutex.assertAtLeastReadLocked(); } }; - class LockMongoFilesExclusive { + class MONGO_CLIENT_API LockMongoFilesExclusive { RWLockRecursive::Exclusive lk; public: - LockMongoFilesExclusive() : lk(LockMongoFilesShared::mmmutex) { + LockMongoFilesExclusive() : lk(LockMongoFilesShared::mmmutex) { LockMongoFilesShared::era++; } }; @@ -92,7 +93,7 @@ namespace mongo { template < class F > static void forEach( F fun ); - /** note: you need to be in mmmutex when using this. forEach (above) handles that for you automatically. + /** note: you need to be in mmmutex when using this. forEach (above) handles that for you automatically. */ static std::set<MongoFile*>& getAllFiles(); @@ -128,7 +129,7 @@ namespace mongo { safe to call more than once, albeit might be wasted work ideal to call close to the close, if the close is well before object destruction */ - void destroyed(); + void destroyed(); virtual unsigned long long length() const = 0; }; @@ -139,7 +140,7 @@ namespace mongo { DurableMappedFile *a = finder.find("file_name_a"); DurableMappedFile *b = finder.find("file_name_b"); */ - class MongoFileFinder : boost::noncopyable { + class MONGO_CLIENT_API MongoFileFinder : boost::noncopyable { public: /** @return The MongoFile object associated with the specified file name. If no file is open with the specified name, returns null. @@ -152,7 +153,7 @@ namespace mongo { class MemoryMappedFile : public MongoFile { protected: - virtual void* viewForFlushing() { + virtual void* viewForFlushing() { if( views.size() == 0 ) return 0; verify( views.size() == 1 ); @@ -171,7 +172,7 @@ namespace mongo { // Throws exception if file doesn't exist. (dm may2010: not sure if this is always true?) void* map(const char *filename); - /** @param options see MongoFile::Options + /** @param options see MongoFile::Options */ void* mapWithOptions(const char *filename, int options); @@ -213,7 +214,7 @@ namespace mongo { HANDLE maphandle; std::vector<void *> views; unsigned long long len; - + #ifdef _WIN32 boost::shared_ptr<mutex> _flushMutex; void clearWritableBits(void *privateView); @@ -239,25 +240,25 @@ namespace mongo { p(*i); } -#if defined(_WIN32) +#if defined(_WIN32) class ourbitset { volatile unsigned bits[MemoryMappedFile::NChunks]; // volatile as we are doing double check locking public: - ourbitset() { + ourbitset() { memset((void*) bits, 0, sizeof(bits)); } - bool get(unsigned i) const { + bool get(unsigned i) const { unsigned x = i / 32; verify( x < MemoryMappedFile::NChunks ); return (bits[x] & (1 << (i%32))) != 0; } - void set(unsigned i) { + void set(unsigned i) { unsigned x = i / 32; wassert( x < (MemoryMappedFile::NChunks*2/3) ); // warn if getting close to limit verify( x < MemoryMappedFile::NChunks ); bits[x] |= (1 << (i%32)); } - void clear(unsigned i) { + void clear(unsigned i) { unsigned x = i / 32; verify( x < MemoryMappedFile::NChunks ); bits[x] &= ~(1 << (i%32)); diff --git a/src/mongo/util/net/httpclient.h b/src/mongo/util/net/httpclient.h index 163c73f09ff..6a762eabdd7 100644 --- a/src/mongo/util/net/httpclient.h +++ b/src/mongo/util/net/httpclient.h @@ -17,9 +17,8 @@ #pragma once -#include "mongo/pch.h" - #include "mongo/client/export_macros.h" +#include "mongo/pch.h" namespace mongo { diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h index 264a4bba7a7..32f6522152c 100644 --- a/src/mongo/util/time_support.h +++ b/src/mongo/util/time_support.h @@ -23,6 +23,7 @@ #include <boost/version.hpp> #include "mongo/base/status_with.h" +#include "mongo/client/export_macros.h" namespace mongo { @@ -95,9 +96,9 @@ namespace mongo { // parses time of day in "hh:mm" format assuming 'hh' is 00-23 bool toPointInTime( const std::string& str , boost::posix_time::ptime* timeOfDay ); - void sleepsecs(int s); - void sleepmillis(long long ms); - void sleepmicros(long long micros); + MONGO_CLIENT_API void sleepsecs(int s); + MONGO_CLIENT_API void sleepmillis(long long ms); + MONGO_CLIENT_API void sleepmicros(long long micros); class Backoff { public: diff --git a/src/mongo/util/timer.h b/src/mongo/util/timer.h index 12a19674b24..69f3a525216 100644 --- a/src/mongo/util/timer.h +++ b/src/mongo/util/timer.h @@ -17,6 +17,8 @@ #pragma once +#include "mongo/client/export_macros.h" + namespace mongo { /** @@ -30,7 +32,7 @@ namespace mongo { * 2.5 years will be supported. Since a typical tick duration will be under 10 per nanosecond, * if not below 1 per nanosecond, this should not be an issue. */ - class Timer /*copyable*/ { + class MONGO_CLIENT_API Timer /*copyable*/ { public: static const unsigned long long millisPerSecond = 1000; static const unsigned long long microsPerSecond = 1000 * millisPerSecond; |