Interface ICommandService


  • public interface ICommandService
    A Command Service API of a csw component. This model provides method based APIs for command interactions with a component.
    • Method Detail

      • onewayAndMatch

        java.util.concurrent.CompletableFuture<CommandResponse.MatchingResponse> onewayAndMatch​(ControlCommand controlCommand,
                                                                                                StateMatcher stateMatcher)
        Submit a command and match the published state from the component using a StateMatcher. If the match is successful a Completed response is provided as a future. In case of a failure or unmatched state, Error CommandResponse is provided as a Future.

        Parameters:
        controlCommand - the ControlCommand payload
        stateMatcher - the StateMatcher implementation for matching received state against a demand state
        Returns:
        a MatchingResponse as a Future value
      • query

        java.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse> query​(Id commandRunId)
        Query for the result of a long running command which was sent as Submit to get a CommandResponse.SubmitResponse as a Future

        Parameters:
        commandRunId - the runId of the command for which response is required
        Returns:
        a CommandResponse as a Future value
      • queryFinal

        java.util.concurrent.CompletableFuture<CommandResponse.SubmitResponse> queryFinal​(Id commandRunId,
                                                                                          akka.util.Timeout timeout)
        Query for the final result of a long running command which was sent as Submit to get a CommandResponse.SubmitResponse as a Future

        Parameters:
        commandRunId - the runId of the command for which response is required
        timeout - (undocumented)
        Returns:
        a CommandResponse as a Future value
      • submitAllAndWait

        java.util.concurrent.CompletableFuture<java.util.List<CommandResponse.SubmitResponse>> submitAllAndWait​(java.util.List<ControlCommand> submitCommands,
                                                                                                                akka.util.Timeout timeout)
        Submit multiple commands and get a Source of CommandResponse.SubmitResponse for all commands. The CommandResponse can be a response of validation (Accepted, Invalid) or a final Response. In case of response as Accepted, final CommandResponse can be obtained by using subscribe API.

        Parameters:
        submitCommands - the set of ControlCommand payloads
        timeout - (undocumented)
        Returns:
        a Source of CommandResponse as a stream of CommandResponses for all commands
      • subscribeCurrentState

        akka.stream.javadsl.Source<CurrentState,​msocket.api.Subscription> subscribeCurrentState()
        Subscribe to all the current states of a component corresponding to the AkkaLocation of the component

        Returns:
        a stream of current states with Subscription as the materialized value which can be used to stop the subscription
      • subscribeCurrentState

        akka.stream.javadsl.Source<CurrentState,​msocket.api.Subscription> subscribeCurrentState​(java.util.Set<StateName> names)
        Subscribe to the current state of a component corresponding to the AkkaLocation of the component

        Parameters:
        names - subscribe to states which have any of the provided value for name. If no states are provided, all the current states will be received.
        Returns:
        a stream of current states with Subscription as the materialized value which can be used to stop the subscription
      • subscribeCurrentState

        msocket.api.Subscription subscribeCurrentState​(java.util.function.Consumer<CurrentState> callback)
        Subscribe to the current state of a component corresponding to the AkkaLocation of the component

        Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.

        Parameters:
        callback - the action to be applied on the CurrentState element received as a result of subscription
        Returns:
        a Subscription to stop the subscription
      • subscribeCurrentState

        msocket.api.Subscription subscribeCurrentState​(java.util.Set<StateName> names,
                                                       java.util.function.Consumer<CurrentState> callback)
        Subscribe to the current state of a component corresponding to the AkkaLocation of the component

        Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.

        Parameters:
        names - subscribe to only those states which have any of the the provided value for name
        callback - the action to be applied on the CurrentState element received as a result of subscription
        Returns:
        a Subscription to stop the subscription
      • validate

        java.util.concurrent.CompletableFuture<CommandResponse.ValidateResponse> validate​(ControlCommand controlCommand)
        Send a Validate command and get ValidateResponse as a Future. The ValidateResponse can be of type Accepted, Invalid or Locked.

        Parameters:
        controlCommand - the ControlCommand payload
        Returns:
        a ValidateResponse as a Future value