# HG changeset patch # User Sebastien Jodogne # Date 1618405731 -7200 # Node ID 3bc442765b88066c88f32e95193ea03e322a43de # Parent 33fa478c119a1fd2df440a21442b2efe0b3ea33a new configuration option: "IndexConnectionsCount" diff -r 33fa478c119a -r 3bc442765b88 Framework/Plugins/DatabaseBackendAdapterV3.cpp --- 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) { diff -r 33fa478c119a -r 3bc442765b88 Framework/Plugins/IndexBackend.cpp --- 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; } diff -r 33fa478c119a -r 3bc442765b88 MySQL/NEWS --- 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 diff -r 33fa478c119a -r 3bc442765b88 MySQL/Plugins/IndexPlugin.cpp --- 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) { diff -r 33fa478c119a -r 3bc442765b88 PostgreSQL/NEWS --- 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 diff -r 33fa478c119a -r 3bc442765b88 PostgreSQL/Plugins/IndexPlugin.cpp --- 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) {