本文整理汇总了C++中NodeSet::Union方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet::Union方法的具体用法?C++ NodeSet::Union怎么用?C++ NodeSet::Union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeSet
的用法示例。
在下文中一共展示了NodeSet::Union方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTargetNodes
void PreferredLocationConstraint::GetTargetNodes(
TempSolution const& tempSolution,
PlacementReplica const* replica,
NodeSet & candidateNodes,
NodeToConstraintDiagnosticsDataMapSPtr const nodeToConstraintDiagnosticsDataMapSPtr) const
{
UNREFERENCED_PARAMETER(nodeToConstraintDiagnosticsDataMapSPtr);
PartitionEntry const* partition = replica->Partition;
if (partition->Service->OnEveryNode)
{
return;
}
bool hasPreferredLocations = partition->ExistsUpgradeLocation || !partition->StandByLocations.empty();
set<Common::TreeNodeIndex> const& upgradedUDs = PreferredLocationConstraint::GetUpgradedUDs(tempSolution, partition);
bool hasUpgradCompletedUDs = !upgradedUDs.empty();
if (replica->IsNew && !hasPreferredLocations && !hasUpgradCompletedUDs)
{
return;
}
// Use prefer locations if exist, otherwise, use completed UDs
NodeSet nodesUpgradedUDs(candidateNodes);
if (!hasPreferredLocations && hasUpgradCompletedUDs)
{
// Only prefer upgraded nodes if SB/Upgrade location is empty
nodesUpgradedUDs.Filter([&](NodeEntry const *node) -> bool
{
return CheckUpgradedUDs(upgradedUDs, node);
});
}
candidateNodes.Intersect([=](function<void(NodeEntry const *)> f)
{
// During singleton replica upgrade, there could be replicas which are not in upgrade,
// but are correlated to the ones that are in upgrade (affinity or scaleout),
// and need to be moved together with replicas which are in upgrade
if ((partition->IsInUpgrade || partition->IsInSingletonReplicaUpgradeOptimization()) && partition->ExistsUpgradeLocation)
{
if (partition->PrimaryUpgradeLocation)
{
f(partition->PrimaryUpgradeLocation);
}
else
{
for (auto it = partition->SecondaryUpgradeLocations.begin(); it != partition->SecondaryUpgradeLocations.end(); ++it)
{
f(*it);
}
}
}
for (auto itNode = partition->StandByLocations.begin(); itNode != partition->StandByLocations.end(); ++itNode)
{
f(*itNode);
}
partition->ForEachExistingReplica([&f](PlacementReplica const* r)
{
f(r->Node);
}, true, false);
});
if (!hasPreferredLocations && hasUpgradCompletedUDs)
{
candidateNodes.Union(nodesUpgradedUDs);
}
}