本文整理汇总了C++中ShardingState::getChunkMatcher方法的典型用法代码示例。如果您正苦于以下问题:C++ ShardingState::getChunkMatcher方法的具体用法?C++ ShardingState::getChunkMatcher怎么用?C++ ShardingState::getChunkMatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShardingState
的用法示例。
在下文中一共展示了ShardingState::getChunkMatcher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
if ( errmsg.size() ){
return false;
}
string ns = cmdObj["setShardVersion"].valuestrsafe();
if ( ns.size() == 0 ){
errmsg = "need to speciy fully namespace";
return false;
}
ConfigVersion& oldVersion = info->getVersion(ns);
ConfigVersion& globalVersion = shardingState.getVersion(ns);
if ( oldVersion > 0 && globalVersion == 0 ){
// this had been reset
oldVersion = 0;
}
if ( version == 0 && globalVersion == 0 ){
// this connection is cleaning itself
oldVersion = 0;
return 1;
}
// SERVER-1633
laps.push_back( timer.millis() );
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 0;
}
log() << "wiping data for: " << ns << endl;
result.appendTimestamp( "beforeDrop" , globalVersion );
// only setting global version on purpose
// need clients to re-find meta-data
globalVersion = 0;
oldVersion = 0;
return 1;
}
if ( version < oldVersion ){
errmsg = "you already have a newer version";
result.appendTimestamp( "oldVersion" , oldVersion );
result.appendTimestamp( "newVersion" , version );
result.appendTimestamp( "globalVersion" , globalVersion );
return false;
}
// SERVER-1633
laps.push_back( timer.millis() );
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;
}
// SERVER-1633
laps.push_back( timer.millis() );
{
dbtemprelease unlock;
shardingState.getChunkMatcher( ns );
}
result.appendTimestamp( "oldVersion" , oldVersion );
oldVersion = version;
globalVersion = version;
// SERVER-1633
ostringstream lapString;
lapString << name /* command name */ << " partials: " ;
for (size_t i = 1; i<laps.size(); ++i){
lapString << (laps[i] - laps[i-1]) / 1000 << " ";
}
lapString << endl;
logIfSlow( timer, lapString.str() );
result.append( "ok" , 1 );
return 1;
}