Package org.apache.flink.streaming.api.environment

Examples of org.apache.flink.streaming.api.environment.StreamExecutionEnvironment


    }
  }

  // Example for connecting data streams
  public static void main(String[] args) throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(
        PARALLELISM).setBufferTimeout(100);

    DataStream<Tuple3<Integer, Long, Integer>> querySource = env.addSource(new QuerySource(),
        SOURCE_PARALLELISM).partitionBy(0);

    DataStream<String> stream = env.addSource(new InfoSource(), SOURCE_PARALLELISM)
        .partitionBy(0).connect(querySource).map(new CellTask());
    stream.print();

    env.execute();
  }
View Full Code Here


  // This example will join two streams with a sliding window. One which emits
  // people's grades and one which emits people's salaries.

  public static void main(String[] args) throws Exception {

    StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(
        PARALLELISM).setBufferTimeout(100);

    DataStream<Tuple3<String, Integer, Long>> grades = env.addSource(new GradeSource(),
        SOURCE_PARALLELISM);

    DataStream<Tuple3<String, Integer, Long>> salaries = env.addSource(new SalarySource(),
        SOURCE_PARALLELISM);

    DataStream<Tuple3<String, Integer, Integer>> joinedStream = grades.connect(salaries)
        .flatMap(new WindowJoinTask());

    System.out.println("(NAME, GRADE, SALARY)");
    joinedStream.print();

    env.execute();

  }
View Full Code Here

  private static final int SOURCE_PARALELISM = 1;

  public static void main(String[] args) throws Exception {

    StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(1);

    @SuppressWarnings("unused")
    DataStream<String> stream1 = env
      .addSource(new MyKafkaSource("localhost:2181", "group", "test", 1), SOURCE_PARALELISM)
      .addSink(new MyKafkaPrintSink());

    @SuppressWarnings("unused")
    DataStream<String> stream2 = env
      .addSource(new MySource())
      .addSink(new MyKafkaSink("test", "localhost:9092"));

    env.execute();
  }
View Full Code Here

    assertEquals(expectedMinList0, MockInvokable.createAndExecute(
        new StreamReduceInvokable<Integer>(minFunction0), simpleInput));
    assertEquals(expectedMaxList0, MockInvokable.createAndExecute(
        new StreamReduceInvokable<Integer>(maxFunction0), simpleInput));

    StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
    try {
      env.generateSequence(1, 100).min(1);
      fail();
    } catch (Exception e) {
      // Nothing to do here
    }
    try {
      env.generateSequence(1, 100).min(2);
      fail();
    } catch (Exception e) {
      // Nothing to do here
    }
    try {
      env.generateSequence(1, 100).min(3);
      fail();
    } catch (Exception e) {
      // Nothing to do here
    }
View Full Code Here

TOP

Related Classes of org.apache.flink.streaming.api.environment.StreamExecutionEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.