summaryrefslogtreecommitdiff
path: root/DAnCE/dance/ExecutionManager/ExecutionManager_Impl.h
blob: d5018a581344e458c8b6967816e229670e05bfef (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    ExecutionManager_Impl.h
 *
 *  $Id$
 *
 * @brief  Implementation of Deployment::ExecutionManager and POA_DAnCE::ExecutionManagerDaemon
 *
 * @author Erwin Gottlieb <eg@prismtech.com>
 */
//=============================================================================

#ifndef EXECUTIONMANAGER_IMPL_H_
#define EXECUTIONMANAGER_IMPL_H_

#include "ace/Map_Manager.h"
#include "ace/SStringfwd.h"
#include "orbsvcs/orbsvcs/CosNamingC.h"
#include "dance/Deployment/Deployment_ExecutionManagerS.h"
#include "dance/Deployment/Deployment_NodeManagerC.h"
#include "dance/DomainApplicationManager/DomainApplicationManager_Impl.h"
#include "dance/DomainApplicationManager/Node_Locator.h"
#include "Completion/CompletionHandler_T.h"
#include "Completion/Completion_Counter_Base.h"

namespace DAnCE
  {
  class ExecutionManager_Impl;

  typedef PortableServer::Servant_var<ExecutionManager_Impl> ExecutionManager_Impl_var;

  class ExecutionManager_Impl
        : public virtual POA_Deployment::AMH_ExecutionManager
    {
    public:
      ExecutionManager_Impl (CORBA::ORB_ptr orb,
                             PortableServer::POA_ptr poa,
                             CosNaming::NamingContext_ptr);

      virtual ~ExecutionManager_Impl(void);

      virtual void preparePlan (
        ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh,
        const ::Deployment::DeploymentPlan & plan,
        ::Deployment::ResourceCommitmentManager_ptr resourceCommitment);

      virtual void getManagers (
        ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh);

      virtual void destroyManager (
        ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh,
        ::Deployment::DomainApplicationManager_ptr manager);

      void add_node_manager (const char *name, const char *ior);

      void load_cdd (const ACE_TCHAR *filename);

      class PreparePlanCompletionHandler
            : public CompletionHandler<DomainApplicationManager_Impl>
        {
        public:
          PreparePlanCompletionHandler (
            ExecutionManager_Impl *em_servant,
            ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh);

          virtual void handle_completion (DomainApplicationManager_Impl *dam_servant);
          virtual void handle_exception (CORBA::Exception* local_ex);

        private:
          ExecutionManager_Impl_var em_servant_;
          ::Deployment::AMH_ExecutionManagerResponseHandler_var em_rh_;
        };

      class DestroyManagerCompletionHandler
            : public CompletionHandler<DomainApplicationManager_Impl>
        {
        public:
          DestroyManagerCompletionHandler (
            ExecutionManager_Impl *em_servant,
            ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh,
            DomainApplicationManager_Impl* dam_servant);

          virtual void handle_completion (DomainApplicationManager_Impl *dam_servant);
          virtual void handle_exception (CORBA::Exception* local_ex);

        private:
          ExecutionManager_Impl_var em_servant_;
          ::Deployment::AMH_ExecutionManagerResponseHandler_var em_rh_;
          DomainApplicationManager_Impl_var dam_servant_;
        };

    private:
      void finish_preparePlan (
        ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh,
        DomainApplicationManager_Impl *dam_servant);
      void fail_preparePlan (
        ::Deployment::AMH_ExecutionManagerResponseHandler_ptr _tao_rh,
        CORBA::Exception* local_ex);

      friend class PreparePlanCompletionHandler;

      typedef ACE_Map_Manager<
        ACE_CString,
        DomainApplicationManager_Impl*,
        ACE_Null_Mutex> TDomainManagers;
      CORBA::ORB_var orb_;
      PortableServer::POA_var poa_;
      TDomainManagers managers_;
      Node_Locator locator_;
    };
}//DAnCE

#endif /*EXECUTIONMANAGER_IMPL_H_*/