[mapguide-commits] r7040 - in branches/2.4/MgDev/Desktop: MapViewer MapViewer.Desktop MgAppLayout MgDesktop MgDesktop/Log MgDesktop/Services MgDesktop/Services/Feature MgDesktop/Services/Rendering MgDesktop/Services/Resource MgDesktop/System UnitTest

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Sep 19 10:49:05 PDT 2012


Author: jng
Date: 2012-09-19 10:49:04 -0700 (Wed, 19 Sep 2012)
New Revision: 7040

Modified:
   branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs
   branches/2.4/MgDev/Desktop/MapViewer/IPropertyPane.cs
   branches/2.4/MgDev/Desktop/MapViewer/MapViewerController.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgLayerSelectionHandler.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgMapViewerProvider.cs
   branches/2.4/MgDev/Desktop/MgAppLayout/Program.cs
   branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.h
   branches/2.4/MgDev/Desktop/MgDesktop/Log/LogManager.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Platform.ini
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
   branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.cpp
   branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.h
   branches/2.4/MgDev/Desktop/UnitTest/main.cpp
Log:
mg-desktop: This submission includes the following changes:
 - Re-enable connection pooling for the GDAL provider in Platform.ini. The previous instability was due to a commented out call to MgdFdoConnectionPool::Cleanup() in MgdPlatform::Terminate()
 - Fix class typo for MgdLogDetail
 - Add internal APIs to clear and flush the resource content cache
 - Add a benchmark test case for GetResourceContent(s) to measure effects of caching resource content.
 - Improve performance of MgMapViewerProvider. This was one of the major bottlenecks in startup time. The majority of the time was spent pre-caching items needed for pre-QueryMapFeatures tooltip and selection processing. Property Mappings we still cache for use by the property pane, but we now do it lazily instead of eagerly. Since the introduction of QueryMapFeatures has eliminated the need for such items, we do not have to do this pre-caching anymore, so such caching code has been removed. The initialization time is now near-instantaneous.

Modified: branches/2.4/MgDev/Desktop/MapViewer/IPropertyPane.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/IPropertyPane.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MapViewer/IPropertyPane.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -135,12 +135,14 @@
         /// </summary>
         /// <param name="selection">The selection.</param>
         public MgSelectionSet(MgSelectionBase selection)
-            : this(selection, new Dictionary<string,NameValueCollection>())
+            : this(selection, null)
         {
             
         }
 
-        internal MgSelectionSet(MgSelectionBase selection, Dictionary<string, NameValueCollection> propertyMappings)
+        private MgMapViewerProvider _provider;
+
+        internal MgSelectionSet(MgSelectionBase selection, MgMapViewerProvider provider)
         {
             _agfRw = new MgAgfReaderWriter();
             _features = new Dictionary<string, List<MgFeature>>();
@@ -158,11 +160,7 @@
                         continue;
                     }
 
-                    var ldfId = layer.GetLayerDefinition();
-                    NameValueCollection mappings = null;
-                    if (propertyMappings.ContainsKey(ldfId.ToString()))
-                        mappings = propertyMappings[ldfId.ToString()];
-
+                    NameValueCollection mappings = provider.GetPropertyMappings(layer);
                     _features[layer.Name] = new List<MgFeature>();
                     
                     var reader = selection.GetSelectedFeatures(layer, layer.GetFeatureClassName(), false);

