Skip to content

Commit

Permalink
Merge pull request #307 from smukil/dual_write_fp
Browse files Browse the repository at this point in the history
Allow setting of dual-write FPs if any user config is provided
  • Loading branch information
smukil authored Mar 10, 2021
2 parents 4053a63 + edaae1e commit 776a3f9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@ public ConnectionPoolConfigurationImpl setCompressionThreshold(int thresholdInBy
return this;
}

public ConnectionPoolConfigurationImpl setDualWriteEnabled(boolean isDualWriteEnabled) {
this.isDualWriteEnabled = isDualWriteEnabled;
return this;
}

public ConnectionPoolConfigurationImpl setDualWriteClusterName(String dualWriteClusterName) {
this.dualWriteClusterName = dualWriteClusterName;
return this;
}

public ConnectionPoolConfigurationImpl setDualWritePercentage(int dualWritePercentage) {
this.dualWritePercentage = dualWritePercentage;
return this;
}

@Override
public String getConnectionPoolConsistency() {
return this.connectionPoolConsistency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4780,9 +4780,25 @@ public DynoJedisClient build() {
throw new DynoException("Cannot set isDatastoreClient(true) and also set withConnectionPoolConsistency() together");
}

ArchaiusConnectionPoolConfiguration archaiusConfig = new ArchaiusConnectionPoolConfiguration(appName);
if (cpConfig == null) {
cpConfig = new ArchaiusConnectionPoolConfiguration(appName);
cpConfig = archaiusConfig;
Logger.info("Dyno Client runtime properties: " + cpConfig.toString());
} else {
// Based on current requirements, we currently only want to prioritize pulling in the following FPs
// if provided:
// 'dualwrite.enabled', 'dualwrite.cluster', 'dualwrite.percentage'
// TODO: Move to a clean generic userconfig + FP model.
if (!cpConfig.isDualWriteEnabled() && archaiusConfig.isDualWriteEnabled()) {
// If a user sets these configs explicitly, they take precedence over the FP values.
if (cpConfig.getDualWriteClusterName() == null) {
cpConfig.setDualWriteClusterName(archaiusConfig.getDualWriteClusterName());
}
if (cpConfig.getDualWritePercentage() == 0) {
cpConfig.setDualWritePercentage(archaiusConfig.getDualWritePercentage());
}
cpConfig.setDualWriteEnabled(true);
}
}
cpConfig.setConnectToDatastore(isDatastoreClient);

Expand Down

0 comments on commit 776a3f9

Please sign in to comment.