Mercurial > hg > orthanc
changeset 376:2cef9c2d4148
separate path for SQLite index, manual loading of external dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 11:13:51 +0200 |
parents | d1ea72f1c967 |
children | 1da6ec6038f5 |
files | NEWS OrthancServer/DicomProtocol/DicomServer.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h OrthancServer/main.cpp Resources/Configuration.json |
diffstat | 6 files changed, 60 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue Apr 16 17:33:44 2013 +0200 +++ b/NEWS Wed Apr 17 11:13:51 2013 +0200 @@ -2,6 +2,9 @@ =============================== * Support of RGB images +* Fix of store SCU in release builds +* Possibility to store the SQLite index at another place than the + DICOM instances Version 0.5.0 (2013/01/31)
--- a/OrthancServer/DicomProtocol/DicomServer.cpp Tue Apr 16 17:33:44 2013 +0200 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Wed Apr 17 11:13:51 2013 +0200 @@ -39,9 +39,14 @@ #include "EmbeddedResources.h" #include <boost/thread.hpp> +#include <boost/filesystem.hpp> #include <dcmtk/dcmdata/dcdict.h> #include <glog/logging.h> +#if defined(__linux) +#include <cstdlib> +#endif + namespace Orthanc { @@ -70,17 +75,31 @@ } + static void LoadExternalDictionary(DcmDataDictionary& dictionary, + const std::string& directory, + const std::string& filename) + { + boost::filesystem::path p = directory; + p = p / filename; + + if (!dictionary.loadDictionary(p.string().c_str())) + { + throw OrthancException(ErrorCode_InternalError); + } + } + + void DicomServer::ServerThread(DicomServer* server) { /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ dcmDisableGethostbyaddr.set(OFTrue); -#if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 - LOG(WARNING) << "Loading the embedded dictionaries"; dcmDataDict.clear(); DcmDataDictionary& d = dcmDataDict.wrlock(); +#if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 + LOG(WARNING) << "Loading the embedded dictionaries"; /** * Do not load DICONDE dictionary, it breaks the other tags. The * command "strace storescu 2>&1 |grep dic" shows that DICONDE @@ -90,8 +109,24 @@ LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICOM); LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_PRIVATE); + +#elif defined(__linux) + std::string path = "/usr/share/dcmtk"; + + const char* env = std::getenv(DCM_DICT_ENVIRONMENT_VARIABLE); + if (env != NULL) + { + path = std::string(env); + } + + LoadExternalDictionary(d, path, "dicom.dic"); + LoadExternalDictionary(d, path, "private.dic"); + +#else +#error Support your platform here +#endif + dcmDataDict.unlock(); -#endif /* make sure data dictionary is loaded */ if (!dcmDataDict.isDictionaryLoaded())
--- a/OrthancServer/ServerContext.cpp Tue Apr 16 17:33:44 2013 +0200 +++ b/OrthancServer/ServerContext.cpp Wed Apr 17 11:13:51 2013 +0200 @@ -52,9 +52,10 @@ namespace Orthanc { - ServerContext::ServerContext(const boost::filesystem::path& path) : - storage_(path.string()), - index_(*this, path.string()), + ServerContext::ServerContext(const boost::filesystem::path& storagePath, + const boost::filesystem::path& indexPath) : + storage_(storagePath.string()), + index_(*this, indexPath.string()), accessor_(storage_), provider_(*this), dicomCache_(provider_, DICOM_CACHE_SIZE)
--- a/OrthancServer/ServerContext.h Tue Apr 16 17:33:44 2013 +0200 +++ b/OrthancServer/ServerContext.h Wed Apr 17 11:13:51 2013 +0200 @@ -71,7 +71,8 @@ MemoryCache dicomCache_; public: - ServerContext(const boost::filesystem::path& path); + ServerContext(const boost::filesystem::path& storagePath, + const boost::filesystem::path& indexPath); ServerIndex& GetIndex() {
--- a/OrthancServer/main.cpp Tue Apr 16 17:33:44 2013 +0200 +++ b/OrthancServer/main.cpp Wed Apr 17 11:13:51 2013 +0200 @@ -210,7 +210,12 @@ } boost::filesystem::path storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); - ServerContext context(storageDirectory); + boost::filesystem::path indexDirectory = GetGlobalStringParameter("IndexDirectory", storageDirectory.string()); + ServerContext context(storageDirectory, indexDirectory); + + LOG(WARNING) << "Storage directory: " << storageDirectory; + LOG(WARNING) << "Index directory: " << indexDirectory; + context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); try
--- a/Resources/Configuration.json Tue Apr 16 17:33:44 2013 +0200 +++ b/Resources/Configuration.json Wed Apr 17 11:13:51 2013 +0200 @@ -7,9 +7,15 @@ // displayed in Orthanc Explorer and at the URI "/system". "Name" : "MyOrthanc", - // Path to the directory that holds the database + // Path to the directory that holds the heavyweight files + // (i.e. the raw DICOM instances) "StorageDirectory" : "OrthancStorage", + // Path to the directory that holds the SQLite index (if unset, + // the value of StorageDirectory is used). This index could be + // stored on a RAM-drive or a SSD device for performance reasons. + "IndexDirectory" : "OrthancStorage", + // Enable the transparent compression of the DICOM instances "StorageCompression" : false,