Modified: branches/2.4/MgDev/Desktop/MapViewer/MapViewerController.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MapViewerController.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MapViewer/MapViewerController.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -111,7 +111,7 @@
             if (_propPane != null || _statBar != null)
             {
                 var sel = _viewer.GetSelection();
-                var sset = new MgSelectionSet(sel, _viewer.GetProvider().AllPropertyMappings);
+                var sset = new MgSelectionSet(sel, _viewer.GetProvider());
                 if (_propPane != null)
                     _propPane.Init(sset);
                 if (_statBar != null)

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgLayerSelectionHandler.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgLayerSelectionHandler.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgLayerSelectionHandler.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -41,7 +41,7 @@
             var selLayers = sel.GetLayers();
             if (selLayers != null)
             {
-                var selectionSet = new MgSelectionSet(sel, _viewer.GetProvider().AllPropertyMappings);
+                var selectionSet = new MgSelectionSet(sel, _viewer.GetProvider());
                 var layers = new Dictionary<string, MgLayerBase>();
                 for (int i = 0; i < selLayers.Count; i++)
                 {

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgMapViewerProvider.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgMapViewerProvider.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgMapViewerProvider.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -76,7 +76,6 @@
 
             DisposeExistingMap();
             _map = map;
-            RebuildLayerInfoCache();
             OnNewMapLoaded(map);
             var h = this.MapLoaded;
             if (h != null)
@@ -105,129 +104,40 @@
             }
         }
 
+        /// <summary>
+        /// Gets the coordinate system for the map
+        /// </summary>
+        /// <returns></returns>
         public MgCoordinateSystem GetMapCoordinateSystem()
         {
             return CoordSysFactory.Create(_map.GetMapSRS());
         }
 
-        private Dictionary<string, MgCoordinateSystemTransform> _mapToLayerTransforms = new Dictionary<string, MgCoordinateSystemTransform>();
         private Dictionary<string, NameValueCollection> _propertyMappings = new Dictionary<string, NameValueCollection>();
 
-        internal Dictionary<string, NameValueCollection> AllPropertyMappings { get { return _propertyMappings; } }
-
-        private Dictionary<string, XmlDocument> _cachedLayerDefinitions = new Dictionary<string, XmlDocument>();
-
-        protected void RebuildLayerInfoCache()
+        internal NameValueCollection GetPropertyMappings(MgLayerBase layer)
         {
-            _cachedLayerDefinitions.Clear();
-            _propertyMappings.Clear();
+            MgResourceIdentifier resId = layer.GetLayerDefinition();
+            MgByteReader content = _resSvc.GetResourceContent(resId);
+            string resIdStr = resId.ToString();
 
-            foreach (var trans in _mapToLayerTransforms.Values)
-            {
-                if (trans != null)
-                    trans.Dispose();
-            }
-            _mapToLayerTransforms.Clear();
+            XmlDocument doc = new XmlDocument();
+            string xml = content.ToString();
+            doc.LoadXml(xml);
 
-            if (_resSvc == null)
-                _resSvc = (MgResourceService)CreateService(MgServiceType.ResourceService);
-
-            //Pre-cache layer definitions and tooltip properties
-            var layers = _map.GetLayers();
-            MgStringCollection resIds = new MgStringCollection();
-            for (int i = 0; i < layers.GetCount(); i++)
+            XmlNodeList propMaps = doc.GetElementsByTagName("PropertyMapping"); //NOXLATE
+            if (propMaps.Count > 0)
             {
-                var layer = layers.GetItem(i);
-                var ldf = layer.GetLayerDefinition();
-                resIds.Add(ldf.ToString());
-
-                //Make sure geometry property checks out
-                MgClassDefinition clsDef = null;
-                try 
+                NameValueCollection propertyMappings = new NameValueCollection();
+                foreach (XmlNode pm in propMaps)
                 {
-                    clsDef = layer.GetClassDefinition();
+                    propertyMappings[pm["Name"].InnerText] = pm["Value"].InnerText; //NOXLATE
                 }
-                catch (MgException ex)
-                {
-                    Trace.TraceWarning("Failed to get geometry property for layer: " + layer.Name + Environment.NewLine + ex.ToString()); //NOXLATE
-                    ex.Dispose();
-                    continue;
-                }
-                var props = clsDef.GetProperties();
-                var geomName = clsDef.DefaultGeometryPropertyName;
-                if (string.IsNullOrEmpty(geomName))
-                    continue;
-
-                if (props.IndexOf(geomName) < 0)
-                    continue;
-
-                var geomProp = props.GetItem(geomName) as MgGeometricPropertyDefinition;
-                if (geomProp == null)
-                    continue;
-
-                var trans = GetMapToLayerTransform(layer, geomProp);
+                _propertyMappings[resIdStr] = propertyMappings;
             }
-            MgStringCollection contents = _resSvc.GetResourceContents(resIds, null);
-            for (int i = 0; i < contents.GetCount(); i++)
-            {
-                XmlDocument doc = new XmlDocument();
-                doc.LoadXml(contents.GetItem(i));
-
-                _cachedLayerDefinitions[resIds.GetItem(i)] = doc;
-
-                XmlNodeList propMaps = doc.GetElementsByTagName("PropertyMapping"); //NOXLATE
-                if (propMaps.Count > 0)
-                {
-                    NameValueCollection propertyMappings = new NameValueCollection();
-                    foreach (XmlNode pm in propMaps)
-                    {
-                        propertyMappings[pm["Name"].InnerText] = pm["Value"].InnerText; //NOXLATE
-                    }
-                    _propertyMappings[resIds.GetItem(i)] = propertyMappings;
-                }
-            }
+            return _propertyMappings[resIdStr];
         }
 
-        internal MgCoordinateSystemTransform GetMapToLayerTransform(MgLayerBase layer, MgGeometricPropertyDefinition geomProp)
-        {
-            string objId = layer.GetObjectId();
-            string mapCsWkt = _map.GetMapSRS();
-            bool bChecked = false;
-            MgCoordinateSystemTransform trans = this.GetLayerTransform(objId, out bChecked);
-            if (trans == null && !bChecked)
-            {
-                MgSpatialContextReader scReader = GetSpatialContexts(layer, false);
-                try
-                {
-                    while (scReader.ReadNext())
-                    {
-                        if (scReader.GetName() == geomProp.SpatialContextAssociation)
-                        {
-                            //Only need to set up transform if layer and map wkts do not match
-                            if (!string.IsNullOrEmpty(mapCsWkt) && !string.IsNullOrEmpty(scReader.GetCoordinateSystemWkt()))
-                            {
-                                if (mapCsWkt != scReader.GetCoordinateSystemWkt())
-                                {
-                                    var csFact = this.CoordSysFactory;
-                                    var layerCs = csFact.Create(scReader.GetCoordinateSystemWkt());
-                                    trans = csFact.GetTransform(this.GetMapCoordinateSystem(), layerCs);
-                                    this.CacheLayerTransform(objId, trans);
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                }
-                finally
-                {
-                    scReader.Close();
-                }
-                if (trans == null)
-                    this.CacheLayerTransform(objId, null);
-            }
-            return trans;
-        }
-
         protected abstract MgSpatialContextReader GetSpatialContexts(MgLayerBase layer, bool activeOnly);
 
         public abstract MgMapBase CreateMap(MgResourceIdentifier mapDefinitionId, string name);
@@ -260,22 +170,6 @@
             return CreateTransientState(_map);
         }
 
-        internal MgCoordinateSystemTransform GetLayerTransform(string objId, out bool bAlreadyChecked)
-        {
-            bAlreadyChecked = false;
-            if (_mapToLayerTransforms.ContainsKey(objId))
-            {
-                bAlreadyChecked = true;
-                return _mapToLayerTransforms[objId];
-            }
-            return null;
-        }
-
-        internal void CacheLayerTransform(string objId, MgCoordinateSystemTransform trans)
-        {
-            _mapToLayerTransforms[objId] = trans;
-        }
-
         /// <summary>
         /// 
         /// </summary>

Modified: branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MapViewer.Desktop/MgDesktopMapViewerProvider.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -26,6 +26,7 @@
         protected override void SubInit()
         {
             _fact = new MgdServiceFactory();
+            _resSvc = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService);
             _renderSvc = (MgdRenderingService)_fact.CreateService(MgServiceType.RenderingService);
             _mappingSvc = (MgdMappingService)_fact.CreateService(MgServiceType.MappingService);
         }

Modified: branches/2.4/MgDev/Desktop/MgAppLayout/Program.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MgAppLayout/Program.cs	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgAppLayout/Program.cs	2012-09-19 17:49:04 UTC (rev 7040)
@@ -1,4 +1,5 @@
-using System;
+//#define PROFILE
+using System;
 using System.Collections.Generic;
 using System.Windows.Forms;
 using OSGeo.MapGuide;
@@ -25,11 +26,14 @@
             //Must call MgPlatform.Initialize() before we can work with anything from the MapGuide API
             try
             {
-                var sw = new Stopwatch();
-                sw.Start();
+#if PROFILE
+                using (new CallMeasure("MgdPlatform.Initialize"))
+                {
+                    MgdPlatform.Initialize("Platform.ini");
+                }
+#else
                 MgdPlatform.Initialize("Platform.ini");
-                sw.Stop();
-                Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);
+#endif
             }
             catch (Exception ex)
             {
@@ -60,22 +64,53 @@
             var provider = new MgDesktopMapViewerProvider(null);
             var resSvc = (MgResourceService)provider.CreateService(MgServiceType.ResourceService);
             if (resSvc.ResourceExists(mdfId))
+            {
+#if PROFILE
+                using (new CallMeasure("MgdMap constructor (cold start)"))
+                {
+                    var mapCold = new MgdMap(mdfId);
+                }
+                MgdMap map = null;
+                using (new CallMeasure("MgdMap constructor (warm start)"))
+                {
+                    map = new MgdMap(mdfId);
+                }
+                using (new CallMeasure("MgMapViewerProvider.LoadMap"))
+                {
+                    provider.LoadMap(map);
+                }
+#else
                 provider.LoadMap(new MgdMap(mdfId));
+#endif
+            }
             var frm = Shell.Instance;
             ((Shell)frm).Initialize(layout, provider);
-            Application.ApplicationExit += new EventHandler(OnAppExit);
             Application.Run((Shell)frm);
             MgdPlatform.Terminate();
         }
 
-        static void OnAppExit(object sender, EventArgs e)
+        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
         {
-            
+            MessageBox.Show(e.Exception.ToString());
         }
+    }
 
-        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
+    class CallMeasure : IDisposable
+    {
+        private Stopwatch _sw;
+        private string _msg;
+
+        public CallMeasure(string msg)
         {
-            MessageBox.Show(e.Exception.ToString());
+            _msg = msg;
+            _sw = new Stopwatch();
+            _sw.Start();
         }
+
+        public void Dispose()
+        {
+            _sw.Stop();
+            Console.WriteLine("{0} - {1}ms", _msg, _sw.ElapsedMilliseconds);
+        }
     }
 }

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -17,7 +17,7 @@
 
 #include "LogDetail.h"
 
