Fix javadocs to allow build to pass in JDK 17 (#4834)

- Added missing javadocs so that javadoc doclint passes against JDK 17 (invoke by Besu gradle build).
- Exclude following packages from javadoc lint:
org.hyperledger.besu.privacy.contracts.generated
org.hyperledger.besu.tests.acceptance.*
- Temporarily exclude ethereum and evm submodule for doc lint checks.
- Run the javadoc task using GitHub actions (use Java 17) to report any javadoc errors during the PR builds
- Updating plugin-api build.gradle with new hash as javadoc comments caused it to change

Signed-off-by: Usman Saleem <usman@usmans.info>
This commit is contained in:
Usman Saleem
2023-01-18 22:51:00 +10:00
committed by GitHub
parent aef335cfcf
commit 9eb32836b7
763 changed files with 15266 additions and 74 deletions

View File

@@ -14,14 +14,27 @@
*/
package org.hyperledger.besu.nat;
/** The enum Nat method. */
public enum NatMethod {
/** Upnp nat method. */
UPNP,
/** Upnpp 2 ponly nat method. */
UPNPP2PONLY,
/** Docker nat method. */
DOCKER,
/** Kubernetes nat method. */
KUBERNETES,
/** Auto nat method. */
AUTO,
/** None nat method. */
NONE;
/**
* Map NatMethod from string value.
*
* @param str the Nat Method in String format
* @return instance of mapped NatMethod
*/
public static NatMethod fromString(final String str) {
for (final NatMethod mode : NatMethod.values()) {
if (mode.name().equalsIgnoreCase(str)) {

View File

@@ -39,12 +39,23 @@ public class NatService {
private Optional<NatManager> currentNatManager;
private final boolean fallbackEnabled;
/**
* Instantiates a new Nat service.
*
* @param natManager the nat manager
* @param fallbackEnabled the fallback enabled
*/
public NatService(final Optional<NatManager> natManager, final boolean fallbackEnabled) {
this.currentNatMethod = retrieveNatMethod(natManager);
this.currentNatManager = natManager;
this.fallbackEnabled = fallbackEnabled;
}
/**
* Instantiates a new Nat service.
*
* @param natManager the nat manager
*/
public NatService(final Optional<NatManager> natManager) {
this(natManager, DEFAULT_FALLBACK_STATUS);
}
@@ -160,6 +171,7 @@ public class NatService {
*
* @param fallbackValue the advertised IP address fallback value
* @return The local IP address wrapped in a {@link Optional}.
* @throws RuntimeException the runtime exception
*/
public String queryLocalIPAddress(final String fallbackValue) throws RuntimeException {
if (isNatEnvironment()) {

View File

@@ -36,21 +36,40 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Abstract Nat manager. */
public abstract class AbstractNatManager implements NatManager {
private static final Logger LOG = LoggerFactory.getLogger(AbstractNatManager.class);
/** The Nat method. */
protected final NatMethod natMethod;
/** The Started. */
protected final AtomicBoolean started = new AtomicBoolean();
/**
* Instantiates a new Abstract nat manager.
*
* @param natMethod the nat method
*/
protected AbstractNatManager(final NatMethod natMethod) {
this.natMethod = natMethod;
}
/**
* Do start.
*
* @throws NatInitializationException the nat initialization exception
*/
protected abstract void doStart() throws NatInitializationException;
/** Do stop. */
protected abstract void doStop();
/**
* Retrieve external ip address completable future.
*
* @return the completable future
*/
protected abstract CompletableFuture<String> retrieveExternalIPAddress();
@Override

View File

@@ -17,7 +17,14 @@ package org.hyperledger.besu.nat.core;
import java.util.Optional;
/** The interface Ip detector. */
public interface IpDetector {
/**
* Detect advertised ip.
*
* @return the optional Ip in String
* @throws Exception in case of error while detecting advertised Ip
*/
Optional<String> detectAdvertisedIp() throws Exception;
}

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.CompletableFuture;
*/
public interface NatManager {
/** The constant TIMEOUT_SECONDS. */
int TIMEOUT_SECONDS = 60;
/**

View File

@@ -19,8 +19,14 @@ import org.hyperledger.besu.nat.NatMethod;
import java.util.Optional;
/** The interface Nat method detector. */
@FunctionalInterface
public interface NatMethodDetector {
/**
* Detect NatMethod.
*
* @return the optional NatMethod
*/
Optional<NatMethod> detect();
}

View File

@@ -25,6 +25,16 @@ public class NatPortMapping {
private final int externalPort;
private final int internalPort;
/**
* Instantiates a new Nat port mapping.
*
* @param natServiceType the nat service type
* @param protocol the protocol
* @param internalHost the internal host
* @param remoteHost the remote host
* @param externalPort the external port
* @param internalPort the internal port
*/
public NatPortMapping(
final NatServiceType natServiceType,
final NetworkProtocol protocol,
@@ -40,26 +50,56 @@ public class NatPortMapping {
this.internalPort = internalPort;
}
/**
* Gets nat service type.
*
* @return the nat service type
*/
public NatServiceType getNatServiceType() {
return natServiceType;
}
/**
* Gets protocol.
*
* @return the protocol
*/
public NetworkProtocol getProtocol() {
return protocol;
}
/**
* Gets internal host.
*
* @return the internal host
*/
public String getInternalHost() {
return internalHost;
}
/**
* Gets remote host.
*
* @return the remote host
*/
public String getRemoteHost() {
return remoteHost;
}
/**
* Gets external port.
*
* @return the external port
*/
public int getExternalPort() {
return externalPort;
}
/**
* Gets internal port.
*
* @return the internal port
*/
public int getInternalPort() {
return internalPort;
}

View File

@@ -17,7 +17,7 @@ package org.hyperledger.besu.nat.core.domain;
/**
* This enum describes the types of services that could be impacted by the {@link
* org.hyperledger.besu.nat.NatMethod} used by the Besu node.
* org.hyperledger.besu.nat.NatMethod}* used by the Besu node.
*
* <ul>
* <li><b>JSON_RPC:</b> Ethereum JSON-RPC HTTP service.
@@ -26,8 +26,11 @@ package org.hyperledger.besu.nat.core.domain;
* </ul>
*/
public enum NatServiceType {
/** Json rpc nat service type. */
JSON_RPC("json-rpc"),
/** Rlpx nat service type. */
RLPX("rlpx"),
/** Discovery nat service type. */
DISCOVERY("discovery");
private final String value;
@@ -53,6 +56,11 @@ public enum NatServiceType {
String.format("Invalid NAT service type provided: %s", natServiceTypeName));
}
/**
* Gets value.
*
* @return the value
*/
public String getValue() {
return value;
}

View File

@@ -24,6 +24,8 @@ package org.hyperledger.besu.nat.core.domain;
* </ul>
*/
public enum NetworkProtocol {
/** Tcp network protocol. */
TCP,
/** Udp network protocol. */
UDP
}

View File

@@ -14,12 +14,24 @@
*/
package org.hyperledger.besu.nat.core.exception;
/** The Nat initialization exception. */
public class NatInitializationException extends Exception {
/**
* Instantiates a new Nat initialization exception.
*
* @param message the message
*/
public NatInitializationException(final String message) {
super(message);
}
/**
* Instantiates a new Nat initialization exception.
*
* @param message the message
* @param cause the cause
*/
public NatInitializationException(final String message, final Throwable cause) {
super(message, cause);
}

View File

@@ -24,6 +24,7 @@ import java.nio.file.Paths;
import java.util.Optional;
import java.util.stream.Stream;
/** The Docker detector. */
public class DockerDetector implements NatMethodDetector {
@Override

View File

@@ -49,10 +49,25 @@ public class DockerNatManager extends AbstractNatManager {
private String internalAdvertisedHost;
private final List<NatPortMapping> forwardedPorts = new ArrayList<>();
/**
* Instantiates a new Docker nat manager.
*
* @param advertisedHost the advertised host
* @param p2pPort the p 2 p port
* @param rpcHttpPort the rpc http port
*/
public DockerNatManager(final String advertisedHost, final int p2pPort, final int rpcHttpPort) {
this(new HostBasedIpDetector(), advertisedHost, p2pPort, rpcHttpPort);
}
/**
* Instantiates a new Docker nat manager.
*
* @param ipDetector the ip detector
* @param advertisedHost the advertised host
* @param p2pPort the p 2 p port
* @param rpcHttpPort the rpc http port
*/
public DockerNatManager(
final IpDetector ipDetector,
final String advertisedHost,

View File

@@ -21,6 +21,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;
/** The Host based Ip detector. */
public class HostBasedIpDetector implements IpDetector {
private static final String HOSTNAME = "HOST_IP";

View File

@@ -23,6 +23,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
/** The Kubernetes detector. */
public class KubernetesDetector implements NatMethodDetector {
// When a Pod runs on a Node, the kubelet adds a set of environment variables for each active

View File

@@ -49,12 +49,18 @@ import org.slf4j.LoggerFactory;
public class KubernetesNatManager extends AbstractNatManager {
private static final Logger LOG = LoggerFactory.getLogger(KubernetesNatManager.class);
/** The constant DEFAULT_BESU_SERVICE_NAME_FILTER. */
public static final String DEFAULT_BESU_SERVICE_NAME_FILTER = "besu";
private String internalAdvertisedHost;
private final String besuServiceNameFilter;
private final List<NatPortMapping> forwardedPorts = new ArrayList<>();
/**
* Instantiates a new Kubernetes nat manager.
*
* @param besuServiceNameFilter the besu service name filter
*/
public KubernetesNatManager(final String besuServiceNameFilter) {
super(NatMethod.KUBERNETES);
this.besuServiceNameFilter = besuServiceNameFilter;
@@ -92,6 +98,12 @@ public class KubernetesNatManager extends AbstractNatManager {
}
}
/**
* Update using besu service. Visible for testing.
*
* @param service the service
* @throws RuntimeException the runtime exception
*/
@VisibleForTesting
void updateUsingBesuService(final V1Service service) throws RuntimeException {
try {

View File

@@ -14,17 +14,28 @@
*/
package org.hyperledger.besu.nat.kubernetes.service;
/** The enum Kubernetes service type. */
public enum KubernetesServiceType {
/** Cluster ip kubernetes service type. */
CLUSTER_IP("ClusterIP"),
/** Load balancer kubernetes service type. */
LOAD_BALANCER("LoadBalancer"),
/** Unknown kubernetes service type. */
UNKNOWN("");
/** The Name. */
String name;
KubernetesServiceType(final String name) {
this.name = name;
}
/**
* Map KubernetesServiceType from String value.
*
* @param name the name
* @return the kubernetes service type
*/
public static KubernetesServiceType fromName(final String name) {
for (KubernetesServiceType value : values()) {
if (value.name.equals(name)) {

View File

@@ -23,10 +23,16 @@ import java.util.Optional;
import io.kubernetes.client.openapi.models.V1LoadBalancerIngress;
import io.kubernetes.client.openapi.models.V1Service;
/** The Load balancer based detector. */
public class LoadBalancerBasedDetector implements IpDetector {
private final V1Service v1Service;
/**
* Instantiates a new Load balancer based detector.
*
* @param v1Service the v 1 service
*/
public LoadBalancerBasedDetector(final V1Service v1Service) {
this.v1Service = v1Service;
}

View File

@@ -32,11 +32,17 @@ import org.jupnp.model.message.UpnpResponse;
import org.jupnp.transport.impl.jetty.StreamClientConfigurationImpl;
import org.jupnp.transport.spi.AbstractStreamClient;
/** The OkHttp stream client. */
public class OkHttpStreamClient extends AbstractStreamClient<StreamClientConfigurationImpl, Call> {
private final StreamClientConfigurationImpl config;
private final OkHttpClient client;
/**
* Instantiates a new OkHttp stream client.
*
* @param config the config
*/
OkHttpStreamClient(final StreamClientConfigurationImpl config) {
this.config = config;
client = new OkHttpClient();