-
Notifications
You must be signed in to change notification settings - Fork 882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add port conflict exception #4565
Add port conflict exception #4565
Conversation
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
…o add_port_conflict_exception
Signed-off-by: Gabriel Fukushima <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a comment on the method name, then a general question, this covers listening ports of the RPC server, are the other listening ports already covered?
return false; | ||
} | ||
|
||
public static void checkPortsAvailable(final int tcpPort) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then method name says Ports
so suggests that more than one port as parameter like a var arg, otherwise use the singular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the name of the method, thanks for raising that @fab-10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the approach to cover the ports we will require to initialise all the services defined in the config. So we can have a more general solution that loops through the ports and check if they are available.
Signed-off-by: Gabriel Fukushima <[email protected]>
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java
Outdated
Show resolved
Hide resolved
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
if (!unavailablePorts.isEmpty()) { | ||
throw new InvalidConfigurationException( | ||
"Port(s) '" | ||
+ unavailablePorts.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: toString on unavailablePorts isn't necessary
@@ -3126,6 +3127,25 @@ private void checkPortClash() { | |||
}); | |||
} | |||
|
|||
private void checkIfRequiredPortsAreAvailable() { | |||
List<Integer> unavailablePorts = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: final
@@ -219,6 +219,7 @@ public CompletableFuture<?> start() { | |||
|
|||
final CompletableFuture<?> resultFuture = new CompletableFuture<>(); | |||
try { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to add the extra empty line?
util/src/main/java/org/hyperledger/besu/util/NetworkUtility.java
Outdated
Show resolved
Hide resolved
changes have been made to check port conflicts for other services
@@ -98,4 +105,31 @@ public static void checkPort(final int port, final String portTypeName) { | |||
"%s port requires a value between 1 and 65535. Got %d.", portTypeName, port)); | |||
} | |||
} | |||
|
|||
public static boolean isPortAvailableForTcp(final int port) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be private?
return false; | ||
} | ||
|
||
public static boolean isPortAvailableForUdp(final int port) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be private?
util/src/main/java/org/hyperledger/besu/util/NetworkUtility.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
return false; | ||
} | ||
|
||
public static boolean isPortAvailable(final int port) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider renaming to make to clear this is checking both udp and tcp. maybe rename to isPortAvailableForTcpAndUdp
Signed-off-by: Gabriel Fukushima <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
PR description
Added methods to check if port is available and call before starting websockets and rpc services.
Fixed Issue(s)
Fixes #4176
Documentation
doc-change-required
label to this PR ifupdates are required.
Changelog