Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.6k
[BEAM-213] Fix README to use refactored package names and use AutoService for Registrar#230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a1b77443f662065860a3cbd65f26eb65c15c92a522File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.runners.spark; | ||
| import com.google.auto.service.AutoService; | ||
| import com.google.common.collect.ImmutableList; | ||
| import org.apache.beam.sdk.options.PipelineOptions; | ||
| import org.apache.beam.sdk.options.PipelineOptionsRegistrar; | ||
| import org.apache.beam.sdk.runners.PipelineRunner; | ||
| import org.apache.beam.sdk.runners.PipelineRunnerRegistrar; | ||
| /** | ||
| * Contains the {@link PipelineRunnerRegistrar} and {@link PipelineOptionsRegistrar} for the | ||
| * {@link SparkPipelineRunner}. | ||
| * | ||
| * {@link AutoService} will register Spark's implementations of the {@link PipelineRunner} | ||
| * and {@link PipelineOptions} as available pipeline runner services. | ||
| */ | ||
| public final class SparkRunnerRegistrar { | ||
| private SparkRunnerRegistrar() {} | ||
| /** | ||
| * Registers the {@link SparkPipelineRunner}. | ||
| */ | ||
| @AutoService(PipelineRunnerRegistrar.class) | ||
| public static class Runner implements PipelineRunnerRegistrar { | ||
| @Override | ||
| public Iterable<Class<? extends PipelineRunner<?>>> getPipelineRunners() { | ||
| return ImmutableList.<Class<? extends PipelineRunner<?>>>of(SparkPipelineRunner.class); | ||
| } | ||
| } | ||
| /** | ||
| * Registers the {@link SparkPipelineOptions} and {@link SparkStreamingPipelineOptions}. | ||
| */ | ||
| @AutoService(PipelineOptionsRegistrar.class) | ||
| public static class Options implements PipelineOptionsRegistrar { | ||
| @Override | ||
| public Iterable<Class<? extends PipelineOptions>> getPipelineOptions() { | ||
| return ImmutableList.<Class<? extends PipelineOptions>>of( | ||
| SparkPipelineOptions.class, | ||
| SparkStreamingPipelineOptions.class); | ||
| } | ||
| } | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.runners.spark; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.common.collect.Lists; | ||
| import org.apache.beam.sdk.options.PipelineOptionsRegistrar; | ||
| import org.apache.beam.sdk.runners.PipelineRunnerRegistrar; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.JUnit4; | ||
| import java.util.ServiceLoader; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.fail; | ||
| /** | ||
| * Test {@link SparkRunnerRegistrar}. | ||
| */ | ||
| @RunWith(JUnit4.class) | ||
| public class SparkRunnerRegistrarTest { | ||
| @Test | ||
| public void testOptions() { | ||
| assertEquals( | ||
| ImmutableList.of(SparkPipelineOptions.class, SparkStreamingPipelineOptions.class), | ||
| new SparkRunnerRegistrar.Options().getPipelineOptions()); | ||
| } | ||
| @Test | ||
| public void testRunners() { | ||
| assertEquals(ImmutableList.of(SparkPipelineRunner.class), | ||
| new SparkRunnerRegistrar.Runner().getPipelineRunners()); | ||
| } | ||
| @Test | ||
| public void testServiceLoaderForOptions() { | ||
| for (PipelineOptionsRegistrar registrar : | ||
| Lists.newArrayList(ServiceLoader.load(PipelineOptionsRegistrar.class).iterator())) { | ||
| if (registrar instanceof SparkRunnerRegistrar.Options) { | ||
| return; | ||
| } | ||
| } | ||
| fail("Expected to find " + SparkRunnerRegistrar.Options.class); | ||
| } | ||
| @Test | ||
| public void testServiceLoaderForRunner() { | ||
| for (PipelineRunnerRegistrar registrar : | ||
| Lists.newArrayList(ServiceLoader.load(PipelineRunnerRegistrar.class).iterator())) { | ||
| if (registrar instanceof SparkRunnerRegistrar.Runner) { | ||
| return; | ||
| } | ||
| } | ||
| fail("Expected to find " + SparkRunnerRegistrar.Runner.class); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please annotate class with:
@RunWith(JUnit4.class)