Mercurial > hg > orthanc-object-storage
comparison Common/StoragePlugin.cpp @ 120:12ea59c97c40
sync orthanc folder + show timings + EnableAwsSdkLogs
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 21 Nov 2023 09:46:51 +0100 |
parents | 91aeaecf7100 |
children | addccb7ad900 82ab647f7e73 |
comparison
equal
deleted
inserted
replaced
115:ca68456d789a | 120:12ea59c97c40 |
---|---|
86 int64_t size, | 86 int64_t size, |
87 OrthancPluginContentType type) | 87 OrthancPluginContentType type) |
88 { | 88 { |
89 try | 89 try |
90 { | 90 { |
91 Orthanc::Toolbox::ElapsedTimer timer; | |
91 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); | 92 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
92 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled)); | 93 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled)); |
93 | 94 |
94 if (cryptoEnabled) | 95 if (cryptoEnabled) |
95 { | 96 { |
109 } | 110 } |
110 else | 111 else |
111 { | 112 { |
112 writer->Write(reinterpret_cast<const char*>(content), size); | 113 writer->Write(reinterpret_cast<const char*>(content), size); |
113 } | 114 } |
115 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": created attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, size) + ")"); | |
114 } | 116 } |
115 catch (StoragePluginException& ex) | 117 catch (StoragePluginException& ex) |
116 { | 118 { |
117 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what()); | 119 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what()); |
118 return OrthancPluginErrorCode_StorageAreaPlugin; | 120 return OrthancPluginErrorCode_StorageAreaPlugin; |
131 { | 133 { |
132 assert(!cryptoEnabled); | 134 assert(!cryptoEnabled); |
133 | 135 |
134 try | 136 try |
135 { | 137 { |
138 Orthanc::Toolbox::ElapsedTimer timer; | |
136 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); | 139 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
137 | 140 |
138 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); | 141 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); |
139 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart); | 142 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart); |
140 | 143 |
144 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read range of attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, target->size) + ")"); | |
141 return OrthancPluginErrorCode_Success; | 145 return OrthancPluginErrorCode_Success; |
142 } | 146 } |
143 catch (StoragePluginException& ex) | 147 catch (StoragePluginException& ex) |
144 { | 148 { |
145 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what())); | 149 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what())); |
179 const char* uuid, | 183 const char* uuid, |
180 OrthancPluginContentType type) | 184 OrthancPluginContentType type) |
181 { | 185 { |
182 try | 186 try |
183 { | 187 { |
188 Orthanc::Toolbox::ElapsedTimer timer; | |
184 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); | 189 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
185 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); | 190 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); |
186 | 191 |
187 size_t fileSize = reader->GetSize(); | 192 size_t fileSize = reader->GetSize(); |
188 size_t size; | 193 size_t size; |
225 } | 230 } |
226 else | 231 else |
227 { | 232 { |
228 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize); | 233 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize); |
229 } | 234 } |
235 | |
236 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read whole attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, fileSize) + ")"); | |
230 } | 237 } |
231 catch (StoragePluginException& ex) | 238 catch (StoragePluginException& ex) |
232 { | 239 { |
233 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what()); | 240 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what()); |
234 return OrthancPluginErrorCode_StorageAreaPlugin; | 241 return OrthancPluginErrorCode_StorageAreaPlugin; |