-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
… have precedence. Fixes #5219
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -132,6 +132,18 @@ static List<MutableCapabilities> getCapabilities() { | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private static class HostPort { | ||||||||||||||
final String host; | ||||||||||||||
final int port; | ||||||||||||||
|
||||||||||||||
HostPort(String host, int port) { | ||||||||||||||
this.host = host; | ||||||||||||||
this.port = port; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private HostPort hubHostPort; | ||||||||||||||
|
||||||||||||||
/* | ||||||||||||||
* config parameters which do not serialize or de-serialize | ||||||||||||||
*/ | ||||||||||||||
|
@@ -228,11 +240,13 @@ static List<MutableCapabilities> getCapabilities() { | |||||||||||||
/** | ||||||||||||||
* The hub url. Defaults to {@code http://localhost:4444}. | ||||||||||||||
*/ | ||||||||||||||
@Expose | ||||||||||||||
@Parameter( | ||||||||||||||
names = "-hub", | ||||||||||||||
description = "<String> : the url that will be used to post the registration request. This option takes precedence over -hubHost and -hubPort options." | ||||||||||||||
) | ||||||||||||||
private String hubOption; | ||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||||||||||||||
|
||||||||||||||
@Expose | ||||||||||||||
public String hub = DEFAULT_HUB; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
|
@@ -307,23 +321,42 @@ public GridNodeConfiguration() { | |||||||||||||
} | ||||||||||||||
|
||||||||||||||
public String getHubHost() { | ||||||||||||||
if (hubHost == null) { | ||||||||||||||
if (hub == null) { | ||||||||||||||
throw new RuntimeException("You must specify either a hubHost or hub parameter."); | ||||||||||||||
} | ||||||||||||||
parseHubUrl(); | ||||||||||||||
} | ||||||||||||||
return hubHost; | ||||||||||||||
return getHubHostPort().host; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
public Integer getHubPort() { | ||||||||||||||
if (hubPort == null) { | ||||||||||||||
if (hub == null) { | ||||||||||||||
throw new RuntimeException("You must specify either a hubPort or hub parameter."); | ||||||||||||||
return getHubHostPort().port; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private HostPort getHubHostPort() { | ||||||||||||||
if (hubHostPort == null) { // parse options | ||||||||||||||
// -hub has precedence | ||||||||||||||
if (hubOption != null) { | ||||||||||||||
hub = hubOption; | ||||||||||||||
try { | ||||||||||||||
URL u = new URL(hub); | ||||||||||||||
hubHostPort = new HostPort(u.getHost(), u.getPort()); | ||||||||||||||
} catch (MalformedURLException mURLe) { | ||||||||||||||
throw new RuntimeException("-hub must be a valid url: " + hub, mURLe); | ||||||||||||||
} | ||||||||||||||
} else if (hubHost != null || hubPort != null) { | ||||||||||||||
if (hubHost == null) { | ||||||||||||||
throw new RuntimeException("You must specify either a -hubHost or -hub parameter."); | ||||||||||||||
} | ||||||||||||||
if (hubPort == null) { | ||||||||||||||
throw new RuntimeException("You must specify either a -hubPort or -hub parameter."); | ||||||||||||||
} | ||||||||||||||
hubHostPort = new HostPort(hubHost, hubPort); | ||||||||||||||
} else { | ||||||||||||||
try { | ||||||||||||||
URL u = new URL(hub); | ||||||||||||||
hubHostPort = new HostPort(u.getHost(), u.getPort()); | ||||||||||||||
} catch (MalformedURLException mURLe) { | ||||||||||||||
throw new RuntimeException("-hub must be a valid url: " + hub, mURLe); | ||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
kool79
Contributor
|
CLI | json | who wins? |
---|---|---|
hub, hubHost, hubPort | <none> |
hub |
<none> |
hub, hubHost, hubPort | ?? hub (I think) |
hubHost, hubPort | hub | ?? CLI should win (I think) |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
@barancev, hubOption is redundant. It was never set.