Interface TrolieClient
- All Superinterfaces:
AutoCloseable
,Closeable
Primary TROLIE client access interface. Represents configured access to a single TROLIE server. Should be used as a singleton within applications, at least for each TROLIE endpoint used by a given application.
Users should note that the TrolieClient is optimized for performance, particularly for users with large data sets. Therefore, most operations use a streaming approach for receipt of data components, rather than force applications to keep entire structures in memory at once.
Using TrolieClient Methods
For consistency, the TrolieClient API uses the same patterns regardless of the size of the data users may be using. These patterns always use reactive-style callbacks, and typically involve streaming mechanisms for breaking each payload into logical slices. This may be more difficult to program for users, but helps ensure that users of the SDK are more likely to have successful implementations, even as data sizes increase.
The methods below make use of the following common constructs:
StreamingResponseReceiver
s are callbacks to get data from the TROLIE server. Instead of returning the entire payload of response in memory, the receivers will have various methods that are invoked as parsed data is returned. API users must implement these interfaces to receive data. This follows a similar pattern to event-based parsing systems, popularized most in Java by the SAX XML parser.RequestSubscription
s are returned from methods that set up a polling loop within the client. The TROLIE client implements the mechanics under the hood to poll for TROLIE servers using Conditional GETs, and will then notify associatedStreamingResponseReceiver
s as new data is returned. These subscriptions may be managed using theunsubscribe(RequestSubscription)
andunsubscribeAll()
methods.StreamingUpdate
s are the inverse of the receivers. Rather than send entire payloads at once in a giant in-memory structure, these classes allow the API user to send the data in small chunks and stream it out. Each StreamingUpdate assumes that its methods are invoked in a particular order matching the structure of the TROLIE operation being invoked.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic TrolieClientBuilder
Initializes a new builder.Create a forecast proposal update that can stream the update submission to the serverCreate a real-time proposal update that can stream the update submission to the servervoid
Identical togetMonitoringSet(MonitoringSetsReceiver, String)
, but simply fetches this grid operator's default monitoring set rather than one specified with a particular name.void
Execute a synchronous request for the current forecast limits with a streaming response handler, assuming this user's default monitoring set.void
getInUseLimitForecasts
(ForecastSnapshotReceiver receiver, String monitoringSet) Execute a request for the current forecast limits with a streaming response handler with the given monitoring set.void
getInUseLimitForecasts
(ForecastSnapshotReceiver receiver, String monitoringSet, String resourceId, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the current forecast limits with a streaming response handlervoid
getInUseLimitForecasts
(ForecastSnapshotReceiver receiver, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the current forecast limits with a streaming response handler, given this user's default monitoring set.void
getInUseLimits
(RealTimeSnapshotReceiver receiver) Execute a request for the current real-time limits with a streaming response handlervoid
getInUseLimits
(RealTimeSnapshotReceiver receiver, String monitoringSet) Execute a request for the current real-time limits with a streaming response handlervoid
getInUseLimits
(RealTimeSnapshotReceiver receiver, String monitoringSet, String resourceId) Execute a request for the current real-time limits with a streaming response handlervoid
getMonitoringSet
(@NonNull MonitoringSetsReceiver receiver, @NonNull String monitoringSet) Synchronously fetch the definition of a monitoring set.void
Execute a request for the current forecast limits with a streaming response handlervoid
getRegionalLimitsForecast
(ForecastSnapshotReceiver receiver, String monitoringSet) Execute a request for the regionally limiting forecast limits with a streaming response handlervoid
getRegionalLimitsForecast
(ForecastSnapshotReceiver receiver, String monitoringSet, String resourceId, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the regionally limiting forecast limits with a streaming response handlervoid
getRegionalLimitsForecast
(ForecastSnapshotReceiver receiver, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the regionally limiting forecast limits with a streaming response handlervoid
Execute a request for the regional real-time limits with a streaming response handler.void
getRegionalRealTimeLimits
(RealTimeSnapshotReceiver receiver, String monitoringSet) Execute a request for the regional real-time limits with a streaming response handlervoid
getRegionalRealTimeLimits
(RealTimeSnapshotReceiver receiver, String monitoringSet, String resourceId) Execute a request for the regional real-time limits with a streaming response handlerIdentical tosubscribeToMonitoringSetUpdates(MonitoringSetsSubscribedReceiver, String)
, but creates a polling subscription for this grid operator's default monitoring set rather than one specified with a particular name.Create a polling subscription for forecast snapshot data updatessubscribeToInUseLimitForecastUpdates
(ForecastSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for forecast snapshot data updatesCreate a polling subscription for real-time snapshot data updatessubscribeToInUseLimits
(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for real-time snapshot data updatessubscribeToInUseLimits
(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet, String resourceId) Create a polling subscription for real-time snapshot data updatessubscribeToMonitoringSetUpdates
(MonitoringSetsSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for updates to the given monitoring set.Create a polling subscription for regionally limiting forecast snapshot data updatessubscribeToRegionalLimitsForecast
(ForecastSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for regionally limiting forecast snapshot data updatesCreate a polling subscription regional real-time snapshot data updatessubscribeToRegionalRealTimeLimits
(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for regional real-time snapshot data updatesvoid
unsubscribe
(RequestSubscription subscription) Un-subscribe an active polling requestvoid
Un-subscribe all active polling requests
-
Method Details
-
getMonitoringSet
void getMonitoringSet(@NonNull @NonNull MonitoringSetsReceiver receiver, @NonNull @NonNull String monitoringSet) Synchronously fetch the definition of a monitoring set.- Parameters:
receiver
- receiver for monitoring set contents.monitoringSet
- monitoring set identifier.
-
subscribeToMonitoringSetUpdates
RequestSubscription subscribeToMonitoringSetUpdates(MonitoringSetsSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for updates to the given monitoring set.- Parameters:
receiver
- receives updates to the monitoring set as they occur. Note that these invocations will be on the polling thread, so long-running operations will block additional polls for data update.monitoringSet
- the monitoring set identifier to poll for- Returns:
- handle to the request.
-
getDefaultMonitoringSet
Identical togetMonitoringSet(MonitoringSetsReceiver, String)
, but simply fetches this grid operator's default monitoring set rather than one specified with a particular name.- Parameters:
receiver
- receiver for the monitoring set
-
subscribeToDefaultMonitoringSetUpdates
RequestSubscription subscribeToDefaultMonitoringSetUpdates(MonitoringSetsSubscribedReceiver receiver) Identical tosubscribeToMonitoringSetUpdates(MonitoringSetsSubscribedReceiver, String)
, but creates a polling subscription for this grid operator's default monitoring set rather than one specified with a particular name.- Parameters:
receiver
- receives updates to the monitoring set as they occur. Note that these invocations will be on the polling thread, so long-running operations will block additional polls for data update.- Returns:
- handle to the request.
-
getInUseLimitForecasts
Execute a synchronous request for the current forecast limits with a streaming response handler, assuming this user's default monitoring set.- Parameters:
receiver
- Streaming data receiver for snapshot data
-
getInUseLimitForecasts
Execute a request for the current forecast limits with a streaming response handler with the given monitoring set.- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set name
-
getInUseLimitForecasts
void getInUseLimitForecasts(ForecastSnapshotReceiver receiver, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the current forecast limits with a streaming response handler, given this user's default monitoring set.- Parameters:
receiver
- Streaming data receiver for snapshot dataoffsetPeriodStart
- Optional. Only periods starting at or after this date will be returned.periodEnd
- Optional. Only periods starting before this date will be returns If periodStart is not given, all available periods starting before this date will be returned.
-
getInUseLimitForecasts
void getInUseLimitForecasts(ForecastSnapshotReceiver receiver, String monitoringSet, String resourceId, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the current forecast limits with a streaming response handler- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set nameresourceId
- Only return limits for this power system resourceoffsetPeriodStart
- Optional. Only periods starting at or after this date will be returned.periodEnd
- Optional. Only periods starting before this date will be returns If periodStart is not given, all available periods starting before this date will be returned.
-
subscribeToInUseLimitForecastUpdates
RequestSubscription subscribeToInUseLimitForecastUpdates(ForecastSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for forecast snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set name- Returns:
- request handle
-
subscribeToInUseLimitForecastUpdates
RequestSubscription subscribeToInUseLimitForecastUpdates(ForecastSnapshotSubscribedReceiver receiver) Create a polling subscription for forecast snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot data- Returns:
- request handle
-
getRegionalLimitsForecast
Execute a request for the current forecast limits with a streaming response handler- Parameters:
receiver
- Streaming data receiver for snapshot data
-
getRegionalLimitsForecast
Execute a request for the regionally limiting forecast limits with a streaming response handler- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set name
-
getRegionalLimitsForecast
void getRegionalLimitsForecast(ForecastSnapshotReceiver receiver, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the regionally limiting forecast limits with a streaming response handler- Parameters:
receiver
- Streaming data receiver for snapshot dataoffsetPeriodStart
- Optional. Only periods starting at or after this date will be returned.periodEnd
- Optional. Only periods starting before this date will be returns If periodStart is not given, all available periods starting before this date will be returned.
-
getRegionalLimitsForecast
void getRegionalLimitsForecast(ForecastSnapshotReceiver receiver, String monitoringSet, String resourceId, Instant offsetPeriodStart, Instant periodEnd) Execute a request for the regionally limiting forecast limits with a streaming response handler- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set nameresourceId
- Only return limits for this power system resourceoffsetPeriodStart
- Optional. Only periods starting at or after this date will be returned.periodEnd
- Optional. Only periods starting before this date will be returns If periodStart is not given, all available periods starting before this date will be returned.
-
subscribeToRegionalLimitsForecast
Create a polling subscription for regionally limiting forecast snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot data- Returns:
- request handle
-
subscribeToRegionalLimitsForecast
RequestSubscription subscribeToRegionalLimitsForecast(ForecastSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for regionally limiting forecast snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- filter for monitoring set name- Returns:
- request result handle
-
createForecastRatingProposalStreamingUpdate
ForecastRatingProposalUpdate createForecastRatingProposalStreamingUpdate()Create a forecast proposal update that can stream the update submission to the server- Returns:
- update handle
-
getInUseLimits
Execute a request for the current real-time limits with a streaming response handler- Parameters:
receiver
- streaming receiver for real-time limitsmonitoringSet
- monitoring set name. Either monitoring set or resourceId may be provided, but not both. If neither are provided, the user's default monitoring set is assumed.resourceId
- a resource to filter by. Either resource ID or monitoring set name may be provided, but not both. If neither are provided, then the user's default monitoring set will be assumed.
-
getInUseLimits
Execute a request for the current real-time limits with a streaming response handler- Parameters:
receiver
- streaming receiver for real-time limitsmonitoringSet
- monitoring set name. If not provided, the user's default monitoring set is assumed.
-
getInUseLimits
Execute a request for the current real-time limits with a streaming response handler- Parameters:
receiver
- stream handler
-
subscribeToInUseLimits
Create a polling subscription for real-time snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot data- Returns:
- subscription result
-
subscribeToInUseLimits
RequestSubscription subscribeToInUseLimits(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for real-time snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- optional filter for monitoring set- Returns:
- subscription handle
-
subscribeToInUseLimits
RequestSubscription subscribeToInUseLimits(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet, String resourceId) Create a polling subscription for real-time snapshot data updates- Parameters:
receiver
- Streaming data receiver for snapshot datamonitoringSet
- optional filter for monitoring setresourceId
- optional filter for transmission facility- Returns:
- subscription handle
-
getRegionalRealTimeLimits
Execute a request for the regional real-time limits with a streaming response handler. Returns limits assuming the default monitoring set in the remote TROLIE.- Parameters:
receiver
- callback for new limit snapshots
-
getRegionalRealTimeLimits
Execute a request for the regional real-time limits with a streaming response handler- Parameters:
receiver
- callback for new limit snapshotsmonitoringSet
- monitoring set to filter by.
-
getRegionalRealTimeLimits
void getRegionalRealTimeLimits(RealTimeSnapshotReceiver receiver, String monitoringSet, String resourceId) Execute a request for the regional real-time limits with a streaming response handler- Parameters:
receiver
- callback for new limit snapshotsmonitoringSet
- monitoring set to filter by.resourceId
- resource ID filter
-
subscribeToRegionalRealTimeLimits
Create a polling subscription regional real-time snapshot data updates- Parameters:
receiver
- Streaming data receiver for regional snapshot data- Returns:
- subscription handle.
-
subscribeToRegionalRealTimeLimits
RequestSubscription subscribeToRegionalRealTimeLimits(RealTimeSnapshotSubscribedReceiver receiver, String monitoringSet) Create a polling subscription for regional real-time snapshot data updates- Parameters:
receiver
- Streaming data receiver for regional snapshot datamonitoringSet
- optional filter for monitoring set- Returns:
- subscription handle
-
createRealTimeRatingProposalStreamingUpdate
RealTimeRatingProposalUpdate createRealTimeRatingProposalStreamingUpdate()Create a real-time proposal update that can stream the update submission to the server- Returns:
- stateful request.
-
unsubscribe
Un-subscribe an active polling request- Parameters:
subscription
- subscription to cancel.
-
unsubscribeAll
void unsubscribeAll()Un-subscribe all active polling requests -
builder
static TrolieClientBuilder builder(String baseUrl, org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) Initializes a new builder.- Parameters:
baseUrl
- URL to the TROLIE service, such as https://trolie.example.com.httpClient
- a pre-configured Apache HTTP client. The TROLIE client is built on top of the Apache HTTP client, and the full suite of configuration options for it are available. See examples for more detail.- Returns:
- new builder
-