Class MLRateLimiter

java.lang.Object
org.opensearch.ml.common.controller.MLRateLimiter
All Implemented Interfaces:
org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject

public class MLRateLimiter extends Object implements org.opensearch.core.xcontent.ToXContentObject, org.opensearch.core.common.io.stream.Writeable
  • Field Details

  • Constructor Details

    • MLRateLimiter

      public MLRateLimiter(String limit, TimeUnit unit)
    • MLRateLimiter

      public MLRateLimiter(org.opensearch.core.common.io.stream.StreamInput in) throws IOException
      Throws:
      IOException
  • Method Details

    • parse

      public static MLRateLimiter parse(org.opensearch.core.xcontent.XContentParser parser) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException
      Specified by:
      writeTo in interface org.opensearch.core.common.io.stream.Writeable
      Throws:
      IOException
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • update

      public void update(MLRateLimiter updateContent)
    • update

      public static MLRateLimiter update(MLRateLimiter rateLimiter, MLRateLimiter updateContent)
    • updateValidityPreCheck

      public static boolean updateValidityPreCheck(MLRateLimiter rateLimiter, MLRateLimiter updateContent)
      Checks the validity of this incoming update before performing an update operation. A valid update indicates the corresponding index will be updated with the current MLRateLimiter config and the update content
      Parameters:
      rateLimiter - The existing rate limiter.
      updateContent - The update content.
      Returns:
      true if the update is valid, false otherwise.
    • isDeployRequiredAfterUpdate

      public static boolean isDeployRequiredAfterUpdate(MLRateLimiter rateLimiter, MLRateLimiter updateContent)
      Checks if we need to deploy this update into ML Cache (if model is deployed) after performing this update operation.
      Parameters:
      rateLimiter - The existing rate limiter.
      updateContent - The update content.
      Returns:
      true if the update is valid, false otherwise.
    • isValid

      public boolean isValid()
    • isEmpty

      public boolean isEmpty()
    • builder

      public static MLRateLimiter.MLRateLimiterBuilder builder()
    • toBuilder

    • setLimit

      public void setLimit(String limit)
    • setUnit

      public void setUnit(TimeUnit unit)
    • getLimit

      public String getLimit()
    • getUnit

      public TimeUnit getUnit()