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 namespace OpenDDS {
00015 namespace DCPS {
00016 
00017 TransportMonitorImpl::TransportReportVec TransportMonitorImpl::queue_;
00018 ACE_Recursive_Thread_Mutex TransportMonitorImpl::queue_lock_;
00019 
00020 TransportMonitorImpl::TransportMonitorImpl(TransportImpl* /*transport*/,
00021               OpenDDS::DCPS::TransportReportDataWriter_ptr transport_writer)
00022   : transport_writer_(TransportReportDataWriter::_duplicate(transport_writer))
00023 {
00024   char host[256];
00025   ACE_OS::hostname(host, 256);
00026   hostname_ = host;
00027   pid_  = ACE_OS::getpid();
00028 }
00029 
00030 TransportMonitorImpl::~TransportMonitorImpl()
00031 {
00032 }
00033 
00034 void
00035 TransportMonitorImpl::report() {
00036   // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report()\n"));
00037   TransportReport report;
00038   report.host = this->hostname_.c_str();
00039   report.pid  = this->pid_;
00040   // TODO: remove/replace
00041   report.transport_id  = 0;
00042   report.transport_type = "";
00043   // ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, queue_lock_);
00044   if (!CORBA::is_nil(this->transport_writer_.in())) {
00045     if (this->queue_.size()) {
00046       // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): popping\n"));
00047       for (unsigned int i = 0; i < this->queue_.size(); i++) {
00048         // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
00049         //                      this->queue_[i].transport_id));
00050         this->transport_writer_->write(this->queue_[i], DDS::HANDLE_NIL);
00051       }
00052       this->queue_.clear();
00053     }
00054     // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): writing, id = %d\n",
00055     //                      report.transport_id));
00056     this->transport_writer_->write(report, DDS::HANDLE_NIL);
00057   } else {
00058     // ACE_DEBUG((LM_DEBUG, "TransportMonitorImpl::report(): queueing, id = %d\n",
00059     //                      report.transport_id));
00060     queue_.push_back(report);
00061   }
00062 }
00063 
00064 
00065 } // namespace DCPS
00066 } // namespace OpenDDS
00067 

Generated on Fri Feb 12 20:05:28 2016 for OpenDDS by  doxygen 1.4.7