OpenDDS  Snapshot(2023/04/28-20:55)
TransportMonitorImpl.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "TransportMonitorImpl.h"
9 #include "monitorC.h"
10 #include "monitorTypeSupportImpl.h"
12 #include <dds/DdsDcpsInfrastructureC.h>
13 
15 
16 namespace OpenDDS {
17 namespace DCPS {
18 
21 
23  OpenDDS::DCPS::TransportReportDataWriter_ptr transport_writer)
24  : transport_writer_(TransportReportDataWriter::_duplicate(transport_writer))
25 {
26  char host[256];
27  ACE_OS::hostname(host, 256);
28  hostname_ = host;
29  pid_ = ACE_OS::getpid();
30 }
31 
33 {
34 }
35 
36 void
38  // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report()\n"));
40  report.host = this->hostname_.c_str();
41  report.pid = this->pid_;
42  // TODO: remove/replace
43  report.transport_id = 0;
44  report.transport_type = "";
45  // ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, queue_lock_);
46  if (!CORBA::is_nil(this->transport_writer_.in())) {
47  if (this->queue_.size()) {
48  // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): popping\n"));
49  for (unsigned int i = 0; i < this->queue_.size(); i++) {
50  // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
51  // this->queue_[i].transport_id));
52  this->transport_writer_->write(this->queue_[i], DDS::HANDLE_NIL);
53  }
54  this->queue_.clear();
55  }
56  // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
57  // report.transport_id));
58  this->transport_writer_->write(report, DDS::HANDLE_NIL);
59  } else {
60  // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): queueing, id = %d\n",
61  // report.transport_id));
62  queue_.push_back(report);
63  }
64 }
65 
66 
67 } // namespace DCPS
68 } // namespace OpenDDS
69 
OpenDDS::DCPS::TransportReportDataWriter_var transport_writer_
std::vector< TransportReport > TransportReportVec
static ACE_Recursive_Thread_Mutex queue_lock_
const InstanceHandle_t HANDLE_NIL
key unsigned long transport_id
Definition: monitor.idl:187
T * _duplicate(T *st)
int hostname(char name[], size_t maxnamelen)
TransportMonitorImpl(TransportImpl *transport, OpenDDS::DCPS::TransportReportDataWriter_ptr transport_writer)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
pid_t getpid(void)
Boolean is_nil(T x)