Interface SnowflakeSinkService
-
- All Known Implementing Classes:
SnowflakeSinkServiceV2
public interface SnowflakeSinkServiceBackground service of data sink, responsible to create/drop pipe and ingest/purge files
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcallAllGetOffset()used for testing onlyvoidclose(Collection<org.apache.kafka.common.TopicPartition> partitions)terminate given topic partitionsvoidcloseAll()terminate all tasks and close this service instanceSnowflakeSinkConnectorConfig.BehaviorOnNullValuesgetBehaviorOnNullValuesConfig()longgetFileSize()longgetFlushTime()Optional<com.codahale.metrics.MetricRegistry>getMetricRegistry(String partitionIdentifier)longgetOffset(org.apache.kafka.common.TopicPartition topicPartition)retrieve offset of last loaded record for given pipe nameintgetPartitionCount()get the number of partitions assigned to this sink servicelonggetRecordNumber()voidinsert(Collection<org.apache.kafka.connect.sink.SinkRecord> records)call pipe to insert a collections of JSON records will trigger time based flushvoidinsert(org.apache.kafka.connect.sink.SinkRecord record)call pipe to insert a JSON record will not trigger time based flushbooleanisClosed()retrieve sink service statusvoidsetBehaviorOnNullValuesConfig(SnowflakeSinkConnectorConfig.BehaviorOnNullValues behavior)voidsetCustomJMXMetrics(boolean enableJMX)default voidsetErrorReporter(KafkaRecordErrorReporter kafkaRecordErrorReporter)voidsetFileSize(long size)change data size of buffer to control the flush rate, the minimum file size is controlled bySnowflakeSinkConnectorConfig.BUFFER_SIZE_BYTES_MINvoidsetFlushTime(long time)change flush rate of sink service the minimum flush time is controlled bySnowflakeSinkConnectorConfig.BUFFER_FLUSH_TIME_SEC_MINvoidsetIsStoppedToTrue()close all cleaner thread but have no effect on sink service contextvoidsetMetadataConfig(SnowflakeMetadataConfig configMap)set the metadata config to let user control what metadata to be collected into SF dbvoidsetRecordNumber(long num)change maximum number of record cached in buffer to control the flush rate, 0 for unlimiteddefault voidsetSinkTaskContext(org.apache.kafka.connect.sink.SinkTaskContext sinkTaskContext)voidsetTopic2TableMap(Map<String,String> topic2TableMap)pass topic to table map to sink servicevoidstartPartition(String tableName, org.apache.kafka.common.TopicPartition topicPartition)Start the Task.voidstartPartitions(Collection<org.apache.kafka.common.TopicPartition> partitions, Map<String,String> topic2Table)Start a collection of TopicPartition.
-
-
-
Method Detail
-
startPartition
void startPartition(String tableName, org.apache.kafka.common.TopicPartition topicPartition)
Start the Task. This should handle any configuration parsing and one-time setup of the task.- Parameters:
tableName- destination table nametopicPartition- TopicPartition passed from Kafka
-
startPartitions
void startPartitions(Collection<org.apache.kafka.common.TopicPartition> partitions, Map<String,String> topic2Table)
Start a collection of TopicPartition. This should handle any configuration parsing and one-time setup of the task.- Parameters:
partitions- collection of topic partitionstopic2Table- a mapping from topic to table
-
insert
void insert(Collection<org.apache.kafka.connect.sink.SinkRecord> records)
call pipe to insert a collections of JSON records will trigger time based flush- Parameters:
records- record content
-
insert
void insert(org.apache.kafka.connect.sink.SinkRecord record)
call pipe to insert a JSON record will not trigger time based flush- Parameters:
record- record content
-
getOffset
long getOffset(org.apache.kafka.common.TopicPartition topicPartition)
retrieve offset of last loaded record for given pipe name- Parameters:
topicPartition- topic and partition- Returns:
- offset, or -1 for empty
-
getPartitionCount
int getPartitionCount()
get the number of partitions assigned to this sink service- Returns:
- number of partitions
-
callAllGetOffset
void callAllGetOffset()
used for testing only
-
closeAll
void closeAll()
terminate all tasks and close this service instance
-
close
void close(Collection<org.apache.kafka.common.TopicPartition> partitions)
terminate given topic partitions- Parameters:
partitions- a list of topic partition
-
setIsStoppedToTrue
void setIsStoppedToTrue()
close all cleaner thread but have no effect on sink service context
-
isClosed
boolean isClosed()
retrieve sink service status- Returns:
- true is closed
-
setRecordNumber
void setRecordNumber(long num)
change maximum number of record cached in buffer to control the flush rate, 0 for unlimited- Parameters:
num- a non negative long number represents number of record limitation
-
setFileSize
void setFileSize(long size)
change data size of buffer to control the flush rate, the minimum file size is controlled bySnowflakeSinkConnectorConfig.BUFFER_SIZE_BYTES_MINPlease note: The buffer size for Streaming and snowpipe doesnt necessarily translate to same file size in Snowflake.
There is Java to UTF conversion followed by file compression in gzip.
- Parameters:
size- a non negative long number represents data size limitation
-
setTopic2TableMap
void setTopic2TableMap(Map<String,String> topic2TableMap)
pass topic to table map to sink service- Parameters:
topic2TableMap- a String to String Map represents topic to table map
-
setFlushTime
void setFlushTime(long time)
change flush rate of sink service the minimum flush time is controlled bySnowflakeSinkConnectorConfig.BUFFER_FLUSH_TIME_SEC_MIN- Parameters:
time- a non negative long number represents service flush time in seconds
-
setMetadataConfig
void setMetadataConfig(SnowflakeMetadataConfig configMap)
set the metadata config to let user control what metadata to be collected into SF db- Parameters:
configMap- a String to String Map
-
getRecordNumber
long getRecordNumber()
- Returns:
- current number of record limitation
-
getFlushTime
long getFlushTime()
- Returns:
- current flush time in seconds
-
getFileSize
long getFileSize()
- Returns:
- current file size limitation
-
setBehaviorOnNullValuesConfig
void setBehaviorOnNullValuesConfig(SnowflakeSinkConnectorConfig.BehaviorOnNullValues behavior)
-
setCustomJMXMetrics
void setCustomJMXMetrics(boolean enableJMX)
-
getBehaviorOnNullValuesConfig
SnowflakeSinkConnectorConfig.BehaviorOnNullValues getBehaviorOnNullValuesConfig()
-
setErrorReporter
default void setErrorReporter(KafkaRecordErrorReporter kafkaRecordErrorReporter)
-
setSinkTaskContext
default void setSinkTaskContext(org.apache.kafka.connect.sink.SinkTaskContext sinkTaskContext)
-
-