OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
InfoRepo Class Reference

#include <DCPSInfoRepoServ.h>

Inheritance diagram for InfoRepo:
Inheritance graph
[legend]
Collaboration diagram for InfoRepo:
Collaboration graph
[legend]

Classes

struct  InitError
 

Public Member Functions

 InfoRepo (int argc, ACE_TCHAR *argv[])
 
 ~InfoRepo ()
 
void run ()
 
virtual void shutdown ()
 ShutdownInterface used to schedule a shutdown. More...
 
void set_shutdown_signal (int which_signal)
 
void sync_shutdown ()
 
virtual int handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Handler for the reactor to dispatch finalization activity to. More...
 
- Public Member Functions inherited from ShutdownInterface
virtual ~ShutdownInterface ()
 
- Public Member Functions inherited from ACE_Event_Handler
virtual ~ACE_Event_Handler (void)
 
virtual ACE_HANDLE get_handle (void) const
 
virtual void set_handle (ACE_HANDLE)
 
virtual int priority (void) const
 
virtual void priority (int priority)
 
virtual int handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_timeout (const ACE_Time_Value &current_time, const void *act=0)
 
virtual int handle_exit (ACE_Process *)
 
virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask)
 
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 
virtual int resume_handler (void)
 
virtual int handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual int handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual void reactor (ACE_Reactor *reactor)
 
virtual ACE_Reactorreactor (void) const
 
virtual ACE_Reactor_Timer_Interfacereactor_timer_interface (void) const
 
virtual Reference_Count add_reference (void)
 
virtual Reference_Count remove_reference (void)
 
Reference_Counting_Policyreference_counting_policy (void)
 

Private Member Functions

void init ()
 
void usage (const ACE_TCHAR *cmd)
 
void parse_args (int argc, ACE_TCHAR *argv[])
 
void finalize ()
 Actual finalization of service resources. More...
 

Private Attributes

CORBA::ORB_var orb_
 
ACE_TString ior_file_
 
std::string listen_address_str_
 
int listen_address_given_
 
bool use_bits_
 
bool resurrect_
 
ACE_Time_Value reassociate_delay_
 
bool finalized_
 Flag to indicate that finalization has already occurred. More...
 
bool servant_finalized_
 
OpenDDS::Federator::Config federatorConfig_
 Repository Federation behaviors. More...
 
OpenDDS::Federator::ManagerImpl federator_
 
PortableServer::Servant_var< TAO_DDS_DCPSInfo_iinfo_servant_
 
ACE_Thread_Mutex lock_
 
ACE_Condition_Thread_Mutex cond_
 
bool shutdown_complete_
 
int shutdown_signal_
 
ACE_Time_Value dispatch_cleanup_delay_
 

Additional Inherited Members

- Public Types inherited from ACE_Event_Handler
typedef long Reference_Count
 
- Static Public Member Functions inherited from ACE_Event_Handler
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler)
 
static int register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED)
 
static int remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr)
 
- Public Attributes inherited from ACE_Event_Handler
 LO_PRIORITY
 
 HI_PRIORITY
 
 NULL_MASK
 
 READ_MASK
 
 WRITE_MASK
 
 EXCEPT_MASK
 
 ACCEPT_MASK
 
 CONNECT_MASK
 
 TIMER_MASK
 
 QOS_MASK
 
 GROUP_QOS_MASK
 
 SIGNAL_MASK
 
 ALL_EVENTS_MASK
 
 RWE_MASK
 
 DONT_CALL
 
 ACE_EVENT_HANDLER_NOT_RESUMED
 
 ACE_REACTOR_RESUMES_HANDLER
 
 ACE_APPLICATION_RESUMES_HANDLER
 
- Protected Types inherited from ACE_Event_Handler
typedef ACE_Atomic_Op< ACE_SYNCH_MUTEX, Reference_CountAtomic_Reference_Count
 
- Protected Member Functions inherited from ACE_Event_Handler
 ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY)
 
- Protected Attributes inherited from ACE_Event_Handler
Atomic_Reference_Count reference_count_
 

Detailed Description

Definition at line 25 of file DCPSInfoRepoServ.h.

Constructor & Destructor Documentation

◆ InfoRepo()

InfoRepo::InfoRepo ( int  argc,
ACE_TCHAR argv[] 
)

Definition at line 41 of file DCPSInfoRepoServ.cpp.

References ACE_TEXT(), finalize(), and init().

