|
PACS System 0.1.0
PACS DICOM system library
|
Hierarchical Storage Management for multi-tier DICOM storage. More...
#include <hsm_storage.h>


Public Member Functions | |
| hsm_storage (std::unique_ptr< storage_interface > hot_tier, std::unique_ptr< storage_interface > warm_tier, std::unique_ptr< storage_interface > cold_tier, const hsm_storage_config &config={}) | |
| Construct HSM storage with three tier backends. | |
| ~hsm_storage () override=default | |
| Destructor. | |
| hsm_storage (const hsm_storage &)=delete | |
| Non-copyable (contains mutex and unique_ptr) | |
| hsm_storage & | operator= (const hsm_storage &)=delete |
| hsm_storage (hsm_storage &&)=delete | |
| Non-movable (contains mutex) | |
| hsm_storage & | operator= (hsm_storage &&)=delete |
| auto | store (const core::dicom_dataset &dataset) -> VoidResult override |
| Store a DICOM dataset to the hot tier. | |
| auto | retrieve (std::string_view sop_instance_uid) -> Result< core::dicom_dataset > override |
| Retrieve a DICOM dataset by SOP Instance UID. | |
| auto | remove (std::string_view sop_instance_uid) -> VoidResult override |
| Remove a DICOM dataset from all tiers. | |
| auto | exists (std::string_view sop_instance_uid) const -> bool override |
| Check if a DICOM instance exists in any tier. | |
| auto | find (const core::dicom_dataset &query) -> Result< std::vector< core::dicom_dataset > > override |
| Find DICOM datasets matching query criteria across all tiers. | |
| auto | get_statistics () const -> storage_statistics override |
| Get combined storage statistics from all tiers. | |
| auto | verify_integrity () -> VoidResult override |
| Verify storage integrity across all tiers. | |
| auto | get_tier (std::string_view sop_instance_uid) const -> std::optional< storage_tier > |
| Get the current tier of an instance. | |
| auto | get_tier_metadata (std::string_view sop_instance_uid) const -> std::optional< tier_metadata > |
| Get tier metadata for an instance. | |
| auto | migrate (std::string_view sop_instance_uid, storage_tier target_tier) -> VoidResult |
| Manually migrate an instance to a different tier. | |
| auto | get_migration_candidates (storage_tier from_tier, storage_tier to_tier) const -> std::vector< tier_metadata > |
| Get instances eligible for migration. | |
| auto | run_migration_cycle () -> migration_result |
| Run a single migration cycle. | |
| auto | get_tier_policy () const -> tier_policy |
| Get the current tier policy. | |
| void | set_tier_policy (const tier_policy &policy) |
| Set the tier policy. | |
| auto | get_hsm_statistics () const -> hsm_statistics |
| Get HSM-specific statistics. | |
| auto | get_tier_storage (storage_tier tier) const -> storage_interface * |
| Get the storage backend for a specific tier. | |
Public Member Functions inherited from kcenon::pacs::storage::storage_interface | |
| virtual | ~storage_interface ()=default |
| Virtual destructor for proper polymorphic destruction. | |
| virtual auto | store_batch (const std::vector< core::dicom_dataset > &datasets) -> VoidResult |
| Store multiple DICOM datasets in a single operation. | |
| virtual auto | retrieve_batch (const std::vector< std::string > &sop_instance_uids) -> Result< std::vector< core::dicom_dataset > > |
| Retrieve multiple DICOM datasets by their SOP Instance UIDs. | |
Private Member Functions | |
| auto | find_tier (std::string_view sop_instance_uid) const -> std::optional< storage_tier > |
| Find which tier contains an instance. | |
| auto | get_storage (storage_tier tier) const -> storage_interface * |
| Get the storage backend for a tier. | |
| void | update_metadata (std::string_view sop_instance_uid, storage_tier tier, const core::dicom_dataset &dataset) |
| Update tier metadata after store/retrieve. | |
| void | update_access_time (std::string_view sop_instance_uid) |
| Update last access time for an instance. | |
| void | remove_metadata (std::string_view sop_instance_uid) |
| Remove tier metadata. | |
| auto | migrate_instance (std::string_view uid, storage_tier from_tier, storage_tier to_tier) -> VoidResult |
| Migrate a single instance between tiers. | |
Private Attributes | |
| std::unique_ptr< storage_interface > | hot_tier_ |
| Hot tier storage backend. | |
| std::unique_ptr< storage_interface > | warm_tier_ |
| Warm tier storage backend (may be nullptr) | |
| std::unique_ptr< storage_interface > | cold_tier_ |
| Cold tier storage backend (may be nullptr) | |
| hsm_storage_config | config_ |
| HSM configuration. | |
| std::unordered_map< std::string, tier_metadata > | metadata_index_ |
| Tier metadata index (SOP Instance UID -> metadata) | |
| std::shared_mutex | mutex_ |
| Mutex for thread-safe access. | |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::pacs::storage::storage_interface | |
| storage_interface ()=default | |
| Protected default constructor for derived classes. | |
| storage_interface (const storage_interface &)=delete | |
| Non-copyable. | |
| storage_interface & | operator= (const storage_interface &)=delete |
| storage_interface (storage_interface &&)=default | |
| Movable. | |
| storage_interface & | operator= (storage_interface &&)=default |
Hierarchical Storage Management for multi-tier DICOM storage.
Combines multiple storage backends (hot, warm, cold) into a unified hierarchical storage system. New data is stored in the hot tier by default, and automatically migrates to cooler tiers based on age and access patterns.
The retrieval process is transparent - the caller doesn't need to know which tier contains the data.
Thread Safety:
Definition at line 87 of file hsm_storage.h.
| kcenon::pacs::storage::hsm_storage::hsm_storage | ( | std::unique_ptr< storage_interface > | hot_tier, |
| std::unique_ptr< storage_interface > | warm_tier, | ||
| std::unique_ptr< storage_interface > | cold_tier, | ||
| const hsm_storage_config & | config = {} ) |
Construct HSM storage with three tier backends.
| hot_tier | Storage backend for hot tier (required) |
| warm_tier | Storage backend for warm tier (optional, can be nullptr) |
| cold_tier | Storage backend for cold tier (optional, can be nullptr) |
| config | HSM configuration |
| std::invalid_argument | if hot_tier is nullptr |
Definition at line 40 of file hsm_storage.cpp.
References hot_tier_.
|
overridedefault |
Destructor.
|
delete |
Non-copyable (contains mutex and unique_ptr)
|
delete |
Non-movable (contains mutex)
|
nodiscardoverridevirtual |
Check if a DICOM instance exists in any tier.
| sop_instance_uid | The unique identifier to check |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 137 of file hsm_storage.cpp.
|
nodiscardoverridevirtual |
Find DICOM datasets matching query criteria across all tiers.
Searches all tiers and combines results.
| query | The query dataset containing search criteria |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 142 of file hsm_storage.cpp.
|
nodiscardprivate |
Find which tier contains an instance.
| sop_instance_uid | The SOP Instance UID |
Definition at line 474 of file hsm_storage.cpp.
References kcenon::pacs::storage::cold, kcenon::pacs::storage::hot, and kcenon::pacs::storage::warm.
|
nodiscard |
Get HSM-specific statistics.
Definition at line 411 of file hsm_storage.cpp.
References kcenon::pacs::storage::hsm_statistics::cold, kcenon::pacs::storage::cold, kcenon::pacs::storage::hsm_statistics::hot, kcenon::pacs::storage::hot, kcenon::pacs::storage::tier_statistics::instance_count, metadata_index_, mutex_, kcenon::pacs::storage::tier_statistics::series_count, kcenon::pacs::storage::tier_statistics::study_count, kcenon::pacs::storage::tier_statistics::total_bytes, uid, kcenon::pacs::storage::hsm_statistics::warm, and kcenon::pacs::storage::warm.
|
nodiscard |
Get instances eligible for migration.
Returns instances that should be migrated based on the tier policy.
| from_tier | Source tier to check |
| to_tier | Target tier |
Definition at line 290 of file hsm_storage.cpp.
References uid.
|
nodiscardoverridevirtual |
Get combined storage statistics from all tiers.
Implements kcenon::pacs::storage::storage_interface.
Definition at line 166 of file hsm_storage.cpp.
References cold_tier_, hot_tier_, metadata_index_, mutex_, kcenon::pacs::storage::storage_statistics::series_count, kcenon::pacs::storage::storage_statistics::studies_count, kcenon::pacs::storage::storage_statistics::total_bytes, kcenon::pacs::storage::storage_statistics::total_instances, uid, and warm_tier_.
|
nodiscardprivate |
Get the storage backend for a tier.
| tier | The tier |
Definition at line 498 of file hsm_storage.cpp.
References kcenon::pacs::storage::cold, kcenon::pacs::storage::hot, and kcenon::pacs::storage::warm.
|
nodiscard |
Get the current tier of an instance.
| sop_instance_uid | The SOP Instance UID |
Definition at line 250 of file hsm_storage.cpp.
|
nodiscard |
Get tier metadata for an instance.
| sop_instance_uid | The SOP Instance UID |
Definition at line 260 of file hsm_storage.cpp.
|
nodiscard |
Get the current tier policy.
Definition at line 401 of file hsm_storage.cpp.
References config_, mutex_, and kcenon::pacs::storage::hsm_storage_config::policy.
|
nodiscard |
Get the storage backend for a specific tier.
| tier | The tier to get |
Definition at line 465 of file hsm_storage.cpp.
|
nodiscard |
Manually migrate an instance to a different tier.
| sop_instance_uid | The SOP Instance UID to migrate |
| target_tier | The target tier |
Definition at line 270 of file hsm_storage.cpp.
|
nodiscardprivate |
Migrate a single instance between tiers.
| uid | The SOP Instance UID |
| from_tier | Source tier |
| to_tier | Target tier |
Definition at line 542 of file hsm_storage.cpp.
References kcenon::pacs::storage::to_string(), and uid.

