Class BinaryStoreAggregatorWriterMultiPartition
java.lang.Object
com.illumon.iris.binarystore.AbstractBinaryStoreWriter<BinaryRowV2>
com.illumon.iris.binarystore.BinaryStoreWriterV2
com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition
- All Implemented Interfaces:
ChannelManager
,ChannelManagerMultiPartition
,Entry
,Record
,Row
,TableWriter<BinaryRowV2>
public class BinaryStoreAggregatorWriterMultiPartition extends BinaryStoreWriterV2 implements ChannelManagerMultiPartition
Write binary rows to a log aggregation service. This implementation is for column partition values that are
determined dynamically (row-based).
After construction, this will contain zero or more authenticated and accepted connections 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 appropriate connection(s) 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 connections while they are being checked.
After construction, this will contain zero or more authenticated and accepted connections 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 appropriate connection(s) 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 connections while they are being checked.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.binarystore.BinaryStoreWriterV2
BinaryStoreWriterV2.DeferrableRowPartition
Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.Record
Record.RecordSetter<T extends RecordData>
-
Field Summary
Fields inherited from class com.illumon.iris.binarystore.BinaryStoreWriterV2
log, primaryRecordWriter, primaryRowWriter
-
Method Summary
Modifier and Type Method Description void
close()
Attempt to close all open channels.void
close(String columnPartitionValue)
Close the specified column partition value's channel.protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRecordWriter
createBinaryRecord()
Make sure all the record writers for this class prepend a LAS message header.protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRowWriter
createBinaryRow(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata)
Make sure all the row writers for this class prepend a LAS message header.void
flush()
Attempt to flush all channels.void
flush(String columnPartitionValue)
Flush the specified column partition value's channel.void
flushDeferredRows(BinaryStoreWriterV2.DeferrableRowPartition part)
Flush all of the deferred rows in the input collection to the underlying stream.GatheringByteChannel
getChannel(String columnPartitionValue)
Get a channel to the Log Aggregator Service based on the supplied column partition value.com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRecordWriter
getRecordWriter()
Get new writer for Record entries.void
init()
boolean
isConnected(String columnPartitionValue)
Provide a way for clients to check the status of the specified column partition's writer.void
sendDeletePartition(String columnPartitionValue)
Send a command message to the Log Aggregator Service for the specified column partition value, requesting that the specified partition be deleted.Methods inherited from class com.illumon.iris.binarystore.BinaryStoreWriterV2
computeHeaderBuffer, flushDeferredRows, getColumnNames, getColumnPartitionValue, getColumnTypes, getRecordSetter, getRecordSetter, getRowWriter, getSetter, makeCurrentDatePartitionedBinaryStoreWriter, makeMultiPartitionFileManagerBinaryStoreWriter, makeSpecifiedPartitionBinaryStoreWriter, setColumnPartitionValue, setFlags, setRecordData, writeDeferredRow, writeMulti, writeRecord, writeRow
Methods inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreWriter
setChannelManager, supportAllTypes
-
Method Details
-
createBinaryRow
protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRowWriter createBinaryRow(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata)Make sure all the row writers for this class prepend a LAS message header.- Overrides:
createBinaryRow
in classBinaryStoreWriterV2
-
createBinaryRecord
protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRecordWriter createBinaryRecord()Make sure all the record writers for this class prepend a LAS message header.- Overrides:
createBinaryRecord
in classBinaryStoreWriterV2
- Returns:
- a new BinaryRecordV2 record writer
-
getRecordWriter
public com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.LogAggregatorRecordWriter getRecordWriter()Description copied from interface:TableWriter
Get new writer for Record entries. This is likely to be newly created, so callers should cache this value. In practice, implementers generally cache the result of the first call to this method as a primary writer.- Specified by:
getRecordWriter
in interfaceTableWriter<BinaryRowV2>
- Overrides:
getRecordWriter
in classBinaryStoreWriterV2
- Returns:
- a Record, likely newly created
-
init
- Overrides:
init
in classBinaryStoreWriterV2
- Throws:
IOException
-
getChannel
Get a channel to the Log Aggregator Service based on the supplied column partition value. If necessary, create a new one and initialize it with table identifiers and binary header.- Specified by:
getChannel
in interfaceChannelManagerMultiPartition
- Parameters:
columnPartitionValue
- the column partition value- Returns:
- non-null, open channel to the Log Aggregator Service, else an exception
- Throws:
IOException
- if the call encounters an error
-
close
Attempt to close all open channels. For each channel, send a CLIENT_FINISHED message, poll for an ACK, and close the channel. If an IOException occurs on one or more channels, the first one will be rethrown, but the operation will still be attempted on all remaining channels. If an exception occurs that is not an IOException, that exception will be thrown and operations on remaining channels will not be attempted.- Specified by:
close
in interfaceChannelManager
- Specified by:
close
in interfaceTableWriter<BinaryRowV2>
- Overrides:
close
in classAbstractBinaryStoreWriter<BinaryRowV2>
- Throws:
IOException
- from the close calls
-
close
Close the specified column partition value's channel. If there is no partition for the specified column partition value, then nothing is done. Send CLIENT_FINISHED message, poll for an ACK and close the channel for the specified column partition value.- Parameters:
columnPartitionValue
- the column partition value- Throws:
IOException
- from the channel close
-
flush
Attempt to flush all channels. If an IOException occurs on one or more channels, the first one will be rethrown, but the operation will still be attempted on all remaining channels. If an exception occurs that is not an IOException, that exception will be thrown and operations on remaining channels will not be attempted.- Specified by:
flush
in interfaceChannelManager
- Specified by:
flush
in interfaceTableWriter<BinaryRowV2>
- Overrides:
flush
in classAbstractBinaryStoreWriter<BinaryRowV2>
- Throws:
IOException
- from the flush calls
-
flush
Flush the specified column partition value's channel.- Parameters:
columnPartitionValue
- the column partition value- Throws:
IOException
- from the channel flushIllegalArgumentException
- if there is no channel for the specified column partition value
-
sendDeletePartition
Send a command message to the Log Aggregator Service for the specified column partition value, requesting that the specified partition be deleted. The connection will be closed by the server, no further data or commands are allowed.- Parameters:
columnPartitionValue
- the column partition value- Throws:
IllegalArgumentException
- if there is no channel for the specified column partition valueIOException
-
isConnected
Provide a way for clients to check the status of the specified column partition's writer. The server can unilaterally close the socket, as when it encounters an error. If there isn't a current open channel for the specified column partition value, this will throw an exception.- Parameters:
columnPartitionValue
- the column partition value- Returns:
- true if the socket is open and connected.
-
flushDeferredRows
Description copied from class:BinaryStoreWriterV2
Flush all of the deferred rows in the input collection to the underlying stream.- Overrides:
flushDeferredRows
in classBinaryStoreWriterV2
- Parameters:
part
- The collection of deferred rows for the partitionVlaue- Throws:
IOException
- if an error occurs during writing. Rows may be partially written, however there are no guarantees that the rows were written completely.
-