TransportMonitorImpl.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "TransportMonitorImpl.h"
00009 #include "monitorC.h"
00010 #include "monitorTypeSupportImpl.h"
00011 #include "dds/DCPS/transport/framework/TransportImpl.h"
00012 #include <dds/DdsDcpsInfrastructureC.h>
00013 
00014 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 namespace OpenDDS {
00017 namespace DCPS {
00018 
00019 TransportMonitorImpl::TransportReportVec TransportMonitorImpl::queue_;
00020 ACE_Recursive_Thread_Mutex TransportMonitorImpl::queue_lock_;
00021 
00022 TransportMonitorImpl::TransportMonitorImpl(TransportImpl* /*transport*/,
00023               OpenDDS::DCPS::TransportReportDataWriter_ptr transport_writer)
00024   : transport_writer_(TransportReportDataWriter::_duplicate(transport_writer))
00025 {
00026   char host[256];
00027   ACE_OS::hostname(host, 256);
00028   hostname_ = host;
00029   pid_  = ACE_OS::getpid();
00030 }
00031 
00032 TransportMonitorImpl::~TransportMonitorImpl()
00033 {
00034 }
00035 
00036 void
00037 TransportMonitorImpl::report() {
00038   // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report()\n"));
00039   TransportReport report;
00040   report.host = this->hostname_.c_str();
00041   report.pid  = this->pid_;
00042   // TODO: remove/replace
00043   report.transport_id  = 0;
00044   report.transport_type = "";
00045   // ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, queue_lock_);
00046   if (!CORBA::is_nil(this->transport_writer_.in())) {
00047     if (this->queue_.size()) {
00048       // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): popping\n"));
00049       for (unsigned int i = 0; i < this->queue_.size(); i++) {
00050         // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
00051         //                      this->queue_[i].transport_id));
00052         this->transport_writer_->write(this->queue_[i], DDS::HANDLE_NIL);
00053       }
00054       this->queue_.clear();
00055     }
00056     // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
00057     //                      report.transport_id));
00058     this->transport_writer_->write(report, DDS::HANDLE_NIL);
00059   } else {
00060     // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): queueing, id = %d\n",
00061     //                      report.transport_id));
00062     queue_.push_back(report);
00063   }
00064 }
00065 
00066 
00067 } // namespace DCPS
00068 } // namespace OpenDDS
00069 
00070 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1