summaryrefslogtreecommitdiff
path: root/ACE/apps/Gateway/Gateway/Options.h
blob: 13dc13dc4dcc33bb58fdb07e1dc341f48171731d (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
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Options.h
 *
 *  @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
 */
//=============================================================================


#ifndef OPTIONS_H
#define OPTIONS_H

#include "ace/config-all.h"

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

#include "ace/svc_export.h"
#include "ace/Thread_Mutex.h"
#include "ace/Lock_Adapter_T.h"
#include "ace/Synch_Traits.h"

/**
 * @class Options
 *
 * @brief Singleton that consolidates all Options for a gatewayd.
 */
class ACE_Svc_Export Options
{
public:
  // = Options that can be enabled/disabled.
  enum
  {
    // = The types of threading strategies.
    REACTIVE = 0,
    OUTPUT_MT = 1,
    INPUT_MT = 2,

    VERBOSE = 01,
    DEBUGGING = 02,

    SUPPLIER_ACCEPTOR = 04,
    CONSUMER_ACCEPTOR = 010,
    SUPPLIER_CONNECTOR = 020,
    CONSUMER_CONNECTOR = 040
  };

  /// Return Singleton.
  static Options *instance (void);

  /// Termination.
  ~Options (void);

  /// Parse the arguments and set the options.
  int parse_args (int argc, ACE_TCHAR *argv[]);

  /**
   * Print the gateway supported parameters.
   * = Accessor methods.
   * Determine if an option is enabled.
   */
  void print_usage(void);
  int enabled (int option) const;

  /**
   * Gets the locking strategy used for serializing access to the
   * reference count in <ACE_Message_Block>.  If it's 0, then there's
   * no locking strategy and we're using a REACTIVE concurrency
   * strategy.
   */
  ACE_Lock_Adapter<ACE_SYNCH_MUTEX> *locking_strategy (void) const;

  /// Set the locking strategy used for serializing access to the
  /// reference count in <ACE_Message_Block>.
  void locking_strategy (ACE_Lock_Adapter<ACE_SYNCH_MUTEX> *);

  /// Number of seconds after connection establishment to report
  /// throughput.
  long performance_window (void) const;

  /// 0 == blocking connects, ACE_NONBLOCK == non-blocking connects.
  int blocking_semantics (void) const;

  /// Size of the socket queue (0 means "use default").
  int socket_queue_size (void) const;

  /// i.e., REACTIVE, OUTPUT_MT, and/or INPUT_MT.
  u_long threading_strategy (void) const;

  /**
   * Our acceptor port number, i.e., the one that we passively listen
   * on for connections to arrive from a gatewayd and create a
   * Supplier.
   */
  u_short supplier_acceptor_port (void) const;

  /**
   * Our acceptor port number, i.e., the one that we passively listen
   * on for connections to arrive from a gatewayd and create a
   * Consumer.
   */
  u_short consumer_acceptor_port (void) const;

  /// The connector port number, i.e., the one that we use to actively
  /// establish connections with a gatewayd and create a Supplier.
  u_short supplier_connector_port (void) const;

  /// The connector port number, i.e., the one that we use to actively
  /// establish connections with a gatewayd and create a Consumer.
  u_short consumer_connector_port (void) const;

  /// Name of the connection configuration file.
  const ACE_TCHAR *connection_config_file (void) const;

  /// Name of the consumer map configuration file.
  const ACE_TCHAR *consumer_config_file (void) const;

  /// The maximum retry timeout delay.
  long max_timeout (void) const;

  /// The maximum size of the queue.
  long max_queue_size (void) const;

  /// Returns a reference to the next available connection id;
  CONNECTION_ID &connection_id (void);

private:
  enum
  {
    MAX_QUEUE_SIZE = 1024 * 1024 * 16,
    // We'll allow up to 16 megabytes to be queued per-output proxy.

    MAX_TIMEOUT = 32
    // The maximum timeout for trying to re-establish connections.
  };

  /// Initialization.
  Options (void);

  /// Options Singleton instance.
  static Options *instance_;

  /**
   * Points to the locking strategy used for serializing access to the
   * reference count in <ACE_Message_Block>.  If it's 0, then there's
   * no locking strategy and we're using a REACTIVE concurrency
   * strategy.
   */
  ACE_Lock_Adapter<ACE_SYNCH_MUTEX> *locking_strategy_;

  /// Number of seconds after connection establishment to report
  /// throughput.
  long performance_window_;

  /// 0 == blocking connects, ACE_NONBLOCK == non-blocking connects.
  int blocking_semantics_;

  /// Size of the socket queue (0 means "use default").
  int socket_queue_size_;

  /// i.e., REACTIVE, OUTPUT_MT, and/or INPUT_MT.
  u_long threading_strategy_;

  /// Flag to indicate if we want verbose diagnostics.
  u_long options_;

  /**
   * The acceptor port number, i.e., the one that we passively listen
   * on for connections to arrive from a gatewayd and create a
   * Supplier.
   */
  u_short supplier_acceptor_port_;

  /**
   * The acceptor port number, i.e., the one that we passively listen
   * on for connections to arrive from a gatewayd and create a
   * Consumer.
   */
  u_short consumer_acceptor_port_;

  /// The connector port number, i.e., the one that we use to actively
  /// establish connections with a gatewayd and create a Supplier.
  u_short supplier_connector_port_;

  /// The connector port number, i.e., the one that we use to actively
  /// establish connections with a gatewayd and create a Consumer.
  u_short consumer_connector_port_;

  /// The maximum retry timeout delay.
  long max_timeout_;

  /// The maximum size of the queue.
  long max_queue_size_;

  /// The next available connection id.
  CONNECTION_ID connection_id_;

  /// Name of the connection configuration file.
  ACE_TCHAR connection_config_file_[MAXPATHLEN + 1];

  /// Name of the consumer map configuration file.
  ACE_TCHAR consumer_config_file_[MAXPATHLEN + 1];
};

#endif /* OPTIONS_H */