summaryrefslogtreecommitdiff
path: root/modules/CIAO/DAnCE/NodeApplicationManager/ImplementationInfo.cpp
blob: af905369dcfa0bfea8a94dd8b32c0f9ce7f8b6f9 (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
//$Id$
#ifndef CIAO_IMPLEMENTATION_INFO_CPP
#define CIAO_IMPLEMENTATION_INFO_CPP

#include "ImplementationInfo.h"
#include "ciao/CIAO_ServerResourcesC.h"
#include "ace/SString.h"

CIAO::NodeImplementationInfoHandler::
NodeImplementationInfoHandler (const ::Deployment::DeploymentPlan & plan,
                               const Deployment::ComponentPlans & shared_components) :
  plan_ (plan),
  node_info_ (0),
  containers_info_map_ (plan, shared_components)
{
  ACE_NEW (node_info_, ::Deployment::NodeImplementationInfo);
  this->populate_server_resource_def ();
  this->populate_container_impl_infos ();
}

Deployment::NodeImplementationInfo *
CIAO::NodeImplementationInfoHandler::node_impl_info (void) const
{
  Deployment::NodeImplementationInfo_var retv;
  ACE_NEW_RETURN (retv,
                  Deployment::NodeImplementationInfo (this->node_info_.in ()),
                  0);
  return retv._retn ();
}

void
CIAO::NodeImplementationInfoHandler::populate_server_resource_def (void)
{
  CORBA::ULong const instance_len = plan_.instance.length ();
  const char * target_resource_id = 0;

  // Iterate over the instance list to find whether any server resource
  // has been specified
  // TODO: We shoud do some sanity check here, since all the component
  // instance in this NodeApplication should have the same "server_resource_def"
  // defined. Since currently we ignored this sanity check, then will allow
  // users to specify some self-conflicting configuration in the descriptor.

  // NW: this stuff is broken because it assumes all component
  // instances in a node will use the same ServerResource file.  This
  // is not the case.  Component instances using the same
  // ServerResource file will be deployed in the same NA.  However,
  // those using different ServerResource files should be deployed to
  // different NAs.  Something to be fixed later.
  for (CORBA::ULong i = 0; i < instance_len; ++i)
    {
      if (this->plan_.instance[i].deployedResource.length () != 0)
        {
          target_resource_id =
            this->plan_.instance[i].deployedResource[0].resourceName.in ();

          // Some component instance has server resource usage defined, so we
          // set the <nodeapp_config> field of the NodeImplementationInfo struct.
          for (CORBA::ULong j = 0; j < this->plan_.infoProperty.length (); ++j)
            {
              CIAO::DAnCE::ServerResource *server_resource_def = 0;
              this->plan_.infoProperty[j].value >>= server_resource_def;

              if (ACE_OS::strcmp ((*server_resource_def).Id,
                                  target_resource_id) == 0)
                {
                  // Found the target server resource def, and store it.
                  this->node_info_->nodeapp_config.length (1);

                  this->node_info_->nodeapp_config[0].name =
                    CORBA::string_dup ("CIAOServerResources");

                  this->node_info_->nodeapp_config[0].value <<=
                    *server_resource_def;
                  break;
                }
            }
        }
    }
}

void
CIAO::NodeImplementationInfoHandler::populate_container_impl_infos (void)
{
  CORBA::ULong const curr_len =
    this->containers_info_map_.containers_info ()->length ();

  ACE_UNUSED_ARG (curr_len);

  // assignment operation
  this->node_info_->impl_infos =
    *(this->containers_info_map_.containers_info ());
}

#endif /* CIAO_IMPLEMENTATION_INFO_CPP */