25#include <condition_variable>
64 std::function<void(
const std::string&
uid,
const std::string&
error)>;
123 std::shared_ptr<kcenon::thread::thread_pool> thread_pool,
159 void stop(
bool wait_for_completion =
true);
166 [[nodiscard]]
auto is_running() const noexcept ->
bool;
216 -> std::optional<std::chrono::seconds>;
244 -> std::chrono::seconds;
302 std::condition_variable
cv_;
std::atomic< bool > cycle_in_progress_
Flag indicating a cycle is in progress.
~hsm_migration_service()
Destructor - ensures graceful shutdown.
void update_stats(const migration_result &result)
Update cumulative statistics.
void set_progress_callback(migration_service_config::progress_callback callback)
Set the progress callback.
void stop(bool wait_for_completion=true)
Stop the background migration service.
auto get_last_result() const -> std::optional< migration_result >
Get the result of the last migration cycle.
hsm_migration_service & operator=(hsm_migration_service &&)=delete
void set_migration_interval(std::chrono::seconds interval)
Update the migration interval.
std::atomic< bool > stop_requested_
Flag to signal shutdown.
hsm_storage & storage_
Reference to managed HSM storage.
std::mutex mutex_
Mutex for thread synchronization.
hsm_migration_service(hsm_storage &storage, const migration_service_config &config={})
Construct migration service.
std::chrono::steady_clock::time_point next_cycle_time_
Time of next scheduled cycle.
std::thread worker_thread_
Background worker thread.
auto cycles_completed() const noexcept -> std::size_t
Get the number of cycles completed.
hsm_migration_service(hsm_migration_service &&)=delete
Non-movable.
auto run_migration_cycle() -> migration_result
Manually trigger a migration cycle.
std::atomic< bool > running_
Flag indicating service is running.
auto is_running() const noexcept -> bool
Check if the service is running.
void trigger_cycle()
Trigger next cycle immediately.
void set_error_callback(migration_service_config::error_callback callback)
Set the error callback.
std::atomic< std::size_t > cycles_count_
Number of completed cycles.
auto execute_cycle() -> migration_result
Execute a single migration cycle.
hsm_migration_service & operator=(const hsm_migration_service &)=delete
auto get_cumulative_stats() const -> migration_result
Get total statistics since service started.
std::optional< migration_result > last_result_
Last migration result.
auto time_until_next_cycle() const -> std::optional< std::chrono::seconds >
Get the time until the next scheduled migration.
auto get_migration_interval() const noexcept -> std::chrono::seconds
Get the current migration interval.
void run_loop()
Background thread main loop.
migration_result cumulative_stats_
Cumulative statistics.
migration_service_config config_
Service configuration.
hsm_migration_service(const hsm_migration_service &)=delete
Non-copyable.
void start()
Start the background migration service.
std::shared_ptr< kcenon::thread::thread_pool > thread_pool_
Thread pool for parallel migrations (optional)
std::condition_variable cv_
Condition variable for sleep/wake.
Hierarchical Storage Management (HSM) for multi-tier DICOM storage.
Types for Hierarchical Storage Management (HSM)
std::shared_mutex mutex
Mutex for thread-safe access.
std::function< bool(std::size_t bytes_transferred, std::size_t total_bytes)> progress_callback
Callback type for upload/download progress tracking.
Result of a migration operation.
Configuration for the migration service.
bool auto_start
Whether to start automatically on construction.
std::size_t max_concurrent_migrations
Maximum concurrent migrations.
std::function< void(const migration_result &result)> progress_callback
Callback for migration progress updates.
std::function< void(const std::string &uid, const std::string &error)> error_callback
Callback for migration errors.
error_callback on_migration_error
progress_callback on_cycle_complete
std::chrono::seconds migration_interval
Interval between migration cycles.