beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [1/5] beam git commit: Factory method best practice for ReshuffleTriggerStateMachine
Date Fri, 24 Feb 2017 15:28:49 GMT
Repository: beam
Updated Branches:
  refs/heads/master 3d0fe8539 -> 25a014f40


Factory method best practice for ReshuffleTriggerStateMachine


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/bd8b72c6
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/bd8b72c6
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/bd8b72c6

Branch: refs/heads/master
Commit: bd8b72c6d2f2beaef516a1b11ddf18639c3e7fb1
Parents: bfdbebd
Author: Kenneth Knowles <klk@google.com>
Authored: Thu Feb 23 19:41:17 2017 -0800
Committer: Kenneth Knowles <klk@google.com>
Committed: Fri Feb 24 07:16:35 2017 -0800

----------------------------------------------------------------------
 .../runners/core/triggers/ReshuffleTriggerStateMachine.java  | 6 +++++-
 .../core/triggers/ReshuffleTriggerStateMachineTest.java      | 8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/bd8b72c6/runners/core-java/src/main/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachine.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachine.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachine.java
index fc9f203..8a2b736 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachine.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachine.java
@@ -25,7 +25,11 @@ import org.apache.beam.sdk.util.Reshuffle;
  */
 public class ReshuffleTriggerStateMachine extends TriggerStateMachine {
 
-  public ReshuffleTriggerStateMachine() {
+  public static ReshuffleTriggerStateMachine create() {
+    return new ReshuffleTriggerStateMachine();
+  }
+
+  private ReshuffleTriggerStateMachine() {
     super(null);
   }
 

http://git-wip-us.apache.org/repos/asf/beam/blob/bd8b72c6/runners/core-java/src/test/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachineTest.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/test/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachineTest.java
b/runners/core-java/src/test/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachineTest.java
index ef74bb5..f8b0324 100644
--- a/runners/core-java/src/test/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachineTest.java
+++ b/runners/core-java/src/test/java/org/apache/beam/runners/core/triggers/ReshuffleTriggerStateMachineTest.java
@@ -38,14 +38,14 @@ public class ReshuffleTriggerStateMachineTest {
 
   /** Public so that other tests can instantiate {@link ReshuffleTriggerStateMachine}. */
   public static <W extends BoundedWindow> ReshuffleTriggerStateMachine forTest() {
-    return new ReshuffleTriggerStateMachine();
+    return ReshuffleTriggerStateMachine.create();
   }
 
   @Test
   public void testShouldFire() throws Exception {
     TriggerStateMachineTester<Integer, IntervalWindow> tester =
         TriggerStateMachineTester.forTrigger(
-            new ReshuffleTriggerStateMachine(), FixedWindows.of(Duration.millis(100)));
+            ReshuffleTriggerStateMachine.create(), FixedWindows.of(Duration.millis(100)));
     IntervalWindow arbitraryWindow = new IntervalWindow(new Instant(300), new Instant(400));
     assertTrue(tester.shouldFire(arbitraryWindow));
   }
@@ -54,7 +54,7 @@ public class ReshuffleTriggerStateMachineTest {
   public void testOnTimer() throws Exception {
     TriggerStateMachineTester<Integer, IntervalWindow> tester =
         TriggerStateMachineTester.forTrigger(
-            new ReshuffleTriggerStateMachine(), FixedWindows.of(Duration.millis(100)));
+            ReshuffleTriggerStateMachine.create(), FixedWindows.of(Duration.millis(100)));
     IntervalWindow arbitraryWindow = new IntervalWindow(new Instant(100), new Instant(200));
     tester.fireIfShouldFire(arbitraryWindow);
     assertFalse(tester.isMarkedFinished(arbitraryWindow));
@@ -62,7 +62,7 @@ public class ReshuffleTriggerStateMachineTest {
 
   @Test
   public void testToString() {
-    TriggerStateMachine trigger = new ReshuffleTriggerStateMachine();
+    TriggerStateMachine trigger = ReshuffleTriggerStateMachine.create();
     assertEquals("ReshuffleTriggerStateMachine()", trigger.toString());
   }
 }


Mime
View raw message