Expand description
Device management and scheduling 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.
§Device Control Module
This module provides comprehensive smart device control functionality for DMSC, including device discovery, control, and resource scheduling. It enables efficient management of devices and their resources across distributed environments.
§Key Components
- DMSCDeviceControlModule: Main device control module implementing service module traits
- DMSCDevice: Device representation with type, status, and capabilities
- DMSCDeviceType: Enum defining supported device types
- DMSCDeviceStatus: Enum defining device statuses
- DMSCDeviceCapabilities: Device capabilities structure
- DMSCDeviceController: Device controller for managing devices
- DMSCDeviceScheduler: Device scheduler for resource allocation
- DMSCResourcePool: Resource pool for managing device resources
- DMSCResourcePoolManager: Manager for multiple resource pools
- DMSCResourcePoolStatistics: Statistics for resource pool monitoring
- DMSCDeviceControlConfig: Configuration for device control behavior
- DMSCDiscoveryResult: Result structure for device discovery
- DMSCResourceRequest: Request structure for resource allocation
- DMSCResourceAllocation: Result structure for resource allocation
- DMSCResourcePoolStatus: Status structure for resource pools
§Design Principles
- Device Abstraction: Unified interface for different device types
- Auto Discovery: Automatic device discovery in the network/environment
- Resource Scheduling: Intelligent resource allocation and scheduling
- Configurable: Highly configurable device control behavior
- Async Support: Full async/await compatibility
- Resource Pooling: Efficient management of device resources through pooling
- Service Module Integration: Implements service module traits for seamless integration
- Thread-safe: Uses Arc and RwLock for safe concurrent access
- Non-critical: Device control failures should not break the entire application
- Monitoring: Comprehensive statistics for device and resource monitoring
- Scalable: Designed to handle large numbers of devices and concurrent tasks
§Usage
use dmsc::prelude::*;
use dmsc::device::{DMSCDeviceControlConfig, DMSCResourceRequest, DMSCDeviceType, DMSCDeviceCapabilities};
async fn example() -> DMSCResult<()> {
// Create device control configuration
let device_config = DMSCDeviceControlConfig {
discovery_enabled: true,
discovery_interval_secs: 30,
auto_scheduling_enabled: true,
max_concurrent_tasks: 100,
resource_allocation_timeout_secs: 60,
};
// Create device control module
let device_module = DMSCDeviceControlModule::new()
.with_config(device_config);
// Discover devices
let discovery_result = device_module.discover_devices().await?;
println!("Discovered {} devices, total devices: {}",
discovery_result.discovered_devices.len(),
discovery_result.total_devices);
// Get device status
let devices = device_module.get_device_status().await?;
println!("Current devices: {:?}", devices);
// Create resource request
let resource_request = DMSCResourceRequest {
request_id: "request-123".to_string(),
device_type: DMSCDeviceType::Compute,
required_capabilities: DMSCDeviceCapabilities {
cpu_cores: Some(4),
memory_gb: Some(8.0),
storage_gb: Some(100.0),
gpu_enabled: Some(true),
network_speed_mbps: Some(1000.0),
extra: Default::default(),
},
priority: 5,
timeout_secs: 30,
};
// Allocate resource
if let Some(allocation) = device_module.allocate_resource(resource_request).await? {
println!("Allocated device: {} (ID: {})",
allocation.device_name,
allocation.device_id);
// Release resource after use
device_module.release_resource(&allocation.allocation_id).await?;
}
Ok(())
}Re-exports§
pub use pool::DMSCResourcePool;pub use pool::DMSCResourcePoolManager;pub use pool::DMSCConnectionPoolStatistics;pub use scheduler::DMSCDeviceScheduler;pub use discovery_scheduler::DMSCDeviceDiscoveryEngine;pub use discovery_scheduler::DMSCResourceScheduler;pub use discovery::DMSCDeviceDiscovery;pub use discovery::DiscoveryConfig;pub use discovery::DiscoveryStats;pub use discovery::DiscoveryStrategy;pub use discovery::HardwareCategory;pub use discovery::PlatformInfo;pub use discovery::PlatformType;pub use discovery::Architecture;pub use discovery::PlatformCompatibility;pub use discovery::ProviderRegistry;pub use discovery::DMSCHardwareProvider;pub use discovery::PluginRegistry;pub use discovery::DMSCHardwareDiscoveryPlugin;pub use discovery::PluginMetadata;pub use discovery::PluginStatus;pub use discovery::PluginError;pub use discovery::AsyncDiscovery;
Modules§
- discovery
- Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
- discovery_
scheduler - Copyright © 2025 Wenze Wei. All Rights Reserved.
- pool
- Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
- scheduler
- Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
Structs§
- DMSC
Affinity Rules - Affinity and anti-affinity rules for device selection.
- DMSC
Device - Smart device representation
- DMSC
Device Capabilities - Device capabilities structure
- DMSC
Device Config - Configuration for device module
- DMSC
Device Control Config - Configuration for device control module
- DMSC
Device Control Module - Main device control module for DMSC.
- DMSC
Device Controller - Device controller - manages device lifecycle and state
- DMSC
Device Health Metrics - Device health metrics structure
- DMSC
Device Scheduling Config - Scheduling configuration for device control module
- DMSC
Discovery Result - Result structure for device discovery operations.
- DMSC
Network Device Info - Network device information for remote device discovery
- DMSC
Resource Allocation - Result structure for resource allocation.
- DMSC
Resource Pool Status - Status structure for resource pools.
- DMSC
Resource Request - Request structure for resource allocation.
- DMSC
Resource Weights - Multi-dimensional resource weights for scheduling.
Enums§
- DMSC
Device Status - Device status enumeration
- DMSC
Device Type - Device type enumeration
- DMSC
Request SlaClass - SLA class for a resource request.