summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.h
blob: 544fa7283093760d8592d93ad80764110e1f2298 (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
/* -*- C++ -*- */
//=============================================================================
/**
 *  @file    Fault_Detector_i.h
 *
 *  This file is part of Fault Tolerant CORBA.
 *  This file declares the Fault_Detector_i class.
 *  The class implements the FaultDetectors as defined
 *  in the specification.
 *  A FaultDetector monitors the health of replicas.
 *  It is *NOT* a CORBA object and does not implement an IDL interface.
 *  All CORBA interaction with a FaultDetector is via a FaultDetectorFactory.
 *
 *  @author Dale Wilson <wilson_d@ociweb.com>
 */
//=============================================================================


#ifndef FAULT_DETECTOR_I_H_
#define FAULT_DETECTOR_I_H_
#include /**/ <ace/pre.h>
#include <ace/ACE.h>
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include <ace/Manual_Event.h>


#include "orbsvcs/FT_NotifierC.h"
#include "orbsvcs/FT_ReplicaC.h"
#include "ace/Time_Value.h"

// Classes declared in this header
TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  //////////////////////
  // Forward references

  class FT_FaultDetectorFactory_i;

  //////////////////////
  // Class declarations

  class Fault_Detector_i
  {
    ///////////////////
    // Public interface
  public:
    /**
     * Construct FaultDetector.
     * @param factory to be notified when this detector goes away.
     * @param id to use when notifyting the factory of detector departure.
     * @param notifier to receive the fault notification if our monitorable faults.
     * @param monitorable object to be monitored.
     * @param domain_id data to include in fault notification.
     * @param object_location data to include in fault notification.
     * @param object_type data to include in fault notification.
     * @param group_id data to include in fault notification.
     */
    Fault_Detector_i (
      FT_FaultDetectorFactory_i & factory,
      CORBA::ULong id,
      FT::FaultNotifier_ptr & notifier,
      FT::PullMonitorable_ptr & monitorable,
      FT::FTDomainId domain_id,
      const PortableGroup::Location & object_location,
      PortableGroup::TypeId object_type,
      PortableGroup::ObjectGroupId group_id);
    /**
     * destructor.
     * Non-virtual because this class does not take part in
     * inheritence.
     */
    ~Fault_Detector_i ();

    /**
     * Start the thread associated with this fault detector.
     * @param threadManager to track this thread.
     */
    void start(ACE_Thread_Manager & threadManager);

    /**
     * Request that this detector shut itself down.
     */
    void request_quit();

    ////////////////////////
    // Static public methods
  public:
    /**
     * Set the polling time for all FaultDetectors in this process.
     * @param value the time between polls.
     */
    static void set_time_for_all_detectors (ACE_Time_Value value);

    /////////////////////////
    // implementation methods
  private:
    /**
     * Send the notification message.
     */
    void notify();

    /**
     * The method to be run in the fault detector thread.
     */
    void run();

    /**
     * The startup function for the fault detector thread.
     */
    static ACE_THR_FUNC_RETURN thr_func (void * arg);

    ////////////////////
    // Forbidden methods
  private:
    Fault_Detector_i ();
    Fault_Detector_i (Fault_Detector_i & rhs);
    Fault_Detector_i & operator = (const Fault_Detector_i & rhs);

    ///////////////
    // Static data
  private:
    /**
     * Time between polls for all fault detectors in this process.
     */
    static ACE_Time_Value sleep_time_;

    ///////////////
    // Data members
  private:
    /**
     * The factory that "owns" us."
     */
    FT_FaultDetectorFactory_i & factory_;

    /**
     * How the factory knows who we are.
     */
    CORBA::ULong id_;

    /**
     * Where to send fault notification messages.
     */
    FT::FaultNotifier_var notifier_;

    /**
     * What to monitor.
     */
    FT::PullMonitorable_var monitorable_;

    /**
     * Data for the notification message.
     */
    FT::FTDomainId domain_id_;
    PortableGroup::Location object_location_;
    PortableGroup::TypeId object_type_;
    PortableGroup::ObjectGroupId group_id_;

    /**
     * An Event (in the Win32 sense) to implement interruptable sleep.
     * Manual rather than auto because once quit is requested we never
     * want to sleep again.
     */
    ACE_Manual_Event sleep_;

    /**
     * A boolean flag.  If true, this fault detector should leave.
     */
    int quit_requested_;
  };
}   // namespace TAO

TAO_END_VERSIONED_NAMESPACE_DECL

#include /**/ <ace/post.h>
#endif // FAULT_DETECTOR_I_H_