Skip to content

Commit 770c241

Browse files
akshaysonvaneaebadirad
authored andcommitted
Changed logic for dealing with mlLoadBalancerHosts and mlIsHostLoadBalancer (#1386)
1 parent 1b96d1a commit 770c241

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,18 +928,43 @@ public void loadConfigurationFromProperties(Properties environmentProperties) {
928928
mlUsername = getEnvPropString(environmentProperties, "mlUsername", mlUsername);
929929
mlPassword = getEnvPropString(environmentProperties, "mlPassword", mlPassword);
930930

931-
isHostLoadBalancer = getEnvPropBoolean(environmentProperties, "mlIsHostLoadBalancer", false);
931+
isHostLoadBalancer = getEnvPropBoolean(environmentProperties, "mlIsHostLoadBalancer");
932932
String mlHost = getEnvPropString(environmentProperties, "mlHost", null);
933933
String lbh = getEnvPropString(environmentProperties, "mlLoadBalancerHosts", null);
934-
if (isHostLoadBalancer) {
935-
if (mlHost != null && lbh != null && !mlHost.equals(lbh)){
936-
throw new DataHubConfigurationException("mlLoadBalancerHosts must be the same as mlHost");
934+
if (isHostLoadBalancer != null){
935+
if (isHostLoadBalancer) {
936+
if (mlHost != null && lbh != null){
937+
logger.warn("\"mlLoadBalancerHosts\" is a deprecated property. When \"mlIsHostLoadBalancer\" is set to \"true\", the value specified for \"mlHost\" will be used as the load balancer.");
938+
if (!mlHost.equals(lbh)) {
939+
throw new DataHubConfigurationException("\"mlLoadBalancerHosts\" must be the same as \"mlHost\"");
940+
}
941+
else {
942+
loadBalancerHost = mlHost;
943+
}
944+
}
945+
}
946+
else {
947+
if (lbh != null){
948+
throw new DataHubConfigurationException("\"mlIsHostLoadBalancer\" must not be false if you are using \"mlLoadBalancerHosts\"");
949+
}
950+
}
951+
}
952+
else{
953+
if (mlHost != null && lbh != null){
954+
if (!mlHost.equals(lbh)) {
955+
throw new DataHubConfigurationException("\"mlLoadBalancerHosts\" must be the same as \"mlHost\"");
956+
}
957+
else {
958+
isHostLoadBalancer = true;
959+
loadBalancerHost = mlHost;
960+
}
937961
}
938962
else {
939-
loadBalancerHost = mlHost;
963+
isHostLoadBalancer = false;
940964
}
941965
}
942966

967+
943968
isProvisionedEnvironment = getEnvPropBoolean(environmentProperties, "mlIsProvisionedEnvironment", false);
944969

945970
projectDir = getEnvPropString(environmentProperties, "hubProjectDir", projectDir);
@@ -1462,6 +1487,18 @@ private boolean getEnvPropBoolean(Properties environmentProperties, String key,
14621487
return res;
14631488
}
14641489

1490+
private Boolean getEnvPropBoolean(Properties environmentProperties, String key) {
1491+
String value = environmentProperties.getProperty(key);
1492+
Boolean res;
1493+
if (value != null) {
1494+
res = Boolean.parseBoolean(value);
1495+
}
1496+
else {
1497+
res = null;
1498+
}
1499+
return res;
1500+
}
1501+
14651502
@JsonIgnore
14661503
public String getInfo()
14671504
{

marklogic-data-hub/src/test/java/com/marklogic/hub/core/HubConfigTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ public void testLoadBalancerProps() {
8282
getHubFlowRunnerConfig();
8383
}
8484
catch (DataHubConfigurationException e){
85-
assertEquals( "mlLoadBalancerHosts must be the same as mlHost", e.getMessage());
85+
assertEquals( "\"mlLoadBalancerHosts\" must be the same as \"mlHost\"", e.getMessage());
8686
}
8787

88+
deleteProp("mlLoadBalancerHosts");
8889
deleteProp("mlIsHostLoadBalancer");
8990
assertFalse(getHubFlowRunnerConfig().getIsHostLoadBalancer());
9091
}

0 commit comments

Comments
 (0)