summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Replication_Manager.h
blob: a751bf7e3cc9d9eee5311f9d426a835f96589cc7 (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
// -*- C++ -*-

//=============================================================================
/**
 * @file   FT_Naming_Replication_Manager.h
 *
 * @author Kevin Stanley <stanleyk@ociweb.com>
 */
//=============================================================================


#ifndef TAO_FT_NAMING_REPLICATION_MANAGER_H
#define TAO_FT_NAMING_REPLICATION_MANAGER_H

#include /**/ "ace/pre.h"

#include "orbsvcs/Naming/FaultTolerant/ftnaming_export.h"
#include "orbsvcs/FT_NamingReplicationS.h"
#include "ace/Recursive_Thread_Mutex.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "orbsvcs/FT_NamingReplicationC.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

class TAO_FT_Naming_Server;

/**
 * @class TAO_FT_Naming_Replication_Manager
 * @brief The class that implements the FT_Naming::ReplicationManager
 * interface.
 */
class TAO_FtNaming_Export TAO_FT_Naming_Replication_Manager
  : public virtual POA_FT_Naming::ReplicationManager
{
public:

  /// Create a Replication Manager and provide it with the naming server
  /// to be updated whenever notified by the peer replica
  TAO_FT_Naming_Replication_Manager(TAO_FT_Naming_Server *naming_svr,
                                    const char* repl_mgr_name);

  virtual ~TAO_FT_Naming_Replication_Manager(void);

  /// Initialize the naming manager. This will provide the poa to
  /// the naming manager and underlying components for use in
  /// managing the object groups.
  void initialize (CORBA::ORB_ptr orb,
                   PortableServer::POA_ptr root_poa);


  /// Implementation of the FT_Naming::ReplicationManager interface
  virtual ::FT_Naming::ReplicaInfo * register_replica (
    ::FT_Naming::ReplicationManager_ptr replica,
    const ::FT_Naming::ReplicaInfo & replica_info);

  /// This method implements the operation invoked by the peer replica when an
  /// object group is updated on the remote process.
  virtual void notify_updated_object_group (
    const FT_Naming::ObjectGroupUpdate & group_info);

  /// This method implements the operation invoked by the peer replica when an
  /// naming context is updated on the remote process.
  virtual void notify_updated_context (
    const FT_Naming::NamingContextUpdate & group_info);

  /// Retrieve the object reference for the peer naming service
  /// ReplicationManager.
  static FT_Naming::ReplicationManager_ptr peer_replica (void);

 /*
  * Utilities for implementing the FT_Naming::ReplicationManager
  */

  /// Stores the peer in the peer_replica_ data member and invokes the
  /// register_replica interface method with the peer. Returns 0 if
  /// successful and -1 if unable to contact the peer.
  int register_with_peer_replica (FT_Naming::ReplicationManager_ptr replica,
                                  CosNaming::NamingContext_ptr nc,
                                  FT_Naming::NamingManager_ptr rm);

  /// The object reference for this servant instance
  FT_Naming::ReplicationManager_ptr reference (void);

protected:

  // The object which implements the naming service and the object manager
  TAO_FT_Naming_Server *naming_svr_;

  // Store the reference to the replica object reference
  // For now only a single replica is supported.
  static FT_Naming::ReplicationManager_var peer_replica_;

  PortableServer::POA_var repl_mgr_poa_;

  ACE_CString repl_mgr_name_;

  FT_Naming::ReplicationManager_var reference_;

  /// Lock used to serialize access to fault tolerant extensions
  /// to Naming Service.
  TAO_SYNCH_MUTEX lock_;

};

TAO_END_VERSIONED_NAMESPACE_DECL

#include /**/ "ace/post.h"

#endif /* TAO_FT_NAMING_REPLICATION_MANAGER_H */