You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by jb...@apache.org on 2017/05/30 20:08:13 UTC

[1/2] beam git commit: [BEAM-2379] Avoid reading projectId from environment variable in tests. SpannerOptions.Builder requires projectId to be not-null.

Repository: beam
Updated Branches:
  refs/heads/master aff406b89 -> 2d3e9fe75


[BEAM-2379] Avoid reading projectId from environment variable in tests. SpannerOptions.Builder requires projectId to be not-null.


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/84a831e3
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/84a831e3
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/84a831e3

Branch: refs/heads/master
Commit: 84a831e3f3ea7f476a28778468cb084f5eecac68
Parents: aff406b
Author: Mairbek Khadikov <ma...@google.com>
Authored: Tue May 30 11:54:55 2017 -0700
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue May 30 21:51:20 2017 +0200

----------------------------------------------------------------------
 .../beam/sdk/io/gcp/spanner/SpannerIO.java      | 27 +++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/84a831e3/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java
index c5325bb..5058d13 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java
@@ -149,14 +149,6 @@ public class SpannerIO {
       abstract Write build();
     }
 
-    SpannerOptions getSpannerOptions() {
-      SpannerOptions.Builder builder = SpannerOptions.newBuilder();
-      if (getServiceFactory() != null) {
-        builder.setServiceFactory(getServiceFactory());
-      }
-      return builder.build();
-    }
-
     /**
      * Returns a new {@link SpannerIO.Write} that will write to the specified Cloud Spanner project.
      *
@@ -259,10 +251,10 @@ public class SpannerIO {
 
     @Setup
     public void setup() throws Exception {
-      spanner = spec.getSpannerOptions().getService();
-      dbClient =
-          spanner.getDatabaseClient(
-              DatabaseId.of(projectId(), spec.getInstanceId(), spec.getDatabaseId()));
+      SpannerOptions spannerOptions = getSpannerOptions();
+      spanner = spannerOptions.getService();
+      dbClient = spanner.getDatabaseClient(
+          DatabaseId.of(projectId(), spec.getInstanceId(), spec.getDatabaseId()));
       mutations = new ArrayList<>();
       batchSizeBytes = 0;
     }
@@ -299,6 +291,17 @@ public class SpannerIO {
       spanner = null;
     }
 
+    private SpannerOptions getSpannerOptions() {
+      SpannerOptions.Builder spannerOptionsBuider = SpannerOptions.newBuilder();
+      if (spec.getServiceFactory() != null) {
+        spannerOptionsBuider.setServiceFactory(spec.getServiceFactory());
+      }
+      if (spec.getProjectId() != null) {
+        spannerOptionsBuider.setProjectId(spec.getProjectId());
+      }
+      return spannerOptionsBuider.build();
+    }
+
     /**
      * Writes a batch of mutations to Cloud Spanner.
      *


[2/2] beam git commit: [BEAM-2379] This closes #3259

Posted by jb...@apache.org.
[BEAM-2379] This closes #3259


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/2d3e9fe7
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/2d3e9fe7
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/2d3e9fe7

Branch: refs/heads/master
Commit: 2d3e9fe75bf3a6524a1f72db13da0e42ea15beab
Parents: aff406b 84a831e
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue May 30 22:08:05 2017 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue May 30 22:08:05 2017 +0200

----------------------------------------------------------------------
 .../beam/sdk/io/gcp/spanner/SpannerIO.java      | 27 +++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------