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


Java Execution类代码示例

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


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

示例1: shouldExecutePipelineCorrectlyManyElements

import teetime.framework.Execution; //导入依赖的package包/类
private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads) {
	List<Integer> processedElements = new ArrayList<>();

	IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
	Configuration config = new Configuration()
			.from(new StreamProducer<>(inputElements))
			.to(new Counter<>())
			.end(new CollectorSink<>(processedElements));

	TeeTimeService scheduling = new PushPullScheduling(config);
	Execution<Configuration> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	for (int i = 0; i < numElements; i++) {
		Integer actualElement = processedElements.get(i);
		assertThat(actualElement, is(i));
	}
	assertThat(processedElements, hasSize(numElements));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:20,代码来源:ThreeStagesPushPullIT.java

示例2: shouldExecutePipelineCorrectlyManyElements

import teetime.framework.Execution; //导入依赖的package包/类
private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads, final int numExecutions) {
	List<Integer> processedElements = new ArrayList<>();

	IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
	Configuration config = new Configuration()
			.from(new StreamProducer<>(inputElements))
			.to(new Counter<>())
			.end(new CollectorSink<>(processedElements));

	TeeTimeService scheduling = new GlobalTaskPoolScheduling(numThreads, config, numExecutions);
	Execution<Configuration> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	for (int i = 0; i < numElements; i++) {
		Integer actualElement = processedElements.get(i);
		assertThat(actualElement, is(i));
	}
	assertThat(processedElements, hasSize(numElements));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:20,代码来源:ThreeStagesGlobalTaskPoolIT.java

示例3: testException

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void testException() {
	Execution<ExceptionPassingTestConfig> execution = new Execution<ExceptionPassingTestConfig>(new ExceptionPassingTestConfig());
	try {
		execution.executeBlocking();
	} catch (ExecutionException e) {
		Entry<Thread, List<Exception>> entry = e.getThrownExceptions().entrySet().iterator().next();
		List<Exception> exceptions = entry.getValue();
		IllegalStateException exception = assertInstanceOf(IllegalStateException.class, exceptions.get(0));

		assertThat(exception.getMessage(), is(equalTo("Correct exception")));

		assertThat(exceptions.size(), is(1));
		assertThat(e.getThrownExceptions().size(), is(1));
	}
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:17,代码来源:ExceptionHandlingTest.java

示例4: shouldWorkWithRemoveActionTriggers

import teetime.framework.Execution; //导入依赖的package包/类
@Test
@Ignore // we cannot ensure anymore to consume at least one element before executing a port action
public void shouldWorkWithRemoveActionTriggers() {
	List<Integer> inputNumbers = Arrays.asList(0, 1, 2);

	DynamicMergerTestConfig config = new DynamicMergerTestConfig(inputNumbers);
	assertTrue(config.addCreatePortAction(3)); // processed after reading 0
	assertTrue(config.addRemovePortAction()); // processed after reading 1
	assertTrue(config.addCreatePortAction(4)); // processed after reading 2
	assertTrue(config.addCreatePortAction(5)); // processed after reading 4
	assertTrue(config.addRemovePortAction()); // processed after reading 5
	assertTrue(config.addRemovePortAction());

	Execution<DynamicMergerTestConfig> analysis = new Execution<DynamicMergerTestConfig>(config);

	analysis.executeBlocking();

	assertThat(config.getOutputElements(), contains(0, 1, 2, 4, 5));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:20,代码来源:DynamicMergerTest.java

示例5: testRegularExecution

import teetime.framework.Execution; //导入依赖的package包/类
void testRegularExecution(final List<String> expectedElements, final int numThreads) {
	for (int numOfExecutions = 1; numOfExecutions < expectedElements.size() + 1; numOfExecutions++) {
		List<String> actualElements = new ArrayList<>();

		Configuration configuration = new Configuration()
				.from(new InitialElementProducer<String>(expectedElements))
				.end(new CollectorSink<String>(actualElements));

		GlobalTaskPoolScheduling scheduler = new GlobalTaskPoolScheduling(numThreads, configuration, numOfExecutions);
		Execution<Configuration> execution = new Execution<>(configuration, true, scheduler);
		execution.executeBlocking();

		assertThat("failed with numOfExecutions=" + numOfExecutions, actualElements, is(equalTo(expectedElements)));
	}
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:16,代码来源:OneExecutionProducerIT.java

示例6: shouldExecutePipelineCorrectlyThreeElements

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void shouldExecutePipelineCorrectlyThreeElements() {
	String[] inputElements = { "a", "b", "c" };
	GlobalTaskPoolConfig<String> config = new GlobalTaskPoolConfig<>(inputElements);
	TeeTimeService scheduling = new GlobalTaskPoolScheduling(NUM_THREADS, config, 1);
	Execution<GlobalTaskPoolConfig<String>> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	List<String> processedElements = config.getSink().getElements();
	List<String> expectedElements = Arrays.asList("a", "b", "c");
	assertThat(WRONG_PIPELINE_EXECUTION, processedElements, is(equalTo(expectedElements)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:13,代码来源:PipelineIT.java

示例7: shouldExecutePipelineCorrectlyThreeElementsWithOneSingleThread

import teetime.framework.Execution; //导入依赖的package包/类
@Test
// FIXME stopped 22.12.2017
public void shouldExecutePipelineCorrectlyThreeElementsWithOneSingleThread() {
	String[] inputElements = { "a", "b", "c" };
	GlobalTaskPoolConfig<String> config = new GlobalTaskPoolConfig<>(inputElements);
	TeeTimeService scheduling = new GlobalTaskPoolScheduling(1, config, 1);
	Execution<GlobalTaskPoolConfig<String>> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	List<String> processedElements = config.getSink().getElements();
	List<String> expectedElements = Arrays.asList("a", "b", "c");
	assertThat(WRONG_PIPELINE_EXECUTION, processedElements, is(equalTo(expectedElements)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:14,代码来源:PipelineIT.java

示例8: shouldExecutePipelineCorrectlyThreeElementsWith2ExecutionsPerTask

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void shouldExecutePipelineCorrectlyThreeElementsWith2ExecutionsPerTask() {
	String[] inputElements = { "a", "b", "c" };
	GlobalTaskPoolConfig<String> config = new GlobalTaskPoolConfig<>(inputElements);
	TeeTimeService scheduling = new GlobalTaskPoolScheduling(NUM_THREADS, config, 2);
	Execution<GlobalTaskPoolConfig<String>> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	List<String> processedElements = config.getSink().getElements();
	List<String> expectedElements = Arrays.asList("a", "b", "c");
	assertThat(WRONG_PIPELINE_EXECUTION, processedElements, is(equalTo(expectedElements)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:13,代码来源:PipelineIT.java

示例9: shouldExecutePipelineCorrectlyThreeElementsWith3ExecutionsPerTask

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void shouldExecutePipelineCorrectlyThreeElementsWith3ExecutionsPerTask() {
	String[] inputElements = { "a", "b", "c" };
	GlobalTaskPoolConfig<String> config = new GlobalTaskPoolConfig<>(inputElements);
	TeeTimeService scheduling = new GlobalTaskPoolScheduling(NUM_THREADS, config, 3);
	Execution<GlobalTaskPoolConfig<String>> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	List<String> processedElements = config.getSink().getElements();
	List<String> expectedElements = Arrays.asList("a", "b", "c");
	assertThat(WRONG_PIPELINE_EXECUTION, processedElements, is(equalTo(expectedElements)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:13,代码来源:PipelineIT.java

示例10: testRegularExecution

import teetime.framework.Execution; //导入依赖的package包/类
void testRegularExecution(final List<String> expectedElements, final int numThreads) {
	for (int numOfExecutions = 1; numOfExecutions < expectedElements.size() + 1; numOfExecutions++) {
		List<String> actualElements = new ArrayList<>();

		Configuration configuration = new Configuration()
				.from(new ResponsiveProducer<String>(expectedElements))
				.end(new CollectorSink<String>(actualElements));

		GlobalTaskPoolScheduling scheduler = new GlobalTaskPoolScheduling(numThreads, configuration, numOfExecutions);
		Execution<Configuration> execution = new Execution<>(configuration, true, scheduler);
		execution.executeBlocking();

		assertThat("failed with numOfExecutions=" + numOfExecutions, actualElements, is(equalTo(expectedElements)));
	}
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:16,代码来源:MultipleExecutionsProducerIT.java

示例11: testParallelExecution

import teetime.framework.Execution; //导入依赖的package包/类
private void testParallelExecution(final int numElements, final int numThreads, final int numExecutions) {
	List<Integer> processedElements = new ArrayList<>();

	ParallelCounterConfig config = new ParallelCounterConfig(numElements, numThreads, processedElements);
	TeeTimeService scheduling = new GlobalTaskPoolScheduling(numThreads, config, numExecutions);
	Execution<ParallelCounterConfig> execution = new Execution<>(config, true, scheduling);
	execution.executeBlocking();

	for (int i = 0; i < numElements; i++) {
		assertThat(processedElements.get(i), is(i));
	}
	assertThat(processedElements, hasSize(numElements));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:14,代码来源:ParallelCounterConfigIT.java

示例12: main

import teetime.framework.Execution; //导入依赖的package包/类
/**
 * Runs the config on the current working directory
 *
 * @param args
 *            No further usage
 */
public static void main(final String... args) {
	PrintResultConfig config = new PrintResultConfig(new File("."));

	Execution<PrintResultConfig> execution = new Execution<PrintResultConfig>(config);
	execution.executeBlocking();
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:13,代码来源:PrintResultConfig.java

示例13: executeTestWithDefaultConfiguration

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void executeTestWithDefaultConfiguration() throws IOException {
	final CipherConfiguration configuration = new CipherConfiguration(INPUT_FILE, OUTPUT_FILE, PASSWORD);
	final Execution<CipherConfiguration> execution = new Execution<CipherConfiguration>(configuration);
	execution.executeBlocking();

	Assert.assertTrue(Files.equal(new File(INPUT_FILE), new File(OUTPUT_FILE)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:9,代码来源:CipherTest.java

示例14: executeTestWithBuilderBasedConfiguration

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void executeTestWithBuilderBasedConfiguration() throws IOException {
	final CipherConfigurationFromBuilder configuration = new CipherConfigurationFromBuilder(INPUT_FILE, OUTPUT_FILE, PASSWORD);
	final Execution<CipherConfigurationFromBuilder> execution = new Execution<CipherConfigurationFromBuilder>(configuration);
	execution.executeBlocking();

	Assert.assertTrue(Files.equal(new File(INPUT_FILE), new File(OUTPUT_FILE)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:9,代码来源:CipherTest.java

示例15: executeTestWithConfigurationCreatedByBuilder

import teetime.framework.Execution; //导入依赖的package包/类
@Test
public void executeTestWithConfigurationCreatedByBuilder() throws IOException {
	final Configuration configuration = ConfigurationBuilder
			.from(new InitialElementProducer<File>(new File(INPUT_FILE)))
			.to(new File2ByteArray())
			.to(new CipherStage(PASSWORD, CipherMode.ENCRYPT))
			.to(new ZipByteArray(ZipMode.COMP))
			.to(new ZipByteArray(ZipMode.DECOMP))
			.to(new CipherStage(PASSWORD, CipherMode.DECRYPT))
			.end(new ByteArrayFileWriter(new File(OUTPUT_FILE)));
	final Execution<Configuration> execution = new Execution<Configuration>(configuration);
	execution.executeBlocking();

	Assert.assertTrue(Files.equal(new File(INPUT_FILE), new File(OUTPUT_FILE)));
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:16,代码来源:CipherTest.java


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