本文整理汇总了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));
}
示例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));
}
示例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));
}
}
示例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));
}
示例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)));
}
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
}
示例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));
}
示例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();
}
示例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)));
}
示例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)));
}
示例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)));
}