[mapguide-commits] r4960 - in sandbox/adsk/2.2gp/Server/src: Common/Manager Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jun 17 14:08:13 EDT 2010


Author: brucedechant
Date: 2010-06-17 18:08:13 +0000 (Thu, 17 Jun 2010)
New Revision: 4960

Modified:
   sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.cpp
   sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.h
   sandbox/adsk/2.2gp/Server/src/Core/OperationThread.cpp
Log:
Fix for trac ticket 1354 - GetSiteInfo is returning bad values for AverageOperationTime and TotalOperationTime
http://trac.osgeo.org/mapguide/ticket/1354

Notes:
- Updated to use INT64 instead of INT32
- Fixed OperationThread recording incorrect timings
- Corrected average operation time calculation


Modified: sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.cpp
===================================================================
--- sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.cpp	2010-06-17 17:58:45 UTC (rev 4959)
+++ sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.cpp	2010-06-17 18:08:13 UTC (rev 4960)
@@ -454,7 +454,7 @@
     pProperties->Add(pProperty);
 
     // Add the Uptime
-    time_t nUptime = GetUptime();
+    INT64 nUptime = GetUptime();
     pProperty = new MgInt64Property(MgServerInformationProperties::Uptime, nUptime);
     pProperties->Add(pProperty);
 
@@ -479,12 +479,13 @@
     pProperties->Add(pProperty);
 
     // Add the TotalOperationTime
-    time_t nTotalOperationTime = GetTotalOperationTime();
+    // This value needs to be returned in seconds according to the schema
+    INT64 nTotalOperationTime = GetTotalOperationTime() / 1000;
     pProperty = new MgInt64Property(MgServerInformationProperties::TotalOperationTime, nTotalOperationTime);
     pProperties->Add(pProperty);
 
     // Add the AverageOperationTime
-    time_t nAverageOperationTime = GetAverageOperationTime();
+    INT64 nAverageOperationTime = GetAverageOperationTime();
     pProperty = new MgInt64Property(MgServerInformationProperties::AverageOperationTime, nAverageOperationTime);
     pProperties->Add(pProperty);
 
@@ -871,12 +872,12 @@
     return m_totalProcessedOperations.value();
 }
 
-time_t MgServerManager::GetTotalOperationTime()
+INT64 MgServerManager::GetTotalOperationTime()
 {
     return m_totalOperationTime.value();
 }
 
-void MgServerManager::IncrementOperationTime(time_t operationTime)
+void MgServerManager::IncrementOperationTime(INT64 operationTime)
 {
     m_totalOperationTime += operationTime;
 }
@@ -1187,7 +1188,7 @@
 ///
 /// EXCEPTIONS:
 /// MgConnectionNotOpenException
-time_t MgServerManager::GetUptime()
+INT64 MgServerManager::GetUptime()
 {
     ACE_Time_Value upTime(0);
 
@@ -1197,7 +1198,7 @@
 
     MG_CATCH_AND_THROW(L"MgServerManager.GetUptime");
 
-    return upTime.sec();
+    return (INT64)upTime.sec();
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
@@ -1210,7 +1211,7 @@
 ///
 /// EXCEPTIONS:
 /// MgConnectionNotOpenException
-time_t MgServerManager::GetAverageOperationTime()
+INT64 MgServerManager::GetAverageOperationTime()
 {
     double avgTime = 0.0;
 
@@ -1218,13 +1219,13 @@
 
     if (GetTotalProcessedOperations() > 0)
     {
-        avgTime = ((double)(GetTotalOperationTime()) * 1000.0) / (double)(GetTotalProcessedOperations());
+        avgTime = ((double)(GetTotalOperationTime())) / (double)(GetTotalProcessedOperations());
     }
 
 
     MG_CATCH_AND_THROW(L"MgServerManager.GetAverageOperationTime")
 
-    return time_t(avgTime);
+    return (INT64)avgTime;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////

Modified: sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.h
===================================================================
--- sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.h	2010-06-17 17:58:45 UTC (rev 4959)
+++ sandbox/adsk/2.2gp/Server/src/Common/Manager/ServerManager.h	2010-06-17 18:08:13 UTC (rev 4960)
@@ -36,7 +36,7 @@
 class MgWorkerThread;
 
 typedef ACE_Atomic_Op<ACE_Thread_Mutex, INT32>  SAFE_INT32;
-typedef ACE_Atomic_Op<ACE_Thread_Mutex, time_t>  SAFE_TIME_T;
+typedef ACE_Atomic_Op<ACE_Thread_Mutex, INT64>  SAFE_INT64;
 
 class MG_SERVER_MANAGER_API MgServerManager : public MgGuardDisposable
 {
@@ -100,9 +100,9 @@
     ACE_Time_Value GetStartTime();
     INT32 GetTotalReceivedOperations();
     INT32 GetTotalProcessedOperations();
-    time_t GetTotalOperationTime();
+    INT64 GetTotalOperationTime();
 
-    void IncrementOperationTime(time_t operationTime);
+    void IncrementOperationTime(INT64 operationTime);
     void IncrementReceivedOperations();
     void IncrementProcessedOperations();
 
@@ -117,8 +117,8 @@
     INT32 GetClientOperationsQueueCount();
     INT32 GetSiteOperationsQueueCount();
 
-    time_t GetUptime();
-    time_t GetAverageOperationTime();
+    INT64 GetUptime();
+    INT64 GetAverageOperationTime();
 
     INT64 GetTotalPhysicalMemory();
     INT64 GetAvailablePhysicalMemory();
@@ -176,7 +176,7 @@
     INT32 m_nSiteThreads;
 
     ACE_Time_Value m_startTime;
-    SAFE_TIME_T m_totalOperationTime;        // This value is tracked in seconds
+    SAFE_INT64 m_totalOperationTime;        // This value is tracked in milliseconds
     SAFE_INT32 m_totalReceivedOperations;
     SAFE_INT32 m_totalProcessedOperations;
 

Modified: sandbox/adsk/2.2gp/Server/src/Core/OperationThread.cpp
===================================================================
--- sandbox/adsk/2.2gp/Server/src/Core/OperationThread.cpp	2010-06-17 17:58:45 UTC (rev 4959)
+++ sandbox/adsk/2.2gp/Server/src/Core/OperationThread.cpp	2010-06-17 18:08:13 UTC (rev 4960)
@@ -309,7 +309,8 @@
     MG_TRY()
 
     {
-        ACE_Time_Value operationTime(0);
+        ACE_Time_Value operationStartTime(0);
+        operationStartTime = ACE_OS::gettimeofday();
         ACE_ASSERT( pData );
         if ( pData )
         {
@@ -396,6 +397,8 @@
                     stat = pServiceHandler->ProcessOperation();
 
                     m_timer.stop();
+                    ACE_Time_Value operationTime(0);
+                    operationTime = ACE_OS::gettimeofday() - operationStartTime;
                     m_timer.elapsed_time(operationTime);
 
                     delete pServiceHandler;
@@ -408,8 +411,11 @@
             // We increment operations processed for successful operations only.
             if (IMgServiceHandler::mpsDone == stat)
             {
-                time_t opTime = operationTime.sec();
+                ACE_Time_Value operationTime(0);
+                operationTime = ACE_OS::gettimeofday() - operationStartTime;
 
+                unsigned long opTime = operationTime.msec();
+
                 pConnection->IncrementProcessedOperations();
                 pConnection->SetCurrentOperationTime(opTime);
 



More information about the mapguide-commits mailing list