Class LocalCall<R>

  • Type Parameters:
    R - the return type of the called function
    All Implemented Interfaces:
    Call<R>

    public class LocalCall<R>
    extends AbstractCall<R>
    Class representing a function call of a salt execution module.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Optional<java.util.List<?>> arg  
      private java.util.Optional<java.lang.Integer> gatherJobTimeout  
      private java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg  
      private java.util.Optional<?> metadata  
      private java.util.Optional<java.lang.Integer> timeout  
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalCall​(java.lang.String functionName, java.util.Optional<java.util.List<?>> arg, java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType)  
      LocalCall​(java.lang.String functionName, java.util.Optional<java.util.List<?>> arg, java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, java.util.Optional<?> metadata)  
      LocalCall​(java.lang.String functionName, java.util.Optional<java.util.List<?>> arg, java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, java.util.Optional<?> metadata, java.util.Optional<java.lang.Integer> timeout, java.util.Optional<java.lang.Integer> gatherJobTimeout)  
      LocalCall​(java.lang.String functionName, java.util.Optional<java.util.List<?>> arg, java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, java.util.Optional<java.lang.Integer> timeout, java.util.Optional<java.lang.Integer> gatherJobTimeout)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client, Target<?> target, AuthMethod auth)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result.
      java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client, Target<?> target, AuthMethod auth, Batch batch)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result.
      java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(SaltClient client, Target<?> target, AuthMethod auth, EventStream events, java.util.concurrent.CompletionStage<GenericError> cancel, Batch batch)
      Calls this salt call via the async client and returns the results as they come in via the event stream.
      java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(SaltClient client, Target<?> target, AuthMethod auth, EventStream events, java.util.concurrent.CompletionStage<GenericError> cancel, java.util.Optional<Batch> batch)
      Calls this salt call via the async client and returns the results as they come in via the event stream.
      java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client, Target<?> target, AuthMethod auth, java.util.Optional<Batch> batch)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result.
      java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(java.util.function.Function<LocalCall<R>,​java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>>> localAsync, java.util.function.Function<RunnerCall<java.util.Map<java.lang.String,​R>>,​java.util.concurrent.CompletionStage<RunnerAsyncResult<java.util.Map<java.lang.String,​R>>>> runnerAsync, EventStream events, java.util.concurrent.CompletionStage<GenericError> cancel)
      Calls this salt call via the async client and returns the results as they come in via the event stream.
      java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​Result<R>>> callSync​(SaltClient client, Target<?> target, AuthMethod auth)
      Calls a execution module function on the given target and synchronously waits for the result.
      java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSync​(SaltClient client, Target<?> target, AuthMethod auth, Batch batch)
      Calls a execution module function on the given target with batching and synchronously waits for the result.
      java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSync​(SaltClient client, Target<?> target, AuthMethod auth, java.util.Optional<Batch> batch)
      Calls a execution module function on the given target with batching and synchronously waits for the result.
      private java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSyncHelperNonBlock​(SaltClient client, Target<?> target, AuthMethod auth, java.util.Optional<Batch> batch)
      Helper to call an execution module function on the given target for batched or unbatched while also providing an option to use the given credentials or to use a prior created token.
      java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​Result<SSHResult<R>>>> callSyncSSH​(SaltClient client, SSHTarget<?> target, SaltSSHConfig cfg, AuthMethod auth)
      Call an execution module function on the given target via salt-ssh and synchronously wait for the result.
      java.util.Map<java.lang.String,​java.lang.Object> getPayload()
      Return the call payload as a map of key/value pairs.
      private java.util.List<java.util.Map<java.lang.String,​Result<R>>> handleRetcodeBatchingHack​(java.util.List<java.util.Map<java.lang.String,​Result<R>>> list, java.lang.reflect.Type xor)  
      private static <R> void onJobReturn​(java.lang.String jid, JobReturnEvent jre, com.google.gson.reflect.TypeToken<Result<R>> tt, java.util.Map<java.lang.String,​java.util.concurrent.CompletableFuture<Result<R>>> targets)  
      private static <R> void onRunnerReturn​(java.lang.String jid, RunnerReturnEvent rre, com.google.gson.reflect.TypeToken<Result<R>> tt, java.util.Map<java.lang.String,​java.util.concurrent.CompletableFuture<Result<R>>> targets)  
      LocalCall<R> withMetadata​(java.lang.Object metadata)  
      LocalCall<R> withoutMetadata()  
      LocalCall<R> withoutTimeouts()  
      LocalCall<R> withTimeouts​(java.util.Optional<java.lang.Integer> timeout, java.util.Optional<java.lang.Integer> gatherJobTimeout)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • arg

        private final java.util.Optional<java.util.List<?>> arg
      • kwarg

        private final java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg
      • metadata

        private final java.util.Optional<?> metadata
      • timeout

        private final java.util.Optional<java.lang.Integer> timeout
      • gatherJobTimeout

        private final java.util.Optional<java.lang.Integer> gatherJobTimeout
    • Constructor Detail

      • LocalCall

        public LocalCall​(java.lang.String functionName,
                         java.util.Optional<java.util.List<?>> arg,
                         java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg,
                         com.google.gson.reflect.TypeToken<R> returnType,
                         java.util.Optional<?> metadata,
                         java.util.Optional<java.lang.Integer> timeout,
                         java.util.Optional<java.lang.Integer> gatherJobTimeout)
      • LocalCall

        public LocalCall​(java.lang.String functionName,
                         java.util.Optional<java.util.List<?>> arg,
                         java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg,
                         com.google.gson.reflect.TypeToken<R> returnType,
                         java.util.Optional<java.lang.Integer> timeout,
                         java.util.Optional<java.lang.Integer> gatherJobTimeout)
      • LocalCall

        public LocalCall​(java.lang.String functionName,
                         java.util.Optional<java.util.List<?>> arg,
                         java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg,
                         com.google.gson.reflect.TypeToken<R> returnType,
                         java.util.Optional<?> metadata)
      • LocalCall

        public LocalCall​(java.lang.String functionName,
                         java.util.Optional<java.util.List<?>> arg,
                         java.util.Optional<java.util.Map<java.lang.String,​?>> kwarg,
                         com.google.gson.reflect.TypeToken<R> returnType)
    • Method Detail

      • withMetadata

        public LocalCall<R> withMetadata​(java.lang.Object metadata)
      • withoutMetadata

        public LocalCall<R> withoutMetadata()
      • withTimeouts

        public LocalCall<R> withTimeouts​(java.util.Optional<java.lang.Integer> timeout,
                                         java.util.Optional<java.lang.Integer> gatherJobTimeout)
      • withoutTimeouts

        public LocalCall<R> withoutTimeouts()
      • getPayload

        public java.util.Map<java.lang.String,​java.lang.Object> getPayload()
        Return the call payload as a map of key/value pairs. Usually this contains the function name and arguments, but the various clients differ in the details.
        Returns:
        call payload as a map of key/value pairs
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client,
                                                                                                       Target<?> target,
                                                                                                       AuthMethod auth,
                                                                                                       Batch batch)
        Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        auth - authentication credentials to use
        batch - parameter for enabling and configuring batching
        Returns:
        information about the scheduled job
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client,
                                                                                                       Target<?> target,
                                                                                                       AuthMethod auth,
                                                                                                       java.util.Optional<Batch> batch)
        Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        auth - authentication credentials to use
        batch - parameter for enabling and configuring batching
        Returns:
        information about the scheduled job
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>> callAsync​(SaltClient client,
                                                                                                       Target<?> target,
                                                                                                       AuthMethod auth)
        Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        auth - authentication credentials to use
        Returns:
        information about the scheduled job
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(SaltClient client,
                                                                                                                                                                         Target<?> target,
                                                                                                                                                                         AuthMethod auth,
                                                                                                                                                                         EventStream events,
                                                                                                                                                                         java.util.concurrent.CompletionStage<GenericError> cancel,
                                                                                                                                                                         Batch batch)
        Calls this salt call via the async client and returns the results as they come in via the event stream.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        events - the event stream to use
        cancel - future to cancel the action
        auth - authentication credentials to use
        batch - parameter for enabling and configuring batching
        Returns:
        a map from minion id to future of the result.
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(SaltClient client,
                                                                                                                                                                         Target<?> target,
                                                                                                                                                                         AuthMethod auth,
                                                                                                                                                                         EventStream events,
                                                                                                                                                                         java.util.concurrent.CompletionStage<GenericError> cancel,
                                                                                                                                                                         java.util.Optional<Batch> batch)
        Calls this salt call via the async client and returns the results as they come in via the event stream.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        events - the event stream to use
        cancel - future to cancel the action
        auth - authentication credentials to use
        batch - parameter for enabling and configuring batching
        Returns:
        a map from minion id to future of the result.
      • callAsync

        public java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,​java.util.concurrent.CompletionStage<Result<R>>>>> callAsync​(java.util.function.Function<LocalCall<R>,​java.util.concurrent.CompletionStage<java.util.Optional<LocalAsyncResult<R>>>> localAsync,
                                                                                                                                                                         java.util.function.Function<RunnerCall<java.util.Map<java.lang.String,​R>>,​java.util.concurrent.CompletionStage<RunnerAsyncResult<java.util.Map<java.lang.String,​R>>>> runnerAsync,
                                                                                                                                                                         EventStream events,
                                                                                                                                                                         java.util.concurrent.CompletionStage<GenericError> cancel)
        Calls this salt call via the async client and returns the results as they come in via the event stream.
        Parameters:
        localAsync - function providing callAsync for LocalCalls
        runnerAsync - function providing callAsync for RunnerCalls
        events - the event stream to use
        cancel - future to cancel the action
        Returns:
        a map from minion id to future of the result.
      • callSync

        public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​Result<R>>> callSync​(SaltClient client,
                                                                                                              Target<?> target,
                                                                                                              AuthMethod auth)
        Calls a execution module function on the given target and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        auth - authentication credentials to use
        Returns:
        a map containing the results with the minion name as key
      • callSync

        public java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSync​(SaltClient client,
                                                                                                                              Target<?> target,
                                                                                                                              AuthMethod auth,
                                                                                                                              Batch batch)
        Calls a execution module function on the given target with batching and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        batch - the batch specification
        auth - authentication credentials to use
        Returns:
        A list of maps with each list representing each batch, and maps containing the results with the minion names as keys.
      • callSync

        public java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSync​(SaltClient client,
                                                                                                                              Target<?> target,
                                                                                                                              AuthMethod auth,
                                                                                                                              java.util.Optional<Batch> batch)
        Calls a execution module function on the given target with batching and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        auth - authentication credentials to use
        batch - parameter for enabling and configuring batching
        Returns:
        A list of maps with each list representing each batch, and maps containing the results with the minion names as keys.
      • handleRetcodeBatchingHack

        private java.util.List<java.util.Map<java.lang.String,​Result<R>>> handleRetcodeBatchingHack​(java.util.List<java.util.Map<java.lang.String,​Result<R>>> list,
                                                                                                          java.lang.reflect.Type xor)
      • callSyncHelperNonBlock

        private java.util.concurrent.CompletionStage<java.util.List<java.util.Map<java.lang.String,​Result<R>>>> callSyncHelperNonBlock​(SaltClient client,
                                                                                                                                             Target<?> target,
                                                                                                                                             AuthMethod auth,
                                                                                                                                             java.util.Optional<Batch> batch)
        Helper to call an execution module function on the given target for batched or unbatched while also providing an option to use the given credentials or to use a prior created token. Synchronously waits for the result.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        batch - the batch parameter, empty for unbatched
        auth - authentication credentials to use
        Returns:
        A list of maps with each list representing each batch, and maps containing the results with the minion names as keys. The first list is the entire output for unbatched input.
      • callSyncSSH

        public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,​Result<SSHResult<R>>>> callSyncSSH​(SaltClient client,
                                                                                                                            SSHTarget<?> target,
                                                                                                                            SaltSSHConfig cfg,
                                                                                                                            AuthMethod auth)
        Call an execution module function on the given target via salt-ssh and synchronously wait for the result.
        Parameters:
        client - SaltClient instance
        target - the target for the function
        cfg - Salt SSH configuration object
        auth - authentication credentials to use
        Returns:
        a map containing the results with the minion name as key
      • onRunnerReturn

        private static <R> void onRunnerReturn​(java.lang.String jid,
                                               RunnerReturnEvent rre,
                                               com.google.gson.reflect.TypeToken<Result<R>> tt,
                                               java.util.Map<java.lang.String,​java.util.concurrent.CompletableFuture<Result<R>>> targets)
      • onJobReturn

        private static <R> void onJobReturn​(java.lang.String jid,
                                            JobReturnEvent jre,
                                            com.google.gson.reflect.TypeToken<Result<R>> tt,
                                            java.util.Map<java.lang.String,​java.util.concurrent.CompletableFuture<Result<R>>> targets)