Skip to content

Commit 5540212

Browse files
author
Vladimir Kotal
committed
rename host to uri
1 parent 87b20e9 commit 5540212

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public final class RuntimeEnvironment {
115115
private final Map<Project, List<RepositoryInfo>> repository_map = new ConcurrentHashMap<>();
116116
private final Map<String, SearcherManager> searcherManagerMap = new ConcurrentHashMap<>();
117117

118-
private String configHost;
118+
private String configURI;
119119

120120
private Statistics statistics = new Statistics();
121121

@@ -1210,15 +1210,15 @@ public int getGroupsCollapseThreshold() {
12101210
return threadConfig.get().getGroupsCollapseThreshold();
12111211
}
12121212

1213-
// The config host/port are not necessary to be present in the configuration
1213+
// The URI is not necessary to be present in the configuration
12141214
// (so that when -U option of the indexer is omitted, the config will not
1215-
// be sent to the webapp) so store them only in the RuntimeEnvironment.
1216-
public void setConfigHost(String host) {
1217-
configHost = host;
1215+
// be sent to the webapp) so store it only in the RuntimeEnvironment.
1216+
public void setConfigURI(String host) {
1217+
configURI = host;
12181218
}
12191219

1220-
public String getConfigHost() {
1221-
return configHost;
1220+
public String getConfigURI() {
1221+
return configURI;
12221222
}
12231223

12241224
public boolean isHistoryEnabled() {

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ private void markProjectIndexed(Project project) {
369369
// the project's isIndexed() is true because it triggers RepositoryInfo
370370
// refresh.
371371
if (project != null) {
372-
if (env.getConfigHost() != null) {
372+
if (env.getConfigURI() != null) {
373373
Response r = ClientBuilder.newClient()
374-
.target(env.getConfigHost())
374+
.target(env.getConfigURI())
375375
.path("api")
376376
.path("v1")
377377
.path("projects")

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public final class Indexer {
106106
private static final Set<String> defaultProjects = new TreeSet<>();
107107
private static final ArrayList<String> zapCache = new ArrayList<>();
108108
private static RuntimeEnvironment env = null;
109-
private static String host = null;
109+
private static String webappURI = null;
110110

111111
private static OptionParser optParser = null;
112112
private static boolean verbose = false;
@@ -238,7 +238,7 @@ public static void main(String argv[]) {
238238
RepositoryFactory.initializeIgnoredNames(env);
239239

240240
if (noindex) {
241-
getInstance().sendToConfigHost(env, host);
241+
getInstance().sendToConfigHost(env, webappURI);
242242
writeConfigToFile(env, configFilename);
243243
System.exit(0);
244244
}
@@ -285,11 +285,11 @@ public static void main(String argv[]) {
285285
// from project-less config to one with projects), set the property
286286
// so that the 'project/indexed' messages
287287
// emitted during indexing do not cause validation error.
288-
if (addProjects && host != null) {
288+
if (addProjects && webappURI != null) {
289289
try {
290-
IndexerUtil.enableProjects(host);
290+
IndexerUtil.enableProjects(webappURI);
291291
} catch (Exception e) {
292-
LOGGER.log(Level.SEVERE, "Mis-configuration of webapp host", e);
292+
LOGGER.log(Level.SEVERE, "Mis-configuration of webapp webappURI", e);
293293
System.err.println("Couldn't notify the webapp: " + e.getLocalizedMessage());
294294
}
295295
}
@@ -316,11 +316,11 @@ listFiles, createDict, subFiles, new ArrayList(repositories),
316316

317317
// Finally ping webapp to refresh indexes in the case of partial reindex
318318
// or send new configuration to the web application in the case of full reindex.
319-
if (host != null) {
319+
if (webappURI != null) {
320320
if (!subFiles.isEmpty()) {
321-
getInstance().refreshSearcherManagers(env, subFiles, host);
321+
getInstance().refreshSearcherManagers(env, subFiles, webappURI);
322322
} else {
323-
getInstance().sendToConfigHost(env, host);
323+
getInstance().sendToConfigHost(env, webappURI);
324324
}
325325
}
326326

@@ -341,7 +341,7 @@ listFiles, createDict, subFiles, new ArrayList(repositories),
341341
}
342342

343343
/**
344-
* Web address consisting of host and port of a web address
344+
* Web address consisting of webappURI and port of a web address
345345
*/
346346
public static class WebAddress {
347347
private String host;
@@ -360,18 +360,18 @@ public int getPort() {
360360
}
361361

362362
/**
363-
* Parse a web address into its host and port components
363+
* Parse a web address into its webappURI and port components
364364
* This method along with the WebAddress class is used by OptionParser
365365
* to validate user entry of a web address.
366-
* @param webAddr expected to be in the form host:port
366+
* @param webAddr expected to be in the form webappURI:port
367367
* @return WebAddress object
368368
* @throws NumberFormatException or IllegalArgumentException
369369
*/
370370
public static WebAddress parseWebAddress(String webAddr) {
371371
String[] hp = webAddr.split(":");
372372

373373
if (hp.length != 2) {
374-
throw new IllegalArgumentException("WebAddress syntax error (expecting host:port)");
374+
throw new IllegalArgumentException("WebAddress syntax error (expecting webappURI:port)");
375375
}
376376

377377
return new WebAddress(hp[0], hp[1]);
@@ -730,21 +730,21 @@ public static String[] parseOptions(String[] argv) throws ParseException {
730730
cfg.setTabSize((Integer)tabSize);
731731
});
732732

733-
parser.on("-U", "--host", "=protocol://host:port/contextPath",
734-
"Send the current configuration to the specified address").Do(webAddr -> {
735-
host = (String) webAddr;
733+
parser.on("-U", "--uri", "=protocol://webappURI:port/contextPath",
734+
"Send the current configuration to the specified webappURI").Do(webAddr -> {
735+
webappURI = (String) webAddr;
736736
try {
737-
URI uri = new URI(host);
737+
URI uri = new URI(webappURI);
738738
String scheme = uri.getScheme();
739739
if (!scheme.equals("http") && !scheme.equals("https")) {
740-
die("URI '" + host + "' does not have HTTP/HTTPS scheme");
740+
die("webappURI '" + webappURI + "' does not have HTTP/HTTPS scheme");
741741
}
742742
} catch (URISyntaxException e) {
743-
die("URL '" + host + "' is not valid.");
743+
die("URL '" + webappURI + "' is not valid.");
744744
}
745745

746746
env = RuntimeEnvironment.getInstance();
747-
env.setConfigHost(host);
747+
env.setConfigURI(webappURI);
748748
}
749749
);
750750

@@ -804,8 +804,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
804804
private static void checkConfiguration() {
805805
env = RuntimeEnvironment.getInstance();
806806

807-
if (noindex && (env.getConfigHost() == null || env.getConfigHost().isEmpty())) {
808-
die("Missing host URL");
807+
if (noindex && (env.getConfigURI() == null || env.getConfigURI().isEmpty())) {
808+
die("Missing webappURI URL");
809809
}
810810

811811
if (repositories.size() > 0 && !cfg.isHistoryEnabled()) {

0 commit comments

Comments
 (0)