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/04/02 12:20:46 UTC

[GitHub] [beam] iemejia opened a new pull request #14409: [BEAM-11212] Display Beam Metrics in Spark History Server for Classic Runner too

iemejia opened a new pull request #14409:
URL: https://github.com/apache/beam/pull/14409


   R: @ibzib 


-- 
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] iemejia removed a comment on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia removed a comment on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812621903


   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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606220672



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/util/SparkCommon.java
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.spark.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.beam.runners.spark.SparkPipelineOptions;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.scheduler.EventLoggingListener;
+import org.apache.spark.scheduler.SparkListenerExecutorAdded;
+import org.apache.spark.scheduler.cluster.ExecutorInfo;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import scala.Tuple2;
+
+/** Common methods to build Spark specific objects used by different runners. */
+@Internal
+@SuppressWarnings({
+  "nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
+})
+public class SparkCommon {
+
+  /**
+   * Starts an EventLoggingListener to save Beam Metrics on Spark's History Server if event logging
+   * is enabled.
+   *
+   * @return The associated EventLoggingListener or null if it could not be started.
+   */
+  public static @Nullable EventLoggingListener startEventLoggingListener(
+      final JavaSparkContext jsc, SparkPipelineOptions pipelineOptions, long startTime) {
+    EventLoggingListener eventLoggingListener = null;
+    try {
+      if (jsc.getConf().getBoolean("spark.eventLog.enabled", false)) {

Review comment:
       This is the official Spark way to configure what the `eventLogEnabled` and `sparkHistoryDir` options were doing. So better to use these.




-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812677496


   Thanks @ibzib !


-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812513717


   Run Java Spark PortableValidatesRunner Batch


-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812551730


   Run Spark ValidatesRunner Java 11


-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812551626


   Run Spark 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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606220672



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/util/SparkCommon.java
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.spark.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.beam.runners.spark.SparkPipelineOptions;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.scheduler.EventLoggingListener;
+import org.apache.spark.scheduler.SparkListenerExecutorAdded;
+import org.apache.spark.scheduler.cluster.ExecutorInfo;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import scala.Tuple2;
+
+/** Common methods to build Spark specific objects used by different runners. */
+@Internal
+@SuppressWarnings({
+  "nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
+})
+public class SparkCommon {
+
+  /**
+   * Starts an EventLoggingListener to save Beam Metrics on Spark's History Server if event logging
+   * is enabled.
+   *
+   * @return The associated EventLoggingListener or null if it could not be started.
+   */
+  public static @Nullable EventLoggingListener startEventLoggingListener(
+      final JavaSparkContext jsc, SparkPipelineOptions pipelineOptions, long startTime) {
+    EventLoggingListener eventLoggingListener = null;
+    try {
+      if (jsc.getConf().getBoolean("spark.eventLog.enabled", false)) {

Review comment:
       This is the [official Spark way to configure](https://spark.apache.org/docs/latest/configuration.html#spark-ui) what the `eventLogEnabled` and `sparkHistoryDir` options were doing. So better to use these.




-- 
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] iemejia removed a comment on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia removed a comment on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812513614






-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812513614






-- 
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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606216057



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,18 +34,6 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
-  @Description("Set it to true if event logs should be saved to Spark History Server directory")

Review comment:
       Historically we avoid at all costs to introduce variables that are already defined as Spark Configurations, so these variables should come from the Spark configuration to avoid duplicated non synchronized configuration changes and confusion for end users.




-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812621903


   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] iemejia commented on pull request #14409: [BEAM-11212] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812507868






-- 
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] iemejia commented on pull request #14409: [BEAM-11212] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812508172


   Run Spark ValidatesRunner Java 11


-- 
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] iemejia merged pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia merged pull request #14409:
URL: https://github.com/apache/beam/pull/14409


   


-- 
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] iemejia commented on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812551825


   Run Java Spark PortableValidatesRunner Batch


-- 
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] ibzib commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
ibzib commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606329603



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkRunner.java
##########
@@ -246,17 +258,28 @@ public SparkPipelineResult run(final Pipeline pipeline) {
       result = new SparkPipelineResult.BatchMode(startPipeline, jsc);
     }
 
-    if (mOptions.getEnableSparkMetricSinks()) {
-      registerMetricsSource(mOptions.getAppName());
+    if (pipelineOptions.getEnableSparkMetricSinks()) {
+      registerMetricsSource(pipelineOptions.getAppName());
     }
 
     // it would have been better to create MetricsPusher from runner-core but we need
     // runner-specific
     // MetricsContainerStepMap
     MetricsPusher metricsPusher =
         new MetricsPusher(
-            MetricsAccumulator.getInstance().value(), mOptions.as(MetricsOptions.class), result);
+            MetricsAccumulator.getInstance().value(),
+            pipelineOptions.as(MetricsOptions.class),
+            result);
     metricsPusher.start();
+
+    if (eventLoggingListener != null && jsc != null) {

Review comment:
       I'm curious how `jsc` could be null here?

##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkRunner.java
##########
@@ -97,7 +102,7 @@
   private static final Logger LOG = LoggerFactory.getLogger(SparkRunner.class);
 
   /** Options used in this pipeline runner. */
-  private final SparkPipelineOptions mOptions;
+  private final SparkPipelineOptions pipelineOptions;

Review comment:
       +1 😄 

##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,18 +34,6 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
-  @Description("Set it to true if event logs should be saved to Spark History Server directory")

Review comment:
       Makes sense. 👍 




-- 
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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606216057



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,18 +34,6 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
-  @Description("Set it to true if event logs should be saved to Spark History Server directory")

Review comment:
       Historically we avoid if possible to introduce variables that are already defined as Spark Configurations, so these variables should come from the Spark configuration to avoid duplicated non synchronized configuration changes and confusion for end users.




-- 
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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606216057



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,18 +34,6 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
-  @Description("Set it to true if event logs should be saved to Spark History Server directory")

Review comment:
       Historically we avoid at all costs to introduce variables that are already resolved by Spark Configuration, so these variables should come from the Spark configuration to avoid duplicated non synchronized configuration changes.




-- 
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] iemejia commented on a change in pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14409:
URL: https://github.com/apache/beam/pull/14409#discussion_r606330533



##########
File path: runners/spark/src/main/java/org/apache/beam/runners/spark/SparkRunner.java
##########
@@ -246,17 +258,28 @@ public SparkPipelineResult run(final Pipeline pipeline) {
       result = new SparkPipelineResult.BatchMode(startPipeline, jsc);
     }
 
-    if (mOptions.getEnableSparkMetricSinks()) {
-      registerMetricsSource(mOptions.getAppName());
+    if (pipelineOptions.getEnableSparkMetricSinks()) {
+      registerMetricsSource(pipelineOptions.getAppName());
     }
 
     // it would have been better to create MetricsPusher from runner-core but we need
     // runner-specific
     // MetricsContainerStepMap
     MetricsPusher metricsPusher =
         new MetricsPusher(
-            MetricsAccumulator.getInstance().value(), mOptions.as(MetricsOptions.class), result);
+            MetricsAccumulator.getInstance().value(),
+            pipelineOptions.as(MetricsOptions.class),
+            result);
     metricsPusher.start();
+
+    if (eventLoggingListener != null && jsc != null) {

Review comment:
       It can't it would have definitely failed before but I am double checking just to be sure.




-- 
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] iemejia removed a comment on pull request #14409: [BEAM-11213] Display Beam Metrics in Spark History Server for Classic Runner too

Posted by GitBox <gi...@apache.org>.
iemejia removed a comment on pull request #14409:
URL: https://github.com/apache/beam/pull/14409#issuecomment-812507868






-- 
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