Search in sources :

Example 21 with SamzaPipelineOptions

use of org.apache.beam.runners.samza.SamzaPipelineOptions in project beam by apache.

the class ConfigGeneratorTest method testSamzaYarnExecutionEnvironmentConfig.

@Test
public void testSamzaYarnExecutionEnvironmentConfig() {
    final String yarnPackagePath = "yarn.package.path";
    SamzaPipelineOptions options = PipelineOptionsFactory.create().as(SamzaPipelineOptions.class);
    options.setJobName("TestEnvConfig");
    options.setRunner(SamzaRunner.class);
    options.setSamzaExecutionEnvironment(SamzaExecutionEnvironment.YARN);
    options.setConfigOverride(ImmutableMap.<String, String>builder().put(yarnPackagePath, "file://${basedir}/target/${project.artifactId}-${pom.version}-dist.tar.gz").build());
    Pipeline pipeline = Pipeline.create(options);
    pipeline.apply(Create.of(1, 2, 3)).apply(Sum.integersGlobally());
    pipeline.replaceAll(SamzaTransformOverrides.getDefaultOverrides());
    final Map<PValue, String> idMap = PViewToIdMapper.buildIdMap(pipeline);
    final ConfigBuilder configBuilder = new ConfigBuilder(options);
    SamzaPipelineTranslator.createConfig(pipeline, options, idMap, configBuilder);
    try {
        Config config = configBuilder.build();
        assertEquals(config.get(APP_RUNNER_CLASS), RemoteApplicationRunner.class.getName());
        assertEquals(config.get(JOB_FACTORY_CLASS), YarnJobFactory.class.getName());
    } catch (IllegalArgumentException e) {
        throw new AssertionError(String.format("Failed to validate correct configs for %s samza execution environment", SamzaExecutionEnvironment.YARN), e);
    }
}
Also used : RemoteApplicationRunner(org.apache.samza.runtime.RemoteApplicationRunner) ZkConfig(org.apache.samza.config.ZkConfig) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) Config(org.apache.samza.config.Config) PValue(org.apache.beam.sdk.values.PValue) SamzaPipelineOptions(org.apache.beam.runners.samza.SamzaPipelineOptions) Pipeline(org.apache.beam.sdk.Pipeline) YarnJobFactory(org.apache.samza.job.yarn.YarnJobFactory) Test(org.junit.Test)

Example 22 with SamzaPipelineOptions

use of org.apache.beam.runners.samza.SamzaPipelineOptions in project beam by apache.

the class PipelineJsonRendererTest method testEmptyPipeline.

@Test
public void testEmptyPipeline() {
    SamzaPipelineOptions options = PipelineOptionsFactory.create().as(SamzaPipelineOptions.class);
    options.setRunner(SamzaRunner.class);
    Pipeline p = Pipeline.create(options);
    String jsonDag = "{  \"RootNode\": [" + "    { \"fullName\":\"OuterMostNode\"," + "      \"ChildNodes\":[    ]}],\"graphLinks\": []" + "}";
    System.out.println(PipelineJsonRenderer.toJsonString(p));
    assertEquals(JsonParser.parseString(jsonDag), JsonParser.parseString(PipelineJsonRenderer.toJsonString(p).replaceAll(System.lineSeparator(), "")));
}
Also used : SamzaPipelineOptions(org.apache.beam.runners.samza.SamzaPipelineOptions) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Example 23 with SamzaPipelineOptions

use of org.apache.beam.runners.samza.SamzaPipelineOptions in project beam by apache.

the class UnboundedSourceSystemTest method createConsumer.

private static UnboundedSourceSystem.Consumer<String, TestCheckpointMark> createConsumer(TestUnboundedSource<String> source, int splitNum) {
    SamzaPipelineOptions pipelineOptions = PipelineOptionsFactory.as(SamzaPipelineOptions.class);
    // emit immediately
    pipelineOptions.setWatermarkInterval(0L);
    pipelineOptions.setMaxSourceParallelism(splitNum);
    return new UnboundedSourceSystem.Consumer<>(source, pipelineOptions, new SamzaMetricsContainer(new MetricsRegistryMap()), "test-step");
}
Also used : SystemConsumer(org.apache.samza.system.SystemConsumer) SamzaMetricsContainer(org.apache.beam.runners.samza.metrics.SamzaMetricsContainer) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) SamzaPipelineOptions(org.apache.beam.runners.samza.SamzaPipelineOptions)

Example 24 with SamzaPipelineOptions

use of org.apache.beam.runners.samza.SamzaPipelineOptions in project beam by apache.

the class BoundedSourceSystemTest method createConsumer.

private static BoundedSourceSystem.Consumer<String> createConsumer(BoundedSource<String> source, int splitNum) {
    SamzaPipelineOptions pipelineOptions = PipelineOptionsFactory.as(SamzaPipelineOptions.class);
    pipelineOptions.setMaxSourceParallelism(splitNum);
    return new BoundedSourceSystem.Consumer<>(source, pipelineOptions, new SamzaMetricsContainer(new MetricsRegistryMap()), "test-step");
}
Also used : SystemConsumer(org.apache.samza.system.SystemConsumer) SamzaMetricsContainer(org.apache.beam.runners.samza.metrics.SamzaMetricsContainer) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) SamzaPipelineOptions(org.apache.beam.runners.samza.SamzaPipelineOptions)

Aggregations

SamzaPipelineOptions (org.apache.beam.runners.samza.SamzaPipelineOptions)24 Test (org.junit.Test)20 Instant (org.joda.time.Instant)12 StateNamespace (org.apache.beam.runners.core.StateNamespace)11 TimerInternals (org.apache.beam.runners.core.TimerInternals)11 ByteArray (org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArray)11 StateValue (org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.StateValue)11 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 Pipeline (org.apache.beam.sdk.Pipeline)9 PValue (org.apache.beam.sdk.values.PValue)7 Config (org.apache.samza.config.Config)6 JobCoordinatorConfig (org.apache.samza.config.JobCoordinatorConfig)6 ZkConfig (org.apache.samza.config.ZkConfig)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 StateSpec (org.apache.beam.sdk.state.StateSpec)3 DoFn (org.apache.beam.sdk.transforms.DoFn)3 HashMap (java.util.HashMap)2 SamzaMetricsContainer (org.apache.beam.runners.samza.metrics.SamzaMetricsContainer)2 ValueState (org.apache.beam.sdk.state.ValueState)2 KV (org.apache.beam.sdk.values.KV)2