Tabnine Logo
StreamExecutionEnvironment.createLocalEnvironment
Code IndexAdd Tabnine to your IDE (free)

How to use
createLocalEnvironment
method
in
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment

Best Java code snippets using org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment (Showing top 20 results out of 315)

origin: apache/flink

/**
 * Creates a {@link LocalStreamEnvironment}. The local execution environment
 * will run the program in a multi-threaded fashion in the same JVM as the
 * environment was created in. The default parallelism of the local
 * environment is the number of hardware contexts (CPU cores / threads),
 * unless it was specified differently by {@link #setParallelism(int)}.
 *
 * @return A local execution environment.
 */
public static LocalStreamEnvironment createLocalEnvironment() {
  return createLocalEnvironment(defaultLocalParallelism);
}
origin: apache/flink

/**
 * Creates a {@link LocalStreamEnvironment}. The local execution environment
 * will run the program in a multi-threaded fashion in the same JVM as the
 * environment was created in. It will use the parallelism specified in the
 * parameter.
 *
 * @param parallelism
 *         The parallelism for the local environment.
 * @return A local execution environment with the specified parallelism.
 */
public static LocalStreamEnvironment createLocalEnvironment(int parallelism) {
  return createLocalEnvironment(parallelism, new Configuration());
}
origin: apache/flink

/**
 * A thin wrapper layer over {@link StreamExecutionEnvironment#createLocalEnvironment(int, Configuration)}.
 *
 * @param parallelism The parallelism for the local environment.
 * @param config Pass a custom configuration into the cluster
 * @return A local python execution environment with the specified parallelism.
 */
public PythonStreamExecutionEnvironment create_local_execution_environment(int parallelism, Configuration config) {
  return new PythonStreamExecutionEnvironment(
    StreamExecutionEnvironment.createLocalEnvironment(parallelism, config), new Path(localTmpPath), scriptName);
}
origin: apache/flink

/**
 * Creates an execution environment that represents the context in which the
 * program is currently executed. If the program is invoked standalone, this
 * method returns a local execution environment, as returned by
 * {@link #createLocalEnvironment()}.
 *
 * @return The execution environment of the context in which the program is
 * executed.
 */
public static StreamExecutionEnvironment getExecutionEnvironment() {
  if (contextEnvironmentFactory != null) {
    return contextEnvironmentFactory.createExecutionEnvironment();
  }
  // because the streaming project depends on "flink-clients" (and not the other way around)
  // we currently need to intercept the data set environment and create a dependent stream env.
  // this should be fixed once we rework the project dependencies
  ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
  if (env instanceof ContextEnvironment) {
    return new StreamContextEnvironment((ContextEnvironment) env);
  } else if (env instanceof OptimizerPlanEnvironment || env instanceof PreviewPlanEnvironment) {
    return new StreamPlanEnvironment(env);
  } else {
    return createLocalEnvironment();
  }
}
origin: apache/flink

/**
 * Creates a {@link LocalStreamEnvironment} for local program execution that also starts the
 * web monitoring UI.
 *
 * <p>The local execution environment will run the program in a multi-threaded fashion in
 * the same JVM as the environment was created in. It will use the parallelism specified in the
 * parameter.
 *
 * <p>If the configuration key 'rest.port' was set in the configuration, that particular
 * port will be used for the web UI. Otherwise, the default port (8081) will be used.
 */
@PublicEvolving
public static StreamExecutionEnvironment createLocalEnvironmentWithWebUI(Configuration conf) {
  checkNotNull(conf, "conf");
  conf.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true);
  if (!conf.contains(RestOptions.PORT)) {
    // explicitly set this option so that it's not set to 0 later
    conf.setInteger(RestOptions.PORT, RestOptions.PORT.defaultValue());
  }
  return createLocalEnvironment(defaultLocalParallelism, conf);
}
origin: apache/flink

