Class RemoteQueryUtils
java.lang.Object
com.illumon.iris.db.tables.remotequery.RemoteQueryUtils
public class RemoteQueryUtils extends Object
-
Field Summary
Fields Modifier and Type Field Description static com.fishlib.net.api.DynamicCommClientPolicy
DEFAULT_CONNECTION_POLICY
static com.fishlib.io.sched.IOParameters
SERVER_IO_PARAMETERS
-
Constructor Summary
Constructors Constructor Description RemoteQueryUtils()
-
Method Summary
Modifier and Type Method Description static void
checkCommandArgs(String source, int type, boolean allowNullValues, Object[] args, Class<?>... expectedArgTypes)
Validate that the provided arguments are of the correct type or throw an IllegalCommandException.static void
checkCommandArgs(String source, int type, Object[] args, Class<?>... expectedArgTypes)
Validate that the provided arguments are of the correct type or throw an IllegalCommandException.static void
checkResponse(String source, Object[] responseArgs, Class<?>... expectedArgTypes)
Check command responses from RemoteQueryDispatcher/RemoteQueryProcessor and similar servers.static void
checkResponse2(String source, Object[] responseArgs, Class<?>... expectedArgTypes)
Check command responses from WeepsController/DbAclWriteServer and similar servers.static Set<String>
getLocalHostNames()
static IrisGroupProvider
makeGroupProvider(com.fishlib.io.logger.Logger log, Database database)
Creates a group provider using the supplied database.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.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.static String
translateHostName(String hostName)
static String
truncateHostName(String hostName)
static String
truncateHostName(String hostName, Iterable<String> suffixesToTruncate)
-
Field Details
-
DEFAULT_CONNECTION_POLICY
public static final com.fishlib.net.api.DynamicCommClientPolicy DEFAULT_CONNECTION_POLICY -
SERVER_IO_PARAMETERS
public static final com.fishlib.io.sched.IOParameters SERVER_IO_PARAMETERS
-
-
Constructor Details
-
RemoteQueryUtils
public RemoteQueryUtils()
-
-
Method Details
-
checkCommandArgs
public static void checkCommandArgs(String source, int type, Object[] args, Class<?>... expectedArgTypes) throws IllegalArgumentExceptionValidate 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 purposestype
- The command typeargs
- The arguments to validateexpectedArgTypes
- 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 IllegalArgumentExceptionValidate that the provided arguments are of the correct type or throw an IllegalCommandException.- Parameters:
source
- The name of the source for logging purposestype
- The command typeallowNullValues
- If true, then allow null argument valuesargs
- The arguments to validateexpectedArgTypes
- 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
-
truncateHostName
-
translateHostName
-
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
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.ScriptSessionImplhostName
- the hostname for the QueryScope.CLIENT_HOST_PARAM_NAME variablequeryName
- 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 loggerdatabase
- the database- Returns:
- a group provider
-