gearpump-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEARPUMP-192) refactor example sources task to use DataSource API
Date Fri, 02 Sep 2016 00:42:20 GMT

    [ https://issues.apache.org/jira/browse/GEARPUMP-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15457095#comment-15457095
] 

ASF GitHub Bot commented on GEARPUMP-192:
-----------------------------------------

Github user Roshanson commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/78#discussion_r77278370
  
    --- Diff: examples/streaming/wordcount/src/main/scala/org/apache/gearpump/streaming/examples/wordcount/Split.scala
---
    @@ -23,29 +23,34 @@ import java.util.concurrent.TimeUnit
     
     import org.apache.gearpump.Message
     import org.apache.gearpump.cluster.UserConfig
    -import org.apache.gearpump.streaming.source.Watermark
    +import org.apache.gearpump.streaming.source.{DataSource, DataSourceTask, Watermark}
     import org.apache.gearpump.streaming.task.{Task, TaskContext}
     
    -class Split(taskContext: TaskContext, conf: UserConfig) extends Task(taskContext, conf)
{
    -  import taskContext.output
     
    -  override def onStart(startTime: Instant): Unit = {
    -    self ! Watermark(Instant.now)
    -  }
    +class Split() extends DataSource {
    +
    +
    +  override def open(context: TaskContext, startTime: Instant): Unit = {}
     
    -  override def onNext(msg: Message): Unit = {
    +
    +  override def read(): Message = {
         Split.TEXT_TO_SPLIT.lines.foreach { line =>
           line.split("[\\s]+").filter(_.nonEmpty).foreach { msg =>
    -        output(new Message(msg, System.currentTimeMillis()))
    +        new Message(msg, System.currentTimeMillis())
           }
         }
    -
    -    import scala.concurrent.duration._
    -    taskContext.scheduleOnce(Duration(100, TimeUnit.MILLISECONDS))(self !
    -      Watermark(Instant.now))
    +    Message("message")
       }
    +
    +  override def close(): Unit = {}
    +
    +  override def getWatermark: Instant = Instant.now()
    +
    +  Watermark(Instant.now)
    --- End diff --
    
    Thanks´╝îi'm learning how  gearpump  is working now.


> refactor example sources task to use DataSource API
> ---------------------------------------------------
>
>                 Key: GEARPUMP-192
>                 URL: https://issues.apache.org/jira/browse/GEARPUMP-192
>             Project: Apache Gearpump
>          Issue Type: Improvement
>          Components: streaming
>    Affects Versions: 0.8.1
>            Reporter: Manu Zhang
>            Assignee: Kaifang Bao
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message