Class RealTimeRatingProposalUpdate

java.lang.Object
energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>
energy.trolie.client.request.ratingproposals.RealTimeRatingProposalUpdate
All Implemented Interfaces:
StreamingUpdate<RealTimeRatingProposalStatus>, AutoCloseable

public class RealTimeRatingProposalUpdate extends energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>

Streaming update for real-time rating proposals. Users stream out proposals by invoking methods in the following sequence:

  1. begin(ProposalHeader) with a completely populated header.
  2. rating(RealTimeRating) for rating value set.
  3. complete() to synchronously finish the request.
  • Constructor Details

    • RealTimeRatingProposalUpdate

      public RealTimeRatingProposalUpdate(org.apache.hc.client5.http.classic.HttpClient httpClient, TrolieHost host, org.apache.hc.client5.http.config.RequestConfig requestConfig, int bufferSize, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Map<String,String> httpHeader)
      Constructs new update. Should generally not be called by application code
      Parameters:
      httpClient - client
      host - host
      requestConfig - client request config
      bufferSize - internal buffer size
      objectMapper - Jackson object mapper
      httpHeader - mapped header list
  • Method Details

    • getRequest

      protected org.apache.hc.client5.http.classic.methods.HttpUriRequestBase getRequest()
      Specified by:
      getRequest in class energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>
      Returns:
      Apache HTTP client request associated with this request.
    • getContentType

      protected org.apache.hc.core5.http.ContentType getContentType()
      Specified by:
      getContentType in class energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>
      Returns:
      content type associated with this update
    • getPath

      protected String getPath()
      Specified by:
      getPath in class energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>
      Returns:
      HTTP path associated with this update
    • getResponseHandler

      protected Function<org.apache.hc.core5.http.HttpEntity,RealTimeRatingProposalStatus> getResponseHandler()
      Specified by:
      getResponseHandler in class energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>
      Returns:
      handler associated with this update.
    • begin

      public void begin(ProposalHeader header)
      Begin the stream, sending a populated header
      Parameters:
      header - populated header. Must include at least emergency rating durations and power system resources
    • rating

      public void rating(RealTimeRating rating)
      Send a rating value set for a given resource.
      Parameters:
      rating - value set
    • complete

      public RealTimeRatingProposalStatus complete()
      Finalize the request.
      Returns:
      status of the proposal retrieved from the TROLIE server. NOTE: TROLIE allows for partial proposal updates. Be sure to check and appropriately log any validation errors returned with this status, as they will indicate that ratings were not sent successfully for those resources.
    • close

      public void close()
      Description copied from class: energy.trolie.client.impl.request.AbstractStreamingUpdate
      Clean up the stream and terminate the request thread if it is still running
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class energy.trolie.client.impl.request.AbstractStreamingUpdate<RealTimeRatingProposalStatus>