final LeaderConnectionInfo connectionInfo = clusterClient.getClusterConnectionInfo(); System.out.println("Flink JobManager is now running on " + connectionInfo.getHostname() + ':' + connectionInfo.getPort() + " with leader id " + connectionInfo.getLeaderSessionID() + '.'); System.out.println("JobManager Web Interface: " + clusterClient.getWebInterfaceURL());
/** * Helper method to wait until the {@link Dispatcher} has set its fencing token. * * @param rpcService to use to connect to the dispatcher * @param haServices high availability services to connect to the dispatcher * @return {@link DispatcherGateway} * @throws Exception if something goes wrong */ static DispatcherGateway retrieveDispatcherGateway(RpcService rpcService, HighAvailabilityServices haServices) throws Exception { final LeaderConnectionInfo leaderConnectionInfo = LeaderRetrievalUtils.retrieveLeaderConnectionInfo(haServices.getDispatcherLeaderRetriever(), Time.seconds(10L)); return rpcService.connect( leaderConnectionInfo.getAddress(), DispatcherId.fromUuid(leaderConnectionInfo.getLeaderSessionID()), DispatcherGateway.class).get(); }
/** * Tests that the configuration is properly passed via the DefaultCLI to the * created ClusterDescriptor. */ @Test public void testConfigurationPassing() throws Exception { final Configuration configuration = getConfiguration(); final String localhost = "localhost"; final int port = 1234; configuration.setString(JobManagerOptions.ADDRESS, localhost); configuration.setInteger(JobManagerOptions.PORT, port); @SuppressWarnings("unchecked") final AbstractCustomCommandLine<StandaloneClusterId> defaultCLI = (AbstractCustomCommandLine<StandaloneClusterId>) getCli(configuration); final String[] args = {}; CommandLine commandLine = defaultCLI.parseCommandLineOptions(args, false); final ClusterDescriptor<StandaloneClusterId> clusterDescriptor = defaultCLI.createClusterDescriptor(commandLine); final ClusterClient<?> clusterClient = clusterDescriptor.retrieve(defaultCLI.getClusterId(commandLine)); final LeaderConnectionInfo clusterConnectionInfo = clusterClient.getClusterConnectionInfo(); assertThat(clusterConnectionInfo.getHostname(), Matchers.equalTo(localhost)); assertThat(clusterConnectionInfo.getPort(), Matchers.equalTo(port)); }
@Override public String getWebInterfaceURL() { final InetSocketAddress inetSocketAddressFromAkkaURL; try { inetSocketAddressFromAkkaURL = AkkaUtils.getInetSocketAddressFromAkkaURL(getClusterConnectionInfo().getAddress()); } catch (Exception e) { throw new RuntimeException("Could not retrieve leader retrieval information.", e); } String host = inetSocketAddressFromAkkaURL.getHostName(); int port = getFlinkConfiguration().getInteger(WebOptions.PORT); return "http://" + host + ":" + port; }
/** * Retrieves the current leader session id of the component identified by the given leader * retrieval service. * * @param leaderRetrievalService Leader retrieval service to be used for the leader retrieval * @param timeout Timeout for the leader retrieval * @return The leader session id of the retrieved leader * @throws LeaderRetrievalException if the leader retrieval operation fails (including a timeout) */ public static UUID retrieveLeaderSessionId( LeaderRetrievalService leaderRetrievalService, FiniteDuration timeout) throws LeaderRetrievalException { return retrieveLeaderConnectionInfo(leaderRetrievalService, timeout).getLeaderSessionID(); }
@Override public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID) { if(leaderAddress != null && !leaderAddress.equals("") && !connectionInfo.isCompleted()) { connectionInfo.success(new LeaderConnectionInfo(leaderAddress, leaderSessionID)); } }
@Override public String getWebInterfaceURL() { final InetSocketAddress inetSocketAddressFromAkkaURL; try { inetSocketAddressFromAkkaURL = AkkaUtils.getInetSocketAddressFromAkkaURL(getClusterConnectionInfo().getAddress()); } catch (Exception e) { throw new RuntimeException("Could not retrieve leader retrieval information.", e); } String host = inetSocketAddressFromAkkaURL.getHostName(); int port = getFlinkConfiguration().getInteger(WebOptions.PORT); return "http://" + host + ":" + port; }
/** * Retrieves the current leader session id of the component identified by the given leader * retrieval service. * * @param leaderRetrievalService Leader retrieval service to be used for the leader retrieval * @param timeout Timeout for the leader retrieval * @return The leader session id of the retrieved leader * @throws LeaderRetrievalException if the leader retrieval operation fails (including a timeout) */ public static UUID retrieveLeaderSessionId( LeaderRetrievalService leaderRetrievalService, FiniteDuration timeout) throws LeaderRetrievalException { return retrieveLeaderConnectionInfo(leaderRetrievalService, timeout).getLeaderSessionID(); }
/** * Tests that command line options override the configuration settings. */ @Test public void testManualConfigurationOverride() throws Exception { final String localhost = "localhost"; final int port = 1234; final Configuration configuration = getConfiguration(); configuration.setString(JobManagerOptions.ADDRESS, localhost); configuration.setInteger(JobManagerOptions.PORT, port); @SuppressWarnings("unchecked") final AbstractCustomCommandLine<StandaloneClusterId> defaultCLI = (AbstractCustomCommandLine<StandaloneClusterId>) getCli(configuration); final String manualHostname = "123.123.123.123"; final int manualPort = 4321; final String[] args = {"-m", manualHostname + ':' + manualPort}; CommandLine commandLine = defaultCLI.parseCommandLineOptions(args, false); final ClusterDescriptor<StandaloneClusterId> clusterDescriptor = defaultCLI.createClusterDescriptor(commandLine); final ClusterClient<?> clusterClient = clusterDescriptor.retrieve(defaultCLI.getClusterId(commandLine)); final LeaderConnectionInfo clusterConnectionInfo = clusterClient.getClusterConnectionInfo(); assertThat(clusterConnectionInfo.getHostname(), Matchers.equalTo(manualHostname)); assertThat(clusterConnectionInfo.getPort(), Matchers.equalTo(manualPort)); }
@Override public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID) { if (leaderAddress != null && !leaderAddress.equals("") && !connectionInfo.isCompleted()) { try { final LeaderConnectionInfo leaderConnectionInfo = new LeaderConnectionInfo(leaderAddress, leaderSessionID); connectionInfo.success(leaderConnectionInfo); } catch (FlinkException e) { connectionInfo.failure(e); } } }
final LeaderConnectionInfo connectionInfo = clusterClient.getClusterConnectionInfo(); System.out.println("Flink JobManager is now running on " + connectionInfo.getHostname() + ':' + connectionInfo.getPort() + " with leader id " + connectionInfo.getLeaderSessionID() + '.'); System.out.println("JobManager Web Interface: " + clusterClient.getWebInterfaceURL());
@Override public String getWebInterfaceURL() { final InetSocketAddress inetSocketAddressFromAkkaURL; try { inetSocketAddressFromAkkaURL = AkkaUtils.getInetSocketAddressFromAkkaURL(getClusterConnectionInfo().getAddress()); } catch (Exception e) { throw new RuntimeException("Could not retrieve leader retrieval information.", e); } String host = inetSocketAddressFromAkkaURL.getHostName(); int port = getFlinkConfiguration().getInteger(WebOptions.PORT); return "http://" + host + ":" + port; }
/** * Retrieves the current leader session id of the component identified by the given leader * retrieval service. * * @param leaderRetrievalService Leader retrieval service to be used for the leader retrieval * @param timeout Timeout for the leader retrieval * @return The leader session id of the retrieved leader * @throws LeaderRetrievalException if the leader retrieval operation fails (including a timeout) */ public static UUID retrieveLeaderSessionId( LeaderRetrievalService leaderRetrievalService, FiniteDuration timeout) throws LeaderRetrievalException { return retrieveLeaderConnectionInfo(leaderRetrievalService, timeout).getLeaderSessionID(); }
@Override public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID) { if (leaderAddress != null && !leaderAddress.equals("") && !connectionInfo.isCompleted()) { try { final LeaderConnectionInfo leaderConnectionInfo = new LeaderConnectionInfo(leaderAddress, leaderSessionID); connectionInfo.success(leaderConnectionInfo); } catch (FlinkException e) { connectionInfo.failure(e); } } }
final LeaderConnectionInfo connectionInfo = clusterClient.getClusterConnectionInfo(); System.out.println("Flink JobManager is now running on " + connectionInfo.getHostname() + ':' + connectionInfo.getPort() + " with leader id " + connectionInfo.getLeaderSessionID() + '.'); System.out.println("JobManager Web Interface: " + clusterClient.getWebInterfaceURL());
/** * Gets the current JobManager address (may change in case of a HA setup). * @return The address (host and port) of the leading JobManager */ public InetSocketAddress getJobManagerAddress() { try { LeaderConnectionInfo leaderConnectionInfo = LeaderRetrievalUtils.retrieveLeaderConnectionInfo( highAvailabilityServices.getJobManagerLeaderRetriever(HighAvailabilityServices.DEFAULT_JOB_ID), timeout); return AkkaUtils.getInetSockeAddressFromAkkaURL(leaderConnectionInfo.getAddress()); } catch (Exception e) { throw new RuntimeException("Failed to retrieve JobManager address", e); } }
/** * Retrieves the current leader session id of the component identified by the given leader * retrieval service. * * @param leaderRetrievalService Leader retrieval service to be used for the leader retrieval * @param timeout Timeout for the leader retrieval * @return The leader session id of the retrieved leader * @throws LeaderRetrievalException if the leader retrieval operation fails (including a timeout) */ public static UUID retrieveLeaderSessionId( LeaderRetrievalService leaderRetrievalService, FiniteDuration timeout) throws LeaderRetrievalException { return retrieveLeaderConnectionInfo(leaderRetrievalService, timeout).getLeaderSessionID(); }
@Override public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID) { if (leaderAddress != null && !leaderAddress.equals("") && !connectionInfo.isCompleted()) { try { final LeaderConnectionInfo leaderConnectionInfo = new LeaderConnectionInfo(leaderAddress, leaderSessionID); connectionInfo.success(leaderConnectionInfo); } catch (FlinkException e) { connectionInfo.failure(e); } } }
public static ClusterClient createStandaloneClient(LauncherOptions launcherOptions) throws Exception { String flinkConfDir = launcherOptions.getFlinkconf(); Configuration config = GlobalConfiguration.loadConfiguration(flinkConfDir); StandaloneClusterDescriptor standaloneClusterDescriptor = new StandaloneClusterDescriptor(config); RestClusterClient clusterClient = standaloneClusterDescriptor.retrieve(StandaloneClusterId.getInstance()); LeaderConnectionInfo connectionInfo = clusterClient.getClusterConnectionInfo(); InetSocketAddress address = AkkaUtils.getInetSocketAddressFromAkkaURL(connectionInfo.getAddress()); config.setString(JobManagerOptions.ADDRESS, address.getAddress().getHostName()); config.setInteger(JobManagerOptions.PORT, address.getPort()); clusterClient.setDetached(true); return clusterClient; }
public static ClusterClient createStandaloneClient(LauncherOptions launcherOptions) throws Exception { String flinkConfDir = launcherOptions.getFlinkconf(); Configuration config = GlobalConfiguration.loadConfiguration(flinkConfDir); StandaloneClusterDescriptor standaloneClusterDescriptor = new StandaloneClusterDescriptor(config); RestClusterClient clusterClient = standaloneClusterDescriptor.retrieve(StandaloneClusterId.getInstance()); LeaderConnectionInfo connectionInfo = clusterClient.getClusterConnectionInfo(); InetSocketAddress address = AkkaUtils.getInetSocketAddressFromAkkaURL(connectionInfo.getAddress()); config.setString(JobManagerOptions.ADDRESS, address.getAddress().getHostName()); config.setInteger(JobManagerOptions.PORT, address.getPort()); clusterClient.setDetached(true); return clusterClient; }