MapGuide Enterprise/OpenSource是通过FDO连接到数据源的。在访问数据源的过程中,MGServer会创建到数据源的FDO连接。为提高性能,连接使用完毕后并不是马上释放,而是放在一个连接池(ConnectionPool)中,下次再使用该FDO连接时,可以先查找连接池中是否有空闲连接,如有空间连接,直接使用连接池中的连接从而省去创建连接的开销;如果连接池中没有可用连接时才会去重新创建,使用完毕后在放置到连接池中。
对应连接池的大小,缺省是200个,但对于不同的FDO连接类型,我们也可以自定义连接池的大小。这些参数就存储在ServerConfig.ini(C:\Program Files\Autodesk\MapGuideEnterprise2010\Server\Bin\serverconfig.ini)文件中。
[FeatureServiceProperties]
# *****************************************************************************
# F E A T U R E S E R V I C E
#
# Property Name Description
# -----------------------------------------------------------------------------
# CacheSize Max # of internal data objects to cache
# (schemas, classes, etc...)
# 0 < Value <= 5000
# CacheTimeLimit Time duration in seconds for how long to
# cache the internal data objects
# 0 < Value <= 2147483647
# CacheTimerInterval Time interval in seconds for when the server
# checks for expired cache entries
# 0 < Value <= 2147483647
# DataCacheSize Max # of features to fetch
# 0 < Value <= 2147483647
# DataConnectionPoolEnabled FDO connection pooling
# 0 = disabled, 1 = enabled
# DataConnectionPoolExcludedProviders The list of providers to exclude from connection pooling.
# 0 <= Length <= 1024
# Value = provider name(s) separated by ","
# Example: OSGeo.SDF,OSGeo.SHP
# DataConnectionPoolSize Default # of FDO connections to cache per provider
# 1 < Value <= 1024
# DataConnectionPoolSizeCustom Custom # of FDO connections to cache for specified provider
# 0 <= Length <= 1024
# Example: OSGeo.SDF:10,OSGeo.SHP:10
# DataConnectionTimeout Time duration in seconds for when an idle FDO
# connection is dropped
# 0 < Value <= 2147483647
# DataConnectionTimerInterval Time interval in seconds for when the server
# checks for idle FDO connections
# 0 < Value <= 2147483647
# JoinQueryBatchSize Join query batch size
# 1 < Value <= 10000
# *****************************************************************************
JoinQueryBatchSize = 1000
DataConnectionTimerInterval = 3600
DataConnectionTimeout = 28800
DataConnectionPoolSizeCustom = OSGeo.Gdal:1
DataConnectionPoolSize = 200
DataConnectionPoolExcludedProviders = OSGeo.SDF,OSGeo.SHP
DataConnectionPoolEnabled = 1
DataCacheSize = 100
CacheTimerInterval = 3600
CacheTimeLimit = 86400
CacheSize = 100
如果我们想设置某种FDO连接的连接池大小,我们就可以通过更改这个配置文件来实现。比如我们需要自定义到ArcSDE的FDO连接池的大小为50个,可以通过更改DataConnectionPoolSizeCustom实现:
DataConnectionPoolSizeCustom = OSGeo.Gdal:1, OSGeo.ArcSDE:50
更改保存完毕,需要重新启动MGServer使改到生效。
另外我们可以通过MapAgent中的测试页面监视FDO连接的使用状况:
通过http://servername/mapagent/index.html 在左边的Feature下的 GetFdoCacheInfo API来查看:
下面是我的MGServer某一时刻的使用状况:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <FdoCacheInformation>
<TimeStamp>2009-11-17T17:48:29.702633</TimeStamp>
- <ConfigurationSettings>
<DataConnectionPoolEnabled>True</DataConnectionPoolEnabled>
<DataConnectionPoolExcludedProviders>OSGeo.SDF,OSGeo.SHP</DataConnectionPoolExcludedProviders>
<DataConnectionPoolSize>200</DataConnectionPoolSize>
<DataConnectionPoolSizeCustom>OSGeo.Gdal:1</DataConnectionPoolSizeCustom>
<DataConnectionTimeout>28800</DataConnectionTimeout>
</ConfigurationSettings>
- <Provider>
<Name>Autodesk.Oracle</Name>
<MaximumDataConnectionPoolSize>200</MaximumDataConnectionPoolSize>
<CurrentDataConnectionPoolSize>1</CurrentDataConnectionPoolSize>
<CurrentDataConnections>0</CurrentDataConnections>
<ThreadModel>FdoThreadCapability_PerConnectionThreaded</ThreadModel>
<KeepDataConnectionsCached>True</KeepDataConnectionsCached>
- <CachedFdoConnection>
<Name>Library://Samples/Sheboygan/Data/Ora.FeatureSource</Name>
<ConnectionState>Open</ConnectionState>
<InUse>False</InUse>
<LongTransaction>LIVE</LongTransaction>
<LastUsed>2009-11-17T10:24:02</LastUsed>
<Valid>True</Valid>
</CachedFdoConnection>
</Provider>
- <Provider>
<Name>OSGeo.Gdal</Name>
<MaximumDataConnectionPoolSize>1</MaximumDataConnectionPoolSize>
<CurrentDataConnectionPoolSize>0</CurrentDataConnectionPoolSize>
<CurrentDataConnections>0</CurrentDataConnections>
<ThreadModel>Not initialized.</ThreadModel>
<KeepDataConnectionsCached>True</KeepDataConnectionsCached>
</Provider>
- <Provider>
<Name>OSGeo.SDF</Name>
<MaximumDataConnectionPoolSize>200</MaximumDataConnectionPoolSize>
<CurrentDataConnectionPoolSize>0</CurrentDataConnectionPoolSize>
<CurrentDataConnections>0</CurrentDataConnections>
<ThreadModel>FdoThreadCapability_PerConnectionThreaded</ThreadModel>
<KeepDataConnectionsCached>False</KeepDataConnectionsCached>
</Provider>
</FdoCacheInformation>
好了,如果你需要为FDO连接池的大小做定制的话,试试这个吧! Cheers!
有任何意见建议欢迎评论或到MGDN论坛讨论。
转载请注明出处及作者 峻祁连 Daniel Du 杜长宇