Java Code Examples for org.apache.flink.table.client.gateway.utils.EnvironmentFileUtil#parseModified()

The following examples show how to use org.apache.flink.table.client.gateway.utils.EnvironmentFileUtil#parseModified() . 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: DependencyTest.java    From flink with Apache License 2.0 6 votes vote down vote up
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 2
Source File: ExecutionContextTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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: ExecutionContextTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: DependencyTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: EnvironmentTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMerging() throws Exception {
	final Map<String, String> replaceVars1 = new HashMap<>();
	replaceVars1.put("$VAR_PLANNER", "old");
	replaceVars1.put("$VAR_EXECUTION_TYPE", "batch");
	replaceVars1.put("$VAR_RESULT_MODE", "table");
	replaceVars1.put("$VAR_UPDATE_MODE", "");
	replaceVars1.put("$VAR_MAX_ROWS", "100");
	replaceVars1.put("$VAR_RESTART_STRATEGY_TYPE", "failure-rate");
	final Environment env1 = EnvironmentFileUtil.parseModified(
		DEFAULTS_ENVIRONMENT_FILE,
		replaceVars1);

	final Map<String, String> replaceVars2 = new HashMap<>(replaceVars1);
	replaceVars2.put("TableNumber1", "NewTable");
	final Environment env2 = EnvironmentFileUtil.parseModified(
		FACTORY_ENVIRONMENT_FILE,
		replaceVars2);

	final Environment merged = Environment.merge(env1, env2);

	final Set<String> tables = new HashSet<>();
	tables.add("TableNumber1");
	tables.add("TableNumber2");
	tables.add("NewTable");
	tables.add("TableSourceSink");
	tables.add("TestView1");
	tables.add("TestView2");

	assertEquals(tables, merged.getTables().keySet());
	assertTrue(merged.getExecution().inStreamingMode());
	assertEquals(16, merged.getExecution().getMaxParallelism());

	final Map<String, String> configuration = new HashMap<>();
	configuration.put("table.optimizer.join-reorder-enabled", "true");

	assertEquals(configuration, merged.getConfiguration().asMap());
}
 
Example 6
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
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 7
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
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 8
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
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 9
Source File: EnvironmentTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMerging() throws Exception {
	final Map<String, String> replaceVars1 = new HashMap<>();
	replaceVars1.put("$VAR_PLANNER", "old");
	replaceVars1.put("$VAR_EXECUTION_TYPE", "batch");
	replaceVars1.put("$VAR_RESULT_MODE", "table");
	replaceVars1.put("$VAR_UPDATE_MODE", "");
	replaceVars1.put("$VAR_MAX_ROWS", "100");
	final Environment env1 = EnvironmentFileUtil.parseModified(
		DEFAULTS_ENVIRONMENT_FILE,
		replaceVars1);

	final Map<String, String> replaceVars2 = new HashMap<>(replaceVars1);
	replaceVars2.put("TableNumber1", "NewTable");
	final Environment env2 = EnvironmentFileUtil.parseModified(
		FACTORY_ENVIRONMENT_FILE,
		replaceVars2);

	final Environment merged = Environment.merge(env1, env2);

	final Set<String> tables = new HashSet<>();
	tables.add("TableNumber1");
	tables.add("TableNumber2");
	tables.add("NewTable");
	tables.add("TableSourceSink");
	tables.add("TestView1");
	tables.add("TestView2");

	assertEquals(tables, merged.getTables().keySet());
	assertTrue(merged.getExecution().inStreamingMode());
	assertEquals(16, merged.getExecution().getMaxParallelism());

	final Map<String, String> configuration = new HashMap<>();
	configuration.put("table.optimizer.join-reorder-enabled", "true");

	assertEquals(configuration, merged.getConfiguration().asMap());
}
 
Example 10
Source File: LocalExecutorITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private <T> LocalExecutor createDefaultExecutor(ClusterClient<T> clusterClient) throws Exception {
	final Map<String, String> replaceVars = new HashMap<>();
	replaceVars.put("$VAR_EXECUTION_TYPE", "batch");
	replaceVars.put("$VAR_UPDATE_MODE", "");
	replaceVars.put("$VAR_MAX_ROWS", "100");
	return new LocalExecutor(
		EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars),
		Collections.emptyList(),
		clusterClient.getFlinkConfiguration(),
		new DummyCustomCommandLine<T>(clusterClient));
}
 
Example 11
Source File: ExecutionContextTest.java    From flink with Apache License 2.0 5 votes vote down vote up
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 12
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private <T> LocalExecutor createModifiedExecutor(
		String yamlFile, ClusterClient<T> clusterClient, Map<String, String> replaceVars) throws Exception {
	return new LocalExecutor(
		EnvironmentFileUtil.parseModified(yamlFile, replaceVars),
		Collections.emptyList(),
		clusterClient.getFlinkConfiguration(),
		new DummyCustomCommandLine<T>(clusterClient));
}
 
Example 13
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private <T> LocalExecutor createModifiedExecutor(ClusterClient<T> clusterClient, Map<String, String> replaceVars) throws Exception {
	return new LocalExecutor(
		EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars),
		Collections.emptyList(),
		clusterClient.getFlinkConfiguration(),
		new DummyCustomCommandLine<T>(clusterClient));
}
 
Example 14
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
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");
	return new LocalExecutor(
		EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars),
		Collections.emptyList(),
		clusterClient.getFlinkConfiguration(),
		new DummyCustomCommandLine<T>(clusterClient));
}
 
Example 15
Source File: EnvironmentTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testMerging() throws Exception {
	final Map<String, String> replaceVars1 = new HashMap<>();
	replaceVars1.put("$VAR_EXECUTION_TYPE", "batch");
	replaceVars1.put("$VAR_RESULT_MODE", "table");
	replaceVars1.put("$VAR_UPDATE_MODE", "");
	replaceVars1.put("$VAR_MAX_ROWS", "100");
	final Environment env1 = EnvironmentFileUtil.parseModified(
		DEFAULTS_ENVIRONMENT_FILE,
		replaceVars1);

	final Map<String, String> replaceVars2 = new HashMap<>(replaceVars1);
	replaceVars2.put("TableNumber1", "NewTable");
	final Environment env2 = EnvironmentFileUtil.parseModified(
		FACTORY_ENVIRONMENT_FILE,
		replaceVars2);

	final Environment merged = Environment.merge(env1, env2);

	final Set<String> tables = new HashSet<>();
	tables.add("TableNumber1");
	tables.add("TableNumber2");
	tables.add("NewTable");
	tables.add("TableSourceSink");
	tables.add("TestView1");
	tables.add("TestView2");

	assertEquals(tables, merged.getTables().keySet());
	assertTrue(merged.getExecution().isStreamingExecution());
	assertEquals(16, merged.getExecution().getMaxParallelism());
}
 
Example 16
Source File: DependencyTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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 17
Source File: ExecutionContextTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 18
Source File: LocalExecutorITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private <T> LocalExecutor createModifiedExecutor(ClusterClient<T> clusterClient, Map<String, String> replaceVars) throws Exception {
	return new LocalExecutor(
		EnvironmentFileUtil.parseModified(DEFAULTS_ENVIRONMENT_FILE, replaceVars),
		Collections.emptyList(),
		clusterClient.getFlinkConfiguration(),
		new DummyCustomCommandLine<T>(clusterClient));
}