Class LogAggregatorWriterStandard
java.lang.Object
com.illumon.iris.db.v2.logaggregator.LogAggregatorWriterStandard
- All Implemented Interfaces:
SinglePartitionWriter,Closeable,AutoCloseable
Write binary rows to a log aggregation service. This implementation is for column partition values that are not
determined by row-level data. They may still change, for example based on the current date.
After construction, this will contain an authenticated and accepted connection to the LAS for the given identifiers. If the channel connection is broken, attempts will be made to reconnect. Once either the client or server requests/indicates termination, or the client initiates a terminating command, the connection will be permanently closed.
This object is expected to be used by a single thread. Synchronization is to ensure that multiple commands don't occur at the same time, and to ensure that we don't close and check connections at the same time.
After construction, this will contain an authenticated and accepted connection to the LAS for the given identifiers. If the channel connection is broken, attempts will be made to reconnect. Once either the client or server requests/indicates termination, or the client initiates a terminating command, the connection will be permanently closed.
This object is expected to be used by a single thread. Synchronization is to ensure that multiple commands don't occur at the same time, and to ensure that we don't close and check connections at the same time.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLogAggregatorWriterStandard(@NotNull ByteBuffer header, @NotNull com.fishlib.io.logger.Logger log, @NotNull InetSocketAddress serverAddress, @NotNull String namespace, @NotNull String tableName, TableIdentifier.NamespaceSet namespaceSet, @NotNull String internalPartition, @NotNull String columnPartition, TokenFactoryFactory tokenFactorySource) LogAggregatorWriterStandard(@NotNull ByteBuffer header, @NotNull com.fishlib.io.logger.Logger log, @NotNull InetSocketAddress serverAddress, @NotNull String namespace, @NotNull String tableName, TableIdentifier.NamespaceSet namespaceSet, @NotNull String internalPartition, @NotNull String columnPartition, ZoneId zoneId, TokenFactoryFactory tokenFactorySource, @Nullable BiFunction<String, ZoneId, ExpirationManager<String>> columnPartitionFactory) Create a BinaryStoreAggregatorWriterStandard for the specified time zone. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Send FLUSH message, poll for ACK, CLIENT_FINISHED message, poll for an ACK and close the channel.voidflush()@NotNull GatheringByteChannelOpen a channel to the Log Aggregator Service and initialize it with table identifiers and binary header.protected static ExpirationManager<String>makeColumnPartitionFactory(String columnPartition, ZoneId zoneid) Injection point for testing.voidSend a command message to the Log Aggregator, requesting that the current partition be deleted.voidwriteDataToPartition(int numRows, @NotNull ByteBuffer buffer) Write all the row data to the partition.
-
Field Details
-
NULL_PARTITION
- See Also:
-
-
Constructor Details
-
LogAggregatorWriterStandard
public LogAggregatorWriterStandard(@NotNull @NotNull ByteBuffer header, @NotNull @NotNull com.fishlib.io.logger.Logger log, @NotNull @NotNull InetSocketAddress serverAddress, @NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull TableIdentifier.NamespaceSet namespaceSet, @NotNull @NotNull String internalPartition, @NotNull @NotNull String columnPartition, TokenFactoryFactory tokenFactorySource) throws IOException Delegate toLogAggregatorWriterStandard(ByteBuffer, Logger, InetSocketAddress, String, String, TableIdentifier.NamespaceSet, String, String, ZoneId, TokenFactoryFactory, BiFunction)using the default time zone.- Parameters:
header-log- the Logger instanceserverAddress- the LAS server's addressnamespace- the namespacetableName- the table namenamespaceSet- the namespace setinternalPartition- the internal partitioncolumnPartition- the column partition; if NULL_PARTITION is specified, then the current date column partition factory will be used to determine column partition valuestokenFactorySource- a token source for authentication- Throws:
IOException- from initialization
-
LogAggregatorWriterStandard
public LogAggregatorWriterStandard(@NotNull @NotNull ByteBuffer header, @NotNull @NotNull com.fishlib.io.logger.Logger log, @NotNull @NotNull InetSocketAddress serverAddress, @NotNull @NotNull String namespace, @NotNull @NotNull String tableName, @NotNull TableIdentifier.NamespaceSet namespaceSet, @NotNull @NotNull String internalPartition, @NotNull @NotNull String columnPartition, ZoneId zoneId, TokenFactoryFactory tokenFactorySource, @Nullable @Nullable BiFunction<String, ZoneId, throws IOExceptionExpirationManager<String>> columnPartitionFactory) Create a BinaryStoreAggregatorWriterStandard for the specified time zone. This is for a specific table location (i.e. namespace/table name/namespace set/internal partition), with column partition values either specified explicitly or determined by a current-date column partition factory.- Parameters:
header-log- the Logger instanceserverAddress- the LAS server's addressnamespace- the namespacetableName- the table namenamespaceSet- the namespace setinternalPartition- the internal partitioncolumnPartition- the column partition; if NULL_PARTITION is specified, then the current date column partition factory will be used to determine column partition valueszoneId- the time zone ID for standard partition determination, or null to use the system default zonetokenFactorySource- a token source for authentication- Throws:
IOException- from initialization
-
-
Method Details
-
getChannel
Open a channel to the Log Aggregator Service and initialize it with table identifiers and binary header. This getChannel implementation only works for standard-column-partition-determination instances.- Returns:
- non-null, open channel to the server, else an exception
- Throws:
IOException
-
close
Send FLUSH message, poll for ACK, CLIENT_FINISHED message, poll for an ACK and close the channel.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSinglePartitionWriter- Throws:
IOException- if an error occurred while closing this writer
-
flush
- Throws:
IOException
-
sendDeletePartition
Send a command message to the Log Aggregator, requesting that the current partition be deleted. The connection will be closed by the server, no further data or commands are allowed.- Throws:
IOException
-
makeColumnPartitionFactory
protected static ExpirationManager<String> makeColumnPartitionFactory(String columnPartition, ZoneId zoneid) Injection point for testing.- Parameters:
columnPartition- the column partition passed into the caller, orNULL_PARTITIONif the partition should be determined by the datezoneid- the ZoneId needed to create a DailyExpiration- Returns:
- an ExpirationManager appropriate to the member variables
-
writeDataToPartition
public void writeDataToPartition(int numRows, @NotNull @NotNull ByteBuffer buffer) throws IOException Description copied from interface:SinglePartitionWriterWrite all the row data to the partition.A write operation will return only after writing all the bytes, with the
buffer's position moved to its limit.On error, the
buffer's position will have been updated to account for the data that was successfully written; though, it is not safe to reuse this interface in an attempt to re-write the data (given the stateful nature of this interface).This is not meant to be called by third parties; the signature and documentation for this method is subject to change at any time.
This method is not guaranteed to be thread-safe. The assumption is that the caller only calls this method from exactly one thread, or uses concurrency control primitives that create a happens-before barrier between calls.
- Specified by:
writeDataToPartitionin interfaceSinglePartitionWriter- Parameters:
numRows- the number of rows represented inbuffer, must be positivebuffer- the buffer to write- Throws:
IOException- if an IO error occurred
-