-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1b7744
Remove specific registrar classes and service files
3f66206
Add dependency on AutoService
5860a3c
Add SparkRunnerRegistrar as a runner specific registrar that uses Aut…
bd65f26
Add a unit test for the SparkRunnerRegistrar
eb65c15
Update README according to dataflow->beam package rename
c92a522
Annotate class with RunWith and some whitespace fix ups
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkRunnerRegistrar.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
| } |
31 changes: 0 additions & 31 deletions
31
...rc/main/java/org/apache/beam/runners/spark/translation/SparkPipelineOptionsRegistrar.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...src/main/java/org/apache/beam/runners/spark/translation/SparkPipelineRunnerRegistrar.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ache/beam/runners/spark/translation/streaming/SparkStreamingPipelineOptionsRegistrar.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...esources/META-INF/services/com.google.cloud.dataflow.sdk.options.PipelineOptionsRegistrar
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...resources/META-INF/services/com.google.cloud.dataflow.sdk.runners.PipelineRunnerRegistrar
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
runners/spark/src/test/java/org/apache/beam/runners/spark/SparkRunnerRegistrarTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)