comparison OrthancServer/ServerIndex.cpp @ 2987:96089d1aba4d

New "DicomDiskSize" and "DicomUncompressedSize" fields in statistics about resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Dec 2018 10:33:58 +0100
parents 4767d36679ed
children 0e1755e5efd0
comparison
equal deleted inserted replaced
2986:b1ba0a8311b5 2987:96089d1aba4d
1777 boost::mutex::scoped_lock lock(mutex_); 1777 boost::mutex::scoped_lock lock(mutex_);
1778 db_.ClearExportedResources(); 1778 db_.ClearExportedResources();
1779 } 1779 }
1780 1780
1781 1781
1782 void ServerIndex::GetStatisticsInternal(/* out */ uint64_t& compressedSize, 1782 void ServerIndex::GetStatisticsInternal(/* out */ uint64_t& diskSize,
1783 /* out */ uint64_t& uncompressedSize, 1783 /* out */ uint64_t& uncompressedSize,
1784 /* out */ unsigned int& countStudies, 1784 /* out */ unsigned int& countStudies,
1785 /* out */ unsigned int& countSeries, 1785 /* out */ unsigned int& countSeries,
1786 /* out */ unsigned int& countInstances, 1786 /* out */ unsigned int& countInstances,
1787 /* out */ uint64_t& dicomDiskSize,
1788 /* out */ uint64_t& dicomUncompressedSize,
1787 /* in */ int64_t id, 1789 /* in */ int64_t id,
1788 /* in */ ResourceType type) 1790 /* in */ ResourceType type)
1789 { 1791 {
1790 std::stack<int64_t> toExplore; 1792 std::stack<int64_t> toExplore;
1791 toExplore.push(id); 1793 toExplore.push(id);
1792 1794
1793 countInstances = 0; 1795 countInstances = 0;
1794 countSeries = 0; 1796 countSeries = 0;
1795 countStudies = 0; 1797 countStudies = 0;
1796 compressedSize = 0; 1798 diskSize = 0;
1797 uncompressedSize = 0; 1799 uncompressedSize = 0;
1800 dicomDiskSize = 0;
1801 dicomUncompressedSize = 0;
1798 1802
1799 while (!toExplore.empty()) 1803 while (!toExplore.empty())
1800 { 1804 {
1801 // Get the internal ID of the current resource 1805 // Get the internal ID of the current resource
1802 int64_t resource = toExplore.top(); 1806 int64_t resource = toExplore.top();
1811 it = f.begin(); it != f.end(); ++it) 1815 it = f.begin(); it != f.end(); ++it)
1812 { 1816 {
1813 FileInfo attachment; 1817 FileInfo attachment;
1814 if (db_.LookupAttachment(attachment, resource, *it)) 1818 if (db_.LookupAttachment(attachment, resource, *it))
1815 { 1819 {
1816 compressedSize += attachment.GetCompressedSize(); 1820 if (attachment.GetContentType() == FileContentType_Dicom)
1821 {
1822 dicomDiskSize += attachment.GetCompressedSize();
1823 dicomUncompressedSize += attachment.GetUncompressedSize();
1824 }
1825
1826 diskSize += attachment.GetCompressedSize();
1817 uncompressedSize += attachment.GetUncompressedSize(); 1827 uncompressedSize += attachment.GetUncompressedSize();
1818 } 1828 }
1819 } 1829 }
1820 1830
1821 if (thisType == ResourceType_Instance) 1831 if (thisType == ResourceType_Instance)
1873 { 1883 {
1874 throw OrthancException(ErrorCode_UnknownResource); 1884 throw OrthancException(ErrorCode_UnknownResource);
1875 } 1885 }
1876 1886
1877 uint64_t uncompressedSize; 1887 uint64_t uncompressedSize;
1878 uint64_t compressedSize; 1888 uint64_t diskSize;
1889 uint64_t dicomUncompressedSize;
1890 uint64_t dicomDiskSize;
1879 unsigned int countStudies; 1891 unsigned int countStudies;
1880 unsigned int countSeries; 1892 unsigned int countSeries;
1881 unsigned int countInstances; 1893 unsigned int countInstances;
1882 GetStatisticsInternal(compressedSize, uncompressedSize, countStudies, 1894 GetStatisticsInternal(diskSize, uncompressedSize, countStudies,
1883 countSeries, countInstances, top, type); 1895 countSeries, countInstances, dicomDiskSize, dicomUncompressedSize, top, type);
1884 1896
1885 target = Json::objectValue; 1897 target = Json::objectValue;
1886 target["DiskSize"] = boost::lexical_cast<std::string>(compressedSize); 1898 target["DiskSize"] = boost::lexical_cast<std::string>(diskSize);
1887 target["DiskSizeMB"] = static_cast<unsigned int>(compressedSize / MEGA_BYTES); 1899 target["DiskSizeMB"] = static_cast<unsigned int>(diskSize / MEGA_BYTES);
1888 target["UncompressedSize"] = boost::lexical_cast<std::string>(uncompressedSize); 1900 target["UncompressedSize"] = boost::lexical_cast<std::string>(uncompressedSize);
1889 target["UncompressedSizeMB"] = static_cast<unsigned int>(uncompressedSize / MEGA_BYTES); 1901 target["UncompressedSizeMB"] = static_cast<unsigned int>(uncompressedSize / MEGA_BYTES);
1902
1903 target["DicomDiskSize"] = boost::lexical_cast<std::string>(dicomDiskSize);
1904 target["DicomDiskSizeMB"] = static_cast<unsigned int>(dicomDiskSize / MEGA_BYTES);
1905 target["DicomUncompressedSize"] = boost::lexical_cast<std::string>(dicomUncompressedSize);
1906 target["DicomUncompressedSizeMB"] = static_cast<unsigned int>(dicomUncompressedSize / MEGA_BYTES);
1890 1907
1891 switch (type) 1908 switch (type)
1892 { 1909 {
1893 // Do NOT add "break" below this point! 1910 // Do NOT add "break" below this point!
1894 case ResourceType_Patient: 1911 case ResourceType_Patient:
1905 break; 1922 break;
1906 } 1923 }
1907 } 1924 }
1908 1925
1909 1926
1910 void ServerIndex::GetStatistics(/* out */ uint64_t& compressedSize, 1927 void ServerIndex::GetStatistics(/* out */ uint64_t& diskSize,
1911 /* out */ uint64_t& uncompressedSize, 1928 /* out */ uint64_t& uncompressedSize,
1912 /* out */ unsigned int& countStudies, 1929 /* out */ unsigned int& countStudies,
1913 /* out */ unsigned int& countSeries, 1930 /* out */ unsigned int& countSeries,
1914 /* out */ unsigned int& countInstances, 1931 /* out */ unsigned int& countInstances,
1932 /* out */ uint64_t& dicomDiskSize,
1933 /* out */ uint64_t& dicomUncompressedSize,
1915 const std::string& publicId) 1934 const std::string& publicId)
1916 { 1935 {
1917 boost::mutex::scoped_lock lock(mutex_); 1936 boost::mutex::scoped_lock lock(mutex_);
1918 1937
1919 ResourceType type; 1938 ResourceType type;
1921 if (!db_.LookupResource(top, type, publicId)) 1940 if (!db_.LookupResource(top, type, publicId))
1922 { 1941 {
1923 throw OrthancException(ErrorCode_UnknownResource); 1942 throw OrthancException(ErrorCode_UnknownResource);
1924 } 1943 }
1925 1944
1926 GetStatisticsInternal(compressedSize, uncompressedSize, countStudies, 1945 GetStatisticsInternal(diskSize, uncompressedSize, countStudies,
1927 countSeries, countInstances, top, type); 1946 countSeries, countInstances, dicomDiskSize,
1947 dicomUncompressedSize, top, type);
1928 } 1948 }
1929 1949
1930 1950
1931 void ServerIndex::UnstableResourcesMonitorThread(ServerIndex* that, 1951 void ServerIndex::UnstableResourcesMonitorThread(ServerIndex* that,
1932 unsigned int threadSleep) 1952 unsigned int threadSleep)