Module device

Module device 

Source
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.0

Unless 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

  1. Device Abstraction: Unified interface for different device types
  2. Auto Discovery: Automatic device discovery in the network/environment
  3. Resource Scheduling: Intelligent resource allocation and scheduling
  4. Configurable: Highly configurable device control behavior
  5. Async Support: Full async/await compatibility
  6. Resource Pooling: Efficient management of device resources through pooling
  7. Service Module Integration: Implements service module traits for seamless integration
  8. Thread-safe: Uses Arc and RwLock for safe concurrent access
  9. Non-critical: Device control failures should not break the entire application
  10. Monitoring: Comprehensive statistics for device and resource monitoring
  11. 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§

DMSCAffinityRules
Affinity and anti-affinity rules for device selection.
DMSCDevice
Smart device representation
DMSCDeviceCapabilities
Device capabilities structure
DMSCDeviceConfig
Configuration for device module
DMSCDeviceControlConfig
Configuration for device control module
DMSCDeviceControlModule
Main device control module for DMSC.
DMSCDeviceController
Device controller - manages device lifecycle and state
DMSCDeviceHealthMetrics
Device health metrics structure
DMSCDeviceSchedulingConfig
Scheduling configuration for device control module
DMSCDiscoveryResult
Result structure for device discovery operations.
DMSCNetworkDeviceInfo
Network device information for remote device discovery
DMSCResourceAllocation
Result structure for resource allocation.
DMSCResourcePoolStatus
Status structure for resource pools.
DMSCResourceRequest
Request structure for resource allocation.
DMSCResourceWeights
Multi-dimensional resource weights for scheduling.

Enums§

DMSCDeviceStatus
Device status enumeration
DMSCDeviceType
Device type enumeration
DMSCRequestSlaClass
SLA class for a resource request.