Class CpuUsageStrategyFactory

All Implemented Interfaces:
MoleculerLifecycle

public class CpuUsageStrategyFactory extends ArrayBasedStrategyFactory
Factory of lowest CPU usage strategy. This strategy comes from a random strategy, but preferably communicates with the "least loaded" nodes (nodes with the lowest CPU usage).
See Also:
  • Field Details

    • sampleCount

      protected int sampleCount
      This strategy compares number of 'sampleCount' random node.
    • lowCpuUsage

      protected int lowCpuUsage
      lowCpuUsage ~= zero CPU usage
    • transporter

      protected Transporter transporter
  • Constructor Details

    • CpuUsageStrategyFactory

      public CpuUsageStrategyFactory()
      Constructor that calls for service based primarily on its own (CPU-based) logic. Does not matter if the service is available locally.
    • CpuUsageStrategyFactory

      public CpuUsageStrategyFactory(boolean preferLocal)
      Constructor that can be configured to use local services if possible.
      Parameters:
      preferLocal - invoke local actions if possible
    • CpuUsageStrategyFactory

      public CpuUsageStrategyFactory(boolean preferLocal, int sampleCount, int lowCpuUsage)
  • Method Details