Class RemoteQueryUtils

java.lang.Object
com.illumon.iris.db.tables.remotequery.RemoteQueryUtils

public class RemoteQueryUtils
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • checkCommandArgs

      public static void checkCommandArgs​(String source, int type, Object[] args, Class<?>... expectedArgTypes) throws IllegalArgumentException
      Validate that the provided arguments are of the correct type or throw an IllegalCommandException. Allow null argument values.
      Parameters:
      source - The name of the source for logging purposes
      type - The command type
      args - The arguments to validate
      expectedArgTypes - The expected argument types
      Throws:
      IllegalArgumentException - if the number of arguments is incorrect, or the arguments are not of the correct type
    • checkCommandArgs

      public static void checkCommandArgs​(String source, int type, boolean allowNullValues, Object[] args, Class<?>... expectedArgTypes) throws IllegalArgumentException
      Validate that the provided arguments are of the correct type or throw an IllegalCommandException.
      Parameters:
      source - The name of the source for logging purposes
      type - The command type
      allowNullValues - If true, then allow null argument values
      args - The arguments to validate
      expectedArgTypes - The expected argument types
      Throws:
      IllegalArgumentException - if the number of arguments is incorrect, or the arguments are not of the correct type, or a null argument is provided when allowNullValues is false
    • checkResponse

      public static void checkResponse​(String source, Object[] responseArgs, Class<?>... expectedArgTypes)
      Check command responses from RemoteQueryDispatcher/RemoteQueryProcessor and similar servers.
      Parameters:
      source -
      responseArgs -
      expectedArgTypes -
    • checkResponse2

      public static void checkResponse2​(String source, Object[] responseArgs, Class<?>... expectedArgTypes)
      Check command responses from WeepsController/DbAclWriteServer and similar servers.
      Parameters:
      source -
      responseArgs -
      expectedArgTypes -
    • truncateHostName

      public static String truncateHostName​(@Nullable String hostName)
    • truncateHostName

      public static String truncateHostName​(@Nullable String hostName, @NotNull Iterable<String> suffixesToTruncate)
    • translateHostName

      public static String translateHostName​(@NotNull String hostName)
    • getLocalHostNames

      public static Set<String> getLocalHostNames()
    • setupGroovySessionAndQueryScope

      public static IrisDbGroovySession setupGroovySessionAndQueryScope​(com.fishlib.io.logger.Logger log, String hostName, String queryName, Database database)
      Run this in the worker (via ContextAwareRemoteQuery to create a groovy session and setup the compiler context and query scope appropriately.
      Parameters:
      log -
      hostName -
      queryName -
      database -
      Returns:
    • setupQueryScope

      public static void setupQueryScope​(ScriptSession scriptSession, String hostName, String queryName)
      Creates a query scope using the supplied scriptSession; and sets the hostname and query name parameters within it. The new query scope is then set as the default query scope.
      Parameters:
      scriptSession - the scriptSession to wrap in a QueryScope.ScriptSessionImpl
      hostName - the hostname for the QueryScope.CLIENT_HOST_PARAM_NAME variable
      queryName - the query name for the QueryScope.QUERY_NAME_PARAM_NAME variable
    • makeGroupProvider

      public static IrisGroupProvider makeGroupProvider​(com.fishlib.io.logger.Logger log, Database database)
      Creates a group provider using the supplied database.
      Parameters:
      log - the logger
      database - the database
      Returns:
      a group provider