-MgdLogDetiail::MgdLogDetiail(INT32 serviceNum, INT8 detail, CREFSTRING methodName, REFSTRING errorLogVar)
+MgdLogDetail::MgdLogDetail(INT32 serviceNum, INT8 detail, CREFSTRING methodName, REFSTRING errorLogVar)
 : m_errorLogVar(errorLogVar)
 {
     MgdLogManager* logMgr = MgdLogManager::GetInstance();
@@ -28,12 +28,12 @@
     m_methodName = methodName;
 }
 
-MgdLogDetiail::~MgdLogDetiail()
+MgdLogDetail::~MgdLogDetail()
 {
     Terminate();
 }
 
-void MgdLogDetiail::AppendName(CREFSTRING paramName)
+void MgdLogDetail::AppendName(CREFSTRING paramName)
 {
     if (m_params.length() > 0)
     {
@@ -43,17 +43,17 @@
     m_params.append(L"=");
 }
 
- bool MgdLogDetiail::ParamsActive()
+ bool MgdLogDetail::ParamsActive()
  {
-     return m_minDetail > MgdLogDetiail::Error;
+     return m_minDetail > MgdLogDetail::Error;
  }
 
- bool MgdLogDetiail::ShouldLog()
+ bool MgdLogDetail::ShouldLog()
  {
      return m_detail <= m_minDetail;
  }
 
-void MgdLogDetiail::AddResourceIdentifier(CREFSTRING paramName, MgResourceIdentifier* resId)
+void MgdLogDetail::AddResourceIdentifier(CREFSTRING paramName, MgResourceIdentifier* resId)
 {
 
     if (NULL != resId && ParamsActive())
@@ -63,7 +63,7 @@
     }
 }
 
