[mapguide-commits] r6888 - in branches/2.4/MgDev/Desktop/MgDesktop: . Services Services/Feature System
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 11 00:39:52 PDT 2012
Author: jng
Date: 2012-07-11 00:39:52 -0700 (Wed, 11 Jul 2012)
New Revision: 6888
Modified:
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/ResourceService.cpp
branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
Log:
#2060: Add internal traces for various parts of the mg-desktop code, namely: connection pooling, content/data path resolution and MgdFeatureService::SelectFeaturesInternal (which all select operations funnel into)
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-07-10 16:57:56 UTC (rev 6887)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp 2012-07-11 07:39:52 UTC (rev 6888)
@@ -41,6 +41,11 @@
FdoIConnection* MgFdoConnectionPool::GetConnection(MgResourceIdentifier* featureSourceId)
{
+ FdoPtr<FdoIConnection> conn;
+ MG_FEATURE_SERVICE_TRY()
+
+ CHECK_FEATURE_SOURCE_ARGUMENT(featureSourceId, L"MgFdoConnectionPool::GetConnection");
+
ScopedLock scc(g_pool.mutex);
STRING fsIdStr = featureSourceId->ToString();
ConnPool::iterator it = g_pool.freePool.find(fsIdStr);
@@ -48,15 +53,17 @@
MdfModel::FeatureSource* fs = MgFdoConnectionUtil::GetFeatureSource(featureSourceId);
STRING providerName = MgFdoConnectionUtil::ParseNonQualifiedProviderName(fs->GetProvider());
+ bool bNewInstance = false;
+
//no connection for this string in the pool -- make one
if (!g_bPoolingEnabled || it == g_pool.freePool.end() || it->second.size() == 0)
{
- FdoPtr<FdoIConnection> conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
+ conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W)\n"), featureSourceId->ToString().c_str()));
#endif
conn->Open();
- return conn.Detach();
+ bNewInstance = true;
}
else
{
@@ -69,33 +76,46 @@
#endif
if (FdoConnectionState_Closed == rec._conn->GetConnectionState())
rec._conn->Open();
- return rec._conn;
+ conn = rec._conn;
+ bNewInstance = false;
}
else
{
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("Provider for (%W) is not poolable\n"), featureSourceId->ToString().c_str()));
#endif
- FdoPtr<FdoIConnection> conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
+ conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W)\n"), featureSourceId->ToString().c_str()));
#endif
conn->Open();
- return conn.Detach();
+ bNewInstance = true;
}
}
- return NULL;
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::GetConnection", mgStackParams);
+ logDetail.AddResourceIdentifier(L"featureSourceId", featureSourceId);
+ logDetail.AddBool(L"IsNewInstance", bNewInstance);
+ logDetail.Create();
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::GetConnection")
+
+ return conn.Detach();
}
void MgFdoConnectionPool::ReturnConnection(MgFeatureConnection* conn)
{
+ MG_FEATURE_SERVICE_TRY()
+
ScopedLock scc(g_pool.mutex);
STRING providerName = conn->GetProviderName();
FdoPtr<FdoIConnection> fdoConn = conn->GetConnection();
Ptr<MgResourceIdentifier> fsId = conn->GetFeatureSource();
STRING fsIdStr = fsId->ToString();
+ bool bReturned = false;
+ bool bProviderExcluded = false;
+
//Only return it to pool if pooling enabled. Connections returned to the pool stay open otherwise close them
if (g_bPoolingEnabled)
{
@@ -107,6 +127,7 @@
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Returned] (%W) %d in cache\n"), fsIdStr.c_str(), vec.size()));
#endif
+ bReturned = true;
}
else
{
@@ -114,6 +135,7 @@
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Provider excluded from pooling\n"), fsIdStr.c_str()));
#endif
+ bProviderExcluded = true;
}
}
else
@@ -123,10 +145,20 @@
ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Connection Pooling disabled\n"), fsIdStr.c_str()));
#endif
}
+
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::ReturnConnection", mgStackParams);
+ logDetail.AddResourceIdentifier(L"FeatureSource", fsId);
+ logDetail.AddBool(L"ReturnedToPool", bReturned);
+ logDetail.AddBool(L"ProviderExcluded", bProviderExcluded);
+ logDetail.Create();
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::ReturnConnection")
}
void MgFdoConnectionPool::Initialize(MgConfiguration* pConfiguration)
{
+ MG_FEATURE_SERVICE_TRY()
+
bool bDataConnectionPoolEnabled = MgConfigProperties::DefaultFeatureServicePropertyDataConnectionPoolEnabled;
INT32 nDataConnectionPoolSize = MgConfigProperties::DefaultFeatureServicePropertyDataConnectionPoolSize;
STRING excludedProviders = MgConfigProperties::DefaultFeatureServicePropertyDataConnectionPoolExcludedProviders;
@@ -165,10 +197,21 @@
{
g_excludedProviders = new MgStringCollection();
}
+
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::Initialize", mgStackParams);
+ logDetail.AddBool(L"PoolingEnabled", g_bPoolingEnabled);
+ logDetail.AddString(L"ExcludedProviders", excludedProviders);
+ logDetail.Create();
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::Initialize")
}
void MgFdoConnectionPool::Cleanup()
{
+ MG_FEATURE_SERVICE_TRY()
+
+ MG_LOG_TRACE_ENTRY(L"MgFdoConnectionPool::Cleanup()");
+
ScopedLock scc(g_pool.mutex);
for (ConnPool::iterator it = g_pool.freePool.begin(); it != g_pool.freePool.end(); ++it)
@@ -183,12 +226,22 @@
it->second.pop_back();
}
}
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::Cleanup")
}
void MgFdoConnectionPool::PurgeCachedConnections(MgResourceIdentifier* resId)
{
+ if (NULL == resId)
+ return;
+
+ if (MgResourceType::FeatureSource != resId->GetResourceType())
+ return;
+
ScopedLock scc(g_pool.mutex);
+ MG_FEATURE_SERVICE_TRY()
+
STRING fsIdStr = resId->ToString();
ConnPool::iterator it = g_pool.freePool.find(fsIdStr);
if (it != g_pool.freePool.end() && it->second.size() > 0)
@@ -204,11 +257,25 @@
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Purge]: (%W) %d purged\n"), fsIdStr.c_str(), purged));
#endif
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::PurgeCachedConnections", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resId", resId);
+ logDetail.AddInt32(L"purgedConnections", purged);
+ logDetail.Create();
}
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::PurgeCachedConnections")
}
void MgFdoConnectionPool::PurgeCachedConnectionsUnderFolder(MgResourceIdentifier* resId)
{
+ if (NULL == resId)
+ return;
+
+ if (MgResourceType::Folder != resId->GetResourceType())
+ return;
+
+ MG_FEATURE_SERVICE_TRY()
+
ScopedLock scc(g_pool.mutex);
STRING fsIdStr = resId->ToString();
@@ -234,6 +301,13 @@
#ifdef DEBUG_FDO_CONNECTION_POOL
ACE_DEBUG((LM_INFO, ACE_TEXT("[Purge]: (%W) %d purged\n"), fsIdStr.c_str(), purged));
#endif
+
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::PurgeCachedConnectionsUnderFolder", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resId", resId);
+ logDetail.AddInt32(L"purgedConnections", purged);
+ logDetail.Create();
+
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::PurgeCachedConnectionsUnderFolder")
}
bool MgFdoConnectionPool::StringStartsWith(CREFSTRING haystack, CREFSTRING needle)
Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp 2012-07-10 16:57:56 UTC (rev 6887)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp 2012-07-11 07:39:52 UTC (rev 6888)
@@ -6,6 +6,15 @@
FdoIConnection* MgFdoConnectionUtil::CreateConnection(CREFSTRING providerName, CREFSTRING connectionString)
{
+ FdoPtr<FdoIConnection> conn;
+
+ MG_FEATURE_SERVICE_TRY()
+
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionUtil::CreateConnection", mgStackParams);
+ logDetail.AddString(L"providerName", providerName);
+ logDetail.AddString(L"connectionString", connectionString);
+ logDetail.Create();
+
Ptr<MgServiceFactory> fact = new MgServiceFactory();
Ptr<MgdResourceService> resSvc = static_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
FdoPtr<FdoProviderNameTokens> tokens = FdoProviderNameTokens::Create(providerName.c_str());
@@ -19,7 +28,7 @@
providerNoVersion += (FdoString*)local->GetString();
FdoPtr<IConnectionManager> connMgr = FdoFeatureAccessManager::GetConnectionManager();
- FdoPtr<FdoIConnection> conn = connMgr->CreateConnection(providerNoVersion.c_str());
+ conn = connMgr->CreateConnection(providerNoVersion.c_str());
//Some providers may be sensitive to being assigned an empty string
if (!connectionString.empty())
@@ -27,11 +36,17 @@
conn->SetConnectionString(connectionString.c_str());
}
+ MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionUtil::CreateConnection")
+
return conn.Detach();
}
FdoIConnection* MgFdoConnectionUtil::CreateConnection(MgResourceIdentifier* resource)
{
+ FdoPtr<FdoIConnection> conn;
+
+ MG_FEATURE_SERVICE_TRY()
+
CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgFdoConnectionUtil::CreateConnection");
Ptr<MgServiceFactory> fact = new MgServiceFactory();
Ptr<MgdResourceService> resSvc = static_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
@@ -45,10 +60,6 @@
STRING provider = (STRING)fs->GetProvider();
STRING configDoc = (STRING)fs->GetConfigurationDocument();
- FdoPtr<FdoIConnection> conn;
-
- MG_FEATURE_SERVICE_TRY()
-
FdoPtr<IConnectionManager> connMgr = FdoFeatureAccessManager::GetConnectionManager();
FdoPtr<FdoProviderNameTokens> tokens = FdoProviderNameTokens::Create(provider.c_str());
@@ -79,6 +90,10 @@
dict->SetProperty(n.c_str(), v.c_str());
}
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionUtil::CreateConnection", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resource", resource);
+ logDetail.Create();
+
FdoPtr<FdoIConnectionCapabilities> connCaps = conn->GetConnectionCapabilities();
if (connCaps->SupportsConfiguration() && !configDoc.empty())
{
Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp 2012-07-10 16:57:56 UTC (rev 6887)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureService.cpp 2012-07-11 07:39:52 UTC (rev 6888)
@@ -2509,6 +2509,13 @@
Ptr<MgFeatureReader> reader;
MG_FEATURE_SERVICE_TRY()
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgdFeatureService::SelectFeaturesInternal", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resource", resource);
+ logDetail.AddString(L"className", className);
+ logDetail.AddString(L"coordinateSystem", coordinateSystem);
+ logDetail.AddBool(L"withLock", withLock);
+ logDetail.AddBool(L"asScrollable", asScrollable);
+
Ptr<MgFeatureConnection> connWrap = new MgFeatureConnection(resource);
{
FdoPtr<FdoIConnection> conn = connWrap->GetConnection();
@@ -2657,6 +2664,8 @@
if (combineFilter != NULL)
{
select->SetFilter(combineFilter);
+ STRING filterText = combineFilter->ToString();
+ logDetail.AddString(L"Filter", filterText);
}
if (asScrollable)
@@ -2669,6 +2678,10 @@
// Check if a feature join is only a calculation
bool bFeatureCalculation = FindFeatureCalculation(resource, className);
+ logDetail.AddBool(L"IsFeatureJoinClass", bFeatureJoinProperties);
+ logDetail.AddBool(L"IsCalculationClass", bFeatureCalculation);
+ logDetail.Create();
+
if (bFeatureJoinProperties)
{
FdoPtr<FdoFilter> fdoFilter = select->GetFilter();
@@ -2787,8 +2800,14 @@
Ptr<MgFeatureConnection> leftConn = new MgFeatureConnection(featureSourceIdentifier);
STRING fsIdStr = featureSourceIdentifier->ToString();
+ bool bSupportsFdoJoinOptimization = SupportsFdoJoins(leftConn, extension);
+
+ MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgdFeatureService::SelectFeaturesJoined", mgStackParams);
+ logDetail.AddBool(L"SupportsFdoJoinOptimization", bSupportsFdoJoinOptimization);
+ logDetail.Create();
+
// See if we can use the FDO join optimization
- if (SupportsFdoJoins(leftConn, extension))
+ if (bSupportsFdoJoinOptimization)
{
#ifdef DEBUG_FDOJOIN
STRING fsIdStr = featureSourceIdentifier->ToString();
@@ -3036,7 +3055,7 @@
// Prepare and Execute Query
query->Prepare();
-
+
// Search the filter to see if it contains the extension name
// If the extension name is not found it means that the filter involves attribute(s) only from the primary
if(NULL != filter)
Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp 2012-07-10 16:57:56 UTC (rev 6887)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp 2012-07-11 07:39:52 UTC (rev 6888)
@@ -112,7 +112,13 @@
STRING MgdResourceService::ResolveContentPath(MgResourceIdentifier* resId)
{
- STRING path = GetContentDirectory(resId);
+ STRING path;
+
+ MG_RESOURCE_SERVICE_TRY()
+
+ CHECKARGUMENTNULL(resId, L"MgdResourceService::ResolveContentPath");
+
+ path = GetContentDirectory(resId);
STRING type = resId->GetResourceType();
if (MgResourceType::Folder != type)
{
@@ -122,15 +128,25 @@
path += L".";
path += type;
}
+
+ MgLogDetail logDetail(MgServiceType::ResourceService, MgLogDetail::InternalTrace, L"MgdResourceService::ResolveContentPath", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resId", resId);
+ logDetail.AddString(L"resolvedPath", path);
+ logDetail.Create();
+
+ MG_RESOURCE_SERVICE_CATCH_AND_THROW(L"MgdResourceService::ResolveContentPath")
+
return path;
}
STRING MgdResourceService::ResolveDataPath(MgResourceIdentifier* resId)
{
+ STRING cntPath;
+ MG_RESOURCE_SERVICE_TRY()
+
CHECKARGUMENTNULL(resId, L"MgdResourceService::ResolveDataPath");
STRING type = resId->GetRepositoryType();
- STRING cntPath;
if (type == L"Library")
{
// [ROOT]/Data/[path]/[name].[resourceType]/
@@ -152,8 +168,6 @@
cntPath += type;
}
MgFileUtil::AppendSlashToEndOfPath(cntPath);
-
- return cntPath;
}
else if (type == L"Session")
{
@@ -180,13 +194,21 @@
cntPath += type;
}
MgFileUtil::AppendSlashToEndOfPath(cntPath);
-
- return cntPath;
}
else
{
throw new MgInvalidArgumentException(L"MgdResourceService::ResolveDataPath", __LINE__, __WFILE__, NULL, L"", NULL);
}
+
+ MgLogDetail logDetail(MgServiceType::ResourceService, MgLogDetail::InternalTrace, L"MgdResourceService::ResolveDataPath", mgStackParams);
+ logDetail.AddResourceIdentifier(L"resId", resId);
+ logDetail.AddString(L"repositoryType", type);
+ logDetail.AddString(L"resolvedPath", cntPath);
+ logDetail.Create();
+
+ MG_RESOURCE_SERVICE_CATCH_AND_THROW(L"MgdResourceService::ResolveDataPath")
+
+ return cntPath;
}
void MgdResourceService::ApplyResourcePackage(MgByteReader* packageStream)
Modified: branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp 2012-07-10 16:57:56 UTC (rev 6887)
+++ branches/2.4/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp 2012-07-11 07:39:52 UTC (rev 6888)
@@ -19,11 +19,6 @@
MgConfiguration* pConfiguration = MgConfiguration::GetInstance();
pConfiguration->LoadConfiguration(configFile);
- MgServiceFactory::Initialize();
-
- // Init the Fdo Connection Pool
- MgFdoConnectionPool::Initialize(pConfiguration);
-
// Get the resources path.
STRING resourcesPath;
pConfiguration->GetStringValue(MgConfigProperties::GeneralPropertiesSection,
@@ -35,16 +30,21 @@
STRING defaultMessageLocale;
pConfiguration->GetStringValue(MgConfigProperties::GeneralPropertiesSection, MgConfigProperties::GeneralPropertyDefaultMessageLocale, defaultMessageLocale, MgConfigProperties::DefaultGeneralPropertyDefaultMessageLocale);
- //Init log manager
+ // Init log manager
MgLogManager* pLogManager = MgLogManager::GetInstance();
pLogManager->Initialize();
- //Init resources
+ MgServiceFactory::Initialize();
+
+ // Init the Fdo Connection Pool
+ MgFdoConnectionPool::Initialize(pConfiguration);
+
+ // Init resources
MgResources* pResources = MgResources::GetInstance();
pResources->Initialize(resourcesPath);
pResources->LoadResources(defaultMessageLocale);
- //Init FDO
+ // Init FDO
STRING fdoPath;
pConfiguration->GetStringValue(MgConfigProperties::GeneralPropertiesSection,
MgConfigProperties::GeneralPropertyFdoPath,
@@ -180,6 +180,10 @@
Ptr<MgdResourceService> resSvc = dynamic_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
resSvc->DeleteSessionFiles();
+ //This is important. Otherwise the process using this library will be left lingering
+ MgLogManager* pLogManager = MgLogManager::GetInstance();
+ pLogManager->StopLogThread();
+
XMLPlatformUtils::Terminate();
ACE::fini();
More information about the mapguide-commits
mailing list