Skip to content

Commit

Permalink
feat: Improve client settings (#2097)
Browse files Browse the repository at this point in the history
* feat: Add necessary client settings to sample

* feat: Add keepalive to default setting and also add it to samples

* .

* .

* .

* .

* .

* .

* .

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
yirutang and gcf-owl-bot[bot] authored May 3, 2023
1 parent bcd7fc9 commit 4fc2fac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ static BigQueryWriteSettings getBigQueryWriteSettings(Builder builder) throws IO
new BigQueryWriteSettings.Builder()
.setTransportChannelProvider(
BigQueryWriteSettings.defaultGrpcTransportProviderBuilder()
.setChannelsPerCpu(1)
.setKeepAliveTime(org.threeten.bp.Duration.ofMinutes(1))
.setKeepAliveTimeout(org.threeten.bp.Duration.ofMinutes(1))
.setKeepAliveWithoutCalls(true)
.setChannelsPerCpu(2)
.build())
.setCredentialsProvider(
BigQueryWriteSettings.defaultCredentialsProviderBuilder().build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,17 @@ public void testBuilderDefaultSetting() throws Exception {
writeSettings.getCredentialsProvider().toString());
assertTrue(
writeSettings.getTransportChannelProvider() instanceof InstantiatingGrpcChannelProvider);
assertTrue(
((InstantiatingGrpcChannelProvider) writeSettings.getTransportChannelProvider())
.getKeepAliveWithoutCalls());
assertEquals(
((InstantiatingGrpcChannelProvider) writeSettings.getTransportChannelProvider())
.getKeepAliveTimeout(),
org.threeten.bp.Duration.ofMinutes(1));
assertEquals(
((InstantiatingGrpcChannelProvider) writeSettings.getTransportChannelProvider())
.getKeepAliveTime(),
org.threeten.bp.Duration.ofMinutes(1));
assertEquals(
BigQueryWriteSettings.getDefaultEndpoint(), writeSettings.getEndpoint().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutureCallback;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.FixedExecutorProvider;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.QueryJobConfiguration;
Expand All @@ -39,6 +40,7 @@
import io.grpc.Status.Code;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.Phaser;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.concurrent.GuardedBy;
Expand Down Expand Up @@ -151,7 +153,10 @@ public void initialize(TableName parentTable)
// For more information about JsonStreamWriter, see:
// https://googleapis.dev/java/google-cloud-bigquerystorage/latest/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.html
streamWriter =
JsonStreamWriter.newBuilder(parentTable.toString(), BigQueryWriteClient.create()).build();
JsonStreamWriter.newBuilder(parentTable.toString(), BigQueryWriteClient.create())
.setExecutorProvider(
FixedExecutorProvider.create(Executors.newScheduledThreadPool(100)))
.build();
}

public void append(AppendContext appendContext)
Expand Down

0 comments on commit 4fc2fac

Please sign in to comment.