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


Java TestStreamEnvironment.setAsContext方法代码示例

本文整理汇总了Java中org.apache.flink.streaming.util.TestStreamEnvironment.setAsContext方法的典型用法代码示例。如果您正苦于以下问题:Java TestStreamEnvironment.setAsContext方法的具体用法?Java TestStreamEnvironment.setAsContext怎么用?Java TestStreamEnvironment.setAsContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.streaming.util.TestStreamEnvironment的用法示例。


在下文中一共展示了TestStreamEnvironment.setAsContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCheckpointedStreamingClassloaderJobWithCustomClassLoader

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Test
public void testCheckpointedStreamingClassloaderJobWithCustomClassLoader() throws IOException, ProgramInvocationException {
	// checkpointed streaming job with custom classes for the checkpoint (FLINK-2543)
	// the test also ensures that user specific exceptions are serializable between JobManager <--> JobClient.
	PackagedProgram streamingCheckpointedProg = new PackagedProgram(new File(STREAMING_CHECKPOINTED_PROG_JAR_FILE));

	TestStreamEnvironment.setAsContext(
		testCluster,
		parallelism,
		Collections.singleton(new Path(STREAMING_CHECKPOINTED_PROG_JAR_FILE)),
		Collections.<URL>emptyList());

	// Program should terminate with a 'SuccessException':
	// we can not access the SuccessException here when executing the tests with maven, because its not available in the jar.
	expectedException.expectCause(
		Matchers.<Throwable>hasProperty("cause",
			hasProperty("class",
				hasProperty("canonicalName", equalTo(
					"org.apache.flink.test.classloading.jar.CheckpointedStreamingProgram.SuccessException")))));

	streamingCheckpointedProg.invokeInteractiveModeForExecution();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:ClassLoaderITCase.java

示例2: testCheckpointingCustomKvStateJobWithCustomClassLoader

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Test
public void testCheckpointingCustomKvStateJobWithCustomClassLoader() throws IOException, ProgramInvocationException {
	File checkpointDir = FOLDER.newFolder();
	File outputDir = FOLDER.newFolder();

	final PackagedProgram program = new PackagedProgram(
		new File(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH),
		new String[] {
			checkpointDir.toURI().toString(),
			outputDir.toURI().toString()
		});

	TestStreamEnvironment.setAsContext(
		testCluster,
		parallelism,
		Collections.singleton(new Path(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)),
		Collections.<URL>emptyList());

	expectedException.expectCause(
		Matchers.<Throwable>hasProperty("cause", isA(SuccessException.class)));

	program.invokeInteractiveModeForExecution();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:ClassLoaderITCase.java

示例3: prepare

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
public static void prepare(boolean hideKafkaBehindProxy) throws ClassNotFoundException {
	LOG.info("-------------------------------------------------------------------------");
	LOG.info("    Starting KafkaTestBase ");
	LOG.info("-------------------------------------------------------------------------");

	startClusters(false, hideKafkaBehindProxy);

	TestStreamEnvironment.setAsContext(flink, PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:KafkaTestBase.java

示例4: prepare

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@BeforeClass
public static void prepare() throws IOException, ClassNotFoundException {
	LOG.info("-------------------------------------------------------------------------");
	LOG.info("    Starting KafkaShortRetentionTestBase ");
	LOG.info("-------------------------------------------------------------------------");

	Configuration flinkConfig = new Configuration();

	// dynamically load the implementation for the test
	Class<?> clazz = Class.forName("org.apache.flink.streaming.connectors.kafka.KafkaTestEnvironmentImpl");
	kafkaServer = (KafkaTestEnvironment) InstantiationUtil.instantiate(clazz);

	LOG.info("Starting KafkaTestBase.prepare() for Kafka " + kafkaServer.getVersion());

	if (kafkaServer.isSecureRunSupported()) {
		secureProps = kafkaServer.getSecureProperties();
	}

	Properties specificProperties = new Properties();
	specificProperties.setProperty("log.retention.hours", "0");
	specificProperties.setProperty("log.retention.minutes", "0");
	specificProperties.setProperty("log.retention.ms", "250");
	specificProperties.setProperty("log.retention.check.interval.ms", "100");
	kafkaServer.prepare(kafkaServer.createConfig().setKafkaServerProperties(specificProperties));

	standardProps = kafkaServer.getStandardProperties();

	// start also a re-usable Flink mini cluster
	flinkConfig.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TMS);
	flinkConfig.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, TM_SLOTS);
	flinkConfig.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 16L);
	flinkConfig.setString(ConfigConstants.RESTART_STRATEGY_FIXED_DELAY_DELAY, "0 s");

	flink = new LocalFlinkMiniCluster(flinkConfig, false);
	flink.start();

	TestStreamEnvironment.setAsContext(flink, PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:39,代码来源:KafkaShortRetentionTestBase.java

示例5: before

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Override
public void before() throws Exception {

	jobExecutorService = startJobExecutorService(miniClusterType);

	numberSlots = miniClusterResourceConfiguration.getNumberSlotsPerTaskManager() * miniClusterResourceConfiguration.getNumberTaskManagers();

	executionEnvironment = new TestEnvironment(jobExecutorService, numberSlots, false);
	executionEnvironment.setAsContext();
	TestStreamEnvironment.setAsContext(jobExecutorService, numberSlots);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:MiniClusterResource.java

示例6: testStreamingCustomSplitJobWithCustomClassLoader

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Test
public void testStreamingCustomSplitJobWithCustomClassLoader() throws IOException, ProgramInvocationException {
	PackagedProgram streamingInputSplitTestProg = new PackagedProgram(new File(STREAMING_INPUT_SPLITS_PROG_JAR_FILE));

	TestStreamEnvironment.setAsContext(
		testCluster,
		parallelism,
		Collections.singleton(new Path(STREAMING_INPUT_SPLITS_PROG_JAR_FILE)),
		Collections.<URL>emptyList());

	streamingInputSplitTestProg.invokeInteractiveModeForExecution();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:ClassLoaderITCase.java

示例7: testStreamingClassloaderJobWithCustomClassLoader

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Test
public void testStreamingClassloaderJobWithCustomClassLoader() throws IOException, ProgramInvocationException {
	// regular streaming job
	PackagedProgram streamingProg = new PackagedProgram(new File(STREAMING_PROG_JAR_FILE));

	TestStreamEnvironment.setAsContext(
		testCluster,
		parallelism,
		Collections.singleton(new Path(STREAMING_PROG_JAR_FILE)),
		Collections.<URL>emptyList());

	streamingProg.invokeInteractiveModeForExecution();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:ClassLoaderITCase.java

示例8: testCollect

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Test
public void testCollect() throws Exception {
	final LocalFlinkMiniCluster cluster = new LocalFlinkMiniCluster(new Configuration(), false);
	try {
		cluster.start();

		TestStreamEnvironment.setAsContext(cluster, 1);

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		final long n = 10;
		DataStream<Long> stream = env.generateSequence(1, n);

		long i = 1;
		for (Iterator<Long> it = DataStreamUtils.collect(stream); it.hasNext(); ) {
			long x = it.next();
			assertEquals("received wrong element", i, x);
			i++;
		}

		assertEquals("received wrong number of elements", n + 1, i);
	}
	finally {
		TestStreamEnvironment.unsetAsContext();
		cluster.stop();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:CollectITCase.java

示例9: setup

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
	// make sure we do not use a singleActorSystem for the tests
	// (therefore, we cannot simply inherit from StreamingMultipleProgramsTestBase)
	LOG.info("Starting FlinkMiniCluster");
	cluster = TestBaseUtils.startCluster(1, DEFAULT_PARALLELISM, false, false, false);
	TestStreamEnvironment.setAsContext(cluster, DEFAULT_PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:BigUserProgramJobSubmitITCase.java

示例10: startCluster

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@BeforeClass
public static void startCluster() {
	Configuration config = new Configuration();
	config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TASK_MANAGERS);
	config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_TASK_SLOTS);
	config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 12L);

	cluster = new LocalFlinkMiniCluster(config, false);

	cluster.start();

	TestStreamEnvironment.setAsContext(cluster, PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:TimestampITCase.java

示例11: startSecureFlinkClusterWithRecoveryModeEnabled

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
private static void startSecureFlinkClusterWithRecoveryModeEnabled() {
	try {
		LOG.info("Starting Flink and ZK in secure mode");

		dfs.mkdirs(new Path("/flink/checkpoints"));
		dfs.mkdirs(new Path("/flink/recovery"));

		org.apache.flink.configuration.Configuration config = new org.apache.flink.configuration.Configuration();

		config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 1);
		config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, DEFAULT_PARALLELISM);
		config.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, false);
		config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, 3);
		config.setString(HighAvailabilityOptions.HA_MODE, "zookeeper");
		config.setString(ConfigConstants.STATE_BACKEND, "filesystem");
		config.setString(ConfigConstants.ZOOKEEPER_CHECKPOINTS_PATH, hdfsURI + "/flink/checkpoints");
		config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, hdfsURI + "/flink/recovery");
		config.setString("state.backend.fs.checkpointdir", hdfsURI + "/flink/checkpoints");

		SecureTestEnvironment.populateFlinkSecureConfigurations(config);

		cluster = TestBaseUtils.startCluster(config, false);
		TestStreamEnvironment.setAsContext(cluster, DEFAULT_PARALLELISM);

	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:29,代码来源:RollingSinkSecuredITCase.java

示例12: initializeExecutionEnvironment

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入方法依赖的package包/类
@Before
public void initializeExecutionEnvironment() {
	TestStreamEnvironment.setAsContext(flinkCluster, 4);
	new TestEnvironment(flinkCluster, 4, false).setAsContext();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:6,代码来源:CassandraConnectorITCase.java


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