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


Java TestStreamEnvironment类代码示例

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


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

示例1: after

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

	TestStreamEnvironment.unsetAsContext();
	TestEnvironment.unsetAsContext();

	final CompletableFuture<?> terminationFuture = jobExecutorService.terminate();

	try {
		terminationFuture.get(
			miniClusterResourceConfiguration.getShutdownTimeout().toMilliseconds(),
			TimeUnit.MILLISECONDS);
	} catch (Exception e) {
		LOG.warn("Could not properly shut down the MiniClusterResource.", e);
	}

	jobExecutorService = null;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:MiniClusterResource.java

示例2: 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

示例3: 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

示例4: runCheckpointedProgram

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
/**
 * Runs the following program the test program defined in {@link #testProgram(StreamExecutionEnvironment)}
 * followed by the checks in {@link #postSubmit}.
 */
@Test
public void runCheckpointedProgram() throws Exception {
	try {
		TestStreamEnvironment env = new TestStreamEnvironment(cluster, PARALLELISM);
		env.setParallelism(PARALLELISM);
		env.enableCheckpointing(500);
		env.getConfig().disableSysoutLogging();
		env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));

		testProgram(env);

		TestUtils.tryExecute(env, "Fault Tolerance Test");

		postSubmit();
	}
	catch (Exception e) {
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:StreamFaultToleranceTestBase.java

示例5: 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

示例6: shutDownServices

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
@AfterClass
public static void shutDownServices() throws Exception {

	LOG.info("-------------------------------------------------------------------------");
	LOG.info("    Shut down KafkaTestBase ");
	LOG.info("-------------------------------------------------------------------------");

	TestStreamEnvironment.unsetAsContext();

	shutdownClusters();

	LOG.info("-------------------------------------------------------------------------");
	LOG.info("    KafkaTestBase finished");
	LOG.info("-------------------------------------------------------------------------");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:KafkaTestBase.java

示例7: 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

示例8: shutDownServices

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
@AfterClass
public static void shutDownServices() throws Exception {
	TestStreamEnvironment.unsetAsContext();

	if (flink != null) {
		flink.stop();
	}
	kafkaServer.shutdown();

	secureProps.clear();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:KafkaShortRetentionTestBase.java

示例9: 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

示例10: tearDown

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
@AfterClass
public static void tearDown() throws Exception {
	if (testCluster != null) {
		testCluster.stop();
	}

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

示例11: 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

示例12: 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

示例13: startTestCluster

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
@BeforeClass
public static void startTestCluster() {
	Configuration config = new Configuration();
	config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 2);
	config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, PARALLELISM / 2);
	config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 48L);
	config.setString(AkkaOptions.LOOKUP_TIMEOUT, "60 s");
	config.setString(AkkaOptions.ASK_TIMEOUT, "60 s");
	cluster = new LocalFlinkMiniCluster(config, false);
	cluster.start();

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

示例14: startTestCluster

import org.apache.flink.streaming.util.TestStreamEnvironment; //导入依赖的package包/类
@BeforeClass
public static void startTestCluster() {
	Configuration config = new Configuration();
	config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 2);
	config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, PARALLELISM / 2);
	config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 48L);

	cluster = new LocalFlinkMiniCluster(config, false);
	cluster.start();

	env = new TestStreamEnvironment(cluster, PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:WindowCheckpointingITCase.java

示例15: 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


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