Class Executor

java.lang.Object
com.google.jenkins.plugins.util.Executor
Direct Known Subclasses:
Executor.Default, MockExecutor

public abstract class Executor extends Object
Interface for a class that executes requests on behalf of a Json API client.

NOTE: This can be used to intercept or mock all "execute" requests.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A default, failure-tolerant implementation of the Executor class.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    execute(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<T> request)
    Executes the request, returning a response of the appropriate type.
    abstract <T> T
    Executes the request, returning a response of the appropriate type.
    void
    Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
    void
    sleep(int retryAttempt)
    Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Executor

      public Executor()
  • Method Details

    • execute

      public <T> T execute(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<T> request) throws IOException, ExecutorException
      Executes the request, returning a response of the appropriate type.
      Type Parameters:
      T - The type of the expected response
      Parameters:
      request - The request we are issuing
      Returns:
      a Json object of the given type
      Throws:
      IOException - if anything goes wrong
      ExecutorException
    • execute

      public abstract <T> T execute(RequestCallable<T> request) throws IOException, ExecutorException
      Executes the request, returning a response of the appropriate type.
      Type Parameters:
      T - The type of the expected response
      Parameters:
      request - The request we are issuing
      Returns:
      a Json object of the given type
      Throws:
      IOException - if anything goes wrong
      ExecutorException
    • sleep

      public void sleep()
      Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
    • sleep

      public void sleep(int retryAttempt)
      Surface this as a canonical means by which to sleep, so that clients can layer their own retry logic on top of the executor using the same sleep facility;
      Parameters:
      retryAttempt - indicates how many times we had retried, to allow for increasing back-off time.