org.apache.flink.client.cli.DefaultCLI Java Examples
The following examples show how to use
org.apache.flink.client.cli.DefaultCLI.
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: ExecutionContextTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testInitCatalogs() throws Exception{ final Map<String, String> replaceVars = createDefaultReplaceVars(); Environment env = EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars); Map<String, Object> catalogProps = new HashMap<>(); catalogProps.put("name", "test"); catalogProps.put("type", "test_cl_catalog"); env.getCatalogs().clear(); env.getCatalogs().put("test", CatalogEntry.create(catalogProps)); Configuration flinkConfig = new Configuration(); ExecutionContext.builder(env, new SessionContext("test-session", new Environment()), Collections.emptyList(), flinkConfig, new DefaultClusterClientServiceLoader(), new Options(), Collections.singletonList(new DefaultCLI(flinkConfig))).build(); }
Example #2
Source File: ExecutionContextTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <T> ExecutionContext<T> createExecutionContext(String file, Map<String, String> replaceVars) throws Exception { final Environment env = EnvironmentFileUtil.parseModified( file, replaceVars); final Configuration flinkConfig = new Configuration(); return (ExecutionContext<T>) ExecutionContext.builder( env, new SessionContext("test-session", new Environment()), Collections.emptyList(), flinkConfig, new DefaultClusterClientServiceLoader(), new Options(), Collections.singletonList(new DefaultCLI(flinkConfig))) .build(); }
Example #3
Source File: DependencyTest.java From flink with Apache License 2.0 | 6 votes |
private LocalExecutor createExecutor() throws Exception { // create environment final Map<String, String> replaceVars = new HashMap<>(); replaceVars.put("$VAR_CONNECTOR_TYPE", CONNECTOR_TYPE_VALUE); replaceVars.put("$VAR_CONNECTOR_PROPERTY", TEST_PROPERTY); replaceVars.put("$VAR_CONNECTOR_PROPERTY_VALUE", "test-value"); final Environment env = EnvironmentFileUtil.parseModified(FACTORY_ENVIRONMENT_FILE, replaceVars); // create executor with dependencies final URL dependency = Paths.get("target", TABLE_FACTORY_JAR_FILE).toUri().toURL(); return new LocalExecutor( env, Collections.singletonList(dependency), new Configuration(), new DefaultCLI(new Configuration()), new DefaultClusterClientServiceLoader()); }
Example #4
Source File: ExecutionContextTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private <T> ExecutionContext<T> createExecutionContext(String file, Map<String, String> replaceVars) throws Exception { final Environment env = EnvironmentFileUtil.parseModified( file, replaceVars); final SessionContext session = new SessionContext("test-session", new Environment()); final Configuration flinkConfig = new Configuration(); return new ExecutionContext<>( env, session, Collections.emptyList(), flinkConfig, new Options(), Collections.singletonList(new DefaultCLI(flinkConfig))); }
Example #5
Source File: DependencyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testTableFactoryDiscovery() throws Exception { // create environment final Map<String, String> replaceVars = new HashMap<>(); replaceVars.put("$VAR_CONNECTOR_TYPE", CONNECTOR_TYPE_VALUE); replaceVars.put("$VAR_CONNECTOR_PROPERTY", TEST_PROPERTY); replaceVars.put("$VAR_CONNECTOR_PROPERTY_VALUE", "test-value"); final Environment env = EnvironmentFileUtil.parseModified(FACTORY_ENVIRONMENT_FILE, replaceVars); // create executor with dependencies final URL dependency = Paths.get("target", TABLE_FACTORY_JAR_FILE).toUri().toURL(); final LocalExecutor executor = new LocalExecutor( env, Collections.singletonList(dependency), new Configuration(), new DefaultCLI(new Configuration())); final SessionContext session = new SessionContext("test-session", new Environment()); final TableSchema result = executor.getTableSchema(session, "TableNumber1"); final TableSchema expected = TableSchema.builder() .field("IntegerField1", Types.INT()) .field("StringField1", Types.STRING()) .field("rowtimeField", Types.SQL_TIMESTAMP()) .build(); assertEquals(expected, result); }
Example #6
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that command line options override the configuration settings. */ @Test public void testRESTManualConfigurationOverride() throws Exception { final String configuredHostname = "localhost"; final int configuredPort = 1234; final Configuration configuration = new Configuration(); configuration.setString(JobManagerOptions.ADDRESS, configuredHostname); configuration.setInteger(JobManagerOptions.PORT, configuredPort); configuration.setString(RestOptions.ADDRESS, configuredHostname); configuration.setInteger(RestOptions.PORT, configuredPort); final DefaultCLI defaultCLI = new DefaultCLI(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 StandaloneClusterDescriptor clusterDescriptor = defaultCLI.createClusterDescriptor(commandLine); final RestClusterClient<?> clusterClient = clusterDescriptor.retrieve(defaultCLI.getClusterId(commandLine)); URL webMonitorBaseUrl = clusterClient.getWebMonitorBaseUrl().get(); assertThat(webMonitorBaseUrl.getHost(), equalTo(manualHostname)); assertThat(webMonitorBaseUrl.getPort(), equalTo(manualPort)); }
Example #7
Source File: CatalogITest.java From pulsar-flink with Apache License 2.0 | 5 votes |
private <T> ExecutionContext<T> createExecutionContext(String file, Map<String, String> replaceVars) throws Exception { final Environment env = EnvironmentFileUtil.parseModified( file, replaceVars); final Configuration flinkConfig = new Configuration(); return new ExecutionContext<>( env, new SessionContext("test-session", new Environment()), Collections.emptyList(), flinkConfig, new Options(), Collections.singletonList(new DefaultCLI(flinkConfig))); }
Example #8
Source File: ExecutionContextTest.java From flink with Apache License 2.0 | 5 votes |
private <T> ExecutionContext<T> createExecutionContext(String file, Map<String, String> replaceVars) throws Exception { final Environment env = EnvironmentFileUtil.parseModified( file, replaceVars); final SessionContext session = new SessionContext("test-session", new Environment()); final Configuration flinkConfig = new Configuration(); return new ExecutionContext<>( env, session, Collections.emptyList(), flinkConfig, new Options(), Collections.singletonList(new DefaultCLI(flinkConfig))); }
Example #9
Source File: DependencyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testTableFactoryDiscovery() throws Exception { // create environment final Map<String, String> replaceVars = new HashMap<>(); replaceVars.put("$VAR_CONNECTOR_TYPE", CONNECTOR_TYPE_VALUE); replaceVars.put("$VAR_CONNECTOR_PROPERTY", TEST_PROPERTY); replaceVars.put("$VAR_CONNECTOR_PROPERTY_VALUE", "test-value"); final Environment env = EnvironmentFileUtil.parseModified(FACTORY_ENVIRONMENT_FILE, replaceVars); // create executor with dependencies final URL dependency = Paths.get("target", TABLE_FACTORY_JAR_FILE).toUri().toURL(); final LocalExecutor executor = new LocalExecutor( env, Collections.singletonList(dependency), new Configuration(), new DefaultCLI(new Configuration())); final SessionContext session = new SessionContext("test-session", new Environment()); final TableSchema result = executor.getTableSchema(session, "TableNumber1"); final TableSchema expected = TableSchema.builder() .field("IntegerField1", Types.INT()) .field("StringField1", Types.STRING()) .field("rowtimeField", Types.SQL_TIMESTAMP()) .build(); assertEquals(expected, result); }
Example #10
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that command line options override the configuration settings. */ @Test public void testRESTManualConfigurationOverride() throws Exception { final String configuredHostname = "localhost"; final int configuredPort = 1234; final Configuration configuration = new Configuration(); configuration.setString(JobManagerOptions.ADDRESS, configuredHostname); configuration.setInteger(JobManagerOptions.PORT, configuredPort); configuration.setString(RestOptions.ADDRESS, configuredHostname); configuration.setInteger(RestOptions.PORT, configuredPort); final DefaultCLI defaultCLI = new DefaultCLI(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 StandaloneClusterDescriptor clusterDescriptor = defaultCLI.createClusterDescriptor(commandLine); final RestClusterClient<?> clusterClient = clusterDescriptor.retrieve(defaultCLI.getClusterId(commandLine)); URL webMonitorBaseUrl = clusterClient.getWebMonitorBaseUrl().get(); assertThat(webMonitorBaseUrl.getHost(), equalTo(manualHostname)); assertThat(webMonitorBaseUrl.getPort(), equalTo(manualPort)); }
Example #11
Source File: LocalExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
private <T> LocalExecutor createDefaultExecutor(ClusterClient<T> clusterClient) throws Exception { final Map<String, String> replaceVars = new HashMap<>(); replaceVars.put("$VAR_PLANNER", planner); replaceVars.put("$VAR_EXECUTION_TYPE", "batch"); replaceVars.put("$VAR_UPDATE_MODE", ""); replaceVars.put("$VAR_MAX_ROWS", "100"); replaceVars.put("$VAR_RESTART_STRATEGY_TYPE", "failure-rate"); return new LocalExecutor( EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars), Collections.emptyList(), clusterClient.getFlinkConfiguration(), new DefaultCLI(clusterClient.getFlinkConfiguration()), new DefaultClusterClientServiceLoader()); }
Example #12
Source File: LocalExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
private <T> LocalExecutor createModifiedExecutor(ClusterClient<T> clusterClient, Map<String, String> replaceVars) throws Exception { replaceVars.putIfAbsent("$VAR_RESTART_STRATEGY_TYPE", "failure-rate"); return new LocalExecutor( EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars), Collections.singletonList(udfDependency), clusterClient.getFlinkConfiguration(), new DefaultCLI(clusterClient.getFlinkConfiguration()), new DefaultClusterClientServiceLoader()); }
Example #13
Source File: LocalExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
private <T> LocalExecutor createModifiedExecutor( String yamlFile, ClusterClient<T> clusterClient, Map<String, String> replaceVars) throws Exception { replaceVars.putIfAbsent("$VAR_RESTART_STRATEGY_TYPE", "failure-rate"); return new LocalExecutor( EnvironmentFileUtil.parseModified(yamlFile, replaceVars), Collections.emptyList(), clusterClient.getFlinkConfiguration(), new DefaultCLI(clusterClient.getFlinkConfiguration()), new DefaultClusterClientServiceLoader()); }
Example #14
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that command line options override the configuration settings. */ @Test public void testRESTManualConfigurationOverride() throws Exception { final String configuredHostname = "localhost"; final int configuredPort = 1234; final Configuration configuration = new Configuration(); configuration.setString(JobManagerOptions.ADDRESS, configuredHostname); configuration.setInteger(JobManagerOptions.PORT, configuredPort); configuration.setString(RestOptions.ADDRESS, configuredHostname); configuration.setInteger(RestOptions.PORT, configuredPort); final DefaultCLI defaultCLI = new DefaultCLI(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 ClusterClientServiceLoader serviceLoader = new DefaultClusterClientServiceLoader(); final Configuration executorConfig = defaultCLI.applyCommandLineOptionsToConfiguration(commandLine); final ClusterClientFactory<StandaloneClusterId> clusterFactory = serviceLoader.getClusterClientFactory(executorConfig); checkState(clusterFactory != null); final ClusterDescriptor<StandaloneClusterId> clusterDescriptor = clusterFactory.createClusterDescriptor(executorConfig); final RestClusterClient<?> clusterClient = (RestClusterClient<?>) clusterDescriptor .retrieve(clusterFactory.getClusterId(executorConfig)) .getClusterClient(); URL webMonitorBaseUrl = clusterClient.getWebMonitorBaseUrl().get(); assertThat(webMonitorBaseUrl.getHost(), equalTo(manualHostname)); assertThat(webMonitorBaseUrl.getPort(), equalTo(manualPort)); }