You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by lc...@apache.org on 2017/05/04 14:41:22 UTC
[1/2] beam git commit: [BEAM-1871] Migrate ReleaseInfo away from
Google API client GenericJson
Repository: beam
Updated Branches:
refs/heads/master 3c5891b31 -> 98e92a0b8
[BEAM-1871] Migrate ReleaseInfo away from Google API client GenericJson
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/cc654f02
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/cc654f02
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/cc654f02
Branch: refs/heads/master
Commit: cc654f02e8670ea789aee67508c569e7547ef11f
Parents: 3c5891b
Author: Luke Cwik <lc...@google.com>
Authored: Wed May 3 13:48:07 2017 -0700
Committer: Luke Cwik <lc...@google.com>
Committed: Thu May 4 07:40:39 2017 -0700
----------------------------------------------------------------------
.../beam/runners/dataflow/DataflowRunner.java | 2 +-
.../org/apache/beam/sdk/util/ReleaseInfo.java | 70 +++++++++++---------
2 files changed, 40 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/cc654f02/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
index 9e5a2fb..2b54ba7 100644
--- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
+++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java
@@ -542,7 +542,7 @@ public class DataflowRunner extends PipelineRunner<DataflowPipelineJob> {
"Unable to submit a job to the Dataflow service with unset version ${pom.version}");
System.out.println("Dataflow SDK version: " + version);
- newJob.getEnvironment().setUserAgent(releaseInfo);
+ newJob.getEnvironment().setUserAgent((Map) releaseInfo.getProperties());
// The Dataflow Service may write to the temporary directory directly, so
// must be verified.
if (!isNullOrEmpty(options.getGcpTempLocation())) {
http://git-wip-us.apache.org/repos/asf/beam/blob/cc654f02/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ReleaseInfo.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ReleaseInfo.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ReleaseInfo.java
index eeac557..c7e24d2 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ReleaseInfo.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ReleaseInfo.java
@@ -17,27 +17,24 @@
*/
package org.apache.beam.sdk.util;
-import com.google.api.client.json.GenericJson;
-import com.google.api.client.util.Key;
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Map;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Utilities for working with release information.
+ * Properties pertaining to this release of Apache Beam.
+ *
+ * <p>Properties will always include a name and version.
*/
-public final class ReleaseInfo extends GenericJson {
- private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class);
-
- private static final String PROPERTIES_PATH =
- "/org/apache/beam/sdk/sdk.properties";
-
- private static class LazyInit {
- private static final ReleaseInfo INSTANCE =
- new ReleaseInfo(PROPERTIES_PATH);
- }
+@AutoValue
+public abstract class ReleaseInfo implements Serializable {
+ private static final String PROPERTIES_PATH = "/org/apache/beam/sdk/sdk.properties";
/**
* Returns an instance of {@link ReleaseInfo}.
@@ -46,35 +43,46 @@ public final class ReleaseInfo extends GenericJson {
return LazyInit.INSTANCE;
}
- @Key private String name = "Apache Beam SDK for Java";
- @Key private String version = "Unknown";
+ /**
+ * Returns an immutable map of all properties pertaining to this release.
+ */
+ public abstract Map<String, String> getProperties();
/** Provides the SDK name. */
public String getName() {
- return name;
+ return getProperties().get("name");
}
/** Provides the SDK version. */
public String getVersion() {
- return version;
+ return getProperties().get("version");
}
- private ReleaseInfo(String resourcePath) {
- Properties properties = new Properties();
+ /////////////////////////////////////////////////////////////////////////
+ private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class);
+ private static final String DEFAULT_NAME = "Apache Beam SDK for Java";
+ private static final String DEFAULT_VERSION = "Unknown";
- try (InputStream in = ReleaseInfo.class.getResourceAsStream(PROPERTIES_PATH)) {
- if (in == null) {
- LOG.warn("Beam properties resource not found: {}", resourcePath);
- return;
+ private static class LazyInit {
+ private static final ReleaseInfo INSTANCE;
+ static {
+ Properties properties = new Properties();
+ try (InputStream in = ReleaseInfo.class.getResourceAsStream(PROPERTIES_PATH)) {
+ if (in == null) {
+ LOG.warn("Beam properties resource not found: {}", PROPERTIES_PATH);
+ } else {
+ properties.load(in);
+ }
+ } catch (IOException e) {
+ LOG.warn("Error loading Beam properties resource: ", e);
}
-
- properties.load(in);
- } catch (IOException e) {
- LOG.warn("Error loading Beam properties resource: ", e);
- }
-
- for (String name : properties.stringPropertyNames()) {
- put(name, properties.getProperty(name));
+ if (!properties.containsKey("name")) {
+ properties.setProperty("name", DEFAULT_NAME);
+ }
+ if (!properties.containsKey("version")) {
+ properties.setProperty("version", DEFAULT_VERSION);
+ }
+ INSTANCE = new AutoValue_ReleaseInfo(ImmutableMap.copyOf((Map) properties));
}
}
}
[2/2] beam git commit: [BEAM-1871] Migrate ReleaseInfo away from
Google API client GenericJson
Posted by lc...@apache.org.
[BEAM-1871] Migrate ReleaseInfo away from Google API client GenericJson
This closes #2868
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/98e92a0b
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/98e92a0b
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/98e92a0b
Branch: refs/heads/master
Commit: 98e92a0b8a4655a05fce4ae699f5bb93fe74f1de
Parents: 3c5891b cc654f0
Author: Luke Cwik <lc...@google.com>
Authored: Thu May 4 07:41:15 2017 -0700
Committer: Luke Cwik <lc...@google.com>
Committed: Thu May 4 07:41:15 2017 -0700
----------------------------------------------------------------------
.../beam/runners/dataflow/DataflowRunner.java | 2 +-
.../org/apache/beam/sdk/util/ReleaseInfo.java | 70 +++++++++++---------
2 files changed, 40 insertions(+), 32 deletions(-)
----------------------------------------------------------------------