仅当记录数超过x时才启动Kinesis使用者吗?

问题描述 投票:7回答:1

有没有一种方法可以创建具有缓冲区限制的Kinesis使用者?像here

#Flush when buffer exceeds 100000 Amazon Kinesis records, 64 MB size limit or when time since last buffer exceeds 1 hour
bufferByteSizeLimit = 67108864 
bufferRecordCountLimit = 100000
bufferMillisecondsLimit = 3600000

基本上,我只想在有大量数据时才启动IRecordProcessor。我无法使用上面的连接器代码,因为我需要latestamazon-kinesis-client版本。

amazon-kinesis
1个回答
0
投票

我最终实现了自己的解决方案。

  1. 具有ConcurrentHashMap以存储流数据
      private val recsMap = new ConcurrentHashMap[String, List[RecordStore]]
      private val currByteSize = new AtomicLong(0L)
      private val currRecordCount = new AtomicLong(0L)
      private val currSeconds = new AtomicLong(0L)
    
  2. 更新计数器(按大小/时间/记录数)
  3. 到达计数器时清除数据
      recsMap.foreach(write2File())
      // clean up
      recsMap.remove(writtenRecs())
    
  4. 检查点和重置计数器
      // reset counters
      currByteSize.getAndSet(value)
      currRecordCount.getAndSet(value)
      currSeconds.getAndSet(value)
    
© www.soinside.com 2019 - 2024. All rights reserved.