/** * Determines the HTTP/HTTPS port NiFi is configured to bind to. Prefers the HTTPS port. Throws an exception if neither is configured. * * @return the configured port number */ public Integer getConfiguredHttpOrHttpsPort() throws RuntimeException { if (getSslPort() != null) { return getSslPort(); } else if (getPort() != null) { return getPort(); } else { throw new RuntimeException("The HTTP or HTTPS port must be configured"); } }
/** * Configures an HTTP connector and adds it to the server. * * @param server the Jetty server instance * @param httpConfiguration the configuration object for the HTTP protocol settings */ private void configureHttpConnector(Server server, HttpConfiguration httpConfiguration) { String hostname = props.getProperty(NiFiProperties.WEB_HTTP_HOST); final Integer port = props.getPort(); String connectorLabel = "HTTP"; final Map<String, String> httpNetworkInterfaces = props.getHttpNetworkInterfaces(); ServerConnectorCreator<Server, HttpConfiguration, ServerConnector> scc = (s, c) -> new ServerConnector(s, new HttpConnectionFactory(c)); configureGenericConnector(server, httpConfiguration, hostname, port, connectorLabel, httpNetworkInterfaces, scc); }
private int determineServerPort(NiFiProperties props) { return props.getSslPort() != null ? props.getSslPort() : props.getPort(); }
/** * Returns true if there are configured properties for both HTTP and HTTPS connectors (specifically port because the hostname can be left blank in the HTTP connector). * Prints a warning log message with the relevant properties. * * @param props the NiFiProperties * @return true if both ports are present */ static boolean bothHttpAndHttpsConnectorsConfigured(NiFiProperties props) { Integer httpPort = props.getPort(); String httpHostname = props.getProperty(NiFiProperties.WEB_HTTP_HOST); Integer httpsPort = props.getSslPort(); String httpsHostname = props.getProperty(NiFiProperties.WEB_HTTPS_HOST); if (httpPort != null && httpsPort != null) { logger.warn("Both the HTTP and HTTPS connectors are configured in nifi.properties. Only one of these connectors should be configured. See the NiFi Admin Guide for more details"); logger.warn("HTTP connector: http://" + httpHostname + ":" + httpPort); logger.warn("HTTPS connector: https://" + httpsHostname + ":" + httpsPort); return true; } return false; }
private void configureConnectors(final Server server) throws ServerConfigurationException { // create the http configuration final HttpConfiguration httpConfiguration = new HttpConfiguration(); final int headerSize = DataUnit.parseDataSize(props.getWebMaxHeaderSize(), DataUnit.B).intValue(); httpConfiguration.setRequestHeaderSize(headerSize); httpConfiguration.setResponseHeaderSize(headerSize); // Check if both HTTP and HTTPS connectors are configured and fail if both are configured if (bothHttpAndHttpsConnectorsConfigured(props)) { logger.error("NiFi only supports one mode of HTTP or HTTPS operation, not both simultaneously. " + "Check the nifi.properties file and ensure that either the HTTP hostname and port or the HTTPS hostname and port are empty"); startUpFailure(new IllegalStateException("Only one of the HTTP and HTTPS connectors can be configured at one time")); } if (props.getSslPort() != null) { configureHttpsConnector(server, httpConfiguration); } else if (props.getPort() != null) { configureHttpConnector(server, httpConfiguration); } else { logger.error("Neither the HTTP nor HTTPS connector was configured in nifi.properties"); startUpFailure(new IllegalStateException("Must configure HTTP or HTTPS connector")); } }
port = getPort();
final Integer apiPort = isSiteToSiteSecure ? nifiProperties.getSslPort() : nifiProperties.getPort(); final NodeInformation self = new NodeInformation(remoteInputHostVal, nifiProperties.getRemoteInputPort(),
/** * Determines the HTTP/HTTPS port NiFi is configured to bind to. Prefers the HTTPS port. Throws an exception if neither is configured. * * @return the configured port number */ public Integer getConfiguredHttpOrHttpsPort() throws RuntimeException { if (getSslPort() != null) { return getSslPort(); } else if (getPort() != null) { return getPort(); } else { throw new RuntimeException("The HTTP or HTTPS port must be configured"); } }
final Integer apiPort = isSiteToSiteSecure ? nifiProperties.getSslPort() : nifiProperties.getPort(); final NodeInformation self = new NodeInformation(remoteInputHostVal, nifiProperties.getRemoteInputPort(),