Class QueryDispatcherConnectionImpl
java.lang.Object
com.illumon.iris.db.tables.remotequery.QueryDispatcherConnectionImpl
- All Implemented Interfaces:
com.fishlib.dataobjects.HashCommandConstants
,com.fishlib.net.api.CommandHandler
,com.fishlib.net.BaseCommandConstants
,RemoteQueryCommandConstants
,QueryDispatcherConnection
public class QueryDispatcherConnectionImpl extends Object implements RemoteQueryCommandConstants, com.fishlib.net.api.CommandHandler, QueryDispatcherConnection
Implementation of
QueryDispatcherConnection
.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.tables.remotequery.QueryDispatcherConnection
QueryDispatcherConnection.QueryProcessorRequestHandle
-
Field Summary
Fields Modifier and Type Field Description static long
DISPATCHER_TIMEOUT_MS
Fields inherited from interface com.fishlib.net.BaseCommandConstants
PING, PONG, REGISTER_QUEUE_LISTENER, RESPONSE
Fields inherited from interface com.fishlib.dataobjects.HashCommandConstants
HASHTABLE_CLEAR, HASHTABLE_GET_ALL_ENTRIES, HASHTABLE_GET_KEYS, HASHTABLE_PUT, HASHTABLE_PUTALL, HASHTABLE_REMOVE, HASHTABLE_REMOVEALL, HASHTABLE_SUBSCRIBE, HASHTABLE_UNSUBSCRIBE
Fields inherited from interface com.illumon.iris.db.RemoteQueryCommandConstants
CANCEL_REMOTE_QUERY, CURRENT_HEAP_UPDATE, GET_TABLE_PARTITION_ID, LOG_BUFFER_RECORD, LOG_BUFFER_SUBSCRIPTION, MAXIMUM_HEAP_REQUEST, PROGRESS_UPDATE, REGISTER, REMOTE_QUERY_CONCURRENT, REMOTE_QUERY_DISPATCHER_ADD_JOB, REMOTE_QUERY_DISPATCHER_ADMIN_COMMAND, REMOTE_QUERY_DISPATCHER_CANCEL_JOB, REMOTE_QUERY_DISPATCHER_PUSH_CLASSES, REMOTE_QUERY_FATAL_ERROR, REMOTE_QUERY_GET_SCOPE_VAR, REMOTE_QUERY_METHOD_CALL, REMOTE_QUERY_PREEMPTIVE_TABLE_DELTA, REMOTE_QUERY_PREEMPTIVE_TABLE_SNAPSHOT, REMOTE_QUERY_PREEMPTIVE_TABLE_SUBSCRIPTION, REMOTE_QUERY_PROCESSOR_TERMINATE, REMOTE_QUERY_RELEASE_REFERENCE, REMOTE_QUERY_SERIAL, REMOTE_QUERY_TABLE_ERROR, REMOTE_TABLE_HANDLE_CREATE, REMOTE_TABLE_HANDLE_UPDATE, REMOTE_TABLE_MAP_KEY_ADDITION, REMOTE_TABLE_MAP_RELEASE, RTLM_CREATE_LOGGER, RTLM_DELETE_TABLE, SUBSCRIBE_USAGE_UPDATES, UNUSED_REMOTE_QUERY_GET_TABLE_SEGMENT_BLOCK_ASYNC
-
Method Summary
Modifier and Type Method Description static QueryDispatcherConnection
getConnection()
static QueryDispatcherConnection
getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams)
static QueryDispatcherConnection
getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)
static QueryDispatcherConnection
getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager, BiConsumer<com.fishlib.net.api.ClientEntry,com.fishlib.base.Command> commandHandler, Consumer<com.fishlib.net.api.ClientEntry> clientDeathHandler, Consumer<QueryDispatcherConnection> newConnectionConsumer)
Factory method to get a QueryDispatcherConnection for remote queries.static QueryDispatcherConnection
getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, BiConsumer<com.fishlib.net.api.ClientEntry,com.fishlib.base.Command> commandHandler, Consumer<com.fishlib.net.api.ClientEntry> clientDeathHandler, Consumer<QueryDispatcherConnection> newConnectionConsumer)
static QueryDispatcherConnection
getConnection(com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams)
static QueryDispatcherConnection
getConnection(com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)
static QueryDispatcherConnection
getConnection(String dispatcherHost, int dispatcherPort)
static QueryDispatcherConnection
getConnection(String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams)
static QueryDispatcherConnection
getConnection(String dispatcherHost, int dispatcherPort, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)
static QueryDispatcherConnection
getConnectionIfAvailable(com.fishlib.auth.WAuthenticationClientManager authenticationClientManager, String dispatcherHost, int dispatcherPort)
Factory method to get a QueryDispatcherConnection for remote queries.static QueryDispatcherConnection
getConnectionIfAvailable(String dispatcherHost, int dispatcherPort)
String
getDispatcherHost()
QueryProcessorConnection
getQueryProcessor(boolean addClientClassesToClassPath, List<RemoteQueryClassDefinition> classList, long timeoutMillis)
Gets a query processor assigned by the dispatcher, optionally pushing client classes.QueryProcessorConnection
getQueryProcessor(QueryDispatcherConnection.QueryProcessorRequestHandle handle, RemoteProcessingRequest request, boolean exportQueryScope, List<RemoteQueryClassDefinition> classList, long timeoutMillis, QueryProcessorConnection.DisconnectHandler disconnectHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams)
Gets a query processor assigned by the dispatcher, and pushes client classes for use in future queries.QueryProcessorConnection
getQueryProcessor(QueryDispatcherConnection.QueryProcessorRequestHandle handle, RemoteProcessingRequest request, boolean exportQueryScope, List<RemoteQueryClassDefinition> classList, long timeoutMillis, QueryProcessorConnection.DisconnectHandler disconnectHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)
Gets a query processor assigned by the dispatcher, and pushes client classes for use in future queries.QueryProcessorConnection
getQueryProcessor(RemoteProcessingRequest request, List<RemoteQueryClassDefinition> classList)
Gets a query processor assigned by the dispatcher, and pushes client classes for use in future queries.QueryProcessorConnection
getQueryProcessor(RemoteProcessingRequest request, List<RemoteQueryClassDefinition> classList, long timeoutMillis)
QueryDispatcherConnection.QueryProcessorRequestHandle
getQueryProcessorRequestHandle(boolean combineWorkerConnectionStats)
Create a new, single-use handle for use in requesting a new query processor.void
handleClientDeath(com.fishlib.net.api.ClientEntry client)
void
handleCommand(com.fishlib.net.api.ClientEntry client, com.fishlib.base.Command comm)
boolean
isConnected()
void
pushClientClasses(List<RemoteQueryClassDefinition> classList)
Pushes client classes to the dispatcher for use in future queries.void
release(boolean force)
This optional method allows programs to ensure that no dispatcher CommClient connections remain, if it's called once for the result of every getConnection() invocation.static void
releaseAll(com.fishlib.io.logger.Logger log, boolean force)
com.fishlib.base.Command
sendCommand(com.fishlib.base.Command command)
String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.tables.remotequery.QueryDispatcherConnection
getQueryProcessorRequestHandle
-
Field Details
-
DISPATCHER_TIMEOUT_MS
public static final long DISPATCHER_TIMEOUT_MS- See Also:
- Constant Field Values
-
-
Method Details
-
sendCommand
- Specified by:
sendCommand
in interfaceQueryDispatcherConnection
- Throws:
IOException
-
handleCommand
public void handleCommand(com.fishlib.net.api.ClientEntry client, com.fishlib.base.Command comm)- Specified by:
handleCommand
in interfacecom.fishlib.net.api.CommandHandler
-
handleClientDeath
public void handleClientDeath(com.fishlib.net.api.ClientEntry client)- Specified by:
handleClientDeath
in interfacecom.fishlib.net.api.CommandHandler
-
getDispatcherHost
- Specified by:
getDispatcherHost
in interfaceQueryDispatcherConnection
-
toString
-
pushClientClasses
Pushes client classes to the dispatcher for use in future queries.- Specified by:
pushClientClasses
in interfaceQueryDispatcherConnection
- Parameters:
classList
- the classes to be pushed- Throws:
IOException
- from the socket operations
-
getQueryProcessorRequestHandle
public QueryDispatcherConnection.QueryProcessorRequestHandle getQueryProcessorRequestHandle(boolean combineWorkerConnectionStats)Description copied from interface:QueryDispatcherConnection
Create a new, single-use handle for use in requesting a new query processor.- Specified by:
getQueryProcessorRequestHandle
in interfaceQueryDispatcherConnection
- Parameters:
combineWorkerConnectionStats
- if true, use one set of statistics items for the worker connection statistics, rather than a different set of items for each worker connection- Returns:
- A new, single-use handle for use in requesting a new query processor.
-
getQueryProcessor
public QueryProcessorConnection getQueryProcessor(QueryDispatcherConnection.QueryProcessorRequestHandle handle, RemoteProcessingRequest request, boolean exportQueryScope, List<RemoteQueryClassDefinition> classList, long timeoutMillis, @Nullable QueryProcessorConnection.DisconnectHandler disconnectHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager) throws RemoteQueryExceptionGets a query processor assigned by the dispatcher, and pushes client classes for use in future queries.- Specified by:
getQueryProcessor
in interfaceQueryDispatcherConnection
- Parameters:
handle
-request
-exportQueryScope
-classList
-timeoutMillis
- How long to wait for the job to be scheduled and the processor to be assigned. <= 0 means practically forever.disconnectHandler
-connectionMonitorParams
-authenticationClientManager
-- Returns:
- Throws:
RemoteQueryException
-
getQueryProcessor
public QueryProcessorConnection getQueryProcessor(QueryDispatcherConnection.QueryProcessorRequestHandle handle, RemoteProcessingRequest request, boolean exportQueryScope, List<RemoteQueryClassDefinition> classList, long timeoutMillis, @Nullable QueryProcessorConnection.DisconnectHandler disconnectHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams) throws RemoteQueryExceptionGets a query processor assigned by the dispatcher, and pushes client classes for use in future queries.- Specified by:
getQueryProcessor
in interfaceQueryDispatcherConnection
- Parameters:
handle
-request
-classList
-timeoutMillis
- How long to wait for the job to be scheduled and the processor to be assigned. <= 0 means practically forever.disconnectHandler
-connectionMonitorParams
-- Returns:
- A new QueryProcessorConnection
- Throws:
RemoteQueryException
-
getQueryProcessor
public QueryProcessorConnection getQueryProcessor(boolean addClientClassesToClassPath, List<RemoteQueryClassDefinition> classList, long timeoutMillis) throws RemoteQueryExceptionGets a query processor assigned by the dispatcher, optionally pushing client classes. This method will create a RemoteProcessingRequest and automatically retry authentication with different origins if a failure occurs -
getQueryProcessor
public QueryProcessorConnection getQueryProcessor(RemoteProcessingRequest request, List<RemoteQueryClassDefinition> classList, long timeoutMillis) throws RemoteQueryException- Specified by:
getQueryProcessor
in interfaceQueryDispatcherConnection
- Throws:
RemoteQueryException
-
getQueryProcessor
public QueryProcessorConnection getQueryProcessor(RemoteProcessingRequest request, List<RemoteQueryClassDefinition> classList) throws RemoteQueryExceptionGets a query processor assigned by the dispatcher, and pushes client classes for use in future queries. Uses default timeout (1 week, effectively infinite).- Specified by:
getQueryProcessor
in interfaceQueryDispatcherConnection
- Parameters:
request
- the remote processing requestclassList
- the classes to be pushed- Returns:
- the QueryProcessorConnection
- Throws:
RemoteQueryException
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceQueryDispatcherConnection
- Returns:
- The internal CommClient's connection status.
-
release
This optional method allows programs to ensure that no dispatcher CommClient connections remain, if it's called once for the result of every getConnection() invocation. Calling it more than once per getConnection() will result in unexpectedly disconnected clients.- Specified by:
release
in interfaceQueryDispatcherConnection
- Parameters:
force
- force a disconnection even if the reference count is not zero- Throws:
IOException
- from the socket calls
-
releaseAll
public static void releaseAll(com.fishlib.io.logger.Logger log, boolean force) -
getConnection
- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(@Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(@Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(String dispatcherHost, int dispatcherPort) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @Nullable BiConsumer<com.fishlib.net.api.ClientEntry,com.fishlib.base.Command> commandHandler, @Nullable Consumer<com.fishlib.net.api.ClientEntry> clientDeathHandler, @Nullable Consumer<QueryDispatcherConnection> newConnectionConsumer) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager) throws IOException- Throws:
IOException
-
getConnection
public static QueryDispatcherConnection getConnection(com.fishlib.io.logger.Logger log, String dispatcherHost, int dispatcherPort, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager, @Nullable BiConsumer<com.fishlib.net.api.ClientEntry,com.fishlib.base.Command> commandHandler, @Nullable Consumer<com.fishlib.net.api.ClientEntry> clientDeathHandler, @Nullable Consumer<QueryDispatcherConnection> newConnectionConsumer) throws IOExceptionFactory method to get a QueryDispatcherConnection for remote queries. See release() for connection cleanup, if desired.- Parameters:
log
- the logdispatcherHost
- the dispatcher's hostdispatcherPort
- the dispatcher's portconnectionMonitorParams
- the connection monitor parametersauthenticationClientManager
- an authentication client managercommandHandler
- if provided, a consumer to be called when a command is sent by the dispatcherclientDeathHandler
- if provided, a consumer to be called when the dispatcher diesnewConnectionConsumer
- if provided, a consumer to be called if a new connection is established- Returns:
- A new connection if none is cached for the host/port pair provided, or the cached connection
- Throws:
IOException
- from the socket calls
-
getConnectionIfAvailable
public static QueryDispatcherConnection getConnectionIfAvailable(com.fishlib.auth.WAuthenticationClientManager authenticationClientManager, String dispatcherHost, int dispatcherPort)Factory method to get a QueryDispatcherConnection for remote queries. See release() for connection cleanup, if desired.- Parameters:
dispatcherHost
- the dispatcher's hostdispatcherPort
- the dispatcher's port- Returns:
- The cached connection if one is available and connected, or null if none is available
-
getConnectionIfAvailable
public static QueryDispatcherConnection getConnectionIfAvailable(String dispatcherHost, int dispatcherPort)
-