beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] incubator-beam git commit: CrashingRunner: cleanup some code
Date Thu, 16 Jun 2016 20:14:38 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master a60b58efd -> f57e66c48


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/b4737ea3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/b4737ea3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/b4737ea3

Branch: refs/heads/master
Commit: b4737ea38d6a85633554d1cf8e0fb0100c8e3c3a
Parents: a60b58e
Author: Dan Halperin <dhalperi@google.com>
Authored: Thu Jun 16 10:15:58 2016 -0700
Committer: Dan Halperin <dhalperi@google.com>
Committed: Thu Jun 16 13:14:29 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/b4737ea3/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/b4737ea3/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());


Mime
View raw message