Abacn commented on code in PR #25193: URL: https://github.com/apache/beam/pull/25193#discussion_r1102224870
########## sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/MetadataSpannerConfig.java: ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.sdk.io.gcp.spanner.changestreams; + +import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.StatusCode.Code; +import com.google.cloud.spanner.Options.RpcPriority; +import org.apache.beam.sdk.io.gcp.spanner.SpannerConfig; +import org.apache.beam.sdk.options.ValueProvider; +import org.apache.beam.sdk.options.ValueProvider.StaticValueProvider; +import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableSet; +import org.joda.time.Duration; + +/** + * This class generates a SpannerConfig for the change stream metadata database by copying only the + * necessary fields from the SpannerConfig of the primary database. + */ +public class MetadataSpannerConfig { + + /** + * Generates an SpannerConfig that can be used to access the change stream metadata database by + * copying only the necessary fields from the given primary database SpannerConfig and setting the + * instance ID and database ID to the supplied metadata values. + * + * @param primaryConfig The SpannerConfig for accessing the primary database + * @param metadataInstanceId The instance ID of the metadata database + * @param metadataDatabaseId The database ID of the metadata database + * @return the metadata SpannerConfig + */ + public static SpannerConfig create( + SpannerConfig primaryConfig, String metadataInstanceId, String metadataDatabaseId) { + + checkNotNull( + metadataInstanceId, "MetadataSpannerConfig.create requires non-null metadata instance id"); + checkNotNull( + metadataDatabaseId, "MetadataSpannerConfig.create requires non-null metadata database id"); + + // NOTE: databaseRole should NOT be copied to the metadata config + + SpannerConfig config = Review Comment: thanks for the detailed explanation. sounds good to me -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
