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

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

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

    https://github.com/apache/flink/pull/6091#discussion_r192316418
  
    --- Diff: 
flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/AsyncDataStreamITCase.scala
 ---
    @@ -0,0 +1,157 @@
    +/*
    + * 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.api.scala
    +
    +import java.util.concurrent.TimeUnit
    +
    +import org.apache.flink.streaming.api.functions.sink.SinkFunction
    +import org.apache.flink.streaming.api.functions.source.SourceFunction
    +import org.apache.flink.streaming.api.scala.AsyncDataStreamITCase._
    +import org.apache.flink.streaming.api.scala.async.{AsyncFunction, 
ResultFuture}
    +import org.apache.flink.test.util.AbstractTestBase
    +import org.junit.Assert._
    +import org.junit.Test
    +
    +import scala.collection.mutable
    +import scala.concurrent.{ExecutionContext, Future}
    +
    +object AsyncDataStreamITCase {
    +  val timeout = 1000L
    +  private var testResult: mutable.ArrayBuffer[Int] = _
    +}
    +
    +class AsyncDataStreamITCase extends AbstractTestBase {
    +
    +  @Test
    +  def testOrderedWait(): Unit = {
    +    testAsyncWait(true)
    +  }
    +
    +  @Test
    +  def testUnorderedWait(): Unit = {
    +    testAsyncWait(false)
    +  }
    +
    +  private def testAsyncWait(ordered: Boolean): Unit = {
    +    val env = StreamExecutionEnvironment.getExecutionEnvironment
    +    env.setParallelism(1)
    +
    +    val source = env.addSource(new SourceFunction[Int]() {
    +      override def run(ctx: SourceFunction.SourceContext[Int]) {
    +        ctx.collect(1)
    +        ctx.collect(2)
    +      }
    +      override def cancel() {}
    +    })
    +
    +    val asyncMapped = if (ordered) {
    +      AsyncDataStream.orderedWait(
    +        source, new MyAsyncFunction(), timeout, TimeUnit.MILLISECONDS)
    +    } else {
    +      AsyncDataStream.unorderedWait(
    +        source, new MyAsyncFunction(), timeout, TimeUnit.MILLISECONDS)
    +    }
    +
    +    testResult = mutable.ArrayBuffer[Int]()
    --- End diff --
    
    can you extract the lines between 71 and 85 to a private function and 
deduplicate them with `testAsyncWaitUsingAnonymousFunction`?


> Add handler for Async IO operator timeouts 
> -------------------------------------------
>
>                 Key: FLINK-7789
>                 URL: https://issues.apache.org/jira/browse/FLINK-7789
>             Project: Flink
>          Issue Type: Improvement
>          Components: DataStream API
>            Reporter: Karthik Deivasigamani
>            Assignee: blues zheng
>            Priority: Major
>
> Currently Async IO operator does not provide a mechanism to handle timeouts. 
> When a request times out it an exception is thrown and job is restarted. It 
> would be good to pass a AsyncIOTimeoutHandler which can be implemented by the 
> user and passed in the constructor.
> Here is the discussion from apache flink users mailing list 
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/async-io-operator-timeouts-tt16068.html



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to