[ https://issues.apache.org/jira/browse/BEAM-8758?focusedWorklogId=386821&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-386821 ]
ASF GitHub Bot logged work on BEAM-8758: ---------------------------------------- Author: ASF GitHub Bot Created on: 13/Feb/20 19:10 Start Date: 13/Feb/20 19:10 Worklog Time Spent: 10m Work Description: suztomo commented on pull request #10765: [BEAM-8758] Google-cloud-spanner upgrade to 1.49.1 URL: https://github.com/apache/beam/pull/10765#discussion_r379061512 ########## File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java ########## @@ -40,6 +57,59 @@ this.batchClient = batchClient; } + static SpannerAccessor create(SpannerConfig spannerConfig) { + SpannerOptions.Builder builder = SpannerOptions.newBuilder(); + + ValueProvider<Duration> commitDeadline = spannerConfig.getCommitDeadline(); + if (commitDeadline != null && commitDeadline.get().getMillis() > 0) { + + // In Spanner API version 1.21 or above, we can set the deadline / total Timeout on an API + // call using the following code: + // + // UnaryCallSettings.Builder commitSettings = + // builder.getSpannerStubSettingsBuilder().commitSettings(); + // RetrySettings.Builder commitRetrySettings = commitSettings.getRetrySettings().toBuilder() + // commitSettings.setRetrySettings( + // commitRetrySettings.setTotalTimeout( + // Duration.ofMillis(getCommitDeadlineMillis().get())) + // .build()); + // + // However, at time of this commit, the Spanner API is at only at v1.6.0, where the only + // method to set a deadline is with GRPC Interceptors, so we have to use that... + SpannerInterceptorProvider interceptorProvider = + SpannerInterceptorProvider.createDefault() + .with(new CommitDeadlineSettingInterceptor(commitDeadline.get())); + builder.setInterceptorProvider(interceptorProvider); + } + + ValueProvider<String> projectId = spannerConfig.getProjectId(); + if (projectId != null) { + builder.setProjectId(projectId.get()); + } + ServiceFactory<Spanner, SpannerOptions> serviceFactory = spannerConfig.getServiceFactory(); + if (serviceFactory != null) { + builder.setServiceFactory(serviceFactory); + } + ValueProvider<String> host = spannerConfig.getHost(); + if (host != null) { + builder.setHost(host.get()); + } + String userAgentString = USER_AGENT_PREFIX + "/" + ReleaseInfo.getReleaseInfo().getVersion(); + builder.setHeaderProvider(FixedHeaderProvider.create("user-agent", userAgentString)); + SpannerOptions options = builder.build(); + + Spanner spanner = options.getService(); + String instanceId = spannerConfig.getInstanceId().get(); + String databaseId = spannerConfig.getDatabaseId().get(); + DatabaseClient databaseClient = + spanner.getDatabaseClient(DatabaseId.of(options.getProjectId(), instanceId, databaseId)); + BatchClient batchClient = + spanner.getBatchClient(DatabaseId.of(options.getProjectId(), instanceId, databaseId)); + DatabaseAdminClient databaseAdminClient = spanner.getDatabaseAdminClient(); + + return new SpannerAccessor(spanner, databaseClient, databaseAdminClient, batchClient); + } + public DatabaseClient getDatabaseClient() { Review comment: The commit message was by Mairbek: ``` commit b99c67e9f2f5064cc6ac708fdedf2a3aeba55ae3 Date: Tue May 1 16:58:23 2018 -0700 Expose DatabaseAdminClient Change-Id: I50670b8cd6a479fcad6ff866c6adb97434ae2ed8 ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 386821) Time Spent: 5h 20m (was: 5h 10m) > Beam Dependency Update Request: com.google.cloud:google-cloud-spanner > --------------------------------------------------------------------- > > Key: BEAM-8758 > URL: https://issues.apache.org/jira/browse/BEAM-8758 > Project: Beam > Issue Type: Sub-task > Components: dependencies > Reporter: Beam JIRA Bot > Assignee: Tomo Suzuki > Priority: Major > Time Spent: 5h 20m > Remaining Estimate: 0h > > ------------------------- 2019-11-19 21:05:29.289016 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.46.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2019-12-02 12:11:08.926875 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.46.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2019-12-09 12:10:16.400168 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.47.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2019-12-23 12:10:17.656471 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.47.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2019-12-30 14:05:49.080960 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.47.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-01-06 12:09:23.346857 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.47.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-01-13 12:09:02.023131 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.47.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-01-20 12:08:38.419575 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.48.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-01-27 12:09:44.298346 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.49.0 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-02-03 12:10:52.455618 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.49.1 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. > ------------------------- 2020-02-10 12:08:36.508488 > ------------------------- > Please consider upgrading the dependency > com.google.cloud:google-cloud-spanner. > The current version is 1.6.0. The latest version is 1.49.2 > cc: > Please refer to [Beam Dependency Guide > |https://beam.apache.org/contribute/dependencies/]for more information. > Do Not Modify The Description Above. -- This message was sent by Atlassian Jira (v8.3.4#803005)