summaryrefslogtreecommitdiff
path: root/ACE/ace
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2008-04-28 10:33:06 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2008-04-28 10:33:06 +0000
commita6e4862a47ce814fc57a21dd1c588945d666c2c6 (patch)
tree470b30489e93bf7832f87b0c17e8f5797abd9fdb /ACE/ace
parentec52b1be10867395b69481557e8076a27642b25d (diff)
downloadATCD-a6e4862a47ce814fc57a21dd1c588945d666c2c6.tar.gz
Diffstat (limited to 'ACE/ace')
-rw-r--r--ACE/ace/Global_Macros.h3
-rw-r--r--ACE/ace/Monitor_Admin.cpp113
-rw-r--r--ACE/ace/Monitor_Admin.h108
-rw-r--r--ACE/ace/Monitor_Admin_Manager.cpp42
-rw-r--r--ACE/ace/Monitor_Admin_Manager.h70
-rw-r--r--ACE/ace/Monitor_Base.cpp188
-rw-r--r--ACE/ace/Monitor_Base.h128
-rw-r--r--ACE/ace/Monitor_Base.inl26
-rw-r--r--ACE/ace/Monitor_Control_Action.cpp45
-rw-r--r--ACE/ace/Monitor_Control_Action.h65
-rw-r--r--ACE/ace/Monitor_Control_Types.cpp69
-rw-r--r--ACE/ace/Monitor_Control_Types.h101
-rw-r--r--ACE/ace/Monitor_Point_Registry.cpp160
-rw-r--r--ACE/ace/Monitor_Point_Registry.h100
-rw-r--r--ACE/ace/Monitor_Size.cpp45
-rw-r--r--ACE/ace/Monitor_Size.h66
-rw-r--r--ACE/ace/ace.mpc8
17 files changed, 1337 insertions, 0 deletions
diff --git a/ACE/ace/Global_Macros.h b/ACE/ace/Global_Macros.h
index e607d812750..5cbe60b8262 100644
--- a/ACE/ace/Global_Macros.h
+++ b/ACE/ace/Global_Macros.h
@@ -1127,6 +1127,9 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC
# define ACE_STATIC_CONSTANT(TYPE, ASSIGNMENT) enum { ASSIGNMENT }
#endif /* !ACE_LACKS_STATIC_IN_CLASS_CONSTANTS */
+#if !defined (ACE_HAS_MONITOR_FRAMEWORK)
+# define ACE_HAS_MONITOR_FRAMEWORK 1
+#endif
#include /**/ "ace/post.h"
diff --git a/ACE/ace/Monitor_Admin.cpp b/ACE/ace/Monitor_Admin.cpp
new file mode 100644
index 00000000000..5401b2153ff
--- /dev/null
+++ b/ACE/ace/Monitor_Admin.cpp
@@ -0,0 +1,113 @@
+// $Id$
+
+#include "ace/Monitor_Admin.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Reactor.h"
+#include "ace/Monitor_Point_Registry.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ int
+ MonitorPointAutoUpdater::handle_timeout (
+ const ACE_Time_Value& /* current_time */,
+ const void* monitor_point)
+ {
+ const Monitor_Base* const_mp =
+ reinterpret_cast<const Monitor_Base*> (monitor_point);
+ Monitor_Base* mp = const_cast<Monitor_Base*> (const_mp);
+ mp->update ();
+ return 0;
+ }
+
+ //====================================================================
+
+ Monitor_Admin::Monitor_Admin (void)
+ : reactor_ (ACE_Reactor::instance ()),
+ default_reactor_ (true)
+ {}
+
+ Monitor_Admin::~Monitor_Admin (void)
+ {
+ if (this->default_reactor_)
+ {
+ /// Destroys the timers associated with our event handler
+ /// before its destructor is called.
+ ACE_Reactor::instance ()->close_singleton ();
+ }
+
+ /// We access the registry through ACE_Singleton, which
+ /// doesn't call the destructor, so we call this method to
+ /// do a remove_ref() on all monitor points left in the registry.
+ /// which needs to be done before the registry goes away.
+ Monitor_Point_Registry::instance ()->cleanup ();
+ }
+
+ bool
+ Monitor_Admin::monitor_point (Monitor_Base* monitor_point,
+ const ACE_Time_Value& time)
+ {
+ /// This call checks for a null monitor_point.
+ bool good_reg_add =
+ Monitor_Point_Registry::instance ()->add (monitor_point);
+
+ if (!good_reg_add)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registration of %s failed\n",
+ monitor_point->name ()),
+ good_reg_add);
+ }
+ else if (time != ACE_Time_Value::zero)
+ {
+ this->reactor_->schedule_timer (&this->auto_updater_,
+ monitor_point,
+ ACE_Time_Value::zero,
+ time);
+ }
+
+ return good_reg_add;
+ }
+
+ Monitor_Base*
+ Monitor_Admin::monitor_point (const char* name)
+ {
+ ACE_CString name_str (name, 0, false);
+ return Monitor_Point_Registry::instance ()->get (name_str);
+ }
+
+ void
+ Monitor_Admin::auto_query (ACE_Event_Handler* handler,
+ MonitorQuery* query,
+ const ACE_Time_Value& time)
+ {
+ this->reactor_->schedule_timer (handler,
+ query,
+ ACE_Time_Value::zero,
+ time);
+ }
+
+ void
+ Monitor_Admin::reactor (ACE_Reactor* new_reactor)
+ {
+ this->reactor_ = new_reactor;
+ this->default_reactor_ = false;
+ }
+
+ ACE_Reactor*
+ Monitor_Admin::reactor (void) const
+ {
+ return this->reactor_;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
diff --git a/ACE/ace/Monitor_Admin.h b/ACE/ace/Monitor_Admin.h
new file mode 100644
index 00000000000..1734f92f517
--- /dev/null
+++ b/ACE/ace/Monitor_Admin.h
@@ -0,0 +1,108 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Admin.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_ADMIN_H
+#define MONITOR_ADMIN_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Event_Handler.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ class MonitorQuery;
+
+ /**
+ * @class MonitorPointAutoUpdater
+ *
+ * @brief Automates periodic updating of monitor point classes.
+ *
+ * A single instance of this class is held by the Admin
+ * class below. For a monitor point that must periodically
+ * check what they are monitoring, the admin class registers
+ * the monitor point with the ACE reactor. Each time the
+ * interval times out, the reactor will call the
+ * handle_timeout() method below, and pass in the appropriate
+ * monitor point. The handle_timeout() method will in turn
+ * call the appropriate method on the monitor point to get
+ * it to update its data.
+ */
+ struct MonitorPointAutoUpdater : ACE_Event_Handler
+ {
+ /// Override of ACE base class method.
+ virtual int handle_timeout (const ACE_Time_Value& interval,
+ const void* monitor_point);
+ };
+
+ /**
+ * @class Admin
+ *
+ * @brief Accesses monitor points or groups and manages the registries.
+ *
+ * Responsible for adding and removing monitor points and creating
+ * automatic periodic actions that update or query monitor points.
+ */
+ class ACE_Export Monitor_Admin
+ {
+ public:
+ Monitor_Admin (void);
+ ~Monitor_Admin (void);
+
+ /// Add or access monitor points in a global registry
+ /// If the ACE_Time_Value arg is non-zero,
+ /// the monitor point, the auto updater member, and the given time
+ /// interval are passed to our reactor's register_timeout()
+ /// method.
+
+ bool monitor_point (Monitor_Base* monitor_point,
+ const ACE_Time_Value& time);
+ Monitor_Base* monitor_point (const char* name);
+
+ /// Works similarly to monitor_point() above, but registers the
+ /// handler arg's handle_timeout() method with the reactor,
+ /// instead of our auto_updater_'s handle_timeout().
+ void auto_query (ACE_Event_Handler* handler,
+ MonitorQuery* query,
+ const ACE_Time_Value& time);
+
+ /// This mutator allows the application to create its own reactor
+ /// and substitute it for the default reactor.
+ void reactor (ACE_Reactor* new_reactor);
+ ACE_Reactor* reactor (void) const;
+
+ private:
+ MonitorPointAutoUpdater auto_updater_;
+ ACE_Reactor* reactor_;
+ bool default_reactor_;
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_ADMIN_H
diff --git a/ACE/ace/Monitor_Admin_Manager.cpp b/ACE/ace/Monitor_Admin_Manager.cpp
new file mode 100644
index 00000000000..b815100ef61
--- /dev/null
+++ b/ACE/ace/Monitor_Admin_Manager.cpp
@@ -0,0 +1,42 @@
+// $Id$
+
+#include "ace/Monitor_Admin_Manager.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Service_Config.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Monitor_Admin&
+ Monitor_Admin_Manager::admin (void)
+ {
+ return this->admin_;
+ }
+
+ int
+ Monitor_Admin_Manager::Initializer (void)
+ {
+ return
+ ACE_Service_Config::process_directive (ace_svc_desc_MC_ADMINMANAGER);
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+ACE_STATIC_SVC_DEFINE (MC_ADMINMANAGER,
+ ACE_TEXT ("MC_ADMINMANAGER"),
+ ACE_SVC_OBJ_T,
+ &ACE_SVC_NAME (MC_ADMINMANAGER),
+ ACE_Service_Type::DELETE_THIS
+ | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (ACE, MC_ADMINMANAGER)
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
diff --git a/ACE/ace/Monitor_Admin_Manager.h b/ACE/ace/Monitor_Admin_Manager.h
new file mode 100644
index 00000000000..5e5fbb09008
--- /dev/null
+++ b/ACE/ace/Monitor_Admin_Manager.h
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Admin_Manager.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_ADMIN_MANAGER_H
+#define MONITOR_ADMIN_MANAGER_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Service_Object.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Admin.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ /**
+ * @class Monitor_Admin_Manager
+ *
+ * @brief Repsonsible for creating and destroying the global
+ * (per process) instance of the Admin class.
+ *
+ * Monitor_Admin_Manager will be instantiated as an ACE_Dynamic_Service
+ * singleton, and implements the interface of ACE_Service_Object.
+ */
+ class ACE_Export Monitor_Admin_Manager : public ACE_Service_Object
+ {
+ public:
+ /// Access the admin instance.
+ ACE::MonitorControl::Monitor_Admin& admin (void);
+
+ /// Used to force initialization of the MC service.
+ static int Initializer (void);
+
+ private:
+ Monitor_Admin admin_;
+ };
+ }
+}
+
+/// For the ACE_FACTORY_DEFINE macro in the .cpp file.
+typedef ACE::MonitorControl::Monitor_Admin_Manager MC_ADMINMANAGER;
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+ACE_STATIC_SVC_DECLARE (MC_ADMINMANAGER)
+ACE_FACTORY_DECLARE (ACE, MC_ADMINMANAGER)
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_ADMIN_MANAGER_H
diff --git a/ACE/ace/Monitor_Base.cpp b/ACE/ace/Monitor_Base.cpp
new file mode 100644
index 00000000000..546dbedef5f
--- /dev/null
+++ b/ACE/ace/Monitor_Base.cpp
@@ -0,0 +1,188 @@
+// $Id$
+
+#include "ace/Monitor_Base.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Admin_Manager.h"
+#include "ace/Monitor_Control_Action.h"
+#include "ace/Monitor_Point_Registry.h"
+#include "ace/Guard_T.h"
+#include "ace/Dynamic_Service.h"
+#include "ace/OS_NS_sys_time.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Monitor_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Monitor_Base::Monitor_Base (void)
+ : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
+ {
+ }
+
+ Monitor_Base::Monitor_Base (const char* name)
+ : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
+ , name_ (name)
+ {
+ }
+
+ Monitor_Base::~Monitor_Base (void)
+ {
+ }
+
+ long
+ Monitor_Base::add_constraint (const char* expression,
+ Control_Action* action)
+ {
+ /// Thread-safe and guaranteed to be unique.
+ long id = Monitor_Point_Registry::instance ()->constraint_id ();
+
+ CONSTRAINTS::value_type entry;
+ entry.first = id;
+ entry.second.expr = expression;
+ entry.second.control_action = action;
+
+ /// This is thread-safe on its own so we don't have
+ /// to guard it here.
+ action->add_ref ();
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1);
+
+ /// Since we know external key is unique,
+ /// we don't check for failure.
+ (void) this->constraints_.insert (entry);
+ }
+
+ return id;
+ }
+
+ Control_Action*
+ Monitor_Base::remove_constraint (const long constraint_id)
+ {
+ Control_Action* retval = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ CONSTRAINT_ITERATOR i = this->constraints_.find (constraint_id);
+
+ if (i != this->constraints_.end ())
+ {
+ retval = i->second.control_action;
+ (void) this->constraints_.erase (constraint_id);
+ }
+ }
+
+ return retval;
+ }
+
+ Monitor_Base::CONSTRAINTS&
+ Monitor_Base::constraints (void)
+ {
+ return this->constraints_;
+ }
+
+ void
+ Monitor_Base::retrieve (Monitor_Control_Types::Data& data) const
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+ data = this->data_;
+ }
+
+ void
+ Monitor_Base::receive (size_t value)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ this->data_.timestamp_ = ACE_OS::gettimeofday ();
+ this->data_.value_ = static_cast<double> (value);
+ }
+
+ void
+ Monitor_Base::receive (double data)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+ this->data_.timestamp_ = ACE_OS::gettimeofday ();
+ this->data_.value_ = data;
+ }
+
+ void
+ Monitor_Base::clear (void)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ this->clear_i ();
+ }
+
+ void
+ Monitor_Base::clear_i (void)
+ {
+ this->data_.value_ = 0.0;
+ this->data_.timestamp_ = ACE_Time_Value::zero;
+ }
+
+
+ void
+ Monitor_Base::retrieve_and_clear (Monitor_Control_Types::Data& data)
+ {
+ ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
+
+ data = this->data_;
+ this->clear_i ();
+ }
+
+ void
+ Monitor_Base::add_to_registry (const ACE_Time_Value& time)
+ {
+ MC_ADMINMANAGER *mgr =
+ ACE_Dynamic_Service<MC_ADMINMANAGER>::instance ("MC_ADMINMANAGER");
+
+ if (!mgr->admin ().monitor_point (this, time))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "monitor point %s registration failed\n",
+ this->name ()));
+ }
+ }
+
+ void
+ Monitor_Base::remove_from_registry (void)
+ {
+ if (!Monitor_Point_Registry::instance ()->remove (this->name ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "monitor point %s unregistration failed\n",
+ this->name ()));
+ }
+ }
+
+ void
+ Monitor_Base::add_ref (void)
+ {
+ (void) this->increment ();
+ }
+
+ void
+ Monitor_Base::remove_ref (void)
+ {
+ long const new_count = this->decrement ();
+
+ if (new_count == 0)
+ {
+ delete this;
+ }
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
diff --git a/ACE/ace/Monitor_Base.h b/ACE/ace/Monitor_Base.h
new file mode 100644
index 00000000000..859deb8cea3
--- /dev/null
+++ b/ACE/ace/Monitor_Base.h
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Base.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_BASE_H
+#define MONITOR_BASE_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Monitor_Control_Types.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Refcountable_T.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Synch_Traits.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+class ETCL_Constraint;
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ class Control_Action;
+
+ /**
+ * @class Monitor_Base
+ *
+ * @brief Base class from which the template monitor point class is
+ * derived.
+ *
+ * All the operations are pure virtual so they can
+ * be implemented in the 'disabled' template specialization
+ * as no-ops.
+ */
+ class ACE_Export Monitor_Base
+ : private ACE_Refcountable_T<ACE_SYNCH_MUTEX>
+ {
+ public:
+ typedef Monitor_Control_Types::ConstraintList CONSTRAINTS;
+ typedef CONSTRAINTS::const_iterator CONSTRAINT_ITERATOR;
+
+ /// Implemented by the most-derived class. Does the actual
+ /// work of fetching the monitored value.
+ virtual void update (void) = 0;
+
+ /// Updates the monitor's data if it is a numeric floating point.
+ virtual void receive (double value);
+
+ /// Updates the monitor's data if it is an integer size.
+ virtual void receive (size_t value);
+
+ /// Add a constraint, returns a unique constraint id.
+ long add_constraint (const char* expression,
+ Control_Action* action = 0);
+
+ /// Remove a constraint and return the associated control action,
+ /// which may be shared, for deletion or further use.
+ Control_Action* remove_constraint (const long constraint_id);
+
+ /// Get all constraints
+ CONSTRAINTS& constraints (void);
+
+ /// Reset function.
+ void clear (void);
+
+ /// Data accessors.
+ void retrieve (Monitor_Control_Types::Data& data) const;
+ void retrieve_and_clear (Monitor_Control_Types::Data& data);
+
+ /// Common to all monitors.
+
+ void add_to_registry (
+ const ACE_Time_Value& time = ACE_Time_Value::zero);
+ void remove_from_registry (void);
+
+ const char* name (void) const;
+ void name (const char* new_name);
+
+ void add_ref (void);
+ void remove_ref (void);
+
+ protected:
+ Monitor_Base (void);
+ Monitor_Base (const char* name);
+ virtual ~Monitor_Base (void);
+
+ /// Overridden in some monitors (for example the OS monitors) where
+ /// clearing requires monitor-specific actions.
+ virtual void clear_i (void);
+
+ protected:
+ Monitor_Control_Types::Data data_;
+ mutable ACE_SYNCH_MUTEX mutex_;
+
+ CONSTRAINTS constraints_;
+
+ private:
+ ACE_CString name_;
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/Monitor_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_BASE_H
diff --git a/ACE/ace/Monitor_Base.inl b/ACE/ace/Monitor_Base.inl
new file mode 100644
index 00000000000..b478e5256fc
--- /dev/null
+++ b/ACE/ace/Monitor_Base.inl
@@ -0,0 +1,26 @@
+// $Id$
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ ACE_INLINE
+ const char*
+ Monitor_Base::name (void) const
+ {
+ return this->name_.c_str ();
+ }
+
+ ACE_INLINE
+ void
+ Monitor_Base::name (const char* new_name)
+ {
+ this->name_ = new_name;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/ACE/ace/Monitor_Control_Action.cpp b/ACE/ace/Monitor_Control_Action.cpp
new file mode 100644
index 00000000000..bee5fa5f9cf
--- /dev/null
+++ b/ACE/ace/Monitor_Control_Action.cpp
@@ -0,0 +1,45 @@
+// $Id$
+
+#include "ace/Monitor_Control_Action.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Guard_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Control_Action::Control_Action (void)
+ : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
+ {}
+
+ Control_Action::~Control_Action (void)
+ {}
+
+ void
+ Control_Action::add_ref (void)
+ {
+ (void) this->increment ();
+ }
+
+ void
+ Control_Action::remove_ref (void)
+ {
+ const long new_count = this->decrement ();
+
+ if (new_count == 0)
+ {
+ delete this;
+ }
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/ACE/ace/Monitor_Control_Action.h b/ACE/ace/Monitor_Control_Action.h
new file mode 100644
index 00000000000..c45d27b1179
--- /dev/null
+++ b/ACE/ace/Monitor_Control_Action.h
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Control_Action.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_CONTROL_ACTION_H
+#define MONITOR_CONTROL_ACTION_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Refcountable_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ /**
+ * @class ControlAction
+ *
+ * @brief Base class for control actions initiated by the
+ * application or by constraint evaluation trigger.
+ *
+ * This class is extended by the application developer or
+ * by the MC service itself to create a concrete class.
+ */
+ class ACE_Export Control_Action
+ : private ACE_Refcountable_T<ACE_SYNCH_MUTEX>
+ {
+ public:
+ /// To be implemented by the concrete derived class.
+ virtual void execute (const char* command = 0) = 0;
+
+ /// Refcounting methods.
+ void add_ref (void);
+ void remove_ref (void);
+
+ protected:
+ Control_Action (void);
+ virtual ~Control_Action (void);
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_CONTROL_ACTION_H
diff --git a/ACE/ace/Monitor_Control_Types.cpp b/ACE/ace/Monitor_Control_Types.cpp
new file mode 100644
index 00000000000..13eaba6fc38
--- /dev/null
+++ b/ACE/ace/Monitor_Control_Types.cpp
@@ -0,0 +1,69 @@
+// $Id$
+
+#include "ace/Monitor_Control_Types.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Control_Action.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Monitor_Control_Types::Data::Data (void)
+ : timestamp_ (ACE_Time_Value::zero),
+ value_ (0.0)
+ {}
+
+ //=============================================================
+
+ Monitor_Control_Types::Constraint::Constraint (void)
+ : control_action (0)
+ {}
+
+ Monitor_Control_Types::Constraint::Constraint (const Constraint& rhs)
+ : expr (rhs.expr),
+ control_action (rhs.control_action)
+ {
+ if (control_action != 0)
+ {
+ control_action->add_ref ();
+ }
+ }
+
+ Monitor_Control_Types::Constraint::~Constraint (void)
+ {
+ if (this->control_action != 0)
+ {
+ this->control_action->remove_ref ();
+ }
+ }
+
+ Monitor_Control_Types::Constraint&
+ Monitor_Control_Types::Constraint::operator= (const Constraint& rhs)
+ {
+ if (this->control_action != 0)
+ {
+ this->control_action->remove_ref ();
+ }
+
+ this->expr = rhs.expr;
+ this->control_action = rhs.control_action;
+
+ if (this->control_action != 0)
+ {
+ this->control_action->add_ref ();
+ }
+
+ return *this;
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+
diff --git a/ACE/ace/Monitor_Control_Types.h b/ACE/ace/Monitor_Control_Types.h
new file mode 100644
index 00000000000..dfc584fe081
--- /dev/null
+++ b/ACE/ace/Monitor_Control_Types.h
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Control_Types.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_CONTROL_TYPES_H
+#define MONITOR_CONTROL_TYPES_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Vector_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Array_Map.h"
+#include "ace/SString.h"
+#include "ace/Time_Value.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ class Control_Action;
+
+ struct ACE_Export Monitor_Control_Types
+ {
+ /**
+ * @brief An instance is contained by each enabled monitor point.
+ */
+ struct ACE_Export Data
+ {
+ Data (void);
+ ACE_Time_Value timestamp_;
+ double value_;
+ };
+
+ /**
+ * @brief Bundles the constrain string with its associated
+ * trigger action.
+ */
+ struct ACE_Export Constraint
+ {
+ Constraint (void);
+ ~Constraint (void);
+
+ /// Implemented explicitly so reference counting of control
+ /// actions can be managed.
+ Constraint (const Constraint& rhs);
+ Constraint& operator= (const Constraint& rhs);
+
+ ACE_CString expr;
+ Control_Action* control_action;
+ };
+
+#if defined (__BORLANDC__) && (__BORLANDC__ <= 0x570)
+ // Borland C++ Builder 6 and earlier don't handle the second template
+ // argument correctly. We have to pass it explicitly
+ typedef ACE_Vector<Data, ACE_VECTOR_DEFAULT_SIZE> DataList;
+ typedef ACE_Vector<ACE_CString, ACE_VECTOR_DEFAULT_SIZE> NameList;
+ typedef ACE_Array_Map<long, Constraint, std::equal_to<long> > ConstraintList;
+#else
+ /**
+ * @brief Used by the admin class as a container for the data from
+ * a group of monitor points.
+ */
+ typedef ACE_Vector<Data> DataList;
+
+ /**
+ * @brief Used in various places to pass around a set of string names.
+ */
+ typedef ACE_Vector<ACE_CString> NameList;
+
+ /**
+ * @brief Holder for a monitor point's constraints.
+ */
+ typedef ACE_Array_Map<long, Constraint> ConstraintList;
+#endif
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_CONTROL_TYPES_H
diff --git a/ACE/ace/Monitor_Point_Registry.cpp b/ACE/ace/Monitor_Point_Registry.cpp
new file mode 100644
index 00000000000..3d58f445906
--- /dev/null
+++ b/ACE/ace/Monitor_Point_Registry.cpp
@@ -0,0 +1,160 @@
+// $Id$
+
+#include "ace/Monitor_Point_Registry.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Monitor_Point_Registry*
+ Monitor_Point_Registry::instance (void)
+ {
+ return
+ ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ Monitor_Point_Registry::Monitor_Point_Registry (void)
+ : constraint_id_ (0)
+ {
+ }
+
+ bool
+ Monitor_Point_Registry::add (Monitor_Base* type)
+ {
+ if (type == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry add: null type\n"),
+ false);
+ }
+
+ int status = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false);
+
+ type->add_ref ();
+
+ status = this->map_.bind (type->name (), type);
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry add: map bind failed\n"),
+ false);
+ }
+
+ return (status == 0);
+ }
+
+ bool
+ Monitor_Point_Registry::remove (const char* name)
+ {
+ if (name == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry remove: null name\n"),
+ false);
+ }
+
+ int status = 0;
+ Map::data_type mp = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false);
+
+ ACE_CString name_str (name, 0, false);
+ status = this->map_.unbind (name_str, mp);
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registry remove: unbind failed for %s\n",
+ name),
+ false);
+ }
+ else
+ {
+ mp->remove_ref ();
+ }
+
+ return (status == 0);
+ }
+
+ Monitor_Control_Types::NameList
+ Monitor_Point_Registry::names (void)
+ {
+ Monitor_Control_Types::NameList name_holder_;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ for (Map::CONST_ITERATOR i (this->map_); !i.done (); i.advance ())
+ {
+ name_holder_.push_back (i->key ());
+ }
+ }
+
+ return name_holder_;
+ }
+
+ Monitor_Base*
+ Monitor_Point_Registry::get (const ACE_CString& name) const
+ {
+ Map::data_type mp = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
+
+ this->map_.find (name, mp);
+ }
+
+ if (mp != 0)
+ {
+ mp->add_ref ();
+ }
+
+ return mp;
+ }
+
+ long
+ Monitor_Point_Registry::constraint_id (void)
+ {
+ long retval = 0;
+
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1);
+
+ retval = this->constraint_id_++;
+ }
+
+ return retval;
+ }
+
+ void
+ Monitor_Point_Registry::cleanup (void)
+ {
+ for (Map::ITERATOR i = this->map_.begin ();
+ i != this->map_.end ();
+ i.advance ())
+ {
+ Map::ENTRY* entry;
+ i.next (entry);
+ entry->int_id_->remove_ref ();
+ }
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
diff --git a/ACE/ace/Monitor_Point_Registry.h b/ACE/ace/Monitor_Point_Registry.h
new file mode 100644
index 00000000000..81b4a413d03
--- /dev/null
+++ b/ACE/ace/Monitor_Point_Registry.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Point_Registry.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_POINT_REGISTRY_H
+#define MONITOR_POINT_REGISTRY_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Thread_Mutex.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Synch_Traits.h"
+#include "ace/Null_Mutex.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Monitor_Control_Types.h"
+#include "ace/Singleton.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ class Monitor_Base;
+
+ /**
+ * @class Monitor_Point_Registry
+ *
+ * @brief Storage for instantiated monitor points.
+ *
+ */
+ class ACE_Export Monitor_Point_Registry
+ {
+ public:
+ friend class ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>;
+
+ /// Used to help ensure that there is only a single instance
+ /// per process of Monitor_Point_Registry.
+ static Monitor_Point_Registry* instance (void);
+
+ /// Adds a monitor to the registry.
+ bool add (Monitor_Base* type);
+
+ /// Remove a monitor from the registry.
+ bool remove (const char* name);
+
+ /// Returns a list of names stored in the registry
+ Monitor_Control_Types::NameList names (void);
+
+ /// Increments the refcount, so the caller is responsible for
+ /// decrementing it when finished.
+ Monitor_Base* get (const ACE_CString& name) const;
+
+ /// Returns a unique id for a constraint when it is created.
+ long constraint_id (void);
+
+ /// Decrements the reference count on all remaining entries,
+ /// called right before we go out of scope (i.e., process exits).
+ void cleanup (void);
+
+ private:
+ /// Prevent that users can make an instance.
+ Monitor_Point_Registry (void);
+
+ /// Underlying container for the registry.
+ typedef ACE_Hash_Map_Manager<ACE_CString,
+ Monitor_Base*,
+ ACE_SYNCH_NULL_MUTEX> Map;
+
+ mutable ACE_SYNCH_MUTEX mutex_;
+ Map map_;
+
+ /// Since we're accessed as a singleton, we can keep track of
+ /// dispensing unique ids for constraints.
+ long constraint_id_;
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_POINT_REGISTRY_H
diff --git a/ACE/ace/Monitor_Size.cpp b/ACE/ace/Monitor_Size.cpp
new file mode 100644
index 00000000000..1e4adbd54eb
--- /dev/null
+++ b/ACE/ace/Monitor_Size.cpp
@@ -0,0 +1,45 @@
+// $Id$
+
+#include "ace/Size_Monitor.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Guard_T.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ Size_Monitor::Size_Monitor (void)
+ {
+ }
+
+ Size_Monitor::Size_Monitor (const char* name)
+ : Monitor_Base (name)
+ {
+ }
+
+ Size_Monitor::~Size_Monitor (void)
+ {
+ }
+
+ void
+ Size_Monitor::update (void)
+ {
+ // No platform-specific or periodic code is needed, receive() can be
+ // called directly whenever the size changes.
+ }
+
+ void
+ Size_Monitor::clear (void)
+ {
+ }
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
diff --git a/ACE/ace/Monitor_Size.h b/ACE/ace/Monitor_Size.h
new file mode 100644
index 00000000000..0aed4edb7ff
--- /dev/null
+++ b/ACE/ace/Monitor_Size.h
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Size_Monitor.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SIZE_MONITOR_H
+#define SIZE_MONITOR_H
+
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/ACE_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Global_Macros.h"
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Monitor_Base.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ /**
+ * @class Size_Monitor
+ *
+ * @brief Base class from which ACE monitors of size are
+ * derived.
+ *
+ */
+ class ACE_Export Size_Monitor : public Monitor_Base
+ {
+ public:
+ Size_Monitor (void);
+ Size_Monitor (const char* name);
+ virtual ~Size_Monitor (void);
+
+ /// Implemented by the most-derived class. Does the actual
+ /// work of fetching the monitored value.
+ virtual void update (void);
+
+ /// Reset function.
+ virtual void clear (void);
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // SIZE_MONITOR_H
diff --git a/ACE/ace/ace.mpc b/ACE/ace/ace.mpc
index 1d40ba96039..4124e678546 100644
--- a/ACE/ace/ace.mpc
+++ b/ACE/ace/ace.mpc
@@ -125,6 +125,12 @@ project(ACE) : acedefaults, install, other, codecs, token, svcconf, uuid, fileca
Method_Request.cpp
MMAP_Memory_Pool.cpp
Msg_WFMO_Reactor.cpp
+ Monitor_Admin.cpp
+ Monitor_Admin_Manager.cpp
+ Monitor_Base.cpp
+ Monitor_Point_Registry.cpp
+ Monitor_Control_Types.cpp
+ Monitor_Control_Action.cpp
Multihomed_INET_Addr.cpp
Mutex.cpp
Netlink_Addr.cpp
@@ -212,6 +218,7 @@ project(ACE) : acedefaults, install, other, codecs, token, svcconf, uuid, fileca
Sig_Adapter.cpp
Sig_Handler.cpp
Signal.cpp
+ Size_Monitor.cpp
SOCK.cpp
SOCK_Acceptor.cpp
SOCK_CODgram.cpp
@@ -328,6 +335,7 @@ project(ACE) : acedefaults, install, other, codecs, token, svcconf, uuid, fileca
Pair_T.cpp
RB_Tree.cpp
Reactor_Token_T.cpp
+ Refcountable_T.cpp
Refcounted_Auto_Ptr.cpp
Reverse_Lock_T.cpp
Select_Reactor_T.cpp