This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git
The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
new 78df8f751 refactor: change DataWorkCloudCustomExcludeFilter to
TypeExcludeFilter (#4127)
78df8f751 is described below
commit 78df8f751a81a21740febd04884fb43a3642bc47
Author: Jack Xu <[email protected]>
AuthorDate: Fri Feb 3 16:51:56 2023 +0800
refactor: change DataWorkCloudCustomExcludeFilter to TypeExcludeFilter
(#4127)
---
.../apache/linkis/DataWorkCloudApplication.java | 11 +---
.../conf/DataWorkCloudTypeExcludeFilter.java | 63 ++++++++++++++++++++++
.../linkis/computation/client/JobMetrics.scala | 24 ++++-----
.../spark/src/main/resources/log4j2.xml | 2 +-
4 files changed, 77 insertions(+), 23 deletions(-)
diff --git
a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/DataWorkCloudApplication.java
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/DataWorkCloudApplication.java
index 2425de98d..24024f20f 100644
---
a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/DataWorkCloudApplication.java
+++
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/DataWorkCloudApplication.java
@@ -23,7 +23,6 @@ import org.apache.linkis.common.conf.Configuration;
import org.apache.linkis.common.exception.LinkisException;
import org.apache.linkis.common.utils.Utils;
import org.apache.linkis.server.BDPJettyServerHelper;
-import org.apache.linkis.server.conf.DataWorkCloudCustomExcludeFilter;
import org.apache.linkis.server.conf.ServerConfiguration;
import org.apache.commons.lang3.StringUtils;
@@ -46,8 +45,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.CompositePropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;
@@ -66,15 +63,9 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.webapp.WebAppContext;
-@SpringBootApplication
+@SpringBootApplication(scanBasePackages = {"org.apache.linkis",
"com.webank.wedatasphere"})
@EnableDiscoveryClient
@RefreshScope
-@ComponentScan(
- basePackages = {"org.apache.linkis", "com.webank.wedatasphere"},
- excludeFilters =
- @ComponentScan.Filter(
- type = FilterType.CUSTOM,
- classes = {DataWorkCloudCustomExcludeFilter.class}))
public class DataWorkCloudApplication extends SpringBootServletInitializer {
private static final Log logger =
LogFactory.getLog(DataWorkCloudApplication.class);
diff --git
a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/conf/DataWorkCloudTypeExcludeFilter.java
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/conf/DataWorkCloudTypeExcludeFilter.java
new file mode 100644
index 000000000..861593d66
--- /dev/null
+++
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/conf/DataWorkCloudTypeExcludeFilter.java
@@ -0,0 +1,63 @@
+/*
+ * 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.linkis.server.conf;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.boot.context.TypeExcludeFilter;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+@Component
+public class DataWorkCloudTypeExcludeFilter extends TypeExcludeFilter {
+
+ private String[] excludePackages =
+
StringUtils.split(ServerConfiguration.BDP_SERVER_EXCLUDE_PACKAGES().getValue(),
",");
+
+ private String[] excludeClasses =
+
StringUtils.split(ServerConfiguration.BDP_SERVER_EXCLUDE_CLASSES().getValue(),
",");
+
+ private String[] excludeAnnotation =
+
StringUtils.split(ServerConfiguration.BDP_SERVER_EXCLUDE_ANNOTATION().getValue(),
",");
+
+ @Override
+ public boolean match(MetadataReader metadataReader, MetadataReaderFactory
metadataReaderFactory)
+ throws IOException {
+ String className = metadataReader.getClassMetadata().getClassName();
+
+ return Arrays.stream(excludePackages).anyMatch(className::startsWith)
+ || Arrays.stream(excludeClasses).anyMatch(className::equals)
+ || Arrays.stream(excludeAnnotation)
+ .anyMatch(
+ annotation ->
metadataReader.getAnnotationMetadata().hasAnnotation(annotation));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj != null) && (getClass() == obj.getClass());
+ }
+
+ @Override
+ public int hashCode() {
+ return getClass().hashCode();
+ }
+}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/computation/client/JobMetrics.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/computation/client/JobMetrics.scala
index e4b9236c7..b276a51e3 100644
---
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/computation/client/JobMetrics.scala
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/computation/client/JobMetrics.scala
@@ -21,9 +21,11 @@ import org.apache.linkis.common.utils.{ByteTimeUtils,
Logging}
import java.util
+import scala.collection.JavaConverters._
+
trait ClientMetrics {
- def getMetrics: Map[String, Any]
+ def getMetrics: Map[String, AnyRef]
def getMetricString: String
def printIt(): Unit
@@ -33,15 +35,13 @@ abstract class AbstractJobMetrics extends ClientMetrics
with Logging {
override def printIt(): Unit = logger.info(getMetricString)
}
-import scala.collection.convert.WrapAsScala._
-
class LinkisJobMetrics(taskId: String) extends AbstractJobMetrics {
private var clientSubmitTime: Long = 0
private var clientFinishedTime: Long = 0
private var clientGetJobInfoTime: Long = 0
private var clientFetchResultSetTime: Long = 0
- private val metricsMap = new util.HashMap[String, Any]
+ private val metricsMap = new util.HashMap[String, AnyRef]
def setClientSubmitTime(clientSubmitTime: Long): Unit =
this.clientSubmitTime = clientSubmitTime
@@ -54,19 +54,19 @@ class LinkisJobMetrics(taskId: String) extends
AbstractJobMetrics {
def addClientFetchResultSetTime(fetchResultSetTime: Long): Unit =
this.clientFetchResultSetTime = clientFetchResultSetTime
- def setLong(key: String, value: Long): Unit = metricsMap.put(key, value)
+ def setLong(key: String, value: Long): Unit = metricsMap.put(key, value:
java.lang.Long)
def addLong(key: String, value: Long): Unit = {
val v = if (metricsMap.containsKey(key))
metricsMap.get(key).asInstanceOf[Long] else 0
- setLong(key, value + v)
+ setLong(key, value + v: java.lang.Long)
}
- override def getMetrics: Map[String, Any] = {
- metricsMap.put("clientSubmitTime", clientSubmitTime)
- metricsMap.put("clientFinishedTime", clientFinishedTime)
- metricsMap.put("clientGetJobInfoTime", clientGetJobInfoTime)
- metricsMap.put("clientFetchResultSetTime", clientFetchResultSetTime)
- metricsMap.toMap
+ override def getMetrics: Map[String, AnyRef] = {
+ metricsMap.put("clientSubmitTime", clientSubmitTime: java.lang.Long)
+ metricsMap.put("clientFinishedTime", clientFinishedTime: java.lang.Long)
+ metricsMap.put("clientGetJobInfoTime", clientGetJobInfoTime:
java.lang.Long)
+ metricsMap.put("clientFetchResultSetTime", clientFetchResultSetTime:
java.lang.Long)
+ metricsMap.asScala.toMap
}
override def getMetricString: String =
diff --git a/linkis-engineconn-plugins/spark/src/main/resources/log4j2.xml
b/linkis-engineconn-plugins/spark/src/main/resources/log4j2.xml
index 4a4ea5d55..b02d5889c 100644
--- a/linkis-engineconn-plugins/spark/src/main/resources/log4j2.xml
+++ b/linkis-engineconn-plugins/spark/src/main/resources/log4j2.xml
@@ -27,7 +27,7 @@
<DefaultRolloverStrategy max="10"/>
</RollingFile>
- <File name="YarnAppIdOutputFile" append="true"
fileName="${env:LOG_DIRS}/yarnApp.log">
+ <File name="YarnAppIdOutputFile" append="true"
fileName="${env:LOG_DIRS:-logs}/yarnApp.log">
<RegexFilter regex=".* application .*" onMatch="ACCEPT"
onMismatch="DENY"/>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level]
[%-40t] %c{1.} (%L) [%M] - %msg%xEx%n"/>
</File>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]