summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2001-06-20 21:24:42 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2001-06-20 21:24:42 +0000
commitf6acb7d2190c6b9c5476297393a0da18ea2e796c (patch)
treea93a4449655076dda5e60c8775509f1295077657
parent4c3adcd675c1818afed953157c72f35ec494cf16 (diff)
downloadATCD-f6acb7d2190c6b9c5476297393a0da18ea2e796c.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/tests/LoadBalancing/server.cpp153
1 files changed, 145 insertions, 8 deletions
diff --git a/TAO/orbsvcs/tests/LoadBalancing/server.cpp b/TAO/orbsvcs/tests/LoadBalancing/server.cpp
index 2a5eb46f339..300e220f968 100644
--- a/TAO/orbsvcs/tests/LoadBalancing/server.cpp
+++ b/TAO/orbsvcs/tests/LoadBalancing/server.cpp
@@ -43,6 +43,125 @@ parse_args (int argc, char *argv[])
return 0;
}
+LoadBalancing::Criteria *
+setup_criteria (HasherFactory &hasher_factory)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ const CORBA::UShort INIT_NUM_REPLICAS = 4;
+ const CORBA::UShort MIN_NUM_REPLICAS = 3;
+
+ // Criteria:
+ // InitialNumberReplicas
+ // MinimumNumberReplicas
+ // Factories
+ const CORBA::ULong DEFAULT_PROPERTY_COUNT = 3;
+
+ LoadBalancing::Criteria *tmp = 0;
+ ACE_NEW_RETURN (tmp,
+ LoadBalancing::Criteria (DEFAULT_PROPERTY_COUNT),
+ 0);
+
+ LoadBalancing::Criteria_var criteria = tmp;
+
+ criteria->length (DEFAULT_PROPERTY_COUNT);
+
+ // Default initial number of replicas
+ LoadBalancing::Property &initial_number_replicas =
+ criteria[0];
+
+ initial_number_replicas.nam.length (1);
+ initial_number_replicas.nam[0].id =
+ CORBA::string_dup ("InitialNumberReplicas");
+ initial_number_replicas.val <<= INIT_NUM_REPLICAS;
+
+ // Default minimum number of replicas
+ LoadBalancing::Property &minimum_number_replicas =
+ criteria[1] = minimum_number_replicas;
+
+ minimum_number_replicas.nam.length (1);
+ minimum_number_replicas.nam[0].id =
+ CORBA::string_dup ("MinimumNumberReplicas");
+ minimum_number_replicas.val <<= MIN_NUM_REPLICAS;
+
+
+ // Default factories (simulated locations)
+ LoadBalancing::Property &factories =
+ criteria[2];
+
+ factories.nam.length (1);
+ factories.nam[0].id = CORBA::string_dup ("Factories");
+
+ // Implicitly activate the HasherFactory.
+ CORBA::Object_var obj =
+ hasher_factory._this (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ LoadBalancing::GenericFactory_var factory =
+ LoadBalancing::GenericFactory::_narrow (obj.in (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ LoadBalancing::FactoryInfos factory_infos;
+ factory_infos.length (INIT_NUM_REPLICAS);
+ for (CORBA::ULong i = 0; i < factory_infos.length (); ++i)
+ {
+ LoadBalancing::FactoryInfo &factory_info =
+ factory_infos[i];
+
+ // For this test, the same GenericFactory is used to create
+ // a replica at each logical location. Of course, a
+ // deployed application would most likely have a
+ // GenericFactory at each physical location, or at least one
+ // capable of creating replicas at multiple physical
+ // locations.
+ factory_info.the_factory =
+ LoadBalancing::GenericFactory::_duplicate (factory.in ());
+
+ factory_info.the_location.length (1);
+
+ // Create a logical location for each factory.
+ char location[BUFSIZ] = { 0 };
+ ACE_OS::sprintf (location, "%u", i);
+ factory_info.the_location[0].id =
+ CORBA::string_dup (location);
+ factory_info.the_location[0].kind =
+ CORBA::string_dup ("location number");
+ }
+
+ factories.val <<= factory_infos;
+
+ // @@ TODO: Add the following criteria to the sequence of
+ // default properties:
+ // ReplicationStyle
+ // MembershipStyle
+ // ConsistencyStyle (?)
+ // LoadMonitoringStyle
+ // LoadMonitoringGranularity
+ // LoadMonitoringInterval
+ // CheckpointInterval (?)
+
+// this->property_manager_->set_default_properties (criteria,
+// ACE_TRY_ENV);
+// ACE_TRY_CHECK;
+
+ return criteria._retn ();
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ ACE_TEXT ("Caught unexpected exception:"));
+
+ return 0;
+ }
+ ACE_ENDTRY;
+
+
+ return 0;
+}
+
+
int
main (int argc, char *argv[])
{
@@ -105,8 +224,13 @@ main (int argc, char *argv[])
// "PropertManager reference is nil.\n"),
// -1);
- // Run the PropertyManager tests, in addition to setting up the
- // Load Balancer for the remainder of this test.
+
+ HasherFactory hasher_factory (orb.in (), root_poa.in ());
+
+ // Set up the criteria to be used when creating the object
+ // group, and activate the hasher factory.
+ LoadBalancing::Criteria_var the_criteria =
+ ::setup_criteria (hasher_factory);
// The FactoryCreationId
LoadBalancing::GenericFactory::FactoryCreationId_var
@@ -114,16 +238,11 @@ main (int argc, char *argv[])
// Create a replicated Hasherobject (object group)
obj = factory->create_object (HasherFactory::replica_type_id (),
- the_criteria,
+ the_criteria.in (),
factory_creation_id.out (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // @@ Move this to a point just before shutdown!
- // Destroy the object group.
- factory->delete_object (factory_creation_id.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
// Application-Controlled MembershipStyle
if (CORBA::is_nil (obj.in ()))
@@ -150,6 +269,24 @@ main (int argc, char *argv[])
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
+
+ // Run the ORB event loop.
+ orb->run (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+
+ ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n"));
+ // @@ Move this to a point just before shutdown!
+ // Destroy the object group.
+ factory->delete_object (factory_creation_id.in (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+
+ root_poa->destroy (1, 1, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
}
ACE_CATCHANY
{