Java Code Examples for org.apache.flink.api.common.operators.ResourceSpec#merge()
The following examples show how to use
org.apache.flink.api.common.operators.ResourceSpec#merge() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamGraphGeneratorTest.java From flink with Apache License 2.0 | 6 votes |
/** * Test iteration job, check slot sharing group and co-location group. */ @Test public void testIteration() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> source = env.fromElements(1, 2, 3).name("source"); IterativeStream<Integer> iteration = source.iterate(3000); iteration.name("iteration").setParallelism(2); DataStream<Integer> map = iteration.map(x -> x + 1).name("map").setParallelism(2); DataStream<Integer> filter = map.filter((x) -> false).name("filter").setParallelism(2); iteration.closeWith(filter).print(); final ResourceSpec resources = ResourceSpec.newBuilder(1.0, 100).build(); iteration.getTransformation().setResources(resources, resources); StreamGraph streamGraph = env.getStreamGraph(); for (Tuple2<StreamNode, StreamNode> iterationPair : streamGraph.getIterationSourceSinkPairs()) { assertNotNull(iterationPair.f0.getCoLocationGroup()); assertEquals(iterationPair.f0.getCoLocationGroup(), iterationPair.f1.getCoLocationGroup()); assertEquals(StreamGraphGenerator.DEFAULT_SLOT_SHARING_GROUP, iterationPair.f0.getSlotSharingGroup()); assertEquals(iterationPair.f0.getSlotSharingGroup(), iterationPair.f1.getSlotSharingGroup()); final ResourceSpec sourceMinResources = iterationPair.f0.getMinResources(); final ResourceSpec sinkMinResources = iterationPair.f1.getMinResources(); final ResourceSpec iterationResources = sourceMinResources.merge(sinkMinResources); assertThat(iterationResources, equalsResourceSpec(resources)); } }
Example 2
Source File: StreamingJobGraphGenerator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedMinResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec minResources = streamGraph.getStreamNode(vertexID).getMinResources(); for (StreamEdge chainable : chainedOutputs) { minResources = minResources.merge(chainedMinResources.get(chainable.getTargetId())); } return minResources; }
Example 3
Source File: StreamingJobGraphGenerator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedPreferredResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec preferredResources = streamGraph.getStreamNode(vertexID).getPreferredResources(); for (StreamEdge chainable : chainedOutputs) { preferredResources = preferredResources.merge(chainedPreferredResources.get(chainable.getTargetId())); } return preferredResources; }
Example 4
Source File: StreamingJobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedMinResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec minResources = streamGraph.getStreamNode(vertexID).getMinResources(); for (StreamEdge chainable : chainedOutputs) { minResources = minResources.merge(chainedMinResources.get(chainable.getTargetId())); } return minResources; }
Example 5
Source File: StreamingJobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedPreferredResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec preferredResources = streamGraph.getStreamNode(vertexID).getPreferredResources(); for (StreamEdge chainable : chainedOutputs) { preferredResources = preferredResources.merge(chainedPreferredResources.get(chainable.getTargetId())); } return preferredResources; }
Example 6
Source File: StreamingJobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedMinResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec minResources = streamGraph.getStreamNode(vertexID).getMinResources(); for (StreamEdge chainable : chainedOutputs) { minResources = minResources.merge(chainedMinResources.get(chainable.getTargetId())); } return minResources; }
Example 7
Source File: StreamingJobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private ResourceSpec createChainedPreferredResources(Integer vertexID, List<StreamEdge> chainedOutputs) { ResourceSpec preferredResources = streamGraph.getStreamNode(vertexID).getPreferredResources(); for (StreamEdge chainable : chainedOutputs) { preferredResources = preferredResources.merge(chainedPreferredResources.get(chainable.getTargetId())); } return preferredResources; }