Permalink
Browse files

Revision: 20268

  • Loading branch information...
1 parent f99c361 commit 939592a4923e02645872c4dd100983606ae841d0 @wangzhonnew wangzhonnew committed Oct 19, 2015
Showing 468 changed files with 169,486 additions and 7,638 deletions.
View
@@ -699,6 +699,7 @@ clientCEnv.Append( CPPDEFINES=[ "SDB_SSL" ] )
shellEnv.Append( CPPDEFINES=[ "SDB_SSL" ] )
if hasSSL:
env.Append( CPPDEFINES=[ "SDB_SSL" ] )
+ fapEnv.Append( CPPDEFINES=[ "SDB_SSL" ] )
env['INSTALL_DIR'] = installDir
if testEnv is not None:
Oops, something went wrong.
@@ -8,8 +8,9 @@ fapMongoFiles = [
"fap/mongodb/mongoConverter.cpp",
"fap/mongodb/mongoSession.cpp",
"fap/mongodb/msgBuffer.cpp",
- "fap/mongodb/mongodef.cpp",
- "fap/mongodb/mongoReplyHelper.cpp"
+ "fap/mongodb/mongoReplyHelper.cpp",
+ "fap/mongodb/baseCommand.cpp",
+ "fap/mongodb/parser.cpp"
]
rtnFiles = [
@@ -46,6 +47,6 @@ bsonFiles = [
#fapmongo = fapEnv.SharedLibrary( 'fapmongo', [ bsonFiles, pdFiles, utilFiles, rtnFiles, pmdFiles, monFiles, fapMongoFiles ] )
#fapmongo = fapEnv.SharedLibrary( 'fapmongo', [ bsonFiles, fapMongoFiles ] )
-fapmongo = fapEnv.SharedLibrary( 'fapmongo', [ pdFiles, fapMongoFiles ] )
+fapmongo = fapEnv.SharedLibrary( 'fapmongo', [ fapMongoFiles ] )
fapEnv.Install( '#/bin/fap', fapmongo )
@@ -84,7 +84,8 @@ namespace engine
}
// PD_TRACE_DECLARE_FUNCTION ( SDB_AUTHCB_AUTHENTICATE, "_authCB::authenticate" )
- INT32 _authCB::authenticate( BSONObj &obj, _pmdEDUCB *cb )
+ INT32 _authCB::authenticate( BSONObj &obj, _pmdEDUCB *cb,
+ BOOLEAN chkPasswd )
{
INT32 rc = SDB_OK ;
BSONObj hint ;
@@ -109,7 +110,8 @@ namespace engine
PD_LOG( PDDEBUG, "get authentication msg:[%s]",
obj.toString().c_str()) ;
- if ( SDB_OK != _valid( obj, FALSE ) )
+ if ( SDB_OK != _valid( obj, FALSE ) &&
+ SDB_OK != _validSource( obj, chkPasswd ) )
{
rc = SDB_INVALIDARG;
goto error ;
@@ -227,7 +229,7 @@ namespace engine
SDB_DMSCB *dmsCB = pmdGetKRCB()->getDMSCB() ;
SDB_DPSCB *dpsCB = pmdGetKRCB()->getDPSCB() ;
- rc = authenticate( obj, cb ) ;
+ rc = authenticate( obj, cb, FALSE ) ;
if ( SDB_OK != rc )
{
goto error ;
@@ -351,7 +353,8 @@ namespace engine
SDB_DMSCB *dmsCB = pmdGetKRCB()->getDMSCB() ;
SDB_DPSCB *dpsCB = pmdGetKRCB()->getDPSCB() ;
- if ( SDB_OK != _valid( obj, TRUE ) )
+ if ( SDB_OK != _valid( obj, TRUE ) &&
+ SDB_OK != _validSource( obj, TRUE ) )
{
rc = SDB_INVALIDARG ;
goto error ;
@@ -430,6 +433,51 @@ namespace engine
goto done ;
}
+ INT32 _authCB::_validSource( BSONObj &obj, BOOLEAN chkPasswd )
+ {
+ INT32 rc = SDB_OK ;
+ PD_TRACE_ENTRY ( SDB_AUTHCB__VALID ) ;
+ BSONElement usr, source, pass ;
+ if ( obj.isEmpty() )
+ {
+ goto error ;
+ }
+
+ if ( !obj.hasField( SDB_AUTH_SOURCE ) )
+ {
+ goto error ;
+ }
+
+ source = obj.getField( SDB_AUTH_SOURCE ) ;
+ if ( source.eoo() || String != source.type() ||
+ ( source.String().empty() ) )
+ {
+ goto error ;
+ }
+
+ usr = obj.getField( SDB_AUTH_USER ) ;
+ if ( usr.eoo() || String != usr.type() || ( usr.String().empty() ) )
+ {
+ goto error ;
+ }
+
+ if ( chkPasswd )
+ {
+ pass = obj.getField( SDB_AUTH_PASSWD ) ;
+ if ( pass.eoo() || String != pass.type() || ( pass.String().empty() ) )
+ {
+ goto error ;
+ }
+ }
+
+ done:
+ return rc ;
+ error:
+ rc = SDB_INVALIDARG ;
+ PD_LOG( PDDEBUG, "invalid obj of the auth[%s]",
+ obj.toString().c_str() ) ;
+ goto done ;
+ }
/*
get gloabl SDB_AUTHCB cb
*/
@@ -1391,7 +1391,7 @@ namespace engine
metaObj = _makeExtentMeta( pLobSU ) ;
pHeader->setMetaData( metaObj.objdata(), metaObj.objsize() ) ;
- rc = pLobData->readRaw( _curOffset, pHeader->_dataSize,
+ rc = pLobData->readRaw( cb, _curOffset, pHeader->_dataSize,
_pExtentBuff, readLen ) ;
if ( rc )
{
@@ -1438,7 +1438,7 @@ namespace engine
metaObj = _makeExtentMeta( pLobSU ) ;
pHeader->setMetaData( metaObj.objdata(), metaObj.objsize() ) ;
- rc = pLobData->readRaw( _curOffset, pHeader->_dataSize,
+ rc = pLobData->readRaw( cb, _curOffset, pHeader->_dataSize,
_pExtentBuff, readLen ) ;
if ( rc )
{
@@ -617,15 +617,77 @@ namespace bson {
inline void BSONElement::toString(StringBuilder& s, bool includeFieldName,
bool full ) const {
if ( includeFieldName && type() != EOO )
- s << "\"" << fieldName() << "\": ";
+ {
+ s << "\"" ;
+ int len = 0 ;
+ const char *tempData = fieldName() ;
+ len = strlen( tempData ) ;
+ for ( int i = 0; i < len; ++i )
+ {
+ switch( *tempData )
+ {
+ /*
+ the JSON standard does not need to be
+ escaped single quotation marks
+ */
+ /*case '\'':
+ {
+ s << "\\\'" ;
+ break ;
+ }*/
+ case '\"':
+ {
+ s << "\\\"" ;
+ break ;
+ }
+ case '\\':
+ {
+ s << "\\\\" ;
+ break ;
+ }
+ case '\b':
+ {
+ s << "\\b" ;
+ break ;
+ }
+ case '\f':
+ {
+ s << "\\f" ;
+ break ;
+ }
+ case '\n':
+ {
+ s << "\\n" ;
+ break ;
+ }
+ case '\r':
+ {
+ s << "\\r" ;
+ break ;
+ }
+ case '\t':
+ {
+ s << "\\t" ;
+ break ;
+ }
+ default:
+ {
+ s << (*tempData) ;
+ break ;
+ }
+ }
+ ++tempData ;
+ }
+ s << "\": " ;
+ }
switch ( type() ) {
case EOO:
s << "EOO";
break;
case bson::Date:
{
char buffer[64] ;
- time_t timer = (time_t)( date() / 1000 ) ;
+ time_t timer = (time_t)( ( (long long)date() ) / 1000 ) ;
struct tm psr ;
local_time ( &timer, &psr ) ;
memset ( buffer, 0, 64 ) ;
@@ -795,7 +857,7 @@ namespace bson {
Date_t date = timestampTime () ;
unsigned int inc = timestampInc () ;
char buffer[128] ;
- time_t timer = (time_t)(date.millis/1000) ;
+ time_t timer = (time_t)(((long long)date.millis)/1000) ;
struct tm psr ;
local_time ( &timer, &psr ) ;
memset ( buffer, 0, 128 ) ;
@@ -372,7 +372,7 @@ namespace bson {
}
Date_t timestampTime() const {
- unsigned long long t = ((unsigned int*)(value() + 4 ))[0];
+ long long t = ((int*)(value() + 4 ))[0];
return t * 1000;
}
unsigned int timestampInc() const {
@@ -486,20 +486,50 @@ namespace bson {
return *l.value() - *r.value();
case Timestamp:
{
- OpTime l_optime( l.date() ) ;
- OpTime r_optime( r.date() ) ;
- if ( l_optime < r_optime )
+ if ( Timestamp == r.type() )
{
- return -1 ;
+ OpTime l_optime( l.date() ) ;
+ OpTime r_optime( r.date() ) ;
+ if ( l_optime < r_optime )
+ {
+ return -1 ;
+ }
+
+ return l_optime == r_optime ? 0 : 1 ;
+ }
+ else
+ {
+ long long L_Macro = ( long long ) l.timestampTime()
+ + l.timestampInc() / 1000 ;
+ long long R_Macro = r.date() ;
+ if ( L_Macro - R_Macro != 0 )
+ {
+ return L_Macro > R_Macro ? 1 : -1 ;
+ }
+ return ( l.timestampInc() % 1000 ) > 0 ? 1 : 0 ;
}
-
- return l_optime == r_optime ? 0 : 1 ;
}
case Date:
{
- if ( l.date() < r.date() )
- return -1;
- return l.date() == r.date() ? 0 : 1;
+ if ( Date == r.type() )
+ {
+ long long iL = l.date() ;
+ long long iR = r.date() ;
+ if ( iL < iR )
+ return -1;
+ return iL == iR ? 0 : 1;
+ }
+ else
+ {
+ long long L_Macro = l.date() ;
+ long long R_Macro = ( long long ) r.timestampTime()
+ + r.timestampInc() / 1000 ;
+ if ( L_Macro - R_Macro != 0 )
+ {
+ return L_Macro > R_Macro ? 1 : -1 ;
+ }
+ return ( r.timestampInc() % 1000 ) > 0 ? -1 : 0 ;
+ }
}
case NumberLong:
if( r.type() == NumberLong ) {
@@ -118,8 +118,10 @@ namespace bson {
return !(*this == r);
}
bool operator<(const OpTime& r) const {
- if ( secs != r.secs )
- return secs < r.secs;
+ INT32 l_secs = ( INT32 ) secs ;
+ INT32 r_secs = ( INT32 ) r.secs ;
+ if ( l_secs != r_secs )
+ return l_secs < r_secs;
return i < r.i;
}
bool operator<=(const OpTime& r) const {
@@ -274,7 +274,7 @@ namespace engine
goto error ;
}
- rc = catGetCSGroupsFromCLs( csName, _pEduCB, groups ) ;
+ rc = catGetCSGroupsFromCLs( csName, _pEduCB, groups, TRUE ) ;
PD_RC_CHECK( rc, PDERROR, "Get collection space[%s] all groups failed, "
"rc: %d", csName, rc ) ;
@@ -354,7 +354,6 @@ namespace engine
if ( SDB_OK == rc && NULL != pReply )
{
rc = _pCatCB->netWork()->syncSend ( handle, pReply );
- SDB_OSS_FREE ( pReply );
}
else
{
@@ -371,6 +370,10 @@ namespace engine
PD_PACK_INT ( rc ) ) ;
rc = _pCatCB->netWork()->syncSend ( handle, &replyMsg );
}
+ if( pReply )
+ {
+ SDB_OSS_FREE ( pReply );
+ }
PD_TRACE_EXITRC ( SDB_CATALOGMGR_QUERYCATALOG, rc ) ;
return rc ;
error :
@@ -1519,7 +1522,7 @@ namespace engine
{
builder.append( CAT_SHARDING_PARTITION, clInfo._shardPartition ) ;
- builder.append( CAT_INTERNAL_VERSION, CAT_INTERNAL_VERSION_2 ) ;
+ builder.append( CAT_INTERNAL_VERSION, CAT_INTERNAL_VERSION_3 ) ;
}
}
if ( clInfo._isMainCL )
@@ -1099,7 +1099,8 @@ namespace engine
}
INT32 catGetCSGroupsFromCLs( const CHAR *csName, pmdEDUCB *cb,
- vector< UINT32 > &groups )
+ vector< UINT32 > &groups,
+ BOOLEAN includeSubCLGroups )
{
INT32 rc = SDB_OK ;
BSONObj matcher ;
@@ -1113,7 +1114,22 @@ namespace engine
std::stringstream ss ;
ss << "^" << csName << "\\." ;
- builder.appendRegex( CAT_COLLECTION_NAME, ss.str() ) ;
+
+ if ( FALSE == includeSubCLGroups )
+ {
+ builder.appendRegex( CAT_COLLECTION_NAME, ss.str() ) ;
+ }
+ else
+ {
+ BSONArrayBuilder orBuilder( builder.subarrayStart( "$or" ) ) ;
+ BSONObjBuilder nameObjBuilder( orBuilder.subobjStart() ) ;
+ nameObjBuilder.appendRegex( CAT_COLLECTION_NAME, ss.str() ) ;
+ nameObjBuilder.done() ;
+ BSONObjBuilder subCLObjBuilder( orBuilder.subobjStart() ) ;
+ subCLObjBuilder.appendRegex( CAT_MAINCL_NAME, ss.str() ) ;
+ subCLObjBuilder.done() ;
+ orBuilder.done() ;
+ }
matcher = builder.obj() ;
rc = rtnQuery( CAT_COLLECTION_INFO_COLLECTION, dummyObj, matcher,
Oops, something went wrong.

0 comments on commit 939592a

Please sign in to comment.