flink-issues 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] (FLINK-3551) Sync Scala and Java Streaming Examples
Date Fri, 25 Nov 2016 17:18:58 GMT

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

ASF GitHub Bot commented on FLINK-3551:
---------------------------------------

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

    https://github.com/apache/flink/pull/2761#discussion_r89644293
  
    --- Diff: flink-examples/flink-examples-streaming/src/main/scala/org/apache/flink/streaming/scala/examples/kafka/ReadFromKafka.scala
---
    @@ -0,0 +1,72 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.streaming.scala.examples.kafka
    +
    +import org.apache.flink.api.common.restartstrategy.RestartStrategies
    +import org.apache.flink.api.java.utils.ParameterTool
    +import org.apache.flink.streaming.api.scala._
    +import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer08
    +import org.apache.flink.streaming.util.serialization.SimpleStringSchema
    +
    +/**
    +  * Read Strings from Kafka and print them to standard out.
    +  * Note: On a cluster, DataStream.print() will print to the TaskManager's .out file!
    +  *
    +  * Please pass the following arguments to run the example:
    +  * --topic test
    +  * --bootstrap.servers localhost:9092
    +  * --zookeeper.connect localhost:2181
    +  * --group.id myconsumer
    +  *
    +  */
    +object ReadFromKafka {
    +
    +  def main(args: Array[String]): Unit = {
    +
    +    // parse input arguments
    +    val params = ParameterTool.fromArgs(args)
    +
    +    if (params.getNumberOfParameters < 4) {
    +      println("Missing parameters!\nUsage: Kafka --topic <topic> " +
    +        "--bootstrap.servers <kafka brokers> --zookeeper.connect <zk quorum>
--group.id <some id>")
    +      return
    +    }
    +
    +    val env = StreamExecutionEnvironment.getExecutionEnvironment
    +    env.getConfig.disableSysoutLogging
    +    env.getConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(4, 10000))
    +    // create a checkpoint every 5 seconds
    +    env.enableCheckpointing(5000)
    +    // make parameters available in the web interface
    +    env.getConfig.setGlobalJobParameters(params)
    +
    +    // create a Kafka streaming source consumer for Kafka 0.8.x
    +    val kafkaConsumer = new FlinkKafkaConsumer08(
    --- End diff --
    
    Actually I saw that there is a related issue [FLINK-4286 Have Kafka examples that use
the Kafka 0.9 connector](https://issues.apache.org/jira/browse/FLINK-4286) which basically
requests to have examples for different Kafka versions (eg, Kafka08.jar, Kafka09.jar). 
    So I just synced exactly same as Java's examples and thinking of let FLINK-4286 to take
care about the different versions of Kafka.
    
    However, if use the more recent one make more sense to you, I am happy to update it


> Sync Scala and Java Streaming Examples
> --------------------------------------
>
>                 Key: FLINK-3551
>                 URL: https://issues.apache.org/jira/browse/FLINK-3551
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Examples
>    Affects Versions: 1.0.0
>            Reporter: Stephan Ewen
>            Assignee: Lim Chee Hau
>             Fix For: 1.0.1
>
>
> The Scala Examples lack behind the Java Examples



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

Mime
View raw message