-void MgdLogDetiail::AddInt64(CREFSTRING paramName, INT64 paramValue)
+void MgdLogDetail::AddInt64(CREFSTRING paramName, INT64 paramValue)
 {
     if (ParamsActive())
     {
@@ -74,7 +74,7 @@
     }
 }
 
-void MgdLogDetiail::AddInt32(CREFSTRING paramName, INT32 paramValue)
+void MgdLogDetail::AddInt32(CREFSTRING paramName, INT32 paramValue)
 {
     if (ParamsActive())
     {
@@ -85,7 +85,7 @@
     }
 }
 
-void MgdLogDetiail::AddBool(CREFSTRING paramName, bool paramValue)
+void MgdLogDetail::AddBool(CREFSTRING paramName, bool paramValue)
 {
     if (ParamsActive())
     {
@@ -94,7 +94,7 @@
     }
 }
 
-void MgdLogDetiail::AddString(CREFSTRING paramName, CREFSTRING paramValue)
+void MgdLogDetail::AddString(CREFSTRING paramName, CREFSTRING paramValue)
 {
     if (ParamsActive())
     {
@@ -103,7 +103,7 @@
     }
 }
 
-void MgdLogDetiail::AddObject(CREFSTRING paramName, MgSerializable* object)
+void MgdLogDetail::AddObject(CREFSTRING paramName, MgSerializable* object)
 {
     if (NULL != object && ParamsActive())
     {
@@ -112,7 +112,7 @@
     }
 }
 
-void MgdLogDetiail::Create()
+void MgdLogDetail::Create()
 {
     // Always propagate parameters for exception message
     m_errorLogVar = m_params;
@@ -129,7 +129,7 @@
     }
 }
 
-void MgdLogDetiail::Terminate()
+void MgdLogDetail::Terminate()
 {
     if (ShouldLog())
     {

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.h	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Log/LogDetail.h	2012-09-19 17:49:04 UTC (rev 7040)
@@ -15,14 +15,14 @@
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-#ifndef MgdLogDetiail_H_
-#define MgdLogDetiail_H_
+#ifndef MgdLogDetail_H_
+#define MgdLogDetail_H_
 
 #include "MgDesktop.h"
 #include "LogManager.h"
 
 //
-// MgdLogDetiail maintains detailed information for both the Trace Log and the Error Log.
+// MgdLogDetail maintains detailed information for both the Trace Log and the Error Log.
 // It also handles writing of the trace log based on information contained in serverconfig.ini
 //
 // [GeneralProperties]
@@ -36,9 +36,9 @@
 // Only error messages without parameters are logged for Resource Service, and
 // Error messages and warnings with parameters are logged for Feature Service
 //
-class MG_DESKTOP_API MgdLogDetiail
+class MG_DESKTOP_API MgdLogDetail
 {
-    DECLARE_CLASSNAME(MgdLogDetiail)
+    DECLARE_CLASSNAME(MgdLogDetail)
 
 public:
 /// Enumerations
@@ -69,8 +69,8 @@
 
     // Defines a log entry for the specified service and detail level.  This entry will only be emitted
     // into trace log if the serverconfig.ini LogsDetail >= detail
-    MgdLogDetiail(INT32 serviceType, INT8 detail, CREFSTRING methodName, REFSTRING errorLogVar);
-    virtual ~MgdLogDetiail();
+    MgdLogDetail(INT32 serviceType, INT8 detail, CREFSTRING methodName, REFSTRING errorLogVar);
+    virtual ~MgdLogDetail();
 
 /// Methods
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Log/LogManager.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Log/LogManager.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Log/LogManager.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -1637,7 +1637,7 @@
     // Warnings are only logged if the detail level for the service is high enough.
     INT8 detailLevel = GetDetailLevelForService(service);
 
-    if (detailLevel >= MgdLogDetiail::Warning)
+    if (detailLevel >= MgdLogDetail::Warning)
     {
         // Log entries to both error log and trace log, if applicable
         if(IsErrorLogEnabled())

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Platform.ini
===================================================================
(Binary files differ)

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -93,7 +93,7 @@
         }
     }
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionPool::GetConnection", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionPool::GetConnection", mgStackParams);
     logDetail.AddResourceIdentifier(L"featureSourceId", featureSourceId);
     logDetail.AddBool(L"IsNewInstance", bNewInstance);
     logDetail.Create();
@@ -156,7 +156,7 @@
         #endif
     }
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionPool::ReturnConnection", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionPool::ReturnConnection", mgStackParams);
     logDetail.AddString(L"FeatureSource", fsIdStr.empty() ? L"<No Feature Source>" : fsIdStr);
     logDetail.AddBool(L"ReturnedToPool", bReturned);
     logDetail.AddBool(L"ProviderExcluded", bProviderExcluded);
@@ -208,7 +208,7 @@
         g_excludedProviders = new MgStringCollection();
     }
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionPool::Initialize", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionPool::Initialize", mgStackParams);
     logDetail.AddBool(L"PoolingEnabled", g_bPoolingEnabled);
     logDetail.AddString(L"ExcludedProviders", excludedProviders);
     logDetail.Create();
