changeset 253:3bc442765b88

new configuration option: "IndexConnectionsCount"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Apr 2021 15:08:51 +0200
parents 33fa478c119a
children 8a4ce70f456a
files Framework/Plugins/DatabaseBackendAdapterV3.cpp Framework/Plugins/IndexBackend.cpp MySQL/NEWS MySQL/Plugins/IndexPlugin.cpp PostgreSQL/NEWS PostgreSQL/Plugins/IndexPlugin.cpp
diffstat 6 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Wed Apr 14 13:33:48 2021 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Wed Apr 14 15:08:51 2021 +0200
@@ -117,7 +117,8 @@
     {
       if (countConnections == 0)
       {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange,
+                                        "There must be a non-zero number of connections to the database");
       }
       else if (backend == NULL)
       {
--- a/Framework/Plugins/IndexBackend.cpp	Wed Apr 14 13:33:48 2021 +0200
+++ b/Framework/Plugins/IndexBackend.cpp	Wed Apr 14 15:08:51 2021 +0200
@@ -2459,6 +2459,9 @@
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
     if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1)
     {
+      LOG(WARNING) << "The index plugin will use " << countConnections << " connection(s) to the database, "
+                   << "and will retry up to " << maxDatabaseRetries << " time(s) in the case of a collision";
+      
       OrthancDatabases::DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries);
       hasLoadedV3 = true;
     }
--- a/MySQL/NEWS	Wed Apr 14 13:33:48 2021 +0200
+++ b/MySQL/NEWS	Wed Apr 14 15:08:51 2021 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* New option "IndexConnectionsCount" to control how many simultaneous
+  connections to the MySQL database are used by the index plugin
 * Support of multiple readers/writers, by handling retries from Orthanc SDK 1.9.2
 * Support of range reads for the storage area, from Orthanc SDK 1.9.0
 
--- a/MySQL/Plugins/IndexPlugin.cpp	Wed Apr 14 13:33:48 2021 +0200
+++ b/MySQL/Plugins/IndexPlugin.cpp	Wed Apr 14 15:08:51 2021 +0200
@@ -62,12 +62,12 @@
 
     try
     {
-      const size_t countConnections = 5;  // TODO - PARAMETER
-      const unsigned int maxDatabaseRetries = 10;  // TODO - PARAMETER
-      
+      const size_t countConnections = mysql.GetUnsignedIntegerValue("IndexConnectionsCount", 1);
+
       OrthancDatabases::MySQLParameters parameters(mysql, configuration);
       OrthancDatabases::IndexBackend::Register(
-        new OrthancDatabases::MySQLIndex(context, parameters), countConnections, maxDatabaseRetries);
+        new OrthancDatabases::MySQLIndex(context, parameters), countConnections,
+        parameters.GetMaxConnectionRetries());
     }
     catch (Orthanc::OrthancException& e)
     {
--- a/PostgreSQL/NEWS	Wed Apr 14 13:33:48 2021 +0200
+++ b/PostgreSQL/NEWS	Wed Apr 14 15:08:51 2021 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* New option "IndexConnectionsCount" to control how many simultaneous
+  connections to the PostgreSQL database are used by the index plugin
 * Support of multiple readers/writers, by handling retries from Orthanc SDK 1.9.2
 * Support of range reads for the storage area, from Orthanc SDK 1.9.0
 
--- a/PostgreSQL/Plugins/IndexPlugin.cpp	Wed Apr 14 13:33:48 2021 +0200
+++ b/PostgreSQL/Plugins/IndexPlugin.cpp	Wed Apr 14 15:08:51 2021 +0200
@@ -56,12 +56,12 @@
 
     try
     {
-      const size_t countConnections = 5;  // TODO - PARAMETER
-      const unsigned int maxDatabaseRetries = 10;  // TODO - PARAMETER
-      
+      const size_t countConnections = postgresql.GetUnsignedIntegerValue("IndexConnectionsCount", 1);
+
       OrthancDatabases::PostgreSQLParameters parameters(postgresql);
       OrthancDatabases::IndexBackend::Register(
-        new OrthancDatabases::PostgreSQLIndex(context, parameters), countConnections, maxDatabaseRetries);
+        new OrthancDatabases::PostgreSQLIndex(context, parameters), countConnections,
+        parameters.GetMaxConnectionRetries());
     }
     catch (Orthanc::OrthancException& e)
     {