summaryrefslogtreecommitdiff
path: root/DAnCE/tools/Split_Plan/Node_Splitter.cpp
blob: 8c7af3a1621670268b6805dadb5e6192c704c4a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "Node_Splitter.h"
#include "dance/Logger/Log_Macros.h"

namespace DAnCE
{
  Node_Splitter::Node_Splitter (const Deployment::DeploymentPlan &plan)
    : plan_ (plan)
    {
    }

  bool Node_Splitter::match_instance (CORBA::ULong instance,
                                      const FILTER &filter) const
    {
      if (filter.is_empty ()) return true;

      return ACE_OS::strcmp (filter.c_str (),
                             this->plan_.instance[instance].node.in ()) == 0;
    }

  bool Node_Splitter::match_sub_plan (CORBA::ULong instance,
                                      const KEY &sub_plan_key) const
    {
      return ACE_OS::strcmp (sub_plan_key.c_str (),
                             this->plan_.instance[instance].node.in ()) == 0;
    }

  void Node_Splitter::prepare_sub_plan (CORBA::ULong instance,
                                        Deployment::DeploymentPlan &sub_plan,
                                        KEY &sub_plan_key)
    {
      if (ACE_OS::strcmp (sub_plan_key.c_str (),
                          this->plan_.instance[instance].node.in ()) != 0)
        {
          // set sub plan key to node name for instance
          sub_plan_key = this->plan_.instance[instance].node.in ();
        }

      if (ACE_OS::strlen (sub_plan.label.in ()) == 0)
        {
          // derive descriptive label
          ACE_CString sub_label ("Split plan from ");
          if (this->plan_.label.in ())
            {
              sub_label += this->plan_.label.in ();
            }
          else
            {
              sub_label += this->plan_.UUID.in ();
            }
          sub_label += " for Node ";
          sub_label += sub_plan_key;
          sub_plan.label = CORBA::string_dup (sub_label.c_str ());
        }
    }

  void Node_Splitter::finalize_sub_plan (Deployment::DeploymentPlan & /*sub_plan*/,
                                         KEY & /*sub_plan_key*/)
    {
      // nothing to do
    }
}