Class DataImportServerCommandChannel
java.lang.Object
com.illumon.iris.db.tables.dataimport.logtailer.DataImportServerCommandChannel
- All Implemented Interfaces:
AutoCloseable
public class DataImportServerCommandChannel extends Object implements AutoCloseable
Open a socket to a DataImportServer, in preparation for sending commands.
Unlike
LogtailerDestinationManager
, this connection is not tied to a specific table location
and it doesn't have an ongoing job, or thread.
TODO: this needs a maintenance thread (or something similar) that can close the socket after a period of inactivity-
Constructor Summary
Constructors Constructor Description DataImportServerCommandChannel(com.fishlib.io.logger.Logger log, SocketAddress remoteAddress, String disName)
Construct a manager to log stream commands.DataImportServerCommandChannel(com.fishlib.io.logger.Logger log, SocketAddress remoteAddress, String disName, com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)
Construct a manager to log stream commands. -
Method Summary
Modifier and Type Method Description void
close()
AckTruncateMessage
delete(FullTableLocationKey key, boolean dryRun)
Instruct the DataImportServer to delete the specified locations, and wait for confirmation.AckRescanMessage
rescan(String namespace, String tableName)
Instruct the DataImportServer to rescan the specified location (or all locations if null), and wait for confirmation.AckTruncateMessage
truncate(FullTableLocationKey key)
Delegate totruncate(FullTableLocationKey, boolean)
with dryRun set to false.AckTruncateMessage
truncate(FullTableLocationKey key, boolean dryRun)
Instruct the DataImportServer to truncate the specified location, and wait for confirmation.
-
Constructor Details
-
DataImportServerCommandChannel
public DataImportServerCommandChannel(com.fishlib.io.logger.Logger log, SocketAddress remoteAddress, String disName)Construct a manager to log stream commands. Uses the default authentication manager.- Parameters:
log
- the log to which errors will be sentremoteAddress
- the address of the remote DataImportServer for this connectiondisName
- the name of the targeted DataImportServer. Useful for logging
-
DataImportServerCommandChannel
public DataImportServerCommandChannel(@NotNull com.fishlib.io.logger.Logger log, @NotNull SocketAddress remoteAddress, @NotNull String disName, @NotNull com.fishlib.auth.WAuthenticationClientManager authenticationClientManager)Construct a manager to log stream commands.- Parameters:
log
- the log to which errors will be sentremoteAddress
- the address of the remote DataImportServer for this connectiondisName
- the name of the targeted DataImportServer. Useful for loggingauthenticationClientManager
- a new authentication client manager
-
-
Method Details
-
truncate
public AckTruncateMessage truncate(FullTableLocationKey key) throws IOException, AuthUtil.AuthenticationFailure, ChannelExceptionDelegate totruncate(FullTableLocationKey, boolean)
with dryRun set to false. -
truncate
public AckTruncateMessage truncate(FullTableLocationKey key, boolean dryRun) throws IOException, AuthUtil.AuthenticationFailure, ChannelExceptionInstruct the DataImportServer to truncate the specified location, and wait for confirmation.- Parameters:
key
- FullTableLocationKey specifying the locations to be truncated; will be AggregateTableLocationKey in most cases.dryRun
- if true, don't really truncate data, just say what would have happened- Returns:
- An AckTruncateMessage containing detailed results of the operation
- Throws:
IOException
- for communication errorsChannelException
- also for communication errorsAuthUtil.AuthenticationFailure
- if the truncation failed due to authentication or permission failure
-
delete
public AckTruncateMessage delete(FullTableLocationKey key, boolean dryRun) throws IOException, AuthUtil.AuthenticationFailure, ChannelExceptionInstruct the DataImportServer to delete the specified locations, and wait for confirmation. Locations may be deleted only after they have been truncated.- Parameters:
key
- FullTableLocationKey specifying the locations to be deleted; will be AggregateTableLocationKey in most cases.dryRun
- if true, don't really delete data, just say what would have happened- Returns:
- An AckTruncateMessage containing detailed results of the operation
- Throws:
IOException
- for communication errorsChannelException
- also for communication errorsAuthUtil.AuthenticationFailure
- if the truncation failed due to authentication or permission failure
-
rescan
public AckRescanMessage rescan(@Nullable String namespace, @Nullable String tableName) throws IOException, ChannelExceptionInstruct the DataImportServer to rescan the specified location (or all locations if null), and wait for confirmation.- Parameters:
namespace
- (optional) namespace of the the table to rescan. If specified, tableName is required.tableName
- (optional) name of the table to rescan. If specified, namespace is required.- Returns:
- An AckRescanMessage containing detailed results of the operation
- Throws:
IOException
- for communication errorsChannelException
- also for communication errorsAuthUtil.AuthenticationFailure
- if the truncation failed due to authentication or permission failure
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-