use of org.apache.flink.client.cli.DefaultCLI in project flink by apache.
the class RestClusterClientTest method testRESTManualConfigurationOverride.
/**
* 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();
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.toConfiguration(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));
}
use of org.apache.flink.client.cli.DefaultCLI in project flink by apache.
the class SessionContextTest method createSessionContext.
// --------------------------------------------------------------------------------------------
private SessionContext createSessionContext() {
Configuration flinkConfig = new Configuration();
flinkConfig.set(OBJECT_REUSE, true);
flinkConfig.set(MAX_PARALLELISM, 16);
DefaultContext defaultContext = new DefaultContext(Collections.emptyList(), flinkConfig, Collections.singletonList(new DefaultCLI()));
return SessionContext.create(defaultContext, "test-session");
}
use of org.apache.flink.client.cli.DefaultCLI in project flink by apache.
the class DependencyTest method createLocalExecutor.
private LocalExecutor createLocalExecutor() throws Exception {
// create executor with dependencies
final URL dependency = Paths.get("target", TABLE_FACTORY_JAR_FILE).toUri().toURL();
// create default context
DefaultContext defaultContext = new DefaultContext(Collections.singletonList(dependency), new Configuration(), Collections.singletonList(new DefaultCLI()));
LocalExecutor executor = new LocalExecutor(defaultContext);
executor.openSession(SESSION_ID);
for (String line : INIT_SQL) {
executor.executeOperation(SESSION_ID, executor.parseStatement(SESSION_ID, line));
}
return executor;
}
use of org.apache.flink.client.cli.DefaultCLI in project flink by apache.
the class CliClientITCase method runSqlStatements.
/**
* Returns printed results for each ran SQL statements.
*
* @param statements the SQL statements to run
* @return the printed results on SQL Client
*/
private List<Result> runSqlStatements(List<String> statements) throws IOException {
final String sqlContent = String.join("", statements);
DefaultContext defaultContext = new DefaultContext(Collections.emptyList(), new Configuration(MINI_CLUSTER_RESOURCE.getClientConfiguration()).set(ExecutionConfigOptions.TABLE_EXEC_LEGACY_CAST_BEHAVIOUR, ExecutionConfigOptions.LegacyCastBehaviour.DISABLED), Collections.singletonList(new DefaultCLI()));
final Executor executor = new LocalExecutor(defaultContext);
InputStream inputStream = new ByteArrayInputStream(sqlContent.getBytes());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
String sessionId = executor.openSession("test-session");
try (Terminal terminal = new DumbTerminal(inputStream, outputStream);
CliClient client = new CliClient(() -> terminal, sessionId, executor, historyPath, HideSqlStatement.INSTANCE)) {
client.executeInInteractiveMode();
String output = new String(outputStream.toByteArray());
return normalizeOutput(output);
}
}
use of org.apache.flink.client.cli.DefaultCLI in project flink by apache.
the class LocalExecutorITCase method createLocalExecutor.
private LocalExecutor createLocalExecutor(List<URL> dependencies, Configuration configuration) {
configuration.addAll(clusterClient.getFlinkConfiguration());
DefaultContext defaultContext = new DefaultContext(dependencies, configuration, Collections.singletonList(new DefaultCLI()));
return new LocalExecutor(defaultContext);
}
Aggregations