Github user davidyan74 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/168#discussion_r46321968
  
    --- Diff: 
engine/src/test/java/com/datatorrent/stram/engine/GenericNodeTest.java ---
    @@ -296,4 +319,105 @@ public void run()
         Assert.assertTrue("End window not called", go.endWindowId != 
go.beginWindowId);
       }
     
    +  @Test
    +  public void testDefaultCheckPointDistance() throws InterruptedException
    +  {
    +    
testCheckpointDistance(Context.DAGContext.CHECKPOINT_WINDOW_COUNT.defaultValue, 
Context.OperatorContext.CHECKPOINT_WINDOW_COUNT.defaultValue);
    +  }
    +
    +  @Test
    +  public void testDAGGreaterCheckPointDistance() throws 
InterruptedException
    +  {
    +    testCheckpointDistance(7, 5);
    +  }
    +
    +  @Test
    +  public void testOpGreaterCheckPointDistance() throws InterruptedException
    +  {
    +    testCheckpointDistance(3, 5);
    +  }
    +
    +  private void testCheckpointDistance(int dagCheckPoint, int opCheckPoint) 
throws InterruptedException
    +  {
    +    int windowWidth = 50;
    +    long sleeptime = 25L;
    +    int maxWindows = 60;
    +    // Adding some extra time for the windows to finish
    +    long maxSleep = windowWidth * maxWindows + 5000;
    +
    +    ScheduledExecutorService executorService = new 
ScheduledThreadPoolExecutor(1, "default");
    +    final WindowGenerator windowGenerator = new 
WindowGenerator(executorService, 1024);
    +    windowGenerator.setWindowWidth(windowWidth);
    +    windowGenerator.setFirstWindow(executorService.getCurrentTimeMillis());
    +    windowGenerator.setCheckpointCount(dagCheckPoint, 0);
    +    //GenericOperator go = new GenericOperator();
    +    CheckpointDistanceOperator go = new CheckpointDistanceOperator();
    +    go.maxWindows = maxWindows;
    +
    +    List<Integer> checkpoints = new ArrayList<Integer>();
    +
    +    int window = 0;
    +    while (window < maxWindows) {
    +      window = (int)Math.ceil((double)(window + 1)/dagCheckPoint) * 
dagCheckPoint;
    +      window = (int)Math.ceil((double)window/opCheckPoint) * opCheckPoint;
    +      checkpoints.add(window);
    +    }
    +
    +    final StreamContext stcontext = new StreamContext("s1");
    +    DefaultAttributeMap attrMap = new DefaultAttributeMap();
    +    attrMap.put(Context.DAGContext.CHECKPOINT_WINDOW_COUNT, dagCheckPoint);
    +    attrMap.put(Context.OperatorContext.CHECKPOINT_WINDOW_COUNT, 
opCheckPoint);
    +    final OperatorContext context = new 
com.datatorrent.stram.engine.OperatorContext(0, attrMap, null);
    +    final GenericNode gn = new GenericNode(go, context);
    +    gn.setId(1);
    +
    +    //DefaultReservoir reservoir1 = new DefaultReservoir("ip1Res", 1024);
    +    //DefaultReservoir reservoir2 = new DefaultReservoir("ip2Res", 1024);
    +
    +    //gn.connectInputPort("ip1", reservoir1);
    +    //gn.connectInputPort("ip2", reservoir2);
    +    gn.connectInputPort("ip1", windowGenerator.acquireReservoir("ip1", 
1024));
    +    gn.connectInputPort("ip1", windowGenerator.acquireReservoir("ip2", 
1024));
    +    gn.connectOutputPort("op", Sink.BLACKHOLE);
    +
    +    final AtomicBoolean ab = new AtomicBoolean(false);
    +    Thread t = new Thread()
    +    {
    +      @Override
    +      public void run()
    +      {
    +        gn.setup(context);
    +        windowGenerator.activate(stcontext);
    +        gn.activate();
    +        ab.set(true);
    +        gn.run();
    +        windowGenerator.deactivate();
    +        gn.deactivate();
    +        gn.teardown();
    +      }
    +    };
    +    t.start();
    +
    +    long interval = 0;
    +    do {
    +      Thread.sleep(sleeptime);
    +      interval += sleeptime;
    +    }
    +    //while ((ab.get() == false) && (interval < maxSleep));
    +    while ((go.numWindows < maxWindows) && (interval < maxSleep));
    --- End diff --
    
    while should be right after the closing curly brace as per the new style 
rule


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to