@Test
public void testUserProvidedHashing() {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  List<String> userHashes = Arrays.asList("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
  env.addSource(new NoOpSourceFunction(), "src").setUidHash(userHashes.get(0))
      .map(new NoOpMapFunction())
      .filter(new NoOpFilterFunction())
      .keyBy(new NoOpKeySelector())
      .reduce(new NoOpReduceFunction()).name("reduce").setUidHash(userHashes.get(1));
  StreamGraph streamGraph = env.getStreamGraph();
  int idx = 1;
  for (JobVertex jobVertex : streamGraph.getJobGraph().getVertices()) {
    List<JobVertexID> idAlternatives = jobVertex.getIdAlternatives();
    Assert.assertEquals(idAlternatives.get(idAlternatives.size() - 1).toString(), userHashes.get(idx));
    --idx;
  }
}
origin: apache/flink

/**
 * If expected values ever change double check that the change is not braking the contract of
 * {@link StreamingRuntimeContext#getOperatorUniqueID()} being stable between job submissions.
 */
@Test
public void testGetOperatorUniqueID() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.fromElements(1, 2, 3)
    .map(new VerifyOperatorIDMapFunction("6c4f323f22da8fb6e34f80c61be7a689")).uid("42")
    .map(new VerifyOperatorIDMapFunction("3e129e83691e7737fbf876b47452acbc")).uid("44");
  env.execute();
}
origin: apache/flink

/**
 * Tests that there are no collisions with two identical sources.
 *
 * <pre>
 * [ (src0) ] --\
 *               +--> [ (sink) ]
 * [ (src1) ] --/
 * </pre>
 */
@Test
public void testNodeHashIdenticalSources() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.setParallelism(4);
  env.disableOperatorChaining();
  DataStream<String> src0 = env.addSource(new NoOpSourceFunction());
  DataStream<String> src1 = env.addSource(new NoOpSourceFunction());
  src0.union(src1).addSink(new NoOpSinkFunction());
  JobGraph jobGraph = env.getStreamGraph().getJobGraph();
  List<JobVertex> vertices = jobGraph.getVerticesSortedTopologicallyFromSources();
  assertTrue(vertices.get(0).isInputVertex());
  assertTrue(vertices.get(1).isInputVertex());
  assertNotNull(vertices.get(0).getID());
  assertNotNull(vertices.get(1).getID());
  assertNotEquals(vertices.get(0).getID(), vertices.get(1).getID());
}
origin: apache/flink

/**
 * Tests that a changed operator name does not affect the hash.
 */
@Test
public void testChangedOperatorName() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.addSource(new NoOpSourceFunction(), "A").map(new NoOpMapFunction());
  JobGraph jobGraph = env.getStreamGraph().getJobGraph();
  JobVertexID expected = jobGraph.getVerticesAsArray()[0].getID();
  env = StreamExecutionEnvironment.createLocalEnvironment();
  env.addSource(new NoOpSourceFunction(), "B").map(new NoOpMapFunction());
  jobGraph = env.getStreamGraph().getJobGraph();
  JobVertexID actual = jobGraph.getVerticesAsArray()[0].getID();
  assertEquals(expected, actual);
}
origin: apache/flink

/**
 * Tests that a manual hash at the beginning of a chain is accepted.
 */
@Test
public void testManualHashAssignmentForStartNodeInInChain() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.setParallelism(4);
  env.addSource(new NoOpSourceFunction()).uid("source")
      .map(new NoOpMapFunction())
      .addSink(new NoOpSinkFunction());
  env.getStreamGraph().getJobGraph();
}
origin: apache/flink

/**
 * Tests that a manual hash for an intermediate chain node is accepted.
 */
@Test
public void testManualHashAssignmentForIntermediateNodeInChain() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.setParallelism(4);
  env.addSource(new NoOpSourceFunction())
      // Intermediate chained node
      .map(new NoOpMapFunction()).uid("map")
      .addSink(new NoOpSinkFunction());
  env.getStreamGraph().getJobGraph();
}
origin: apache/flink

/**
 * Tests that there are no collisions with two identical intermediate nodes connected to the
 * same predecessor.
 *
 * <pre>
 *             /-> [ (map) ] -> [ (sink) ]
 * [ (src) ] -+
 *             \-> [ (map) ] -> [ (sink) ]
 * </pre>
 */
