Expand description
Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
This file is part of DMSC. The DMSC project belongs to the Dunimd Team.
Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
§Resource Pool Management
This file implements resource pool management for the DMSC framework, providing a way to group similar devices together for efficient resource allocation and management. It includes both single resource pools and a resource pool manager for handling multiple pools.
§Key Components
- DMSCResourcePool: Manages a pool of similar devices
- DMSCResourcePoolConfig: Configuration for resource pools
- DMSCResourcePoolStatistics: Statistics for monitoring resource pools
- DMSCResourcePoolManager: Manages multiple resource pools
§Design Principles
- Resource Grouping: Groups similar devices together for efficient management
- Capacity Tracking: Tracks total, available, and allocated capacity
- Statistics Collection: Collects comprehensive statistics for monitoring
- Device Filtering: Filters devices by availability and allocation status
- Health Monitoring: Monitors pool health based on available devices
- Utilization Tracking: Tracks resource utilization rates
- Multi-Pool Management: Supports managing multiple pools through a central manager
- Device Type Segregation: Each pool contains devices of a single type
- Arc-Based Sharing: Uses Arc for safe concurrent access to devices
- Serialization Support: All structures support serialization/deserialization
- Builder Pattern: Configurable through DMSCResourcePoolConfig
- Resource Optimization: Calculates total compute, memory, storage, and bandwidth
§Usage
use dmsc::device::{DMSCResourcePoolManager, DMSCResourcePoolConfig, DMSCDeviceType};
use dmsc::core::DMSCResult;
fn example() -> DMSCResult<()> {
// Create a resource pool manager
let mut manager = DMSCResourcePoolManager::new();
// Create a resource pool configuration
let config = DMSCResourcePoolConfig {
name: "cpu-pool-1".to_string(),
device_type: DMSCDeviceType::CPU,
max_concurrent_allocations: 10,
allocation_timeout_secs: 60,
health_check_interval_secs: 30,
};
// Create a resource pool
let pool = manager.create_pool(config);
// Get pool statistics
let stats = pool.get_statistics();
println!("Pool has {} devices, utilization: {:.2}%",
stats.total_devices, stats.utilization_rate * 100.0);
// Get all pools by device type
let cpu_pools = manager.get_pools_by_type(DMSCDeviceType::CPU);
println!("Found {} CPU pools", cpu_pools.len());
// Get overall statistics
let overall_stats = manager.get_overall_statistics();
println!("Total devices across all pools: {}", overall_stats.total_devices);
Ok(())
}Structs§
- DMSC
Connection Health Metrics - Connection health metrics
- DMSC
Connection Info - Connection information for tracking individual connections
- DMSC
Connection Pool - Connection pool for managing device connections with lifecycle and health monitoring
- DMSC
Connection Pool Statistics - Connection pool statistics
- DMSC
Resource Pool - Resource pool for managing multiple similar devices
- DMSC
Resource Pool Config - Configuration for a resource pool
- DMSC
Resource Pool Manager - Resource pool manager for managing multiple resource pools
- DMSC
Resource Pool Statistics - Resource pool statistics structure
Enums§
- DMSC
Connection State - Connection state enumeration