summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-21 15:54:38 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-21 15:54:38 +0000
commitca36beba27ded4abc6c360393db670101b74ebcc (patch)
treec0ab6cf503b6ddcbfb2d879d5af2cbbc93b91b6b
parent72560fc96c486202280553898b23d961d8f283d3 (diff)
downloadATCD-ca36beba27ded4abc6c360393db670101b74ebcc.tar.gz
ChangeLogTag: Wed May 21 15:52:17 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog63
-rw-r--r--TAO/MPC/config/notification_mc.mpb2
-rw-r--r--TAO/TAO_IDL/be/be_codegen.cpp14
-rw-r--r--TAO/TAO_IDL/be/be_visitor_root/root.cpp25
-rw-r--r--TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp1
-rw-r--r--TAO/orbsvcs/orbsvcs/CosNotification.mpc4
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp11
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.h18
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp95
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h62
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h10
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.cpp21
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.h33
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.cpp89
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.h75
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp114
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h6
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl17
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp154
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h43
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp113
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h35
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl29
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.cpp18
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.h28
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp97
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp717
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h38
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp269
-rw-r--r--TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp4
-rw-r--r--TAO/tao/Monitor.mpc6
31 files changed, 1297 insertions, 914 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index fe14108baf4..0543232cc13 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,66 @@
+Wed May 21 15:52:17 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Generic.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Generic.h:
+
+ Removed these files, using the base registry and monitor
+ classes in ACE instead.
+
+ * MPC/config/notification_mc.mpb:
+
+ Added tao_monitor base project.
+
+ * orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl:
+
+ Added include of $TAO_ROOT/tao/Monitor.idl and used the
+ indirectly included StringSeq type for NameList, instead of
+ declaring a new typedef. These changes are the start of
+ the integration of the new ACE and TAO monitor and control
+ framework with the existing one in the Notification Service.
+
+ * orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/Control.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h:
+ * orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h:
+ * orbsvcs/tests/Notify/MC/test_monitor.cpp:
+
+ Changes falling out from the file removal and IDL changes
+ above, as well as format and style changes.
+
+ * orbsvcs/orbsvcs/CosNotification.mpc:
+
+ Added tao_monitor as a base project.
+
+ * tao/Monitor.mpc:
+
+ Changes to IDL compiler command line options to generate
+ typecodes needed by dependent types in NotificationServiceMC.idl.
+
+ * TAO_IDL/be/be_codegen.cpp:
+ * TAO_IDL/be/be_visitor_root/root.cpp:
+ * TAO_IDL/be/be_visitor_structure/structure_cs.cpp:
+
+ Fixed a bug in the use case where typecodes must be
+ generated into *A.h and *A.cpp files, and the headers
+ propagated via a 'safe include' through another IDL
+ file with no declarations of its own.
+
Tue May 20 19:37:31 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
* tao/Transport_Cache_Manager.cpp:
diff --git a/TAO/MPC/config/notification_mc.mpb b/TAO/MPC/config/notification_mc.mpb
index 8fc74b2244f..8f7ccdecb1b 100644
--- a/TAO/MPC/config/notification_mc.mpb
+++ b/TAO/MPC/config/notification_mc.mpb
@@ -1,7 +1,7 @@
// -*- MPC -*-
// $Id$
-project: portableserver, iortable, naming {
+project: portableserver, iortable, naming, tao_monitor {
after += CosNotification_MC
libs += TAO_CosNotification_MC
}
diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp
index 3471ef38c3a..3036ccd9d17 100644
--- a/TAO/TAO_IDL/be/be_codegen.cpp
+++ b/TAO/TAO_IDL/be/be_codegen.cpp
@@ -889,11 +889,13 @@ TAO_CodeGen::start_anyop_header (const char *fname)
// We want the empty file not only with -GX
// but also when -GA appears with -Sa or -St.
- bool gen_empty_file = be_global->gen_empty_anyop_header ()
- || be_global->gen_anyop_files ()
- && !be_global->any_support ();
+ // (JP) Not so - what if we are just passing along an *A.h
+ // from a safe_include?
+// bool gen_empty_file = be_global->gen_empty_anyop_header ()
+// || be_global->gen_anyop_files ()
+// && !be_global->tc_support ();
- if (gen_empty_file)
+ if (be_global->gen_empty_anyop_header ())
{
*this->anyop_header_ << be_nl
<< "// Generated empty file" << be_nl
@@ -968,7 +970,7 @@ TAO_CodeGen::start_anyop_header (const char *fname)
// If we have not suppressed Any operator generation and also
// are not generating the operators in a separate file, we
// need to include the *A.h file from all .pidl files here.
- if (be_global->any_support ())
+ if (be_global->gen_anyop_files ())
{
for (size_t j = 0; j < idl_global->n_included_idl_files (); ++j)
{
@@ -1039,7 +1041,7 @@ TAO_CodeGen::start_anyop_header (const char *fname)
int
TAO_CodeGen::start_anyop_source (const char *fname)
{
- if (!be_global->gen_anyop_files () || !be_global->any_support ())
+ if (!be_global->gen_anyop_files ())
{
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp
index 4ce67d3821c..aed5fa92848 100644
--- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_root/root.cpp
@@ -325,13 +325,13 @@ int be_visitor_root::visit_root (be_root *node)
{
be_visitor_root_any_op visitor (&ctx);
status = node->accept (&visitor);
+ }
- // Conditional switch to the *A.h stream is done
- // in the visitor constructor.
- if (be_global->gen_anyop_files ())
- {
- (void) tao_cg->end_anyop_header ();
- }
+ // Conditional switch to the *A.h stream is done
+ // in the visitor constructor.
+ if (be_global->gen_anyop_files ())
+ {
+ (void) tao_cg->end_anyop_header ();
}
break;
@@ -344,15 +344,16 @@ int be_visitor_root::visit_root (be_root *node)
{
be_visitor_root_any_op visitor (&ctx);
status = node->accept (&visitor);
+ }
- // Conditional switch to the *A.cpp stream is done
- // in the visitor constructor.
- if (be_global->gen_anyop_files ())
- {
- (void) tao_cg->end_anyop_source ();
- }
+ // Conditional switch to the *A.cpp stream is done
+ // in the visitor constructor.
+ if (be_global->gen_anyop_files ())
+ {
+ (void) tao_cg->end_anyop_source ();
}
+
break;
}
case TAO_CodeGen::TAO_ROOT_IH:
diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp
index 98c015f982e..2fe589782d5 100644
--- a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp
@@ -46,7 +46,6 @@ be_visitor_structure_cs::visit_structure (be_structure *node)
if (be_global->tc_support ())
{
be_visitor_context ctx (*this->ctx_);
- // ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE);
TAO::be_visitor_struct_typecode visitor (&ctx);
if (visitor.visit_structure (node) == -1)
diff --git a/TAO/orbsvcs/orbsvcs/CosNotification.mpc b/TAO/orbsvcs/orbsvcs/CosNotification.mpc
index b2bf627852e..22d88f1522b 100644
--- a/TAO/orbsvcs/orbsvcs/CosNotification.mpc
+++ b/TAO/orbsvcs/orbsvcs/CosNotification.mpc
@@ -246,7 +246,7 @@ project(CosNotification_Persist) : notification_serv, orbsvcs_output, install, a
}
}
-project(CosNotification_MC): tao_versioning_idl_defaults, orbsvcs_output, naming, portableserver, iortable, install {
+project(CosNotification_MC): tao_versioning_idl_defaults, orbsvcs_output, naming, tao_monitor, iortable, install {
sharedname = TAO_CosNotification_MC
dynamicflags = TAO_NOTIFY_MC_BUILD_DLL
tagchecks += Notify
@@ -274,7 +274,7 @@ project(CosNotification_MC): tao_versioning_idl_defaults, orbsvcs_output, naming
}
}
-project(CosNotification_MC_Ext): notification_serv, orbsvcs_output, notification_mc, install {
+project(CosNotification_MC_Ext): notification_serv, orbsvcs_output, notification_mc, tao_monitor, install {
sharedname = TAO_CosNotification_MC_Ext
dynamicflags = TAO_NOTIFY_MC_EXT_BUILD_DLL
tagchecks += Notify
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp
index e6d52d6bdb0..09638e1e7f1 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.cpp
@@ -1,5 +1,6 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/Control.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Control.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -8,8 +9,14 @@ TAO_NS_Control::~TAO_NS_Control (void)
}
TAO_NS_Control::TAO_NS_Control (const char* name)
- : TAO_NS_Generic (name)
+ : name_ (name)
+{
+}
+
+const ACE_CString&
+TAO_NS_Control::name (void) const
{
+ return this->name_;
}
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.h
index d04c998a669..195a7c127b2 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control.h
@@ -1,10 +1,15 @@
// $Id$
+
#ifndef CONTROL_H
#define CONTROL_H
#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
-#include "orbsvcs/Notify/MonitorControl/Generic.h"
+
+#include "ace/SString.h"
+
+#include "tao/Versioned_Namespace.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/notify_mc_export.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -14,12 +19,15 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL
#define TAO_NS_CONTROL_REMOVE_CONSUMERADMIN "remove_consumeradmin"
#define TAO_NS_CONTROL_REMOVE_SUPPLIERADMIN "remove_supplieradmin"
-class TAO_Notify_MC_Export TAO_NS_Control: public TAO_NS_Generic
+class TAO_Notify_MC_Export TAO_NS_Control
{
public:
/// This is here due to virtual functions.
virtual ~TAO_NS_Control (void);
+ /// Return the name of this control object.
+ const ACE_CString& name (void) const;
+
/// Execute the control object. Only return false if the command
/// specified is not supported.
virtual bool execute (const char* command) = 0;
@@ -27,9 +35,13 @@ public:
protected:
/// Construct a control object.
TAO_NS_Control (const char* name);
+
+private:
+ ACE_CString name_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
+
#endif /* CONTROL_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp
index 797a8870f16..bf33ede852c 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.cpp
@@ -6,13 +6,104 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_Control_Registry*
TAO_Control_Registry::instance (void)
{
- return TAO_Singleton<TAO_Control_Registry, TAO_SYNCH_MUTEX>::instance();
+ return TAO_Singleton<TAO_Control_Registry, TAO_SYNCH_MUTEX>::instance ();
+}
+
+TAO_Control_Registry::~TAO_Control_Registry (void)
+{
+ ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
+
+ Map::iterator itr (this->map_);
+ Map::value_type* entry = 0;
+
+ while (itr.next (entry))
+ {
+ delete entry->item ();
+ itr.advance ();
+ }
+}
+
+bool
+TAO_Control_Registry::add (TAO_NS_Control* type)
+{
+ ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false);
+
+ if (type == 0)
+ {
+ throw Map_Error (Map_Error::MAP_ERROR_INVALID_VALUE);
+ }
+
+ int status = this->map_.bind(type->name(), type);
+
+ if (status == -1)
+ {
+ throw Map_Error (Map_Error::MAP_ERROR_BIND_FAILURE);
+ }
+ else if (status == 0)
+ {
+ // Invalidate the name list cache.
+ this->name_cache_.length (0);
+ }
+
+ return (status == 0);
+}
+
+bool
+TAO_Control_Registry::remove (const ACE_CString& name)
+{
+ ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false);
+
+ Map::data_type type = 0;
+ int status = this->map_.unbind(name, type);
+
+ if (status != 0)
+ {
+ return false;
+ }
+
+ // Invalidate the name list cache.
+ this->name_cache_.length (0);
+ delete type;
+ return true;
+}
+
+const TAO_Control_Registry::NameList&
+TAO_Control_Registry::names (void)
+{
+ if (this->name_cache_.length () == 0)
+ {
+ ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
+ guard,
+ this->mutex_,
+ this->name_cache_);
+
+ if (this->name_cache_.length () == 0)
+ {
+ CORBA::ULong length = 0;
+ Map::iterator itr (this->map_);
+ Map::value_type* entry = 0;
+
+ while (itr.next (entry))
+ {
+ this->name_cache_.length (length + 1);
+ this->name_cache_[length++] =
+ CORBA::string_dup (entry->key ().c_str ());
+ itr.advance ();
+ }
+ }
+ }
+
+ return this->name_cache_;
}
TAO_NS_Control*
TAO_Control_Registry::get (const ACE_CString& name) const
{
- return dynamic_cast<TAO_NS_Control*> (this->getobj (name));
+ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
+
+ Map::data_type type = 0;
+ this->map_.find (name, type);
+ return type;
}
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h
index 3cc269ed2ef..784f2a047f9 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h
@@ -1,28 +1,82 @@
// $Id$
+
#ifndef CONTROL_REGISTRY_H
#define CONTROL_REGISTRY_H
#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControl/Generic_Registry.h"
-#include "orbsvcs/Notify/MonitorControl/Control.h"
+#include "tao/TAO_Singleton.h"
+
+#include "tao/Monitor/Monitor.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Control.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-class TAO_Notify_MC_Export TAO_Control_Registry:
- public TAO_Generic_Registry
+class TAO_Notify_MC_Export TAO_Control_Registry
{
public:
+ /// Reusing NameList that comes from the TAO Monitor library.
+ typedef Monitor::NameList NameList;
+
+ /// Exception thrown in the event that something goes wrong
+ /// when adding to the registry
+ class TAO_Notify_MC_Export Map_Error
+ {
+ public:
+ enum ErrorReason
+ {
+ MAP_ERROR_BIND_FAILURE,
+ MAP_ERROR_INVALID_VALUE
+ };
+
+ ErrorReason why_;
+
+ Map_Error (ErrorReason why)
+ : why_ (why)
+ {
+ }
+ };
+
/// Return the singleton instance of the registry
static TAO_Control_Registry* instance (void);
+ /// Empty out the map of objects
+ ~TAO_Control_Registry (void);
+
+ /// Adds an object to the map.
+ /// Throws Map_Error if the object is null or if there
+ /// is a fatal error adding it to the map.
+ /// Returns true if the object is successfully added to the map.
+ /// Returns false otherwise.
+ bool add (TAO_NS_Control* type);
+
+ /// Removes an object from the map.
+ /// Returns true if the object is successfully removed from the map.
+ /// Returns false otherwise.
+ bool remove (const ACE_CString& name);
+
+ /// Returns a list of names stored in the registry
+ const NameList& names (void);
+
/// Gets an object from the map
/// Returns the object if it is successfully located.
/// Returns null otherwise.
TAO_NS_Control* get (const ACE_CString& name) const;
+
+private:
+ typedef ACE_Hash_Map_Manager<ACE_CString,
+ TAO_NS_Control*,
+ ACE_SYNCH_NULL_MUTEX>
+ Map;
+
+ mutable TAO_SYNCH_RW_MUTEX mutex_;
+ Map map_;
+ NameList name_cache_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
+
#endif /* CONTROL_REGISTRY_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h
index 9fe2e9eda9e..455604757f9 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h
@@ -1,14 +1,16 @@
// $Id$
+
#ifndef DYNAMIC_STATISTIC_H
#define DYNAMIC_STATISTIC_H
#include /**/ "ace/pre.h"
+
#include "orbsvcs/Notify/MonitorControl/Statistic.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
template <typename TYPE>
-class TAO_Dynamic_Statistic: public TAO_Statistic
+class TAO_Dynamic_Statistic : public TAO_Statistic
{
public:
/// Construct the dynamic statistic. It is assumed that
@@ -17,8 +19,9 @@ public:
TAO_Dynamic_Statistic (TYPE* interf,
const char* name,
TAO_Statistic::Information_Type type)
- : TAO_Statistic (name, type),
- interf_ (interf) {
+ : TAO_Statistic (name, type),
+ interf_ (interf)
+ {
}
/// Take the interface, calculate the statistic and
@@ -33,4 +36,5 @@ protected:
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
+
#endif /* DYNAMIC_STATISTIC_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.cpp
deleted file mode 100644
index c0552a9e328..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// $Id$
-#include "orbsvcs/Notify/MonitorControl/Generic.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-TAO_NS_Generic::~TAO_NS_Generic (void)
-{
-}
-
-const ACE_CString&
-TAO_NS_Generic::name (void) const
-{
- return this->name_;
-}
-
-TAO_NS_Generic::TAO_NS_Generic (const char* name)
- : name_ (name)
-{
-}
-
-TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.h
deleted file mode 100644
index 49eb1a4999b..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-#ifndef GENERIC_H
-#define GENERIC_H
-
-#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
-
-#include "tao/Versioned_Namespace.h"
-#include "ace/SString.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-class TAO_Notify_MC_Export TAO_NS_Generic
-{
-public:
- /// Ensure that the correct destructor is called by making it virtual
- virtual ~TAO_NS_Generic (void);
-
- /// Return the name of this control object
- const ACE_CString& name (void) const;
-
-protected:
- /// Construct a control object.
- TAO_NS_Generic (const char* name);
-
-private:
- ACE_CString name_;
-};
-
-TAO_END_VERSIONED_NAMESPACE_DECL
-
-#include /**/ "ace/post.h"
-#endif /* GENERIC_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.cpp
deleted file mode 100644
index e3ca10c0bb3..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// $Id$
-#include "orbsvcs/Notify/MonitorControl/Generic_Registry.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-TAO_Generic_Registry::~TAO_Generic_Registry (void)
-{
- ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
- Map::iterator itr (this->map_);
- Map::value_type* entry = 0;
- while (itr.next (entry))
- {
- delete entry->item ();
- itr.advance ();
- }
-}
-
-bool
-TAO_Generic_Registry::add(TAO_NS_Generic* type)
-{
- ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false);
- if (type == 0)
- throw Map_Error (Map_Error::MAP_ERROR_INVALID_VALUE);
-
- int status = this->map_.bind(type->name(), type);
- if (status == -1)
- {
- throw Map_Error (Map_Error::MAP_ERROR_BIND_FAILURE);
- }
- else if (status == 0)
- {
- // Invalidate the name list cache
- this->name_cache_.length (0);
- }
- return (status == 0);
-}
-
-bool
-TAO_Generic_Registry::remove(const ACE_CString& name)
-{
- ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false);
- Map::data_type type = 0;
- int status = this->map_.unbind(name, type);
- if (status != 0)
- return false;
-
- // Invalidate the name list cache
- this->name_cache_.length (0);
- delete type;
- return true;
-}
-
-const TAO_Generic_Registry::NameList&
-TAO_Generic_Registry::names (void)
-{
- if (this->name_cache_.length () == 0)
- {
- ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
- this->mutex_, this->name_cache_);
-
- if (this->name_cache_.length () == 0)
- {
- CORBA::ULong length = 0;
- Map::iterator itr (this->map_);
- Map::value_type* entry = 0;
- while (itr.next (entry))
- {
- this->name_cache_.length (length + 1);
- this->name_cache_[length++] =
- CORBA::string_dup (entry->key ().c_str ());
- itr.advance ();
- }
- }
- }
-
- return this->name_cache_;
-}
-
-TAO_NS_Generic*
-TAO_Generic_Registry::getobj(const ACE_CString& name) const
-{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
- Map::data_type type = 0;
- this->map_.find(name, type);
- return type;
-}
-
-TAO_END_VERSIONED_NAMESPACE_DECL
-
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.h
deleted file mode 100644
index 44629bfbaba..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Generic_Registry.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// $Id$
-#ifndef GENERIC_REGISTRY_H
-#define GENERIC_REGISTRY_H
-
-#include /**/ "ace/pre.h"
-
-#include "ace/SString.h"
-#include "ace/Null_Mutex.h"
-#include "ace/Hash_Map_Manager_T.h"
-#include "tao/TAO_Singleton.h"
-#include "orbsvcs/Notify/MonitorControl/Generic.h"
-#include "orbsvcs/Notify/MonitorControl/NotificationServiceMCC.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-class TAO_Notify_MC_Export TAO_Generic_Registry
-{
-public:
- /// In order to minimize the number of allocations, we're reusing the
- /// NameList that comes from the idl generated interface
- /// CosNotification::NotificationServiceMonitor
- typedef CosNotification::NotificationServiceMonitorControl::NameList NameList;
-
- /// Exception thrown in the event that something goes wrong
- /// when adding to the registry
- class TAO_Notify_MC_Export Map_Error
- {
- public:
- enum ErrorReason { MAP_ERROR_BIND_FAILURE, MAP_ERROR_INVALID_VALUE };
-
- ErrorReason why_;
-
- Map_Error (ErrorReason why)
- : why_ (why) {
- }
- };
-
- /// Empty out the map of objects
- ~TAO_Generic_Registry (void);
-
- /// Adds an object to the map.
- /// Throws Map_Error if the object is null or if there
- /// is a fatal error adding it to the map.
- /// Returns true if the object is successfully added to the map.
- /// Returns false otherwise.
- bool add (TAO_NS_Generic* type);
-
- /// Removes an object from the map.
- /// Returns true if the object is successfully removed from the map.
- /// Returns false otherwise.
- bool remove (const ACE_CString& name);
-
- /// Returns a list of names stored in the registry
- const NameList& names (void);
-
-protected:
- /// Gets an object from the map
- /// Returns the object if it is successfully located.
- /// Returns null otherwise.
- TAO_NS_Generic* getobj (const ACE_CString& name) const;
-
-private:
- typedef ACE_Hash_Map_Manager<ACE_CString,
- TAO_NS_Generic*,
- ACE_SYNCH_NULL_MUTEX> Map;
-
- mutable TAO_SYNCH_RW_MUTEX mutex_;
- Map map_;
- NameList name_cache_;
-};
-
-TAO_END_VERSIONED_NAMESPACE_DECL
-
-#include /**/ "ace/post.h"
-#endif /* GENERIC_REGISTRY_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp
index fa15e522f78..93173e4615c 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.cpp
@@ -1,6 +1,8 @@
// $Id$
+
#include "orbsvcs/Notify/MonitorControl/MonitorManager.h"
#include "orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h"
+
#include "orbsvcs/Naming/Naming_Client.h"
#include "tao/ORB.h"
@@ -20,10 +22,17 @@ int
TAO_MonitorManager::init (int argc, ACE_TCHAR* argv[])
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->task_.mutex_, -1);
+
this->task_.argv_.add ("fake_process_name");
- ACE_Get_Opt opts (argc, argv, ACE_TEXT ("o:"), 0, 0,
- ACE_Get_Opt::PERMUTE_ARGS, 1);
+ ACE_Get_Opt opts (argc,
+ argv,
+ ACE_TEXT ("o:"),
+ 0,
+ 0,
+ ACE_Get_Opt::PERMUTE_ARGS,
+ 1);
+
static const ACE_TCHAR* orbarg = ACE_TEXT ("ORBArg");
static const ACE_TCHAR* nonamesvc = ACE_TEXT ("NoNameSvc");
opts.long_option (orbarg, ACE_Get_Opt::ARG_REQUIRED);
@@ -64,10 +73,13 @@ TAO_MonitorManager::fini (void)
if (!CORBA::is_nil (this->task_.orb_.in ()))
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->task_.mutex_, -1);
- if (!CORBA::is_nil (this->task_.orb_.in ())) {
- this->task_.orb_->shutdown (true);
- }
+
+ if (!CORBA::is_nil (this->task_.orb_.in ()))
+ {
+ this->task_.orb_->shutdown (true);
+ }
}
+
this->task_.wait ();
return 0;
}
@@ -84,26 +96,32 @@ TAO_MonitorManager::run (void)
// so any libs are loaded in the parent thread.
// Initialize the ORB
int argc = task_.argv_.argc ();
- task_.orb_ = CORBA::ORB_init (argc, task_.argv_.argv ()
- , task_.mc_orb_name_.c_str());
+ task_.orb_ = CORBA::ORB_init (argc,
+ task_.argv_.argv (),
+ task_.mc_orb_name_.c_str ());
- if (!this->run_) {
- this->run_ = true;
- activate = true;
- }
+ if (!this->run_)
+ {
+ this->run_ = true;
+ activate = true;
+ }
}
int status = 0;
- if (activate) {
- status = this->task_.activate ();
- if (status == 0) {
- //cj: Wait till the child thread has initialized completely
- // It still leaves a tiny race window open, but hopefully not much.
- // The race condition R1 is in ORBTask::svc
-
- this->task_.startup_barrier_.wait ();
+
+ if (activate)
+ {
+ status = this->task_.activate ();
+
+ if (status == 0)
+ {
+ // cj: Wait till the child thread has initialized completely
+ // It still leaves a tiny race window open, but hopefully not much.
+ // The race condition R1 is in ORBTask::svc().
+
+ this->task_.startup_barrier_.wait ();
+ }
}
- }
return status;
}
@@ -120,8 +138,11 @@ TAO_MonitorManager::shutdown (void)
TAO_MonitorManager* monitor =
ACE_Dynamic_Service<TAO_MonitorManager>::instance (
TAO_NOTIFY_MONITOR_CONTROL_MANAGER);
+
if (monitor != 0)
- monitor->fini ();
+ {
+ monitor->fini ();
+ }
}
TAO_MonitorManager::ORBTask::ORBTask (void)
@@ -137,12 +158,15 @@ TAO_MonitorManager::ORBTask::svc (void)
try
{
if (CORBA::is_nil (this->orb_.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) TAO_MonitorManager: Unable to "
- "initialize the ORB\n"),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) TAO_MonitorManager: Unable to "
+ "initialize the ORB\n"),
+ 1);
+ }
PortableServer::POA_var poa;
+
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
@@ -150,11 +174,14 @@ TAO_MonitorManager::ORBTask::svc (void)
this->orb_->resolve_initial_references ("RootPOA");
poa = PortableServer::POA::_narrow (obj.in ());
+
if (CORBA::is_nil (poa.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) TAO_MonitorManager: Unable to "
- "resolve the RootPOA\n"),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) TAO_MonitorManager: Unable to "
+ "resolve the RootPOA\n"),
+ 1);
+ }
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
poa_manager->activate ();
@@ -173,11 +200,15 @@ TAO_MonitorManager::ORBTask::svc (void)
CORBA::String_var ior = this->orb_->object_to_string (monitor.in ());
obj = this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var iortable = IORTable::Table::_narrow (obj.in ());
+
if (CORBA::is_nil (iortable.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) TAO_MonitorManager: Unable to "
- "resolve the IORTable\n"),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) TAO_MonitorManager: Unable to "
+ "resolve the IORTable\n"),
+ 1);
+ }
+
iortable->bind(mc_orb_name_.c_str(), ior.in ());
if (this->use_name_svc_)
@@ -193,12 +224,15 @@ TAO_MonitorManager::ORBTask::svc (void)
if (this->ior_output_.length () > 0)
{
FILE* fp = ACE_OS::fopen (this->ior_output_.c_str (), "w");
+
if (fp == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) TAO_MonitorManager: "
- "Unable to write to %s\n"),
- this->ior_output_.c_str ()),
- 1);
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_MonitorManager: "
+ "Unable to write to %s\n"),
+ this->ior_output_.c_str ()),
+ 1);
+ }
else
{
ACE_OS::fprintf (fp, "%s", ior.in ());
@@ -221,6 +255,7 @@ TAO_MonitorManager::ORBTask::svc (void)
{
poa->destroy (true, true);
}
+
this->orb_->destroy ();
// Set to nil to avoid double shutdown in TAO_MonitorManager::fini()
@@ -237,8 +272,10 @@ TAO_MonitorManager::ORBTask::svc (void)
catch (...)
{
}
+
this->orb_ = CORBA::ORB::_nil ();
}
+
ex._tao_print_exception ("Caught in "
"TAO_MonitorManager::ORBTask::svc");
}
@@ -255,6 +292,7 @@ TAO_MonitorManager::ORBTask::svc (void)
}
this->orb_ = CORBA::ORB::_nil ();
}
+
ACE_ERROR ((LM_ERROR,
"Unexpected exception type caught "
"in TAO_MonitorManager::ORBTask::svc"));
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h
index 699e513e311..0d2accd4572 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/MonitorManager.h
@@ -1,11 +1,14 @@
// $Id$
+
#ifndef MONITORMANAGER_H
#define MONITORMANAGER_H
#include /**/ "ace/pre.h"
+
#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
#include "tao/ORB.h"
+
#include "ace/Service_Object.h"
#include "ace/Task.h"
#include "ace/ARGV.h"
@@ -14,7 +17,7 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-class TAO_Notify_MC_Export TAO_MonitorManager: public ACE_Service_Object
+class TAO_Notify_MC_Export TAO_MonitorManager : public ACE_Service_Object
{
public:
/// Perform member initialization
@@ -63,4 +66,5 @@ ACE_STATIC_SVC_DECLARE_EXPORT(TAO_Notify_MC, TAO_MonitorAndControl)
ACE_FACTORY_DECLARE(TAO_Notify_MC, TAO_MonitorAndControl)
#include /**/ "ace/post.h"
+
#endif /* MONITORMANAGER_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl
index e3b04e52062..4b18242fbd0 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMC.idl
@@ -11,7 +11,8 @@
#ifndef NOTIFICATIONSERVICEMC_IDL
#define NOTIFICATIONSERVICEMC_IDL
-#include <orb.idl>
+//#include <orb.idl>
+#include "tao/Monitor/Monitor_include.pidl"
#pragma prefix "sandia.gov"
@@ -40,31 +41,31 @@ module CosNotification
double last;
};
- typedef sequence<string> NameList;
+// typedef sequence<string> NameList;
exception InvalidName {
- NameList names;
+ Monitor::NameList names;
};
enum DataType { DATA_NUMERIC, DATA_TEXT };
union Data switch (DataType) {
case DATA_NUMERIC: Numeric num;
- case DATA_TEXT: NameList list;
+ case DATA_TEXT: Monitor::NameList list;
};
- NameList get_statistic_names ();
+ Monitor::NameList get_statistic_names ();
Data get_statistic (in string name)
raises (InvalidName);
typedef sequence<Data> DataList;
- DataList get_statistics (in NameList names)
+ DataList get_statistics (in Monitor::NameList names)
raises (InvalidName);
- DataList get_and_clear_statistics (in NameList names)
+ DataList get_and_clear_statistics (in Monitor::NameList names)
raises (InvalidName);
- void clear_statistics (in NameList names)
+ void clear_statistics (in Monitor::NameList names)
raises (InvalidName);
// Control commands begin here
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp
index b83f5dd815f..a987165ef9f 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.cpp
@@ -1,41 +1,65 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
-#include "orbsvcs/Notify/MonitorControl/Control_Registry.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h"
+
#include "ace/Auto_Ptr.h"
+#include "ace/Monitor_Point_Registry.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Control_Registry.h"
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
NotificationServiceMonitor_i::NotificationServiceMonitor_i (CORBA::ORB_ptr orb)
- : orb_ (CORBA::ORB::_duplicate (orb))
+ : orb_ (CORBA::ORB::_duplicate (orb))
{
}
-CosNotification::NotificationServiceMonitorControl::NameList*
+Monitor::NameList*
NotificationServiceMonitor_i::get_statistic_names (void)
{
- CosNotification::NotificationServiceMonitorControl::NameList* names = 0;
- ACE_NEW_RETURN (names,
- CosNotification::NotificationServiceMonitorControl::NameList (
- TAO_Statistic_Registry::instance ()->names ()),
+ Monitor_Control_Types::NameList name_list =
+ Monitor_Point_Registry::instance ()->names ();
+ CORBA::ULong the_length = name_list.size ();
+
+ Monitor::NameList* the_names = 0;
+ ACE_NEW_RETURN (the_names,
+ Monitor::NameList (the_length),
0);
- return names;
+ Monitor::NameList_var safe_names = the_names;
+ the_names->length (the_length);
+ CORBA::ULong i = 0;
+
+ for (Monitor_Control_Types::NameList::Iterator iter (name_list);
+ !iter.done ();
+ iter.advance (), ++i)
+ {
+ ACE_CString* tmp = 0;
+ iter.next (tmp);
+ safe_names[i] = tmp->c_str ();
+ }
+
+ return safe_names._retn ();
}
CosNotification::NotificationServiceMonitorControl::Data*
NotificationServiceMonitor_i::get_statistic (const char* name)
{
- TAO_Statistic_Registry* registry = TAO_Statistic_Registry::instance ();
+ Monitor_Point_Registry* registry = Monitor_Point_Registry::instance ();
- CosNotification::NotificationServiceMonitorControl::NameList invalid;
- CosNotification::NotificationServiceMonitorControl::NameList names (1);
+ Monitor::NameList invalid;
+ Monitor::NameList names (1);
names.length (1);
names[0] = name;
this->get_invalid_names (registry, names, invalid);
if (invalid.length () > 0)
- throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
-
+ {
+ throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
+ }
+
CosNotification::NotificationServiceMonitorControl::Data* data = 0;
ACE_NEW_THROW_EX (data,
CosNotification::NotificationServiceMonitorControl::Data,
@@ -45,16 +69,19 @@ NotificationServiceMonitor_i::get_statistic (const char* name)
}
CosNotification::NotificationServiceMonitorControl::DataList*
-NotificationServiceMonitor_i::get_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names)
+NotificationServiceMonitor_i::get_statistics (const Monitor::NameList& names)
{
- TAO_Statistic_Registry* registry = TAO_Statistic_Registry::instance ();
+ Monitor_Point_Registry* registry = Monitor_Point_Registry::instance ();
- CosNotification::NotificationServiceMonitorControl::NameList invalid;
+ Monitor::NameList invalid;
this->get_invalid_names (registry, names, invalid);
+
if (invalid.length () > 0)
- throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
-
- CORBA::ULong length = names.length();
+ {
+ throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
+ }
+
+ CORBA::ULong length = names.length ();
CosNotification::NotificationServiceMonitorControl::DataList* data = 0;
ACE_NEW_RETURN (data,
CosNotification::NotificationServiceMonitorControl::DataList (
@@ -64,15 +91,18 @@ NotificationServiceMonitor_i::get_statistics (const CosNotification::Notificatio
safe_data (data);
data->length (length);
- for(CORBA::ULong i = 0; i < length; i++)
+
+ for (CORBA::ULong i = 0; i < length; ++i)
{
this->get_data (registry, names[i], (*data)[i]);
}
+
return safe_data.release ();
}
CosNotification::NotificationServiceMonitorControl::DataList*
-NotificationServiceMonitor_i::get_and_clear_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names)
+NotificationServiceMonitor_i::get_and_clear_statistics (
+ const Monitor::NameList& names)
{
CosNotification::NotificationServiceMonitorControl::DataList* data =
this->get_statistics (names);
@@ -82,33 +112,45 @@ NotificationServiceMonitor_i::get_and_clear_statistics (const CosNotification::N
// to change at this point. So, I'm bypassing the call to
// clear_statistics() to avoid a possible exception.
CORBA::ULong length = names.length();
- TAO_Statistic_Registry* registry = TAO_Statistic_Registry::instance ();
- for(CORBA::ULong i = 0; i < length; i++)
+ Monitor_Point_Registry* registry = Monitor_Point_Registry::instance ();
+
+ for (CORBA::ULong i = 0; i < length; ++i)
{
- TAO_Statistic* statistic = registry->get (names[i].in ());
+ Monitor_Base* statistic = registry->get (names[i].in ());
+
if (statistic != 0)
- statistic->clear();
+ {
+ statistic->clear ();
+ }
}
return data;
}
void
-NotificationServiceMonitor_i::clear_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names)
+NotificationServiceMonitor_i::clear_statistics (
+ const Monitor::NameList& names)
{
- TAO_Statistic_Registry* registry = TAO_Statistic_Registry::instance ();
+ Monitor_Point_Registry* registry = Monitor_Point_Registry::instance ();
- CosNotification::NotificationServiceMonitorControl::NameList invalid;
+ Monitor::NameList invalid;
this->get_invalid_names (registry, names, invalid);
+
if (invalid.length () > 0)
- throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
-
- CORBA::ULong length = names.length();
- for(CORBA::ULong i = 0; i < length; i++)
{
- TAO_Statistic* statistic = registry->get (names[i].in ());
+ throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
+ }
+
+ CORBA::ULong length = names.length ();
+
+ for (CORBA::ULong i = 0; i < length; ++i)
+ {
+ Monitor_Base* statistic = registry->get (names[i].in ());
+
if (statistic != 0)
- statistic->clear();
+ {
+ statistic->clear ();
+ }
}
}
@@ -156,7 +198,7 @@ NotificationServiceMonitor_i::send_control_command (const char* name,
// control object.
if (control == 0 || !control->execute (cmd))
{
- CosNotification::NotificationServiceMonitorControl::NameList invalid (1);
+ Monitor::NameList invalid (1);
invalid.length (1);
invalid[0] = name;
throw CosNotification::NotificationServiceMonitorControl::InvalidName (invalid);
@@ -167,17 +209,20 @@ void
NotificationServiceMonitor_i::shutdown (void)
{
if (!CORBA::is_nil (this->orb_.in ()))
- this->orb_->shutdown ();
+ {
+ this->orb_->shutdown ();
+ }
}
void
NotificationServiceMonitor_i::get_data (
- TAO_Statistic_Registry* registry,
- const char* name,
- CosNotification::NotificationServiceMonitorControl::Data& data)
+ Monitor_Point_Registry* registry,
+ const char* name,
+ CosNotification::NotificationServiceMonitorControl::Data& data)
{
- // Get the statistic by name
- TAO_Statistic* statistic = registry->get (name);
+ // Get the statistic by name.
+ TAO_Statistic* statistic =
+ dynamic_cast<TAO_Statistic*> (registry->get (name));
if (statistic == 0)
{
@@ -200,20 +245,23 @@ NotificationServiceMonitor_i::get_data (
// the most up-to-date information. A counter will always have
// the correct value.
if (statistic->type () != TAO_Statistic::TS_COUNTER)
- statistic->calculate ();
+ {
+ statistic->calculate ();
+ }
// Populate the data structure based on the type of statistic
if (statistic->type () == TAO_Statistic::TS_LIST)
{
TAO_Statistic::List slist (statistic->get_list ());
CORBA::ULong size = static_cast<CORBA::ULong> (slist.size ());
- CosNotification::NotificationServiceMonitorControl::NameList
- list (size);
+ Monitor::NameList list (size);
list.length (size);
- for(CORBA::ULong i = 0; i < size; i++)
+
+ for (CORBA::ULong i = 0; i < size; ++i)
{
list[i] = CORBA::string_dup (slist[i].c_str ());
}
+
data.list (list);
}
else
@@ -232,8 +280,9 @@ NotificationServiceMonitor_i::get_data (
else
{
num.average = statistic->average ();
- num.sum_of_squares = statistic->sum_of_squares();
+ num.sum_of_squares = statistic->sum_of_squares ();
}
+
data.num (num);
}
}
@@ -241,15 +290,16 @@ NotificationServiceMonitor_i::get_data (
void
NotificationServiceMonitor_i::get_invalid_names (
- TAO_Statistic_Registry* registry,
- const CosNotification::NotificationServiceMonitorControl::NameList& names,
- CosNotification::NotificationServiceMonitorControl::NameList& invalid)
+ Monitor_Point_Registry* registry,
+ const Monitor::NameList& names,
+ Monitor::NameList& invalid)
{
invalid.length (0);
CORBA::ULong ilength = 0;
CORBA::ULong length = names.length ();
- for(CORBA::ULong i = 0; i < length; i++)
+
+ for (CORBA::ULong i = 0; i < length; ++i)
{
if (registry->get (names[i].in ()) == 0)
{
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h
index 26c06711dbc..9186c0894cd 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/NotificationServiceMonitor_i.h
@@ -1,18 +1,32 @@
// $Id$
+
#ifndef NOTIFICATIONSERVICEMONITOR_I_H
#define NOTIFICATIONSERVICEMONITOR_I_H
#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
#include "orbsvcs/Notify/MonitorControl/NotificationServiceMCS.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
+
#include "tao/ORB.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace Monitor_Control
+ {
+ class Monitor_Point_Registry;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-class TAO_Notify_MC_Export NotificationServiceMonitor_i:
- public virtual POA_CosNotification::NotificationServiceMonitorControl
+class TAO_Notify_MC_Export NotificationServiceMonitor_i
+ : public virtual POA_CosNotification::NotificationServiceMonitorControl
{
public:
/// Construct a monitor service. If the orb parameter is provided,
@@ -20,25 +34,23 @@ public:
NotificationServiceMonitor_i (CORBA::ORB_ptr orb = 0);
/// Get a list of statistic names
- virtual CosNotification::NotificationServiceMonitorControl::NameList*
- get_statistic_names (void);
+ virtual Monitor::NameList* get_statistic_names (void);
/// Get the data from a single statistic
virtual CosNotification::NotificationServiceMonitorControl::Data*
- get_statistic (const char* name);
+ get_statistic (const char* name);
/// Get the data from multiple statistic instances
virtual CosNotification::NotificationServiceMonitorControl::DataList*
- get_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names);
+ get_statistics (const Monitor::NameList& names);
/// Get the data from multiple statistic instances and clear them
/// directly afterward
virtual CosNotification::NotificationServiceMonitorControl::DataList*
- get_and_clear_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names);
+ get_and_clear_statistics (const Monitor::NameList& names);
/// Clear the data from multiple statistic instances
- virtual void
- clear_statistics (const CosNotification::NotificationServiceMonitorControl::NameList& names);
+ virtual void clear_statistics (const Monitor::NameList& names);
/// Shut down an event channel by name
virtual void shutdown_event_channel (const char* name);
@@ -62,13 +74,13 @@ private:
void send_control_command (const char* name,
const char* cmd);
- void get_data (TAO_Statistic_Registry* registry,
+ void get_data (Monitor_Point_Registry* registry,
const char* name,
CosNotification::NotificationServiceMonitorControl::Data& data);
- void get_invalid_names (TAO_Statistic_Registry* registry,
- const CosNotification::NotificationServiceMonitorControl::NameList& names,
- CosNotification::NotificationServiceMonitorControl::NameList& invalid);
+ void get_invalid_names (Monitor_Point_Registry* registry,
+ const Monitor::NameList& names,
+ Monitor::NameList& invalid);
CORBA::ORB_var orb_;
};
@@ -76,4 +88,5 @@ private:
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
+
#endif /* NOTIFICATIONSERVICEMONITOR_I_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp
index 154cbe2b8ed..db9135834d3 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.cpp
@@ -1,6 +1,8 @@
// $Id$
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
-#include "tao/SystemException.h"
+
+#include "orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h"
+
+#include "tao/String_Alloc.h"
#if !defined (__ACE_INLINE__)
# include "Statistic.inl"
@@ -10,26 +12,29 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_Statistic::TAO_Statistic (const char* name,
TAO_Statistic::Information_Type type)
- : TAO_NS_Generic (name),
+ : Monitor_Base (name),
type_ (type),
- index_ (0),
+ index_ (0UL),
minimum_set_ (false),
- minimum_ (0),
- maximum_ (0),
- sum_ (0),
- sum_of_squares_ (0),
- last_ (0)
+ minimum_ (0.0),
+ maximum_ (0.0),
+ sum_ (0.0),
+ sum_of_squares_ (0.0),
+ last_ (0.0)
{
}
TAO_Statistic::~TAO_Statistic (void)
{
- ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
if (this->type_ == TS_LIST)
- for(size_t i = 0; i < this->index_; i++)
- {
- delete [] this->data_[i];
- }
+ {
+ for (size_t i = 0UL; i < this->index_; ++i)
+ {
+ delete [] this->data_[i];
+ }
+ }
}
void
@@ -41,9 +46,12 @@ void
TAO_Statistic::receive (double data)
{
if (this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
if (this->type_ != TS_COUNTER)
{
this->sum_ += data;
@@ -59,6 +67,7 @@ TAO_Statistic::receive (double data)
else
{
this->last_ = data;
+
if (!this->minimum_set_)
{
this->minimum_set_ = true;
@@ -68,8 +77,11 @@ TAO_Statistic::receive (double data)
{
this->minimum_ = data;
}
+
if (this->maximum_ < data)
- this->maximum_ = data;
+ {
+ this->maximum_ = data;
+ }
}
}
@@ -77,17 +89,21 @@ void
TAO_Statistic::receive (const TAO_Statistic::List& data)
{
if (this->type_ != TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
- for(size_t i = 0; i < this->index_; i++)
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ for (size_t i = 0UL; i < this->index_; ++i)
{
delete [] this->data_[i];
}
this->index_ = data.size ();
this->data_.max_size (this->index_);
- for(size_t i = 0; i < this->index_; i++)
+
+ for (size_t i = 0UL; i < this->index_; ++i)
{
this->data_[i] = CORBA::string_dup (data[i].c_str ());
}
@@ -96,41 +112,50 @@ TAO_Statistic::receive (const TAO_Statistic::List& data)
void
TAO_Statistic::clear (void)
{
- ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
// If the type is a string list, we need to delete the data
- // before we change the index
+ // before we change the index.
if (this->type_ == TS_LIST)
- for(size_t i = 0; i < this->index_; i++)
- {
- delete [] this->data_[i];
- }
+ {
+ for (size_t i = 0UL; i < this->index_; ++i)
+ {
+ delete [] this->data_[i];
+ }
+ }
- this->index_ = 0;
+ this->index_ = 0UL;
this->minimum_set_ = false;
- this->minimum_ = 0;
- this->maximum_ = 0;
- this->sum_ = 0;
- this->sum_of_squares_ = 0;
- this->last_ = 0;
+ this->minimum_ = 0.0;
+ this->maximum_ = 0.0;
+ this->sum_ = 0.0;
+ this->sum_of_squares_ = 0.0;
+ this->last_ = 0.0;
}
double
TAO_Statistic::average (void) const
{
if (this->type_ == TS_COUNTER || this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
- return (this->index_== 0 ? 0.0 : this->sum_ / this->index_);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ return (this->index_== 0UL ? 0.0 : this->sum_ / this->index_);
}
double
TAO_Statistic::sum_of_squares (void) const
{
if (this->type_ == TS_COUNTER || this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
return this->sum_of_squares_;
}
@@ -138,16 +163,20 @@ TAO_Statistic::List
TAO_Statistic::get_list (void) const
{
if (this->type_ != TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
List list;
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, list);
- for(size_t i = 0; i < this->index_; i++)
+
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, list);
+
+ for (size_t i = 0UL; i < this->index_; ++i)
{
list.push_back (this->data_[i]);
}
+
return list;
-
}
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
index 578102d8700..64bc5a8088c 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.h
@@ -1,30 +1,38 @@
// $Id$
+
#ifndef STATISTIC_H
#define STATISTIC_H
#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
-#include "orbsvcs/Notify/MonitorControl/Generic.h"
-#include "ace/Synch.h"
-#include "ace/SString.h"
+#include "ace/Monitor_Base.h"
#include "ace/Array_Base.h"
-#include "ace/Vector_T.h"
+
#include "tao/Versioned_Namespace.h"
#include "tao/orbconf.h"
+#include "orbsvcs/Notify/MonitorControl/notify_mc_export.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-class TAO_Notify_MC_Export TAO_Statistic: public TAO_NS_Generic
+class TAO_Notify_MC_Export TAO_Statistic : public Monitor_Base
{
public:
/// A statistic can hold various types of data and acts differently
/// depending upon the type of information stored.
- enum Information_Type { TS_COUNTER, TS_NUMBER,
- TS_TIME, TS_INTERVAL, TS_LIST };
+ enum Information_Type
+ {
+ TS_COUNTER,
+ TS_NUMBER,
+ TS_TIME,
+ TS_INTERVAL,
+ TS_LIST
+ };
/// A simple string list.
- typedef ACE_Vector<ACE_CString> List;
+ typedef Monitor_Control_Types::NameList List;
/// This exception is thrown if a method is called that doesn't apply
/// to the type of information being stored.
@@ -40,10 +48,8 @@ public:
/// Perform calculations if the statistic is dynamic.
virtual void calculate (void);
- /// Take the data and store it for later calculations.
- /// It is assumed that the type of data corresponds to
- /// the type specified during construction.
- void receive (double data = 0);
+ /// Override of the base class method.
+ virtual void receive (double data);
/// Take the data and store it.
/// It is assumed that the type of data corresponds to
@@ -82,7 +88,7 @@ public:
private:
Information_Type type_;
- mutable TAO_SYNCH_RW_MUTEX mutex_;
+// mutable TAO_SYNCH_RW_MUTEX mutex_;
size_t index_;
bool minimum_set_;
double minimum_;
@@ -100,4 +106,5 @@ TAO_END_VERSIONED_NAMESPACE_DECL
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
+
#endif /* STATISTIC_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl
index c2d14196137..dba4919302b 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic.inl
@@ -11,18 +11,23 @@ TAO_Statistic::type (void) const
ACE_INLINE size_t
TAO_Statistic::count (void) const
{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
- return (this->type_ == TS_COUNTER ? static_cast<size_t> (this->last_) :
- this->index_);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ return (this->type_ == TS_COUNTER
+ ? static_cast<size_t> (this->last_)
+ : this->index_);
}
ACE_INLINE double
TAO_Statistic::minimum_sample (void) const
{
if (this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation( );
+ }
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
return this->minimum_;
}
@@ -30,9 +35,12 @@ ACE_INLINE double
TAO_Statistic::maximum_sample (void) const
{
if (this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
return this->maximum_;
}
@@ -40,9 +48,12 @@ ACE_INLINE double
TAO_Statistic::last_sample (void) const
{
if (this->type_ == TS_LIST)
- throw Invalid_Operation();
+ {
+ throw Invalid_Operation ();
+ }
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
return this->last_;
}
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.cpp
deleted file mode 100644
index 5e5ee4c89c0..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-TAO_Statistic_Registry*
-TAO_Statistic_Registry::instance (void)
-{
- return TAO_Singleton<TAO_Statistic_Registry, TAO_SYNCH_MUTEX>::instance();
-}
-
-TAO_Statistic*
-TAO_Statistic_Registry::get (const ACE_CString& name) const
-{
- return dynamic_cast<TAO_Statistic*> (this->getobj (name));
-}
-
-TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.h
deleted file mode 100644
index ed8c3a96617..00000000000
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControl/Statistic_Registry.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// $Id$
-#ifndef STATISTIC_REGISTRY_H
-#define STATISTIC_REGISTRY_H
-
-#include /**/ "ace/pre.h"
-
-#include "orbsvcs/Notify/MonitorControl/Generic_Registry.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-class TAO_Notify_MC_Export TAO_Statistic_Registry:
- public TAO_Generic_Registry
-{
-public:
- /// Return the singleton instance of the registry
- static TAO_Statistic_Registry* instance (void);
-
- /// Gets an object from the map
- /// Returns the object if it is successfully located.
- /// Returns null otherwise.
- TAO_Statistic* get (const ACE_CString& name) const;
-};
-
-TAO_END_VERSIONED_NAMESPACE_DECL
-
-#include /**/ "ace/post.h"
-#endif /* STATISTIC_REGISTRY_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp
index da4b7369b06..60d11e7ffb2 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.cpp
@@ -1,4 +1,5 @@
// $Id$
+
#include "orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.h"
#include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h"
#include "orbsvcs/Notify/MonitorControl/Control_Registry.h"
@@ -9,24 +10,29 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-class ConsumerAdminControl: public TAO_NS_Control
+class ConsumerAdminControl : public TAO_NS_Control
{
public:
ConsumerAdminControl (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
CosNotifyChannelAdmin::AdminID id)
- : TAO_NS_Control (name.c_str ()),
- ec_ (ec),
- id_ (id) {
+ : TAO_NS_Control (name.c_str ()),
+ ec_ (ec),
+ id_ (id)
+ {
}
- virtual bool execute (const char* command) {
+ virtual bool execute (const char* command)
+ {
if (ACE_OS::strcmp (command, TAO_NS_CONTROL_REMOVE_CONSUMERADMIN) == 0)
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->ec_->get_consumeradmin (this->id_);
+
if (!CORBA::is_nil (admin.in ()))
- admin->destroy ();
+ {
+ admin->destroy ();
+ }
}
else
{
@@ -42,43 +48,51 @@ private:
};
TAO_MonitorConsumerAdmin::TAO_MonitorConsumerAdmin (void)
- : stat_name_ (),
- control_name_ (),
- queue_size_ (0)
+ : stat_name_ (),
+ control_name_ (),
+ queue_size_ (0)
{
}
TAO_MonitorConsumerAdmin::~TAO_MonitorConsumerAdmin (void)
{
- // First, make sure we can get down to the real ec type
+ // First, make sure we can get down to the real ec type.
TAO_MonitorEventChannel* ec =
dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
+
if (ec != 0)
{
- ec->unregister_statistic (this->stat_name_);
+ ec->unregister_statistic (this->stat_name_.c_str ());
ec->remove_consumeradmin (this->id ());
TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
cinstance->remove (this->control_name_);
}
- // We don't own queue_size_, so we must not delete it
+ // The registry also manages this refcount. The pointer itself
+ // should never be 0 since we throw an exception if anything
+ // fails in allocation or registration.
+ this->queue_size_->remove_ref ();
}
void
TAO_MonitorConsumerAdmin::register_stats_controls (
- TAO_MonitorEventChannel* mec,
- const ACE_CString& base)
+ TAO_MonitorEventChannel* mec,
+ const ACE_CString& base)
{
// Set up the statistic name, create it and register it
this->stat_name_ = base + "/";
this->stat_name_ += NotifyMonitoringExt::EventChannelQueueSize;
+
ACE_NEW_THROW_EX (this->queue_size_,
TAO_Statistic (this->stat_name_.c_str (),
TAO_Statistic::TS_NUMBER),
CORBA::NO_MEMORY ());
+
if (!mec->register_statistic (this->stat_name_, this->queue_size_))
{
- delete this->queue_size_;
+ // The constructor sets the refcount to 1 so this call will
+ // delete the pointer.
+ this->queue_size_->remove_ref ();
this->queue_size_ = 0;
throw NotifyMonitoringExt::NameAlreadyUsed ();
}
@@ -87,6 +101,7 @@ TAO_MonitorConsumerAdmin::register_stats_controls (
// buffering strategy so it can let us know when the queue changes.
TAO_Notify_ThreadPool_Task* tpt =
dynamic_cast<TAO_Notify_ThreadPool_Task*> (this->get_worker_task ());
+
if (tpt != 0)
{
TAO_Notify_Buffering_Strategy* bs = tpt->buffering_strategy ();
@@ -101,32 +116,37 @@ TAO_MonitorConsumerAdmin::register_stats_controls (
this->id ()),
CORBA::NO_MEMORY ());
TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
+
if (!cinstance->add (control))
{
delete control;
- ACE_ERROR ((LM_ERROR, "Unable to add control: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add control: %s\n",
this->control_name_.c_str ()));
}
}
CosNotifyChannelAdmin::ProxySupplier_ptr
TAO_MonitorConsumerAdmin::obtain_named_notification_push_supplier (
- CosNotifyChannelAdmin::ClientType ctype,
- CosNotifyChannelAdmin::ProxyID_out proxy_id,
- const char * name)
+ CosNotifyChannelAdmin::ClientType ctype,
+ CosNotifyChannelAdmin::ProxyID_out proxy_id,
+ const char * name)
{
- // First, make sure we can get down to the real ec type
+ // First, make sure we can get down to the real ec type.
TAO_MonitorEventChannel* ec =
dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
+
if (ec == 0)
- throw CORBA::INTERNAL ();
+ {
+ throw CORBA::INTERNAL ();
+ }
- // Next, create the push consumer proxy
+ // Next, create the push consumer proxy.
CosNotifyChannelAdmin::ProxySupplier_var proxy =
this->TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier (
ctype, proxy_id);
- // Next, map the proxy id to the name in the ec
+ // Next, map the proxy id to the name in the ec.
ec->map_supplier_proxy (proxy_id, name);
return proxy._retn ();
@@ -134,23 +154,26 @@ TAO_MonitorConsumerAdmin::obtain_named_notification_push_supplier (
CosNotifyChannelAdmin::ProxySupplier_ptr
TAO_MonitorConsumerAdmin::obtain_notification_push_supplier (
- CosNotifyChannelAdmin::ClientType ctype,
- CosNotifyChannelAdmin::ProxyID_out proxy_id)
+ CosNotifyChannelAdmin::ClientType ctype,
+ CosNotifyChannelAdmin::ProxyID_out proxy_id)
{
- // First, make sure we can get down to the real ec type
+ // First, make sure we can get down to the real ec type.
TAO_MonitorEventChannel* ec =
dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
+
if (ec == 0)
- throw CORBA::INTERNAL ();
+ {
+ throw CORBA::INTERNAL ();
+ }
- // Next, create the push consumer proxy
+ // Next, create the push consumer proxy.
CosNotifyChannelAdmin::ProxySupplier_var proxy =
this->TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier (
ctype, proxy_id);
- // Next, map the proxy id to the name in the ec
+ // Next, map the proxy id to the name in the ec.
char name[64];
- ACE_OS::sprintf(name, "%d", proxy_id);
+ ACE_OS::sprintf (name, "%d", proxy_id);
ec->map_supplier_proxy (proxy_id, name);
return proxy._retn ();
@@ -160,12 +183,14 @@ void
TAO_MonitorConsumerAdmin::update_queue_count (size_t count)
{
if (this->queue_size_ != 0)
- // The message blocks stored in this queue are of size
- // zero. However, each message block is a
- // TAO_Notify_Event which has an associated set of data
- // which can be used to estimate the amount of memory
- // allocated to the message queue
- this->queue_size_->receive (count * sizeof (TAO_Notify_Event));
+ {
+ // The message blocks stored in this queue are of size
+ // zero. However, each message block is a
+ // TAO_Notify_Event which has an associated set of data
+ // which can be used to estimate the amount of memory
+ // allocated to the message queue
+ this->queue_size_->receive (count * sizeof (TAO_Notify_Event));
+ }
}
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp
index 50bb9fb8e0e..7b0f28457e7 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.cpp
@@ -1,8 +1,11 @@
// $Id$
+
#include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h"
+
+#include "ace/Monitor_Point_Registry.h"
+
#include "orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.h"
#include "orbsvcs/Notify/MonitorControlExt/MonitorSupplierAdmin.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
#include "orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h"
#include "orbsvcs/Notify/MonitorControl/Control_Registry.h"
#include "orbsvcs/Notify/Buffering_Strategy.h"
@@ -10,99 +13,133 @@
#include "orbsvcs/Notify/ProxyConsumer.h"
#include "orbsvcs/Notify/ThreadPool_Task.h"
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
// ******************************************************************
// Dynamic Statistic Classes
// ******************************************************************
-class EventChannelConsumersSuppliers:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
+class EventChannelConsumersSuppliers
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
{
public:
EventChannelConsumersSuppliers (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
TAO_Statistic::Information_Type type,
bool is_supplier = false)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
- name.c_str (),
- type),
- is_supplier_ (is_supplier) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
+ name.c_str (),
+ type),
+ is_supplier_ (is_supplier)
+ {
}
- virtual void calculate (void) {
+
+ virtual void calculate (void)
+ {
if (this->type () == TAO_Statistic::TS_LIST)
{
TAO_Statistic::List list;
+
if (this->is_supplier_)
- this->interf_->get_suppliers (&list);
+ {
+ this->interf_->get_suppliers (&list);
+ }
else
- this->interf_->get_consumers (&list);
+ {
+ this->interf_->get_consumers (&list);
+ }
+
this->receive (list);
}
else
{
if (this->is_supplier_)
- this->receive (static_cast<double> (this->interf_->get_suppliers (0)));
+ {
+ this->receive (
+ static_cast<double> (this->interf_->get_suppliers (0)));
+ }
else
- this->receive (static_cast<double> (this->interf_->get_consumers (0)));
+ {
+ this->receive (
+ static_cast<double> (this->interf_->get_consumers (0)));
+ }
}
}
private:
bool is_supplier_;
};
-class EventChannelConsumerSupplierAdmins:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
+
+class EventChannelConsumerSupplierAdmins
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
{
public:
EventChannelConsumerSupplierAdmins (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
TAO_Statistic::Information_Type type,
bool is_supplier = false)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
- name.c_str (),
- type),
- is_supplier_ (is_supplier) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
+ name.c_str (),
+ type),
+ is_supplier_ (is_supplier)
+ {
}
- virtual void calculate (void) {
+
+ virtual void calculate (void)
+ {
if (this->type () == TAO_Statistic::TS_LIST)
{
TAO_Statistic::List list;
- if (this->is_supplier_)
- this->interf_->get_supplieradmins (&list);
+
+ if (this->is_supplier_)
+ {
+ this->interf_->get_supplieradmins (&list);
+ }
else
- this->interf_->get_consumeradmins (&list);
+ {
+ this->interf_->get_consumeradmins (&list);
+ }
+
this->receive (list);
}
else
{
if (this->is_supplier_)
- this->receive (
- static_cast<double> (this->interf_->get_supplieradmins (0)));
+ {
+ this->receive (
+ static_cast<double> (this->interf_->get_supplieradmins (0)));
+ }
else
- this->receive (
- static_cast<double> (this->interf_->get_consumeradmins (0)));
+ {
+ this->receive (
+ static_cast<double> (this->interf_->get_consumeradmins (0)));
+ }
}
}
private:
bool is_supplier_;
};
-class QueuedEvents:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
+
+class QueuedEvents
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
{
public:
QueuedEvents (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
TAO_Statistic::Information_Type type,
bool count)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
- name.c_str (),
- type),
- count_ (count) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
+ name.c_str (),
+ type),
+ count_ (count)
+ {
}
- virtual void calculate (void) {
+ virtual void calculate (void)
+ {
this->receive (
static_cast<double> (
this->interf_->calculate_queue_size (this->count_)));
@@ -111,49 +148,58 @@ public:
private:
bool count_;
};
-class OldestEvent:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
+class OldestEvent
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
{
public:
OldestEvent (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
TAO_Statistic::Information_Type type)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
- name.c_str (),
- type) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
+ name.c_str (),
+ type)
+ {
}
- virtual void calculate (void) {
+ virtual void calculate (void)
+ {
this->receive (this->interf_->get_oldest_event ());
}
};
-class SlowestConsumers:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
+
+class SlowestConsumers
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannel>
{
public:
SlowestConsumers (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
TAO_Statistic::Information_Type type)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
- name.c_str (),
- type) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannel> (ec,
+ name.c_str (),
+ type)
+ {
}
- virtual void calculate (void) {
+
+ virtual void calculate (void)
+ {
TAO_Statistic::List list;
this->interf_->determine_slowest_consumer (&list);
this->receive (list);
}
};
-class ShutdownControl: public TAO_NS_Control
+
+class ShutdownControl : public TAO_NS_Control
{
public:
ShutdownControl (TAO_MonitorEventChannel* ec,
const ACE_CString& name)
- : TAO_NS_Control (name.c_str ()),
- ec_ (ec) {
+ : TAO_NS_Control (name.c_str ()),
+ ec_ (ec)
+ {
}
- virtual bool execute (const char* command) {
+ virtual bool execute (const char* command)
+ {
if (ACE_OS::strcmp (command, TAO_NS_CONTROL_SHUTDOWN) == 0)
{
this->ec_->destroy ();
@@ -170,21 +216,24 @@ private:
TAO_MonitorEventChannel* ec_;
};
-class RemoveConsumerSupplierControl: public TAO_NS_Control
+class RemoveConsumerSupplierControl : public TAO_NS_Control
{
public:
RemoveConsumerSupplierControl (TAO_MonitorEventChannel* ec,
const ACE_CString& name,
CosNotifyChannelAdmin::ProxyID id,
bool is_supplier)
- : TAO_NS_Control (name.c_str ()),
- ec_ (ec),
- id_ (id),
- is_supplier_ (is_supplier) {
+ : TAO_NS_Control (name.c_str ()),
+ ec_ (ec),
+ id_ (id),
+ is_supplier_ (is_supplier)
+ {
}
- virtual bool execute (const char* command) {
+ virtual bool execute (const char* command)
+ {
bool status = true;
+
if (this->is_supplier_)
{
if (ACE_OS::strcmp (command, TAO_NS_CONTROL_REMOVE_SUPPLIER) == 0)
@@ -193,7 +242,7 @@ public:
}
else
{
- // Indicate that the command was unknown
+ // Indicate that the command was unknown.
return false;
}
}
@@ -205,7 +254,7 @@ public:
}
else
{
- // Indicate that the command was unknown
+ // Indicate that the command was unknown.
return false;
}
}
@@ -224,7 +273,7 @@ private:
// ******************************************************************
TAO_MonitorEventChannel::TAO_MonitorEventChannel (const char* name)
- : name_ (name)
+ : name_ (name)
{
this->add_stats ();
}
@@ -232,18 +281,19 @@ TAO_MonitorEventChannel::TAO_MonitorEventChannel (const char* name)
TAO_MonitorEventChannel::~TAO_MonitorEventChannel (void)
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->names_mutex_);
- TAO_Statistic_Registry* instance =
- TAO_Statistic_Registry::instance ();
+
+ Monitor_Point_Registry* instance = Monitor_Point_Registry::instance ();
size_t size = this->stat_names_.size ();
- for(size_t i = 0; i < size; i++)
+
+ for (size_t i = 0; i < size; ++i)
{
- instance->remove (this->stat_names_[i]);
+ instance->remove (this->stat_names_[i].c_str ());
}
- TAO_Control_Registry* cinstance =
- TAO_Control_Registry::instance ();
+ TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
size = this->control_names_.size ();
- for(size_t i = 0; i < size; i++)
+
+ for (size_t i = 0; i < size; ++i)
{
cinstance->remove (this->control_names_[i]);
}
@@ -256,61 +306,63 @@ TAO_MonitorEventChannel::name (void) const
}
bool
-TAO_MonitorEventChannel::register_statistic(
- const ACE_CString& name,
- TAO_Statistic* stat,
- TAO_Statistic_Registry* instance)
+TAO_MonitorEventChannel::register_statistic (const ACE_CString& name,
+ TAO_Statistic* stat)
{
- // Allow the caller to provide the registry
- if (instance == 0)
- instance = TAO_Statistic_Registry::instance ();
-
- // Add the statistic to the registry and if it's successful
+ // Add the statistic to the registry and
// add the name to the statistic names list.
- bool added = instance->add (stat);
+ bool added = Monitor_Point_Registry::instance ()->add (stat);
+
if (added)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->names_mutex_, added);
+
this->stat_names_.push_back (name);
}
+
return added;
}
bool
-TAO_MonitorEventChannel::unregister_statistic(
- const ACE_CString& name,
- TAO_Statistic_Registry* instance)
+TAO_MonitorEventChannel::unregister_statistic (const ACE_CString& name)
{
- // Allow the caller to provide the registry
- if (instance == 0)
- instance = TAO_Statistic_Registry::instance ();
-
// Remove the statistic from the registry and if it's successful
// remove the name from the statistic names list.
- bool removed = instance->remove (name);
+ bool removed = Monitor_Point_Registry::instance ()->remove (name.c_str ());
+
if (removed)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->names_mutex_, removed);
+
this->remove_list_name(this->stat_names_, name);
}
+
return removed;
}
void
TAO_MonitorEventChannel::map_supplier_proxy (
- CosNotifyChannelAdmin::ProxyID id,
- const ACE_CString& name)
+ CosNotifyChannelAdmin::ProxyID id,
+ const ACE_CString& name)
{
if (name.length () == 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
ACE_CString full = this->name_ + "/" + name;
+
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->supplier_mutex_);
+
if (this->is_duplicate_name (this->supplier_map_, full))
- throw NotifyMonitoringExt::NameAlreadyUsed ();
+ {
+ throw NotifyMonitoringExt::NameAlreadyUsed ();
+ }
if (this->supplier_map_.bind (id, full) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
// The view from the outside sees a supplier proxy as a consumer.
// So, we'll register a RemoveConsumerSupplierControl for each supplier
@@ -320,36 +372,46 @@ TAO_MonitorEventChannel::map_supplier_proxy (
RemoveConsumerSupplierControl (this, full, id, false),
CORBA::NO_MEMORY ());
- TAO_Control_Registry* cinstance =
- TAO_Control_Registry::instance ();
+ TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
+
if (cinstance->add (rcsc))
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->names_mutex_);
+
this->control_names_.push_back (full);
}
else
{
delete rcsc;
- ACE_ERROR ((LM_ERROR, "Unable to add control: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add control: %s\n",
full.c_str ()));
}
}
void
TAO_MonitorEventChannel::map_consumer_proxy (
- CosNotifyChannelAdmin::ProxyID id,
- const ACE_CString& name)
+ CosNotifyChannelAdmin::ProxyID id,
+ const ACE_CString& name)
{
if (name.length () == 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
ACE_CString full = this->name_ + "/" + name;
+
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->consumer_mutex_);
+
if (this->is_duplicate_name (this->consumer_map_, full))
- throw NotifyMonitoringExt::NameAlreadyUsed ();
+ {
+ throw NotifyMonitoringExt::NameAlreadyUsed ();
+ }
if (this->consumer_map_.bind (id, full) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
// The view from the outside sees a consumer proxy as a supplier.
// So, we'll register a RemoveConsumerSupplierControl for each consumer
@@ -359,17 +421,19 @@ TAO_MonitorEventChannel::map_consumer_proxy (
RemoveConsumerSupplierControl (this, full, id, true),
CORBA::NO_MEMORY ());
- TAO_Control_Registry* cinstance =
- TAO_Control_Registry::instance ();
+ TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
+
if (cinstance->add (rcsc))
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->names_mutex_);
+
this->control_names_.push_back (full);
}
else
{
delete rcsc;
- ACE_ERROR ((LM_ERROR, "Unable to add control: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add control: %s\n",
full.c_str ()));
}
}
@@ -379,9 +443,11 @@ TAO_MonitorEventChannel::cleanup_proxy (CosNotifyChannelAdmin::ProxyID id,
bool is_supplier)
{
ACE_CString name;
+
if (is_supplier)
{
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->supplier_mutex_);
+
// It may seem like a good idea to throw a
// NotifyMonitoringExt::NameMapError() exception if we can't unbind the
// id from the map, but we can't. This method is called indirectly
@@ -394,34 +460,37 @@ TAO_MonitorEventChannel::cleanup_proxy (CosNotifyChannelAdmin::ProxyID id,
else
{
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->consumer_mutex_);
+
// The same goes for this one too.
this->consumer_map_.unbind (id, name);
}
if (name.length () != 0)
{
- TAO_Control_Registry* cinstance =
- TAO_Control_Registry::instance ();
- cinstance->remove(name);
+ TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
+ cinstance->remove (name);
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->names_mutex_);
+
this->remove_list_name (this->control_names_, name);
}
}
void
TAO_MonitorEventChannel::remove_consumeradmin (
- CosNotifyChannelAdmin::ProxyID id)
+ CosNotifyChannelAdmin::ProxyID id)
{
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->consumeradmin_mutex_);
+
this->consumeradmin_map_.unbind (id);
}
void
TAO_MonitorEventChannel::remove_supplieradmin (
- CosNotifyChannelAdmin::ProxyID id)
+ CosNotifyChannelAdmin::ProxyID id)
{
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->supplieradmin_mutex_);
+
this->supplieradmin_map_.unbind (id);
}
@@ -429,12 +498,14 @@ void
TAO_MonitorEventChannel::add_stats (const char* name)
{
if (name != 0 && this->name_.length () == 0)
- this->name_ = name;
+ {
+ this->name_ = name;
+ }
if (this->name_.length () != 0)
{
- TAO_Statistic_Registry* instance =
- TAO_Statistic_Registry::instance ();
+ Monitor_Point_Registry* instance =
+ Monitor_Point_Registry::instance ();
ACE_CString dir_name (this->name_ + "/");
ACE_CString stat_name = dir_name +
@@ -444,49 +515,61 @@ TAO_MonitorEventChannel::add_stats (const char* name)
TAO_Statistic (stat_name.c_str (),
TAO_Statistic::TS_TIME),
CORBA::NO_MEMORY ());
- ACE_Time_Value tv (ACE_OS::gettimeofday());
+ ACE_Time_Value tv (ACE_OS::gettimeofday ());
timestamp->receive (tv.sec () + (tv.usec () / 1000000.0));
- if (!this->register_statistic (stat_name, timestamp, instance))
+
+ if (!this->register_statistic (stat_name, timestamp))
{
- delete timestamp;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ timestamp->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelConsumerCount;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelConsumerCount;
EventChannelConsumersSuppliers* consumers = 0;
ACE_NEW_THROW_EX (consumers,
EventChannelConsumersSuppliers (
- this,
- stat_name.c_str (),
- TAO_Statistic::TS_NUMBER),
+ this,
+ stat_name.c_str (),
+ TAO_Statistic::TS_NUMBER),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, consumers, instance))
+
+ if (!this->register_statistic (stat_name, consumers))
{
- delete consumers;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ consumers->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelConsumerNames;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelConsumerNames;
consumers = 0;
ACE_NEW_THROW_EX (consumers,
EventChannelConsumersSuppliers (
- this,
- stat_name.c_str (),
- TAO_Statistic::TS_LIST),
+ this,
+ stat_name.c_str (),
+ TAO_Statistic::TS_LIST),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, consumers, instance))
+
+ if (!this->register_statistic (stat_name, consumers))
{
- delete consumers;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ consumers->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelSupplierCount;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelSupplierCount;
EventChannelConsumersSuppliers* suppliers = 0;
ACE_NEW_THROW_EX (suppliers,
EventChannelConsumersSuppliers (
@@ -495,15 +578,19 @@ TAO_MonitorEventChannel::add_stats (const char* name)
TAO_Statistic::TS_NUMBER,
true),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, suppliers, instance))
+
+ if (!this->register_statistic (stat_name, suppliers))
{
- delete suppliers;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ suppliers->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelSupplierNames;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelSupplierNames;
suppliers = 0;
ACE_NEW_THROW_EX (suppliers,
EventChannelConsumersSuppliers (
@@ -512,15 +599,19 @@ TAO_MonitorEventChannel::add_stats (const char* name)
TAO_Statistic::TS_LIST,
true),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, suppliers, instance))
+
+ if (!this->register_statistic (stat_name, suppliers))
{
- delete suppliers;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ suppliers->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelConsumerAdminCount;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelConsumerAdminCount;
EventChannelConsumerSupplierAdmins* conadmins = 0;
ACE_NEW_THROW_EX (conadmins,
EventChannelConsumerSupplierAdmins (
@@ -528,15 +619,19 @@ TAO_MonitorEventChannel::add_stats (const char* name)
stat_name.c_str (),
TAO_Statistic::TS_NUMBER),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, conadmins, instance))
+
+ if (!this->register_statistic (stat_name, conadmins))
{
- delete conadmins;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ conadmins->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelConsumerAdminNames;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelConsumerAdminNames;
conadmins = 0;
ACE_NEW_THROW_EX (conadmins,
EventChannelConsumerSupplierAdmins (
@@ -544,15 +639,19 @@ TAO_MonitorEventChannel::add_stats (const char* name)
stat_name.c_str (),
TAO_Statistic::TS_LIST),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, conadmins, instance))
+
+ if (!this->register_statistic (stat_name, conadmins))
{
- delete conadmins;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ conadmins->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelSupplierAdminCount;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelSupplierAdminCount;
EventChannelConsumerSupplierAdmins* supadmins = 0;
ACE_NEW_THROW_EX (supadmins,
EventChannelConsumerSupplierAdmins (
@@ -561,15 +660,19 @@ TAO_MonitorEventChannel::add_stats (const char* name)
TAO_Statistic::TS_NUMBER,
true),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, supadmins, instance))
+
+ if (!this->register_statistic (stat_name, supadmins))
{
- delete supadmins;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ supadmins->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelSupplierAdminNames;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelSupplierAdminNames;
supadmins = 0;
ACE_NEW_THROW_EX (supadmins,
EventChannelConsumerSupplierAdmins (
@@ -578,12 +681,16 @@ TAO_MonitorEventChannel::add_stats (const char* name)
TAO_Statistic::TS_LIST,
true),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, supadmins, instance))
+
+ if (!this->register_statistic (stat_name, supadmins))
{
- delete supadmins;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ supadmins->remove_ref ();
stat_name = dir_name + NotifyMonitoringExt::EventChannelQueueSize;
QueuedEvents* events = 0;
@@ -591,26 +698,27 @@ TAO_MonitorEventChannel::add_stats (const char* name)
QueuedEvents (this, stat_name.c_str (),
TAO_Statistic::TS_NUMBER, false),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, events, instance))
+
+ if (!this->register_statistic (stat_name, events))
{
- delete events;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ events->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelQueueElementCount;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelQueueElementCount;
events = 0;
ACE_NEW_THROW_EX (events,
QueuedEvents (this, stat_name.c_str (),
TAO_Statistic::TS_NUMBER, true),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, events, instance))
- {
- delete events;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+
+ events->add_to_registry ();
+ events->remove_ref ();
stat_name = dir_name + NotifyMonitoringExt::EventChannelOldestEvent;
OldestEvent* oldest = 0;
@@ -618,26 +726,34 @@ TAO_MonitorEventChannel::add_stats (const char* name)
OldestEvent (this, stat_name.c_str (),
TAO_Statistic::TS_TIME),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, oldest, instance))
+
+ if (!this->register_statistic (stat_name, oldest))
{
- delete oldest;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ oldest->remove_ref ();
- stat_name = dir_name +
- NotifyMonitoringExt::EventChannelSlowestConsumers;
+ stat_name = dir_name
+ + NotifyMonitoringExt::EventChannelSlowestConsumers;
SlowestConsumers* slowest = 0;
ACE_NEW_THROW_EX (slowest,
SlowestConsumers (this, stat_name.c_str (),
TAO_Statistic::TS_LIST),
CORBA::NO_MEMORY ());
- if (!this->register_statistic (stat_name, slowest, instance))
+
+ if (!this->register_statistic (stat_name, slowest))
{
- delete oldest;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
+ ACE_ERROR ((LM_ERROR,
+ "Unable to add statistic %s\n",
stat_name.c_str ()));
}
+
+ // Registry manages refcount, so we do this regardless.
+ slowest->remove_ref ();
TAO_Control_Registry* cinstance =
TAO_Control_Registry::instance ();
@@ -647,6 +763,7 @@ TAO_MonitorEventChannel::add_stats (const char* name)
ShutdownControl (this,
this->name_),
CORBA::NO_MEMORY ());
+
if (cinstance->add (sd))
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->names_mutex_);
@@ -663,38 +780,44 @@ TAO_MonitorEventChannel::add_stats (const char* name)
CosNotifyChannelAdmin::ConsumerAdmin_ptr
TAO_MonitorEventChannel::new_for_consumers (
- CosNotifyChannelAdmin::InterFilterGroupOperator op,
- CosNotifyChannelAdmin::AdminID_out id)
+ CosNotifyChannelAdmin::InterFilterGroupOperator op,
+ CosNotifyChannelAdmin::AdminID_out id)
{
return this->named_new_for_consumers (op, id, 0);
}
CosNotifyChannelAdmin::ConsumerAdmin_ptr
TAO_MonitorEventChannel::named_new_for_consumers (
- CosNotifyChannelAdmin::InterFilterGroupOperator op,
- CosNotifyChannelAdmin::AdminID_out id,
- const char* name)
+ CosNotifyChannelAdmin::InterFilterGroupOperator op,
+ CosNotifyChannelAdmin::AdminID_out id,
+ const char* name)
{
if (name != 0 && name[0] == 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->TAO_Notify_EventChannel::new_for_consumers (op, id);
- // WARNING: Internal knowledge of TAO
+ // WARNING: Internal knowledge of TAO.
TAO_MonitorConsumerAdmin* low_admin =
dynamic_cast<TAO_MonitorConsumerAdmin*> (admin->_servant ());
+
if (low_admin == 0)
- // This shouldn't happen
- throw CORBA::INTERNAL ();
+ {
+ // This shouldn't happen.
+ throw CORBA::INTERNAL ();
+ }
else
{
- // Build up the full name
+ // Build up the full name.
ACE_CString full = this->name_ + "/";
+
if (name == 0)
{
char idname[64];
- ACE_OS::sprintf(idname, "%d", id);
+ ACE_OS::sprintf (idname, "%d", id);
full += idname;
}
else
@@ -705,11 +828,16 @@ TAO_MonitorEventChannel::named_new_for_consumers (
ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
this->consumeradmin_mutex_,
CosNotifyChannelAdmin::ConsumerAdmin::_nil ());
+
if (this->is_duplicate_name (this->consumeradmin_map_, full))
- throw NotifyMonitoringExt::NameAlreadyUsed ();
+ {
+ throw NotifyMonitoringExt::NameAlreadyUsed ();
+ }
if (this->consumeradmin_map_.bind (id, full) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
low_admin->register_stats_controls (this, full);
}
@@ -719,38 +847,44 @@ TAO_MonitorEventChannel::named_new_for_consumers (
CosNotifyChannelAdmin::SupplierAdmin_ptr
TAO_MonitorEventChannel::new_for_suppliers (
- CosNotifyChannelAdmin::InterFilterGroupOperator op,
- CosNotifyChannelAdmin::AdminID_out id)
+ CosNotifyChannelAdmin::InterFilterGroupOperator op,
+ CosNotifyChannelAdmin::AdminID_out id)
{
return this->named_new_for_suppliers (op, id, 0);
}
CosNotifyChannelAdmin::SupplierAdmin_ptr
TAO_MonitorEventChannel::named_new_for_suppliers (
- CosNotifyChannelAdmin::InterFilterGroupOperator op,
- CosNotifyChannelAdmin::AdminID_out id,
- const char* name)
+ CosNotifyChannelAdmin::InterFilterGroupOperator op,
+ CosNotifyChannelAdmin::AdminID_out id,
+ const char* name)
{
if (name != 0 && name[0] == 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
CosNotifyChannelAdmin::SupplierAdmin_var admin =
this->TAO_Notify_EventChannel::new_for_suppliers (op, id);
- // WARNING: Internal knowledge of TAO
+ // WARNING: Internal knowledge of TAO.
TAO_MonitorSupplierAdmin* low_admin =
dynamic_cast<TAO_MonitorSupplierAdmin*> (admin->_servant ());
+
if (low_admin == 0)
- // This shouldn't happen
- throw CORBA::INTERNAL ();
+ {
+ // This shouldn't happen
+ throw CORBA::INTERNAL ();
+ }
else
{
// Build up the full name
ACE_CString full = this->name_ + "/";
+
if (name == 0)
{
char idname[64];
- ACE_OS::sprintf(idname, "%d", id);
+ ACE_OS::sprintf (idname, "%d", id);
full += idname;
}
else
@@ -761,11 +895,16 @@ TAO_MonitorEventChannel::named_new_for_suppliers (
ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
this->supplieradmin_mutex_,
CosNotifyChannelAdmin::SupplierAdmin::_nil ());
+
if (this->is_duplicate_name (this->supplieradmin_map_, full))
- throw NotifyMonitoringExt::NameAlreadyUsed ();
+ {
+ throw NotifyMonitoringExt::NameAlreadyUsed ();
+ }
if (this->supplieradmin_map_.bind (id, full) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
low_admin->register_stats_controls (this, full);
}
@@ -780,30 +919,38 @@ TAO_MonitorEventChannel::get_consumers (TAO_Statistic::List* names)
CosNotifyChannelAdmin::AdminIDSeq_var conadmin_ids =
this->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->get_consumeradmin (conadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
CosNotifyChannelAdmin::ProxyIDSeq_var proxys =
admin->push_suppliers ();
CORBA::ULong plen = proxys->length ();
+
if (plen > 0)
{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
- this->supplier_mutex_, 0);
+ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
+ guard,
+ this->supplier_mutex_,
+ 0);
- for(CORBA::ULong i = 0; i < plen; i++)
+ for (CORBA::ULong i = 0; i < plen; ++i)
{
if (names == 0)
{
if (this->supplier_map_.find (proxys[i]) == 0)
- count++;
+ {
+ count++;
+ }
}
else
{
ACE_CString name;
+
if (this->supplier_map_.find (proxys[i], name) == 0)
{
count++;
@@ -814,6 +961,7 @@ TAO_MonitorEventChannel::get_consumers (TAO_Statistic::List* names)
}
}
}
+
return count;
}
@@ -824,30 +972,38 @@ TAO_MonitorEventChannel::get_suppliers (TAO_Statistic::List* names)
CosNotifyChannelAdmin::AdminIDSeq_var supadmin_ids =
this->get_all_supplieradmins ();
CORBA::ULong length = supadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::SupplierAdmin_var admin =
this->get_supplieradmin (supadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
CosNotifyChannelAdmin::ProxyIDSeq_var proxys =
admin->push_consumers ();
CORBA::ULong plen = proxys->length ();
+
if (plen > 0)
{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
- this->consumer_mutex_, 0);
+ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
+ guard,
+ this->consumer_mutex_,
+ 0);
- for(CORBA::ULong i = 0; i < plen; i++)
+ for (CORBA::ULong i = 0; i < plen; ++i)
{
if (names == 0)
{
if (this->consumer_map_.find (proxys[i]) == 0)
- count++;
+ {
+ count++;
+ }
}
else
{
ACE_CString name;
+
if (this->consumer_map_.find (proxys[i], name) == 0)
{
count++;
@@ -858,49 +1014,64 @@ TAO_MonitorEventChannel::get_suppliers (TAO_Statistic::List* names)
}
}
}
+
return count;
}
size_t
TAO_MonitorEventChannel::get_consumeradmins (TAO_Statistic::List* names)
{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
- this->consumeradmin_mutex_, 0);
+ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
+ guard,
+ this->consumeradmin_mutex_,
+ 0);
CosNotifyChannelAdmin::AdminIDSeq_var admin_ids =
this->get_all_consumeradmins ();
- return this->get_admins (this->consumeradmin_map_, admin_ids.in (), names);
+
+ return this->get_admins (this->consumeradmin_map_,
+ admin_ids.in (),
+ names);
}
size_t
TAO_MonitorEventChannel::get_supplieradmins (TAO_Statistic::List* names)
{
- ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard,
- this->supplieradmin_mutex_, 0);
+ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
+ guard,
+ this->supplieradmin_mutex_,
+ 0);
CosNotifyChannelAdmin::AdminIDSeq_var admin_ids =
this->get_all_supplieradmins ();
- return this->get_admins (this->supplieradmin_map_, admin_ids.in (), names);
+
+ return this->get_admins (this->supplieradmin_map_,
+ admin_ids.in (),
+ names);
}
size_t
TAO_MonitorEventChannel::get_admins (
- TAO_MonitorEventChannel::Map& map,
- const CosNotifyChannelAdmin::AdminIDSeq& admin_ids,
- TAO_Statistic::List* names)
+ TAO_MonitorEventChannel::Map& map,
+ const CosNotifyChannelAdmin::AdminIDSeq& admin_ids,
+ TAO_Statistic::List* names)
{
size_t count = 0;
CORBA::ULong length = admin_ids.length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
if (names == 0)
{
if (map.find (admin_ids[j]) == 0)
- count++;
+ {
+ count++;
+ }
}
else
{
ACE_CString name;
+
if (map.find (admin_ids[j], name) == 0)
{
count++;
@@ -908,25 +1079,29 @@ TAO_MonitorEventChannel::get_admins (
}
}
}
+
return count;
}
TAO_Notify_ThreadPool_Task*
TAO_MonitorEventChannel::get_threadpool_task (
- CosNotifyChannelAdmin::AdminID id)
+ CosNotifyChannelAdmin::AdminID id)
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->get_consumeradmin (id);
+
if (!CORBA::is_nil (admin.in ()))
{
// WARNING: Internal knowledge of TAO and the Notification
// Service implementation.
TAO_Notify_ConsumerAdmin* low_admin =
dynamic_cast<TAO_Notify_ConsumerAdmin*> (admin->_servant ());
+
if (low_admin != 0)
{
- return dynamic_cast<TAO_Notify_ThreadPool_Task*> (
- low_admin->get_worker_task ());
+ return
+ dynamic_cast<TAO_Notify_ThreadPool_Task*> (
+ low_admin->get_worker_task ());
}
}
@@ -940,23 +1115,29 @@ TAO_MonitorEventChannel::calculate_queue_size (bool count)
CosNotifyChannelAdmin::AdminIDSeq_var conadmin_ids =
this->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; j++)
{
TAO_Notify_ThreadPool_Task* task =
this->get_threadpool_task (conadmin_ids[j]);
+
if (task != 0)
{
- TAO_Notify_Message_Queue* queue =
- task->msg_queue ();
+ TAO_Notify_Message_Queue* queue = task->msg_queue ();
+
if (count)
- size += queue->message_count ();
+ {
+ size += queue->message_count ();
+ }
else
- // The message blocks stored in this queue are of size
- // zero. However, each message block is a
- // TAO_Notify_Event which has an associated set of data
- // which can be used to estimate the amount of memory
- // allocated to the message queue
- size += (queue->message_count () * sizeof (TAO_Notify_Event));
+ {
+ // The message blocks stored in this queue are of size
+ // zero. However, each message block is a
+ // TAO_Notify_Event which has an associated set of data
+ // which can be used to estimate the amount of memory
+ // allocated to the message queue
+ size += (queue->message_count () * sizeof (TAO_Notify_Event));
+ }
}
}
@@ -965,7 +1146,7 @@ TAO_MonitorEventChannel::calculate_queue_size (bool count)
void
TAO_MonitorEventChannel::determine_slowest_consumer (
- TAO_Statistic::List* names)
+ TAO_Statistic::List* names)
{
size_t largest = 0;
CosNotifyChannelAdmin::AdminID id = 0;
@@ -973,15 +1154,17 @@ TAO_MonitorEventChannel::determine_slowest_consumer (
CosNotifyChannelAdmin::AdminIDSeq_var conadmin_ids =
this->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
TAO_Notify_ThreadPool_Task* task =
this->get_threadpool_task (conadmin_ids[j]);
+
if (task != 0)
{
- TAO_Notify_Message_Queue* queue =
- task->msg_queue ();
+ TAO_Notify_Message_Queue* queue = task->msg_queue ();
size_t count = queue->message_count ();
+
if (count > largest)
{
largest = count;
@@ -994,18 +1177,23 @@ TAO_MonitorEventChannel::determine_slowest_consumer (
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->get_consumeradmin (id);
+
if (!CORBA::is_nil (admin.in ()))
{
CosNotifyChannelAdmin::ProxyIDSeq_var proxys =
admin->push_suppliers ();
CORBA::ULong plen = proxys->length ();
+
if (plen > 0)
{
ACE_READ_GUARD (TAO_SYNCH_RW_MUTEX,
- guard, this->supplier_mutex_);
- for(CORBA::ULong i = 0; i < plen; i++)
+ guard,
+ this->supplier_mutex_);
+
+ for (CORBA::ULong i = 0; i < plen; ++i)
{
ACE_CString name;
+
if (this->supplier_map_.find (proxys[i], name) == 0)
{
names->push_back (name);
@@ -1023,7 +1211,7 @@ TAO_MonitorEventChannel::get_oldest_event (void)
this->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- // If there are no consumers, we will return the special case indicator
+ // If there are no consumers, we will return the special case indicator.
if (length == 0)
{
return 0.0;
@@ -1032,16 +1220,21 @@ TAO_MonitorEventChannel::get_oldest_event (void)
// Loop through each consumer admins thread pool task and have the
// buffering strategy give us the time of the oldest event.
ACE_Time_Value tv (ACE_Time_Value::max_time);
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
TAO_Notify_ThreadPool_Task* task =
this->get_threadpool_task (conadmin_ids[j]);
+
if (task != 0)
{
ACE_Time_Value old =
task->buffering_strategy ()->oldest_event ();
+
if (old < tv)
- tv = old;
+ {
+ tv = old;
+ }
}
}
@@ -1049,36 +1242,42 @@ TAO_MonitorEventChannel::get_oldest_event (void)
// ACE_Time_Value::max_time. For this situation, we must return the
// special case indicator.
if (tv == ACE_Time_Value::max_time)
- return 0.0;
+ {
+ return 0.0;
+ }
return tv.sec () + (tv.usec () / 1000000.0);
}
bool
TAO_MonitorEventChannel::is_duplicate_name (
- const TAO_MonitorEventChannel::Map& map,
- const ACE_CString& name) const
+ const TAO_MonitorEventChannel::Map& map,
+ const ACE_CString& name) const
{
Map::const_iterator itr (map);
Map::value_type* entry = 0;
+
while (itr.next (entry))
{
if (name == entry->item ())
{
return true;
}
+
itr.advance ();
}
+
return false;
}
void
TAO_MonitorEventChannel::remove_list_name (
- TAO_MonitorEventChannel::NameList& list,
- const ACE_CString& name)
+ TAO_MonitorEventChannel::NameList& list,
+ const ACE_CString& name)
{
size_t size = list.size ();
- for(size_t i = 0; i < size; i++)
+
+ for (size_t i = 0; i < size; ++i)
{
if (list[i] == name)
{
@@ -1092,8 +1291,10 @@ TAO_MonitorEventChannel::remove_list_name (
{
list[i] = list[size - 1];
}
+
list.resize (size - 1, "");
}
+
break;
}
}
@@ -1101,23 +1302,26 @@ TAO_MonitorEventChannel::remove_list_name (
bool
TAO_MonitorEventChannel::destroy_consumer (
- CosNotifyChannelAdmin::ProxyID id)
+ CosNotifyChannelAdmin::ProxyID id)
{
// Since we just have a proxy id, we have to search through all of the
// consumer admins. We have no idea to which the proxy will belong.
CosNotifyChannelAdmin::AdminIDSeq_var conadmin_ids =
this->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
this->get_consumeradmin (conadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
try
{
CosNotifyChannelAdmin::ProxySupplier_var supplier =
admin->get_proxy_supplier(id);
+
if (!CORBA::is_nil(supplier.in()))
{
// WARNING: Internal knowledge of TAO and the
@@ -1141,23 +1345,26 @@ TAO_MonitorEventChannel::destroy_consumer (
bool
TAO_MonitorEventChannel::destroy_supplier (
- CosNotifyChannelAdmin::ProxyID id)
+ CosNotifyChannelAdmin::ProxyID id)
{
// Since we just have a proxy id, we have to search through all of the
// supplier admins. We have no idea to which the proxy will belong.
CosNotifyChannelAdmin::AdminIDSeq_var supadmin_ids =
this->get_all_supplieradmins ();
CORBA::ULong length = supadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::SupplierAdmin_var admin =
this->get_supplieradmin (supadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
try
{
CosNotifyChannelAdmin::ProxyConsumer_var consumer =
admin->get_proxy_consumer(id);
+
if (!CORBA::is_nil(consumer.in()))
{
// WARNING: Internal knowledge of TAO and the
@@ -1166,7 +1373,7 @@ TAO_MonitorEventChannel::destroy_supplier (
dynamic_cast<TAO_Notify_ProxyConsumer*> (
consumer->_servant ());
- low_proxy->destroy();
+ low_proxy->destroy ();
return true;
}
}
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h
index d15f533741a..4be9d957e2f 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h
@@ -3,16 +3,19 @@
#define MONITOREVENTCHANNEL_H
#include /**/ "ace/pre.h"
-#include "orbsvcs/Notify/MonitorControlExt/notify_mc_ext_export.h"
+
+#include "ace/Vector_T.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtS.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic.h"
#include "orbsvcs/Notify/EventChannel.h"
-#include "ace/Vector_T.h"
+
+#include "orbsvcs/Notify/MonitorControl/Statistic.h"
+
+#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtS.h"
+#include "orbsvcs/Notify/MonitorControlExt/notify_mc_ext_export.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -25,40 +28,38 @@ class TAO_Notify_MC_Ext_Export TAO_MonitorEventChannel:
{
public:
/// Construct a named event channel and associate various
- /// statistic objects with it in the statistic registry
+ /// statistic objects with it in the statistic registry.
TAO_MonitorEventChannel (const char* name);
- /// Remove the statistics for this event channel
+ /// Remove the statistics for this event channel.
~TAO_MonitorEventChannel (void);
- /// Return the name of this event channel
+ /// Return the name of this event channel.
const ACE_CString& name (void) const;
- /// Register a single statistic with the EC and statistic registry
+ /// Register a single statistic with the EC and statistic registry.
bool register_statistic (const ACE_CString& name,
- TAO_Statistic* stat,
- TAO_Statistic_Registry* instance = 0);
+ TAO_Statistic* stat);
- /// Unregister a single statistic from the EC and statistic registry
- bool unregister_statistic (const ACE_CString& name,
- TAO_Statistic_Registry* instance = 0);
+ /// Unregister a single statistic from the EC and statistic registry.
+ bool unregister_statistic (const ACE_CString& name);
- /// Keep track of the supplier name associated with the proxy id
+ /// Keep track of the supplier name associated with the proxy id.
void map_supplier_proxy (CosNotifyChannelAdmin::ProxyID id,
const ACE_CString& name);
- /// Keep track of the consumer name associated with the proxy id
+ /// Keep track of the consumer name associated with the proxy id.
void map_consumer_proxy (CosNotifyChannelAdmin::ProxyID id,
const ACE_CString& name);
- /// Remove the supplier/consumer proxy id/name mapping
+ /// Remove the supplier/consumer proxy id/name mapping.
virtual void cleanup_proxy (CosNotifyChannelAdmin::ProxyID id,
bool is_supplier);
- /// Remove the consumer admin id/name mapping
+ /// Remove the consumer admin id/name mapping.
virtual void remove_consumeradmin (CosNotifyChannelAdmin::AdminID id);
- /// Remove the supplier admin id/name mapping
+ /// Remove the supplier admin id/name mapping.
virtual void remove_supplieradmin (CosNotifyChannelAdmin::AdminID id);
/// Add the statistics for this event channel. If the ec was
@@ -142,4 +143,5 @@ private:
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
+
#endif /* MONITOREVENTCHANNEL_H */
diff --git a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp
index 0890884ac1d..b89b7ad88e6 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.cpp
@@ -1,12 +1,15 @@
// $Id$
+
#include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.h"
#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtC.h"
#include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h"
-#include "orbsvcs/Notify/MonitorControl/Statistic_Registry.h"
#include "orbsvcs/Notify/MonitorControl/Dynamic_Statistic.h"
#include "orbsvcs/Notify/Properties.h"
#include "orbsvcs/Notify/Builder.h"
-#include "ace/OS_NS_time.h"
+
+#include "ace/Monitor_Point_Registry.h"
+
+using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -14,20 +17,23 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL
// Dynamic Statistic Classes
// ******************************************************************
-class EventChannels:
- public TAO_Dynamic_Statistic<TAO_MonitorEventChannelFactory>
+class EventChannels
+ : public TAO_Dynamic_Statistic<TAO_MonitorEventChannelFactory>
{
public:
EventChannels (TAO_MonitorEventChannelFactory* ecf,
const ACE_CString& name,
TAO_Statistic::Information_Type type,
bool active)
- : TAO_Dynamic_Statistic<TAO_MonitorEventChannelFactory> (ecf,
- name.c_str (),
- type),
- active_ (active) {
+ : TAO_Dynamic_Statistic<TAO_MonitorEventChannelFactory> (ecf,
+ name.c_str (),
+ type),
+ active_ (active)
+ {
}
- virtual void calculate (void) {
+
+ virtual void calculate (void)
+ {
if (this->type () == TAO_Statistic::TS_LIST)
{
TAO_Statistic::List names;
@@ -50,94 +56,89 @@ private:
// ******************************************************************
TAO_MonitorEventChannelFactory::TAO_MonitorEventChannelFactory (
- const char* name)
- : name_ (name)
+ const char* name)
+ : name_ (name)
{
if (name != 0)
{
ACE_CString dir_name (this->name_ + "/");
- TAO_Statistic_Registry* instance = TAO_Statistic_Registry::instance ();
-
ACE_CString stat_name (dir_name +
NotifyMonitoringExt::ActiveEventChannelCount);
+
EventChannels* event_channels = 0;
ACE_NEW (event_channels,
- EventChannels (this, stat_name,
- TAO_Statistic::TS_NUMBER, true));
- bool added = instance->add (event_channels);
- if (added)
- this->stat_names_.push_back (stat_name);
- else
- {
- delete event_channels;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+ EventChannels (this,
+ stat_name,
+ TAO_Statistic::TS_NUMBER,
+ true));
+
+ event_channels->add_to_registry ();
+ event_channels->remove_ref ();
+
+ this->stat_names_.push_back (stat_name);
stat_name = dir_name + NotifyMonitoringExt::InactiveEventChannelCount;
event_channels = 0;
ACE_NEW (event_channels,
- EventChannels (this, stat_name,
- TAO_Statistic::TS_NUMBER, false));
- added = instance->add (event_channels);
- if (added)
- this->stat_names_.push_back (stat_name);
- else
- {
- delete event_channels;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+ EventChannels (this,
+ stat_name,
+ TAO_Statistic::TS_NUMBER,
+ false));
+
+ event_channels->add_to_registry ();
+ event_channels->remove_ref ();
+
+ this->stat_names_.push_back (stat_name);
stat_name = dir_name + NotifyMonitoringExt::ActiveEventChannelNames;
event_channels = 0;
ACE_NEW (event_channels,
- EventChannels (this, stat_name,
- TAO_Statistic::TS_LIST, true));
- added = instance->add (event_channels);
- if (added)
- this->stat_names_.push_back (stat_name);
- else
- {
- delete event_channels;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+ EventChannels (this,
+ stat_name,
+ TAO_Statistic::TS_LIST,
+ true));
+
+ event_channels->add_to_registry ();
+ event_channels->remove_ref ();
+
+ this->stat_names_.push_back (stat_name);
stat_name = dir_name + NotifyMonitoringExt::InactiveEventChannelNames;
event_channels = 0;
ACE_NEW (event_channels,
- EventChannels (this, stat_name,
- TAO_Statistic::TS_LIST, false));
- added = instance->add (event_channels);
- if (added)
- this->stat_names_.push_back (stat_name);
- else
- {
- delete event_channels;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+ EventChannels (this,
+ stat_name,
+ TAO_Statistic::TS_LIST,
+ false));
+
+ event_channels->add_to_registry ();
+ event_channels->remove_ref ();
+
+ this->stat_names_.push_back (stat_name);
stat_name = dir_name + NotifyMonitoringExt::EventChannelCreationTime;
TAO_Statistic* timestamp = 0;
ACE_NEW (timestamp,
- TAO_Statistic (stat_name.c_str (), TAO_Statistic::TS_TIME));
+ TAO_Statistic (stat_name.c_str (),
+ TAO_Statistic::TS_TIME));
+
ACE_Time_Value tv (ACE_OS::gettimeofday());
timestamp->receive (tv.sec () + (tv.usec () / 1000000.0));
- added = instance->add (timestamp);
- if (added)
- this->stat_names_.push_back (stat_name);
- else
- {
- delete timestamp;
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- }
+
+ timestamp->add_to_registry ();
+ timestamp->remove_ref ();
+
+ this->stat_names_.push_back (stat_name);
+
+ Monitor_Point_Registry* instance =
+ Monitor_Point_Registry::instance ();
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
- TAO_Statistic* names = instance->get (
- NotifyMonitoringExt::EventChannelFactoryNames);
+
+ TAO_Statistic* names =
+ dynamic_cast<TAO_Statistic*> (
+ instance->get (NotifyMonitoringExt::EventChannelFactoryNames));
+
if (names == 0)
{
stat_name = NotifyMonitoringExt::EventChannelFactoryNames;
@@ -145,65 +146,68 @@ TAO_MonitorEventChannelFactory::TAO_MonitorEventChannelFactory (
TAO_Statistic (stat_name.c_str (),
TAO_Statistic::TS_LIST),
CORBA::NO_MEMORY ());
- if (!instance->add (names))
- {
- ACE_ERROR ((LM_ERROR, "Unable to add statistic: %s\n",
- stat_name.c_str ()));
- return;
- }
+ names->add_to_registry ();
}
+
TAO_Statistic::List list = names->get_list ();
list.push_back (this->name_);
names->receive (list);
+ names->remove_ref ();
}
}
TAO_MonitorEventChannelFactory::~TAO_MonitorEventChannelFactory (void)
{
- TAO_Statistic_Registry* instance =
- TAO_Statistic_Registry::instance ();
+ Monitor_Point_Registry* instance = Monitor_Point_Registry::instance ();
size_t size = this->stat_names_.size ();
- for(size_t i = 0; i < size; i++)
+
+ for (size_t i = 0; i < size; ++i)
{
- instance->remove (this->stat_names_[i]);
+ instance->remove (this->stat_names_[i].c_str ());
}
}
CosNotifyChannelAdmin::EventChannel_ptr
TAO_MonitorEventChannelFactory::create_named_channel (
- const CosNotification::QoSProperties& initial_qos,
- const CosNotification::AdminProperties& initial_admin,
- CosNotifyChannelAdmin::ChannelID_out id,
- const char* name)
+ const CosNotification::QoSProperties& initial_qos,
+ const CosNotification::AdminProperties& initial_admin,
+ CosNotifyChannelAdmin::ChannelID_out id,
+ const char* name)
{
if (ACE_OS::strlen (name) == 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
ACE_CString sname (this->name_ + "/");
sname += name;
ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
- // Make sure the name isn't already used
+ // Make sure the name isn't already used.
if (this->map_.find (sname) == 0)
- throw NotifyMonitoringExt::NameAlreadyUsed ();
+ {
+ throw NotifyMonitoringExt::NameAlreadyUsed ();
+ }
CosNotifyChannelAdmin::EventChannel_var ec =
- TAO_Notify_Properties::instance ()->builder ()->
- build_event_channel (this,
- initial_qos,
- initial_admin,
- id,
- sname.c_str ());
+ TAO_Notify_Properties::instance ()->builder ()->build_event_channel (
+ this,
+ initial_qos,
+ initial_admin,
+ id,
+ sname.c_str ());
if (CORBA::is_nil (ec.in ()))
{
return CosNotifyChannelAdmin::EventChannel::_nil ();
}
- // Event channel creation was successful, try to bind it in our map
+ // Event channel creation was successful, try to bind it in our map.
if (this->map_.bind (sname, id) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
// The destructor of this object will unbind the
// name from the map unless release is called.
@@ -217,9 +221,9 @@ TAO_MonitorEventChannelFactory::create_named_channel (
CosNotifyChannelAdmin::EventChannel_ptr
TAO_MonitorEventChannelFactory::create_channel (
- const CosNotification::QoSProperties& initial_qos,
- const CosNotification::AdminProperties& initial_admin,
- CosNotifyChannelAdmin::ChannelID_out id)
+ const CosNotification::QoSProperties& initial_qos,
+ const CosNotification::AdminProperties& initial_admin,
+ CosNotifyChannelAdmin::ChannelID_out id)
{
CosNotifyChannelAdmin::EventChannel_var ec =
this->TAO_Notify_EventChannelFactory::create_channel (initial_qos,
@@ -234,8 +238,11 @@ TAO_MonitorEventChannelFactory::create_channel (
// Make sure we can get down to the real event channel
TAO_MonitorEventChannel* mec =
dynamic_cast<TAO_MonitorEventChannel*> (ec->_servant ());
+
if (mec == 0)
- throw CORBA::INTERNAL ();
+ {
+ throw CORBA::INTERNAL ();
+ }
// Construct the name using the new id
ACE_CString sname (this->name_ + "/");
@@ -245,15 +252,17 @@ TAO_MonitorEventChannelFactory::create_channel (
ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0);
- // Make sure the name isn't already used
+ // Make sure the name isn't already used.
if (this->map_.find (sname) == 0)
throw NotifyMonitoringExt::NameAlreadyUsed ();
// Event channel creation was successful, try to bind it in our map
if (this->map_.bind (sname, id) != 0)
- throw NotifyMonitoringExt::NameMapError ();
+ {
+ throw NotifyMonitoringExt::NameMapError ();
+ }
- // Set the name and statistics on the event channel
+ // Set the name and statistics on the event channel.
mec->add_stats (sname.c_str ());
return ec._retn ();
@@ -264,30 +273,35 @@ TAO_MonitorEventChannelFactory::remove (TAO_Notify_EventChannel* channel)
{
TAO_MonitorEventChannel* mec =
dynamic_cast<TAO_MonitorEventChannel*> (channel);
+
if (mec != 0)
{
ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);
this->map_.unbind (mec->name ());
}
+
this->TAO_Notify_EventChannelFactory::remove (channel);
}
size_t
TAO_MonitorEventChannelFactory::get_suppliers (
- CosNotifyChannelAdmin::ChannelID id)
+ CosNotifyChannelAdmin::ChannelID id)
{
size_t count = 0;
CosNotifyChannelAdmin::EventChannel_var ec =
this->get_event_channel (id);
+
if (!CORBA::is_nil (ec.in ()))
{
CosNotifyChannelAdmin::AdminIDSeq_var supadmin_ids =
ec->get_all_supplieradmins ();
CORBA::ULong length = supadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::SupplierAdmin_var admin =
ec->get_supplieradmin (supadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
CosNotifyChannelAdmin::ProxyIDSeq_var proxys =
@@ -296,25 +310,29 @@ TAO_MonitorEventChannelFactory::get_suppliers (
}
}
}
+
return count;
}
size_t
TAO_MonitorEventChannelFactory::get_consumers (
- CosNotifyChannelAdmin::ChannelID id)
+ CosNotifyChannelAdmin::ChannelID id)
{
size_t count = 0;
CosNotifyChannelAdmin::EventChannel_var ec =
this->get_event_channel (id);
+
if (!CORBA::is_nil (ec.in ()))
{
CosNotifyChannelAdmin::AdminIDSeq_var conadmin_ids =
ec->get_all_consumeradmins ();
CORBA::ULong length = conadmin_ids->length ();
- for(CORBA::ULong j = 0; j < length; j++)
+
+ for (CORBA::ULong j = 0; j < length; ++j)
{
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
ec->get_consumeradmin (conadmin_ids[j]);
+
if (!CORBA::is_nil (admin.in ()))
{
CosNotifyChannelAdmin::ProxyIDSeq_var proxys =
@@ -323,35 +341,38 @@ TAO_MonitorEventChannelFactory::get_consumers (
}
}
}
+
return count;
}
size_t
-TAO_MonitorEventChannelFactory::get_ecs (
- TAO_Statistic::List* names,
- bool active)
+TAO_MonitorEventChannelFactory::get_ecs (TAO_Statistic::List* names,
+ bool active)
{
size_t count = 0;
CosNotifyChannelAdmin::ChannelIDSeq_var ids = this->get_all_channels ();
CORBA::ULong total = ids->length ();
- for(CORBA::ULong i = 0; i < total; i++)
+
+ for (CORBA::ULong i = 0; i < total; ++i)
{
CosNotifyChannelAdmin::ChannelID id = ids[i];
bool want_event_channel = !active;
- // Check for connected consumers
+ // Check for connected consumers.
size_t consumers = this->get_consumers (id);
+
if (consumers > 0)
{
want_event_channel = active;
}
- if ((!active && want_event_channel) ||
- (active && !want_event_channel))
+ if ((!active && want_event_channel)
+ || (active && !want_event_channel))
{
// Check for connected suppliers
size_t suppliers = this->get_suppliers (id);
+
if (suppliers > 0)
{
want_event_channel = active;
@@ -361,18 +382,24 @@ TAO_MonitorEventChannelFactory::get_ecs (
if (want_event_channel)
{
count++;
+
if (names != 0)
{
ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
- guard, this->mutex_, 0);
+ guard,
+ this->mutex_,
+ 0);
+
Map::iterator itr (this->map_);
Map::value_type* entry = 0;
+
while (itr.next (entry))
{
if (id == entry->item ())
{
names->push_back (entry->key ());
}
+
itr.advance ();
}
}
@@ -387,18 +414,20 @@ TAO_MonitorEventChannelFactory::get_ecs (
// ******************************************************************
TAO_MonitorEventChannelFactory::Unbinder::Unbinder (
- TAO_MonitorEventChannelFactory::Map& map,
- const ACE_CString& name)
- : map_ (map),
- name_ (name),
- released_ (false)
+ TAO_MonitorEventChannelFactory::Map& map,
+ const ACE_CString& name)
+ : map_ (map),
+ name_ (name),
+ released_ (false)
{
}
TAO_MonitorEventChannelFactory::Unbinder::~Unbinder (void)
{
if (!this->released_)
- this->map_.unbind (this->name_);
+ {
+ this->map_.unbind (this->name_);
+ }
}
void
@@ -407,6 +436,4 @@ TAO_MonitorEventChannelFactory::Unbinder::release (void)
this->released_ = true;
}
-
-
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp b/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp
index 5e1d10ac76a..a67e43e2982 100644
--- a/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp
+++ b/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp
@@ -27,7 +27,7 @@ MonitorTestInterface_i::running (MonitorTestInterface::Which proc)
{
ACE_CString str;
CosNotification::NotificationServiceMonitorControl::Data_var data;
- CosNotification::NotificationServiceMonitorControl::NameList list;
+ Monitor::NameList list;
CosNotification::NotificationServiceMonitorControl::Numeric num;
switch(proc)
@@ -112,7 +112,7 @@ MonitorTestInterface_i::finished (MonitorTestInterface::Which proc)
{
ACE_CString str;
CosNotification::NotificationServiceMonitorControl::Data_var data;
- CosNotification::NotificationServiceMonitorControl::NameList list;
+ Monitor::NameList list;
CosNotification::NotificationServiceMonitorControl::Numeric num;
switch(proc)
diff --git a/TAO/tao/Monitor.mpc b/TAO/tao/Monitor.mpc
index dd7a46a39ef..96b1b6befce 100644
--- a/TAO/tao/Monitor.mpc
+++ b/TAO/tao/Monitor.mpc
@@ -2,7 +2,7 @@
project (TAO_Monitor): portableserver, install, tao_versioning_idl_defaults, ace_mc, tao_output {
sharedname = TAO_Monitor
dynamicflags = TAO_MONITOR_BUILD_DLL
- idlflags += -Gp -Gd \
+ idlflags += -Gp -Gd -GA \
-Wb,export_macro=TAO_Monitor_Export \
-Wb,export_include=tao/Monitor/Monitor_export.h \
-o Monitor
@@ -32,12 +32,12 @@ project (TAO_Monitor): portableserver, install, tao_versioning_idl_defaults, ace
}
IDL_Files {
- idlflags += -Sa -St \
- -Wb,unique_include=tao/Monitor/Monitor.h
+ idlflags += -Wb,unique_include=tao/Monitor/Monitor.h
Monitor/Monitor_include.pidl
}
IDL_Files {
+ idlflags -= -St
idlflags += -Wb,include_guard=TAO_MONITOR_SAFE_INCLUDE \
-Wb,safe_include=tao/Monitor/Monitor.h
Monitor/Monitor.pidl