This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new a0b4919ba7 Fix HopRun's level option don't work in beam engine
     new f4b293c425 Merge pull request #1536 from shlxue/beam
a0b4919ba7 is described below

commit a0b4919ba701014bd492a493aab89899a72ba507
Author: Shl Xue <[email protected]>
AuthorDate: Sat Jun 18 12:17:15 2022 +0800

    Fix HopRun's level option don't work in beam engine
---
 .../core/transform/TransformBatchTransform.java    |  4 +--
 .../beam/core/transform/TransformTransform.java    |  4 +--
 .../hop/beam/engines/BeamPipelineEngine.java       |  4 +++
 .../beam/engines/HopPipelineExecutionOptions.java  | 32 ++++++++++++++++++++++
 .../HopPipelineMetaToBeamPipelineConverter.java    |  9 ++++++
 .../java/org/apache/hop/beam/util/BeamConst.java   |  1 +
 6 files changed, 50 insertions(+), 4 deletions(-)

diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformBatchTransform.java
 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformBatchTransform.java
index 07bb18e36c..3ced71cefd 100644
--- 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformBatchTransform.java
+++ 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformBatchTransform.java
@@ -29,9 +29,9 @@ import org.apache.hop.beam.core.HopRow;
 import org.apache.hop.beam.core.shared.VariableValue;
 import org.apache.hop.beam.core.util.HopBeamUtil;
 import org.apache.hop.beam.core.util.JsonRowMeta;
+import org.apache.hop.beam.engines.HopPipelineExecutionOptions;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.exception.HopTransformException;
-import org.apache.hop.core.logging.LogLevel;
 import org.apache.hop.core.logging.LoggingObject;
 import org.apache.hop.core.metadata.SerializableMetadataProvider;
 import org.apache.hop.core.plugins.PluginRegistry;
@@ -424,7 +424,7 @@ public class TransformBatchTransform extends 
TransformTransform {
                   pipelineMeta,
                   Variables.getADefaultVariableSpace(),
                   new LoggingObject("apache-beam-transform"));
-          pipeline.setLogLevel(LogLevel.ERROR);
+          
pipeline.setLogLevel(context.getPipelineOptions().as(HopPipelineExecutionOptions.class).getLogLevel());
           pipeline.setMetadataProvider(pipelineMeta.getMetadataProvider());
 
           // Give transforms variables from above
diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformTransform.java
 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformTransform.java
index 280b9234da..7d1d7ce3e1 100644
--- 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformTransform.java
+++ 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/core/transform/TransformTransform.java
@@ -30,9 +30,9 @@ import org.apache.hop.beam.core.HopRow;
 import org.apache.hop.beam.core.shared.VariableValue;
 import org.apache.hop.beam.core.util.HopBeamUtil;
 import org.apache.hop.beam.core.util.JsonRowMeta;
+import org.apache.hop.beam.engines.HopPipelineExecutionOptions;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.exception.HopTransformException;
-import org.apache.hop.core.logging.LogLevel;
 import org.apache.hop.core.metadata.SerializableMetadataProvider;
 import org.apache.hop.core.plugins.PluginRegistry;
 import org.apache.hop.core.plugins.TransformPluginType;
@@ -421,7 +421,7 @@ public class TransformTransform extends 
PTransform<PCollection<HopRow>, PCollect
           // Create the transformation...
           //
           pipeline = new LocalPipelineEngine(pipelineMeta);
-          pipeline.setLogLevel(LogLevel.ERROR);
+          
pipeline.setLogLevel(context.getPipelineOptions().as(HopPipelineExecutionOptions.class).getLogLevel());
           pipeline.setMetadataProvider(pipelineMeta.getMetadataProvider());
 
           // Give transforms variables from above
diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/BeamPipelineEngine.java
 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/BeamPipelineEngine.java
index a9ad95c159..78a414d754 100644
--- 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/BeamPipelineEngine.java
+++ 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/BeamPipelineEngine.java
@@ -31,6 +31,7 @@ import org.apache.beam.sdk.metrics.MetricsFilter;
 import org.apache.beam.sdk.util.ThrowingSupplier;
 import org.apache.hop.beam.metadata.RunnerType;
 import org.apache.hop.beam.pipeline.HopPipelineMetaToBeamPipelineConverter;
+import org.apache.hop.beam.util.BeamConst;
 import org.apache.hop.core.IRowSet;
 import org.apache.hop.core.Result;
 import org.apache.hop.core.exception.HopException;
