summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-22 19:39:20 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-22 19:39:20 +0000
commit189a886b8d7887572d5d6840f4fc8f867cb1f8e1 (patch)
tree5a88b8f7b2fc0d4e5e8aa102c2e257e5721592bf
parenta5baabb4b84fe369da90763648bf0052e5b47856 (diff)
downloadATCD-189a886b8d7887572d5d6840f4fc8f867cb1f8e1.tar.gz
ChangeLogTag: Thu May 22 19:38:02 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog20
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h4
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/Control/Control.cpp41
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp289
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp23
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp31
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp148
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp112
-rw-r--r--TAO/orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp83
9 files changed, 506 insertions, 245 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index c0e5f8be4bd..ac26b75f655 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,23 @@
+Thu May 22 19:38:02 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h (clear):
+
+ Made the method virtual, also made virtual in the ACE
+ base class Monitor_Base. Now it behaves correctly when
+ called on a TAO_Statistic monitor fetched from the registry
+ as a Monitor_Base pointer.
+
+ * orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp:
+ * orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp:
+ * orbsvcs/tests/unit/Notify/MC/Control/Control.cpp:
+ * orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp:
+ * orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp:
+ * orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp:
+ * orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp:
+
+ Modified these test code files to be in line with recent
+ changes to the Notification Service monitors.
+
Thu May 22 11:43:44 UTC 2008 Chad Elliott <elliott_c@ociweb.com>
* tests/Bug_1361_Regression/Echo.cpp:
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
index 64bc5a8088c..342289aa178 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
@@ -56,8 +56,8 @@ public:
/// the type specified during construction.
void receive (const TAO_Statistic::List& data);
- /// Clear all stored data
- void clear (void);
+ /// Clear all stored data. Overridden from Monitor_Base.
+ virtual void clear (void);
/// Calculate the average of the accumulated samples.
double average (void) const;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/Control/Control.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/Control/Control.cpp
index 82027fa3eb5..6186600d7c0 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/Control/Control.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/Control/Control.cpp
@@ -1,32 +1,31 @@
// $Id$
+
#include "ace/Log_Msg.h"
-#include "orbsvcs/Notify/MonitorControl/Control.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Control.h"
static ACE_CString command;
-class ControlTest: public TAO_NS_Control
+class ControlTest : public TAO_NS_Control
{
public:
ControlTest (const ACE_CString& name)
- : TAO_NS_Control (name.c_str ()) {
+ : TAO_NS_Control (name.c_str ())
+ {
}
- virtual bool execute (const char* cmd) {
+ virtual bool execute (const char* cmd)
+ {
command = cmd;
- if (ACE_OS::strcmp (cmd, TAO_NS_CONTROL_SHUTDOWN) != 0)
- {
- return false;
- }
-
- return true;
+ return (ACE_OS::strcmp (cmd, TAO_NS_CONTROL_SHUTDOWN) == 0);
}
};
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -38,20 +37,28 @@ ACE_TMAIN (int, ACE_TCHAR*[])
ControlTest ct (name);
if (name != ct.name ())
- error ("The TAO_NS_Control name does not work");
+ {
+ error ("The TAO_NS_Control name does not work");
+ }
if (ct.execute (TAO_NS_CONTROL_REMOVE_CONSUMER))
- error ("The control object should have returned false");
+ {
+ error ("The control object should have returned false");
+ }
if (!ct.execute (TAO_NS_CONTROL_SHUTDOWN))
- error ("The control object shouldn't have returned false");
+ {
+ error ("The control object shouldn't have returned false");
+ }
if (command != TAO_NS_CONTROL_SHUTDOWN)
- error ("The TAO_NS_Control callback does not work");
+ {
+ error ("The TAO_NS_Control callback does not work");
+ }
}
catch(...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp
index 64e7370120c..d5ec220e0b6 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorControlExt/MonitorControlExt.cpp
@@ -1,20 +1,27 @@
// $Id$
-#include "orbsvcs/Notify/Service.h"
-#include "orbsvcs/Notify/Factory.h"
-#include "orbsvcs/CosNotifyChannelAdminC.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
-#include "orbsvcs/Notify/MonitorControl/MonitorManager.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
-#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtC.h"
-#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtC.h"
+
+#include "orbsvcs/orbsvcs/Notify/Service.h"
+#include "orbsvcs/orbsvcs/Notify/Factory.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h"
+#include "orbsvcs/orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtC.h"
+
+#include "orbsvcs/orbsvcs/CosNotifyChannelAdminC.h"
+
#include "tao/ORB.h"
#include "tao/PortableServer/PortableServer.h"
+#include "ace/Monitor_Point_Registry.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -23,14 +30,21 @@ ACE_TMAIN (int argc, ACE_TCHAR* argv[])
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
- PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ());
+ PortableServer::POA_var poa =
+ PortableServer::POA::_narrow (obj.in ());
+
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
- poa_manager->activate();
+ poa_manager->activate ();
- TAO_Notify_Service* notify_service = TAO_Notify_Service::load_default ();
+ TAO_Notify_Service* notify_service =
+ TAO_Notify_Service::load_default ();
+
if (notify_service == 0)
- error ("Unable to load the Notify Service");
+ {
+ error ("Unable to load the Notify Service");
+ }
notify_service->init_service (orb.in ());
ACE_OS::sleep (1);
@@ -40,218 +54,311 @@ ACE_TMAIN (int argc, ACE_TCHAR* argv[])
notify_service->create (poa.in (), ecf_name.c_str ());
NotifyMonitoringExt::EventChannelFactory_var monitor_ec_factory =
NotifyMonitoringExt::EventChannelFactory::_narrow (ecf.in ());
+
if (CORBA::is_nil (monitor_ec_factory.in ()))
- error ("Unable to create the Monitoring Event Channel Factory");
+ {
+ error ("Unable to create the Monitoring Event Channel Factory");
+ }
CosNotification::QoSProperties qos_prop;
CosNotification::AdminProperties admin_prop;
CosNotifyChannelAdmin::ChannelID id;
const ACE_CString ec_name ("test1");
+
CosNotifyChannelAdmin::EventChannel_var ec =
- monitor_ec_factory->create_named_channel (qos_prop, admin_prop,
- id, ec_name.c_str ());
+ monitor_ec_factory->create_named_channel (qos_prop,
+ admin_prop,
+ id,
+ ec_name.c_str ());
NotifyMonitoringExt::EventChannel_var mec =
NotifyMonitoringExt::EventChannel::_narrow (ec.in ());
+
if (CORBA::is_nil (mec.in ()))
- error ("Unable to narrow the event channel");
+ {
+ error ("Unable to narrow the event channel");
+ }
try
{
CosNotifyChannelAdmin::ChannelID fake_id;
CosNotifyChannelAdmin::EventChannel_var fake =
- monitor_ec_factory->create_named_channel (qos_prop, admin_prop,
- fake_id, "test1");
- error("Expected a NotifyMonitoringExt::NameAlreadyUsed exception");
+ monitor_ec_factory->create_named_channel (qos_prop,
+ admin_prop,
+ fake_id,
+ "test1");
+ error ("Expected a NotifyMonitoringExt::"
+ "NameAlreadyUsed exception");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
- // This is expected
+ // This is expected.
}
- TAO_Statistic_Registry* instance = TAO_Statistic_Registry::instance ();
- ACE_CString stat_name = ecf_name + "/" +
- ACE_CString (NotifyMonitoringExt::InactiveEventChannelCount);
- TAO_Statistic* stat = instance->get (stat_name);
+ Monitor_Point_Registry* instance = Monitor_Point_Registry::instance ();
+ ACE_CString stat_name =
+ ecf_name
+ + "/"
+ + ACE_CString (NotifyMonitoringExt::InactiveEventChannelCount);
+
+ TAO_Statistic* stat =
+ dynamic_cast<TAO_Statistic*> (instance->get (stat_name));
+
if (stat == 0)
- error("Could not find InactiveEventChannelCount statistic");
+ {
+ error ("Could not find InactiveEventChannelCount statistic");
+ }
stat->calculate ();
double count = stat->last_sample ();
+
if (count != 1)
- error("Invalid inactive event channel count");
+ {
+ error ("Invalid inactive event channel count");
+ }
- stat_name = ecf_name + "/" +
- ACE_CString (NotifyMonitoringExt::ActiveEventChannelCount);
- stat = instance->get (stat_name);
+ stat_name =
+ ecf_name
+ + "/"
+ + ACE_CString (NotifyMonitoringExt::ActiveEventChannelCount);
+
+ stat = dynamic_cast<TAO_Statistic*> (instance->get (stat_name));
+
if (stat == 0)
- error("Could not find ActiveEventChannelCount statistic");
+ {
+ error ("Could not find ActiveEventChannelCount statistic");
+ }
stat->calculate ();
count = stat->last_sample ();
+
if (count != 0)
- error("Invalid active event channel count");
+ {
+ error ("Invalid active event channel count");
+ }
- stat_name = ecf_name + "/" +
- ACE_CString (NotifyMonitoringExt::InactiveEventChannelNames);
- stat = instance->get (stat_name);
+ stat_name =
+ ecf_name
+ + "/"
+ + ACE_CString (NotifyMonitoringExt::InactiveEventChannelNames);
+
+ stat = dynamic_cast<TAO_Statistic*> (instance->get (stat_name));
+
if (stat == 0)
- error("Could not find InactiveEventChannels statistic");
+ {
+ error ("Could not find InactiveEventChannels statistic");
+ }
stat->calculate ();
TAO_Statistic::List list = stat->get_list ();
+
if (list.size () != 1)
- error("Invalid inactive event channel list");
+ {
+ error ("Invalid inactive event channel list");
+ }
ACE_CString full_ec_name (ecf_name + "/" + ec_name);
+
if (list[0] != full_ec_name)
- error("Wrong event channel name");
+ {
+ error("Wrong event channel name");
+ }
CosNotifyChannelAdmin::AdminID aid;
CosNotifyChannelAdmin::SupplierAdmin_var admin =
- mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP, aid,
+ mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
+ aid,
"TestSupplierAdmin");
try
{
admin =
mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
- aid, "TestSupplierAdmin");
- error("Expected a SupplierAdmin "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+ aid,
+ "TestSupplierAdmin");
+
+ error ("Expected a SupplierAdmin "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
+ // This is expected.
};
- // We should be able to create another one with the same name
+ // We should be able to create another one with the same name.
admin->destroy ();
admin =
- mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP, aid,
+ mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
+ aid,
"TestSupplierAdmin");
NotifyMonitoringExt::SupplierAdmin_var madmin =
NotifyMonitoringExt::SupplierAdmin::_narrow (admin.in ());
+
if (CORBA::is_nil (madmin.in ()))
- error("Could not narrow the supplier admin");
+ {
+ error ("Could not narrow the supplier admin");
+ }
CosNotifyChannelAdmin::ProxyID pid;
CosNotifyChannelAdmin::ProxyConsumer_var conproxy =
madmin->obtain_named_notification_push_consumer (
- CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier");
+ CosNotifyChannelAdmin::STRUCTURED_EVENT,
+ pid,
+ "supplier");
try
{
CosNotifyChannelAdmin::ProxyConsumer_var fake =
madmin->obtain_named_notification_push_consumer
(CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier");
- error("Expected a ProxyConsumer "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+
+ error ("Expected a ProxyConsumer "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
- // This is expected
+ // This is expected.
}
- stat_name = ecf_name + "/" + ec_name + "/" +
- ACE_CString (NotifyMonitoringExt::EventChannelSupplierCount);
- stat = instance->get (stat_name);
+ stat_name =
+ ecf_name
+ + "/"
+ + ec_name
+ + "/"
+ + ACE_CString (NotifyMonitoringExt::EventChannelSupplierCount);
+
+ stat = dynamic_cast<TAO_Statistic*> (instance->get (stat_name));
+
if (stat == 0)
- error("Could not find the event channel suppliers statistic");
+ {
+ error ("Could not find the event channel suppliers statistic");
+ }
stat->calculate ();
count = stat->last_sample ();
+
if (count != 1)
- error("Invalid supplier count");
+ {
+ error ("Invalid supplier count");
+ }
- CosNotifyChannelAdmin::StructuredProxyPushConsumer_var push_conproxy
- = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow
- (conproxy.in());
- ACE_ASSERT (!CORBA::is_nil (push_conproxy.in()));
- push_conproxy->disconnect_structured_push_consumer();
+ CosNotifyChannelAdmin::StructuredProxyPushConsumer_var push_conproxy =
+ CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (
+ conproxy.in ());
+ ACE_ASSERT (!CORBA::is_nil (push_conproxy.in ()));
+ push_conproxy->disconnect_structured_push_consumer ();
try
{
CosNotifyChannelAdmin::ProxyConsumer_var fake =
- madmin->obtain_named_notification_push_consumer
- (CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier");
+ madmin->obtain_named_notification_push_consumer (
+ CosNotifyChannelAdmin::STRUCTURED_EVENT,
+ pid,
+ "supplier");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
- error("Unexpected ProxyConsumer "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+ error ("Unexpected ProxyConsumer "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
CosNotifyChannelAdmin::ConsumerAdmin_var cadmin =
- mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP, aid,
+ mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
+ aid,
"TestConsumerAdmin");
try
{
cadmin =
mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
- aid, "TestConsumerAdmin");
- error("Expected a ConsumerAdmin "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+ aid,
+ "TestConsumerAdmin");
+
+ error ("Expected a ConsumerAdmin "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
+ // This is expected.
};
// We should be able to create another one with the same name
cadmin->destroy ();
cadmin =
- mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP, aid,
+ mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
+ aid,
"TestConsumerAdmin");
NotifyMonitoringExt::ConsumerAdmin_var mcadmin =
NotifyMonitoringExt::ConsumerAdmin::_narrow (cadmin.in ());
+
if (CORBA::is_nil (mcadmin.in ()))
- error("Could not narrow the consumer admin");
+ {
+ error ("Could not narrow the consumer admin");
+ }
CosNotifyChannelAdmin::ProxySupplier_var supproxy =
mcadmin->obtain_named_notification_push_supplier (
- CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer");
+ CosNotifyChannelAdmin::STRUCTURED_EVENT,
+ pid,
+ "consumer");
try
{
CosNotifyChannelAdmin::ProxySupplier_var fake =
- mcadmin->obtain_named_notification_push_supplier
- (CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer");
- error("Expected a ProxySupplier "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+ mcadmin->obtain_named_notification_push_supplier (
+ CosNotifyChannelAdmin::STRUCTURED_EVENT,
+ pid,
+ "consumer");
+
+ error ("Expected a ProxySupplier "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
- // This is expected
+ // This is expected.
}
- stat_name = ecf_name + "/" + ec_name + "/" +
- ACE_CString (NotifyMonitoringExt::EventChannelConsumerCount);
- stat = instance->get (stat_name);
+ stat_name =
+ ecf_name
+ + "/"
+ + ec_name
+ + "/"
+ + ACE_CString (NotifyMonitoringExt::EventChannelConsumerCount);
+
+ stat = dynamic_cast<TAO_Statistic*> (instance->get (stat_name));
+
if (stat == 0)
- error("Could not find the event channel consumers statistic");
+ {
+ error ("Could not find the event channel consumers statistic");
+ }
stat->calculate ();
count = stat->last_sample ();
+
if (count != 1)
- error("Invalid consumer count");
+ {
+ error ("Invalid consumer count");
+ }
- CosNotifyChannelAdmin::StructuredProxyPushSupplier_var push_supproxy
- = CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow
- (supproxy.in());
- ACE_ASSERT (!CORBA::is_nil (push_supproxy.in()));
- push_supproxy->disconnect_structured_push_supplier();
+ CosNotifyChannelAdmin::StructuredProxyPushSupplier_var push_supproxy =
+ CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow (
+ supproxy.in());
+ ACE_ASSERT (!CORBA::is_nil (push_supproxy.in ()));
+ push_supproxy->disconnect_structured_push_supplier ();
try
{
CosNotifyChannelAdmin::ProxySupplier_var fake =
- mcadmin->obtain_named_notification_push_supplier
- (CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer");
+ mcadmin->obtain_named_notification_push_supplier (
+ CosNotifyChannelAdmin::STRUCTURED_EVENT,
+ pid,
+ "consumer");
}
catch (const NotifyMonitoringExt::NameAlreadyUsed&)
{
- error("Unexpected ProxySupplier "
- "NotifyMonitoringExt::NameAlreadyUsed exception");
+ error ("Unexpected ProxySupplier "
+ "NotifyMonitoringExt::NameAlreadyUsed exception");
}
TAO_MonitorManager::shutdown ();
@@ -263,7 +370,7 @@ ACE_TMAIN (int argc, ACE_TCHAR* argv[])
}
catch (...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp
index c1b9c89ed3e..3e3141adb93 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorClient.cpp
@@ -1,11 +1,12 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/NotificationServiceMCC.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMCC.h"
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -14,18 +15,22 @@ ACE_TMAIN (int argc, ACE_TCHAR* argv[])
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
- CORBA::Object_var obj = orb->string_to_object("corbaloc:iiop:127.0.0.1:32101/TAO_MonitorAndControl");
+ CORBA::Object_var obj =
+ orb->string_to_object (
+ "corbaloc:iiop:127.0.0.1:32101/TAO_MonitorAndControl");
CosNotification::NotificationServiceMonitorControl_var monitor =
- CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ());
+ CosNotification::NotificationServiceMonitorControl::_narrow (
+ obj.in ());
if (CORBA::is_nil (monitor.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to resolve the TAO_MonitorAndControl\n"),
- -1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to resolve the TAO_MonitorAndControl\n"),
+ -1);
+ }
monitor->shutdown ();
-
orb->destroy ();
}
catch (const CORBA::Exception& ex)
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp
index f2c9f4cf233..4d4bbc8bda8 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/MonitorManager/MonitorManager.cpp
@@ -1,14 +1,15 @@
// $Id$
+
#include "ace/Service_Types.h"
#include "ace/Service_Config.h"
#include "ace/Service_Repository.h"
#include "ace/Thread_Manager.h"
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -17,23 +18,29 @@ ACE_TMAIN (int, ACE_TCHAR* argv[])
try
{
if (ACE_Service_Config::open (argv[0]) != 0)
- error("Unable to load the TAO_MonitorAndControl");
+ {
+ error("Unable to load the TAO_MonitorAndControl");
+ }
- // Run the service
+ // Run the service.
const ACE_Service_Type* st = 0;
- ACE_Service_Repository::instance()->find("TAO_MonitorAndControl", &st);
+ ACE_Service_Repository::instance ()->find ("TAO_MonitorAndControl",
+ &st);
if (st == 0)
- error ("Failed to find the TAO_MonitorAndControl instance");
+ {
+ error ("Failed to find the TAO_MonitorAndControl instance");
+ }
- ACE_Service_Object* obj = (ACE_Service_Object*)st->type()->object();
- obj->resume();
+ ACE_Service_Object* obj =
+ (ACE_Service_Object*) st->type ()->object ();
+ obj->resume ();
- // Wait for an external entity to stop it
- ACE_Thread_Manager::instance()->wait();
+ // Wait for an external entity to stop it.
+ ACE_Thread_Manager::instance ()->wait ();
}
- catch(...)
+ catch (...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp
index 1fce3c59656..d52dca818a0 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/NotificationServiceMonitor/NotificationServiceMonitor.cpp
@@ -1,14 +1,19 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
-#include "orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h"
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h"
+
#include "tao/TAO_Singleton_Manager.h"
+#include "ace/Monitor_Point_Registry.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -18,87 +23,142 @@ ACE_TMAIN (int, ACE_TCHAR*[])
{
TAO_Singleton_Manager::instance ()->init ();
- // Test registry acquisition
- TAO_Statistic_Registry* reg = TAO_Statistic_Registry::instance();
+ // Test registry acquisition.
+ Monitor_Point_Registry* reg = Monitor_Point_Registry::instance ();
+
if (reg == 0)
- error("TAO_Statistic_Registry::instance() failed");
+ {
+ error ("Monitor_Point_Registry::instance() failed");
+ }
- // Test registry addition
+ // Test registry addition.
TAO_Statistic* s = 0;
ACE_NEW_RETURN (s,
TAO_Statistic ("test1",
TAO_Statistic::TS_COUNTER),
2);
- if (reg->add(s) == false)
- error("clean TAO_Statistic_Registry::add() failed");
- for(int i = 0; i < 10; i++)
- s->receive();
+ if (reg->add (s) == false)
+ {
+ error ("clean Monitor_Point_Registry::add() failed");
+ }
+
+ for (int i = 0; i < 10; ++i)
+ {
+ s->receive (0.0);
+ }
ACE_NEW_RETURN (s,
TAO_Statistic ("test2",
TAO_Statistic::TS_NUMBER),
2);
- if (reg->add(s) == false)
- error("second TAO_Statistic_Registry::add() failed");
- for(int i = 0; i < 10; i++)
- s->receive(i);
+
+ if (reg->add (s) == false)
+ {
+ error ("second Monitor_Point_Registry::add() failed");
+ }
+
+ for (int i = 0; i < 10; ++i)
+ {
+ s->receive (i);
+ }
ACE_NEW_RETURN (s,
TAO_Statistic ("test3",
TAO_Statistic::TS_INTERVAL),
2);
+
if (reg->add(s) == false)
- error("third TAO_Statistic_Registry::add() failed");
- for(int i = 0; i < 10; i++)
- s->receive(i / .08);
+ {
+ error ("third Monitor_Point_Registry::add() failed");
+ }
+
+ for (int i = 0; i < 10; ++i)
+ {
+ s->receive (i / .08);
+ }
NotificationServiceMonitor_i monitor;
- CosNotification::NotificationServiceMonitorControl::NameList* names =
- monitor.get_statistic_names ();
- if (names == 0 || names->length () != 3)
- error("get_statistic_names() returned the incorrect number of names");
+ Monitor::NameList* names = monitor.get_statistic_names ();
+ Monitor::NameList_var safe_names = names;
+
+ // We added 3 and there's one in the default reactor's
+ // message queue.
+ if (names == 0 || names->length () != 4)
+ {
+ error ("get_statistic_names() returned "
+ "the incorrect number of names");
+ }
+ CORBA::ULong index = 1UL;
CosNotification::NotificationServiceMonitorControl::Data_var d =
- monitor.get_statistic ((*names)[0]);
- CosNotification::NotificationServiceMonitorControl::Numeric num = d->num ();
+ monitor.get_statistic (safe_names[index]);
+ CosNotification::NotificationServiceMonitorControl::Numeric num =
+ d->num ();
+
if (num.count != 10)
- error("get_statistic() returned the wrong data");
+ {
+ error ("get_statistic() returned the wrong data");
+ }
CosNotification::NotificationServiceMonitorControl::DataList* data =
monitor.get_statistics (*names);
- if (data == 0 || data->length () != 3)
- error("get_statistics() returned the incorrect number of data elements");
- num = (*data)[1].num ();
+
+ if (data == 0 || data->length () != 4)
+ {
+ error ("get_statistics() returned the "
+ "incorrect number of data elements");
+ }
+
+ num = (*data)[2].num ();
+
if (num.average != 4.5)
- error("get_statistics() return the wrong data");
+ {
+ error ("get_statistics() return the wrong data");
+ }
+
delete data;
data = monitor.get_and_clear_statistics (*names);
- if (data == 0 || data->length () != 3)
- error("get_and_clear_statistics() returned the incorrect number of data elements");
- for(CORBA::ULong i = 0; i < data->length (); i++)
+
+ if (data == 0 || data->length () != 4)
+ {
+ error ("get_and_clear_statistics() returned "
+ "the incorrect number of data elements");
+ }
+
+ // Skip the first one, which is an ACE_Message_Queue
+ // monitor.
+ for (CORBA::ULong i = 1; i < data->length (); ++i)
{
num = (*data)[i].num ();
+
if (num.count == 0)
- error("get_and_clear_statistics() failed");
+ {
+ error ("get_and_clear_statistics() failed");
+ }
}
+
delete data;
- // Test the clear_statistics method
- for(int i = 0; i < 10; i++)
- s->receive(i / .7);
+ // Test the clear_statistics method.
+ for (int i = 0; i < 10; ++i)
+ {
+ s->receive (i / .7);
+ }
+
monitor.clear_statistics (*names);
- if (s->count() != 0)
- error("clear_statistics() did not clear the data");
-
- delete names;
+
+ if (s->count () != 0)
+ {
+ error ("clear_statistics() did not clear the data");
+ }
TAO_Singleton_Manager::instance ()->fini ();
}
- catch(...)
+ catch (...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp
index ef1f6af02c5..65c90635bed 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/Statistic/Statistic.cpp
@@ -1,12 +1,14 @@
// $Id$
+
#include "orbsvcs/Notify/MonitorControl/Statistic.h"
+
#include "ace/Log_Msg.h"
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -15,69 +17,107 @@ ACE_TMAIN (int, ACE_TCHAR*[])
try
{
TAO_Statistic counter ("counter", TAO_Statistic::TS_COUNTER);
- counter.receive();
- counter.receive();
- counter.receive();
+ counter.receive (0.0);
+ counter.receive (0.0);
+ counter.receive (0.0);
+
if (counter.last_sample() != 3)
- error("Counter TAO_Statistic::receive() failed");
+ {
+ error ("Counter TAO_Statistic::receive() failed");
+ }
TAO_Statistic number ("number", TAO_Statistic::TS_NUMBER);
- number.receive(8);
- number.receive(10);
- number.receive(42);
+ number.receive (8);
+ number.receive (10);
+ number.receive (42);
+
if (number.average() != 20)
- error("Number TAO_Statistic::average() failed");
+ {
+ error ("Number TAO_Statistic::average() failed");
+ }
+
if (number.minimum_sample() != 8)
- error("Number TAO_Statistic::minimum_sample() failed");
+ {
+ error ("Number TAO_Statistic::minimum_sample() failed");
+ }
+
if (number.maximum_sample() != 42)
- error("Number TAO_Statistic::maximum_sample() failed");
+ {
+ error ("Number TAO_Statistic::maximum_sample() failed");
+ }
+
if (number.sum_of_squares() != 1928)
- error("Number TAO_Statistic::sum_of_squares() failed");
+ {
+ error ("Number TAO_Statistic::sum_of_squares() failed");
+ }
TAO_Statistic stime ("time", TAO_Statistic::TS_TIME);
- stime.receive(1183466309.01234);
- stime.receive(1183466377.9922);
- stime.receive(1083466309.88374);
+ stime.receive (1183466309.01234);
+ stime.receive (1183466377.9922);
+ stime.receive (1083466309.88374);
+
if (stime.average() != 1150132998.96276)
- error("Time TAO_Statistic::average() failed");
+ {
+ error ("Time TAO_Statistic::average() failed");
+ }
+
if (stime.minimum_sample() != 1083466309.88374)
- error("Time TAO_Statistic::minimum_sample() failed");
+ {
+ error ("Time TAO_Statistic::minimum_sample() failed");
+ }
+
if (stime.maximum_sample() != 1183466377.9922)
- error("Time TAO_Statistic::maximum_sample() failed");
-
+ {
+ error ("Time TAO_Statistic::maximum_sample() failed");
+ }
TAO_Statistic interval ("interval", TAO_Statistic::TS_INTERVAL);
- interval.receive(.8);
- interval.receive(.1);
- interval.receive(.42);
+ interval.receive (.8);
+ interval.receive (.1);
+ interval.receive (.42);
+
// This multiplication and casting is necessary since the machine
// representation of the floating point values in the receive()
// calls are not exactly what is represented by the text of the code.
if (static_cast<int> (interval.average() * 100) != 44)
- error("Interval TAO_Statistic::average() failed");
+ {
+ error ("Interval TAO_Statistic::average() failed");
+ }
+
if (interval.minimum_sample() != .1)
- error("Interval TAO_Statistic::minimum_sample() failed");
+ {
+ error ("Interval TAO_Statistic::minimum_sample() failed");
+ }
+
if (interval.maximum_sample() != .8)
- error("Interval TAO_Statistic::maximum_sample() failed");
+ {
+ error ("Interval TAO_Statistic::maximum_sample() failed");
+ }
+
if (static_cast<int> (interval.sum_of_squares() * 10000) != 8264)
- error("Interval TAO_Statistic::sum_of_squares() failed");
+ {
+ error ("Interval TAO_Statistic::sum_of_squares() failed");
+ }
TAO_Statistic list ("list", TAO_Statistic::TS_LIST);
TAO_Statistic::List l;
- l.push_back("one");
- l.push_back("two");
- l.push_back("three");
- list.receive(l);
+ l.push_back ("one");
+ l.push_back ("two");
+ l.push_back ("three");
+ list.receive (l);
+
if (counter.count () != 3)
- error("List TAO_Statistic::receive() failed");
+ {
+ error ("List TAO_Statistic::receive() failed");
+ }
- /// Test for memory leaks (with valgrind)
+ /// Test for memory leaks (with valgrind).
list.clear ();
- list.receive(l);
+ list.receive (l);
}
- catch(...)
+ catch (...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;
diff --git a/TAO/orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp b/TAO/orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp
index 09285576ded..d6a8855e1d9 100644
--- a/TAO/orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp
+++ b/TAO/orbsvcs/tests/unit/Notify/MC/Statistic_Registry/Statistic_Registry.cpp
@@ -1,13 +1,18 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h"
+
#include "tao/TAO_Singleton_Manager.h"
+#include "ace/Monitor_Point_Registry.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
void
-error(const char* msg)
+error (const char* msg)
{
ACE_ERROR ((LM_ERROR, "%s\n", msg));
- ACE_OS::exit(1);
+ ACE_OS::exit (1);
}
int
@@ -17,65 +22,75 @@ ACE_TMAIN (int, ACE_TCHAR*[])
{
TAO_Singleton_Manager::instance ()->init ();
- // Test registry acquisition
- TAO_Statistic_Registry* reg = TAO_Statistic_Registry::instance();
+ // Test registry acquisition.
+ Monitor_Point_Registry* reg = Monitor_Point_Registry::instance ();
+
if (reg == 0)
- error("TAO_Statistic_Registry::instance() failed");
+ {
+ error ("Monitor_Point_Registry::instance() failed");
+ }
- // Test registry addition
+ // Test registry addition.
TAO_Statistic* s = 0;
ACE_NEW_RETURN (s,
TAO_Statistic ("test1",
TAO_Statistic::TS_COUNTER),
2);
- if (reg->add(s) == false)
- error("clean TAO_Statistic_Registry::add() failed");
-
- if (reg->add(s) == true)
- error("duplicate TAO_Statistic_Registry::add() failed");
+ if (reg->add (s) == false)
+ {
+ error ("clean Monitor_Point_Registry::add() failed");
+ }
- try
+ if (reg->add (s) == true)
{
- reg->add(0);
- error("exception TAO_Statistic_Registry::add() failed");
+ error ("duplicate Monitor_Point_Registry::add() failed");
}
- catch (const TAO_Statistic_Registry::Map_Error& ex)
+
+ // Test registry addition of null value - should get ACE_ERROR
+ // message and return value of 'false'.
+ if (reg->add (0) == true)
{
- if (ex.why_ != TAO_Statistic_Registry::Map_Error::MAP_ERROR_INVALID_VALUE)
- {
- error("TAO_Statistic_Registry::add() threw exception "
- "with an incorrect reason");
- }
+ error ("Monitor_Point_Registry::add() of null succeeded");
}
- // Test registry removal
- if (reg->remove("fake name") == true)
- error("non-existent TAO_Statistic_Registry::remove() failed");
+ // Test registry removal.
+ if (reg->remove ("fake name") == true)
+ {
+ error ("non-existent Monitor_Point_Registry::remove() failed");
+ }
- if (reg->remove("test1") == false)
- error("existent TAO_Statistic_Registry::remove() failed");
+ if (reg->remove ("test1") == false)
+ {
+ error ("existent Monitor_Point_Registry::remove() failed");
+ }
- // Test destruction with registered statistics
+ // Test destruction with registered statistics.
ACE_NEW_RETURN (s,
TAO_Statistic ("test1",
TAO_Statistic::TS_COUNTER),
2);
- if (reg->add(s) == false)
- error("re-addition TAO_Statistic_Registry::add() failed");
+
+ if (reg->add (s) == false)
+ {
+ error ("re-addition Monitor_Point_Registry::add() failed");
+ }
ACE_NEW_RETURN (s,
TAO_Statistic ("test2",
TAO_Statistic::TS_NUMBER),
2);
- if (reg->add(s) == false)
- error("second TAO_Statistic_Registry::add() failed");
+
+ if (reg->add (s) == false)
+ {
+ error ("second Monitor_Point_Registry::add() failed");
+ }
TAO_Singleton_Manager::instance ()->fini ();
}
- catch(...)
+ catch (...)
{
- error("Caught an unexpected exception type");
+ error ("Caught an unexpected exception type");
}
return 0;