org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils.AddressResolution Java Examples
The following examples show how to use
org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils.AddressResolution.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AkkaRpcServiceUtils.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param config The configuration from which to deduce further settings. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, Configuration config) throws UnknownHostException { checkNotNull(config, "config is null"); final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) && SSLUtils.isInternalSSLEnabled(config); return getRpcUrl( hostname, port, endpointName, addressResolution, sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP); }
Example #2
Source File: AkkaRpcServiceUtils.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param akkaProtocol True, if security/encryption is enabled, false otherwise. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, AkkaProtocol akkaProtocol) throws UnknownHostException { checkNotNull(hostname, "hostname is null"); checkNotNull(endpointName, "endpointName is null"); checkArgument(port > 0 && port <= 65535, "port must be in [1, 65535]"); final String protocolPrefix = akkaProtocol == AkkaProtocol.SSL_TCP ? AKKA_SSL_TCP : AKKA_TCP; if (addressResolution == AddressResolution.TRY_ADDRESS_RESOLUTION) { // Fail fast if the hostname cannot be resolved //noinspection ResultOfMethodCallIgnored InetAddress.getByName(hostname); } final String hostPort = NetUtils.unresolvedHostAndPortToNormalizedString(hostname, port); return String.format("%s://flink@%s/user/%s", protocolPrefix, hostPort, endpointName); }
Example #3
Source File: StandaloneUtils.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates a {@link StandaloneLeaderRetrievalService} form the given configuration and the * JobManager name. The host and port for the remote Akka URL are retrieved from the provided * configuration. Instead of using the standard JobManager Akka name, the provided one is used * for the remote Akka URL. * * @param configuration Configuration instance containing hte host and port information * @param resolveInitialHostName If true, resolves the hostname of the StandaloneLeaderRetrievalService * @param jobManagerName Name of the JobManager actor * @return StandaloneLeaderRetrievalService * @throws ConfigurationException if the job manager address cannot be retrieved from the configuration * @throws UnknownHostException if the job manager address cannot be resolved */ public static StandaloneLeaderRetrievalService createLeaderRetrievalService( Configuration configuration, boolean resolveInitialHostName, String jobManagerName) throws ConfigurationException, UnknownHostException { Tuple2<String, Integer> hostnamePort = HighAvailabilityServicesUtils.getJobManagerAddress(configuration); String jobManagerAkkaUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, jobManagerName != null ? jobManagerName : JobMaster.JOB_MANAGER_NAME, resolveInitialHostName ? AddressResolution.TRY_ADDRESS_RESOLUTION : AddressResolution.NO_ADDRESS_RESOLUTION, configuration); return new StandaloneLeaderRetrievalService(jobManagerAkkaUrl); }
Example #4
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 6 votes |
/** * * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param config The configuration from which to deduce further settings. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, Configuration config) throws UnknownHostException { checkNotNull(config, "config is null"); final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) && SSLUtils.isInternalSSLEnabled(config); return getRpcUrl( hostname, port, endpointName, addressResolution, sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP); }
Example #5
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 6 votes |
/** * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param akkaProtocol True, if security/encryption is enabled, false otherwise. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, AkkaProtocol akkaProtocol) throws UnknownHostException { checkNotNull(hostname, "hostname is null"); checkNotNull(endpointName, "endpointName is null"); checkArgument(port > 0 && port <= 65535, "port must be in [1, 65535]"); final String protocolPrefix = akkaProtocol == AkkaProtocol.SSL_TCP ? AKKA_SSL_TCP : AKKA_TCP; if (addressResolution == AddressResolution.TRY_ADDRESS_RESOLUTION) { // Fail fast if the hostname cannot be resolved //noinspection ResultOfMethodCallIgnored InetAddress.getByName(hostname); } final String hostPort = NetUtils.unresolvedHostAndPortToNormalizedString(hostname, port); return String.format("%s://flink@%s/user/%s", protocolPrefix, hostPort, endpointName); }
Example #6
Source File: StandaloneUtils.java From flink with Apache License 2.0 | 6 votes |
/** * Creates a {@link StandaloneLeaderRetrievalService} form the given configuration and the * JobManager name. The host and port for the remote Akka URL are retrieved from the provided * configuration. Instead of using the standard JobManager Akka name, the provided one is used * for the remote Akka URL. * * @param configuration Configuration instance containing hte host and port information * @param resolveInitialHostName If true, resolves the hostname of the StandaloneLeaderRetrievalService * @param jobManagerName Name of the JobManager actor * @return StandaloneLeaderRetrievalService * @throws ConfigurationException if the job manager address cannot be retrieved from the configuration * @throws UnknownHostException if the job manager address cannot be resolved */ public static StandaloneLeaderRetrievalService createLeaderRetrievalService( Configuration configuration, boolean resolveInitialHostName, String jobManagerName) throws ConfigurationException, UnknownHostException { Tuple2<String, Integer> hostnamePort = HighAvailabilityServicesUtils.getJobManagerAddress(configuration); String jobManagerAkkaUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, jobManagerName != null ? jobManagerName : JobMaster.JOB_MANAGER_NAME, resolveInitialHostName ? AddressResolution.TRY_ADDRESS_RESOLUTION : AddressResolution.NO_ADDRESS_RESOLUTION, configuration); return new StandaloneLeaderRetrievalService(jobManagerAkkaUrl); }
Example #7
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 6 votes |
/** * * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param config The configuration from which to deduce further settings. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, Configuration config) throws UnknownHostException { checkNotNull(config, "config is null"); final boolean sslEnabled = config.getBoolean(AkkaOptions.SSL_ENABLED) && SSLUtils.isInternalSSLEnabled(config); return getRpcUrl( hostname, port, endpointName, addressResolution, sslEnabled ? AkkaProtocol.SSL_TCP : AkkaProtocol.TCP); }
Example #8
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 6 votes |
/** * @param hostname The hostname or address where the target RPC service is listening. * @param port The port where the target RPC service is listening. * @param endpointName The name of the RPC endpoint. * @param addressResolution Whether to try address resolution of the given hostname or not. * This allows to fail fast in case that the hostname cannot be resolved. * @param akkaProtocol True, if security/encryption is enabled, false otherwise. * * @return The RPC URL of the specified RPC endpoint. */ public static String getRpcUrl( String hostname, int port, String endpointName, HighAvailabilityServicesUtils.AddressResolution addressResolution, AkkaProtocol akkaProtocol) throws UnknownHostException { checkNotNull(hostname, "hostname is null"); checkNotNull(endpointName, "endpointName is null"); checkArgument(isValidClientPort(port), "port must be in [1, 65535]"); if (addressResolution == AddressResolution.TRY_ADDRESS_RESOLUTION) { // Fail fast if the hostname cannot be resolved //noinspection ResultOfMethodCallIgnored InetAddress.getByName(hostname); } final String hostPort = NetUtils.unresolvedHostAndPortToNormalizedString(hostname, port); return internalRpcUrl(endpointName, Optional.of(new RemoteAddressInformation(hostPort, akkaProtocol))); }