Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions k8s/helm/values/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ seqcoordAppProperties:
spring.data.mongodb.replica-set-name=production-mongodb-borrego-a
spring.data.mongodb.ssl.enabled=false
seqcoords.mongo-db-uri-scheme=mongodb+srv
seqcoords.read-preference=secondaryPreferred
seqcoord.b.app.properties: |-
spring.data.mongodb.host=production-mongodb-borrego-b-svc.production.svc.cluster.local
spring.data.mongodb.database=annot
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.replica-set-name=production-mongodb-borrego-b
spring.data.mongodb.ssl.enabled=false
seqcoords.mongo-db-uri-scheme=mongodb+srv
seqcoords.read-preference=secondaryPreferred

javaOptions: "-Xmx20g -server -Dspring.config.additional-location=/var/www/seqcoord.app.properties -Dlog4j.configurationFile=/var/www/log4j2.xml"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ public class SeqCoordAppConfigs {

private String mongoDbUriScheme = "mongodb";

private String readPreference;

public String getMongoDbUriScheme() {
return mongoDbUriScheme;
}

public void setMongoDbUriScheme(String mongoDbUriScheme) {
this.mongoDbUriScheme = mongoDbUriScheme;
}

public String getReadPreference() {
return readPreference;
}

public void setReadPreference(String readPreference) {
this.readPreference = readPreference;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MongoConnectionDetails mongoConnectionDetails(MongoProperties props) {
}
String userEncoded = URLEncoder.encode(props.getUsername(), StandardCharsets.UTF_8);
String pwdEncoded = URLEncoder.encode(new String(props.getPassword()), StandardCharsets.UTF_8);
String extraParams = buildParamsString(props.getSsl() != null && props.getSsl().isEnabled(), props.getReplicaSetName());
String extraParams = buildParamsString(props.getSsl() != null && props.getSsl().isEnabled(), props.getReplicaSetName(), seqCoordAppConfigs.getReadPreference());
String uri = String.format("%s://%s:%s@%s%s/%s%s",
seqCoordAppConfigs.getMongoDbUriScheme(),
userEncoded,
Expand All @@ -63,11 +63,15 @@ private String getUriRedacted(String uri, String userEncoded, String pwdEncoded)
return uri.replace(userEncoded, "********").replace(pwdEncoded, "********");
}

private String buildParamsString(boolean sslEnabled, String replicaSet) {
private String buildParamsString(boolean sslEnabled, String replicaSet, String readPreference) {
String repSetStr = "";
if (replicaSet != null && !replicaSet.isEmpty()) {
repSetStr = "&replicaSet=" + replicaSet;
}
return "?ssl=" + sslEnabled + repSetStr;
String readPrefStr = "";
if (readPreference != null && !readPreference.isEmpty()) {
readPrefStr = "&readPreference=" + readPreference;
}
return "?ssl=" + sslEnabled + repSetStr + readPrefStr;
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ spring.data.mongodb.authentication-database=admin
spring.data.mongodb.replica-set-name=
spring.data.mongodb.ssl.enabled=false
seqcoords.mongo-db-uri-scheme=mongodb
seqcoords.read-preference=primary