Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-4318

Create CoreSocketNormalizer in swatch-common-instances

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • subs-swatch-thunder

      Description

      As a swatch developer, I need a single source of truth for cores/sockets normalization logic so that both swatch-tally and swatch-metrics-hbi services produce consistent values.

      Currently, normalization logic is duplicated in:

      • FactNormalizer (swatch-tally)
      • MeasurementNormalizer (swatch-metrics-hbi)
      • Product Usage Collectors (swatch-tally)

      This leads to conflicting values between instance_measurements and host_tally_buckets tables.

      Technical Details

      Create new classes in swatch-common-instances/src/main/java/com/redhat/swatch/common/normalization/:

      1. NormalizationContext.java - Input data class containing:

      • rawCores / rawSockets
      • coresPerSocket / threadsPerCore
      • isMarketplace / cloudProvider
      • isVirtual / isHypervisor / isUnmappedGuest
      • arch / syspurposeUnits
      • productIds

      2. NormalizedMeasurements.java - Output data class containing:

      • cores / sockets (normalized values)

      3. CoreSocketNormalizer.java - Static method normalize(NormalizationContext ctx):

      • Apply all normalization rules in priority order
      • Return NormalizedMeasurements

      Normalization Rules (Priority Order)

      Priority Rule Condition Action
      1 Marketplace isMarketplace == true cores=0, sockets=0
      2 Cloud Provider cloudProvider != null sockets=1
      3 Unmapped Guest isVirtual && isUnmappedGuest && isRHEL sockets=1
      4 Modulo-2 Rounding (!isVirtual || isHypervisor) && sockets % 2 == 1 sockets++
      5 vCPU Calculation arch=="x86_64" && isVirtual cores = cores / threadsPerCore
      6 Unit-Based units == "Sockets" cores=null
      6 Unit-Based units == "Cores/vCPU" sockets=null
      7 Null Handling cores == null cores = fallback

      Acceptance Criteria

      • NormalizationContext class created with all required fields
      • NormalizedMeasurements class created
      • CoreSocketNormalizer.normalize() method implements all rules in priority order
      • Comprehensive unit tests for each normalization rule
      • Edge case tests (null inputs, boundary values)
      • Tests match existing behavior in FactNormalizer and MeasurementNormalizer

              Unassigned Unassigned
              kflahert@redhat.com Kevin Flaherty
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: