summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-26 16:34:04 +0000
committerjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-26 16:34:04 +0000
commit958011c1b5df5b65e5a38a40d9f799ff4ab618e3 (patch)
tree3f9b1cdd867d30e911c98530b138916666c4dff1
parente689211f9df57c2ae4389850acf54d831b56e66b (diff)
downloadATCD-958011c1b5df5b65e5a38a40d9f799ff4ab618e3.tar.gz
added FLARe directory
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Agent.h97
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/AppOptions.h63
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Handler.h40
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Thread.h44
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideReg.h46
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/ArgPair.h17
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/CPULoadCalculator.h19
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_ORBInitializer.h54
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_Request_Interceptor.h83
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Failure_Handler.h64
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/HMOptions.h67
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Hello.h29
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/HostMonitorImpl.h55
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/IOR_Interceptor.h64
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/LinuxCPULoadCalculator.h34
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Monitor_Thread.h34
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/ObjectReferenceFactory.h65
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/RMOptions.h55
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/RM_Proxy.h37
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/ReplicationManager.h460
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/ServerORBInitializer.h50
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Timer.h66
-rw-r--r--TAO/orbsvcs/examples/FaultTolerance/FLARe/Utilization_Monitor.h37
23 files changed, 1580 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Agent.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Agent.h
new file mode 100644
index 00000000000..8cd120eb2e5
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Agent.h
@@ -0,0 +1,97 @@
+// cvs-id : $Id$
+
+#ifndef AGENT_H
+#define AGENT_H
+
+#include "LWFTS.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Unbounded_Queue.h"
+
+#include <list>
+
+struct AGENT_RANKED_IOR_LIST
+{
+ bool now;
+ std::list<CORBA::Object_var> ior_list;
+};
+
+
+class Agent_i : public virtual POA_Agent
+{
+public:
+ Agent_i (bool proactive = true);
+
+ ~Agent_i (void);
+
+ virtual CORBA::Object_ptr next_member (const char * m
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void update_rank_list (const RankList & rank_list
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ void initialize (CORBA::Object_ptr);
+ void proactive(bool v);
+
+/*
+ virtual void update_reference (const char * m
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void update_failover (const char * object_id,
+ CORBA::Object_ptr next_object
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void update_secondary (const char * object_id,
+ CORBA::Object_ptr next_member
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+
+ virtual void initialize_agent (const ReplicaList & replica_list,
+ const ReplicasList & replicas_list
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+
+ virtual void update_failover_list (const FailoverList &failover_list
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ CORBA::Object_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> REPLICA_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ CORBA::ULong,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> FAILURE_MAP;
+*/
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ AGENT_RANKED_IOR_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECTID_RANKED_IOR_MAP;
+
+
+private:
+ //CORBA::String_var forward_str_;
+ //REPLICA_MAP failover_map_;
+ //REPLICA_MAP secondary_map_;
+ //FAILURE_MAP failure_map_;
+ ReplicationManager_var RM_var_;
+ OBJECTID_RANKED_IOR_MAP objectid_rankedior_map_;
+ ACE_Thread_Mutex ior_map_mutex_;
+ bool proactive_;
+ size_t update_count_;
+};
+
+#endif /* AGENT_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppOptions.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppOptions.h
new file mode 100644
index 00000000000..a1c061f6e8c
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppOptions.h
@@ -0,0 +1,63 @@
+/**
+ * @file AppOptions.h
+ *
+ * @brief Declared the AppOptions class interface.
+ *
+ */
+
+#ifndef _APPOPTIONS_H
+#define _APPOPTIONS_H
+
+#include <iostream>
+#include <string>
+#include "ace/Thread_Mutex.h"
+#include "ArgPair.h"
+
+/**
+ * @class AppOptions
+ *
+ * @brief Declares AppOptions singleton to hold the command line options.
+ */
+
+class AppOptions
+/// TITLE
+/// Singleton class for the program options.
+{
+public:
+
+ /// Singleton access method.
+ static AppOptions *instance (void);
+
+ /// Parse command-line arguments and set the appropriate values as
+ /// follows:
+ bool parse_args (int argc, char **argv);
+ std::string host_id () const;
+ std::string host_monitor_ior () const;
+ size_t get_port () const;
+ std::string ior_output_file () const;
+ std::string object_info_file () const;
+ std::string process_id () const;
+ ArgPair arg_pair () const;
+
+
+protected:
+
+ /// Constructor is protected to ensure Singleton access.
+ AppOptions (void);
+
+ std::string host_monitor_ior_;
+ std::string host_id_;
+ size_t port_;
+ std::string ior_output_file_;
+ std::string object_info_file_;
+ std::string process_id_;
+ ArgPair arg_pair_;
+
+ /// Singleton instance.
+ static AppOptions * volatile instance_;
+ static std::auto_ptr<AppOptions> deleter_;
+ static ACE_Thread_Mutex lock_;
+};
+
+
+#endif /* _APPOPTIONS_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Handler.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Handler.h
new file mode 100644
index 00000000000..bf782cd84a6
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Handler.h
@@ -0,0 +1,40 @@
+/**
+ * @file C++ Interface: AppSideMonitor_Handler
+ *
+ * @brief Declares interface for AppSideMonitor_Handler.
+ *
+ */
+
+#ifndef __APPSIDEMONITOR_HANDLER_H_
+#define __APPSIDEMONITOR_HANDLER_H_
+
+#include "ace/Svc_Handler.h"
+#include "ace/SOCK_Acceptor.h"
+#include "ace/Acceptor.h"
+
+/**
+ * @class AppSideMonitor_Handler
+ *
+ * @brief Encapsulates AppSideMonitor_Handler
+ */
+
+class AppSideMonitor_Handler : public ACE_Svc_Handler <ACE_SOCK_Acceptor::PEER_STREAM, ACE_NULL_SYNCH>
+{
+ public:
+
+ typedef ACE_Svc_Handler <ACE_SOCK_Acceptor::PEER_STREAM, ACE_NULL_SYNCH> super;
+ typedef ACE_Acceptor <AppSideMonitor_Handler, ACE_SOCK_Acceptor> FactoryAcceptor;
+
+ //private:
+ AppSideMonitor_Handler ();
+ public:
+
+ virtual int handle_input (ACE_HANDLE fd);
+ virtual int open (void *factory);
+
+ private:
+ FactoryAcceptor *acceptor_;
+};
+
+#endif /// __APPSIDEMONITOR_HANDLER_H_
+
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Thread.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Thread.h
new file mode 100644
index 00000000000..d8c30519b4f
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideMonitor_Thread.h
@@ -0,0 +1,44 @@
+/**
+ * @file C++ Interface: AppSideMonitor_Thread
+ *
+ * @brief Declares interface for AppSideMonitor_Thread.
+ *
+ */
+
+#ifndef __APPSIDEMONITOR_THREAD_H_
+#define __APPSIDEMONITOR_THREAD_H_
+
+#include "ace/Task.h"
+#include "ace/SOCK_Acceptor.h"
+#include "ace/Reactor.h"
+#include "ace/Barrier.h"
+#include "ace/Acceptor.h"
+
+#include "AppSideMonitor_Handler.h"
+
+/**
+ * @class AppSideMonitor_Thread
+ *
+ * @brief Encapsulates AppSideMonitor_Thread
+ */
+
+class AppSideMonitor_Thread : public ACE_Task_Base
+{
+public:
+
+ AppSideMonitor_Thread (ACE_Barrier *thread_barrier);
+
+ void stop ();
+ virtual int svc (void);
+
+private:
+ size_t port_;
+ ACE_SOCK_Acceptor::PEER_ADDR serv_addr_;
+ ACE_Reactor reactor_;
+ ACE_Acceptor <AppSideMonitor_Handler, ACE_SOCK_Acceptor> acceptor_;
+ ACE_Barrier *synchronizer_;
+};
+
+
+
+#endif /// __APPSIDEMONITOR_THREAD_H_
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideReg.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideReg.h
new file mode 100644
index 00000000000..98ff84e2db8
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/AppSideReg.h
@@ -0,0 +1,46 @@
+/**
+ * @file C++ Interface: AppSideReg
+ *
+ * @brief Declares interface for AppSideReg.
+ *
+ */
+
+#ifndef __APPSIDEREG_H_
+#define __APPSIDEREG_H_
+
+#include "ace/Task.h"
+
+#include "monitorC.h"
+#include "AppSideMonitor_Thread.h"
+
+#include <string>
+
+/**
+ * @class AppSideReg
+ *
+ * @brief Encapsulates AppSideReg
+ */
+
+class ACE_Barrier;
+
+class AppSideReg : public ACE_Task_Base
+{
+public:
+ AppSideReg(ACE_Barrier *ext_b, CORBA::ORB_ptr);
+
+ ~AppSideReg();
+
+ virtual int svc (void);
+ void unregister_process (void);
+
+private:
+ std::string HM_ior_;
+ std::auto_ptr <AppSideMonitor_Thread> monitor_;
+ HostMonitor_var hmvar_;
+ CORBA::ORB_var orb_;
+ ACE_Barrier *external_barrier_;
+};
+
+
+
+#endif /// __APPSIDEREG_H_
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/ArgPair.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ArgPair.h
new file mode 100644
index 00000000000..873316b3531
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ArgPair.h
@@ -0,0 +1,17 @@
+#ifndef _ARGPAIR_H
+#define _ARGPAIR_H
+
+struct ArgPair
+{
+ ArgPair (int argc, char **argv);
+ ~ArgPair ();
+ ArgPair (const ArgPair &);
+ ArgPair & operator = (const ArgPair &);
+ void swap (ArgPair &);
+
+ int argc;
+ char **argv;
+};
+
+#endif /// _ARGPAIR_H
+
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/CPULoadCalculator.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/CPULoadCalculator.h
new file mode 100644
index 00000000000..82053c7b180
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/CPULoadCalculator.h
@@ -0,0 +1,19 @@
+/**
+ * @file C++ Interface: CPULoadCalculator
+ *
+ * @brief Declares interface for CPULoadCalculator.
+ *
+ */
+
+#ifndef __CPULOADCALCULATOR_H
+#define __CPULOADCALCULATOR_H
+
+class CPULoadCalculator
+{
+ public:
+ virtual double percent_load (void) = 0;
+ virtual ~CPULoadCalculator () {}
+};
+
+
+#endif /// __CPULOADCALCULATOR_H
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_ORBInitializer.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_ORBInitializer.h
new file mode 100644
index 00000000000..f78de24fcea
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_ORBInitializer.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+
+#ifndef TAO_CLIENT_ORB_INITIALIZER_H
+#define TAO_CLIENT_ORB_INITIALIZER_H
+
+#include /**/ "ace/pre.h"
+
+#include "tao/PI/PI.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if TAO_HAS_INTERCEPTORS == 1
+
+#include "tao/LocalObject.h"
+
+// This is to remove "inherits via dominance" warnings from MSVC.
+// MSVC is being a little too paranoid.
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class Agent_i;
+
+/// Client side ORB initializer.
+class Client_ORBInitializer :
+ public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ Client_ORBInitializer (Agent_i *agent);
+
+ ~Client_ORBInitializer (void);
+
+ virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info);
+
+ virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info);
+
+private:
+ Agent_i *agent_;
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_CLIENT_ORB_INITIALIZER_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_Request_Interceptor.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_Request_Interceptor.h
new file mode 100644
index 00000000000..0e80b6570a3
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Client_Request_Interceptor.h
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+
+#ifndef CLIENT_REQUEST_INTERCEPTOR_H
+#define CLIENT_REQUEST_INTERCEPTOR_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PI/PI.h"
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+#include "tao/ORB.h"
+#include "tao/CORBA_String.h"
+
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class Agent_i;
+
+class Client_Request_Interceptor
+ : public virtual PortableInterceptor::ClientRequestInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor.
+ Client_Request_Interceptor (const char *orb_id, Agent_i *agent);
+
+ /**
+ * @name Methods Required by the Client Request Interceptor
+ * Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all client request interceptors.
+ */
+ //@{
+ /// Return the name of this ClientRequestinterceptor.
+ virtual char * name (void);
+
+ virtual void destroy (void);
+
+ virtual void send_request (
+ PortableInterceptor::ClientRequestInfo_ptr ri);
+
+ virtual void send_poll (
+ PortableInterceptor::ClientRequestInfo_ptr ri);
+
+ virtual void receive_reply (
+ PortableInterceptor::ClientRequestInfo_ptr ri);
+
+ virtual void receive_exception (
+ PortableInterceptor::ClientRequestInfo_ptr ri);
+
+ virtual void receive_other (
+ PortableInterceptor::ClientRequestInfo_ptr ri);
+ //@}
+
+private:
+
+ ///The ID of the ORB this interceptor is registered with.
+ CORBA::String_var orb_id_;
+
+ /// Pseudo-reference to the ORB this interceptor is registered
+ /// with.
+ CORBA::ORB_var orb_;
+
+ /// The number of requests intercepted by this interceptor.
+ CORBA::ULong request_count_;
+
+ Agent_i *agent_;
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* CLIENT_REQUEST_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Failure_Handler.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Failure_Handler.h
new file mode 100644
index 00000000000..b03b1f00e35
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Failure_Handler.h
@@ -0,0 +1,64 @@
+/**
+ * @file C++ Interface: Failure_Handler
+ *
+ * @brief Declares interface for Failure_Handler.
+ *
+ */
+
+#ifndef __FAILURE_HANDLER_H_
+#define __FAILURE_HANDLER_H_
+
+#include <string>
+
+struct ProcessInfo
+{
+ ProcessInfo () {}
+ ProcessInfo (const std::string &pid,
+ const std::string &hn,
+ size_t port);
+
+ std::string process_id;
+ std::string hostname;
+ size_t port;
+};
+
+
+/**
+ * @class Failure_Handler
+ *
+ * @brief Encapsulates Failure_Handler
+ */
+
+#include "ace/Svc_Handler.h"
+#include "ace/Map_Manager.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/Connector.h"
+
+class HostMonitorImpl;
+
+class Failure_Handler : public ACE_Svc_Handler <ACE_SOCK_Connector::PEER_STREAM, ACE_NULL_SYNCH>
+{
+ public:
+ typedef ACE_Map_Manager <ACE_HANDLE, ProcessInfo, ACE_Thread_Mutex> ProcessInfoMap;
+ typedef ACE_Svc_Handler <ACE_SOCK_Connector::PEER_STREAM, ACE_NULL_SYNCH> super;
+ typedef ACE_Connector <super, ACE_SOCK_Connector> FactoryConnector;
+
+ Failure_Handler ();
+
+ virtual int handle_input (ACE_HANDLE fd);
+ virtual int open (void *factory);
+
+ void set_host_monitor (HostMonitorImpl *hm);
+ int watch_process (ACE_HANDLE fd, const std::string &process_id, const std::string &hostname, size_t port);
+ int drop_process (ACE_HANDLE fd);
+
+ private:
+ static ProcessInfoMap process_map_;
+ FactoryConnector *connector_factory_;
+ HostMonitorImpl *host_monitor_;
+};
+
+
+
+
+#endif /// __FAILURE_HANDLER_H_
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/HMOptions.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/HMOptions.h
new file mode 100644
index 00000000000..3298cf40179
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/HMOptions.h
@@ -0,0 +1,67 @@
+/**
+ * @file HMOptions.h
+ *
+ * @brief Declared the HMOptions class interface.
+ *
+ */
+
+#ifndef _HMOPTIONS_H
+#define _HMOPTIONS_H
+
+#include <iostream>
+#include <string>
+#include "ace/Thread_Mutex.h"
+
+
+/**
+ * @class HMOptions
+ *
+ * @brief Declares HMOptions singleton to hold the command line options.
+ */
+
+#include "ArgPair.h"
+
+class HMOptions
+/// TITLE
+/// Singleton class for the program options.
+{
+public:
+
+ /// Singleton access method.
+ static HMOptions *instance (void);
+
+ /// Parse command-line arguments and set the appropriate values as
+ /// follows:
+ bool parse_args (int argc, char **argv);
+ std::string RM_ior () const;
+ std::string HM_ior_file () const;
+ std::string host_id () const;
+ int RM_update_freq () const;
+ int load_monitor_freq () const;
+ std::string util_file () const;
+ ArgPair arg_pair ();
+ std::pair <char, std::string> ior_access () const;
+
+
+protected:
+
+ /// Constructor is protected to ensure Singleton access.
+ HMOptions (void);
+
+ std::string RM_ior_;
+ std::string host_id_;
+ std::string HM_ior_file_;
+ std::string util_file_;
+ ArgPair arg_pair_;
+ size_t RM_update_freq_;
+ size_t load_monitor_freq_;
+ std::pair <char, std::string> ior_access_;
+
+ /// Singleton instance.
+ static HMOptions * volatile instance_;
+ static std::auto_ptr<HMOptions> deleter_;
+ static ACE_Thread_Mutex lock_;
+};
+
+
+#endif /* _APPOPTIONS_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Hello.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Hello.h
new file mode 100644
index 00000000000..d93950d2bb9
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Hello.h
@@ -0,0 +1,29 @@
+//
+// $Id$
+//
+
+#ifndef HELLO_H
+#define HELLO_H
+#include /**/ "ace/pre.h"
+#include "LWFTS.h"
+
+class Hello_i
+ : public virtual POA_Hello
+{
+public:
+ /// Constructor
+ Hello_i (CORBA::ORB_ptr orb);
+
+ // = The skeleton methods
+ virtual char * get_string (void);
+
+ virtual void shutdown (void);
+
+private:
+ /// Use an ORB reference to conver strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/HostMonitorImpl.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/HostMonitorImpl.h
new file mode 100644
index 00000000000..87b1b45a2fb
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/HostMonitorImpl.h
@@ -0,0 +1,55 @@
+#ifndef __HOSTMONITORIMPL_H
+#define __HOSTMONITORIMPL_H
+
+#include "monitorS.h"
+#include "LWFTS.h"
+
+#include "ace/Map_Manager.h"
+#include "ace/Event_Handler.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/SOCK_Connector.h"
+
+#include "Failure_Handler.h"
+#include "Utilization_Monitor.h"
+#include "RM_Proxy.h"
+#include <string>
+
+class Monitor_Thread;
+
+class HostMonitorImpl : public virtual POA_HostMonitor
+{
+public:
+
+ typedef ACE_Map_Manager <std::string, Failure_Handler *, ACE_Thread_Mutex> ProcessHandlerMap;
+
+ explicit HostMonitorImpl (CORBA::ORB_ptr, Monitor_Thread *);
+ int drop_process (const std::string &process_id);
+
+ ::CORBA::Boolean
+ register_process (const char *process_id, const char * hostname, CORBA::Long port)
+ throw (CORBA::SystemException);
+
+ ::CORBA::Boolean
+ unregister_process (const char *process_id)
+ throw (CORBA::SystemException);
+
+ void dump (void)
+ throw (CORBA::SystemException);
+
+protected:
+ RM_Proxy *create_rm_proxy (void);
+ void remove_rm_proxy (void);
+ int remove_process (std::string const &process_id);
+
+private:
+ Monitor_Thread *monitor_thread_;
+ std::auto_ptr <RM_Proxy> rm_proxy_;
+ std::auto_ptr <Utilization_Monitor> util_mon_;
+ ProcessHandlerMap process_map_;
+ ACE_Connector <Failure_Handler, ACE_SOCK_Connector> connector_;
+ CORBA::ORB_var orb_;
+};
+
+
+#endif
+
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/IOR_Interceptor.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/IOR_Interceptor.h
new file mode 100644
index 00000000000..ca75d85160f
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/IOR_Interceptor.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+
+#ifndef IOR_INTERCEPTOR_H
+#define IOR_INTERCEPTOR_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/IORInterceptor/IORInterceptor.h"
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class IOR_Interceptor
+ : public virtual PortableInterceptor::IORInterceptor_3_0,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ IOR_Interceptor (void);
+
+ /**
+ * @name Methods Required by the IOR Interceptor Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all IOR interceptors.
+ */
+ //@{
+ /// Return the name of this IORInterceptor.
+ virtual char * name (void);
+
+ /// Cleanup resources acquired by this IORInterceptor.
+ virtual void destroy (void);
+
+ /// Add the tagged components to the IOR.
+ virtual void establish_components (
+ PortableInterceptor::IORInfo_ptr info);
+
+ virtual void components_established (
+ PortableInterceptor::IORInfo_ptr info);
+
+ virtual void adapter_manager_state_changed (
+ const char * id,
+ PortableInterceptor::AdapterState state);
+
+ virtual void adapter_state_changed (
+ const PortableInterceptor::ObjectReferenceTemplateSeq & templates,
+ PortableInterceptor::AdapterState state);
+
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* IOR_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/LinuxCPULoadCalculator.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/LinuxCPULoadCalculator.h
new file mode 100644
index 00000000000..c9ebe36c881
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/LinuxCPULoadCalculator.h
@@ -0,0 +1,34 @@
+/**
+ * @file C++ Interface: LinuxCPULoadCalculator
+ *
+ * @brief Declares interface for LinuxCPULoadCalculator.
+ *
+ */
+
+#ifndef __LINUXCPULOADCALCULATOR_H_
+#define __LINUXCPULOADCALCULATOR_H_
+
+#include "CPULoadCalculator.h"
+#include "ace/Thread_Mutex.h"
+
+/**
+ * @class LinuxCPULoadCalculator
+ *
+ * @brief Encapsulates LinuxCPULoadCalculator
+ */
+
+class LinuxCPULoadCalculator : public CPULoadCalculator
+{
+public:
+
+ LinuxCPULoadCalculator();
+
+ virtual double percent_load (void);
+
+ ~LinuxCPULoadCalculator();
+private:
+ ACE_Thread_Mutex calc_mutex_;
+
+};
+
+#endif /// __LINUXCPULOADCALCULATOR_H_
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Monitor_Thread.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Monitor_Thread.h
new file mode 100644
index 00000000000..e29d5cc029e
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Monitor_Thread.h
@@ -0,0 +1,34 @@
+/**
+ * @file C++ Interface: Monitor_Thread
+ *
+ * @brief Declares interface for Monitor_Thread.
+ *
+ */
+
+#ifndef __MONITOR_THREAD_H_
+#define __MONITOR_THREAD_H_
+
+#include "ace/Reactor.h"
+#include "ace/Task.h"
+
+/**
+ * @class Monitor_Thread
+ *
+ * @brief Encapsulates Monitor_Thread
+ */
+
+class Monitor_Thread : public ACE_Task_Base
+{
+ public:
+ Monitor_Thread ();
+ virtual int svc (void);
+ //int register_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask);
+ ACE_Reactor * get_reactor ();
+
+ private:
+ ACE_Reactor reactor_;
+};
+
+
+
+#endif /// __MONITOR_THREAD_H_
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/ObjectReferenceFactory.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ObjectReferenceFactory.h
new file mode 100644
index 00000000000..eec42bb929c
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ObjectReferenceFactory.h
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+
+#ifndef TAO_OBJECT_REFERENCE_FACTORY_H
+#define TAO_OBJECT_REFERENCE_FACTORY_H
+
+#include "ObjectReferenceFactoryC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class ObjectReferenceFactory
+ : public virtual OBV_lwft::ObjectReferenceFactory
+ , public virtual CORBA::DefaultValueRefCountBase
+{
+ public:
+
+ /// Constructor
+ ObjectReferenceFactory (
+ PortableInterceptor::ObjectReferenceFactory * old_orf);
+
+ /**
+ * @name PortableInterceptor::ObjectReferenceFactory Methods
+ *
+ * Methods required by the
+ * PortableInterceptor::ObjectReferenceFactory interface.
+ */
+ //@{
+ virtual CORBA::Object_ptr make_object (
+ const char *repository_id,
+ const PortableInterceptor::ObjectId & id);
+ //@}
+
+protected:
+
+ /// Destructor
+ /**
+ * Protected destructor to enforce proper memory management via
+ * reference counting.
+ */
+ ~ObjectReferenceFactory (void);
+
+private:
+
+ /// The old ObjectReferenceFactory used to create object references.
+ /**
+ * This ObjectReferenceFactory will still be used when creating
+ * object references. However, it will be invoked through this
+ * ObjectReferenceFactory.
+ */
+ PortableInterceptor::ObjectReferenceFactory_var old_orf_;
+
+};
+
+
+#if defined (_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_OBJECT_REFERENCE_FACTORY_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/RMOptions.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/RMOptions.h
new file mode 100644
index 00000000000..634e0cd7ab8
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/RMOptions.h
@@ -0,0 +1,55 @@
+/**
+ * @file RMOptions.h
+ *
+ * @brief Declared the RMOptions class interface.
+ *
+ */
+
+#ifndef _HMOPTIONS_H
+#define _HMOPTIONS_H
+
+#include <iostream>
+#include <string>
+#include "ace/Thread_Mutex.h"
+
+
+/**
+ * @class RMOptions
+ *
+ * @brief Declares RMOptions singleton to hold the command line options.
+ */
+
+#include "ArgPair.h"
+
+class RMOptions
+/// TITLE
+/// Singleton class for the program options.
+{
+public:
+
+ /// Singleton access method.
+ static RMOptions *instance (void);
+
+ /// Parse command-line arguments and set the appropriate values as
+ /// follows:
+ bool parse_args (int argc, char **argv);
+ bool proactive () const;
+ double hertz() const;
+
+protected:
+
+ /// Constructor is protected to ensure Singleton access.
+ RMOptions (void);
+
+ double hertz_;
+ bool proactive_;
+ ArgPair arg_pair_;
+
+ /// Singleton instance.
+ static RMOptions * volatile instance_;
+ static std::auto_ptr<RMOptions> deleter_;
+ static ACE_Thread_Mutex lock_;
+};
+
+
+#endif /* _APPOPTIONS_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/RM_Proxy.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/RM_Proxy.h
new file mode 100644
index 00000000000..5ce1c56e5b2
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/RM_Proxy.h
@@ -0,0 +1,37 @@
+
+#ifndef RM_PROXY_H
+#define RM_PROXY_H
+
+#include "RM_Proxy.h"
+#include "Timer.h"
+#include "monitorC.h"
+#include "CPULoadCalculator.h"
+#include "LWFTC.h"
+
+class RM_Proxy : protected Timer
+{
+public:
+
+ using Timer::start;
+ using Timer::stop;
+ using Timer::hertz;
+
+ RM_Proxy (CORBA::ORB_ptr);
+ virtual ~RM_Proxy ();
+ void setCPULoadCalculator (CPULoadCalculator *load_calc);
+ void proc_failure (const std::string &process_id);
+
+ /// Helper function to be called back after a timeout
+ virtual int pulse (void);
+
+protected:
+ CORBA::Object_var obtain_RM_ior (CORBA::ORB_ptr orb);
+
+private:
+ CPULoadCalculator *load_calc_;
+ ReplicationManager_var RM_var_;
+ CORBA::ORB_var orb_;
+};
+
+
+#endif /* RM_TIMER_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/ReplicationManager.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ReplicationManager.h
new file mode 100644
index 00000000000..d3d3c53bd1d
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ReplicationManager.h
@@ -0,0 +1,460 @@
+// cvs-id : $Id$
+
+#ifndef REPLICATION_MANAGER_H
+#define REPLICATION_MANAGER_H
+
+#include "LWFTS.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Unbounded_Queue.h"
+#include "ace/Unbounded_Set.h"
+#include "ace/Condition_T.h"
+#include "ace/Containers_T.h"
+#include "Timer.h"
+#include "ace/Recursive_Thread_Mutex.h"
+
+#include <list>
+#include <queue>
+
+typedef enum { PRIMARY=1, BACKUP=2 } Role;
+typedef enum { PROCESS_LEVEL=1, PROCESSOR_LEVEL=2 } AlgoMode;
+
+class Algorithm;
+
+struct APP_INFO
+{
+ ACE_CString object_id;
+ double load;
+ ACE_CString host_name;
+ ACE_CString process_id;
+ Role role;
+ CORBA::Object_var ior;
+
+public:
+
+ APP_INFO();
+ APP_INFO (APP_INFO const & app_info);
+ APP_INFO (const char *oid, double l, const char *hname,
+ const char *pid, Role r, CORBA::Object_ptr ref);
+ APP_INFO (const char *oid, const char *hname,
+ const char *pid, Role r);
+ void swap (APP_INFO & app_info);
+ APP_INFO & operator = (APP_INFO const & app_info);
+ bool operator == (APP_INFO const & app_info);
+};
+
+struct RANKED_IOR_LIST
+{
+ bool now;
+ std::list<CORBA::Object_var> ior_list;
+ std::list<ACE_CString> host_list;
+
+ RANKED_IOR_LIST();
+};
+
+struct UtilRank
+{
+ double util;
+ std::string host_id;
+
+ UtilRank ();
+ UtilRank (UtilRank const & ur);
+ UtilRank (double u, const char * hid);
+};
+
+bool operator < (UtilRank const & u1, UtilRank const & u2);
+
+struct MonitorUpdate
+{
+ typedef enum { PROC_FAIL_UPDATE, HOST_UTIL_UPDATE, RUN_NOW, APP_REG } UpdateType;
+ UpdateType type;
+
+ ACE_CString process_id;
+ ACE_CString host_id;
+ double value;
+ APP_INFO app_info;
+
+ static MonitorUpdate *
+ create_proc_fail_update(const char * pid);
+ static MonitorUpdate *
+ create_host_util_update(const char *hid, double value);
+ static MonitorUpdate *
+ create_run_now_update();
+ static MonitorUpdate *
+ create_app_info_update (const char *oid, double l,
+ const char *hname, const char *pid,
+ Role r, CORBA::Object_ptr ref);
+};
+
+class ReplicationManager_i : public virtual POA_ReplicationManager,
+ protected Timer
+{
+public:
+
+ ReplicationManager_i (CORBA::ORB_ptr orb, double hertz,
+ bool proactive = true, AlgoMode mode = PROCESS_LEVEL);
+
+ ~ReplicationManager_i (void);
+
+ virtual void register_application (const char *object_id,
+ double load,
+ const char *host_name,
+ const char *process_id,
+ CORBA::Short role,
+ CORBA::Object_ptr server_reference
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ void util_update (const char *host_id,
+ double util
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void proc_failure (const char *process_id
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual RankList * register_agent (CORBA::Object_ptr agent_reference
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual CORBA::Object_ptr get_next (const char * object_id
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ bool replica_selection_algo ();
+
+ typedef ACE_Unbounded_Set<ACE_CString> STRING_LIST;
+ typedef ACE_Unbounded_Set<APP_INFO> APP_SET;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ STRING_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> STRING_TO_STRING_LIST_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ ACE_CString,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> STRING_TO_STRING_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ double,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> STRING_TO_DOUBLE_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ APP_SET,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECTID_APPSET_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ RANKED_IOR_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECTID_RANKED_IOR_MAP;
+
+ typedef ACE_Unbounded_Set<CORBA::Object_var> AGENT_LIST;
+
+ enum { UPDATE_LIST_MAX_SIZE = 100 };
+
+private:
+
+ CORBA::ORB_var orb_;
+ Algorithm * algo_thread_;
+ bool proactive_;
+ AlgoMode mode_;
+
+ ACE_DLList <MonitorUpdate> update_list_;
+ ACE_Thread_Mutex update_mutex_;
+ ACE_Condition <ACE_Thread_Mutex> update_available_;
+ ACE_Condition <ACE_Thread_Mutex> update_list_full_;
+
+ OBJECTID_APPSET_MAP objectid_appset_map_;
+ ACE_Recursive_Thread_Mutex appset_lock_;
+ OBJECTID_RANKED_IOR_MAP objectid_rankedior_map_;
+ STRING_TO_DOUBLE_MAP hostid_util_map_;
+ STRING_TO_DOUBLE_MAP objectid_load_map_;
+ STRING_TO_STRING_MAP processid_host_map_;
+
+ STRING_TO_STRING_LIST_MAP processid_backup_map_;
+ STRING_TO_STRING_LIST_MAP processid_primary_map_;
+ STRING_TO_STRING_LIST_MAP hostid_process_map_;
+
+ RankList rank_list_;
+ AGENT_LIST agent_list_;
+ ACE_Thread_Mutex rank_list_agent_list_combined_mutex_;
+
+
+ void update_map (const char * key_str,
+ const char * value_str,
+ STRING_TO_STRING_LIST_MAP & map);
+
+ void update_util_map (const char * key_str,
+ double value,
+ STRING_TO_DOUBLE_MAP & map);
+
+ void update_appset_map (const char * key_str,
+ APP_INFO const & app_info,
+ OBJECTID_APPSET_MAP &);
+
+ void update_ior_map (ACE_CString const & oid,
+ std::priority_queue<UtilRank> const & rank_list);
+
+ void update_proc_host_map (const char *pid,
+ const char * hid,
+ STRING_TO_STRING_MAP & map);
+
+ std::priority_queue <UtilRank>
+ util_sorted_host_list (ACE_CString const & oid,
+ STRING_LIST const & host_list,
+ STRING_TO_DOUBLE_MAP const & hu_map);
+
+ virtual int pulse();
+
+ void move_update_list (ACE_DLList<MonitorUpdate> & source,
+ ACE_DLList<MonitorUpdate> & dest);
+
+ bool process_updates(ACE_DLList<MonitorUpdate> & update_list);
+ void remove_process(ACE_CString const & pid,
+ STRING_TO_STRING_LIST_MAP & map,
+ ACE_CString const & host,
+ Role role);
+
+ void send_rank_list ();
+ void build_rank_list ();
+ void app_reg(APP_INFO & app_info);
+ void static_ranklist_update (const char * object_id,
+ CORBA::Object_ptr ior,
+ Role role);
+ void process_proc_failure (ACE_CString const & process_id);
+ STRING_LIST non_primary_host_list (ACE_CString const & primary_object_id);
+ void replace_primary_tags (ACE_CString const & pid, ACE_CString const & host);
+ void remove_from_appset (ACE_CString const & host, ACE_CString const & pid,
+ ACE_CString const & tag, Role role);
+ void elevate_backup_to_primary (ACE_CString const & tag);
+ void replace_backup_tags (ACE_CString const & pid, ACE_CString const & host);
+ void copy_map (STRING_TO_DOUBLE_MAP const & source, STRING_TO_DOUBLE_MAP & dest);
+ void print_queue (std::priority_queue <UtilRank> queue);
+ // RankList * rank_list_clone ();
+};
+
+/*
+class ReplicationManager_i : public virtual POA_ReplicationManager,
+ protected Timer
+{
+public:
+
+ using Timer::start;
+ using Timer::stop;
+ using Timer::hertz;
+
+ ReplicationManager_i (CORBA::ORB_ptr orb);
+
+ ~ReplicationManager_i (void);
+
+// *************************************************************************
+
+ virtual void register_application (const char *object_id,
+ CORBA::Long load,
+ const char *host_name,
+ const char *process_id,
+ CORBA::Short role,
+ CORBA::Object_ptr server_reference
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void register_agent (CORBA::Object_ptr agent_reference
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual CORBA::Long next_member (const char *
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void util_update (const char *host_id, double utilization
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void proc_failure (const char *process_id
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+
+// *************************************************************************
+
+ virtual int pulse (void);
+
+ void update_replica_group_map (const char *object_id,
+ const char *host_name,
+ const char *process_id,
+ CORBA::Object_ptr server_reference);
+
+ void update_replica_list (CORBA::Object_ptr server_reference,
+ const char *object_id);
+
+ void update_replicas_list (CORBA::Object_ptr server_reference,
+ const char *object_id);
+
+ void update_primary_map (const char *process_id, const char *object_id);
+
+ void update_failover_map (const char *process_id, const char *object_id);
+
+ void update_secondary_map (const char *process_id, const char *object_id);
+
+ void update_host_list (const char *object_id, const char *host_id);
+
+ void update_object_primary_map (const char *process_id,
+ const char *host_id,
+ const char *object_id);
+
+ void update_object_failover_map (const char *process_id,
+ const char *host_id,
+ const char *object_id);
+
+ void update_object_secondary_map (const char *process_id,
+ const char *host_id,
+ const char *object_id);
+
+// ***************************************************************************
+
+ typedef ACE_Unbounded_Set<ACE_CString> PRIMARY_LIST;
+ typedef ACE_Unbounded_Set<ACE_CString> FAILOVER_LIST;
+ typedef ACE_Unbounded_Set<ACE_CString> SECONDARY_LIST;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ PRIMARY_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> PRIMARY_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ FAILOVER_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> FAILOVER_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ SECONDARY_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> SECONDARY_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ ACE_CString,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> PROCESS_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ CORBA::Object_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> REF_MAP;
+
+ typedef ACE_Unbounded_Set<ACE_CString> HOST_LIST;
+
+ typedef ACE_Unbounded_Set<CORBA::Object_ptr> AGENT_LIST;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ HOST_LIST,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> REPLICA_HOST_MAP;
+
+ struct Replica_Group_Entry
+ {
+ PROCESS_MAP process_map;
+ REF_MAP ref_map;
+ HOST_LIST host_list;
+ };
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ Replica_Group_Entry *,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> REPLICA_GROUP_MAP;
+
+ typedef ACE_Hash_Map_Iterator_Ex <
+ ACE_CString,
+ Replica_Group_Entry *,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> REPLICA_GROUP_MAP_ITERATOR;
+
+ struct Object_Info
+ {
+ ACE_CString process_id;
+ ACE_CString host_id;
+ };
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ Object_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECT_PRIMARY_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ Object_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECT_FAILOVER_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ Object_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> OBJECT_SECONDARY_MAP;
+
+ typedef ACE_Hash_Map_Manager_Ex<
+ ACE_CString,
+ double,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> HOST_UTIL_MAP;
+
+private:
+
+ CORBA::ORB_var orb_;
+ TAO_SYNCH_MUTEX lock_;
+ TAO_SYNCH_MUTEX primary_map_lock_;
+ TAO_SYNCH_MUTEX failover_map_lock_;
+ TAO_SYNCH_MUTEX secondary_map_lock_;
+ TAO_SYNCH_MUTEX replica_group_map_lock_;
+ TAO_SYNCH_MUTEX replica_host_map_lock_;
+ TAO_SYNCH_MUTEX object_primary_map_lock_;
+ TAO_SYNCH_MUTEX object_failover_map_lock_;
+ TAO_SYNCH_MUTEX object_secondary_map_lock_;
+ ReplicaList replica_list_;
+ ReplicasList replicas_list_;
+ PRIMARY_MAP primary_map_;
+ FAILOVER_MAP failover_map_;
+ SECONDARY_MAP secondary_map_;
+ REPLICA_GROUP_MAP replica_group_map_;
+ REPLICA_HOST_MAP replica_host_map_;
+ OBJECT_PRIMARY_MAP object_primary_map_;
+ OBJECT_FAILOVER_MAP object_failover_map_;
+ OBJECT_SECONDARY_MAP object_secondary_map_;
+ HOST_UTIL_MAP host_util_map_;
+ AGENT_LIST agent_list_;
+
+};
+*/
+#endif /* REPLICATION_MANAGER_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/ServerORBInitializer.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ServerORBInitializer.h
new file mode 100644
index 00000000000..bd8fb0e3805
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/ServerORBInitializer.h
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+
+#ifndef SERVER_ORB_INITIALIZER_H
+#define SERVER_ORB_INITIALIZER_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PI/PI.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class ServerORBInitializer :
+ public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /**
+ * @name Methods Required by the ORBInitializer Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all ORB initializers.
+ */
+ //@{
+ /// The pre-initialization hook.
+ virtual void pre_init (
+ PortableInterceptor::ORBInitInfo_ptr info);
+
+ /// The post-initialization hook.
+ virtual void post_init (
+ PortableInterceptor::ORBInitInfo_ptr info);
+ //@}
+
+};
+
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* SERVER_ORB_INITIALIZER_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Timer.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Timer.h
new file mode 100644
index 00000000000..37a28c08c3f
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Timer.h
@@ -0,0 +1,66 @@
+//============================================================
+/**
+ * @file Timer.h
+ *
+ * taken from basic sp timer code
+ * @author
+ */
+//============================================================
+
+#ifndef TIMER_H
+#define TIMER_H
+
+#include "ace/Task.h"
+
+/**
+ * @class Timer
+ *
+ */
+class Timer : public ACE_Task_Base
+{
+public:
+ /// Default constructor.
+ Timer (void);
+
+ /// Default destructor.
+ ~Timer (void);
+
+ double hertz (void);
+ void hertz (double h);
+ void start ();
+ void stop ();
+
+ /// Helper function to be called back after a timeout
+ virtual int pulse (void);
+
+ /// timer related functions including the active object svc function which
+ /// runs our timer
+
+ /// Handle the timeout.
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg);
+
+ /// Called when <Time_Handler> is removed.
+ virtual int handle_close (ACE_HANDLE handle,
+ ACE_Reactor_Mask close_mask);
+
+ virtual int svc (void);
+
+protected:
+ /// Flag to indicate completion of this active object.
+ int done_;
+
+ /// flag to indicate if we are already activated
+ int active_;
+
+ /// Frequency
+ double hertz_;
+
+ /// The timer id we are waiting.
+ long tid_;
+
+};
+
+
+
+#endif /* TIMER_H */
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Utilization_Monitor.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Utilization_Monitor.h
new file mode 100644
index 00000000000..2784d88b4cb
--- /dev/null
+++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Utilization_Monitor.h
@@ -0,0 +1,37 @@
+
+#ifndef UTILIZATION_MONITOR_H
+#define UTILIZATION_MONITOR_H
+
+#include "Timer.h"
+#include "CPULoadCalculator.h"
+#include <fstream>
+
+class RM_Proxy;
+
+
+class Utilization_Monitor : protected Timer,
+ public CPULoadCalculator
+{
+public:
+
+ using Timer::start;
+ using Timer::stop;
+ using Timer::hertz;
+
+ explicit Utilization_Monitor (CPULoadCalculator *load_calc);
+ virtual ~Utilization_Monitor ();
+
+ /// Helper function to be called back after a timeout
+ virtual int pulse (void);
+ virtual double percent_load (void);
+ void setRM_Proxy (RM_Proxy *rm_proxy);
+
+private:
+ std::auto_ptr <CPULoadCalculator> load_calc_;
+ RM_Proxy *rm_proxy_;
+ double load_;
+ std::ofstream outfile_;
+};
+
+
+#endif /* UTILIZATION_MONITOR_H */