summaryrefslogtreecommitdiff
path: root/TAO/examples/Load_Balancing_persistent/Identity_Server.h
blob: 36f902015cfb6119fed06fd99ed7ed2d84f295d6 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Identity_Server.h
 *
 *  $Id$
 *
 *  Driver for identity server, which is used to test/demonstrate
 *  the functionality of the Load Balancing service.
 *
 *
 *  @author Marina Spivak <marina@cs.wustl.edu> with modifications by Bala Natarajan <bala@cs.wustl.edu>
 */
//=============================================================================


#ifndef IDENTITY_SERVER_H_
#define IDENTITY_SERVER_H_

#include "tao/Utils/ORB_Manager.h"
#include "Load_BalancerC.h"

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

/**
 * @class Identity_Server
 =TITLE
 * Contacts the <Object_Group_Factory> in the Load Balancing Server
 * to create two <Object_Group>s, one round robin and one random.
 * Then, creates a number of <Identity> objects and registers them with
 * the created <Object_Group>s in a manner specified by the
 * commandline arguments.
 */
class Identity_Server
{
public:

  /// Default constructor.
  Identity_Server (void);

  /// Destructor.
  ~Identity_Server (void);

  /// Parses the commandline arguments.
  int parse_args (int argc, ACE_TCHAR *argv[]);

  /// Performs all the initializations necessary before going into the
  /// ORB event loop.
  int init (int argc, ACE_TCHAR *argv[]);

  int register_groups (void);


  /// Run the server.
  int run (void);

private:


  /**
   * Creates the specified number of identity objects, and registers
   * each one with the provided <Object_Group>.  Identity servants are
   * given names
   *"Identity object 1" .... "Identity object <number_of_objects>".
   */
  void create_objects (size_t number_of_objects,
                       Load_Balancer::Object_Group_ptr group);


  /// The ORB manager.
  TAO_ORB_Manager orb_manager_;

  /// The ior of the <Object_Group_Factory> object we shall use to
  /// create <Object_Group>s to load balance our <Identity> objects.
  const ACE_TCHAR *group_factory_ior_;

  /// Number of <Identity> objects to create for registering with
  /// the random <Object_Group>.  The default value is 5.
  size_t random_objects_;

  /// Number of <Identity> objects to create for registering with the
  /// round robin <Object_Group>.  The default value is 5.
  size_t rr_objects_;

  PortableServer::POA_var persistent_POA_;
};

#endif /* IDENTITY_SERVER_H_ */