[mapguide-commits] r1111 - in trunk/MgDev: Common/MapGuideCommon/System Server/src/Core Server/src/Services/Tile

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Feb 16 14:21:33 EST 2007


Author: stevedang
Date: 2007-02-16 14:21:33 -0500 (Fri, 16 Feb 2007)
New Revision: 1111

Modified:
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
   trunk/MgDev/Server/src/Core/serverconfig.ini
   trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp
   trunk/MgDev/Server/src/Services/Tile/ServerTileService.h
   trunk/MgDev/Server/src/Services/Tile/TileCache.cpp
   trunk/MgDev/Server/src/Services/Tile/TileCache.h
Log:
Stability - Miscellaneous code cleanups and fixes:
1.Fixed some threading problem when reading Tile Service configuration properties.
2.Updated to use correct default values when initializing some of Tile Service configuration properties.
3.Added missing comments on some of Tile Service configuration properties to server configuration file.
4.Some other cleanups (e.g. ordering Tile Service configuration properties so that they get validated more efficiently).


Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2007-02-16 19:21:33 UTC (rev 1111)
@@ -306,20 +306,20 @@
 // Tile Service Properties
 // ******************************************************************
 const STRING MgConfigProperties::TileServicePropertiesSection                               = L"TileServiceProperties";
+const STRING MgConfigProperties::TileServicePropertyRenderOnly                              = L"RenderOnly";
+const bool   MgConfigProperties::DefaultTileServicePropertyRenderOnly                       = false;
 const STRING MgConfigProperties::TileServicePropertyTileCachePath                           = L"TileCachePath";
 const STRING MgConfigProperties::DefaultTileServicePropertyTileCachePath                    = L"Repositories/TileCache/";
+const STRING MgConfigProperties::TileServicePropertyTileColumnsPerFolder                    = L"TileColumnsPerFolder";
+const INT32 MgConfigProperties::DefaultTileServicePropertyTileColumnsPerFolder              = 30;
+const STRING MgConfigProperties::TileServicePropertyTileRowsPerFolder                       = L"TileRowsPerFolder";
+const INT32 MgConfigProperties::DefaultTileServicePropertyTileRowsPerFolder                 = 30;
 const STRING MgConfigProperties::TileServicePropertyCreationCutoffTime                      = L"CreationCutoffTime";
 const INT32  MgConfigProperties::DefaultTileServicePropertyCreationCutoffTime               = 120;
 const STRING MgConfigProperties::TileServicePropertyPollingInterval                         = L"PollingInterval";
 const INT32  MgConfigProperties::DefaultTileServicePropertyPollingInterval                  = 1;
-const STRING MgConfigProperties::TileServicePropertyRenderOnly                              = L"RenderOnly";
-const bool   MgConfigProperties::DefaultTileServicePropertyRenderOnly                       = false;
 const STRING MgConfigProperties::TileServicePropertyTiledMapCacheSize                       = L"TiledMapCacheSize";
 const INT32  MgConfigProperties::DefaultTileServicePropertyTiledMapCacheSize                = 10;
-const STRING MgConfigProperties::TileServicePropertyTileRowsPerFolder                       = L"TileRowsPerFolder";
-const INT32 MgConfigProperties::DefaultTileServicePropertyTileRowsPerFolder                 = 30;
-const STRING MgConfigProperties::TileServicePropertyTileColumnsPerFolder                    = L"TileColumnsPerFolder";
-const INT32 MgConfigProperties::DefaultTileServicePropertyTileColumnsPerFolder              = 30;
 
 // ******************************************************************
 // Access Log Properties
