diff --git a/README.md b/README.md index 2e80d88d8..f04b82a7b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This is similar to 'Cluster Awareness' but uses those servers which are part of ### Connection Properties added for load balancing -- _load-balance_ - Starting with version 42.3.5-yb-7, it expects one of **false, any (same as true), only-primary, only-rr, prefer-primary and prefer-rr** as its possible values. In `YBClusterAwareDataSource` load balancing is `true` by default. However, when using the `DriverManager.getConnection()` API the 'load-balance' property is considered to be `false` by default. +- _load-balance_ - Starting with version 42.3.5-yb-8, it expects one of **false, any (same as true), only-primary, only-rr, prefer-primary and prefer-rr** as its possible values. In `YBClusterAwareDataSource` load balancing is `true` by default. However, when using the `DriverManager.getConnection()` API the 'load-balance' property is considered to be `false` by default. - _false_ - No connection load balancing. Behaviour is similar to vanilla PGJDBC driver - _any_ - Same as value _true_. Distribute connections equally across all nodes in the cluster, irrespective of its type (`primary` or `read-replica`) - _only-primary_ - Create connections equally across only the primary nodes of the cluster diff --git a/examples/pom.xml b/examples/pom.xml index c1f8e2c8f..53fb708f4 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -11,7 +11,7 @@ com.yugabyte jdbc-yugabytedb - 42.3.5-yb-7 + 42.3.5-yb-8 diff --git a/gradle.properties b/gradle.properties index 2c93e3129..6bc6c9938 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ kotlin.parallel.tasks.in.project=true # This is version for PgJdbc itself # Note: it should not include "-SNAPSHOT" as it is automatically added by build.gradle.kts # Release version can be generated by using -Prelease or -Prc= arguments -pgjdbc.version=42.3.5-yb-7 +pgjdbc.version=42.3.5-yb-8 # The options below configures the use of local clone (e.g. testing development versions) # You can pass un-comment it, or pass option -PlocalReleasePlugins, or -PlocalReleasePlugins= diff --git a/pgjdbc/src/main/java/com/yugabyte/ysql/ClusterAwareLoadBalancer.java b/pgjdbc/src/main/java/com/yugabyte/ysql/ClusterAwareLoadBalancer.java index eeaa6e4de..b0872a06c 100644 --- a/pgjdbc/src/main/java/com/yugabyte/ysql/ClusterAwareLoadBalancer.java +++ b/pgjdbc/src/main/java/com/yugabyte/ysql/ClusterAwareLoadBalancer.java @@ -37,7 +37,11 @@ public int getRefreshListSeconds() { protected int refreshListSeconds = LoadBalanceProperties.DEFAULT_REFRESH_INTERVAL; public ClusterAwareLoadBalancer(LoadBalanceService.LoadBalanceType lb, int refreshInterval) { - this.loadBalance = lb; + if (lb != null) { + this.loadBalance = lb; + } else { + this.loadBalance = LoadBalanceType.FALSE; + } this.refreshListSeconds = refreshInterval; } diff --git a/pgjdbc/src/main/java/com/yugabyte/ysql/LoadBalanceProperties.java b/pgjdbc/src/main/java/com/yugabyte/ysql/LoadBalanceProperties.java index f3d19a829..7b609eb1e 100644 --- a/pgjdbc/src/main/java/com/yugabyte/ysql/LoadBalanceProperties.java +++ b/pgjdbc/src/main/java/com/yugabyte/ysql/LoadBalanceProperties.java @@ -65,7 +65,7 @@ public class LoadBalanceProperties { new ConcurrentHashMap<>(); private final String originalUrl; private final Properties originalProperties; - private LoadBalanceService.LoadBalanceType loadBalance; + private LoadBalanceService.LoadBalanceType loadBalance = LoadBalanceService.LoadBalanceType.FALSE; private final String ybURL; private String placements = null; private int refreshInterval = -1; diff --git a/pgjdbc/src/main/java/com/yugabyte/ysql/TopologyAwareLoadBalancer.java b/pgjdbc/src/main/java/com/yugabyte/ysql/TopologyAwareLoadBalancer.java index 598887c79..adf5654f8 100644 --- a/pgjdbc/src/main/java/com/yugabyte/ysql/TopologyAwareLoadBalancer.java +++ b/pgjdbc/src/main/java/com/yugabyte/ysql/TopologyAwareLoadBalancer.java @@ -57,7 +57,11 @@ public class TopologyAwareLoadBalancer implements LoadBalancer { private byte requestFlags; public TopologyAwareLoadBalancer(LoadBalanceType lb, String placementValues, boolean onlyExplicitFallback) { - loadBalance = lb; + if (lb != null) { + loadBalance = lb; + } else { + loadBalance = LoadBalanceType.FALSE; + } placements = placementValues; explicitFallbackOnly = onlyExplicitFallback; refreshIntervalSeconds = Integer.getInteger(REFRESH_INTERVAL_KEY, DEFAULT_REFRESH_INTERVAL);