flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trohrm...@apache.org
Subject flink git commit: [FLINK-6581] [cli] Correct dynamic property parsing for YARN cli
Date Tue, 16 May 2017 22:39:43 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.3 629d3633b -> 4104409cc


[FLINK-6581] [cli] Correct dynamic property parsing for YARN cli

The YARN cli will now split the dynamic propertie at the first occurrence of
the = sign instead of splitting it at every = sign. That way we support dynamic
properties of the form -yDenv.java.opts="-DappName=foobar".

Address PR comments


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/4104409c
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/4104409c
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/4104409c

Branch: refs/heads/release-1.3
Commit: 4104409cc7a595c17d474333fe0516a3a98a130e
Parents: 629d363
Author: Till Rohrmann <trohrmann@apache.org>
Authored: Mon May 15 12:04:07 2017 +0200
Committer: Till Rohrmann <trohrmann@apache.org>
Committed: Wed May 17 00:39:21 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flink/yarn/FlinkYarnSessionCliTest.java  |  6 ++++--
 .../org/apache/flink/yarn/cli/FlinkYarnSessionCli.java  | 12 +++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/4104409c/flink-yarn-tests/src/test/java/org/apache/flink/yarn/FlinkYarnSessionCliTest.java
----------------------------------------------------------------------
diff --git a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/FlinkYarnSessionCliTest.java
b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/FlinkYarnSessionCliTest.java
index 264b6aa..4da5a39 100644
--- a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/FlinkYarnSessionCliTest.java
+++ b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/FlinkYarnSessionCliTest.java
@@ -68,7 +68,8 @@ public class FlinkYarnSessionCliTest {
 		CommandLineParser parser = new DefaultParser();
 		CommandLine cmd = null;
 		try {
-			cmd = parser.parse(options, new String[]{"run", "-j", "fake.jar", "-n", "15", "-D", "akka.ask.timeout=5
min"});
+			cmd = parser.parse(options, new String[]{"run", "-j", "fake.jar", "-n", "15",
+				"-D", "akka.ask.timeout=5 min", "-D", "env.java.opts=-DappName=foobar"});
 		} catch(Exception e) {
 			e.printStackTrace();
 			Assert.fail("Parsing failed with " + e.getMessage());
@@ -80,8 +81,9 @@ public class FlinkYarnSessionCliTest {
 
 		Map<String, String> dynProperties =
 			FlinkYarnSessionCli.getDynamicProperties(flinkYarnDescriptor.getDynamicPropertiesEncoded());
-		Assert.assertEquals(1, dynProperties.size());
+		Assert.assertEquals(2, dynProperties.size());
 		Assert.assertEquals("5 min", dynProperties.get("akka.ask.timeout"));
+		Assert.assertEquals("-DappName=foobar", dynProperties.get("env.java.opts"));
 	}
 
 	@Test

http://git-wip-us.apache.org/repos/asf/flink/blob/4104409c/flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java b/flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java
index 3d82132..69b472a 100644
--- a/flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java
+++ b/flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java
@@ -702,9 +702,15 @@ public class FlinkYarnSessionCli implements CustomCommandLine<YarnClusterClient>
 					continue;
 				}
 
-				String[] kv = propLine.split("=");
-				if (kv.length >= 2 && kv[0] != null && kv[1] != null && kv[0].length()
> 0) {
-					properties.put(kv[0], kv[1]);
+				int firstEquals = propLine.indexOf("=");
+
+				if (firstEquals >= 0) {
+					String key = propLine.substring(0, firstEquals).trim();
+					String value = propLine.substring(firstEquals + 1, propLine.length()).trim();
+
+					if (!key.isEmpty()) {
+						properties.put(key, value);
+					}
 				}
 			}
 			return properties;


Mime
View raw message