@@ -269,7 +269,7 @@
     #ifdef DEBUG_FDO_CONNECTION_POOL
         ACE_DEBUG((LM_INFO, ACE_TEXT("[Purge]: (%W) %d purged\n"), fsIdStr.c_str(), purged));
     #endif
-        MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionPool::PurgeCachedConnections", mgStackParams);
+        MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionPool::PurgeCachedConnections", mgStackParams);
         logDetail.AddResourceIdentifier(L"resId", resId);
         logDetail.AddInt32(L"purgedConnections", purged);
         logDetail.Create();
@@ -314,7 +314,7 @@
     ACE_DEBUG((LM_INFO, ACE_TEXT("[Purge]: (%W) %d purged\n"), fsIdStr.c_str(), purged));
 #endif
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionPool::PurgeCachedConnectionsUnderFolder", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionPool::PurgeCachedConnectionsUnderFolder", mgStackParams);
     logDetail.AddResourceIdentifier(L"resId", resId);
     logDetail.AddInt32(L"purgedConnections", purged);
     logDetail.Create();

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -16,7 +16,7 @@
 
     MG_FEATURE_SERVICE_TRY()
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionUtil::CreateConnection", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionUtil::CreateConnection", mgStackParams);
     logDetail.AddString(L"providerName", providerName);
     logDetail.AddString(L"connectionString", connectionString);
     logDetail.Create();
@@ -125,7 +125,7 @@
 		dict->SetProperty(n.c_str(), v.c_str());
 	}
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::InternalTrace, L"MgdFdoConnectionUtil::CreateConnection", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::InternalTrace, L"MgdFdoConnectionUtil::CreateConnection", mgStackParams);
     logDetail.AddResourceIdentifier(L"resource", resource);
     logDetail.Create();
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -643,7 +643,7 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgFeatureQueryOptions");
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::Trace, L"MgdFeatureService::SelectFeatures", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::Trace, L"MgdFeatureService::SelectFeatures", mgStackParams);
     logDetail.AddResourceIdentifier(L"Resource", resource);
     logDetail.AddString(L"ClassName", className);
     logDetail.AddObject(L"Options", options);
@@ -696,7 +696,7 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"STRING");
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-	MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::Trace, L"MgdFeatureService::SelectFeatures", mgStackParams);
+	MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::Trace, L"MgdFeatureService::SelectFeatures", mgStackParams);
     logDetail.AddResourceIdentifier(L"Resource", resource);
     logDetail.AddString(L"ClassName", className);
     logDetail.AddObject(L"Options", options);
@@ -794,7 +794,7 @@
 
     MG_LOG_TRACE_ENTRY(L"MgdFeatureService::SelectFeaturesExtended()");
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::Trace, L"MgdFeatureService::SelectFeaturesExtended", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::Trace, L"MgdFeatureService::SelectFeaturesExtended", mgStackParams);
     logDetail.AddResourceIdentifier(L"Resource", resource);
     logDetail.AddString(L"ClassName", className);
     logDetail.AddObject(L"Options", options);
@@ -845,7 +845,7 @@
     MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgFeatureAggregateOptions");
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::Trace, L"MgdFeatureService::SelectAggregate", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::Trace, L"MgdFeatureService::SelectAggregate", mgStackParams);
     logDetail.AddResourceIdentifier(L"Resource", resource);
     logDetail.AddString(L"ClassName", className);
     logDetail.AddObject(L"Options", options);
@@ -1667,7 +1667,7 @@
     MG_LOG_OPERATION_MESSAGE_ADD_BOOL(bActiveOnly);
     MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
-    MgdLogDetiail logDetail(MgServiceType::FeatureService, MgdLogDetiail::Trace, L"MgdFeatureService::GetSpatialContexts", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::FeatureService, MgdLogDetail::Trace, L"MgdFeatureService::GetSpatialContexts", mgStackParams);
     logDetail.AddResourceIdentifier(L"Id", resId);
     logDetail.AddBool(L"ActiveOnly", bActiveOnly);
     logDetail.Create();

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -420,7 +420,7 @@
 
             Ptr<MgLayerGroup> group = mapLayer->GetGroup();
 			
-            MgdLogDetiail logDetail(MgServiceType::MappingService, MgdLogDetiail::InternalTrace, L"MgdMappingUtil.StylizeLayers", mgStackParams);
+            MgdLogDetail logDetail(MgServiceType::MappingService, MgdLogDetail::InternalTrace, L"MgdMappingUtil.StylizeLayers", mgStackParams);
             logDetail.AddString(L"Map",map->GetName());
 
             logDetail.AddResourceIdentifier(L"LayerId",layerid);

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -40,6 +40,18 @@
     return ret;
 }
 