42 : ior_file_(ACE_TEXT("repo.ior"))
44 #ifdef DDS_HAS_MINIMUM_BIT
45 , use_bits_(false)
46 #else
47 , use_bits_(true)
48 #endif
49 , resurrect_(true)
50 , finalized_(false)
51 , servant_finalized_(false)
52 , federatorConfig_(argc, argv)
54 , lock_()
55 , cond_(lock_)
56 , shutdown_complete_(false)
59 {
60  try {
61  this->init();
62  } catch (...) {
63  this->finalize();
64  throw;
65  }
66 }
ACE_Condition_Thread_Mutex cond_
int listen_address_given_
ACE_Time_Value dispatch_cleanup_delay_
bool servant_finalized_
OpenDDS::Federator::ManagerImpl federator_
ACE_TEXT("TCP_Factory")
int shutdown_signal_
bool finalized_
Flag to indicate that finalization has already occurred.
OpenDDS::Federator::Config federatorConfig_
Repository Federation behaviors.
ACE_Thread_Mutex lock_
bool shutdown_complete_
void finalize()
Actual finalization of service resources.
ACE_TString ior_file_

◆ ~InfoRepo()

InfoRepo::~InfoRepo ( )

Definition at line 68 of file DCPSInfoRepoServ.cpp.

References finalize().

69 {
70  try {
71  this->finalize();
72  } catch (const OpenDDS::Federator::Incomplete&) {}
73 }
void finalize()
Actual finalization of service resources.

Member Function Documentation

◆ finalize()

void InfoRepo::finalize ( void  )
private

Actual finalization of service resources.

Definition at line 87 of file DCPSInfoRepoServ.cpp.

References ACE_ERROR, TAO_DDS_DCPSInfo_i::cleanup_all_built_in_topics(), federator_, OpenDDS::Federator::ManagerImpl::finalize(), TAO_DDS_DCPSInfo_i::finalize(), finalized_, info_servant_, CORBA::is_nil(), LM_ERROR, orb_, OpenDDS::DCPS::retcode_to_string(), servant_finalized_, and TheServiceParticipant.

Referenced by InfoRepo(), run(), and ~InfoRepo().

88 {
89  if (this->finalized_) {
90  return;
91  }
92 
93  if (!this->servant_finalized_) {
94  // reached if the ImR caused the ORB to shut down,
95  // which bypasses InfoRepo::handle_exception()
96  this->info_servant_->finalize();
97  this->federator_.finalize();
98  info_servant_->cleanup_all_built_in_topics(); // Used by federator_->finalize
99  const DDS::ReturnCode_t shutdown_error = TheServiceParticipant->shutdown();
100  if (shutdown_error) {
101  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: InfoRepo::finalize: "
102  "TheServiceParticipant->shutdown returned: %C\n",
103  OpenDDS::DCPS::retcode_to_string(shutdown_error)));
104  }
105  this->servant_finalized_ = true;
106  }
107 
108  if (!CORBA::is_nil(this->orb_)) {
109  try {
110  this->orb_->destroy();
111  }
112  catch (const CORBA::Exception&) {
113  //finalizing anyway, not an issue.
114  }
115  }
116 
117  this->finalized_ = true;
118 }
#define ACE_ERROR(X)
const char * retcode_to_string(DDS::ReturnCode_t value)
Definition: DCPS_Utils.cpp:29
PortableServer::Servant_var< TAO_DDS_DCPSInfo_i > info_servant_
bool servant_finalized_
void finalize()
Release resources gracefully.
void finalize()
Cleanup state for shutdown.
OpenDDS::Federator::ManagerImpl federator_
CORBA::ORB_var orb_
void cleanup_all_built_in_topics()
bool finalized_
Flag to indicate that finalization has already occurred.
#define TheServiceParticipant
Boolean is_nil(T x)

◆ handle_exception()

int InfoRepo::handle_exception ( ACE_HANDLE  fd = ACE_INVALID_HANDLE)
virtual

Handler for the reactor to dispatch finalization activity to.

Reimplemented from ACE_Event_Handler.

Definition at line 121 of file DCPSInfoRepoServ.cpp.

References ACE_DEBUG, ACE_ERROR, TAO_DDS_DCPSInfo_i::cleanup_all_built_in_topics(), federator_, OpenDDS::Federator::ManagerImpl::finalize(), TAO_DDS_DCPSInfo_i::finalize(), info_servant_, LM_DEBUG, LM_ERROR, orb_, OpenDDS::DCPS::retcode_to_string(), servant_finalized_, shutdown_signal_, and TheServiceParticipant.

