summaryrefslogtreecommitdiff
path: root/DAnCE/dance/LocalityManager/Handler/Config_Handler_Impl.cpp
blob: ba661da2c4ab72a2d05361cfa93860600dc08044 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// -*- C++ -*-
// TAO_IDL - Generated from
// be/be_codegen.cpp:1560

#include "tao/ORB_Core.h"
#include "Config_Handler_Impl.h"
#include "LocalityActivator_Impl.h"
#include "dance/LocalityManager/Scheduler/Plugin_Manager.h"

#include "dance/DAnCE_PropertiesC.h"

#ifdef GEN_OSTREAM_OPS
#include <iostream>
#include <sstream>
#endif /* GEN_OSTREAM_OPS */

namespace DAnCE
{
  const char *
  Config_Handler_Impl::instance_type_ =
    "edu.vanderbilt.dre.DAnCE.InstanceHandler";

  // Implementation skeleton constructor
  Config_Handler_Impl::
  Config_Handler_Impl (void)
  {
  }

  // Implementation skeleton destructor
  Config_Handler_Impl::~Config_Handler_Impl (void)
  {
  }

  ::CORBA::StringSeq *
  Config_Handler_Impl::dependencies (void)
  {
    ::CORBA::StringSeq *retval (0);
    ACE_NEW_THROW_EX (retval,
                      ::CORBA::StringSeq (0),
                      CORBA::NO_MEMORY ());
    return retval;
  }

  void
  Config_Handler_Impl::close (void)
  {

  }

  char * Config_Handler_Impl::instance_type (void)
  {
    DANCE_TRACE ("Config_Handler_Impl::instance_type");
    return CORBA::string_dup (Config_Handler_Impl::instance_type_);
  }

  void
  Config_Handler_Impl::install_instance (const ::Deployment::DeploymentPlan & plan,
                                       ::CORBA::ULong instanceRef,
                                       ::CORBA::Any_out instance_reference)
  {
    CORBA::Any *outany (0);
    ACE_NEW_THROW_EX (outany,
                      CORBA::Any (),
                      CORBA::NO_MEMORY ());
    instance_reference = outany;

    if (plan.instance.length () <= instanceRef)
      {
        DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, DLINFO
                      ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                      ACE_TEXT ("Invalid instance reference %u provided ")
                      ACE_TEXT ("to install_instance\n"),
                      instanceRef));
        throw ::Deployment::PlanError (plan.UUID.in (),
                                       "Invalid instance reference");
      }

    const ::Deployment::InstanceDeploymentDescription &idd =
      plan.instance[instanceRef];

    if (plan.implementation.length () <= idd.implementationRef)
      {
        DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, DLINFO
                      ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                      ACE_TEXT ("Invalid implementation reference %u provided ")
                      ACE_TEXT ("to install_instance\n"),
                      idd.implementationRef));
        throw ::Deployment::PlanError (plan.UUID.in (),
                                       "Invalid Implementation reference");
      }

    const ::Deployment::MonolithicDeploymentDescription &mdd =
      plan.implementation[idd.implementationRef];

    DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT,
                 (LM_TRACE, DLINFO
                  ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                  ACE_TEXT ("Starting installation of instance <%C>\n"),
                  idd.name.in ()));

    const char *entrypt (0);
    if (!DAnCE::Utility::get_property_value (DAnCE::DANCE_PLUGIN_ENTRYPT,
                                             mdd.execParameter,
                                             entrypt))
      {
        DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, DLINFO
                      ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                      ACE_TEXT ("No entrypoint found for plug-in initialization\n")));
        throw ::Deployment::StartError (idd.name.in (),
                                        "No entrypoint found for plug-in initialization\n");
      }

    const char *artifact (0);
    if (!DAnCE::Utility::get_property_value (DAnCE::DANCE_PLUGIN_ARTIFACT,
                                             mdd.execParameter,
                                             artifact))
      {
        DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, DLINFO
                      ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                      ACE_TEXT ("No artifact found for plug-in initialization\n")));
        throw ::Deployment::StartError (idd.name.in (),
                                        "No artifact found for plug-in initialization\n");
      }

    int open_mode = ACE_DEFAULT_SHLIB_MODE;
    if (!DAnCE::Utility::get_property_value (DAnCE::DANCE_PLUGIN_OPENMODE,
                                             mdd.execParameter,
                                             open_mode))
      {
        DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                     (LM_ERROR, DLINFO
                      ACE_TEXT ("Config_Handler_Impl::install_instance - ")
                      ACE_TEXT ("No open mode found for plug-in initialization\n")));
        throw ::Deployment::StartError (idd.name.in (),
                                        "No open mode found for plug-in initialization\n");
      }

    PLUGIN_MANAGER::instance ()->register_configuration_plugin (ACE_TEXT_CHAR_TO_TCHAR (artifact),
                                                                ACE_TEXT_CHAR_TO_TCHAR (entrypt),
                                                                open_mode);
  }

  void
  Config_Handler_Impl::remove_instance (const ::Deployment::DeploymentPlan &,
                                        ::CORBA::ULong,
                                        const ::CORBA::Any &)
  {
  }

  void
  Config_Handler_Impl::connect_instance (const ::Deployment::DeploymentPlan &,
                                       ::CORBA::ULong,
                                       const ::CORBA::Any &)
  {
    throw CORBA::NO_IMPLEMENT ();
  }

  void
  Config_Handler_Impl::disconnect_instance (const ::Deployment::DeploymentPlan &,
                                          ::CORBA::ULong)
  {
    throw CORBA::NO_IMPLEMENT ();
  }

  void
  Config_Handler_Impl::configure (const ::Deployment::Properties &prop)
  {
    ::DAnCE::Utility::PROPERTY_MAP pmap (prop.length ());

    ::DAnCE::Utility::build_property_map (pmap, prop);
  }
}

extern "C"
{
  ::DAnCE::InstanceDeploymentHandler_ptr create_Config_Handler (void)
  {
    return new DAnCE::Config_Handler_Impl ();
  }
}