本文整理汇总了C++中Shard::moveAndCommit方法的典型用法代码示例。如果您正苦于以下问题:C++ Shard::moveAndCommit方法的具体用法?C++ Shard::moveAndCommit怎么用?C++ Shard::moveAndCommit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shard
的用法示例。
在下文中一共展示了Shard::moveAndCommit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveIfShould
bool Shard::moveIfShould( Shard * newShard ){
Shard * toMove = 0;
if ( newShard->countObjects() <= 1 ){
toMove = newShard;
}
else if ( this->countObjects() <= 1 ){
toMove = this;
}
else {
log(1) << "don't know how to decide if i should move inner shard" << endl;
}
if ( ! toMove )
return false;
string newLocation = grid.pickServerForNewDB();
if ( newLocation == getServer() ){
// if this is the best server, then we shouldn't do anything!
log(1) << "not moving shard: " << toString() << " b/c would move to same place " << newLocation << " -> " << getServer() << endl;
return 0;
}
log() << "moving shard (auto): " << toMove->toString() << " to: " << newLocation << " #objcets: " << toMove->countObjects() << endl;
string errmsg;
massert( (string)"moveAndCommit failed: " + errmsg ,
toMove->moveAndCommit( newLocation , errmsg ) );
return true;
}