@@ -159,6 +159,9 @@ static class SpannerPoolKey {
159159 private final Integer dcpMinChannels ;
160160 private final Integer dcpMaxChannels ;
161161 private final Integer dcpInitialChannels ;
162+ private final Integer dcpMinRpcPerChannel ;
163+ private final Integer dcpMaxRpcPerChannel ;
164+ private final Integer dcpConcurrentStreamsLowWatermark ;
162165 private final boolean usePlainText ;
163166 private final String userAgent ;
164167 private final String databaseRole ;
@@ -202,6 +205,9 @@ private SpannerPoolKey(ConnectionOptions options) throws IOException {
202205 this .dcpMinChannels = options .getDcpMinChannels ();
203206 this .dcpMaxChannels = options .getDcpMaxChannels ();
204207 this .dcpInitialChannels = options .getDcpInitialChannels ();
208+ this .dcpMinRpcPerChannel = options .getDcpMinRpcPerChannel ();
209+ this .dcpMaxRpcPerChannel = options .getDcpMaxRpcPerChannel ();
210+ this .dcpConcurrentStreamsLowWatermark = options .getDcpConcurrentStreamsLowWatermark ();
205211 this .usePlainText = options .isUsePlainText ();
206212 this .userAgent = options .getUserAgent ();
207213 this .routeToLeader = options .isRouteToLeader ();
@@ -234,6 +240,10 @@ public boolean equals(Object o) {
234240 && Objects .equals (this .dcpMinChannels , other .dcpMinChannels )
235241 && Objects .equals (this .dcpMaxChannels , other .dcpMaxChannels )
236242 && Objects .equals (this .dcpInitialChannels , other .dcpInitialChannels )
243+ && Objects .equals (this .dcpMinRpcPerChannel , other .dcpMinRpcPerChannel )
244+ && Objects .equals (this .dcpMaxRpcPerChannel , other .dcpMaxRpcPerChannel )
245+ && Objects .equals (
246+ this .dcpConcurrentStreamsLowWatermark , other .dcpConcurrentStreamsLowWatermark )
237247 && Objects .equals (this .databaseRole , other .databaseRole )
238248 && Objects .equals (this .usePlainText , other .usePlainText )
239249 && Objects .equals (this .userAgent , other .userAgent )
@@ -265,6 +275,9 @@ public int hashCode() {
265275 this .dcpMinChannels ,
266276 this .dcpMaxChannels ,
267277 this .dcpInitialChannels ,
278+ this .dcpMinRpcPerChannel ,
279+ this .dcpMaxRpcPerChannel ,
280+ this .dcpConcurrentStreamsLowWatermark ,
268281 this .usePlainText ,
269282 this .databaseRole ,
270283 this .userAgent ,
@@ -442,7 +455,10 @@ Spanner createSpanner(SpannerPoolKey key, ConnectionOptions options) {
442455 // Build custom GcpChannelPoolOptions if any DCP-specific options are set.
443456 if (key .dcpMinChannels != null
444457 || key .dcpMaxChannels != null
445- || key .dcpInitialChannels != null ) {
458+ || key .dcpInitialChannels != null
459+ || key .dcpMinRpcPerChannel != null
460+ || key .dcpMaxRpcPerChannel != null
461+ || key .dcpConcurrentStreamsLowWatermark != null ) {
446462 // Build GcpChannelPoolOptions from scratch with custom values or Spanner defaults.
447463 // Note: GcpChannelPoolOptions does not have a toBuilder() method, so we must
448464 // construct from scratch using SpannerOptions defaults for unspecified values.
@@ -458,19 +474,32 @@ Spanner createSpanner(SpannerPoolKey key, ConnectionOptions options) {
458474 key .dcpInitialChannels != null
459475 ? key .dcpInitialChannels
460476 : SpannerOptions .DEFAULT_DYNAMIC_POOL_INITIAL_SIZE ;
461- GcpChannelPoolOptions poolOptions =
477+
478+ int minRpc =
479+ key .dcpMinRpcPerChannel != null
480+ ? key .dcpMinRpcPerChannel
481+ : SpannerOptions .DEFAULT_DYNAMIC_POOL_MIN_RPC ;
482+ int maxRpc =
483+ key .dcpMaxRpcPerChannel != null
484+ ? key .dcpMaxRpcPerChannel
485+ : SpannerOptions .DEFAULT_DYNAMIC_POOL_MAX_RPC ;
486+
487+ GcpChannelPoolOptions .Builder poolOptionsBuilder =
462488 GcpChannelPoolOptions .newBuilder ()
463489 .setMinSize (minChannels )
464490 .setMaxSize (maxChannels )
465491 .setInitSize (initChannels )
466492 .setDynamicScaling (
467- SpannerOptions .DEFAULT_DYNAMIC_POOL_MIN_RPC ,
468- SpannerOptions .DEFAULT_DYNAMIC_POOL_MAX_RPC ,
469- SpannerOptions .DEFAULT_DYNAMIC_POOL_SCALE_DOWN_INTERVAL )
493+ minRpc , maxRpc , SpannerOptions .DEFAULT_DYNAMIC_POOL_SCALE_DOWN_INTERVAL )
470494 .setAffinityKeyLifetime (SpannerOptions .DEFAULT_DYNAMIC_POOL_AFFINITY_KEY_LIFETIME )
471- .setCleanupInterval (SpannerOptions .DEFAULT_DYNAMIC_POOL_CLEANUP_INTERVAL )
472- .build ();
473- builder .setGcpChannelPoolOptions (poolOptions );
495+ .setCleanupInterval (SpannerOptions .DEFAULT_DYNAMIC_POOL_CLEANUP_INTERVAL );
496+
497+ if (key .dcpConcurrentStreamsLowWatermark != null ) {
498+ poolOptionsBuilder .setConcurrentStreamsLowWatermark (
499+ key .dcpConcurrentStreamsLowWatermark );
500+ }
501+
502+ builder .setGcpChannelPoolOptions (poolOptionsBuilder .build ());
474503 }
475504 } else {
476505 // Explicitly disable DCP when enableDynamicChannelPool=false.
0 commit comments