Interface MetricsProvider

All Known Implementing Classes:
MockMetricsProvider, OshiMetricsProvider, RealMetricsProvider

public interface MetricsProvider
Output port for retrieving system metrics.

This interface abstracts the source of system metrics, allowing the domain to remain independent of how metrics are obtained. Implementations can read from the real OS, return mock data, or fetch from remote monitoring systems.

Hexagonal Architecture Role

This is a driven port (output port) - the application core calls out to infrastructure through this interface.

  • Method Summary

    Modifier and Type
    Method
    Description
    Get all system metrics at once.
    double
    Get current CPU usage percentage.
    double
    Get current disk usage percentage.
    double
    Get current memory usage percentage.
  • Method Details

    • getCpuUsage

      double getCpuUsage()
      Get current CPU usage percentage.
      Returns:
      CPU usage as percentage (0-100)
    • getMemoryUsage

      double getMemoryUsage()
      Get current memory usage percentage.
      Returns:
      Memory usage as percentage (0-100)
    • getDiskUsage

      double getDiskUsage()
      Get current disk usage percentage.
      Returns:
      Disk usage as percentage (0-100)
    • getAllMetrics

      default SystemMetrics getAllMetrics()
      Get all system metrics at once.

      Default implementation calls individual methods, but implementations may override for efficiency (e.g., single OS call).

      Returns:
      SystemMetrics containing all current values