@@ -189,6 +190,9 @@ public abstract class BeamPipelineEngine extends Variables
         logChannel.logBasic(
             "Make sure Hop is correctly configured for more information see: 
https://hop.apache.org/manual/latest/pipeline/beam/spark-on-local-host.html";);
       }
+      if (logLevel != null) {
+        
beamEngineRunConfiguration.setVariable(BeamConst.STRING_LOCAL_PIPELINE_FLAG_LOG_LEVEL,
 logLevel.getCode());
+      }
 
       converter =
           new HopPipelineMetaToBeamPipelineConverter(
diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/HopPipelineExecutionOptions.java
 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/HopPipelineExecutionOptions.java
new file mode 100644
index 0000000000..54616c8c0c
--- /dev/null
+++ 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/engines/HopPipelineExecutionOptions.java
@@ -0,0 +1,32 @@
+/*
+ * 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.hop.beam.engines;
+
+import org.apache.beam.sdk.options.Default;
+import org.apache.beam.sdk.options.Description;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.hop.core.logging.LogLevel;
+
+public interface HopPipelineExecutionOptions extends PipelineOptions {
+
+  @Description("The log level of local pipeline engine, one of NONE, MINIMAL, 
BASIC, DETAILED, DEBUG, ROWLEVEL")
+  @Default.Enum("BASIC")
+  LogLevel getLogLevel();
+
+  void setLogLevel(LogLevel logLevel);
+}
diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/pipeline/HopPipelineMetaToBeamPipelineConverter.java
 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/pipeline/HopPipelineMetaToBeamPipelineConverter.java
index a48f3aded4..6db9c086d8 100644
--- 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/pipeline/HopPipelineMetaToBeamPipelineConverter.java
+++ 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/pipeline/HopPipelineMetaToBeamPipelineConverter.java
@@ -31,6 +31,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.hop.beam.core.HopRow;
 import org.apache.hop.beam.core.coder.HopRowCoder;
 import org.apache.hop.beam.core.util.HopBeamUtil;
+import org.apache.hop.beam.engines.HopPipelineExecutionOptions;
 import org.apache.hop.beam.engines.IBeamPipelineEngineRunConfiguration;
 import org.apache.hop.beam.metadata.RunnerType;
 import org.apache.hop.beam.pipeline.handler.BeamGenericTransformHandler;
@@ -43,6 +44,7 @@ import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.extension.ExtensionPoint;
 import org.apache.hop.core.logging.ILogChannel;
 import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.logging.LogLevel;
 import org.apache.hop.core.metadata.SerializableMetadataProvider;
 import org.apache.hop.core.plugins.JarCache;
 import org.apache.hop.core.row.IRowMeta;
@@ -196,6 +198,13 @@ public class HopPipelineMetaToBeamPipelineConverter<T 
extends IBeamPipelineEngin
       pipelineOptions.setJobName(sanitizeJobName(pipelineMeta.getName()));
 
       pipelineOptions.setRunner(runnerClass);
+      pipelineOptions
+          .as(HopPipelineExecutionOptions.class)
+          .setLogLevel(
+              LogLevel.getLogLevelForCode(
+                  pipelineRunConfiguration.getVariable(
+                      BeamConst.STRING_LOCAL_PIPELINE_FLAG_LOG_LEVEL)));
+
       Pipeline pipeline = Pipeline.create(pipelineOptions);
 
       pipeline.getCoderRegistry().registerCoderForClass(HopRow.class, new 
HopRowCoder());
diff --git 
a/plugins/engines/beam/src/main/java/org/apache/hop/beam/util/BeamConst.java 
b/plugins/engines/beam/src/main/java/org/apache/hop/beam/util/BeamConst.java
index b1ed6b1ec6..85f302459e 100644
--- a/plugins/engines/beam/src/main/java/org/apache/hop/beam/util/BeamConst.java
+++ b/plugins/engines/beam/src/main/java/org/apache/hop/beam/util/BeamConst.java
@@ -45,6 +45,7 @@ public class BeamConst {
 
   public static final String STRING_TRANSFORM_FLAG_BATCH = "Batch";
   public static final String STRING_TRANSFORM_FLAG_SINGLE_THREADED = 
"SingleThreaded";
+  public static final String STRING_LOCAL_PIPELINE_FLAG_LOG_LEVEL = "LogLevel";
 
   private static List<String[]> gcpWorkerCodeDescriptions =
       Arrays.asList(

Reply via email to