122 {
123  if (shutdown_signal_) {
124  ACE_DEBUG((LM_DEBUG,
125  "InfoRepo_Shutdown: shutting down on signal %d\n",
127  }
128 
129  // these should occur before ORB::shutdown() since they use the ORB/reactor
130  this->info_servant_->finalize();
131  this->federator_.finalize();
132  info_servant_->cleanup_all_built_in_topics(); // Used by federator_->finalize
133  const DDS::ReturnCode_t shutdown_error = TheServiceParticipant->shutdown();
134  if (shutdown_error) {
135  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: InfoRepo::handle_exception: "
136  "TheServiceParticipant->shutdown returned: %C\n",
137  OpenDDS::DCPS::retcode_to_string(shutdown_error)));
138  }
139  this->servant_finalized_ = true;
140 
141  this->orb_->shutdown(true);
142  return 0;
143 }
#define ACE_DEBUG(X)
#define ACE_ERROR(X)
const char * retcode_to_string(DDS::ReturnCode_t value)
Definition: DCPS_Utils.cpp:29
PortableServer::Servant_var< TAO_DDS_DCPSInfo_i > info_servant_
bool servant_finalized_
void finalize()
Release resources gracefully.
void finalize()
Cleanup state for shutdown.
OpenDDS::Federator::ManagerImpl federator_
CORBA::ORB_var orb_
void cleanup_all_built_in_topics()
int shutdown_signal_
#define TheServiceParticipant

◆ init()

void InfoRepo::init ( void  )
private

