You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2016/06/20 22:16:23 UTC
[30/50] [abbrv] incubator-beam git commit: CrashingRunner: cleanup
some code
CrashingRunner: cleanup some code
make it final, fix an error message, remove unused code
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/93f9ef92
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/93f9ef92
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/93f9ef92
Branch: refs/heads/python-sdk
Commit: 93f9ef92dcdcdec4f481e996b02f256cb18dc628
Parents: 3d87f8b
Author: Dan Halperin <dh...@google.com>
Authored: Thu Jun 16 10:15:58 2016 -0700
Committer: Davor Bonaci <da...@google.com>
Committed: Mon Jun 20 15:14:30 2016 -0700
----------------------------------------------------------------------
.../apache/beam/sdk/testing/CrashingRunner.java | 33 +++-----------------
.../apache/beam/sdk/testing/TestPipeline.java | 3 +-
2 files changed, 6 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/93f9ef92/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CrashingRunner.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CrashingRunner.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CrashingRunner.java
index 975facc..b3360ae 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CrashingRunner.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CrashingRunner.java
@@ -21,17 +21,15 @@ package org.apache.beam.sdk.testing;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.options.PipelineOptions;
-import org.apache.beam.sdk.runners.AggregatorRetrievalException;
-import org.apache.beam.sdk.runners.AggregatorValues;
import org.apache.beam.sdk.runners.PipelineRunner;
-import org.apache.beam.sdk.transforms.Aggregator;
/**
* A {@link PipelineRunner} that applies no overrides and throws an exception on calls to
* {@link Pipeline#run()}. For use in {@link TestPipeline} to construct but not execute pipelines.
*/
-public class CrashingRunner extends PipelineRunner<PipelineResult>{
+public final class CrashingRunner extends PipelineRunner<PipelineResult>{
+ @SuppressWarnings("unused") // used by reflection
public static CrashingRunner fromOptions(PipelineOptions opts) {
return new CrashingRunner();
}
@@ -41,32 +39,11 @@ public class CrashingRunner extends PipelineRunner<PipelineResult>{
throw new IllegalArgumentException(String.format("Cannot call #run(Pipeline) on an instance "
+ "of %s. %s should only be used as the default to construct a Pipeline "
+ "using %s, and cannot execute Pipelines. Instead, specify a %s "
- + "by providing PipelineOptions in the environment variable '%s'.",
- getClass().getSimpleName(),
- getClass().getSimpleName(),
+ + "by providing PipelineOptions in the system property '%s'.",
+ CrashingRunner.class.getSimpleName(),
+ CrashingRunner.class.getSimpleName(),
TestPipeline.class.getSimpleName(),
PipelineRunner.class.getSimpleName(),
TestPipeline.PROPERTY_BEAM_TEST_PIPELINE_OPTIONS));
}
-
- private static class TestPipelineResult implements PipelineResult {
- private TestPipelineResult() {
- // Should never be instantiated by the enclosing class
- throw new UnsupportedOperationException(String.format("Forbidden to instantiate %s",
- getClass().getSimpleName()));
- }
-
- @Override
- public State getState() {
- throw new UnsupportedOperationException(String.format("Forbidden to instantiate %s",
- getClass().getSimpleName()));
- }
-
- @Override
- public <T> AggregatorValues<T> getAggregatorValues(Aggregator<?, T> aggregator)
- throws AggregatorRetrievalException {
- throw new AssertionError(String.format("Forbidden to instantiate %s",
- getClass().getSimpleName()));
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/93f9ef92/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
index 4618e33..0dba043 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java
@@ -141,8 +141,7 @@ public class TestPipeline extends Pipeline {
Strings.isNullOrEmpty(beamTestPipelineOptions)
? PipelineOptionsFactory.create()
: PipelineOptionsFactory.fromArgs(
- MAPPER.readValue(
- System.getProperty(PROPERTY_BEAM_TEST_PIPELINE_OPTIONS), String[].class))
+ MAPPER.readValue(beamTestPipelineOptions, String[].class))
.as(TestPipelineOptions.class);
options.as(ApplicationNameOptions.class).setAppName(getAppName());