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


Java Execution.executeBlocking方法代码示例

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


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

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

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

示例3: shouldWorkWithCreateActionTriggers

import teetime.framework.Execution; //导入方法依赖的package包/类
@Test
public void shouldWorkWithCreateActionTriggers() {
	List<Integer> inputNumbers = Arrays.asList(0, 1, 2, 3, 4);

	@SuppressWarnings("unchecked")
	PortAction<DynamicDistributor<Integer>>[] inputActions = new PortAction[inputNumbers.size()];
	for (int i = 0; i < inputActions.length; i++) {
		PortAction<DynamicDistributor<Integer>> createAction = createPortCreateAction(new PortContainer<Integer>());
		inputActions[i] = createAction;
	}

	DynamicDistributorTestConfig<Integer> config = new DynamicDistributorTestConfig<Integer>(inputNumbers, Arrays.asList(inputActions));
	Execution<DynamicDistributorTestConfig<Integer>> analysis = new Execution<DynamicDistributorTestConfig<Integer>>(config);

	try {
		analysis.executeBlocking();
	} catch (Exception e) {
		throw new IllegalStateException(e);
	}

	assertThat(config.getOutputElements(), contains(0));
	assertValuesForIndex(inputActions[0], Arrays.asList(1));
	assertValuesForIndex(inputActions[1], Arrays.asList(2));
	assertValuesForIndex(inputActions[2], Arrays.asList(3));
	assertValuesForIndex(inputActions[3], Arrays.asList(4));
	assertValuesForIndex(inputActions[4], Collections.<Integer> emptyList());
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:28,代码来源:DynamicDistributorTest.java

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

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

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

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

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

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

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

示例11: shouldWorkWithoutActionTriggers

import teetime.framework.Execution; //导入方法依赖的package包/类
@Test
public void shouldWorkWithoutActionTriggers() {
	PortAction<DynamicDistributor<Integer>> createAction = new DoNothingPortAction<Integer>();

	List<Integer> inputNumbers = Arrays.asList(0, 1, 2, 3, 4);
	List<PortAction<DynamicDistributor<Integer>>> inputActions = Arrays.asList(createAction, createAction, createAction, createAction, createAction);

	DynamicDistributorTestConfig<Integer> config = new DynamicDistributorTestConfig<Integer>(inputNumbers, inputActions);
	Execution<DynamicDistributorTestConfig<Integer>> analysis = new Execution<DynamicDistributorTestConfig<Integer>>(config);

	analysis.executeBlocking();

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

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

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

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

示例15: shouldWorkWithRemoveActionTriggers

import teetime.framework.Execution; //导入方法依赖的package包/类
@Test
public void shouldWorkWithRemoveActionTriggers() {
	List<Integer> inputNumbers = Arrays.asList(0, 1, 2, 3, 4, 5);

	@SuppressWarnings("unchecked")
	PortAction<DynamicDistributor<Integer>>[] inputActions = new PortAction[6];

	final PortContainer<Integer> portContainer0 = new PortContainer<Integer>();
	final PortContainer<Integer> portContainer1 = new PortContainer<Integer>();
	final PortContainer<Integer> portContainer2 = new PortContainer<Integer>();

	inputActions[0] = createPortCreateAction(portContainer0);
	inputActions[1] = new RemovePortActionDelegation<Integer>(portContainer0);
	inputActions[2] = createPortCreateAction(portContainer1);
	inputActions[3] = createPortCreateAction(portContainer2);
	inputActions[4] = new RemovePortActionDelegation<Integer>(portContainer1);
	inputActions[5] = new RemovePortActionDelegation<Integer>(portContainer2);

	DynamicDistributorTestConfig<Integer> config = new DynamicDistributorTestConfig<Integer>(inputNumbers, Arrays.asList(inputActions));
	Execution<DynamicDistributorTestConfig<Integer>> analysis = new Execution<DynamicDistributorTestConfig<Integer>>(config);

	analysis.executeBlocking();

	assertThat(config.getOutputElements(), contains(0, 1, 2, 4, 5));
	assertValuesForIndex(inputActions[0], Collections.<Integer> emptyList());
	assertValuesForIndex(inputActions[2], Arrays.asList(3));
	assertValuesForIndex(inputActions[3], Collections.<Integer> emptyList());
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:29,代码来源:DynamicDistributorTest.java


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