@@ -548,12 +548,12 @@
 
 const MgConfigValidationInfo MgConfigProperties::sm_cviTileServiceProperties[] =
 {
+    { MgConfigProperties::TileServicePropertyRenderOnly                             , MgPropertyType::Boolean   , 0                                     , 1                                     , L""                                       },
     { MgConfigProperties::TileServicePropertyTileCachePath                          , MgPropertyType::String    , MG_CONFIG_MIN_PATH_LENGTH             , MG_CONFIG_MAX_PATH_LENGTH             , MG_CONFIG_PATH_RESERVED_CHARACTERS        },
+    { MgConfigProperties::TileServicePropertyTileColumnsPerFolder                   , MgPropertyType::Int32     , 1                                     , 1000                                  , L""                                       },
+    { MgConfigProperties::TileServicePropertyTileRowsPerFolder                      , MgPropertyType::Int32     , 1                                     , 1000                                  , L""                                       },
     { MgConfigProperties::TileServicePropertyCreationCutoffTime                     , MgPropertyType::Int32     , 1                                     , 600                                   , L""                                       },
-    { MgConfigProperties::TileServicePropertyTileRowsPerFolder                      , MgPropertyType::Int32     , 1                                     , 1000                                  , L""                                       },
-    { MgConfigProperties::TileServicePropertyTileColumnsPerFolder                   , MgPropertyType::Int32     , 1                                     , 1000                                  , L""                                       },
     { MgConfigProperties::TileServicePropertyPollingInterval                        , MgPropertyType::Int32     , 1                                     , 60                                    , L""                                       },
-    { MgConfigProperties::TileServicePropertyRenderOnly                             , MgPropertyType::Boolean   , 0                                     , 1                                     , L""                                       },
     { MgConfigProperties::TileServicePropertyTiledMapCacheSize                      , MgPropertyType::Int32     , MG_CONFIG_MIN_CACHE_SIZE              , MG_CONFIG_MAX_CACHE_SIZE              , L""                                       },
     { L""                                                                           , 0                         , 0.0                                   , 0.0                                   , L""                                       }
 };

Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2007-02-16 19:21:33 UTC (rev 1111)
@@ -392,22 +392,22 @@
     /// Tile Service properties
     static const STRING TileServicePropertiesSection;                   /// value("TileServiceProperties")
 
+    /// Specifies whether the tile is only rendered
+    static const STRING TileServicePropertyRenderOnly;                  /// value("RenderOnly")
+    static const bool DefaultTileServicePropertyRenderOnly;             /// value(false)
+
     /// Sets the root of the image tile cache
     static const STRING TileServicePropertyTileCachePath;               /// value("TileCachePath")
     static const STRING DefaultTileServicePropertyTileCachePath;        /// value("Repositories/TileCache/")
 
-    /// Specifies whether the tile is only rendered
-    static const STRING TileServicePropertyRenderOnly;                  /// value("RenderOnly")
-    static const bool DefaultTileServicePropertyRenderOnly;             /// value(true)
+    // Sets the number of columns of tiles per folder
+    static const STRING TileServicePropertyTileColumnsPerFolder;       /// value("TileColumnsPerFolder")
+    static const INT32 DefaultTileServicePropertyTileColumnsPerFolder; /// value(30)
 
     // Sets the number of rows of tiles per folder
     static const STRING TileServicePropertyTileRowsPerFolder;          /// value("TileRowsPerFolder")
     static const INT32 DefaultTileServicePropertyTileRowsPerFolder;    /// value(30)
     
-    // Sets the number of columns of tiles per folder
-    static const STRING TileServicePropertyTileColumnsPerFolder;       /// value("TileColumnsPerFolder")
-    static const INT32 DefaultTileServicePropertyTileColumnsPerFolder; /// value(30)
-
 INTERNAL_API:
 
     /// Sets the maximum amount of time (in seconds) to create a tile

Modified: trunk/MgDev/Server/src/Core/serverconfig.ini
===================================================================
--- trunk/MgDev/Server/src/Core/serverconfig.ini	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Server/src/Core/serverconfig.ini	2007-02-16 19:21:33 UTC (rev 1111)
@@ -339,12 +339,18 @@
 #
 # Property Name                    Description
 # -----------------------------------------------------------------------------
+# RenderOnly                       Renders the tile only
+#                                       0 = false and 1 = true
 # TileCachePath                    Root path of the image tile cache
+# TileColumnsPerFolder             Number of columns of tiles per folder
+#                                       0 < Value <= 1000
+# TileRowsPerFolder                Number of rows of tiles per folder
+#                                       0 < Value <= 1000
 # *****************************************************************************
+RenderOnly                         = 0
 TileCachePath                      = Repositories/TileCache/
-RenderOnly                         = 0
+TileColumnsPerFolder               = 30
 TileRowsPerFolder                  = 30
-TileColumnsPerFolder               = 30
 
 [AccessLogProperties]
 # *****************************************************************************

Modified: trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Server/src/Services/Tile/ServerTileService.cpp	2007-02-16 19:21:33 UTC (rev 1111)
@@ -21,44 +21,51 @@
 IMPLEMENT_CREATE_SERVICE(MgServerTileService)
 
 ACE_Recursive_Thread_Mutex MgServerTileService::sm_mutex;
+bool MgServerTileService::sm_initialized = false;
 MgServerTileService::MapCache MgServerTileService::sm_mapCache;
