当前位置: 首页>>代码示例>>Java>>正文


Java FlinkYarnSessionCli类代码示例

本文整理汇总了Java中org.apache.flink.yarn.cli.FlinkYarnSessionCli的典型用法代码示例。如果您正苦于以下问题:Java FlinkYarnSessionCli类的具体用法?Java FlinkYarnSessionCli怎么用?Java FlinkYarnSessionCli使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FlinkYarnSessionCli类属于org.apache.flink.yarn.cli包,在下文中一共展示了FlinkYarnSessionCli类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNotEnoughTaskSlots

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testNotEnoughTaskSlots() throws Exception {
	String[] params =
		new String[] {"-yn", "2", "-ys", "3", "-p", "7"};

	FlinkYarnSessionCli yarnCLI = new FlinkYarnSessionCli(
		new Configuration(),
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	Options options = new Options();
	// TODO: Nasty workaround: We should get rid of the YarnCLI and run options coupling
	options.addOption(CliFrontendParser.PARALLELISM_OPTION);
	yarnCLI.addGeneralOptions(options);
	yarnCLI.addRunOptions(options);

	final CommandLine commandLine = CliFrontendParser.parse(options, params, true);

	ClusterSpecification clusterSpecification = yarnCLI.getClusterSpecification(commandLine);

	// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
	assertEquals(4, clusterSpecification.getSlotsPerTaskManager());
	assertEquals(2, clusterSpecification.getNumberTaskManagers());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:FlinkYarnSessionCliTest.java

示例2: testCorrectSettingOfMaxSlots

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testCorrectSettingOfMaxSlots() throws Exception {
	String[] params =
		new String[] {"-yn", "2", "-ys", "3"};

	FlinkYarnSessionCli yarnCLI = new FlinkYarnSessionCli(
		new Configuration(),
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	final CommandLine commandLine = yarnCLI.parseCommandLineOptions(params, true);

	AbstractYarnClusterDescriptor descriptor = yarnCLI.createClusterDescriptor(commandLine);

	final ClusterSpecification clusterSpecification = yarnCLI.getClusterSpecification(commandLine);

	// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
	assertEquals(3, clusterSpecification.getSlotsPerTaskManager());
	assertEquals(2, clusterSpecification.getNumberTaskManagers());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:FlinkYarnSessionCliTest.java

示例3: testZookeeperNamespaceProperty

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testZookeeperNamespaceProperty() throws Exception {
	String zkNamespaceCliInput = "flink_test_namespace";

	String[] params = new String[] {"-yn", "2", "-yz", zkNamespaceCliInput};

	FlinkYarnSessionCli yarnCLI = new FlinkYarnSessionCli(
		new Configuration(),
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	CommandLine commandLine = yarnCLI.parseCommandLineOptions(params, true);

	AbstractYarnClusterDescriptor descriptor = yarnCLI.createClusterDescriptor(commandLine);

	assertEquals(zkNamespaceCliInput, descriptor.getZookeeperNamespace());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:FlinkYarnSessionCliTest.java

示例4: testResumeFromYarnPropertiesFile

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
/**
 * Test that the CliFrontend is able to pick up the .yarn-properties file from a specified location.
 */
@Test
public void testResumeFromYarnPropertiesFile() throws Exception {

	File directoryPath = writeYarnPropertiesFile(validPropertiesFile);

	final Configuration configuration = new Configuration();
	configuration.setString(YarnConfigOptions.PROPERTIES_FILE_LOCATION, directoryPath.getAbsolutePath());

	final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {}, true);

	final ApplicationId clusterId = flinkYarnSessionCli.getClusterId(commandLine);

	assertEquals(TEST_YARN_APPLICATION_ID, clusterId);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:FlinkYarnSessionCliTest.java

示例5: testResumeFromYarnIDZookeeperNamespace

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testResumeFromYarnIDZookeeperNamespace() throws Exception {
	final Configuration configuration = new Configuration();
	final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID.toString()}, true);

	final AbstractYarnClusterDescriptor clusterDescriptor = flinkYarnSessionCli.createClusterDescriptor(commandLine);

	final Configuration clusterDescriptorConfiguration = clusterDescriptor.getFlinkConfiguration();

	String zkNs = clusterDescriptorConfiguration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
	assertTrue(zkNs.matches("application_\\d+_0042"));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:FlinkYarnSessionCliTest.java

示例6: testResumeFromYarnIDZookeeperNamespaceOverride

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testResumeFromYarnIDZookeeperNamespaceOverride() throws Exception {
	final Configuration configuration = new Configuration();
	final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	final String overrideZkNamespace = "my_cluster";

	final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID.toString(), "-yz", overrideZkNamespace}, true);

	final AbstractYarnClusterDescriptor clusterDescriptor = flinkYarnSessionCli.createClusterDescriptor(commandLine);

	final Configuration clusterDescriptorConfiguration = clusterDescriptor.getFlinkConfiguration();

	final String clusterId = clusterDescriptorConfiguration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
	assertEquals(overrideZkNamespace, clusterId);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:FlinkYarnSessionCliTest.java

示例7: testYarnIDOverridesPropertiesFile

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testYarnIDOverridesPropertiesFile() throws Exception {
	File directoryPath = writeYarnPropertiesFile(validPropertiesFile);

	final Configuration configuration = new Configuration();
	configuration.setString(YarnConfigOptions.PROPERTIES_FILE_LOCATION, directoryPath.getAbsolutePath());

	final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");
	final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID_2.toString() }, true);
	final ApplicationId clusterId = flinkYarnSessionCli.getClusterId(commandLine);
	assertEquals(TEST_YARN_APPLICATION_ID_2, clusterId);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:FlinkYarnSessionCliTest.java

示例8: testNotEnoughTaskSlots

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testNotEnoughTaskSlots() throws Exception {
	File jarFile = tmp.newFile("test.jar");

	String[] params =
		new String[] {"-yn", "2", "-ys", "3", "-p", "7", jarFile.getAbsolutePath()};

	RunOptions runOptions = CliFrontendParser.parseRunCommand(params);

	FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");

	ClusterSpecification clusterSpecification = yarnCLI.createClusterSpecification(new Configuration(), runOptions.getCommandLine());

	// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
	Assert.assertEquals(4, clusterSpecification.getSlotsPerTaskManager());
	Assert.assertEquals(2, clusterSpecification.getNumberTaskManagers());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:FlinkYarnSessionCliTest.java

示例9: testZookeeperNamespaceProperty

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testZookeeperNamespaceProperty() throws Exception {

	File confFile = tmp.newFile("flink-conf.yaml");
	File jarFile = tmp.newFile("test.jar");
	CliFrontend cliFrontend = new CliFrontend(tmp.getRoot().getAbsolutePath());
	final Configuration configuration = cliFrontend.getConfiguration();

	String zkNamespaceCliInput = "flink_test_namespace";

	String[] params =
			new String[] {"-yn", "2", "-yz", zkNamespaceCliInput, jarFile.getAbsolutePath()};

	RunOptions runOptions = CliFrontendParser.parseRunCommand(params);

	FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");
	AbstractYarnClusterDescriptor descriptor = yarnCLI.createDescriptor(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"",
		runOptions.getCommandLine());

	Assert.assertEquals(zkNamespaceCliInput, descriptor.getZookeeperNamespace());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:FlinkYarnSessionCliTest.java

示例10: testDynamicProperties

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testDynamicProperties() throws Exception {

	FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
		new Configuration(),
		tmp.getRoot().getAbsolutePath(),
		"",
		"",
		false);
	Options options = new Options();
	cli.addGeneralOptions(options);
	cli.addRunOptions(options);

	CommandLineParser parser = new DefaultParser();
	CommandLine cmd = parser.parse(options, new String[]{"run", "-j", "fake.jar", "-n", "15",
			"-D", "akka.ask.timeout=5 min", "-D", "env.java.opts=-DappName=foobar"});

	AbstractYarnClusterDescriptor flinkYarnDescriptor = cli.createClusterDescriptor(cmd);

	Assert.assertNotNull(flinkYarnDescriptor);

	Map<String, String> dynProperties =
		FlinkYarnSessionCli.getDynamicProperties(flinkYarnDescriptor.getDynamicPropertiesEncoded());
	assertEquals(2, dynProperties.size());
	assertEquals("5 min", dynProperties.get("akka.ask.timeout"));
	assertEquals("-DappName=foobar", dynProperties.get("env.java.opts"));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:FlinkYarnSessionCliTest.java

示例11: testInvalidYarnPropertiesFile

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
/**
 * Tests that we fail when reading an invalid yarn properties file when retrieving
 * the cluster id.
 */
@Test(expected = FlinkException.class)
public void testInvalidYarnPropertiesFile() throws Exception {

	File directoryPath = writeYarnPropertiesFile(invalidPropertiesFile);

	final Configuration configuration = new Configuration();
	configuration.setString(YarnConfigOptions.PROPERTIES_FILE_LOCATION, directoryPath.getAbsolutePath());

	new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:FlinkYarnSessionCliTest.java

示例12: testResumeFromYarnID

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testResumeFromYarnID() throws Exception {
	final Configuration configuration = new Configuration();
	final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"y",
		"yarn");

	final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(new String[] {"-yid", TEST_YARN_APPLICATION_ID.toString()}, true);

	final ApplicationId clusterId = flinkYarnSessionCli.getClusterId(commandLine);

	assertEquals(TEST_YARN_APPLICATION_ID, clusterId);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:FlinkYarnSessionCliTest.java

示例13: run

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Override
public void run() {
	try {
		int returnValue;
		switch (type) {
			case YARN_SESSION:
				yCli = new FlinkYarnSessionCli(
					configuration,
					configurationDirectory,
					"",
					"",
					true);
				returnValue = yCli.run(args);
				break;
			case CLI_FRONTEND:
				try {
					CliFrontend cli = new CliFrontend(
						configuration,
						CliFrontend.loadCustomCommandLines(configuration, configurationDirectory));
					returnValue = cli.parseParameters(args);
				} catch (Exception e) {
					throw new RuntimeException("Failed to execute the following args with CliFrontend: "
						+ Arrays.toString(args), e);
				}
				break;
			default:
				throw new RuntimeException("Unknown type " + type);
		}

		if (returnValue != this.expectedReturnValue) {
			Assert.fail("The YARN session returned with unexpected value=" + returnValue + " expected=" + expectedReturnValue);
		}
	} catch (Throwable t) {
		LOG.info("Runner stopped with exception", t);
		// save error.
		this.runnerError = t;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:39,代码来源:YarnTestBase.java

示例14: testDynamicProperties

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testDynamicProperties() throws Exception {

	FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
		"",
		"",
		false);
	Options options = new Options();
	cli.addGeneralOptions(options);
	cli.addRunOptions(options);

	CommandLineParser parser = new DefaultParser();
	CommandLine cmd = parser.parse(options, new String[]{"run", "-j", "fake.jar", "-n", "15",
			"-D", "akka.ask.timeout=5 min", "-D", "env.java.opts=-DappName=foobar"});

	AbstractYarnClusterDescriptor flinkYarnDescriptor = cli.createDescriptor(
		new Configuration(),
		tmp.getRoot().getAbsolutePath(),
		null,
		cmd);

	Assert.assertNotNull(flinkYarnDescriptor);

	Map<String, String> dynProperties =
		FlinkYarnSessionCli.getDynamicProperties(flinkYarnDescriptor.getDynamicPropertiesEncoded());
	Assert.assertEquals(2, dynProperties.size());
	Assert.assertEquals("5 min", dynProperties.get("akka.ask.timeout"));
	Assert.assertEquals("-DappName=foobar", dynProperties.get("env.java.opts"));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:30,代码来源:FlinkYarnSessionCliTest.java

示例15: testCorrectSettingOfMaxSlots

import org.apache.flink.yarn.cli.FlinkYarnSessionCli; //导入依赖的package包/类
@Test
public void testCorrectSettingOfMaxSlots() throws Exception {

	File confFile = tmp.newFile("flink-conf.yaml");
	File jarFile = tmp.newFile("test.jar");
	CliFrontend cliFrontend = new CliFrontend(tmp.getRoot().getAbsolutePath());

	final Configuration config = cliFrontend.getConfiguration();

	String[] params =
		new String[] {"-yn", "2", "-ys", "3", jarFile.getAbsolutePath()};

	RunOptions runOptions = CliFrontendParser.parseRunCommand(params);

	FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");

	final Configuration configuration = new Configuration();

	AbstractYarnClusterDescriptor descriptor = yarnCLI.createDescriptor(
		configuration,
		tmp.getRoot().getAbsolutePath(),
		"",
		runOptions.getCommandLine());

	final ClusterSpecification clusterSpecification = yarnCLI.createClusterSpecification(
		configuration,
		runOptions.getCommandLine());

	// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
	Assert.assertEquals(3, clusterSpecification.getSlotsPerTaskManager());
	Assert.assertEquals(2, clusterSpecification.getNumberTaskManagers());

	CliFrontend.setJobManagerAddressInConfig(config, new InetSocketAddress("localhost", 9000));
	ClusterClient client = new TestingYarnClusterClient(
		descriptor,
		clusterSpecification.getNumberTaskManagers(),
		clusterSpecification.getSlotsPerTaskManager(),
		config);
	Assert.assertEquals(6, client.getMaxSlots());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:41,代码来源:FlinkYarnSessionCliTest.java


注:本文中的org.apache.flink.yarn.cli.FlinkYarnSessionCli类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。