You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/03/11 04:27:03 UTC
[GitHub] [beam] kileys opened a new pull request #14197: [BEAM-11945] Add debug capture to SDK harness
kileys opened a new pull request #14197:
URL: https://github.com/apache/beam/pull/14197
Send thread dump and active bundle status to the runner for debugging purposes
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
- [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
Post-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
Lang | SDK | Dataflow | Flink | Samza | Spark | Twister2
--- | --- | --- | --- | --- | --- | ---
Go | [](https://ci-beam.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/) | ---
Java | [](https://ci-beam.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_VR_Dataflow_V2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/) | [](https://ci-beam
.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Twister2/lastCompletedBuild/)
Python | [](https://ci-beam.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python38/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/) | ---
XLang | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Direct/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Dataflow/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/) | ---
Pre-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
--- |Java | Python | Go | Website | Whitespace | Typescript
--- | --- | --- | --- | --- | --- | ---
Non-portable | [](https://ci-beam.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/lastCompletedBuild/) <br>[](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Whitespace_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Typescript_Cron/lastCompletedBuild/)
Portable | --- | [](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/) | --- | --- | --- | ---
See [.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md) for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] boyuanzz commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
boyuanzz commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-800441429
Also adding @y1chi as the reviewer for major functionality since he did similar changes for python.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-814365172
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-799903361
R: @boyuanzz @kennknowles
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] boyuanzz commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
boyuanzz commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-796935247
Is this PR ready to review? If so, please tag folks to request review on this : )
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-812260256
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r604467527
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/MemoryMonitor.java
##########
@@ -0,0 +1,342 @@
+/*
+ * 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.fn.harness.status;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.util.concurrent.AtomicDouble;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A runnable which monitors a server for GC thrashing.
+ *
+ * <p>Note: Only one instance of this should be initialized per server and it should be done when
+ * the server starts running.
+ *
+ * <p>This runnable works as follows:
+ *
+ * <ul>
+ * <li>It wakes up periodically and determines how much time was spend on garbage collection since
+ * the last time it woke up.
+ * <li>If the time spent in garbage collection in the last period of time exceeds a certain
+ * threshold, that period is marked as "being in GC thrashing"
+ * <li>It keeps track of the GC thrashing status of the last few periods.
+ * <li>Every time the runnable's thread wakes up, it computes the ratio {@code (# monitored
+ * periods in GC thrashing) / (# monitored periods)}.
+ * <li>If this ratio exceeds a certain threshold, it is assumed that the server is in GC
+ * thrashing.
+ * </ul>
+ */
+public class MemoryMonitor implements Runnable {
Review comment:
Is it worth abstracting to make it compatible since legacy worker is being deprecated?
The head dump upload to GCS does use FileSystems, so I can add those back as a generic upload. Also had an offline discussion, runner v2 can handle the SDK harness exiting on gc thrashing, so will add that back as well
cc: @robertwb, @kennknowles
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-816813553
Run Java Dataflow V2 ValidatesRunner Streaming
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-815253355
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-812198900
The window test is failing because of an `UnsupportedOperationException` on `java.nio.file.Files.setPosixFilePermissions`. Is that something that can be ignored since SDK harness isn't run on a windows container? I'm guessing these tests were turned on after the current MemoryMonitor was changed @kennknowles
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r601820830
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
Review comment:
Okay, brought in the memory monitor to calculate GC metrics
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r605056458
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/MemoryMonitor.java
##########
@@ -0,0 +1,342 @@
+/*
+ * 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.fn.harness.status;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.util.concurrent.AtomicDouble;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A runnable which monitors a server for GC thrashing.
+ *
+ * <p>Note: Only one instance of this should be initialized per server and it should be done when
+ * the server starts running.
+ *
+ * <p>This runnable works as follows:
+ *
+ * <ul>
+ * <li>It wakes up periodically and determines how much time was spend on garbage collection since
+ * the last time it woke up.
+ * <li>If the time spent in garbage collection in the last period of time exceeds a certain
+ * threshold, that period is marked as "being in GC thrashing"
+ * <li>It keeps track of the GC thrashing status of the last few periods.
+ * <li>Every time the runnable's thread wakes up, it computes the ratio {@code (# monitored
+ * periods in GC thrashing) / (# monitored periods)}.
+ * <li>If this ratio exceeds a certain threshold, it is assumed that the server is in GC
+ * thrashing.
+ * </ul>
+ */
+public class MemoryMonitor implements Runnable {
Review comment:
+1 to parity where it makes sense, but forking is just fine. Definitely remove anything Dataflow-specific from the SDK harness.
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-812067055
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] amaliujia commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r599846473
##########
File path: runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java
##########
@@ -102,6 +102,7 @@ public RemoteEnvironment createEnvironment(Environment environment, String worke
options,
loggingServer.getApiServiceDescriptor(),
controlServer.getApiServiceDescriptor(),
+ null,
Review comment:
cc @kennknowles any suggestions?
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-818045798
retest this please
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-816035258
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-815283592
I see it is `apache-ci-beam-jenkins-5`
--
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:
users@infra.apache.org
[GitHub] [beam] kileys edited a comment on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys edited a comment on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-812198900
The Java unit tests on Windows is failing because of an `UnsupportedOperationException` on `java.nio.file.Files.setPosixFilePermissions`. Is that something that can be ignored since SDK harness isn't run on a windows container? I'm guessing these tests were turned on after the current MemoryMonitor was changed @kennknowles
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r599177432
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
Review comment:
Is the GC info useful for debugging? I only added the runtime memory info for now -- I can bring in the full MemoryMonitor if it's helpful
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-815283274
I was going to SSH to `apache-beam-jenkins-5` and run https://gist.github.com/suztomo/901bb04033b1b303fc14cdeed7d0a8cc but it appears to be stopped. So maybe the node names don't match the GCE VMs? @tysonjh @suztomo
--
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:
users@infra.apache.org
[GitHub] [beam] amaliujia commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r599846026
##########
File path: runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/EmbeddedEnvironmentFactory.java
##########
@@ -102,6 +102,7 @@ public RemoteEnvironment createEnvironment(Environment environment, String worke
options,
loggingServer.getApiServiceDescriptor(),
controlServer.getApiServiceDescriptor(),
+ null,
Review comment:
Setting `null` seems a bit scary. Is there a better way to specify this value? Like a default/empty value instead of setting a `null`?
--
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:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r595408081
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
Review comment:
The jvm memory usage might be a good info to record as well https://github.com/apache/beam/blob/master/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/MemoryMonitor.java#L625
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ }
+
+ void threadDump(StringJoiner trace) {
+ trace.add("========== THREAD DUMP ==========");
+ Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
+ threads
+ .entrySet()
+ .forEach(
+ entry -> {
+ trace.add(
+ String.format(
+ "%n--- Thread #%d name: %s ---",
+ entry.getKey().getId(), entry.getKey().getName()));
+ Arrays.stream(entry.getValue()).map(StackTraceElement::toString).forEach(trace::add);
+ });
+ }
+
+ @VisibleForTesting
+ void activeProcessBundleState(StringJoiner activeBundlesState) {
Review comment:
nit:The meaning of StringJoiner parameter is a little bit confusing to me, maybe just call this getActiveProcessBundleStates() to keep the signature simple and just use the StringJoiner for concating each section at call site.
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ }
+
+ void threadDump(StringJoiner trace) {
+ trace.add("========== THREAD DUMP ==========");
+ Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
+ threads
+ .entrySet()
+ .forEach(
+ entry -> {
+ trace.add(
+ String.format(
+ "%n--- Thread #%d name: %s ---",
+ entry.getKey().getId(), entry.getKey().getName()));
+ Arrays.stream(entry.getValue()).map(StackTraceElement::toString).forEach(trace::add);
+ });
+ }
+
+ @VisibleForTesting
+ void activeProcessBundleState(StringJoiner activeBundlesState) {
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.\n");
+ } else {
+ processBundleCache.getActiveBundleProcessors().entrySet().stream()
+ .sorted(
+ Comparator.comparingLong(
+ (Map.Entry<String, BundleProcessor> bundle) ->
+ bundle.getValue().getStateTracker().getMillisSinceLastTransition())
+ .reversed()) // reverse sort active bundle by time since last transition.
+ .limit(10) // only keep top 10
+ .forEach(
+ entry -> {
+ ExecutionStateTracker executionStateTracker = entry.getValue().getStateTracker();
+ activeBundlesState.add(String.format("---- Instruction %s ----", entry.getKey()));
+ activeBundlesState.add(
+ String.format(
+ "Tracked thread: %s", executionStateTracker.getTrackedThread().getName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ executionStateTracker.getMillisSinceLastTransition() / 1000.0));
+ });
+ }
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ activeProcessBundleState(status);
+ status.add("\n");
+ threadDump(status);
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
Review comment:
We can also sends the error back to be captured.
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ }
+
+ void threadDump(StringJoiner trace) {
Review comment:
maybe call it getThreadDump? also could we do the deduplication like https://github.com/apache/beam/blob/master/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/status/ThreadzServlet.java#L76? Sometimes there are hundreds of threads and it is gonna make it hard for the browser to render.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-815221442
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610232124
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ }
+
+ void threadDump(StringJoiner trace) {
+ trace.add("========== THREAD DUMP ==========");
+ Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
+ threads
+ .entrySet()
+ .forEach(
+ entry -> {
+ trace.add(
+ String.format(
+ "%n--- Thread #%d name: %s ---",
+ entry.getKey().getId(), entry.getKey().getName()));
+ Arrays.stream(entry.getValue()).map(StackTraceElement::toString).forEach(trace::add);
+ });
+ }
+
+ @VisibleForTesting
+ void activeProcessBundleState(StringJoiner activeBundlesState) {
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.\n");
+ } else {
+ processBundleCache.getActiveBundleProcessors().entrySet().stream()
+ .sorted(
+ Comparator.comparingLong(
+ (Map.Entry<String, BundleProcessor> bundle) ->
+ bundle.getValue().getStateTracker().getMillisSinceLastTransition())
+ .reversed()) // reverse sort active bundle by time since last transition.
+ .limit(10) // only keep top 10
+ .forEach(
+ entry -> {
+ ExecutionStateTracker executionStateTracker = entry.getValue().getStateTracker();
+ activeBundlesState.add(String.format("---- Instruction %s ----", entry.getKey()));
+ activeBundlesState.add(
+ String.format(
+ "Tracked thread: %s", executionStateTracker.getTrackedThread().getName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ executionStateTracker.getMillisSinceLastTransition() / 1000.0));
+ });
+ }
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ activeProcessBundleState(status);
+ status.add("\n");
+ threadDump(status);
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
Review comment:
I think outboundObserver.onError(t) will not actually send back the exception as an error response but instead shut down the grpc connection. We can consider either just logging the error without calling outboundObserver.onError(t), or try to catch exception in onNext() and send it back with
```
WorkerStatusResponse.newBuilder()
.setId(workerStatusRequest.getId())
.setError(exceptionMesasge)
.build()
```
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-813612456
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-814507081
Run Java PreCommit
--
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:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610772548
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,231 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+ private final MemoryMonitor memoryMonitor;
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache,
+ PipelineOptions options) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ this.memoryMonitor = MemoryMonitor.fromOptions(options);
+ Thread thread = new Thread(memoryMonitor);
+ thread.setDaemon(true);
+ thread.setPriority(Thread.MIN_PRIORITY);
+ thread.setName("MemoryMonitor");
+ thread.start();
+ }
+
+ /**
+ * Class representing the execution state of a thread.
+ *
+ * <p>Can be used in hash maps.
+ */
+ static class Stack {
+ final StackTraceElement[] elements;
+ final Thread.State state;
+
+ Stack(StackTraceElement[] elements, Thread.State state) {
+ this.elements = elements;
+ this.state = state;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.deepHashCode(elements), state);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (other == this) {
+ return true;
+ } else if (!(other instanceof Stack)) {
+ return false;
+ } else {
+ Stack that = (Stack) other;
+ return state == that.state && Arrays.deepEquals(elements, that.elements);
+ }
+ }
+ }
+
+ String getThreadDump() {
+ StringJoiner trace = new StringJoiner("\n");
+ trace.add("========== THREAD DUMP ==========");
+ // filter duplicates.
+ Map<Stack, List<String>> stacks = new HashMap<>();
+ Thread.getAllStackTraces()
+ .forEach(
+ (thread, elements) -> {
+ if (thread != Thread.currentThread()) {
+ Stack stack = new Stack(elements, thread.getState());
+ stacks.putIfAbsent(stack, new ArrayList<>());
+ stacks.get(stack).add(thread.toString());
+ }
+ });
+
+ // Stacks with more threads are printed first.
+ stacks.entrySet().stream()
+ .sorted(Comparator.comparingInt(entry -> -entry.getValue().size()))
+ .forEachOrdered(
+ entry -> {
+ Stack stack = entry.getKey();
+ List<String> threads = entry.getValue();
+ trace.add(
+ String.format(
+ "---- Threads (%d): %s State: %s Stack: ----",
+ threads.size(), threads, stack.state));
+ Arrays.stream(stack.elements).map(StackTraceElement::toString).forEach(trace::add);
+ trace.add("\n");
+ });
+ return trace.toString();
+ }
+
+ String getMemoryUsage() {
+ StringJoiner memory = new StringJoiner("\n");
+ memory.add("========== MEMORY USAGE ==========");
+ memory.add(memoryMonitor.describeMemory());
+ return memory.toString();
+ }
+ /** Class representing the execution state of a bundle. */
+ static class BundleState {
+ final String instruction;
+ final String trackedThreadName;
+ final long timeSinceTransition;
+
+ public String getInstruction() {
+ return instruction;
+ }
+
+ public String getTrackedThreadName() {
+ return trackedThreadName;
+ }
+
+ public long getTimeSinceTransition() {
+ return timeSinceTransition;
+ }
+
+ public BundleState(String instruction, String trackedThreadName, long timeSinceTransition) {
+ this.instruction = instruction;
+ this.trackedThreadName = trackedThreadName;
+ this.timeSinceTransition = timeSinceTransition;
+ }
+ }
+
+ @VisibleForTesting
+ String getActiveProcessBundleState() {
+ StringJoiner activeBundlesState = new StringJoiner("\n");
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.");
+ } else {
+ List<BundleState> bundleStates = new ArrayList<>();
+ processBundleCache.getActiveBundleProcessors().keySet().stream()
+ .forEach(
+ instruction -> {
+ BundleProcessor bundleProcessor = processBundleCache.find(instruction);
+ if (bundleProcessor != null) {
+ ExecutionStateTracker executionStateTracker = bundleProcessor.getStateTracker();
+ Thread trackedTread = executionStateTracker.getTrackedThread();
+ if (trackedTread != null) {
+ bundleStates.add(
+ new BundleState(
+ instruction,
+ trackedTread.getName(),
+ executionStateTracker.getMillisSinceLastTransition()));
+ }
+ }
+ });
+ bundleStates.stream()
+ // reverse sort active bundle by time since last transition.
+ .sorted(Comparator.comparing(BundleState::getTimeSinceTransition).reversed())
+ .limit(10) // only keep top 10
+ .forEachOrdered(
+ bundleState -> {
+ activeBundlesState.add(
+ String.format("---- Instruction %s ----", bundleState.getInstruction()));
+ activeBundlesState.add(
+ String.format("Tracked thread: %s", bundleState.getTrackedThreadName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ bundleState.getTimeSinceTransition() / 1000.0));
+ });
+ }
+ return activeBundlesState.toString();
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ status.add(getMemoryUsage());
+ status.add("\n");
+ status.add(getActiveProcessBundleState());
+ status.add("\n");
+ status.add(getThreadDump());
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
+ outboundObserver.onError(t);
Review comment:
I think outboundObserver.onError(t) will not actually send back the exception as an error response but instead shut down the grpc connection. We can consider either just logging the error without calling outboundObserver.onError(t), or try to catch exception in onNext() and send it back with
```
WorkerStatusResponse.newBuilder()
.setId(workerStatusRequest.getId())
.setError(exceptionMesasge)
.build()
```
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ }
+
+ void threadDump(StringJoiner trace) {
+ trace.add("========== THREAD DUMP ==========");
+ Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
+ threads
+ .entrySet()
+ .forEach(
+ entry -> {
+ trace.add(
+ String.format(
+ "%n--- Thread #%d name: %s ---",
+ entry.getKey().getId(), entry.getKey().getName()));
+ Arrays.stream(entry.getValue()).map(StackTraceElement::toString).forEach(trace::add);
+ });
+ }
+
+ @VisibleForTesting
+ void activeProcessBundleState(StringJoiner activeBundlesState) {
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.\n");
+ } else {
+ processBundleCache.getActiveBundleProcessors().entrySet().stream()
+ .sorted(
+ Comparator.comparingLong(
+ (Map.Entry<String, BundleProcessor> bundle) ->
+ bundle.getValue().getStateTracker().getMillisSinceLastTransition())
+ .reversed()) // reverse sort active bundle by time since last transition.
+ .limit(10) // only keep top 10
+ .forEach(
+ entry -> {
+ ExecutionStateTracker executionStateTracker = entry.getValue().getStateTracker();
+ activeBundlesState.add(String.format("---- Instruction %s ----", entry.getKey()));
+ activeBundlesState.add(
+ String.format(
+ "Tracked thread: %s", executionStateTracker.getTrackedThread().getName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ executionStateTracker.getMillisSinceLastTransition() / 1000.0));
+ });
+ }
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ activeProcessBundleState(status);
+ status.add("\n");
+ threadDump(status);
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
Review comment:
I think outboundObserver.onError(t) will not actually send back the exception as an error response but instead shut down the grpc connection. We can consider either just logging the error without calling outboundObserver.onError(t), or try to catch exception in onNext() and send it back with
```
WorkerStatusResponse.newBuilder()
.setId(workerStatusRequest.getId())
.setError(exceptionMesasge)
.build()
```
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610860284
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,231 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+ private final MemoryMonitor memoryMonitor;
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache,
+ PipelineOptions options) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ this.memoryMonitor = MemoryMonitor.fromOptions(options);
+ Thread thread = new Thread(memoryMonitor);
+ thread.setDaemon(true);
+ thread.setPriority(Thread.MIN_PRIORITY);
+ thread.setName("MemoryMonitor");
+ thread.start();
+ }
+
+ /**
+ * Class representing the execution state of a thread.
+ *
+ * <p>Can be used in hash maps.
+ */
+ static class Stack {
+ final StackTraceElement[] elements;
+ final Thread.State state;
+
+ Stack(StackTraceElement[] elements, Thread.State state) {
+ this.elements = elements;
+ this.state = state;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.deepHashCode(elements), state);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (other == this) {
+ return true;
+ } else if (!(other instanceof Stack)) {
+ return false;
+ } else {
+ Stack that = (Stack) other;
+ return state == that.state && Arrays.deepEquals(elements, that.elements);
+ }
+ }
+ }
+
+ String getThreadDump() {
+ StringJoiner trace = new StringJoiner("\n");
+ trace.add("========== THREAD DUMP ==========");
+ // filter duplicates.
+ Map<Stack, List<String>> stacks = new HashMap<>();
+ Thread.getAllStackTraces()
+ .forEach(
+ (thread, elements) -> {
+ if (thread != Thread.currentThread()) {
+ Stack stack = new Stack(elements, thread.getState());
+ stacks.putIfAbsent(stack, new ArrayList<>());
+ stacks.get(stack).add(thread.toString());
+ }
+ });
+
+ // Stacks with more threads are printed first.
+ stacks.entrySet().stream()
+ .sorted(Comparator.comparingInt(entry -> -entry.getValue().size()))
+ .forEachOrdered(
+ entry -> {
+ Stack stack = entry.getKey();
+ List<String> threads = entry.getValue();
+ trace.add(
+ String.format(
+ "---- Threads (%d): %s State: %s Stack: ----",
+ threads.size(), threads, stack.state));
+ Arrays.stream(stack.elements).map(StackTraceElement::toString).forEach(trace::add);
+ trace.add("\n");
+ });
+ return trace.toString();
+ }
+
+ String getMemoryUsage() {
+ StringJoiner memory = new StringJoiner("\n");
+ memory.add("========== MEMORY USAGE ==========");
+ memory.add(memoryMonitor.describeMemory());
+ return memory.toString();
+ }
+ /** Class representing the execution state of a bundle. */
+ static class BundleState {
+ final String instruction;
+ final String trackedThreadName;
+ final long timeSinceTransition;
+
+ public String getInstruction() {
+ return instruction;
+ }
+
+ public String getTrackedThreadName() {
+ return trackedThreadName;
+ }
+
+ public long getTimeSinceTransition() {
+ return timeSinceTransition;
+ }
+
+ public BundleState(String instruction, String trackedThreadName, long timeSinceTransition) {
+ this.instruction = instruction;
+ this.trackedThreadName = trackedThreadName;
+ this.timeSinceTransition = timeSinceTransition;
+ }
+ }
+
+ @VisibleForTesting
+ String getActiveProcessBundleState() {
+ StringJoiner activeBundlesState = new StringJoiner("\n");
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.");
+ } else {
+ List<BundleState> bundleStates = new ArrayList<>();
+ processBundleCache.getActiveBundleProcessors().keySet().stream()
+ .forEach(
+ instruction -> {
+ BundleProcessor bundleProcessor = processBundleCache.find(instruction);
+ if (bundleProcessor != null) {
+ ExecutionStateTracker executionStateTracker = bundleProcessor.getStateTracker();
+ Thread trackedTread = executionStateTracker.getTrackedThread();
+ if (trackedTread != null) {
+ bundleStates.add(
+ new BundleState(
+ instruction,
+ trackedTread.getName(),
+ executionStateTracker.getMillisSinceLastTransition()));
+ }
+ }
+ });
+ bundleStates.stream()
+ // reverse sort active bundle by time since last transition.
+ .sorted(Comparator.comparing(BundleState::getTimeSinceTransition).reversed())
+ .limit(10) // only keep top 10
+ .forEachOrdered(
+ bundleState -> {
+ activeBundlesState.add(
+ String.format("---- Instruction %s ----", bundleState.getInstruction()));
+ activeBundlesState.add(
+ String.format("Tracked thread: %s", bundleState.getTrackedThreadName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ bundleState.getTimeSinceTransition() / 1000.0));
+ });
+ }
+ return activeBundlesState.toString();
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ status.add(getMemoryUsage());
+ status.add("\n");
+ status.add(getActiveProcessBundleState());
+ status.add("\n");
+ status.add(getThreadDump());
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
+ outboundObserver.onError(t);
Review comment:
If the onError has been called for the client, isn't it already shutting down so it's okay to terminate the connection?
--
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:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610202635
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1p36p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p36p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+ private final MemoryMonitor memoryMonitor;
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache,
+ PipelineOptions options) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
Review comment:
you probably should only create the InboundObserver and call stub.workerStatus once.
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-799875995
Run Java Examples on Dataflow Runner V2
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-816813711
Run Java Dataflow V2 ValidatesRunner
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610864085
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,231 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+ private final MemoryMonitor memoryMonitor;
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache,
+ PipelineOptions options) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
+ this.processBundleCache = processBundleCache;
+ this.memoryMonitor = MemoryMonitor.fromOptions(options);
+ Thread thread = new Thread(memoryMonitor);
+ thread.setDaemon(true);
+ thread.setPriority(Thread.MIN_PRIORITY);
+ thread.setName("MemoryMonitor");
+ thread.start();
+ }
+
+ /**
+ * Class representing the execution state of a thread.
+ *
+ * <p>Can be used in hash maps.
+ */
+ static class Stack {
+ final StackTraceElement[] elements;
+ final Thread.State state;
+
+ Stack(StackTraceElement[] elements, Thread.State state) {
+ this.elements = elements;
+ this.state = state;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.deepHashCode(elements), state);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (other == this) {
+ return true;
+ } else if (!(other instanceof Stack)) {
+ return false;
+ } else {
+ Stack that = (Stack) other;
+ return state == that.state && Arrays.deepEquals(elements, that.elements);
+ }
+ }
+ }
+
+ String getThreadDump() {
+ StringJoiner trace = new StringJoiner("\n");
+ trace.add("========== THREAD DUMP ==========");
+ // filter duplicates.
+ Map<Stack, List<String>> stacks = new HashMap<>();
+ Thread.getAllStackTraces()
+ .forEach(
+ (thread, elements) -> {
+ if (thread != Thread.currentThread()) {
+ Stack stack = new Stack(elements, thread.getState());
+ stacks.putIfAbsent(stack, new ArrayList<>());
+ stacks.get(stack).add(thread.toString());
+ }
+ });
+
+ // Stacks with more threads are printed first.
+ stacks.entrySet().stream()
+ .sorted(Comparator.comparingInt(entry -> -entry.getValue().size()))
+ .forEachOrdered(
+ entry -> {
+ Stack stack = entry.getKey();
+ List<String> threads = entry.getValue();
+ trace.add(
+ String.format(
+ "---- Threads (%d): %s State: %s Stack: ----",
+ threads.size(), threads, stack.state));
+ Arrays.stream(stack.elements).map(StackTraceElement::toString).forEach(trace::add);
+ trace.add("\n");
+ });
+ return trace.toString();
+ }
+
+ String getMemoryUsage() {
+ StringJoiner memory = new StringJoiner("\n");
+ memory.add("========== MEMORY USAGE ==========");
+ memory.add(memoryMonitor.describeMemory());
+ return memory.toString();
+ }
+ /** Class representing the execution state of a bundle. */
+ static class BundleState {
+ final String instruction;
+ final String trackedThreadName;
+ final long timeSinceTransition;
+
+ public String getInstruction() {
+ return instruction;
+ }
+
+ public String getTrackedThreadName() {
+ return trackedThreadName;
+ }
+
+ public long getTimeSinceTransition() {
+ return timeSinceTransition;
+ }
+
+ public BundleState(String instruction, String trackedThreadName, long timeSinceTransition) {
+ this.instruction = instruction;
+ this.trackedThreadName = trackedThreadName;
+ this.timeSinceTransition = timeSinceTransition;
+ }
+ }
+
+ @VisibleForTesting
+ String getActiveProcessBundleState() {
+ StringJoiner activeBundlesState = new StringJoiner("\n");
+ activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
+ if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
+ activeBundlesState.add("No active processing bundles.");
+ } else {
+ List<BundleState> bundleStates = new ArrayList<>();
+ processBundleCache.getActiveBundleProcessors().keySet().stream()
+ .forEach(
+ instruction -> {
+ BundleProcessor bundleProcessor = processBundleCache.find(instruction);
+ if (bundleProcessor != null) {
+ ExecutionStateTracker executionStateTracker = bundleProcessor.getStateTracker();
+ Thread trackedTread = executionStateTracker.getTrackedThread();
+ if (trackedTread != null) {
+ bundleStates.add(
+ new BundleState(
+ instruction,
+ trackedTread.getName(),
+ executionStateTracker.getMillisSinceLastTransition()));
+ }
+ }
+ });
+ bundleStates.stream()
+ // reverse sort active bundle by time since last transition.
+ .sorted(Comparator.comparing(BundleState::getTimeSinceTransition).reversed())
+ .limit(10) // only keep top 10
+ .forEachOrdered(
+ bundleState -> {
+ activeBundlesState.add(
+ String.format("---- Instruction %s ----", bundleState.getInstruction()));
+ activeBundlesState.add(
+ String.format("Tracked thread: %s", bundleState.getTrackedThreadName()));
+ activeBundlesState.add(
+ String.format(
+ "Time since transition: %.2f seconds%n",
+ bundleState.getTimeSinceTransition() / 1000.0));
+ });
+ }
+ return activeBundlesState.toString();
+ }
+
+ private class InboundObserver implements StreamObserver<BeamFnApi.WorkerStatusRequest> {
+ @Override
+ public void onNext(WorkerStatusRequest workerStatusRequest) {
+ StringJoiner status = new StringJoiner("\n");
+ status.add(getMemoryUsage());
+ status.add("\n");
+ status.add(getActiveProcessBundleState());
+ status.add("\n");
+ status.add(getThreadDump());
+ outboundObserver.onNext(
+ WorkerStatusResponse.newBuilder()
+ .setId(workerStatusRequest.getId())
+ .setStatusInfo(status.toString())
+ .build());
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ LOG.error("Error getting SDK harness status", t);
+ outboundObserver.onError(t);
Review comment:
I think it would make sense to just log and not call onError on the outboundObserver
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r610770920
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1p36p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p36p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
+ private final StreamObserver<WorkerStatusResponse> outboundObserver;
+ private final BundleProcessorCache processBundleCache;
+ private static final Logger LOG = LoggerFactory.getLogger(BeamFnStatusClient.class);
+ private final MemoryMonitor memoryMonitor;
+
+ public BeamFnStatusClient(
+ ApiServiceDescriptor apiServiceDescriptor,
+ Function<ApiServiceDescriptor, ManagedChannel> channelFactory,
+ BundleProcessorCache processBundleCache,
+ PipelineOptions options) {
+ BeamFnWorkerStatusGrpc.BeamFnWorkerStatusStub stub =
+ BeamFnWorkerStatusGrpc.newStub(channelFactory.apply(apiServiceDescriptor));
+ stub.workerStatus(new InboundObserver());
+ this.outboundObserver = stub.workerStatus(new InboundObserver());
Review comment:
Good catch. Fixed
--
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:
users@infra.apache.org
[GitHub] [beam] amaliujia commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r599847539
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/BeamFnStatusClient.java
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.fn.harness.status;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.Function;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessor;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler.BundleProcessorCache;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusRequest;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.WorkerStatusResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.ManagedChannel;
+import org.apache.beam.vendor.grpc.v1p26p0.io.grpc.stub.StreamObserver;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeamFnStatusClient {
Review comment:
For Java SDK harness, I think memory information is useful for debugging, especially relevant information about JVM GC
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles merged pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles merged pull request #14197:
URL: https://github.com/apache/beam/pull/14197
--
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:
users@infra.apache.org
[GitHub] [beam] kennknowles commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kennknowles commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-816035580
I am not certain if the Jenkins job or GitHub re-merges against current master where the problem should be alleviated.
--
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:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #14197:
URL: https://github.com/apache/beam/pull/14197#discussion_r603671579
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/status/MemoryMonitor.java
##########
@@ -0,0 +1,342 @@
+/*
+ * 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.fn.harness.status;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.util.concurrent.AtomicDouble;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A runnable which monitors a server for GC thrashing.
+ *
+ * <p>Note: Only one instance of this should be initialized per server and it should be done when
+ * the server starts running.
+ *
+ * <p>This runnable works as follows:
+ *
+ * <ul>
+ * <li>It wakes up periodically and determines how much time was spend on garbage collection since
+ * the last time it woke up.
+ * <li>If the time spent in garbage collection in the last period of time exceeds a certain
+ * threshold, that period is marked as "being in GC thrashing"
+ * <li>It keeps track of the GC thrashing status of the last few periods.
+ * <li>Every time the runnable's thread wakes up, it computes the ratio {@code (# monitored
+ * periods in GC thrashing) / (# monitored periods)}.
+ * <li>If this ratio exceeds a certain threshold, it is assumed that the server is in GC
+ * thrashing.
+ * </ul>
+ */
+public class MemoryMonitor implements Runnable {
Review comment:
Can we move the original class to a utility module and reuse the same class for both legacy worker and sdk harness?
--
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:
users@infra.apache.org
[GitHub] [beam] kileys commented on pull request #14197: [BEAM-11945] Add debug capture to SDK harness
Posted by GitBox <gi...@apache.org>.
kileys commented on pull request #14197:
URL: https://github.com/apache/beam/pull/14197#issuecomment-804544857
Run Java Examples on Dataflow Runner V2
--
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:
users@infra.apache.org