[ 
https://issues.apache.org/jira/browse/BEAM-8619?focusedWorklogId=348352&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-348352
 ]

ASF GitHub Bot logged work on BEAM-8619:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 22/Nov/19 20:42
            Start Date: 22/Nov/19 20:42
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #10126: [BEAM-8619] 
Tear down the DoFns upon the control service termination …
URL: https://github.com/apache/beam/pull/10126#discussion_r349783828
 
 

 ##########
 File path: 
runners/core-java/src/test/java/org/apache/beam/runners/core/metrics/ExecutionStateTrackerTest.java
 ##########
 @@ -0,0 +1,84 @@
+/*
+ * 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.core.metrics;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+import java.io.Closeable;
+import java.util.concurrent.TimeUnit;
+import 
org.apache.beam.runners.core.metrics.ExecutionStateTracker.ExecutionState;
+import org.joda.time.DateTimeUtils.MillisProvider;
+import org.junit.Before;
+import org.junit.Test;
+
+/** Tests for {@link ExecutionStateTracker}. */
+public class ExecutionStateTrackerTest {
+
+  private MillisProvider clock;
+  private ExecutionStateSampler sampler;
+
+  @Before
+  public void setUp() {
+    clock = mock(MillisProvider.class);
+    sampler = ExecutionStateSampler.newForTest(clock);
+  }
+
+  private static class TestExecutionState extends ExecutionState {
+
+    private long totalMillis = 0;
+
+    public TestExecutionState(String stateName) {
+      super(stateName);
+    }
+
+    @Override
+    public void takeSample(long millisSinceLastSample) {
+      totalMillis += millisSinceLastSample;
+    }
+
+    @Override
+    public void reportLull(Thread trackedThread, long millis) {}
+  }
+
+  private final TestExecutionState testExecutionState = new 
TestExecutionState("activity");
+
+  @Test
+  public void testReset() throws Exception {
+    ExecutionStateTracker tracker = createTracker();
+    try (Closeable c1 = tracker.activate(new Thread())) {
 
 Review comment:
   ```suggestion
       try (Closeable c1 = tracker.activate(Thread.currentThread())) {
   ```
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 348352)
    Time Spent: 2h 10m  (was: 2h)

> Tear down the DoFns upon the control service termination in Java SDK harness
> ----------------------------------------------------------------------------
>
>                 Key: BEAM-8619
>                 URL: https://issues.apache.org/jira/browse/BEAM-8619
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-java-harness
>    Affects Versions: 2.18.0
>            Reporter: sunjincheng
>            Assignee: sunjincheng
>            Priority: Major
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Per the discussion in the ML, the detail can be found [1], the teardown of 
> DoFns should be supported in the portability framework. It happens at two 
> places:
> 1) Upon the control service termination
> 2) Tear down the unused DoFns periodically
> The aim of this JIRA is to add support for teardown the DoFns upon the 
> control service termination in Java SDK harness.
> [1] 
> https://lists.apache.org/thread.html/0c4a4cf83cf2e35c3dfeb9d906e26cd82d3820968ba6f862f91739e4@%3Cdev.beam.apache.org%3E



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to