gearpump-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From huafengw <...@git.apache.org>
Subject [GitHub] incubator-gearpump pull request #67: fix GEARPUMP-32, introduce source water...
Date Wed, 27 Jul 2016 09:59:18 GMT
Github user huafengw commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/67#discussion_r72412383
  
    --- Diff: streaming/src/main/scala/org/apache/gearpump/streaming/source/DataSourceTask.scala
---
    @@ -46,23 +46,39 @@ class DataSourceTask private[source](context: TaskContext, conf: UserConfig,
sou
       }
       private val batchSize = conf.getInt(DataSourceConfig.SOURCE_READ_BATCH_SIZE).getOrElse(1000)
       private var startTime = 0L
    +  private var lastWatermark: TimeStamp = startTime
     
       override def onStart(newStartTime: StartTime): Unit = {
         startTime = newStartTime.startTime
         LOG.info(s"opening data source at $startTime")
         source.open(context, startTime)
    -    self ! Message("start", System.currentTimeMillis())
    +    self ! Message("start")
       }
     
       override def onNext(message: Message): Unit = {
         0.until(batchSize).foreach { _ =>
    -      Option(source.read()).foreach(context.output)
    +      Option(source.read()).foreach { msg =>
    +        context.output(msg)
    +      }
         }
    -    self ! Message("continue", System.currentTimeMillis())
    +
    +    maybeUpdateWatermark()
    +    self ! Message("continue")
       }
     
       override def onStop(): Unit = {
         LOG.info("closing data source...")
         source.close()
       }
    +
    +  private def maybeUpdateWatermark(): Unit = {
    +    val curWatermark = source.getWatermark
    +    if (curWatermark > lastWatermark) {
    +      lastWatermark = curWatermark
    +      self ! UpstreamMinClock(curWatermark)
    --- End diff --
    
    Once the watermark move forward, the Actor will send an UpstreamMinClock to self. If DataSource's
watermark updates frequently, will it be a problem? I mean the UpstreamMinClock flood.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message