+INT32 MgdResourceContentCache::GetCacheSize()
+{
+	ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_MgdMutex, 0));
+	return m_resourceContentCacheEntries.size();
+}
+
+void MgdResourceContentCache::Clear()
+{
+	ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_MgdMutex));
+	m_resourceContentCacheEntries.clear();
+}
+
 void MgdResourceContentCache::RemoveContentEntry(MgResourceIdentifier* resource)
 {
     CHECKARGUMENTNULL(resource, L"MgdResourceContentCache::PutContentEntry");

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.h	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Resource/ResourceContentCache.h	2012-09-19 17:49:04 UTC (rev 7040)
@@ -3,7 +3,7 @@
 
 #include "MgDesktop.h"
 
-class MgdResourceContentCache : public MgGuardDisposable
+class MG_DESKTOP_API MgdResourceContentCache : public MgGuardDisposable
 {
 private:
     static Ptr<MgdResourceContentCache> smInstance;
@@ -17,6 +17,9 @@
     void RemoveContentEntry(MgResourceIdentifier* resource);
     void PutContentEntry(MgResourceIdentifier* resource, CREFSTRING content);
 
+	void Clear();
+	INT32 GetCacheSize();
+
 protected:
     virtual void Dispose() { delete this; }
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -131,7 +131,7 @@
         path += type;
     }
 
-    MgdLogDetiail logDetail(MgServiceType::ResourceService, MgdLogDetiail::InternalTrace, L"MgdResourceService::ResolveContentPath", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::ResourceService, MgdLogDetail::InternalTrace, L"MgdResourceService::ResolveContentPath", mgStackParams);
     logDetail.AddResourceIdentifier(L"resId", resId);
     logDetail.AddString(L"resolvedPath", path);
     logDetail.Create();
@@ -202,7 +202,7 @@
 		throw new MgInvalidArgumentException(L"MgdResourceService::ResolveDataPath", __LINE__, __WFILE__, NULL, L"", NULL);
 	}
 
-    MgdLogDetiail logDetail(MgServiceType::ResourceService, MgdLogDetiail::InternalTrace, L"MgdResourceService::ResolveDataPath", mgStackParams);
+    MgdLogDetail logDetail(MgServiceType::ResourceService, MgdLogDetail::InternalTrace, L"MgdResourceService::ResolveDataPath", mgStackParams);
     logDetail.AddResourceIdentifier(L"resId", resId);
     logDetail.AddString(L"repositoryType", type);
     logDetail.AddString(L"resolvedPath", cntPath);

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -89,34 +89,4 @@
         return new MgdTileService();
     }
     throw new MgServiceNotSupportedException(L"MgdServiceFactory::CreateService", __LINE__, __WFILE__, NULL, L"", NULL);