+bool MgServerTileService::sm_renderOnly = false;
 INT32 MgServerTileService::sm_creationCutoffTime = 120;     // in seconds
 INT32 MgServerTileService::sm_pollingInterval = 1;          // in seconds
-bool MgServerTileService::sm_renderOnly = false;
-INT32 MgServerTileService::sm_mapCacheSize = -1;
+INT32 MgServerTileService::sm_mapCacheSize = 10;
 
 MgServerTileService::MgServerTileService() : MgTileService()
 {
-    //TODO: It is possible to get a double write on sm_mapCacheSize here.  We need
-    //to investigate general mutex use in this class.
-    if (sm_mapCacheSize < 0)
+    if (!sm_initialized)
     {
-        // initialize the tile cache size
-        MgConfiguration* pConf = MgConfiguration::GetInstance();
+        // Perform Double-Checked Locking Optimization.
+        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
-        pConf->GetIntValue(
-            MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyCreationCutoffTime,
-            sm_creationCutoffTime,
-            MgConfigProperties::DefaultTileServicePropertyCreationCutoffTime);
+        if (!sm_initialized)
+        {
+            MgConfiguration* configuration = MgConfiguration::GetInstance();
 
-        pConf->GetIntValue(
-            MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyPollingInterval,
-            sm_pollingInterval,
-            MgConfigProperties::DefaultTileServicePropertyPollingInterval);
+            configuration->GetBoolValue(
+                MgConfigProperties::TileServicePropertiesSection,
+                MgConfigProperties::TileServicePropertyRenderOnly,
+                sm_renderOnly,
+                MgConfigProperties::DefaultTileServicePropertyRenderOnly);
 
-        pConf->GetBoolValue(
-            MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyRenderOnly,
-            sm_renderOnly,
-            MgConfigProperties::DefaultTileServicePropertyRenderOnly);
+            configuration->GetIntValue(
+                MgConfigProperties::TileServicePropertiesSection,
+                MgConfigProperties::TileServicePropertyCreationCutoffTime,
+                sm_creationCutoffTime,
+                MgConfigProperties::DefaultTileServicePropertyCreationCutoffTime);
 
-        pConf->GetIntValue(
-            MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyTiledMapCacheSize,
-            sm_mapCacheSize,
-            MgConfigProperties::DefaultTileServicePropertyTiledMapCacheSize);
+            configuration->GetIntValue(
+                MgConfigProperties::TileServicePropertiesSection,
+                MgConfigProperties::TileServicePropertyPollingInterval,
+                sm_pollingInterval,
+                MgConfigProperties::DefaultTileServicePropertyPollingInterval);
+
+            configuration->GetIntValue(
+                MgConfigProperties::TileServicePropertiesSection,
+                MgConfigProperties::TileServicePropertyTiledMapCacheSize,
+                sm_mapCacheSize,
+                MgConfigProperties::DefaultTileServicePropertyTiledMapCacheSize);
+
+            MgTileCache::Initialize();
+            sm_initialized = true;
+        }
     }
 
     m_tileCache = new MgTileCache();

Modified: trunk/MgDev/Server/src/Services/Tile/ServerTileService.h
===================================================================
--- trunk/MgDev/Server/src/Services/Tile/ServerTileService.h	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Server/src/Services/Tile/ServerTileService.h	2007-02-16 19:21:33 UTC (rev 1111)
@@ -69,10 +69,11 @@
     typedef std::map<STRING, MgMemoryStreamHelper*> MapCache;
 
     static ACE_Recursive_Thread_Mutex sm_mutex;
+    static bool sm_initialized;
     static MapCache sm_mapCache;
+    static bool sm_renderOnly;
     static INT32 sm_creationCutoffTime;
     static INT32 sm_pollingInterval;
-    static bool sm_renderOnly;
     static INT32 sm_mapCacheSize;
 };
 

