summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/TargetManager/DomainDataManager.h
blob: 2e39022dce4fb6c30cc5de0da5862f156c4c09e2 (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
// $Id$
//===============================================================
/**
 * @file DomainDataManager.h
 *
 * @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
 */
//===============================================================
#ifndef DOMAIN_DATA_MGRH
#define DOMAIN_DATA_MGRH

#include "TargetManagerImplC.h"
#include "Deployment_Configuration.h"

/**
 * @namespace CIAO
 *
 * @brief The main CIAO namespace
 *
 */
namespace CIAO
{
  /**
   * @class DomainDataManager
   *
   * @brief Responsible for maintaining the Domain Information
   *
   * It maintains both the Current Domain Information as well
   * as the Initial domain at full capacity.
   */
  class DomainDataManager
    {

      public :
        /**
         * @operation updateDomain
         * @brief     This function is called by the other classes to update
         *            current domain data.
         * @param     elements The string sequence of elements
         *            being updated
         * @param     domainSubset The subset of the actual Domain to be updated
         * @param     updateKind Specifies the update type eg. add, delete, update
         *
         */
        int update_domain (const ::CORBA::StringSeq & elements,
                           const ::Deployment::Domain & domainSubset,
                           ::Deployment::DomainUpdateKind updateKind
                           );
      /**
       * @operation    getInitialDomain
       * @brief        This function is called the Executor code
       *               to get the Original Domain data.
       * @return       Domain* The Initial Domain
       *
       */
      ::Deployment::Domain* get_initial_domain ();

      /**
       * @operation   getCurrentDomain
       * @brief       This function is called the Executor code
       *              to get the Current Domain data.
       * @return      Domain* The Current Domain
       */
      ::Deployment::Domain* get_current_domain ();


      /**
       * @operation create
       * @brief     This function is called to create the Datamanager
       * @param orb The orb pointer
       * @param target The Target Manager Object Reference
       *
       * @description This function calls the constructor of the
       *              class Domain Data Manager
       */
      static DomainDataManager * create (CORBA::ORB_ptr orb,
                                  ::Deployment::TargetManager_ptr target
                                  );

      /**
       * @operation get_data_manager
       * @brief Returns the static pointer to the
       *        data manager.
       * @return DomainDataManager*
       * @description The staic get_data_manger function returning
       *              the data_manager pointer
       */
      static DomainDataManager* get_data_manager ();

      /**
       * @operation delete_data_manager
       * @brief deletes the data manager
       */

      static void delete_data_manger ();

      /**
       * @operation get_node_managers
       * @brief returns the sequence of node managers
       * object reference
       */

      CIAO::Host_NodeManager_seq *
        get_node_managers ();

      /**
       * @operation get_cpu_info
       * @brief returns the node specific cpu utilization
       *
       * @return CIAO::Host_Infos*
       */

       CIAO::Host_Infos* get_cpu_info ();

       /**
        * @operation get_pid
        * @brief returns the pid of the component id submitted
        * @param cmp The component id
        *
        * @return process id
        */
       CORBA::Long get_pid (ACE_CString cmp);

       /**
        * @operation commitResources
        * @brief commits the resources that are specified
        * in the plan.
        * @param plan ::Deployment::DeploymentPlan
        * @exception  ::Deployment::ResourceNotAvailable thrown
        *             when the resources mentioned in the plan exceeds
        *             the current resource.
        * @exception  ::Deployment::PlanError thrown if the plan has any
        *              error
        *
        */
       void commitResources (
       const ::Deployment::DeploymentPlan & plan);

       /**
        * @operation releaseResources
        * @brief The function releases the resources held by a plan
        *
        * @param argname ::Deployment::DeploymentPlan the plan whose
        *                resources are to be released
        */
       void releaseResources (
       const ::Deployment::DeploymentPlan& plan);

       /**
        * @operation stop_monitors
        * @brief The function makes a call on the leaveDomain on the
        *        NodeManager
        *
        * @description The node manager in turn stops the monitor
        *
        */

       void stop_monitors ();

    protected:


      /**
       * @operation   Constructor
       * @param orb The orb pointer
       * @param target The Target Manager Object Reference
       * @description The constructor made proteccted so that no one can create
       *              it.
       */
      DomainDataManager (CORBA::ORB_ptr orb,
                         ::Deployment::TargetManager_ptr target
                         );

      /**
       * @operation readinDomainData
       * @brief   It will read the initial Domain data from
       *          XML files.
       */
      int readin_domain_data ();

      /**
       * @operation match_requirement_resource
       * @brief Match the deployed resources to the
       * available resource
       */
      void match_requirement_resource (
         ::Deployment::InstanceResourceDeploymentDescriptions deployed,
         ::Deployment::Resources& available
         );

      /**
       * @operation match_properties
       * @brief Match the properties of a Requirement to the
       * properties of available resource
       * @param deployed The deployed Properties
       * @param available The available Properties
       */

      void match_properties (
                        ::Deployment::Properties deployed,
                        ::Deployment::SatisfierProperties& available);


        /// The different actiona that can take place
        enum  Action {commit , release};

      /**
       * @operation commit_release_resource
       * @brief Either commits or releases the given resource
       * based on the current Action set.
       * @param deployed ::Deployment::Property is the resource
       * to be commited/released
       * @param available ::Deployment::SatisfierProperty is the
       * available resource from which committed/released.
       * @exception  ::Deployment::ResourceNotAvailable thrown
       *             when the deployed resources exceeds
       *             the available resource.
       */

        void commit_release_resource (  ::Deployment::Property & deployed,
                          ::Deployment::SatisfierProperty & available);

      /**
       * @operation call_all_node_managers
       * @brief This function calls all NM and gives them
       * the sub-domain
       */
      int call_all_node_managers ();

      /**
       * @operation add_to_domain
       * @brief This function add new elements to the
       * already existing domain
       *
       * @param domain Deployment::Domain contians the new
       * elements
       */
      int add_to_domain (const ::Deployment::Domain& domain);

      /**
       *  @operation delete_from_domain
       *  @brief This function deletes elements from the domain
       *
       *  @param domain ::Deployment::Domain contains the new elements
       *  in the domain
       */
      int delete_from_domain (const ::Deployment::Domain& domain);

      /**
       *  @operation intimate_planner
       *  @brief This function intimates the planner about a domain
       *  change
       *
       *  @param domain ::Deployment::Domain contains the new elements
       *  in the domain
       */
      int intimate_planner (const ::Deployment::Domain& domain);

      /**
       *  @operation find_in_initial_domain
       *  @brief This function finds a new node in the initial_domain
       *
       *  @param node The name of the node which is to be searched
       */

      bool find_in_initial_domain (const char* node_name,
                              ::Deployment::Node& node);
      /**
       *  @operation find_in_provisioned_domain
       *  @brief This function finds a new node in the proviosiond_domain
       *
       *  @param node The name of the node which is to be searched
       */

      bool find_in_provisioned_domain (const char* node_name,
                                  ::Deployment::Node& node);

      /**
       *  @operation update_node_status
       *  @brief updates the node status by reading it from a file
       */

      bool update_node_status ();

      /// The ORB pointer
      CORBA::ORB_var orb_;

      /// The Deployment Configuration
      CIAO::Deployment_Configuration deployment_config_;

      /// The Initial Domain - contains resources
      /// at total capacity
      ::Deployment::Domain initial_domain_;


      /// The Current Domain - contains resources
      /// at current capacity
      ::Deployment::Domain current_domain_;

      /// The Target Manager Context
      ::Deployment::TargetManager_var target_mgr_;

      /**
       * The staic data manager pointer implementing
       * singleton pattern
       */
      static DomainDataManager* global_data_manager_;

      /**
       * The static provisioned Domain data
       */
      ::Deployment::Domain provisioned_data_;

      ///The current action
      Action current_action_;
    };

} // CIAO

#endif /* DOMAIN_DATA_MGRH */