summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/TargetManager/DomainDataManager.cpp
blob: 57130b90fa4f43a0b0a610e8a9858dbc03d72e59 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// $Id$
//===============================================================
/**
 * @file DomainDataManager.cpp
 *
 * @brief Maintains the Domain Information
 *
 * It contains the entire Domain information.Both the
 * initial domain as well as the current available domain.
 *
 * @author Nilabja Roy nilabjar@dre.vanderbilt.edu
 */
//===============================================================
#include "DomainDataManager.h"

#include "Config_Handlers/DD_Handler.h"
#include "Config_Handlers/DnC_Dump.h"
#include "ciao/CIAO_common.h"

const char * domain_file_name = "Domain.cdd";

int CIAO::DomainDataManager::update_domain (const ::CORBA::StringSeq &,
                                      const ::Deployment::Domain & domainSubset,
                                      ::Deployment::DomainUpdateKind )
{
  // Update the subset of the domain which the above
  // parameter corresponds to

  // for now consider only nodes
  if (CIAO::debug_level () > 9)
    {
      ACE_DEBUG ((LM_DEBUG , "Inside The update Domain of Manager\n"));
      ACE_DEBUG ((LM_DEBUG , "the length of domain is [%d]",
                  current_domain_.node.length ()));
      ACE_DEBUG ((LM_DEBUG , "domainSubsetNode is \n" ));
    }
  int size = current_domain_.node.length ();
  int i;
  for (i=0;i < size;i++)
    {
      if (!strcmp (domainSubset.node[0].name , current_domain_.node[i].name))
        {
          // found a match
          // for now overwrite the entire Node info ...
          // but later , this has to be changed to overwrite
          // only the specific part ...
          if (CIAO::debug_level () > 9)
            {
              ACE_DEBUG ((LM_DEBUG , "Changed the memory Value\n"));
            }
          current_domain_.node[i] = domainSubset.node[0];
          break; // finished job ...break
        }
    }

  if (i == size)
    {
      // thus the node is new .. add it to current_domain_
      // later change it ...
      current_domain_.node.length (size+1);
      current_domain_.node[size]=domainSubset.node[0];
    }
  if (CIAO::debug_level () > 9)
    {
      ACE_DEBUG ((LM_DEBUG , "Inside The update Domain of Manager\n"));
    }
  return 0;
}

CIAO::DomainDataManager::
DomainDataManager (CORBA::ORB_ptr orb,
                   ::Deployment::TargetManager_ptr target)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    deployment_config_ (orb_.in()),
    target_mgr_ (::Deployment::TargetManager::_duplicate(target))
{
  CIAO::Config_Handlers::DD_Handler dd (domain_file_name);
  ::Deployment::Domain* dmn = dd.domain_idl ();
  ::Deployment::DnC_Dump::dump (*dmn);
  current_domain_ = *dmn;
  initial_domain_ = current_domain_;

  call_all_node_managers ();
}

::Deployment::Domain* CIAO::DomainDataManager::get_current_domain ()
{
  ::Deployment::Domain * retval = new ::Deployment::Domain (current_domain_);
  return retval;
}

::Deployment::Domain* CIAO::DomainDataManager::get_initial_domain ()
{
  ::Deployment::Domain * retval = new ::Deployment::Domain (initial_domain_);
  return retval;
}

int CIAO::DomainDataManager::readin_domain_data ()
{
  // here read in Domain data ...
  //
  return 0;
}

int CIAO::DomainDataManager::call_all_node_managers ()
{
  if ( this->deployment_config_.init ("NodeDetails.dat") == -1 )
    {
      ACE_ERROR ((LM_ERROR,
                  "TargetM (%P|%t) DomainDataManager.cpp -"
                  "CIAO::DomainDataManager::call_all_node_managers -"
                  "ERROR while trying to initialize after reading "
                  "node details DAT file \n"));
      return 0;
    }

  int length = initial_domain_.node.length ();
  for (int i=0;i < length;i++)
    {
      ::Deployment::NodeManager_var node_manager =
          deployment_config_.get_node_manager (initial_domain_.node[i].name);
      if (node_manager.in () != 0)
        {
          Deployment::Logger_ptr log =
            Deployment::Logger::_nil ();
          ::Deployment::Domain sub_domain;
          sub_domain.UUID = CORBA::string_dup("Node-Level-domain");
          sub_domain.label = CORBA::string_dup("Node-level-domain");
          sub_domain.sharedResource.length(0);
          sub_domain.interconnect.length(0);
          sub_domain.bridge.length(0);
          sub_domain.infoProperty.length(0);
          sub_domain.node.length (1);
          sub_domain.node[0] = initial_domain_.node[i];
          try
            {
              node_manager->joinDomain (sub_domain , target_mgr_.in (), log);
            }
          catch (CORBA::Exception&)
            {
              ACE_DEBUG ((LM_DEBUG , "Error in calling Join Domain==\n"));
            }
        }
    }
  return 0;

}