本文整理汇总了C++中KEY::instances方法的典型用法代码示例。如果您正苦于以下问题:C++ KEY::instances方法的具体用法?C++ KEY::instances怎么用?C++ KEY::instances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KEY
的用法示例。
在下文中一共展示了KEY::instances方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finalize_sub_plan
void Locality_Splitter::finalize_sub_plan (
Deployment::DeploymentPlan &sub_plan,
KEY &sub_plan_key)
{
DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan");
// check for availability of LocalityManager instance
if (!sub_plan_key.has_locality_manager ())
{
// add minimal default LocalityManager instance to sub plan
uint32_t impl_index = sub_plan.implementation ().size ();
sub_plan.implementation ().push_back (::Deployment::MonolithicDeploymentDescription ());
uint32_t inst_index = sub_plan.instance ().size ();
sub_plan.instance ().push_back (::Deployment::InstanceDeploymentDescription ());
sub_plan.instance ().back ().implementationRef (impl_index);
// set correct implementation type
Deployment::Property exec_property;
exec_property.name (IMPL_TYPE);
exec_property.value () <<= DANCE_LOCALITYMANAGER;
sub_plan.implementation ().back ().execParameter ().push_back (exec_property);
// create unique name for Locality Manager
ACE_Utils::UUID uuid;
ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);
std::string lm_name ("Locality Manager [");
lm_name += uuid.to_string ()->c_str ();
lm_name += "]";
sub_plan.instance ().back ().name (lm_name);
DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan - " <<
"No locality manager found, created a default locality named<" <<
sub_plan.instance ().back ().name () << ">");
// add instance to sub plan key
sub_plan_key.add_instance (inst_index);
// mark as locality manager
sub_plan_key.locality_manager_instance (
sub_plan_key.instances ().size () - 1);
}
}
示例2: prepare_sub_plan
void Locality_Splitter::prepare_sub_plan (
uint32_t instance,
Deployment::DeploymentPlan &sub_plan,
KEY &sub_plan_key)
{
DANCEX11_LOG_TRACE ("Locality_Splitter::prepare_sub_plan");
// first time?
if (sub_plan_key.uuid ().empty ())
{
// use UUID to uniquely identify sub plan key
sub_plan_key.uuid (sub_plan.UUID ());
}
if (sub_plan_key.node () != this->plan_.instance ()[instance].node ())
{
// set sub plan key to node name for instance
sub_plan_key.node (this->plan_.instance ()[instance].node ());
}
if (!sub_plan_key.has_instance (instance))
{
sub_plan_key.add_instance (instance);
if (!sub_plan_key.has_locality_manager ())
{
// check if this is the LocalityManager instance
uint32_t impl_idx =
this->plan_.instance ()[instance].implementationRef ();
if (impl_idx >= this->plan_.implementation ().size ())
{
DANCEX11_LOG_ERROR ("Locality_Splitter::prepare_sub_plan - " <<
"Invalid implementation index");
}
else
{
const std::string instance_type =
DAnCE::Utility::get_instance_type (
plan_.implementation ()[impl_idx].execParameter ());
if (!instance_type.empty ())
{
if (instance_type == DANCE_LOCALITYMANAGER)
{
// mark locality manager instance offset
sub_plan_key.locality_manager_instance (
sub_plan_key.instances ().size () - 1);
DANCEX11_LOG_TRACE ("Locality_Splitter::prepare_sub_plan - " <<
"Found locality manager instance " <<
instance << ":" << plan_.instance ()[instance].name ());
}
}
}
}
}
if (sub_plan.label ().empty ())
{
// derive descriptive label
std::string sub_label ("Split plan from ");
if (!this->plan_.label ().empty ())
{
sub_label += this->plan_.label ();
}
else
{
sub_label += this->plan_.UUID ();
}
sub_label += " for a Locality on Node ";
sub_label += sub_plan_key.node ();
sub_plan.label (sub_label);
}
}
示例3: match_sub_plan
bool Locality_Splitter::match_sub_plan (
uint32_t instance,
const KEY &sub_plan_key) const
{
DANCEX11_LOG_TRACE ("Locality_Splitter::match_sub_plan");
// check if the node for the instance matches the sub plan
bool match =
(sub_plan_key.node () == this->plan_.instance ()[instance].node ());
// if the node matches see if the instance is or can be included in the
// sub plan
if (match)
{
if (sub_plan_key.has_instance (instance)) return true; // matches
// see if the locality constraints allow this instance to be
// included in this sub plan
uint32_t num_localities = this->plan_.localityConstraint ().size ();
for (uint32_t l = 0; l < num_localities; ++l)
{
const Deployment::PlanLocality &ploc =
this->plan_.localityConstraint ()[l];
// only interested in real constraints
if (ploc.constraint () != Deployment::PlanLocalityKind::PlanNoConstraint)
{
// see if the instance we're matching is
// included in this constraint
bool apply_constraint = false;
for (uint32_t i = 0;
i < ploc.constrainedInstanceRef ().size ();
++i)
{
apply_constraint =
ploc.constrainedInstanceRef ()[i] == instance;
if (apply_constraint)
break;
}
if (ploc.constraint () == Deployment::PlanLocalityKind::PlanDifferentProcess)
{
if (apply_constraint) // in case the constraint applies
{
// check if there are no incompatible
// instances already in
// the sub plan we're matching
for (uint32_t i = 0;
i < ploc.constrainedInstanceRef ().size ();
++i)
{
if (ploc.constrainedInstanceRef ()[i] != instance)
{
uint32_t incompatible_instance =
ploc.constrainedInstanceRef ()[i];
if (sub_plan_key.has_instance (
incompatible_instance))
{
// sub plan includes an instance which
// is constrained to a different locality
return false;
}
}
}
}
// in case the constraint does not apply to the instance
// we're matching forget about it
}
else // Deployment::PlanSameProcess
{
if (apply_constraint) // in case the constraint applies
{
// check to see that all instances included in the
// sub plan also comply with this constraint
// since if one complies with the constraint
// than all should, it is enough to test the first
// instance in the sub plan
if (!sub_plan_key.instances ().empty ())
{
uint32_t first_inst_nr =
sub_plan_key.instances ().front ();
bool included = false;
for (uint32_t j = 0;
j < ploc.constrainedInstanceRef ().size ();
++j)
{
if (first_inst_nr ==
ploc.constrainedInstanceRef ()[j])
{
included = true;
break;
}
}
if (!included)
{
// sub plan includes instance(s) which do(es)
// not comply with this constraint
return false;
}
}
}
//.........这里部分代码省略.........