You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by StephanEwen <gi...@git.apache.org> on 2015/05/22 18:57:07 UTC
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
GitHub user StephanEwen opened a pull request:
https://github.com/apache/flink/pull/718
[FLINK-2084] [core] Add an option to start Flink in streaming mode
The streaming mode subsumes the batch mode, as it allows to run both kinds of programs. Batch programs will most likely run slightly less efficient than in pure batch mode, due to lazy memory allocation (see below)
Adds new startup options to the JobManager and TaskManager.
Adds additional scripts `bin/start-cluster-streaming.sh` and `start-local-streaming.sh`.
Currently, streaming mode only sets the memory manager to lazy memory allocation to ensure heap is not blocked by batch memory manager
Includes [FLINK-2085] To support on-demand memory allocation in the memory manager.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/StephanEwen/incubator-flink streaming_mode
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/718.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #718
----
commit 7b58e2d49521e955ddacfa5586659df01fe57c57
Author: Stephan Ewen <se...@apache.org>
Date: 2015-05-22T16:35:40Z
[FLINK-2085] [runtime] Add an option to let the MemoryManager allocate and release memory as needed.
This is an alternative mode to the current mode that pre-allocates all memory.
The default remains to pre-allocate all memory.
commit 43978cd979114858ad2f200f04bd1723693c2c3e
Author: Stephan Ewen <se...@apache.org>
Date: 2015-05-22T15:12:45Z
[FLINK-2084] [core] Add an option to start Flink in streaming mode
- Streaming mode sets the memory manager to lazy memory allocation to ensure
heap is not blocked by batch memory manager
commit 1df1f12e367b4b89b56e9e47dbe5a7a11e5e1583
Author: Stephan Ewen <se...@apache.org>
Date: 2015-05-22T15:24:19Z
[tests] Adjust tests for dedicated streaming mode and clean up test bases.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/718#discussion_r31026487
--- Diff: flink-dist/src/main/flink-bin/bin/jobmanager.sh ---
@@ -80,7 +81,7 @@ case $STARTSTOP in
rotateLogFile $out
echo "Starting Job Manager"
- $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --executionMode $EXECUTIONMODE --configDir "$FLINK_CONF_DIR" > "$out" 2>&1 < /dev/null &
+ $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --configDir "$FLINK_CONF_DIR" --executionMode $EXECUTIONMODE --streamingMode "$STREAMINGMODE" > "$out" 2>&1 < /dev/null &
--- End diff --
Actually, the streaming mode parameter is optional and defaults to "batch".
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/718#issuecomment-105462206
+1 looks solid.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by mxm <gi...@git.apache.org>.
Github user mxm commented on a diff in the pull request:
https://github.com/apache/flink/pull/718#discussion_r31016976
--- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/memory/MemoryManagerLazyAllocationTest.java ---
@@ -0,0 +1,209 @@
+/*
+ * 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.runtime.memory;
+
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
+import org.apache.flink.runtime.memorymanager.DefaultMemoryManager;
+import org.apache.flink.runtime.memorymanager.MemoryAllocationException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Tests for the memory manager, in the mode where it pre-allocates all memory.
+ */
+public class MemoryManagerLazyAllocationTest {
+
+ private static final long RANDOM_SEED = 643196033469871L;
+
+ private static final int MEMORY_SIZE = 1024 * 1024 * 72; // 72 MiBytes
+
+ private static final int PAGE_SIZE = 1024 * 32; // 32 KiBytes
+
+ private static final int NUM_PAGES = MEMORY_SIZE / PAGE_SIZE;
+
+ private DefaultMemoryManager memoryManager;
+
+ private Random random;
+
+
+ @Before
+ public void setUp() {
+ this.memoryManager = new DefaultMemoryManager(MEMORY_SIZE, 1, PAGE_SIZE, false);
+ this.random = new Random(RANDOM_SEED);
+ }
+
+ @After
+ public void tearDown() {
+ if (!this.memoryManager.verifyEmpty()) {
+ fail("Memory manager is not complete empty and valid at the end of the test.");
+ }
+ this.memoryManager = null;
+ this.random = null;
+ }
+
+ @Test
+ public void allocateAllSingle() {
+ try {
+ final AbstractInvokable mockInvoke = new DummyInvokable();
+ List<MemorySegment> segments = new ArrayList<MemorySegment>();
+
+ try {
+ for (int i = 0; i < NUM_PAGES; i++) {
+ segments.add(this.memoryManager.allocatePages(mockInvoke, 1).get(0));
+ }
+ }
+ catch (MemoryAllocationException e) {
+ fail("Unable to allocate memory");
+ }
+
+ for (MemorySegment seg : segments) {
+ this.memoryManager.release(seg);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void allocateAllMulti() {
+ try {
+ final AbstractInvokable mockInvoke = new DummyInvokable();
+ final List<MemorySegment> segments = new ArrayList<MemorySegment>();
+
+ try {
+ for(int i = 0; i < NUM_PAGES / 2; i++) {
+ segments.addAll(this.memoryManager.allocatePages(mockInvoke, 2));
+ }
+ } catch (MemoryAllocationException e) {
+ Assert.fail("Unable to allocate memory");
+ }
+
+ this.memoryManager.release(segments);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void allocateMultipleOwners() {
+ final int NUM_OWNERS = 17;
+
+ try {
+ AbstractInvokable[] owners = new AbstractInvokable[NUM_OWNERS];
+
+ @SuppressWarnings("unchecked")
+ List<MemorySegment>[] mems = (List<MemorySegment>[]) new List<?>[NUM_OWNERS];
+
+ for (int i = 0; i < NUM_OWNERS; i++) {
+ owners[i] = new DummyInvokable();
+ mems[i] = new ArrayList<MemorySegment>(64);
+ }
+
+ // allocate all memory to the different owners
+ for (int i = 0; i < NUM_PAGES; i++) {
+ final int owner = this.random.nextInt(NUM_OWNERS);
+ mems[owner].addAll(this.memoryManager.allocatePages(owners[owner], 1));
+ }
+
+ // free one owner at a time
+ for (int i = 0; i < NUM_OWNERS; i++) {
+ this.memoryManager.releaseAll(owners[i]);
+ owners[i] = null;
+ Assert.assertTrue("Released memory segments have not been destroyed.", allMemorySegmentsFreed(mems[i]));
+ mems[i] = null;
+
+ // check that the owner owners were not affected
+ for (int k = i+1; k < NUM_OWNERS; k++) {
+ Assert.assertTrue("Non-released memory segments are accidentaly destroyed.", allMemorySegmentsValid(mems[k]));
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void allocateTooMuch() {
+ try {
+ final AbstractInvokable mockInvoke = new DummyInvokable();
+
+ List<MemorySegment> segs = this.memoryManager.allocatePages(mockInvoke, NUM_PAGES);
+
+ try {
+ this.memoryManager.allocatePages(mockInvoke, 1);
+ Assert.fail("Expected MemoryAllocationException.");
+ } catch (MemoryAllocationException maex) {
+ // expected
+ }
+
+ Assert.assertTrue("The previously allocated segments were not valid any more.",
+ allMemorySegmentsValid(segs));
+
--- End diff --
Formatting
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/flink/pull/718
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/718#discussion_r31029417
--- Diff: flink-dist/src/main/flink-bin/bin/jobmanager.sh ---
@@ -80,7 +81,7 @@ case $STARTSTOP in
rotateLogFile $out
echo "Starting Job Manager"
- $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --executionMode $EXECUTIONMODE --configDir "$FLINK_CONF_DIR" > "$out" 2>&1 < /dev/null &
+ $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --configDir "$FLINK_CONF_DIR" --executionMode $EXECUTIONMODE --streamingMode "$STREAMINGMODE" > "$out" 2>&1 < /dev/null &
--- End diff --
I'll add it anyways. It is a good hint.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by rmetzger <gi...@git.apache.org>.
Github user rmetzger commented on a diff in the pull request:
https://github.com/apache/flink/pull/718#discussion_r31026871
--- Diff: flink-dist/src/main/flink-bin/bin/jobmanager.sh ---
@@ -80,7 +81,7 @@ case $STARTSTOP in
rotateLogFile $out
echo "Starting Job Manager"
- $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --executionMode $EXECUTIONMODE --configDir "$FLINK_CONF_DIR" > "$out" 2>&1 < /dev/null &
+ $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --configDir "$FLINK_CONF_DIR" --executionMode $EXECUTIONMODE --streamingMode "$STREAMINGMODE" > "$out" 2>&1 < /dev/null &
--- End diff --
Okay, sorry. I didn't see this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:
https://github.com/apache/flink/pull/718#issuecomment-105502334
Thank you for the comments.
I'll address them and merge this...
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by rmetzger <gi...@git.apache.org>.
Github user rmetzger commented on the pull request:
https://github.com/apache/flink/pull/718#issuecomment-105230094
+1 to merge.
The changes look good.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] flink pull request: [FLINK-2084] [core] Add an option to start Fli...
Posted by rmetzger <gi...@git.apache.org>.
Github user rmetzger commented on a diff in the pull request:
https://github.com/apache/flink/pull/718#discussion_r30977601
--- Diff: flink-dist/src/main/flink-bin/bin/jobmanager.sh ---
@@ -80,7 +81,7 @@ case $STARTSTOP in
rotateLogFile $out
echo "Starting Job Manager"
- $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --executionMode $EXECUTIONMODE --configDir "$FLINK_CONF_DIR" > "$out" 2>&1 < /dev/null &
+ $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_JM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.runtime.jobmanager.JobManager --configDir "$FLINK_CONF_DIR" --executionMode $EXECUTIONMODE --streamingMode "$STREAMINGMODE" > "$out" 2>&1 < /dev/null &
--- End diff --
With this change, the script now expects three arguments, right?
If you, you need to update this line as well
```
echo "Please specify 'start (cluster|local)' or stop"
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---