|
delete |
|
delete |
|
nodiscardoverridevirtual |
Remove a DICOM dataset from all tiers.
Removes the instance from whichever tier contains it.
| sop_instance_uid | The unique identifier for the instance to remove |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 110 of file hsm_storage.cpp.
|
private |
Remove tier metadata.
| sop_instance_uid | The SOP Instance UID |
Definition at line 538 of file hsm_storage.cpp.
References metadata_index_.
|
nodiscardoverridevirtual |
Retrieve a DICOM dataset by SOP Instance UID.
Searches all tiers for the instance, starting from hot tier. If track_access_time is enabled, updates the last access timestamp.
| sop_instance_uid | The unique identifier for the instance |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 78 of file hsm_storage.cpp.
|
nodiscard |
Run a single migration cycle.
Migrates eligible instances according to the tier policy.
Definition at line 312 of file hsm_storage.cpp.
References kcenon::pacs::storage::migration_result::bytes_migrated, kcenon::pacs::storage::cold, kcenon::pacs::storage::migration_result::duration, kcenon::pacs::storage::migration_result::failed_uids, kcenon::pacs::storage::hot, kcenon::pacs::storage::migration_result::instances_migrated, and kcenon::pacs::storage::warm.
| void kcenon::pacs::storage::hsm_storage::set_tier_policy | ( | const tier_policy & | policy | ) |
Set the tier policy.
| policy | The new tier policy |
Definition at line 406 of file hsm_storage.cpp.
References config_, mutex_, and kcenon::pacs::storage::hsm_storage_config::policy.
|
nodiscardoverridevirtual |
Store a DICOM dataset to the hot tier.
New data is always stored in the hot tier. Migration to cooler tiers happens based on the configured tier policy.
| dataset | The DICOM dataset to store |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 57 of file hsm_storage.cpp.
References kcenon::pacs::storage::hot, and kcenon::pacs::core::tags::sop_instance_uid.
|
private |
Update last access time for an instance.
| sop_instance_uid | The SOP Instance UID |
Definition at line 531 of file hsm_storage.cpp.
References metadata_index_.
|
private |
Update tier metadata after store/retrieve.
| sop_instance_uid | The SOP Instance UID |
| tier | The tier where the instance is stored |
| dataset | The dataset (for extracting metadata) |
Definition at line 510 of file hsm_storage.cpp.
References kcenon::pacs::storage::tier_metadata::current_tier, kcenon::pacs::core::dicom_dataset::get_string(), metadata_index_, kcenon::pacs::core::tags::series_instance_uid, kcenon::pacs::storage::tier_metadata::series_instance_uid, kcenon::pacs::storage::tier_metadata::size_bytes, kcenon::pacs::storage::tier_metadata::sop_instance_uid, kcenon::pacs::storage::tier_metadata::stored_at, kcenon::pacs::core::tags::study_instance_uid, kcenon::pacs::storage::tier_metadata::study_instance_uid, and uid.

|
nodiscardoverridevirtual |
Verify storage integrity across all tiers.
Verifies each tier's integrity and checks tier metadata consistency.
Implements kcenon::pacs::storage::storage_interface.
Definition at line 205 of file hsm_storage.cpp.
References kcenon::pacs::storage::cold, kcenon::pacs::storage::hot, kcenon::pacs::storage::to_string(), uid, and kcenon::pacs::storage::warm.

|
private |
Cold tier storage backend (may be nullptr)
Definition at line 350 of file hsm_storage.h.
Referenced by get_statistics().
|
private |
HSM configuration.
Definition at line 353 of file hsm_storage.h.
Referenced by get_tier_policy(), and set_tier_policy().
|
private |
Hot tier storage backend.
Definition at line 344 of file hsm_storage.h.
Referenced by get_statistics(), and hsm_storage().
|
private |
Tier metadata index (SOP Instance UID -> metadata)
Definition at line 356 of file hsm_storage.h.
Referenced by get_hsm_statistics(), get_statistics(), remove_metadata(), update_access_time(), and update_metadata().
|
mutableprivate |
Mutex for thread-safe access.
Definition at line 359 of file hsm_storage.h.
Referenced by get_hsm_statistics(), get_statistics(), get_tier_policy(), and set_tier_policy().
|
private |
Warm tier storage backend (may be nullptr)
Definition at line 347 of file hsm_storage.h.
Referenced by get_statistics().