Modified: trunk/MgDev/Server/src/Services/Tile/TileCache.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Tile/TileCache.cpp	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Server/src/Services/Tile/TileCache.cpp	2007-02-16 19:21:33 UTC (rev 1111)
@@ -29,35 +29,43 @@
 // default constructor
 MgTileCache::MgTileCache()
 {
-    //TODO: It is possible to get a double write on sm_path here.  We need
-    //to investigate general mutex use in this class.
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Initialize the tile cache configuration.
+///
+void MgTileCache::Initialize()
+{
     if (sm_path.empty())
     {
         // initialize the tile cache path
-        MgConfiguration* pConf = MgConfiguration::GetInstance();
+        MgConfiguration* configuration = MgConfiguration::GetInstance();
 
-        pConf->GetStringValue(
+        configuration->GetStringValue(
             MgConfigProperties::TileServicePropertiesSection,
             MgConfigProperties::TileServicePropertyTileCachePath,
             sm_path,
             MgConfigProperties::DefaultTileServicePropertyTileCachePath);
 
-        pConf->GetIntValue(MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyTileRowsPerFolder,
-            sm_tileRowsPerFolder,
-            MgConfigProperties::DefaultTileServicePropertyTileRowsPerFolder);
-
-        pConf->GetIntValue(MgConfigProperties::TileServicePropertiesSection,
-            MgConfigProperties::TileServicePropertyTileColumnsPerFolder,
-            sm_tileColumnsPerFolder,
-            MgConfigProperties::DefaultTileServicePropertyTileColumnsPerFolder);
-
         // generate directory location for tile cache
         MgFileUtil::AppendSlashToEndOfPath(sm_path);
 
         // create directory if it is not already there
         if (!MgFileUtil::PathnameExists(sm_path))
+        {
             MgFileUtil::CreateDirectory(sm_path, false);
+        }
+
+        configuration->GetIntValue(MgConfigProperties::TileServicePropertiesSection,
+            MgConfigProperties::TileServicePropertyTileColumnsPerFolder,
+            sm_tileColumnsPerFolder,
+            MgConfigProperties::DefaultTileServicePropertyTileColumnsPerFolder);
+
+        configuration->GetIntValue(MgConfigProperties::TileServicePropertiesSection,
+            MgConfigProperties::TileServicePropertyTileRowsPerFolder,
+            sm_tileRowsPerFolder,
+            MgConfigProperties::DefaultTileServicePropertyTileRowsPerFolder);
     }
 }
 
@@ -104,9 +112,6 @@
 // returns any cached tile for the given pathname
 MgByteReader* MgTileCache::Get(CREFSTRING tilePathname)
 {
-    // acquire a read lock - this blocks if a writer holds the lock
-    ACE_Read_Guard<ACE_RW_Thread_Mutex> ace_mon(m_rwMutex);
-
     Ptr<MgByteReader> ret;
 
     MG_TRY()
@@ -127,9 +132,6 @@
 // caches a tile for the given pathname
 void MgTileCache::Set(MgByteReader* img, CREFSTRING tilePathname)
 {
-    // acquire a write lock - this blocks if any readers or a writer hold the lock
-    ACE_Write_Guard<ACE_RW_Thread_Mutex> ace_mon(m_rwMutex);
-
     if (img != NULL)
     {
         Ptr<MgByteSink> byteSink = new MgByteSink(img);
@@ -141,9 +143,6 @@
 // clears the tile cache for the given map
 void MgTileCache::Clear(MgMap* map)
 {
-    // acquire a write lock - this blocks if any readers or a writer hold the lock
-    ACE_Write_Guard<ACE_RW_Thread_Mutex> ace_mon(m_rwMutex);
-
     if (map != NULL)
     {
         STRING basePath = GetBasePath(map);
@@ -157,9 +156,6 @@
 // clears the tile cache for the given map
 void MgTileCache::Clear(MgResourceIdentifier* mapDef)
 {
-    // acquire a write lock - this blocks if any readers or a writer hold the lock
-    ACE_Write_Guard<ACE_RW_Thread_Mutex> ace_mon(m_rwMutex);
-
     // the resource must be a map definition
     if (mapDef != NULL && mapDef->GetResourceType() == MgResourceType::MapDefinition)
     {

Modified: trunk/MgDev/Server/src/Services/Tile/TileCache.h
===================================================================
--- trunk/MgDev/Server/src/Services/Tile/TileCache.h	2007-02-14 20:31:39 UTC (rev 1110)
+++ trunk/MgDev/Server/src/Services/Tile/TileCache.h	2007-02-16 19:21:33 UTC (rev 1111)
@@ -26,6 +26,8 @@
 public:
     MgTileCache();
 
+    static void Initialize();
+
     void GeneratePathnames(MgResourceIdentifier* mapDef, int scaleIndex,
         CREFSTRING group, int tileColumn, int tileRow,
         STRING& tilePathname, STRING& lockPathname, bool createFullPath);
@@ -70,7 +72,6 @@
     STRING GetTileName(int tileRow, int tileColumn);
     STRING GetTileIndexString(int tileIndex, int tilesPerFolder);
     
-    ACE_RW_Thread_Mutex m_rwMutex;
     static STRING sm_path;
     static INT32 sm_tileColumnsPerFolder;
     static INT32 sm_tileRowsPerFolder;



More information about the mapguide-commits mailing list