本文整理汇总了C++中ShardingState::getShardChunkManager方法的典型用法代码示例。如果您正苦于以下问题:C++ ShardingState::getShardChunkManager方法的具体用法?C++ ShardingState::getShardChunkManager怎么用?C++ ShardingState::getShardChunkManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShardingState
的用法示例。
在下文中一共展示了ShardingState::getShardChunkManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
else {
OID clientId = cmdObj["serverID"].__oid();
if ( ! info->hasID() ){
info->setID( clientId );
}
else if ( clientId != info->getID() ){
errmsg = "server id has changed!";
return 0;
}
}
}
unsigned long long version = extractVersion( cmdObj["version"] , errmsg );
if ( errmsg.size() ){
return false;
}
string ns = cmdObj["setShardVersion"].valuestrsafe();
if ( ns.size() == 0 ){
errmsg = "need to speciy fully namespace";
return false;
}
const ConfigVersion oldVersion = info->getVersion(ns);
const ConfigVersion globalVersion = shardingState.getVersion(ns);
if ( oldVersion > 0 && globalVersion == 0 ){
// this had been reset
info->setVersion( ns , 0 );
}
if ( version == 0 && globalVersion == 0 ){
// this connection is cleaning itself
info->setVersion( ns , 0 );
return true;
}
if ( version == 0 && globalVersion > 0 ){
if ( ! authoritative ){
result.appendBool( "need_authoritative" , true );
result.appendTimestamp( "globalVersion" , globalVersion );
result.appendTimestamp( "oldVersion" , oldVersion );
errmsg = "dropping needs to be authoritative";
return false;
}
log() << "wiping data for: " << ns << endl;
result.appendTimestamp( "beforeDrop" , globalVersion );
// only setting global version on purpose
// need clients to re-find meta-data
shardingState.setVersion( ns , 0 );
info->setVersion( ns , 0 );
return true;
}
if ( version < oldVersion ){
errmsg = "you already have a newer version";
result.appendTimestamp( "oldVersion" , oldVersion );
result.appendTimestamp( "newVersion" , version );
result.appendTimestamp( "globalVersion" , globalVersion );
return false;
}
if ( version < globalVersion ){
while ( shardingState.inCriticalMigrateSection() ){
dbtemprelease r;
sleepmillis(2);
log() << "waiting till out of critical section" << endl;
}
errmsg = "going to older version for global";
result.appendTimestamp( "version" , version );
result.appendTimestamp( "globalVersion" , globalVersion );
return false;
}
if ( globalVersion == 0 && ! cmdObj.getBoolField( "authoritative" ) ){
// need authoritative for first look
result.appendBool( "need_authoritative" , true );
result.append( "ns" , ns );
errmsg = "first time for this ns";
return false;
}
result.appendTimestamp( "oldVersion" , oldVersion );
result.append( "ok" , 1 );
info->setVersion( ns , version );
shardingState.setVersion( ns , version );
// TODO SERVER-1849 pending drop work
// getShardChunkManager is assuming that the setVersion above were valid
// ideally, we'd call getShardChunkManager first, verify that 'version' is sound, and then update
// connection and global state
{
dbtemprelease unlock;
shardingState.getShardChunkManager( ns );
}
return true;
}