Skip to content

Commit

Permalink
Set the default loadBalance to LoadBalanceType.FALSE (#23)
Browse files Browse the repository at this point in the history
* Set the default loadBalance to LoadBalanceType.FALSE
* Update version to 42.3.5-yb-8
  • Loading branch information
ashetkar authored Oct 1, 2024
1 parent 5a1f2f0 commit b42efc6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>jdbc-yugabytedb</artifactId>
<version>42.3.5-yb-7</version>
<version>42.3.5-yb-8</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.zaxxer/HikariCP -->
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=<int> 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=<path>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b42efc6

Please sign in to comment.