Skip to content

Commit b9f03c9

Browse files
rahulvudutalamarklogic-builder
authored andcommitted
DHFPROD-10578: Lazy hubclient object creation
1 parent d8f505d commit b9f03c9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/ConfigureAppServerBasePaths.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
public class ConfigureAppServerBasePaths extends AbstractCommand {
3636

3737
private final HubConfigImpl hubConfig;
38-
private final HubClientImpl hubClient;
3938
private ObjectMapper mapper = new ObjectMapper();
4039

41-
public ConfigureAppServerBasePaths(HubConfig hubConfig, HubClient hubClient) {
40+
public ConfigureAppServerBasePaths(HubConfig hubConfig) {
4241
this.hubConfig = (HubConfigImpl) hubConfig;
43-
this.hubClient = (HubClientImpl) hubClient;
4442
setExecuteSortOrder(SortOrderConstants.DEPLOY_OTHER_SERVERS + 1);
4543
}
4644

@@ -130,13 +128,17 @@ private String getBasePathConfig() {
130128
}
131129

132130
private void waitForGateWayToRestart() {
133-
DatabaseClient databaseClient = hubClient.getStagingClient();
134131
int maxTimeToWaitInMs = 90000;
135132
int maxRetries = 15;
136133
int sleepTime = maxTimeToWaitInMs/maxRetries;
134+
HubClientImpl hubClient = null;
137135

138136
while(maxRetries > 0) {
139137
try {
138+
if(hubClient == null) {
139+
hubClient = (HubClientImpl) hubConfig.newHubClient();
140+
}
141+
DatabaseClient databaseClient = hubClient.getStagingClient();
140142
if(databaseClient.checkConnection().isConnected()) {
141143
logger.info("Checking gateway status: " + databaseClient.checkConnection().isConnected());
142144
break;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,7 @@ private void updateServerCommandList(Map<String, List<Command>> commandMap) {
708708
}
709709
newCommands.add(c);
710710
}
711-
hubClient = hubClient == null ? hubConfig.newHubClient() : hubClient;
712-
newCommands.add(new ConfigureAppServerBasePaths(hubConfig, hubClient));
711+
newCommands.add(new ConfigureAppServerBasePaths(hubConfig));
713712
commandMap.put(key, newCommands);
714713
}
715714

0 commit comments

Comments
 (0)