You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ch...@apache.org on 2017/10/31 23:12:09 UTC

[1/2] beam git commit: Allows to set a Cloud Spanner host. https://batch-spanner.googleapis.com/ is set as a default host name.

Repository: beam
Updated Branches:
  refs/heads/master 612af0a29 -> 239319b2a


Allows to set a Cloud Spanner host. https://batch-spanner.googleapis.com/ is set as a default host name.


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

Branch: refs/heads/master
Commit: 6179cc712195d7f4671fb1b912adba5c70884955
Parents: 612af0a
Author: Mairbek Khadikov <ma...@google.com>
Authored: Tue Sep 26 16:59:30 2017 -0700
Committer: chamikara@google.com <ch...@google.com>
Committed: Tue Oct 31 16:11:37 2017 -0700

----------------------------------------------------------------------
 .../beam/sdk/io/gcp/spanner/SpannerConfig.java  | 16 ++++++++++++-
 .../beam/sdk/io/gcp/spanner/SpannerIO.java      | 24 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/6179cc71/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerConfig.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerConfig.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerConfig.java
index dc0bab8..9be641f 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerConfig.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerConfig.java
@@ -37,6 +37,8 @@ import org.apache.beam.sdk.util.ReleaseInfo;
 public abstract class SpannerConfig implements Serializable {
   // A common user agent token that indicates that this request was originated from Apache Beam.
   private static final String USER_AGENT_PREFIX = "Apache_Beam_Java";
+  // A default host name for batch traffic.
+  private static final String DEFAULT_HOST = "https://batch-spanner.googleapis.com/";
 
   @Nullable
   abstract ValueProvider<String> getProjectId();
@@ -48,13 +50,16 @@ public abstract class SpannerConfig implements Serializable {
   abstract ValueProvider<String> getDatabaseId();
 
   @Nullable
+  abstract String getHost();
+
+  @Nullable
   @VisibleForTesting
   abstract ServiceFactory<Spanner, SpannerOptions> getServiceFactory();
 
   abstract Builder toBuilder();
 
   public static SpannerConfig create() {
-    return builder().build();
+    return builder().setHost(DEFAULT_HOST).build();
   }
 
   static Builder builder() {
@@ -93,6 +98,8 @@ public abstract class SpannerConfig implements Serializable {
 
     abstract Builder setDatabaseId(ValueProvider<String> databaseId);
 
+    abstract Builder setHost(String host);
+
     abstract Builder setServiceFactory(ServiceFactory<Spanner, SpannerOptions> serviceFactory);
 
     public abstract SpannerConfig build();
@@ -122,6 +129,10 @@ public abstract class SpannerConfig implements Serializable {
     return withDatabaseId(ValueProvider.StaticValueProvider.of(databaseId));
   }
 
+  public SpannerConfig withHost(String host) {
+    return toBuilder().setHost(host).build();
+  }
+
   @VisibleForTesting
   SpannerConfig withServiceFactory(ServiceFactory<Spanner, SpannerOptions> serviceFactory) {
     return toBuilder().setServiceFactory(serviceFactory).build();
@@ -135,6 +146,9 @@ public abstract class SpannerConfig implements Serializable {
     if (getServiceFactory() != null) {
       builder.setServiceFactory(this.getServiceFactory());
     }
+    if (getHost() != null) {
+      builder.setHost(getHost());
+    }
     ReleaseInfo releaseInfo = ReleaseInfo.getReleaseInfo();
     builder.setUserAgentPrefix(USER_AGENT_PREFIX + "/" + releaseInfo.getVersion());
     SpannerOptions options = builder.build();

http://git-wip-us.apache.org/repos/asf/beam/blob/6179cc71/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 26ac884..be4417b 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
@@ -265,6 +265,12 @@ public class SpannerIO {
       return withDatabaseId(ValueProvider.StaticValueProvider.of(databaseId));
     }
 
+    /** Specifies the Cloud Spanner host. */
+    public ReadAll witHost(String host) {
+      SpannerConfig config = getSpannerConfig();
+      return withSpannerConfig(config.withHost(host));
+    }
+
     /** Specifies the Cloud Spanner database. */
     public ReadAll withDatabaseId(ValueProvider<String> databaseId) {
       SpannerConfig config = getSpannerConfig();
@@ -365,6 +371,12 @@ public class SpannerIO {
       return withSpannerConfig(config.withDatabaseId(databaseId));
     }
 
+    /** Specifies the Cloud Spanner host. */
+    public Read witHost(String host) {
+      SpannerConfig config = getSpannerConfig();
+      return withSpannerConfig(config.withHost(host));
+    }
+
     @VisibleForTesting
     Read withServiceFactory(ServiceFactory<Spanner, SpannerOptions> serviceFactory) {
       SpannerConfig config = getSpannerConfig();
@@ -518,6 +530,12 @@ public class SpannerIO {
       return withSpannerConfig(config.withDatabaseId(databaseId));
     }
 
+    /** Specifies the Cloud Spanner host. */
+    public CreateTransaction witHost(String host) {
+      SpannerConfig config = getSpannerConfig();
+      return withSpannerConfig(config.withHost(host));
+    }
+
     @VisibleForTesting
     CreateTransaction withServiceFactory(
         ServiceFactory<Spanner, SpannerOptions> serviceFactory) {
@@ -604,6 +622,12 @@ public class SpannerIO {
       return withSpannerConfig(config.withDatabaseId(databaseId));
     }
 
+    /** Specifies the Cloud Spanner host. */
+    public Write witHost(String host) {
+      SpannerConfig config = getSpannerConfig();
+      return withSpannerConfig(config.withHost(host));
+    }
+
     @VisibleForTesting
     Write withServiceFactory(ServiceFactory<Spanner, SpannerOptions> serviceFactory) {
       SpannerConfig config = getSpannerConfig();


[2/2] beam git commit: This closes #3907

Posted by ch...@apache.org.
This closes #3907


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

Branch: refs/heads/master
Commit: 239319b2a093cdb5c63375eddb5a91ac70172641
Parents: 612af0a 6179cc7
Author: chamikara@google.com <ch...@google.com>
Authored: Tue Oct 31 16:11:50 2017 -0700
Committer: chamikara@google.com <ch...@google.com>
Committed: Tue Oct 31 16:11:50 2017 -0700

----------------------------------------------------------------------
 .../beam/sdk/io/gcp/spanner/SpannerConfig.java  | 16 ++++++++++++-
 .../beam/sdk/io/gcp/spanner/SpannerIO.java      | 24 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------