@Test
public void testNodeHashIdenticalNodes() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.setParallelism(4);
  env.disableOperatorChaining();
  DataStream<String> src = env.addSource(new NoOpSourceFunction());
  src.map(new NoOpMapFunction()).addSink(new NoOpSinkFunction());
  src.map(new NoOpMapFunction()).addSink(new NoOpSinkFunction());
  JobGraph jobGraph = env.getStreamGraph().getJobGraph();
  Set<JobVertexID> vertexIds = new HashSet<>();
  for (JobVertex vertex : jobGraph.getVertices()) {
    assertTrue(vertexIds.add(vertex.getID()));
  }
}
origin: apache/flink

/**
 * Tests that a collision on the manual hash throws an Exception.
 */
@Test(expected = IllegalArgumentException.class)
public void testManualHashAssignmentCollisionThrowsException() throws Exception {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.setParallelism(4);
  env.disableOperatorChaining();
  env.addSource(new NoOpSourceFunction()).uid("source")
      .map(new NoOpMapFunction()).uid("source") // Collision
      .addSink(new NoOpSinkFunction());
  // This call is necessary to generate the job graph
  env.getStreamGraph().getJobGraph();
}
origin: apache/flink

final StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
env.enableCheckpointing(500);
origin: apache/flink

StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
    .get(0).getID();
env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
origin: apache/flink

@Test
public void testUserProvidedHashingOnChainSupported() {
  StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
  env.addSource(new NoOpSourceFunction(), "src").setUidHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
      .map(new NoOpMapFunction()).setUidHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
      .filter(new NoOpFilterFunction()).setUidHash("cccccccccccccccccccccccccccccccc")
      .keyBy(new NoOpKeySelector())
      .reduce(new NoOpReduceFunction()).name("reduce").setUidHash("dddddddddddddddddddddddddddddddd");
  env.getStreamGraph().getJobGraph();
}
origin: apache/flink

StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
JobVertexID chainedMapId = chainedMap.getID();
env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
origin: apache/flink

StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
env.disableOperatorChaining();
env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
env.disableOperatorChaining();
origin: apache/flink

StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
env = StreamExecutionEnvironment.createLocalEnvironment();
env.setParallelism(4);
origin: uber/AthenaX

public static CompilationResult compileJob(JobDescriptor job) {
 StreamExecutionEnvironment execEnv = StreamExecutionEnvironment.createLocalEnvironment();
 StreamTableEnvironment env = StreamTableEnvironment.getTableEnvironment(execEnv);
 execEnv.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
 CompilationResult res = new CompilationResult();
 try {
  res.jobGraph(new JobCompiler(env, job).getJobGraph());
 } catch (IOException e) {
  res.remoteThrowable(e);
 }
 return res;
}
org.apache.flink.streaming.api.environmentStreamExecutionEnvironmentcreateLocalEnvironment

Javadoc

Creates a LocalStreamEnvironment. The local execution environment will run the program in a multi-threaded fashion in the same JVM as the environment was created in. The default parallelism of the local environment is the number of hardware contexts (CPU cores / threads), unless it was specified differently by #setParallelism(int).

Popular methods of StreamExecutionEnvironment

  • execute
  • getExecutionEnvironment
    Creates an execution environment that represents the context in which the program is currently execu
  • addSource
    Ads a data source with a custom type information thus opening a DataStream. Only in very special cas
  • getConfig
    Gets the config object.
  • enableCheckpointing
    Enables checkpointing for the streaming job. The distributed state of the streaming dataflow will be
  • setStreamTimeCharacteristic
    Sets the time characteristic for all streams create from this environment, e.g., processing time, ev
  • setParallelism
    Sets the parallelism for operations executed through this environment. Setting a parallelism of x he
  • fromElements
    Creates a new data stream that contains the given elements. The elements must all be of the same typ
  • setStateBackend
    Sets the state backend that describes how to store and checkpoint operator state. It defines both wh
  • fromCollection
    Creates a data stream from the given iterator.Because the iterator will remain unmodified until the
  • getCheckpointConfig
    Gets the checkpoint config, which defines values like checkpoint interval, delay between checkpoints
  • getParallelism
    Gets the parallelism with which operation are executed by default. Operations can individually overr
  • getCheckpointConfig,
  • getParallelism,
  • getStreamGraph,
  • setRestartStrategy,
  • socketTextStream,
  • readTextFile,
  • generateSequence,
  • clean,
  • getStreamTimeCharacteristic

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JFrame (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now