-}
-
-/*
-MgdTileService* MgdServiceFactory::CreateTileService()
-{
-    return new MgdTileService();
-}
-
-MgdFeatureService* MgdServiceFactory::CreateFeatureService()
-{
-	return new MgdFeatureService();
-}
-
-MgdResourceService* MgdServiceFactory::CreateResourceService()
-{
-	return new MgdResourceService(sm_libContentPath,
-                                  sm_libDataPath, 
-                                  sm_sesContentPath, 
-                                  sm_sesDataPath);
-}
-
-MgdDrawingService* MgdServiceFactory::CreateDrawingService()
-{
-    return new MgdDrawingService();
-}
-
-MgdRenderingService* MgdServiceFactory::CreateRenderingService()
-{
-    return new MgdRenderingService();
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -174,7 +174,7 @@
     MG_LOG_TRACE_ENTRY(L"MgdPlatform::Terminate()");
     MG_TRY()
 
-    //MgdFdoConnectionPool::Cleanup();
+    MgdFdoConnectionPool::Cleanup();
 
     //This is important. Otherwise the process using this library will be left lingering
     MgdLogManager* pLogManager = MgdLogManager::GetInstance();

Modified: branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -16,6 +16,7 @@
 //
 
 #include "MgDesktop.h"
+#include "Services\Resource\ResourceContentCache.h"
 #include "Fdo.h"
 #include "TestResourceService.h"
 #include "CppUnitExtensions.h"
@@ -1100,189 +1101,84 @@
     }
 }
 
-// data structure which is passed to each thread
-struct ResourceThreadData
+void TestResourceService::TestCase_BenchmarkGetResourceContents()
 {
-    INT32 threadId;
-    INT32 command;
-    bool success;
-    bool done;
-    STRING session;
-};
-
-// the method which gets executed by the ACE worker thread
-ACE_THR_FUNC_RETURN RepositoryWorker(void* param)
-{
-    // get the data for this thread
-    ResourceThreadData* threadData = (ResourceThreadData*)param;
-    INT32 threadId = threadData->threadId;
-    INT32 command = threadData->command;
-    STRING session = threadData->session;
-
-    ACE_DEBUG((LM_INFO, ACE_TEXT("> thread %d started\n"), threadId));
-
-    try
-    {
-        // get the tile service instance
-        Ptr<MgdServiceFactory> fact = new MgdServiceFactory();
-        Ptr<MgResourceService> svcResource = dynamic_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
-        assert(svcResource != NULL);
-
-        STRING resource = L"Session:";
-        resource += session;
-        resource += L"//UnitTests/Data/test-1.FeatureSource";
-        Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resource);
-
-        switch (command)
+	try
+	{
+		Ptr<MgdServiceFactory> fact = new MgdServiceFactory();
+        Ptr<MgResourceService> pService = dynamic_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+        if (pService == 0)
         {
-        case 0:
-            {
-            //Set the resource
-            Ptr<MgByteSource> contentSource = new MgByteSource(resourceContentFileName);
-            Ptr<MgByteReader> contentReader = contentSource->GetReader();
-            svcResource->SetResource(resId, contentReader, NULL);
-            }
-        case 1:
-            {
-            //Set the resource data
-            Ptr<MgByteSource> dataSource = new MgByteSource(dataFileName);
-            Ptr<MgByteReader> dataReader = dataSource->GetReader();
-            svcResource->SetResourceData(resId, resourceDataName, L"File", dataReader);
-            }
-            // Need to add a case that updates the session with runtime map
+            throw new MgServiceNotAvailableException(L"TestResourceService.TestCase_BenchmarkGetResourceContents", __LINE__, __WFILE__, NULL, L"", NULL);
         }
 
-        threadData->success = true;
-    }
-    catch (MgException* e)
-    {
-        STRING message = e->GetDetails(TEST_LOCALE);
-        message += L"\n";
-        message += e->GetStackTrace(TEST_LOCALE);
-        SAFE_RELEASE(e);
-        ACE_DEBUG((LM_INFO, ACE_TEXT("RepositoryWorker(%d) - Exception:\n%W\n"), threadId, message.c_str()));
-    }
-    catch (...)
-    {
-        throw;
-    }
+		Ptr<MgStringCollection> resources = new MgStringCollection();
 
-    ACE_DEBUG((LM_INFO, ACE_TEXT("> thread %d done\n"), threadId));
+		Ptr<MgByteSource> source = new MgByteSource(resourceContentFileName2);
+		Ptr<MgByteReader> reader = source->GetReader();
+		// Prepare the resources
+		for (INT32 i = 0; i < 150; i++)
+		{
+			STRING numStr;
+			MgUtil::Int32ToString(i, numStr);
+			STRING resIdStr = L"Library://BatchTests/Layer";
+			resIdStr += numStr;
+			resIdStr += L".LayerDefinition";
 
-    threadData->done = true;
-    return 0;
-}
+			Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resIdStr);
+			pService->SetResource(resId, reader, NULL);
+			resources->Add(resId->ToString());
+			reader->Rewind();
+		}
 
-/*
-void TestResourceService::TestCase_RepositoryBusy()
-{
-    // specify the number of threads to use
-    const INT32 numThreads = MG_TEST_THREADS;
-    ResourceThreadData threadData[numThreads];
+		//Evict all cached copies to avoid distortion of results due to caching
+		MgdResourceContentCache* cache = MgdResourceContentCache::GetInstance();
+		cache->Clear();
 
-    try
-    {
-        long lStart = GetTickCount();
+		long lStart = GetTickCount();
+		ACE_DEBUG((LM_INFO, ACE_TEXT("\nTestResourceService::TestCase_BenchmarkGetResourceContents() - Individual GetResourceContent calls (cold) \n")));
+		for (INT32 i = 0; i < resources->GetCount(); i++)
+		{
+			Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resources->GetItem(i));
+			Ptr<MgByteReader> content = pService->GetResourceContent(resId);
+		}
+		ACE_DEBUG((LM_INFO, ACE_TEXT("  Execution Time: = %6.4f (s)\n"), ((GetTickCount()-lStart)/1000.0) ));
+		ACE_DEBUG((LM_INFO, ACE_TEXT(" %d resource content items in cache\n"), (cache->GetCacheSize()) ));
 
-        // get the tile service instance
-        Ptr<MgResourceService> svcResource = MgdServiceFactory::CreateResourceService();
-        assert(svcResource != NULL);
+		lStart = GetTickCount();
+		ACE_DEBUG((LM_INFO, ACE_TEXT("\nTestResourceService::TestCase_BenchmarkGetResourceContents() - Individual GetResourceContent calls (cached contents) \n")));
+		for (INT32 i = 0; i < resources->GetCount(); i++)
+		{
+			Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resources->GetItem(i));
+			Ptr<MgByteReader> content = pService->GetResourceContent(resId);
+		}
+		ACE_DEBUG((LM_INFO, ACE_TEXT("  Execution Time: = %6.4f (s)\n"), ((GetTickCount()-lStart)/1000.0) ));
+		
+		//Evict all cached copies to avoid distortion of results due to caching
+		cache->Clear();
+		ACE_DEBUG((LM_INFO, ACE_TEXT(" %d resource content items in cache\n"), (cache->GetCacheSize()) ));
 
-        // need a thread manager
-        ACE_Thread_Manager* manager = ACE_Thread_Manager::instance();
+		lStart = GetTickCount();
+		Ptr<MgStringCollection> contents;
+		ACE_DEBUG((LM_INFO, ACE_TEXT("\nTestResourceService::TestCase_BenchmarkGetResourceContents() - Multi-threaded GetResourceContents call (cold) \n")));
+		contents = pService->GetResourceContents(resources, NULL);
+		CPPUNIT_ASSERT(NULL != contents.p);
+		CPPUNIT_ASSERT(contents->GetCount() == resources->GetCount());
+		ACE_DEBUG((LM_INFO, ACE_TEXT("  Execution Time: = %6.4f (s)\n"), ((GetTickCount()-lStart)/1000.0) ));
+		ACE_DEBUG((LM_INFO, ACE_TEXT(" %d resource content items in cache\n"), (cache->GetCacheSize()) ));
 
-        // initialize the thread data
-        for (INT32 i=0; i<numThreads; i++)
-        {
-            // Initialize the resource
-            wchar_t wszBuffer[255];
-            swprintf(wszBuffer, 255, L"48cb0286-%04d-1000-8001-005056c00008_en_6F7A8590045708AE0D05", i);
-
-            // Session format: 48cb0286-0000-1000-8001-005056c00008_en_6F7A8590045708AE0D05
-            STRING session = wszBuffer;
-            STRING resource = L"Session:";
-            resource += session;
-            resource += L"//";
-
-            // Create session resource
-            Ptr<MgResourceIdentifier> resIdSession = new MgResourceIdentifier(resource);
-            svcResource->CreateRepository(resIdSession, NULL, NULL);
-
-            // Create feature source resource
-            resource += L"UnitTests/Data/test-1.FeatureSource";
-            Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(resource);
-            Ptr<MgByteSource> contentSource = new MgByteSource(resourceContentFileName);
-            Ptr<MgByteReader> contentReader = contentSource->GetReader();
-            svcResource->SetResource(resId, contentReader, NULL);
-
-            // Set the thread specific data
-            threadData[i].threadId = i;
-            threadData[i].success  = false;
-            threadData[i].done     = true;
-            threadData[i].session  = session;
-        }
-
-        ACE_DEBUG((LM_INFO, ACE_TEXT("\nTestCase_RepositoryBusy\nThreads: %d  Requests: %d\n\n"), numThreads, TESTREQUESTS));
-
-        INT32 nRequest = 0;
-        INT32 nSuccessful = 0;
-        bool bExceptionOcurred = false;
-        for (;;)
-        {
-            INT32 dc = 0;
-            for (INT32 i=0; i<numThreads; i++)
-            {
-                // check if the thread is available
-                if (threadData[i].done)
-                {
-                    if(threadData[i].success)
-                        nSuccessful++;
-
-                    threadData[i].success = false;
-                    threadData[i].done    = false;
-                    threadData[i].command = i%2;
-
-                    // spawn a new thread using a specific group id
-                    int thid = manager->spawn(ACE_THR_FUNC(RepositoryWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
-                    nRequest++;
-                }
-            }
-
-            // move on if all threads are done
-            if ((nRequest > TESTREQUESTS) || (bExceptionOcurred))
-                break;
-
-            // under Linux we get a deadlock if we don't call this every once in a while
-            if (nRequest % 25 == 0)
-                manager->wait_grp(THREAD_GROUP);
-            else
-            {
-                // pause briefly (10ms) before checking again
-                ACE_Time_Value t(0, 10000);
-                ACE_OS::sleep(t);
-            }
-        }
-
-        // make sure all threads in the group have completed
-        manager->wait_grp(THREAD_GROUP);
-
-        for (INT32 i=0; i<numThreads; i++)
-        {
-            if(threadData[i].success)
-                nSuccessful++;
-        }
-
-        ACE_DEBUG((LM_INFO, ACE_TEXT("\nRequests: %d/%d - Execution Time: = %6.4f (s)\n"), nSuccessful, nRequest, ((GetTickCount()-lStart)/1000.0)));
-    }
-    catch (MgException* e)
+		lStart = GetTickCount();
+		ACE_DEBUG((LM_INFO, ACE_TEXT("\nTestResourceService::TestCase_BenchmarkGetResourceContents() - Multi-threaded GetResourceContents call (cached contents) \n")));
+		contents = pService->GetResourceContents(resources, NULL);
+		CPPUNIT_ASSERT(NULL != contents.p);
+		CPPUNIT_ASSERT(contents->GetCount() == resources->GetCount());
+		ACE_DEBUG((LM_INFO, ACE_TEXT("  Execution Time: = %6.4f (s)\n"), ((GetTickCount()-lStart)/1000.0) ));
+		ACE_DEBUG((LM_INFO, ACE_TEXT(" %d resource content items in cache\n"), (cache->GetCacheSize()) ));
+	}
+    catch(MgException* e)
     {
         STRING message = e->GetDetails(TEST_LOCALE);
         SAFE_RELEASE(e);
         CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
     }
-    catch (...)
-    {
-        throw;
-    }
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.h
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.h	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/UnitTest/TestResourceService.h	2012-09-19 17:49:04 UTC (rev 7040)
@@ -57,6 +57,8 @@
     CPPUNIT_TEST(TestCase_EnumerateUnmanagedData);
     //CPPUNIT_TEST(TestCase_RepositoryBusy);
 
+	CPPUNIT_TEST(TestCase_BenchmarkGetResourceContents);
+
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
 
@@ -100,6 +102,9 @@
 
     void TestCase_EnumerateUnmanagedData();
     //void TestCase_RepositoryBusy();
+
+	// Benchmarking
+	void TestCase_BenchmarkGetResourceContents();
 };
 
 #endif // TESTRESOURCESERVICE_H_

Modified: branches/2.4/MgDev/Desktop/UnitTest/main.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/UnitTest/main.cpp	2012-09-19 13:22:29 UTC (rev 7039)
+++ branches/2.4/MgDev/Desktop/UnitTest/main.cpp	2012-09-19 17:49:04 UTC (rev 7040)
@@ -25,13 +25,13 @@
 #endif
 
 #define TEST_COORDINATE_SYSTEM  0
-#define TEST_LOG_MANAGER        1
+#define TEST_LOG_MANAGER        0
 #define TEST_RESOURCE_SERVICE   1
-#define TEST_FEATURE_SERVICE    1
-#define TEST_MAPPING_SERVICE    1
-#define TEST_PROFILING_SERVICE  1
-#define TEST_RENDERING_SERVICE  1
-#define TEST_TILE_SERVICE       1
+#define TEST_FEATURE_SERVICE    0
+#define TEST_MAPPING_SERVICE    0
+#define TEST_PROFILING_SERVICE  0
+#define TEST_RENDERING_SERVICE  0
+#define TEST_TILE_SERVICE       0
 
 int main(int argc, char** argv)
 {



More information about the mapguide-commits mailing list