Java Code Examples for org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils#getRpcUrl()
The following examples show how to use
org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils#getRpcUrl() .
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: 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 2
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 3
Source File: AddressResolutionTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNoAddressResolution() throws UnknownHostException { AkkaRpcServiceUtils.getRpcUrl( NON_EXISTING_HOSTNAME, PORT, ENDPOINT_NAME, HighAvailabilityServicesUtils.AddressResolution.NO_ADDRESS_RESOLUTION, new Configuration()); }
Example 4
Source File: AddressResolutionTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testTryAddressResolution() { try { AkkaRpcServiceUtils.getRpcUrl( NON_EXISTING_HOSTNAME, PORT, ENDPOINT_NAME, HighAvailabilityServicesUtils.AddressResolution.TRY_ADDRESS_RESOLUTION, new Configuration()); fail("This should fail with an UnknownHostException"); } catch (UnknownHostException ignore) { // expected } }
Example 5
Source File: YarnPreConfiguredMasterNonHaServices.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Creates new YarnPreConfiguredMasterHaServices for the given Flink and YARN configuration. * This constructor parses the ResourceManager address from the Flink configuration and sets * up the HDFS access to store recovery data in the YARN application's working directory. * * @param config The Flink configuration of this component / process. * @param hadoopConf The Hadoop configuration for the YARN cluster. * * @throws IOException * Thrown, if the initialization of the Hadoop file system used by YARN fails. * @throws IllegalConfigurationException * Thrown, if the Flink configuration does not properly describe the ResourceManager address and port. */ public YarnPreConfiguredMasterNonHaServices( Configuration config, org.apache.hadoop.conf.Configuration hadoopConf, HighAvailabilityServicesUtils.AddressResolution addressResolution) throws IOException { super(config, hadoopConf); // track whether we successfully perform the initialization boolean successful = false; try { // extract the hostname and port of the resource manager final String rmHost = config.getString(YarnConfigOptions.APP_MASTER_RPC_ADDRESS); final int rmPort = config.getInteger(YarnConfigOptions.APP_MASTER_RPC_PORT); if (rmHost == null) { throw new IllegalConfigurationException("Config parameter '" + YarnConfigOptions.APP_MASTER_RPC_ADDRESS.key() + "' is missing."); } if (rmPort < 0) { throw new IllegalConfigurationException("Config parameter '" + YarnConfigOptions.APP_MASTER_RPC_PORT.key() + "' is missing."); } if (rmPort <= 0 || rmPort >= 65536) { throw new IllegalConfigurationException("Invalid value for '" + YarnConfigOptions.APP_MASTER_RPC_PORT.key() + "' - port must be in [1, 65535]"); } this.resourceManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( rmHost, rmPort, ResourceManager.RESOURCE_MANAGER_NAME, addressResolution, config); this.dispatcherRpcUrl = AkkaRpcServiceUtils.getRpcUrl( rmHost, rmPort, Dispatcher.DISPATCHER_NAME, addressResolution, config); // all well! successful = true; } finally { if (!successful) { // quietly undo what the parent constructor initialized try { super.close(); } catch (Throwable ignored) {} } } }
Example 6
Source File: HighAvailabilityServicesUtils.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public static HighAvailabilityServices createHighAvailabilityServices( Configuration configuration, Executor executor, AddressResolution addressResolution) throws Exception { HighAvailabilityMode highAvailabilityMode = LeaderRetrievalUtils.getRecoveryMode(configuration); switch (highAvailabilityMode) { case NONE: final Tuple2<String, Integer> hostnamePort = getJobManagerAddress(configuration); final String jobManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, JobMaster.JOB_MANAGER_NAME, addressResolution, configuration); final String resourceManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, ResourceManager.RESOURCE_MANAGER_NAME, addressResolution, configuration); final String dispatcherRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, Dispatcher.DISPATCHER_NAME, addressResolution, configuration); final String address = checkNotNull(configuration.getString(RestOptions.ADDRESS), "%s must be set", RestOptions.ADDRESS.key()); final int port = configuration.getInteger(RestOptions.PORT); final boolean enableSSL = SSLUtils.isRestSSLEnabled(configuration); final String protocol = enableSSL ? "https://" : "http://"; return new StandaloneHaServices( resourceManagerRpcUrl, dispatcherRpcUrl, jobManagerRpcUrl, String.format("%s%s:%s", protocol, address, port)); case ZOOKEEPER: BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(configuration); return new ZooKeeperHaServices( ZooKeeperUtils.startCuratorFramework(configuration), executor, configuration, blobStoreService); case FACTORY_CLASS: return createCustomHAServices(configuration, executor); default: throw new Exception("Recovery mode " + highAvailabilityMode + " is not supported."); } }
Example 7
Source File: YarnPreConfiguredMasterNonHaServices.java From flink with Apache License 2.0 | 4 votes |
/** * Creates new YarnPreConfiguredMasterHaServices for the given Flink and YARN configuration. * This constructor parses the ResourceManager address from the Flink configuration and sets * up the HDFS access to store recovery data in the YARN application's working directory. * * @param config The Flink configuration of this component / process. * @param hadoopConf The Hadoop configuration for the YARN cluster. * * @throws IOException * Thrown, if the initialization of the Hadoop file system used by YARN fails. * @throws IllegalConfigurationException * Thrown, if the Flink configuration does not properly describe the ResourceManager address and port. */ public YarnPreConfiguredMasterNonHaServices( Configuration config, org.apache.hadoop.conf.Configuration hadoopConf, HighAvailabilityServicesUtils.AddressResolution addressResolution) throws IOException { super(config, hadoopConf); // track whether we successfully perform the initialization boolean successful = false; try { // extract the hostname and port of the resource manager final String rmHost = config.getString(YarnConfigOptions.APP_MASTER_RPC_ADDRESS); final int rmPort = config.getInteger(YarnConfigOptions.APP_MASTER_RPC_PORT); if (rmHost == null) { throw new IllegalConfigurationException("Config parameter '" + YarnConfigOptions.APP_MASTER_RPC_ADDRESS.key() + "' is missing."); } if (rmPort < 0) { throw new IllegalConfigurationException("Config parameter '" + YarnConfigOptions.APP_MASTER_RPC_PORT.key() + "' is missing."); } if (rmPort <= 0 || rmPort >= 65536) { throw new IllegalConfigurationException("Invalid value for '" + YarnConfigOptions.APP_MASTER_RPC_PORT.key() + "' - port must be in [1, 65535]"); } this.resourceManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( rmHost, rmPort, ResourceManager.RESOURCE_MANAGER_NAME, addressResolution, config); this.dispatcherRpcUrl = AkkaRpcServiceUtils.getRpcUrl( rmHost, rmPort, Dispatcher.DISPATCHER_NAME, addressResolution, config); // all well! successful = true; } finally { if (!successful) { // quietly undo what the parent constructor initialized try { super.close(); } catch (Throwable ignored) {} } } }
Example 8
Source File: HighAvailabilityServicesUtils.java From flink with Apache License 2.0 | 4 votes |
public static HighAvailabilityServices createHighAvailabilityServices( Configuration configuration, Executor executor, AddressResolution addressResolution) throws Exception { HighAvailabilityMode highAvailabilityMode = HighAvailabilityMode.fromConfig(configuration); switch (highAvailabilityMode) { case NONE: final Tuple2<String, Integer> hostnamePort = getJobManagerAddress(configuration); final String jobManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, JobMaster.JOB_MANAGER_NAME, addressResolution, configuration); final String resourceManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, ResourceManager.RESOURCE_MANAGER_NAME, addressResolution, configuration); final String dispatcherRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, Dispatcher.DISPATCHER_NAME, addressResolution, configuration); final String address = checkNotNull(configuration.getString(RestOptions.ADDRESS), "%s must be set", RestOptions.ADDRESS.key()); final int port = configuration.getInteger(RestOptions.PORT); final boolean enableSSL = SSLUtils.isRestSSLEnabled(configuration); final String protocol = enableSSL ? "https://" : "http://"; return new StandaloneHaServices( resourceManagerRpcUrl, dispatcherRpcUrl, jobManagerRpcUrl, String.format("%s%s:%s", protocol, address, port)); case ZOOKEEPER: BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(configuration); return new ZooKeeperHaServices( ZooKeeperUtils.startCuratorFramework(configuration), executor, configuration, blobStoreService); case FACTORY_CLASS: return createCustomHAServices(configuration, executor); default: throw new Exception("Recovery mode " + highAvailabilityMode + " is not supported."); } }
Example 9
Source File: HighAvailabilityServicesUtils.java From flink with Apache License 2.0 | 4 votes |
public static HighAvailabilityServices createHighAvailabilityServices( Configuration configuration, Executor executor, AddressResolution addressResolution) throws Exception { HighAvailabilityMode highAvailabilityMode = HighAvailabilityMode.fromConfig(configuration); switch (highAvailabilityMode) { case NONE: final Tuple2<String, Integer> hostnamePort = getJobManagerAddress(configuration); final String resourceManagerRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, AkkaRpcServiceUtils.createWildcardName(ResourceManager.RESOURCE_MANAGER_NAME), addressResolution, configuration); final String dispatcherRpcUrl = AkkaRpcServiceUtils.getRpcUrl( hostnamePort.f0, hostnamePort.f1, AkkaRpcServiceUtils.createWildcardName(Dispatcher.DISPATCHER_NAME), addressResolution, configuration); final String webMonitorAddress = getWebMonitorAddress( configuration, addressResolution); return new StandaloneHaServices( resourceManagerRpcUrl, dispatcherRpcUrl, webMonitorAddress); case ZOOKEEPER: BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(configuration); return new ZooKeeperHaServices( ZooKeeperUtils.startCuratorFramework(configuration), executor, configuration, blobStoreService); case FACTORY_CLASS: return createCustomHAServices(configuration, executor); default: throw new Exception("Recovery mode " + highAvailabilityMode + " is not supported."); } }