Renamed PingAnalyzer to HostStatusAnalyzer
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Fri, 25 Mar 2011 15:58:20 +0000 (16:58 +0100)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 28 Mar 2011 09:50:30 +0000 (11:50 +0200)
- this describes better what the class is suppode to do, analyze the status of the host, using the pings.

src/CMakeLists.txt
src/ping/hoststatusanalyzer.cpp [moved from src/ping/pinganalyzer.cpp with 70% similarity]
src/ping/hoststatusanalyzer.h [moved from src/ping/pinganalyzer.h with 76% similarity]
src/ping/pingscheduler.h

index d63f58f..fa0d756 100644 (file)
@@ -30,7 +30,7 @@ set(SOURCES
     notify/statusnotifier.cpp
     notify/statusnotifiercommand.cpp
     ping/boostpinger.cpp
-    ping/pinganalyzer.cpp
+    ping/hoststatusanalyzer.cpp
     ping/pingscheduler.cpp
     main.cpp
 )
similarity index 70%
rename from src/ping/pinganalyzer.cpp
rename to src/ping/hoststatusanalyzer.cpp
index b72d4c1..47118ea 100644 (file)
@@ -1,4 +1,4 @@
-#include "ping/pinganalyzer.h"
+#include "ping/hoststatusanalyzer.h"
 
 #include <iostream>
 
@@ -10,10 +10,16 @@ using namespace std;
 using namespace boost;
 
 //-----------------------------------------------------------------------------
-// PingAnalyzer
+// HostStatusAnalyzer
 //-----------------------------------------------------------------------------
 
-PingAnalyzer::PingAnalyzer(
+/**
+ * @param host_address the address of the host it has to analyze.
+ * @param ping_fail_percentage_limit the percentage threshold of pings that can
+ * fail.
+ * @param notifier the object used to notify the status of the host.
+ */
+HostStatusAnalyzer::HostStatusAnalyzer(
         const string &host_address,
         const int ping_fail_percentage_limit,
         shared_ptr<StatusNotifier> notifier
@@ -30,23 +36,34 @@ PingAnalyzer::PingAnalyzer(
     BOOST_ASSERT( ( 0 <= PingFailPercentageLimit ) && ( PingFailPercentageLimit <= 100 ) );
 }
 
-PingAnalyzer::~PingAnalyzer()
+HostStatusAnalyzer::~HostStatusAnalyzer()
 {
 }
 
-void PingAnalyzer::set_resolved_ip_count( const int resolved_ip_count )
+/**
+ * @param resolved_ip_count the number of IPs resolved for the host.
+ */
+void HostStatusAnalyzer::set_resolved_ip_count( const int resolved_ip_count )
 {
     BOOST_ASSERT( 1 <= resolved_ip_count );
 
     ResolvedIpCount = resolved_ip_count;
 }
 
-bool PingAnalyzer::exceeded_ping_failed_limit() const
+/**
+ * @return true if the amount of failed pings given to the host exceeded the
+ * limit.
+ */
+bool HostStatusAnalyzer::exceeded_ping_failed_limit() const
 {
     return ExceededPingFailedLimit;
 }
 
-void PingAnalyzer::update_ping_statistics( bool ping_success )
+/**
+ * Adds a ping status (success or failure).
+ * @param ping_success
+ */
+void HostStatusAnalyzer::update_ping_statistics( bool ping_success )
 {
     BOOST_ASSERT( 1 <= ResolvedIpCount );
     BOOST_ASSERT( 0 <= PingsPerformedCount );
@@ -71,14 +88,14 @@ void PingAnalyzer::update_ping_statistics( bool ping_success )
     BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount );
 }
 
-bool PingAnalyzer::tried_all_resolved_ip() const
+bool HostStatusAnalyzer::tried_all_resolved_ip() const
 {
     BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) );
 
     return ( PingsPerformedCount == ResolvedIpCount );
 }
 
-void PingAnalyzer::analyze_ping_statistics()
+void HostStatusAnalyzer::analyze_ping_statistics()
 {
     BOOST_ASSERT( !HostAddress.empty() );
     BOOST_ASSERT( PingsPerformedCount == ResolvedIpCount );
@@ -95,20 +112,20 @@ void PingAnalyzer::analyze_ping_statistics()
 
 }
 
-void PingAnalyzer::reset_ping_counters()
+void HostStatusAnalyzer::reset_ping_counters()
 {
     PingsPerformedCount = 0;
     PingsFailedCount = 0;
 }
 
-void PingAnalyzer::increase_ping_performed_count()
+void HostStatusAnalyzer::increase_ping_performed_count()
 {
     ++PingsPerformedCount;
 
     BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) );
 }
 
-void PingAnalyzer::increase_ping_failed_count()
+void HostStatusAnalyzer::increase_ping_failed_count()
 {
     ++PingsFailedCount;
 
@@ -117,7 +134,7 @@ void PingAnalyzer::increase_ping_failed_count()
     BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
 }
 
-void PingAnalyzer::analyze_ping_failed_count()
+void HostStatusAnalyzer::analyze_ping_failed_count()
 {
     BOOST_ASSERT( ( 0 <= PingFailPercentageLimit ) && ( PingFailPercentageLimit <= 100 ) );
     BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
similarity index 76%
rename from src/ping/pinganalyzer.h
rename to src/ping/hoststatusanalyzer.h
index 6f89620..c46cea6 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef PINGANALYZER_H
-#define PINGANALYZER_H
+#ifndef HOSTSTATUSANALYZER_H
+#define HOSTSTATUSANALYZER_H
 
 #include <string>
 
@@ -8,23 +8,23 @@
 class StatusNotifier;
 
 //-----------------------------------------------------------------------------
-// PingAnalyzer
+// HostStatusAnalyzer
 //-----------------------------------------------------------------------------
 
 /**
- * @brief This class analyze the ping status (success or failure) and decides
- * what to do.
+ * @brief This class analyze the host status (up or down) based on the pings
+ * responses (success or failure). And notifies its status.
  * Scope: one object per host.
  */
-class PingAnalyzer
+class HostStatusAnalyzer
 {
 public:
-    PingAnalyzer(
+    HostStatusAnalyzer(
             const std::string &host_address,
             const int ping_fail_percentage_limit,
             boost::shared_ptr<StatusNotifier> notifier
     );
-    virtual ~PingAnalyzer();
+    virtual ~HostStatusAnalyzer();
 
     void set_resolved_ip_count( const int resolved_ip_count );
     bool exceeded_ping_failed_limit() const;
@@ -49,4 +49,4 @@ private:
 
 };
 
-#endif /* PINGANALYZER_H */
+#endif /* HOSTSTATUSANALYZER_H */
index a5b6683..bc0caed 100644 (file)
@@ -7,7 +7,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include "dns/dnsresolver.h"
-#include "ping/pinganalyzer.h"
+#include "ping/hoststatusanalyzer.h"
 #include "ping/pinginterval.h"
 
 class StatusNotifier;
@@ -51,7 +51,7 @@ private:
     boost::posix_time::ptime TimeSentLastPing;
     PingInterval<long> PingIntervalInSec;
     DnsResolver IpList;
-    PingAnalyzer Analyzer;
+    HostStatusAnalyzer Analyzer;
 
 };