Class PerfClientUtils

java.lang.Object
org.apache.pulsar.testclient.PerfClientUtils

public class PerfClientUtils extends Object
Utility for test clients.
  • Constructor Details

    • PerfClientUtils

      public PerfClientUtils()
  • Method Details

    • setExitProcedure

      public static void setExitProcedure(Consumer<Integer> exitProcedure)
    • exit

      public static void exit(int code)
    • printJVMInformation

      public static void printJVMInformation(org.slf4j.Logger log)
      Print useful JVM information, you need this information in order to be able to compare the results of executions in different environments.
      Parameters:
      log -
    • createClientBuilderFromArguments

      public static ClientBuilder createClientBuilderFromArguments(PerformanceBaseArguments arguments) throws PulsarClientException.UnsupportedAuthenticationException
      Throws:
      PulsarClientException.UnsupportedAuthenticationException
    • createAdminBuilderFromArguments

      public static PulsarAdminBuilder createAdminBuilderFromArguments(PerformanceBaseArguments arguments, String adminUrl) throws PulsarClientException.UnsupportedAuthenticationException
      Throws:
      PulsarClientException.UnsupportedAuthenticationException
    • addShutdownHook

      public static Thread addShutdownHook(Runnable runnable)
      This is used to register a shutdown hook that will be called when the JVM exits.
      Parameters:
      runnable - the runnable to run on shutdown
      Returns:
      the thread that was registered as a shutdown hook
    • removeAndRunShutdownHook

      public static void removeAndRunShutdownHook(Thread shutdownHookThread) throws InterruptedException
      This is used to remove a previously registered shutdown hook and run it immediately. This is useful at least for tests when there are multiple instances of the classes in the JVM. It will also prevent resource leaks when test code isn't relying on the JVM exit to clean up resources.
      Parameters:
      shutdownHookThread - the shutdown hook thread to remove and run
      Throws:
      InterruptedException - if the thread is interrupted while waiting for it to finish
    • closeClient

      public static void closeClient(PulsarClient client)
      This is used to close the client so that the interrupted status is cleared before closing the client. This is needed if the thread is already interrupted before calling this method.
      Parameters:
      client - the client to close
    • hasInterruptedException

      public static boolean hasInterruptedException(Throwable throwable)
      Check if the throwable or any of its causes is an InterruptedException.
      Parameters:
      throwable - the throwable to check
      Returns:
      true if the throwable or any of its causes is an InterruptedException, false otherwise