Definition at line 255 of file DCPSInfoRepoServ.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TEXT(), ACE_ARGV_T< CHAR_TYPE >::add(), ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), OpenDDS::Federator::Config::argv(), ACE_OS::atoi(), ACE_String_Base< char >::c_str(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::Discovery::DEFAULT_REPO, dispatch_cleanup_delay_, ACE_OS::fclose(), OpenDDS::Federator::Config::federateIor(), OpenDDS::Federator::Config::federationDomain(), OpenDDS::Federator::Config::federationId(), federator_, OpenDDS::Federator::FEDERATOR_IORTABLE_KEY, federatorConfig_, ACE_OS::fopen(), ACE_OS::fprintf(), OpenDDS::DCPS::Service_Participant::get_discovery(), OpenDDS::Federator::ManagerImpl::id(), TAO::String_var< charT >::in(), OpenDDS::Federator::ManagerImpl::info(), info_servant_, ior_file_, CORBA::is_nil(), LM_DEBUG, LM_ERROR, OpenDDS::Federator::ManagerImpl::localRepo(), OpenDDS::Federator::ManagerImpl::orb(), orb_, CORBA::ORB_init(), TAO_DDS_DCPSFederationId::overridden(), parse_args(), PortableServer::PERSISTENT, reassociate_delay_, OpenDDS::Federator::REPOSITORY_IORTABLE_KEY, resurrect_, OpenDDS::DCPS::Service_Participant::set_repo_ior(), OpenDDS::DCPS::static_rchandle_cast(), ACE_OS::strcmp(), PortableServer::string_to_ObjectId(), TheParticipantFactoryWithArgs, TheServiceParticipant, use_bits_, PortableServer::USER_ID, and ACE_Time_Value::zero.

Referenced by InfoRepo().

256 {
257  ACE_ARGV args;
258  args.add(federatorConfig_.argv(), true /*quote arg*/);
259 
260  bool use_bidir = true;
261 
262  for (int i = 0; i < args.argc() - 1; ++i) {
263  if (0 == ACE_OS::strcmp(args[i], ACE_TEXT("-DCPSBidirGIOP"))) {
264  use_bidir = ACE_OS::atoi(args[i + 1]);
265  break;
266  }
267  }
268 
269  if (use_bidir) {
270  const ACE_TCHAR* config[] = {
271  ACE_TEXT("-ORBSvcConfDirective"),
272  ACE_TEXT("static Client_Strategy_Factory \"-ORBWaitStrategy rw ")
273  ACE_TEXT("-ORBTransportMuxStrategy exclusive -ORBConnectStrategy blocked ")
274  ACE_TEXT("-ORBConnectionHandlerCleanup 1\""),
275  ACE_TEXT("-ORBSvcConfDirective"),
276  ACE_TEXT("static Resource_Factory \"-ORBFlushingStrategy blocking\""),
277  0
278  };
279  args.add((ACE_TCHAR**)config, true /*quote arg*/);
280  }
281 
282  int argc = args.argc();
283  orb_ = CORBA::ORB_init(argc, args.argv());
284 
285  this->info_servant_ =
286  new TAO_DDS_DCPSInfo_i(this->orb_, this->resurrect_, this,
287  this->federatorConfig_.federationId());
288 
289  // Install the DCPSInfo_i into the Federator::Manager.
290  this->federator_.info() = this->info_servant_.in();
291 
292  CORBA::Object_var obj =
293  this->orb_->resolve_initial_references("RootPOA");
294  PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
295 
296  PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
297 
298  // Use persistent and user id POA policies so the Info Repo's
299  // object references are consistent.
300  CORBA::PolicyList policies(2 + use_bidir);
301  policies.length(2 + use_bidir);
302  policies[0] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
303  policies[1] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
304  if (use_bidir) {
305  CORBA::Any policy;
306  policy <<= BiDirPolicy::BOTH;
307  policies[2] =
308  orb_->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, policy);
309  }
310  PortableServer::POA_var info_poa = root_poa->create_POA("InfoRepo",
311  poa_manager,
312  policies);
313 
314  // Creation of the new POAs over, so destroy the Policy_ptr's.
315  for (CORBA::ULong i = 0; i < policies.length(); ++i) {
316  policies[i]->destroy();
317  }
318 
321  info_poa->activate_object_with_id(oid, this->info_servant_.in());
322  obj = info_poa->id_to_reference(oid);
323  // the object is created locally, so it is safe to do an
324  // _unchecked_narrow, this was needed to prevent an exception
325  // when dealing with ImR-ified objects
326  OpenDDS::DCPS::DCPSInfo_var info_repo =
327  OpenDDS::DCPS::DCPSInfo::_unchecked_narrow(obj);
328 
329  CORBA::String_var objref_str =
330  orb_->object_to_string(info_repo);
331 
332  // Initialize the DomainParticipantFactory
333  DDS::DomainParticipantFactory_var dpf =
334  TheParticipantFactoryWithArgs(argc, args.argv());
335 
336  // We need parse the command line options for DCPSInfoRepo after parsing DCPS specific
337  // command line options.
338 
339  // Check the non-ORB arguments.
340  this->parse_args(argc, args.argv());
341 
342  // Activate the POA manager before initialize built-in-topics
343  // so invocations can be processed.
344  poa_manager->activate();
345 
346  if (this->use_bits_) {
347  if (this->info_servant_->init_transport(this->listen_address_given_,
348  this->listen_address_str_.c_str())
349  != 0 /* init_transport returns 0 for success */) {
350  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPSInfoRepo::init: ")
351  ACE_TEXT("Unable to initialize transport.\n")));
352  throw InitError("Unable to initialize transport.");
353  }
354 
355  } else {
356  TheServiceParticipant->set_BIT(false);
357  }
358 
359  // This needs to be done after initialization since we create the reference
360  // to ourselves in the service here.
363 
364  OpenDDS::DCPS::Discovery_rch disc = serv_part->get_discovery(0 /*domainId*/);
367  if (!ird->set_ORB(orb_)) {
368  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPSInfoRepo::init: ")
369  ACE_TEXT("Unable to set the ORB in InfoRepoDiscovery.\n")));
370  throw InitError("Unable to set the ORB in InfoRepoDiscovery.");
371  }
372 
373  // Initialize persistence _after_ initializing the participant factory
374  // and initializing the transport.
375  if (!this->info_servant_->init_persistence()) {
376  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPSInfoRepo::init: ")
377  ACE_TEXT("Unable to initialize persistence.\n")));
378  throw InitError("Unable to initialize persistence.");
379  }
380 
381  // Initialize reassociation.
383  !this->info_servant_->init_reassociation(this->reassociate_delay_)) {
384  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPSInfoRepo::init: ")
385  ACE_TEXT("Unable to initialize reassociation.\n")));
386  throw InitError("Unable to initialize reassociation.");
387  }
388 
389  // Initialize dispatch checking
391  !this->info_servant_->init_dispatchChecking(this->dispatch_cleanup_delay_)) {
392  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPSInfoRepo::init: ")
393  ACE_TEXT("Unable to initialize Dispatch checking.\n")));
394  throw InitError("Unable to initialize dispatch checking.");
395  }
396 
397  // Fire up the federator.
398  OpenDDS::Federator::Manager_var federator;
399  CORBA::String_var federator_ior;
400 
401  if (federator_.id().overridden()) {
402  oid = PortableServer::string_to_ObjectId("Federator");
403  info_poa->activate_object_with_id(oid, &federator_);
404  obj = info_poa->id_to_reference(oid);
405  federator = OpenDDS::Federator::Manager::_narrow(obj);
406 
407  federator_ior = orb_->object_to_string(federator);
408 
409  // Add a local repository reference that can be returned via a
410  // remote call to a peer.
411  this->federator_.localRepo(info_repo);
412 
413  // It should be safe to initialize the federation mechanism at this
414  // point. What we really needed to wait for is the initialization of
415  // the service components - like the DomainParticipantFactory and the
416  // repository bindings.
417  // N.B. This is done *before* being added to the IOR table to avoid any
418  // races with an eager client.
419  this->federator_.orb(this->orb_);
420 
421  //
422  // Add the federator to the info_servant update manager as an
423  // additional updater interface to be called.
424  // N.B. This needs to be done *after* the call to load_domains()
425  // since that is where the update manager is initialized in the
426  // info startup sequencing.
427  this->info_servant_->add(&this->federator_);
428  }
429 
430  // Grab the IOR table.
431  CORBA::Object_var table_object =
432  this->orb_->resolve_initial_references("IORTable");
433 
434  IORTable::Table_var adapter = IORTable::Table::_narrow(table_object);
435 
436  if (CORBA::is_nil(adapter)) {
437  ACE_ERROR((LM_ERROR, ACE_TEXT("Nil IORTable\n")));
438 
439  } else {
440  adapter->bind(OpenDDS::Federator::REPOSITORY_IORTABLE_KEY, objref_str);
441 
442  if (this->federator_.id().overridden()) {
443  // Bind to '/Federator'
444  adapter->bind(OpenDDS::Federator::FEDERATOR_IORTABLE_KEY, federator_ior);
445 
446  // Bind to '/Federator/1382379631'
447  std::stringstream buffer(OpenDDS::Federator::FEDERATOR_IORTABLE_KEY);
448  buffer << "/" << std::dec << this->federatorConfig_.federationDomain();
449  adapter->bind(buffer.str().c_str(), federator_ior);
450  }
451  }
452 
453  FILE* output_file = ACE_OS::fopen(this->ior_file_.c_str(), ACE_TEXT("w"));
454 
455  if (output_file == 0) {
456  ACE_ERROR((LM_ERROR, ACE_TEXT("ERROR: Unable to open IOR file: %s\n"),
457  ior_file_.c_str()));
458  throw InitError("Unable to open IOR file.");
459  }
460 
461  ACE_OS::fprintf(output_file, "%s", objref_str.in());
462  ACE_OS::fclose(output_file);
463 
464  // Initial federation join if specified on command line.
465  if (this->federator_.id().overridden()
466  && !this->federatorConfig_.federateIor().empty()) {
468  ACE_DEBUG((LM_DEBUG,
469  ACE_TEXT("(%P|%t) INFO: DCPSInfoRepo::init() - ")
470  ACE_TEXT("joining federation with repository %s\n"),
471  this->federatorConfig_.federateIor().c_str()));
472  }
473 
474  obj = this->orb_->string_to_object(
475  this->federatorConfig_.federateIor().c_str());
476 
477  if (CORBA::is_nil(obj)) {
478  ACE_ERROR((LM_ERROR,
479  ACE_TEXT("(%P|%t) ERROR: could not resolve %s for initial federation.\n"),
480  this->federatorConfig_.federateIor().c_str()));
481  throw InitError("Unable to resolve IOR for initial federation.");
482  }
483 
484  OpenDDS::Federator::Manager_var peer =
485  OpenDDS::Federator::Manager::_narrow(obj);
486 
487  if (CORBA::is_nil(peer)) {
488  ACE_ERROR((LM_ERROR,
489  ACE_TEXT("(%P|%t) ERROR: could not narrow %s.\n"),
490  this->federatorConfig_.federateIor().c_str()));
491  throw InitError("Unable to narrow peer for initial federation.");
492  }
493 
494  // Actually join.
495  peer = peer->join_federation(federator,
497  }
498 }
void add(Update::Updater *updater)
Add an additional Updater interface.
#define ACE_DEBUG(X)
int fclose(FILE *fp)
Discovery_rch get_discovery(const DDS::DomainId_t domain)
Accessor of the Discovery object for a given domain.
#define ACE_ERROR(X)
const char * c_str(void) const
const string FEDERATOR_IORTABLE_KEY
Definition: Federator.idl:242
RcHandle< T > static_rchandle_cast(const RcHandle< U > &h)
Definition: RcHandle_T.h:202
ACE_Time_Value dispatch_cleanup_delay_
bool set_repo_ior(const char *ior, Discovery::RepoKey key=Discovery::DEFAULT_REPO, bool attach_participant=true)
CORBA::OctetSeq_var ObjectId_var
PortableServer::Servant_var< TAO_DDS_DCPSInfo_i > info_servant_
PortableServer::ObjectId * string_to_ObjectId(const char *string)
FILE * fopen(const char *filename, const char *mode)
ACE_TCHAR **& argv()
Access the enhanced argc.
void parse_args(int argc, ACE_TCHAR *argv[])
const TAO_DDS_DCPSFederationId & id() const
Accessors for the federation Id value.
CORBA::ORB_ptr orb()
Accessors for the ORB.
ACE_CDR::ULong ULong
OpenDDS::Federator::ManagerImpl federator_
Discovery Strategy class that implements InfoRepo discovery.
char ACE_TCHAR
bool init_dispatchChecking(const ACE_Time_Value &delay)
CORBA::ORB_var orb_
void localRepo(::OpenDDS::DCPS::DCPSInfo_ptr repo)
Capture a remote callable reference to the DCPSInfo.
int argc(void) const
ACE_Time_Value reassociate_delay_
static const char * DEFAULT_REPO
Key value for the default repository IOR.
Definition: Discovery.h:85
sequence< Policy > PolicyList
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
int strcmp(const char *s, const char *t)
ACE_TEXT("TCP_Factory")
int atoi(const char *s)
CHAR_TYPE ** argv(void)
void federationDomain(long domain)
Federation Id value.
OpenDDS::Federator::Config federatorConfig_
Repository Federation behaviors.
static const ACE_Time_Value zero
const string REPOSITORY_IORTABLE_KEY
Definition: Federator.idl:241
const character_type * in(void) const
int init_transport(int listen_address_given, const char *listen_str)
#define TheServiceParticipant
int fprintf(FILE *fp, const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
Implementation of the DCPSInfo.
Definition: DCPSInfo_i.h:53
ACE_TString ior_file_
bool init_reassociation(const ACE_Time_Value &delay)
Boolean is_nil(T x)
int add(const CHAR_TYPE *next_arg, bool quote_arg=false)
void federateIor(const tstring &ior)
Initial federation IOR value.
#define TheParticipantFactoryWithArgs(argc, argv)

◆ parse_args()

void InfoRepo::parse_args ( int  argc,
ACE_TCHAR argv[] 
)
private

Definition at line 193 of file DCPSInfoRepoServ.cpp.

References ACE_TEXT(), ACE_TEXT_ALWAYS_CHAR, ACE_OS::atoi(), ACE_Arg_Shifter_T< class >::consume_arg(), ACE_Arg_Shifter_T< class >::cur_arg_strncasecmp(), dispatch_cleanup_delay_, ACE_Arg_Shifter_T< class >::get_the_parameter(), ACE_Arg_Shifter_T< class >::ignore_arg(), ior_file_, ACE_Arg_Shifter_T< class >::is_anything_left(), listen_address_given_, listen_address_str_, ACE_Time_Value::msec(), reassociate_delay_, resurrect_, ACE_Time_Value::sec(), TURN_ON_VERBOSE_DEBUG, usage(), and use_bits_.

Referenced by init().

194 {
195  ACE_Arg_Shifter arg_shifter(argc, argv);
196 
197  const ACE_TCHAR* current_arg = 0;
198 
199  while (arg_shifter.is_anything_left()) {
200  if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-a"))) != 0) {
201  this->listen_address_str_ = ACE_TEXT_ALWAYS_CHAR(current_arg);
202  this->listen_address_given_ = 1;
203  arg_shifter.consume_arg();
204  // Must check for -ReassociateDelay before -r
205  } else if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-ReassociateDelay"))) != 0) {
206  long msec = ACE_OS::atoi(current_arg);
207  this->reassociate_delay_.msec(msec);
208 
209  arg_shifter.consume_arg();
210  } else if ((current_arg = arg_shifter.get_the_parameter
211  (ACE_TEXT("-r"))) != 0) {
212  int p = ACE_OS::atoi(current_arg);
213  this->resurrect_ = true;
214 
215  if (p == 0) {
216  this->resurrect_ = false;
217  }
218 
219  arg_shifter.consume_arg();
220 
221  } else if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-o"))) != 0) {
222  this->ior_file_ = current_arg;
223  arg_shifter.consume_arg();
224 
225  } else if (arg_shifter.cur_arg_strncasecmp(ACE_TEXT("-NOBITS")) == 0) {
226  this->use_bits_ = false;
227  arg_shifter.consume_arg();
228 
229  } else if (arg_shifter.cur_arg_strncasecmp(ACE_TEXT("-z")) == 0) {
231  arg_shifter.consume_arg();
232 
233  } else if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-DispatchingCheckDelay"))) != 0) {
234  long sec = ACE_OS::atoi(current_arg);
235  this->dispatch_cleanup_delay_.sec(sec);
236  arg_shifter.consume_arg();
237 
238  }
239 
240  // The '-?' option
241  else if (arg_shifter.cur_arg_strncasecmp(ACE_TEXT("-?")) == 0) {
242  this->usage(argv[0]);
243  throw InitError("Usage");
244  }
245 
246  // Anything else we just skip
247 
248  else {
249  arg_shifter.ignore_arg();
250  }
251  }
252 }
std::string listen_address_str_
int listen_address_given_
ACE_Time_Value dispatch_cleanup_delay_
#define ACE_TEXT_ALWAYS_CHAR(STRING)
char ACE_TCHAR
void usage(const ACE_TCHAR *cmd)
ACE_Time_Value reassociate_delay_
time_t sec(void) const
ACE_TEXT("TCP_Factory")
int atoi(const char *s)
unsigned long msec(void) const
#define TURN_ON_VERBOSE_DEBUG
ACE_TString ior_file_

