mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of ssh://aaron@git.10gen.com/data/gitroot/p
This commit is contained in:
commit
c2cde25267
@ -6,7 +6,7 @@
|
||||
|
||||
# some common tasks
|
||||
# build 64-bit mac and pushing to s3
|
||||
# scons --64 --dist=osx-x86_64 s3dist
|
||||
# scons --64 s3dist
|
||||
# all s3 pushes require settings.py
|
||||
|
||||
import os
|
||||
@ -184,6 +184,7 @@ if "darwin" == os.sys.platform:
|
||||
elif "linux2" == os.sys.platform:
|
||||
useJavaHome = True
|
||||
javaOS = "linux"
|
||||
platform = "linux"
|
||||
|
||||
if not os.path.exists( javaHome ):
|
||||
#fedora standarm jvm location
|
||||
@ -637,6 +638,7 @@ distFile = installDir + ".tgz"
|
||||
env.Append( TARFLAGS=" -z " )
|
||||
env.Tar( distFile , installDir )
|
||||
|
||||
env.Alias( "dist" , distFile )
|
||||
env.Alias( "s3dist" , [ "install" , distFile ] , [ s3dist ] )
|
||||
env.AlwaysBuild( "s3dist" )
|
||||
|
||||
|
@ -516,6 +516,11 @@ namespace mongo {
|
||||
|
||||
class DBClientPaired;
|
||||
|
||||
class ConnectException : public UserException {
|
||||
public:
|
||||
ConnectException(string msg) : UserException(msg) { }
|
||||
};
|
||||
|
||||
/**
|
||||
A basic connection to the database.
|
||||
This is the main entry point for talking to a simple Mongo setup
|
||||
@ -539,7 +544,7 @@ namespace mongo {
|
||||
DBClientConnection(bool _autoReconnect=false,DBClientPaired* cp=0) :
|
||||
clientPaired(cp), failed(false), autoReconnect(_autoReconnect), lastReconnectTry(0) { }
|
||||
|
||||
/**Connect to a Mongo database server.
|
||||
/** Connect to a Mongo database server.
|
||||
|
||||
If autoReconnect is true, you can try to use the DBClientConnection even when
|
||||
false was returned -- it will try to connect again.
|
||||
@ -550,6 +555,20 @@ namespace mongo {
|
||||
*/
|
||||
virtual bool connect(const char *serverHostname, string& errmsg);
|
||||
|
||||
/** Connect to a Mongo database server. Exception throwing version.
|
||||
Throws a UserException if cannot connect.
|
||||
|
||||
If autoReconnect is true, you can try to use the DBClientConnection even when
|
||||
false was returned -- it will try to connect again.
|
||||
|
||||
@param serverHostname host to connect to. can include port number ( 127.0.0.1 , 127.0.0.1:5555 )
|
||||
*/
|
||||
void connect(string serverHostname) {
|
||||
string errmsg;
|
||||
if( !connect(serverHostname.c_str(), errmsg) )
|
||||
throw new ConnectException(string("can't connect ") + errmsg);
|
||||
}
|
||||
|
||||
virtual bool auth(const char *dbname, const char *username, const char *pwd, string& errmsg, bool digestPassword = true);
|
||||
|
||||
virtual auto_ptr<DBClientCursor> query(const char *ns, Query query, int nToReturn = 0, int nToSkip = 0,
|
||||
|
20
client/examples/tutorial.cpp
Normal file
20
client/examples/tutorial.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include "client/dbclient.h"
|
||||
|
||||
// g++ -I ../.. -L ../.. tutorial.cpp -lmongoclient -lboost_thread -lboost_filesystem
|
||||
|
||||
using namespace mongo;
|
||||
|
||||
void run() {
|
||||
DBClientConnection c;
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
run();
|
||||
} catch( DBException &e ) {
|
||||
cout << "caught " << e.what() << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -678,7 +678,7 @@ namespace mongo {
|
||||
_runCommands(ns, o, ss, bb, ob, true, 0);
|
||||
}
|
||||
}
|
||||
catch ( UserAssertionException& e ) {
|
||||
catch ( UserException& e ) {
|
||||
log() << "sync: caught user assertion " << e.msg << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ namespace NamespaceTests {
|
||||
|
||||
BSONObjSetDefaultOrder keys;
|
||||
ASSERT_EXCEPTION( id().getKeysFromObject( b.done(), keys ),
|
||||
UserAssertionException );
|
||||
UserException );
|
||||
}
|
||||
private:
|
||||
virtual BSONObj key() const {
|
||||
|
@ -94,16 +94,16 @@ namespace PairingTests {
|
||||
checkFields( rp3, "", "", DBPort, "bar" );
|
||||
|
||||
ASSERT_EXCEPTION( ReplPair( "foo:", "bar" ),
|
||||
UserAssertionException );
|
||||
UserException );
|
||||
|
||||
ASSERT_EXCEPTION( ReplPair( "foo:0", "bar" ),
|
||||
UserAssertionException );
|
||||
UserException );
|
||||
|
||||
ASSERT_EXCEPTION( ReplPair( "foo:10000000", "bar" ),
|
||||
UserAssertionException );
|
||||
UserException );
|
||||
|
||||
ASSERT_EXCEPTION( ReplPair( "foo", "" ),
|
||||
UserAssertionException );
|
||||
UserException );
|
||||
}
|
||||
private:
|
||||
void checkFields( const ReplPair &rp,
|
||||
|
@ -69,7 +69,7 @@ namespace mongo {
|
||||
RARELY log() << "User Assertion " << msg << endl;
|
||||
lastAssert[3].set(msg, getDbContext().c_str(), "", 0);
|
||||
raiseError(msg);
|
||||
throw UserAssertionException(msg);
|
||||
throw UserException(msg);
|
||||
}
|
||||
|
||||
void msgasserted(const char *msg) {
|
||||
|
8
stdafx.h
8
stdafx.h
@ -129,13 +129,13 @@ namespace mongo {
|
||||
virtual const char* what() const throw() { return msg.c_str(); }
|
||||
};
|
||||
|
||||
/* we use the same mechanism for bad things the user does -- which are really just errors */
|
||||
class UserAssertionException : public AssertionException {
|
||||
/* UserExceptions are valid errors that a user can cause, like out of disk space or duplicate key */
|
||||
class UserException : public AssertionException {
|
||||
public:
|
||||
UserAssertionException(const char *_msg) {
|
||||
UserException(const char *_msg) {
|
||||
msg = _msg;
|
||||
}
|
||||
UserAssertionException(string _msg) {
|
||||
UserException(string _msg) {
|
||||
msg = _msg;
|
||||
}
|
||||
virtual bool severe() {
|
||||
|
Loading…
Reference in New Issue
Block a user