◆ run()

void InfoRepo::run ( void  )

Definition at line 76 of file DCPSInfoRepoServ.cpp.

References ACE_GUARD, cond_, finalize(), lock_, orb_, shutdown_complete_, and ACE_Condition< ACE_Thread_Mutex >::signal().

Referenced by ACE_TMAIN().

77 {
78  this->shutdown_complete_ = false;
79  this->orb_->run();
80  this->finalize();
81  ACE_GUARD(ACE_Thread_Mutex, g, this->lock_);
82  this->shutdown_complete_ = true;
83  this->cond_.signal();
84 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
ACE_Condition_Thread_Mutex cond_
CORBA::ORB_var orb_
ACE_Thread_Mutex lock_
bool shutdown_complete_
void finalize()
Actual finalization of service resources.

◆ set_shutdown_signal()

void InfoRepo::set_shutdown_signal ( int  which_signal)

Definition at line 146 of file DCPSInfoRepoServ.cpp.

References shutdown_signal_.

Referenced by InfoRepo_Shutdown::operator()().

147 {
148  shutdown_signal_ = which_signal;
149 }
int shutdown_signal_

◆ shutdown()

void InfoRepo::shutdown ( void  )
virtual

ShutdownInterface used to schedule a shutdown.

Implements ShutdownInterface.

Definition at line 152 of file DCPSInfoRepoServ.cpp.

References orb_.

Referenced by InfoRepo_Shutdown::operator()(), and sync_shutdown().

153 {
154  this->orb_->orb_core()->reactor()->notify(this);
155  // reactor will invoke our InfoRepo::handle_exception()
156 }
CORBA::ORB_var orb_

◆ sync_shutdown()

void InfoRepo::sync_shutdown ( )

shutdown() and wait for it to complete: cannot be called from the reactor thread.

Definition at line 159 of file DCPSInfoRepoServ.cpp.

References ACE_GUARD, cond_, lock_, shutdown(), shutdown_complete_, and ACE_Condition< ACE_Thread_Mutex >::wait().

160 {
161  this->shutdown();
162  ACE_GUARD(ACE_Thread_Mutex, g, this->lock_);
163 
164  while (!this->shutdown_complete_) {
165  this->cond_.wait();
166  }
167 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
ACE_Condition_Thread_Mutex cond_
virtual void shutdown()
ShutdownInterface used to schedule a shutdown.
int wait(const ACE_Time_Value *abstime)
ACE_Thread_Mutex lock_
bool shutdown_complete_

◆ usage()

void InfoRepo::usage ( const ACE_TCHAR cmd)
private

Definition at line 170 of file DCPSInfoRepoServ.cpp.

References ACE_DEBUG, ACE_TEXT(), and LM_INFO.

Referenced by parse_args().

171 {
172  // NOTE: The federation arguments are parsed early by the
173  // FederationConfig object.
174  ACE_DEBUG((LM_INFO,
175  ACE_TEXT("Usage:\n")
176  ACE_TEXT(" %s\n")
177  ACE_TEXT(" -a <address> listening address for Built-In Topics\n")
178  ACE_TEXT(" -o <file> write ior to file\n")
179  ACE_TEXT(" -NOBITS disable the Built-In Topics\n")
180  ACE_TEXT(" -z turn on verbose Transport logging\n")
181  ACE_TEXT(" -r Resurrect from persistent file\n")
182  ACE_TEXT(" -FederatorConfig <file> configure federation from <file>\n")
183  ACE_TEXT(" -FederationId <number> value for this repository\n")
184  ACE_TEXT(" -FederateWith <ior> federate initially with object at <ior>\n")
185  ACE_TEXT(" -ReassociateDelay <msec> delay between reassociations\n")
186  ACE_TEXT(" -DispatchingCheckDelay <sec> delay between checks for cleaning up dispatching connections.\n")
187  ACE_TEXT(" -?\n")
188  ACE_TEXT("\n"),
189  cmd));
190 }
#define ACE_DEBUG(X)
ACE_TEXT("TCP_Factory")

Member Data Documentation

◆ cond_

ACE_Condition_Thread_Mutex InfoRepo::cond_
private

Definition at line 78 of file DCPSInfoRepoServ.h.

Referenced by run(), and sync_shutdown().

◆ dispatch_cleanup_delay_

ACE_Time_Value InfoRepo::dispatch_cleanup_delay_
private

Definition at line 83 of file DCPSInfoRepoServ.h.

Referenced by init(), and parse_args().

◆ federator_

OpenDDS::Federator::ManagerImpl InfoRepo::federator_
private

Definition at line 73 of file DCPSInfoRepoServ.h.

Referenced by finalize(), handle_exception(), and init().

◆ federatorConfig_

OpenDDS::Federator::Config InfoRepo::federatorConfig_
private

Repository Federation behaviors.

Definition at line 72 of file DCPSInfoRepoServ.h.

Referenced by init().

◆ finalized_

bool InfoRepo::finalized_
private

Flag to indicate that finalization has already occurred.

Definition at line 68 of file DCPSInfoRepoServ.h.

Referenced by finalize().

◆ info_servant_

PortableServer::Servant_var<TAO_DDS_DCPSInfo_i> InfoRepo::info_servant_
private

Definition at line 75 of file DCPSInfoRepoServ.h.

Referenced by finalize(), handle_exception(), and init().

◆ ior_file_

ACE_TString InfoRepo::ior_file_
private

Definition at line 60 of file DCPSInfoRepoServ.h.

Referenced by init(), and parse_args().

◆ listen_address_given_

int InfoRepo::listen_address_given_
private

Definition at line 62 of file DCPSInfoRepoServ.h.

Referenced by parse_args().

◆ listen_address_str_

std::string InfoRepo::listen_address_str_
private

Definition at line 61 of file DCPSInfoRepoServ.h.

Referenced by parse_args().

◆ lock_

ACE_Thread_Mutex InfoRepo::lock_
private

Definition at line 77 of file DCPSInfoRepoServ.h.

Referenced by run(), and sync_shutdown().

◆ orb_

CORBA::ORB_var InfoRepo::orb_
private

Definition at line 58 of file DCPSInfoRepoServ.h.

Referenced by finalize(), handle_exception(), init(), run(), and shutdown().

◆ reassociate_delay_

ACE_Time_Value InfoRepo::reassociate_delay_
private

Definition at line 65 of file DCPSInfoRepoServ.h.

Referenced by init(), and parse_args().

◆ resurrect_

bool InfoRepo::resurrect_
private

Definition at line 64 of file DCPSInfoRepoServ.h.

Referenced by init(), and parse_args().

◆ servant_finalized_

bool InfoRepo::servant_finalized_
private

Definition at line 69 of file DCPSInfoRepoServ.h.

Referenced by finalize(), and handle_exception().

◆ shutdown_complete_

bool InfoRepo::shutdown_complete_
private

Definition at line 79 of file DCPSInfoRepoServ.h.

Referenced by run(), and sync_shutdown().

◆ shutdown_signal_

int InfoRepo::shutdown_signal_
private

Definition at line 81 of file DCPSInfoRepoServ.h.

Referenced by handle_exception(), and set_shutdown_signal().

◆ use_bits_

bool InfoRepo::use_bits_
private

Definition at line 63 of file DCPSInfoRepoServ.h.

Referenced by init(), and parse_args().


The documentation for this class was generated from the following files: