You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/06/24 06:21:22 UTC
[incubator-linkis] branch dev-1.2.0 updated (3c95ac409 -> fe32f2896)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a change to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
from 3c95ac409 FIX [Bug] Linkis-computation-client failed to submit jobs (#2333)
new 45e7c01bc fix: fix #2314 and format some code
new cebc771ae fix: deprecated JavaLog and Logging's method, fix InstanceResource code not reach pr
new fe32f2896 style: fomat code
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitignore | 5 +-
.../org/apache/linkis/common/ServiceInstance.scala | 15 +--
.../org/apache/linkis/common/utils/JavaLog.scala | 73 +++-----------
.../org/apache/linkis/common/utils/LDAPUtils.scala | 6 +-
.../org/apache/linkis/common/utils/Logging.scala | 15 ++-
.../apache/linkis/common/utils/RefreshUtils.scala | 4 +-
.../org/apache/linkis/common/utils/Utils.scala | 108 +++++++++++----------
.../apache/linkis/common/utils/VariableUtils.scala | 7 +-
.../linkis/common/utils/ArrayUtilsTest.scala | 1 +
.../linkis/hadoop/common/conf/HadoopConf.scala | 2 +-
.../linkis/hadoop/common/utils/HDFSUtils.scala | 23 ++---
.../AbstractAuthenticationStrategy.scala | 5 +-
.../linkis/httpclient/config/ClientConfig.scala | 26 ++---
.../httpclient/discovery/AbstractDiscovery.scala | 33 +++----
.../linkis/httpclient/request/GetAction.scala | 8 +-
.../linkis/httpclient/request/HttpAction.scala | 8 --
.../linkis/httpclient/request/POSTAction.scala | 7 +-
.../httpclient/response/HashMapHttpResult.scala | 2 +-
.../apache/linkis/DataWorkCloudApplication.java | 1 +
.../org/apache/linkis/proxy/ProxyUserEntity.java | 2 +-
.../apache/linkis/server/utils/AopTargetUtils.java | 3 +-
.../linkis/server/BDPJettyServerHelper.scala | 16 +--
.../scala/org/apache/linkis/server/Message.scala | 45 +++++----
.../conf/DataWorkCloudCustomExcludeFilter.scala | 2 +-
.../linkis/server/conf/ServerConfiguration.scala | 18 ++--
.../scala/org/apache/linkis/server/package.scala | 28 +++---
.../apache/linkis/server/security/SSOUtils.scala | 12 +--
.../linkis/server/security/SecurityFilter.scala | 4 +-
.../linkis/mybatis/conf/MybatisConfiguration.java | 29 +++---
.../linkis/entrance/job/EntranceExecutionJob.java | 17 +++-
.../rm/service/RequestResourceService.scala | 4 +-
.../manager/common/entity/resource/Resource.scala | 6 +-
.../manager/common/utils/ResourceUtils.scala | 39 ++++----
.../hive/executor/HiveEngineConnExecutor.scala | 6 +-
.../jdbc/src/main/resources/log4j2.xml | 2 +-
.../linkis-configuration/src/test/rpcTest.scala | 2 +-
.../dws/discovery/DefaultConfigDiscovery.scala | 3 +-
37 files changed, 285 insertions(+), 302 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org
[incubator-linkis] 03/03: style: fomat code
Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
commit fe32f2896be104abcede41f099d3f3065411ed61
Author: Jack Xu <xu...@126.com>
AuthorDate: Thu Jun 23 11:15:55 2022 +0800
style: fomat code
---
.../linkis/mybatis/conf/MybatisConfiguration.java | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java b/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
index d58d01c23..d44731e7f 100644
--- a/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
+++ b/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
@@ -50,31 +50,24 @@ public class MybatisConfiguration {
CommonVars.apply("wds.linkis.server.mybatis.datasource.maxWait", 6000);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_TBERM =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.timeBetweenEvictionRunsMillis",
- 60000);
+ "wds.linkis.server.mybatis.datasource.timeBetweenEvictionRunsMillis", 60000);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_MEITM =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.minEvictableIdleTimeMillis",
- 300000);
+ "wds.linkis.server.mybatis.datasource.minEvictableIdleTimeMillis", 300000);
public static final CommonVars<String> BDP_SERVER_MYBATIS_DATASOURCE_VALIDATIONQUERY =
CommonVars.apply("wds.linkis.server.mybatis.datasource.validationQuery", "SELECT 1");
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTWHILEIDLE =
- CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testWhileIdle", Boolean.TRUE);
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.testWhileIdle", Boolean.TRUE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTONBORROW =
- CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testOnBorrow", Boolean.FALSE);
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.testOnBorrow", Boolean.FALSE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTONRETURN =
- CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testOnReturn", Boolean.FALSE);
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.testOnReturn", Boolean.FALSE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_POOLPREPAREDSTATEMENTS =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.poolPreparedStatements",
- Boolean.TRUE);
+ "wds.linkis.server.mybatis.datasource.poolPreparedStatements", Boolean.TRUE);
public static final CommonVars<Boolean> MYBATIS_DATASOURCE_REMOVE_ABANDONED_ENABLED =
- CommonVars.apply(
- "wds.linkis.server.mybatis.remove.abandoned.enabled", Boolean.TRUE);
+ CommonVars.apply("wds.linkis.server.mybatis.remove.abandoned.enabled", Boolean.TRUE);
public static final CommonVars<Integer> MYBATIS_DATASOURCE_REMOVE_ABANDONED_TIMEOUT =
CommonVars.apply("wds.linkis.server.mybatis.remove.abandoned.timeout", 300);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org
[incubator-linkis] 01/03: fix: fix #2314 and format some code
Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
commit 45e7c01bcd5bcba992c4861b2498a3b039f6c007
Author: Jack Xu <xu...@126.com>
AuthorDate: Tue Jun 21 18:31:16 2022 +0800
fix: fix #2314 and format some code
---
.gitignore | 5 +-
.../org/apache/linkis/common/ServiceInstance.scala | 15 +--
.../org/apache/linkis/common/utils/LDAPUtils.scala | 6 +-
.../org/apache/linkis/common/utils/Logging.scala | 2 +-
.../apache/linkis/common/utils/RefreshUtils.scala | 4 +-
.../org/apache/linkis/common/utils/Utils.scala | 108 +++++++++++----------
.../apache/linkis/common/utils/VariableUtils.scala | 8 +-
.../linkis/common/utils/ArrayUtilsTest.scala | 1 +
.../linkis/hadoop/common/conf/HadoopConf.scala | 2 +-
.../linkis/hadoop/common/utils/HDFSUtils.scala | 23 ++---
.../AbstractAuthenticationStrategy.scala | 5 +-
.../linkis/httpclient/config/ClientConfig.scala | 26 ++---
.../httpclient/discovery/AbstractDiscovery.scala | 33 +++----
.../linkis/httpclient/request/GetAction.scala | 8 +-
.../linkis/httpclient/request/HttpAction.scala | 8 --
.../linkis/httpclient/request/POSTAction.scala | 7 +-
.../httpclient/response/HashMapHttpResult.scala | 2 +-
.../apache/linkis/DataWorkCloudApplication.java | 1 +
.../org/apache/linkis/proxy/ProxyUserEntity.java | 2 +-
.../apache/linkis/server/utils/AopTargetUtils.java | 3 +-
.../linkis/server/BDPJettyServerHelper.scala | 16 +--
.../scala/org/apache/linkis/server/Message.scala | 45 +++++----
.../conf/DataWorkCloudCustomExcludeFilter.scala | 2 +-
.../linkis/server/conf/ServerConfiguration.scala | 18 ++--
.../scala/org/apache/linkis/server/package.scala | 28 +++---
.../apache/linkis/server/security/SSOUtils.scala | 12 +--
.../linkis/server/security/SecurityFilter.scala | 4 +-
.../linkis/entrance/job/EntranceExecutionJob.java | 17 +++-
.../manager/common/entity/resource/Resource.scala | 4 +-
.../hive/executor/HiveEngineConnExecutor.scala | 6 +-
.../jdbc/src/main/resources/log4j2.xml | 2 +-
.../linkis-configuration/src/test/rpcTest.scala | 2 +-
.../dws/discovery/DefaultConfigDiscovery.scala | 3 +-
33 files changed, 225 insertions(+), 203 deletions(-)
diff --git a/.gitignore b/.gitignore
index 6bbdb3426..a0dae0888 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,4 +26,7 @@ node_modules/
.mvn/wrapper/maven-wrapper.jar
dist/
out/
-target/
\ No newline at end of file
+target/
+
+# log folder
+logs/
\ No newline at end of file
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/ServiceInstance.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/ServiceInstance.scala
index 841ec4b76..311cdeb97 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/ServiceInstance.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/ServiceInstance.scala
@@ -21,10 +21,10 @@ package org.apache.linkis.common
class ServiceInstance {
private var applicationName: String = _
private var instance: String = _
- def setApplicationName(applicationName: String) = this.applicationName = applicationName
- def getApplicationName = applicationName
- def setInstance(instance: String) = this.instance = instance
- def getInstance = instance
+ def setApplicationName(applicationName: String): Unit = this.applicationName = applicationName
+ def getApplicationName: String = applicationName
+ def setInstance(instance: String): Unit = this.instance = instance
+ def getInstance: String = instance
def canEqual(other: Any): Boolean = other.isInstanceOf[ServiceInstance]
@@ -46,7 +46,7 @@ class ServiceInstance {
}
- override def toString = s"ServiceInstance($applicationName, $instance)"
+ override def toString: String = s"ServiceInstance($applicationName, $instance)"
}
object ServiceInstance {
def apply(applicationName: String, instance: String): ServiceInstance = {
@@ -56,6 +56,7 @@ object ServiceInstance {
serviceInstance
}
- def unapply(serviceInstance: ServiceInstance): Option[(String, String)] = if(serviceInstance != null)
- Some(serviceInstance.applicationName, serviceInstance.instance) else None
+ def unapply(serviceInstance: ServiceInstance): Option[(String, String)] = if (serviceInstance != null) {
+ Some(serviceInstance.applicationName, serviceInstance.instance)
+ } else None
}
\ No newline at end of file
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
index 39a661c62..c76730262 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
@@ -22,13 +22,11 @@ import java.util.Hashtable
import org.apache.linkis.common.conf.CommonVars
import javax.naming.Context
import javax.naming.ldap.InitialLdapContext
-import org.apache.commons.lang.StringUtils
-
-
+import org.apache.commons.lang3.StringUtils
object LDAPUtils extends Logging {
- val url = CommonVars("wds.linkis.ldap.proxy.url", "").getValue
+ val url = CommonVars("wds.linkis.ldap.proxy.url", "").getValue
val baseDN = CommonVars("wds.linkis.ldap.proxy.baseDN", "").getValue
val userNameFormat = CommonVars("wds.linkis.ldap.proxy.userNameFormat", "").getValue
def login(userID: String, password: String): Unit = {
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
index e01e89420..a761df81b 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
@@ -24,7 +24,7 @@ trait Logging {
protected lazy implicit val logger = LoggerFactory.getLogger(getClass)
- def trace(message: => String) = {
+ def trace(message: => String): Unit = {
if (logger.isTraceEnabled) {
logger.trace(message)
}
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/RefreshUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/RefreshUtils.scala
index f257f8595..0d1e39cbe 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/RefreshUtils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/RefreshUtils.scala
@@ -29,9 +29,9 @@ object RefreshUtils {
def registerFileRefresh(period: Long, file: String, deal: java.util.List[String] => Unit): Unit = {
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
val f = new File(file)
- var fileModifiedTime = if(f.exists()) f.lastModified() else 0
+ var fileModifiedTime = if (f.exists()) f.lastModified() else 0
override def run(): Unit = {
- if(!f.exists()) return
+ if (!f.exists()) return
if(f.lastModified() > fileModifiedTime) {
deal(FileUtils.readLines(f, Configuration.BDP_ENCODING.getValue))
fileModifiedTime = f.lastModified()
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
index 6e13ef90b..7c073010c 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Utils.scala
@@ -14,18 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package org.apache.linkis.common.utils
-import java.io.{BufferedReader, InputStreamReader}
-import java.net.InetAddress
-import java.util.concurrent.atomic.AtomicInteger
-import java.util.concurrent.{ScheduledThreadPoolExecutor, _}
+package org.apache.linkis.common.utils
-import org.apache.linkis.common.exception.{ErrorException, FatalException, LinkisCommonErrorException, WarnException}
import org.apache.commons.io.IOUtils
+import org.apache.linkis.common.exception.{ErrorException, FatalException, LinkisCommonErrorException, WarnException}
import org.slf4j.Logger
+import java.io.{BufferedReader, InputStreamReader}
+import java.net.InetAddress
+import java.util.concurrent.atomic.AtomicInteger
+import java.util.concurrent._
import scala.annotation.tailrec
import scala.collection.JavaConversions._
import scala.concurrent.duration.Duration
@@ -54,19 +53,19 @@ object Utils extends Logging {
}
}
- def tryThrow[T](tryOp: => T)(exception: Throwable => Throwable): T = tryCatch(tryOp){
+ def tryThrow[T](tryOp: => T)(exception: Throwable => Throwable): T = tryCatch(tryOp) {
t: Throwable => throw exception(t)
}
def tryFinally[T](tryOp: => T)(finallyOp: => Unit): T = try tryOp finally finallyOp
- def tryQuietly[T](tryOp: => T, catchOp: Throwable => Unit): T = tryCatch(tryOp){
+ def tryQuietly[T](tryOp: => T, catchOp: Throwable => Unit): T = tryCatch(tryOp) {
t =>
catchOp(t)
null.asInstanceOf[T]
}
- def tryAndWarn[T](tryOp: => T)(implicit log: Logger): T = tryCatch(tryOp){
+ def tryAndWarn[T](tryOp: => T)(implicit log: Logger): T = tryCatch(tryOp) {
case error: ErrorException =>
val errorMsg = s"error code(错误码): ${error.getErrCode}, Error message(错误信息): ${error.getDesc}."
log.error(errorMsg, error)
@@ -80,7 +79,7 @@ object Utils extends Logging {
null.asInstanceOf[T]
}
- def tryAndWarnMsg[T](tryOp: => T)(message: String)(implicit log: Logger): T = tryCatch(tryOp){
+ def tryAndWarnMsg[T](tryOp: => T)(message: String)(implicit log: Logger): T = tryCatch(tryOp) {
case error: ErrorException =>
log.warn(s"error code(错误码): ${error.getErrCode}, Error message(错误信息): ${error.getDesc}.")
log.warn(message, error)
@@ -94,7 +93,7 @@ object Utils extends Logging {
null.asInstanceOf[T]
}
- def tryAndError[T](tryOp: => T)(implicit log: Logger): T = tryCatch(tryOp){
+ def tryAndError[T](tryOp: => T)(implicit log: Logger): T = tryCatch(tryOp) {
case error: ErrorException =>
val errorMsg = s"error code(错误码): ${error.getErrCode}, Error message(错误信息): ${error.getDesc}."
log.error(errorMsg, error)
@@ -108,7 +107,7 @@ object Utils extends Logging {
null.asInstanceOf[T]
}
- def tryAndErrorMsg[T](tryOp: => T)(message: String)(implicit log: Logger): T = tryCatch(tryOp){
+ def tryAndErrorMsg[T](tryOp: => T)(message: String)(implicit log: Logger): T = tryCatch(tryOp) {
case error: ErrorException =>
log.error(s"error code(错误码): ${error.getErrCode}, Error message(错误信息): ${error.getDesc}.")
log.error(message, error)
@@ -121,12 +120,13 @@ object Utils extends Logging {
log.error(message, t)
null.asInstanceOf[T]
}
-
+
def sleepQuietly(mills: Long): Unit = tryQuietly(Thread.sleep(mills))
def threadFactory(threadName: String, isDaemon: Boolean = true): ThreadFactory = {
new ThreadFactory {
val num = new AtomicInteger(0)
+
override def newThread(r: Runnable): Thread = {
val t = new Thread(r)
t.setDaemon(isDaemon)
@@ -167,19 +167,21 @@ object Utils extends Logging {
def getComputerName: String = Utils.tryCatch(InetAddress.getLocalHost.getCanonicalHostName)(t => sys.env("COMPUTERNAME"))
/**
- * Checks if event has occurred during some time period. This performs an exponential backoff
- * to limit the poll calls.
- *
- * @param checkForEvent event to check, until it is true
- * @param atMost most wait time
- * @throws java.util.concurrent.TimeoutException throws this exception when it is timeout
- * @throws java.lang.InterruptedException throws this exception when it is interrupted
- * @return
- */
+ * Checks if event has occurred during some time period. This performs an exponential backoff
+ * to limit the poll calls.
+ *
+ * @param checkForEvent event to check, until it is true
+ * @param atMost most wait time
+ * @throws java.util.concurrent.TimeoutException throws this exception when it is timeout
+ * @throws java.lang.InterruptedException throws this exception when it is interrupted
+ * @return
+ */
@throws(classOf[TimeoutException])
@throws(classOf[InterruptedException])
final def waitUntil(checkForEvent: () => Boolean, atMost: Duration, radix: Int, maxPeriod: Long): Unit = {
- val endTime = try System.currentTimeMillis() + atMost.toMillis catch { case _: IllegalArgumentException => 0l }
+ val endTime = try System.currentTimeMillis() + atMost.toMillis catch {
+ case _: IllegalArgumentException => 0L
+ }
@tailrec
def aux(count: Int): Unit = {
@@ -202,67 +204,75 @@ object Utils extends Logging {
final def waitUntil(checkForEvent: () => Boolean, atMost: Duration): Unit = waitUntil(checkForEvent, atMost, 100, 2000)
/**
- * do not exec complex shell command with lots of output, may cause io blocking
- * @param commandLine shell command
- * @return
- */
+ * do not exec complex shell command with lots of output, may cause io blocking
+ *
+ * @param commandLine shell command
+ * @return
+ */
def exec(commandLine: Array[String]): String = exec(commandLine, -1)
/**
- * do not exec complex shell command with lots of output, may cause io blocking
- * @param commandLine shell command
- * @return
- */
+ * do not exec complex shell command with lots of output, may cause io blocking
+ *
+ * @param commandLine shell command
+ * @return
+ */
def exec(commandLine: List[String]): String = exec(commandLine, -1)
/**
- * do not exec complex shell command with lots of output, may cause io blocking
- * @param commandLine shell command
- * @param maxWaitTime max wait time
- * @return
- */
+ * do not exec complex shell command with lots of output, may cause io blocking
+ *
+ * @param commandLine shell command
+ * @param maxWaitTime max wait time
+ * @return
+ */
def exec(commandLine: Array[String], maxWaitTime: Long): String = exec(commandLine.toList, maxWaitTime)
/**
- * do not exec complex shell command with lots of output, may cause io blocking
- * @param commandLine shell command
- * @param maxWaitTime max wait time
- * @return
- */
+ * do not exec complex shell command with lots of output, may cause io blocking
+ *
+ * @param commandLine shell command
+ * @param maxWaitTime max wait time
+ * @return
+ */
def exec(commandLine: List[String], maxWaitTime: Long): String = {
val pb = new ProcessBuilder(commandLine)
pb.redirectErrorStream(true)
pb.redirectInput(ProcessBuilder.Redirect.PIPE)
val process = pb.start
val log = new BufferedReader(new InputStreamReader(process.getInputStream))
- val exitCode = if(maxWaitTime > 0) {
+ val exitCode = if (maxWaitTime > 0) {
val completed = process.waitFor(maxWaitTime, TimeUnit.MILLISECONDS)
- if(!completed) {
+ if (!completed) {
IOUtils.closeQuietly(log)
process.destroy()
throw new TimeoutException(s"exec timeout with ${ByteTimeUtils.msDurationToString(maxWaitTime)}!")
}
process.exitValue
- } else
- tryThrow(process.waitFor)(t => {process.destroy();IOUtils.closeQuietly(log);t})
+ } else {
+ tryThrow(process.waitFor)(t => {
+ process.destroy(); IOUtils.closeQuietly(log); t
+ })
+ }
val lines = log.lines().toArray
IOUtils.closeQuietly(log)
if (exitCode != 0) {
throw new LinkisCommonErrorException(0, s"exec failed with exit code: $exitCode, ${lines.mkString(". ")}")
}
- lines.mkString("\n")
+ lines.mkString("\n")
}
def addShutdownHook(hook: => Unit): Unit = ShutdownUtils.addShutdownHook(hook)
- def getClassInstance[T](className: String): T ={
+ def getClassInstance[T](className: String): T = {
Utils.tryThrow(
- Thread.currentThread.getContextClassLoader.loadClass(className).asInstanceOf[Class[T]].newInstance()) (t =>{
+ Thread.currentThread.getContextClassLoader.loadClass(className).asInstanceOf[Class[T]].newInstance())(t => {
error(s"Failed to instance: $className ", t)
throw t
})
}
+ @deprecated("use ByteTimeUtils.msDurationToString method")
def msDurationToString(ms: Long): String = {
val second = 1000
val minute = 60 * second
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
index f57637c24..926ecc796 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
@@ -222,7 +222,7 @@ object VariableUtils extends Logging {
var expression = name.trim
val varType = nameAndType.get(name.trim).orNull
if (varType == null) {
- logger.warn(s"Use undefined variables or use the set method: [$str](使用了未定义的变量或者使用了set方式:[$str])")
+ warn(s"Use undefined variables or use the set method: [$str](使用了未定义的变量或者使用了set方式:[$str])")
parseCode ++= codes(i - 1) ++ str
} else {
var res: String = varType.getValue
@@ -241,7 +241,7 @@ object VariableUtils extends Logging {
}
}
if (!expressionCache.contains(expression)) {
- logger.info(s"Variable expression [$str] = $res(变量表达式[$str] = $res)")
+ info(s"Variable expression [$str] = $res(变量表达式[$str] = $res)")
expressionCache += expression
}
parseCode ++= codes(i - 1) ++ res
@@ -302,13 +302,11 @@ object VariableUtils extends Logging {
}
}
case errRegex() =>
- logger.warn(s"The variable definition is incorrect:$str,if it is not used, it will not run the error, but it is recommended to use the correct specification to define")
+ warn(s"The variable definition is incorrect:$str,if it is not used, it will not run the error, but it is recommended to use the correct specification to define")
case _ =>
}
}
}
nameAndValue
}
-
-
}
diff --git a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala
index 4fc3069d2..c2e69c3af 100644
--- a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala
+++ b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Assertions._
import org.junit.jupiter.api.Test
class ArrayUtilsTest {
+
@Test private[utils] def testCopyArray() = {
val array = ArrayUtils.newArray[scala.Int](2, Array.emptyIntArray.getClass)
array(0) = 123
diff --git a/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/conf/HadoopConf.scala b/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/conf/HadoopConf.scala
index 40ffb9eaf..ed8538bb2 100644
--- a/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/conf/HadoopConf.scala
+++ b/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/conf/HadoopConf.scala
@@ -44,5 +44,5 @@ object HadoopConf {
val HDFS_ENABLE_CACHE_IDLE_TIME = CommonVars("wds.linkis.hadoop.hdfs.cache.idle.time", 3*60*1000).getValue
- val HDFS_ENABLE_CACHE_MAX_TIME = CommonVars("wds.linkis.hadoop.hdfs.cache.max.time", new TimeType("12h")).getValue.toLong
+ val HDFS_ENABLE_CACHE_MAX_TIME = CommonVars("wds.linkis.hadoop.hdfs.cache.max.time", new TimeType("12h")).getValue.toLong
}
diff --git a/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/utils/HDFSUtils.scala b/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/utils/HDFSUtils.scala
index 0fa2f2f27..bd75919e2 100644
--- a/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/utils/HDFSUtils.scala
+++ b/linkis-commons/linkis-hadoop-common/src/main/scala/org/apache/linkis/hadoop/common/utils/HDFSUtils.scala
@@ -17,21 +17,20 @@
package org.apache.linkis.hadoop.common.utils
-import java.io.File
-import java.nio.file.Paths
-import java.security.PrivilegedExceptionAction
-import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
-
-import org.apache.linkis.common.utils.{Logging, Utils}
-import org.apache.linkis.hadoop.common.conf.HadoopConf
-import org.apache.linkis.hadoop.common.conf.HadoopConf.{hadoopConfDir, _}
-import org.apache.linkis.hadoop.common.entity.HDFSFileSystemContainer
import org.apache.commons.io.IOUtils
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.security.UserGroupInformation
+import org.apache.linkis.common.utils.{Logging, Utils}
+import org.apache.linkis.hadoop.common.conf.HadoopConf
+import org.apache.linkis.hadoop.common.conf.HadoopConf._
+import org.apache.linkis.hadoop.common.entity.HDFSFileSystemContainer
+import java.io.File
+import java.nio.file.Paths
+import java.security.PrivilegedExceptionAction
+import java.util.concurrent.TimeUnit
import scala.collection.JavaConverters._
object HDFSUtils extends Logging {
@@ -119,7 +118,9 @@ object HDFSUtils extends Logging {
def createFileSystem(userName: String, conf: org.apache.hadoop.conf.Configuration): FileSystem =
getUserGroupInformation(userName)
.doAs(new PrivilegedExceptionAction[FileSystem] {
- def run = FileSystem.get(conf)
+ // scalastyle:off FileSystemGet
+ def run: FileSystem = FileSystem.get(conf)
+ // scalastyle:on FileSystemGet
})
def closeHDFSFIleSystem(fileSystem: FileSystem, userName: String): Unit = if (null != fileSystem && StringUtils.isNotBlank(userName)) {
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/authentication/AbstractAuthenticationStrategy.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/authentication/AbstractAuthenticationStrategy.scala
index b7e9082ec..a5abc7a13 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/authentication/AbstractAuthenticationStrategy.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/authentication/AbstractAuthenticationStrategy.scala
@@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap
import org.apache.linkis.httpclient.Client
import org.apache.linkis.httpclient.config.ClientConfig
import org.apache.linkis.httpclient.request.{Action, UserAction}
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.apache.http.HttpResponse
import org.apache.linkis.common.utils.Logging
@@ -41,8 +41,7 @@ abstract class AbstractAuthenticationStrategy extends AuthenticationStrategy wit
protected def getUser(requestAction: Action): String = requestAction match {
case _: AuthenticationAction => null
case authAction: UserAction => authAction.getUser
- case _ if StringUtils.isNotBlank(clientConfig.getAuthTokenKey) => clientConfig.getAuthTokenKey
- case _ => null
+ case _ => if (StringUtils.isNotBlank(clientConfig.getAuthTokenKey)) clientConfig.getAuthTokenKey else null
}
protected def getKey(requestAction: Action, serverUrl: String): String = {
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/config/ClientConfig.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/config/ClientConfig.scala
index f117d1bb1..2e8540fb0 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/config/ClientConfig.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/config/ClientConfig.scala
@@ -17,7 +17,7 @@
package org.apache.linkis.httpclient.config
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.utils.RetryHandler
import org.apache.linkis.httpclient.authentication.{AbstractAuthenticationStrategy, AuthenticationStrategy}
import org.apache.linkis.httpclient.loadbalancer.LoadBalancerStrategy
@@ -69,7 +69,7 @@ class ClientConfig private() {
}
}
- def getServerUrl = serverUrl
+ def getServerUrl: String = serverUrl
def getDefaultServerUrl: String = {
if (StringUtils.isNotBlank(serverUrl) && serverUrl.contains(HttpClientConstant.URL_SPLIT_TOKEN)) {
@@ -79,30 +79,30 @@ class ClientConfig private() {
}
}
- def isDiscoveryEnabled = discoveryEnabled
+ def isDiscoveryEnabled: Boolean = discoveryEnabled
- def getDiscoveryPeriod = discoveryPeriod
+ def getDiscoveryPeriod: Long = discoveryPeriod
- def getDiscoveryTimeUnit = discoveryTimeUnit
+ def getDiscoveryTimeUnit: TimeUnit = discoveryTimeUnit
- def isLoadbalancerEnabled = loadbalancerEnabled
+ def isLoadbalancerEnabled: Boolean = loadbalancerEnabled
- def getLoadbalancerStrategy = loadbalancerStrategy
+ def getLoadbalancerStrategy: LoadBalancerStrategy = loadbalancerStrategy
- def getAuthenticationStrategy = authenticationStrategy
+ def getAuthenticationStrategy: AuthenticationStrategy = authenticationStrategy
def getAuthTokenKey: String = authTokenKey
def getAuthTokenValue: String = authTokenValue
- def getConnectTimeout = connectTimeout
+ def getConnectTimeout: Long = connectTimeout
- def getReadTimeout = readTimeout
+ def getReadTimeout: Long = readTimeout
- def getMaxConnection = maxConnection
+ def getMaxConnection: Int = maxConnection
- def isRetryEnabled = retryEnabled
+ def isRetryEnabled: Boolean = retryEnabled
- def getRetryHandler = retryHandler
+ def getRetryHandler: RetryHandler = retryHandler
}
\ No newline at end of file
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
index 19a32156e..414e72789 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
@@ -21,15 +21,14 @@ import java.io.Closeable
import java.net.ConnectException
import java.util
import java.util.concurrent.ScheduledFuture
-
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.utils.{Logging, Utils}
import org.apache.linkis.httpclient.Client
import org.apache.linkis.httpclient.exception.DiscoveryException
import org.apache.http.HttpResponse
import org.apache.linkis.httpclient.config.HttpClientConstant
-import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
import scala.concurrent.duration.TimeUnit
@@ -64,19 +63,19 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
def getClient: Client = client
override def start(): Unit = {
- val delayTime = timeUnit.convert(timeUnit.toMillis(period) / 5, timeUnit)
+ val delayTime = if (period < 10) 1 else period / 5
discoveryFuture = startDiscovery()
heartbeatFuture = startHealthyCheck(delayTime)
unhealthyHeartbeatFuture = startUnHealthyCheck(delayTime)
}
def startHealthyCheck(delayTime: Long): ScheduledFuture[_] = {
- logger.info("start HealthyCheck thread")
+ info("start HealthyCheck thread")
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
override def run(): Unit = {
- serverInstances.toList.foreach { serverUrl =>
+ serverInstances.asScala.foreach { serverUrl =>
val action = getHeartbeatAction(serverUrl)
- logger.info("heartbeat to healthy gateway " + serverUrl)
+ info("heartbeat to healthy gateway " + serverUrl)
Utils.tryCatch(client.execute(action, 3000) match {
case heartbeat: HeartbeatResult =>
if (!heartbeat.isHealthy) {
@@ -92,15 +91,15 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
}
def startDiscovery(): ScheduledFuture[_] = {
- logger.info("start Discovery thread")
+ info("start Discovery thread")
client.execute(getHeartbeatAction(serverUrl), 3000) match {
case heartbeat: HeartbeatResult => if (!heartbeat.isHealthy) throw new DiscoveryException(s"connect to serverUrl $serverUrl failed! Reason: gateway server is unhealthy!")
- else discoveryListeners.foreach(_.onServerDiscovered(serverUrl))
+ else discoveryListeners.asScala.foreach(_.onServerDiscovered(serverUrl))
}
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
override def run(): Unit = Utils.tryAndWarn {
- logger.info("to discovery gateway" + serverUrl)
+ info("to discovery gateway" + serverUrl)
val serverUrls = discovery()
addServerInstances(serverUrls)
}
@@ -111,21 +110,21 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
logger.info("start UnHealthyCheck thread")
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
override def run(): Unit = {
- unhealthyServerInstances.toList.foreach { serverUrl =>
+ unhealthyServerInstances.asScala.foreach { serverUrl =>
val action = getHeartbeatAction(serverUrl)
logger.info("heartbeat to unhealthy gateway " + serverUrl)
Utils.tryCatch(client.execute(action, 3000) match {
case heartbeat: HeartbeatResult =>
if (heartbeat.isHealthy) {
unhealthyServerInstances synchronized unhealthyServerInstances.remove(serverUrl)
- discoveryListeners.foreach(_.onServerHealthy(serverUrl))
+ discoveryListeners.asScala.foreach(_.onServerHealthy(serverUrl))
serverInstances synchronized serverInstances.add(serverUrl)
} else if (serverInstances.contains(serverUrl)) serverInstances synchronized serverInstances.remove(serverUrl)
}) {
case _: ConnectException =>
unhealthyServerInstances synchronized unhealthyServerInstances.remove(serverUrl)
serverInstances synchronized serverInstances.remove(serverUrl)
- discoveryListeners.foreach(_.onServerUnconnected(serverUrl))
+ discoveryListeners.asScala.foreach(_.onServerUnconnected(serverUrl))
}
}
}
@@ -150,7 +149,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
}
def addUnhealthyServerInstances(unhealthyUrl: String): Unit = {
- logger.info(s"add ${unhealthyUrl} to unhealthy list ")
+ info(s"add ${unhealthyUrl} to unhealthy list ")
val updateUnhealthyUrl = if (serverInstances.contains(unhealthyUrl)) {
unhealthyUrl
} else if (serverInstances.contains(unhealthyUrl + HttpClientConstant.PATH_SPLIT_TOKEN)) {
@@ -159,10 +158,10 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
""
}
if (StringUtils.isBlank(updateUnhealthyUrl)) {
- logger.info(s"${unhealthyUrl} unhealthy url not exists")
+ info(s"${unhealthyUrl} unhealthy url not exists")
} else {
unhealthyServerInstances synchronized unhealthyServerInstances.add(updateUnhealthyUrl)
- discoveryListeners.foreach(_.onServerUnhealthy(updateUnhealthyUrl))
+ discoveryListeners.asScala.foreach(_.onServerUnhealthy(updateUnhealthyUrl))
serverInstances synchronized serverInstances.remove(updateUnhealthyUrl)
}
}
@@ -173,7 +172,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
val parsedUrl = if (url.endsWith(HttpClientConstant.PATH_SPLIT_TOKEN)) url.substring(0, url.length - 1)
else url
serverInstances.add(parsedUrl)
- discoveryListeners.foreach(_.onServerDiscovered(parsedUrl))
+ discoveryListeners.asScala.foreach(_.onServerDiscovered(parsedUrl))
}
}
}
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/GetAction.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/GetAction.scala
index 231dd2599..58e160e9f 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/GetAction.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/GetAction.scala
@@ -19,19 +19,21 @@ package org.apache.linkis.httpclient.request
import java.net.URLEncoder
import java.util
-
import org.apache.linkis.common.conf.Configuration
-import scala.collection.JavaConversions
+import scala.collection.JavaConverters._
abstract class GetAction extends HttpAction {
private val queryParams: util.Map[String, Any] = new util.HashMap[String, Any]
+
def setParameter(key: String, value: Any): Unit = this.queryParams.put(key, value)
+
def getParameters: util.Map[String, Any] = queryParams
+
override def getRequestBody: String = {
val queryString = new StringBuilder
- JavaConversions.mapAsScalaMap(queryParams).foreach { case (k, v) =>
+ queryParams.asScala.foreach { case (k, v) =>
queryString.append(URLEncoder.encode(k, Configuration.BDP_ENCODING.getValue)).append("=")
.append(URLEncoder.encode(v.toString, Configuration.BDP_ENCODING.getValue)).append("&")
}
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/HttpAction.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/HttpAction.scala
index 07ed91aef..4678420fb 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/HttpAction.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/HttpAction.scala
@@ -34,14 +34,6 @@ trait HttpAction extends Action {
def getCookies: Array[Cookie] = cookies.toArray(new Array[Cookie](cookies.size()))
- /*def addCookie(cookie: javax.servlet.http.Cookie): Unit = {
- val newCookie: BasicClientCookie = new BasicClientCookie(cookie.getName, cookie.getValue)
- newCookie.setDomain(cookie.getDomain)
- newCookie.setPath(cookie.getPath)
- newCookie.setSecure(true)
- cookies.add(newCookie)
- }*/
-
def addCookie(cookie: Cookie): Unit = cookies.add(cookie)
def getURL: String
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/POSTAction.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/POSTAction.scala
index 84064a5da..32dc4dda4 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/POSTAction.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/request/POSTAction.scala
@@ -21,14 +21,15 @@ import java.util
abstract class POSTAction extends GetAction {
+
private val formParams: util.Map[String, String] = new util.HashMap[String, String]
private val payload: util.Map[String, Any] = new util.HashMap[String, Any]
- def setFormParam(key: String, value: Any): Unit = if(value != null) this.formParams.put(key, value.toString)
+ def setFormParam(key: String, value: Any): Unit = if (value != null) this.formParams.put(key, value.toString)
def getFormParams: util.Map[String, String] = formParams
- def addRequestPayload(key: String, value: Any): Unit = if(value != null) this.payload.put(key, value)
- def getRequestPayloads = payload
+ def addRequestPayload(key: String, value: Any): Unit = if (value != null) this.payload.put(key, value)
+ def getRequestPayloads: util.Map[String, Any] = payload
def getRequestPayload: String
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/response/HashMapHttpResult.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/response/HashMapHttpResult.scala
index 2b6492b86..f1fad7f05 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/response/HashMapHttpResult.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/response/HashMapHttpResult.scala
@@ -40,7 +40,7 @@ class HashMapHttpResult extends HttpResult {
def getResultMap: util.Map[String, Object] = resultMap
override def set(responseBody: String, statusCode: Int, url: String, contentType: String): Unit = {
- if(statusCode != 200) throw new HttpClientResultException(s"URL $url request failed! ResponseBody is $responseBody." )
+ if (statusCode != 200) throw new HttpClientResultException(s"URL $url request failed! ResponseBody is $responseBody." )
resultMap = JsonUtils.jackson.readValue(responseBody, classOf[util.Map[String, Object]])
this.responseBody = responseBody
this.statusCode = statusCode
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 43847cb9c..b6cf4263a 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
@@ -103,6 +103,7 @@ public class DataWorkCloudApplication extends SpringBootServletInitializer {
});
application.addListeners(
new ApplicationListener<RefreshScopeRefreshedEvent>() {
+ @Override
public void onApplicationEvent(RefreshScopeRefreshedEvent applicationEvent) {
logger.info("refresh config from config server...");
updateRemoteConfig();
diff --git a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/proxy/ProxyUserEntity.java b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/proxy/ProxyUserEntity.java
index a4e0a50f7..93296c13f 100644
--- a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/proxy/ProxyUserEntity.java
+++ b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/proxy/ProxyUserEntity.java
@@ -17,7 +17,7 @@
package org.apache.linkis.proxy;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
public class ProxyUserEntity {
diff --git a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/utils/AopTargetUtils.java b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/utils/AopTargetUtils.java
index e3a8e5c6d..d6f50737c 100644
--- a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/utils/AopTargetUtils.java
+++ b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/server/utils/AopTargetUtils.java
@@ -35,7 +35,8 @@ public class AopTargetUtils {
public static Object getTarget(Object proxy) throws Exception {
if (!AopUtils.isAopProxy(proxy)) {
- return proxy; // Not a proxy object(不是代理对象)
+ // Not a proxy object(不是代理对象)
+ return proxy;
}
if (AopUtils.isJdkDynamicProxy(proxy)) {
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/BDPJettyServerHelper.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/BDPJettyServerHelper.scala
index 725de15c6..1fbec4745 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/BDPJettyServerHelper.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/BDPJettyServerHelper.scala
@@ -60,7 +60,7 @@ private[linkis] object BDPJettyServerHelper extends Logging {
}
def addServerEventService(serverEventService: ServerEventService): Unit = {
- if(serverListenerEventBus != null) serverListenerEventBus.addListener(serverEventService)
+ if (serverListenerEventBus != null) serverListenerEventBus.addListener(serverEventService)
else services += serverEventService
}
@@ -84,8 +84,8 @@ private[linkis] object BDPJettyServerHelper extends Logging {
servletHolder.getRegistration.setMultipartConfig(multipartConfigElement)
val p = BDP_SERVER_RESTFUL_URI.getValue
- val restfulPath = if(p.endsWith("/*")) p
- else if(p.endsWith("/")) p + "*"
+ val restfulPath = if (p.endsWith("/*")) p
+ else if (p.endsWith("/")) p + "*"
else p + "/*"
webApp.addServlet(servletHolder, restfulPath)
@@ -95,17 +95,17 @@ private[linkis] object BDPJettyServerHelper extends Logging {
}
def setupControllerServer(webApp: ServletContextHandler): ControllerServer = {
- if(controllerServer != null) return controllerServer
+ if (controllerServer != null) return controllerServer
synchronized {
- if(controllerServer != null) return controllerServer
+ if (controllerServer != null) return controllerServer
createServerListenerEventBus()
controllerServer = new ControllerServer(serverListenerEventBus)
val maxTextMessageSize = BDP_SERVER_SOCKET_TEXT_MESSAGE_SIZE_MAX.getValue
val servletHolder = new ServletHolder(controllerServer)
servletHolder.setInitParameter("maxTextMessageSize", maxTextMessageSize)
val p = BDP_SERVER_SOCKET_URI.getValue
- val socketPath = if(p.endsWith("/*")) p
- else if(p.endsWith("/")) p + "*"
+ val socketPath = if (p.endsWith("/*")) p
+ else if (p.endsWith("/")) p + "*"
else p + "/*"
webApp.addServlet(servletHolder, socketPath)
controllerServer
@@ -144,7 +144,7 @@ private[linkis] object BDPJettyServerHelper extends Logging {
implicit val gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").serializeNulls
.registerTypeAdapter(classOf[java.lang.Double], new JsonSerializer[java.lang.Double] {
override def serialize(t: lang.Double, `type`: Type, jsonSerializationContext: JsonSerializationContext): JsonElement =
- if(t == t.longValue()) new JsonPrimitive(t.longValue()) else new JsonPrimitive(t)
+ if (t == t.longValue()) new JsonPrimitive(t.longValue()) else new JsonPrimitive(t)
}).create
implicit val jacksonJson = new ObjectMapper().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Message.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Message.scala
index 5ea0d4ae5..c1f8686af 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Message.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Message.scala
@@ -18,11 +18,11 @@
package org.apache.linkis.server
import java.util
-
import javax.servlet.http.HttpServletRequest
-import org.apache.commons.lang.StringUtils
-import org.apache.commons.lang.exception.ExceptionUtils
-import org.slf4j.LoggerFactory
+import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.exception.ExceptionUtils
+import org.apache.linkis.common.utils.Logging
+
import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes}
@@ -47,40 +47,39 @@ class Message(private var method: String,
this.method = method
this
}
- def setMessage(message: String) = {
+ def setMessage(message: String): Message = {
this.message = message
this
}
- def getMessage = message
+ def getMessage: String = message
def setMethod(method: String): Unit = this.method = method
- def getMethod = method
+ def getMethod: String = method
def setStatus(status: Int): Unit = this.status = status
- def getStatus = status
+ def getStatus: Int = status
def setData(data: util.HashMap[String, Object]): Unit = this.data = data
- def getData = data
+ def getData: util.HashMap[String, Object] = data
// def isSuccess = status == 0
// def isError = status != 0
- override def toString = s"Message($getMethod, $getStatus, $getData)"
+ override def toString: String = s"Message($getMethod, $getStatus, $getData)"
}
-object Message {
- private val logger = LoggerFactory.getLogger(getClass)
+object Message extends Logging {
def apply(method: String = null, status: Int = 0, message: String = null,
data: util.HashMap[String, Object] = new util.HashMap[String, Object]): Message = {
if (StringUtils.isEmpty(method)) {
Thread.currentThread().getStackTrace.find(_.getClassName.toLowerCase.endsWith("restfulapi")).foreach {
stack => {
- val httpRequest:HttpServletRequest=getCurrentHttpRequest
- if(httpRequest!=null){
- val pathInfo=httpRequest.getPathInfo;
- if(pathInfo!=null) {
- val method = if (pathInfo.startsWith("/")) "/api"+ pathInfo else "/api" + "/" + pathInfo
+ val httpRequest: HttpServletRequest = getCurrentHttpRequest
+ if (httpRequest!=null) {
+ val pathInfo = httpRequest.getPathInfo;
+ if (pathInfo!=null) {
+ val method = if (pathInfo.startsWith("/")) "/api" + pathInfo else "/api/" + pathInfo
return new Message(method, status, message, data)
- }else{
- logger.warn("get HttpServletRequest pathInfo is null,please check it!")
+ } else {
+ warn("get HttpServletRequest pathInfo is null,please check it!")
}
}
}
@@ -95,13 +94,13 @@ object Message {
}
def error(msg: String): Message = error(msg, null)
implicit def error(t: Throwable): Message = {
- Message(status = 1).setMessage(ExceptionUtils.getRootCauseMessage(t)) << ("stack", ExceptionUtils.getFullStackTrace(t))
+ Message(status = 1).setMessage(ExceptionUtils.getRootCauseMessage(t)) << ("stack", ExceptionUtils.getStackTrace(t))
}
implicit def error(e: (String, Throwable)): Message = error(e._1, e._2)
implicit def error(msg: String, t: Throwable): Message = {
- val message = Message(status = 1)
+ val message = Message(status = 1)
message.setMessage(msg)
- if(t != null) message << ("stack", ExceptionUtils.getFullStackTrace(t))
+ if(t != null) message << ("stack", ExceptionUtils.getStackTrace(t))
message
}
implicit def warn(msg: String): Message = {
@@ -124,7 +123,7 @@ object Message {
def noLogin(msg: String, t: Throwable): Message = {
val message = Message(status = -1)
message.setMessage(msg)
- if(t != null) message << ("stack", ExceptionUtils.getFullStackTrace(t))
+ if(t != null) message << ("stack", ExceptionUtils.getStackTrace(t))
message
}
def noLogin(msg: String): Message = noLogin(msg, null)
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/DataWorkCloudCustomExcludeFilter.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/DataWorkCloudCustomExcludeFilter.scala
index 9de27e214..9c7b74cda 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/DataWorkCloudCustomExcludeFilter.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/DataWorkCloudCustomExcludeFilter.scala
@@ -17,7 +17,7 @@
package org.apache.linkis.server.conf
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.springframework.core.`type`.classreading.{MetadataReader, MetadataReaderFactory}
import org.springframework.core.`type`.filter.TypeFilter
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
index 75df6d9f9..f600a6292 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
@@ -17,15 +17,15 @@
package org.apache.linkis.server.conf
-import java.io.File
-import java.lang.Boolean
-
+import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.conf.{CommonVars, Configuration, TimeType}
import org.apache.linkis.common.utils.{DESUtil, Logging, Utils}
import org.apache.linkis.server.exception.BDPInitServerException
-import org.apache.commons.lang3.StringUtils
import sun.misc.BASE64Encoder
+import java.io.File
+import java.lang
+
object ServerConfiguration extends Logging{
val BDP_SERVER_EXCLUDE_PACKAGES = CommonVars("wds.linkis.server.component.exclude.packages", "")
@@ -33,7 +33,7 @@ object ServerConfiguration extends Logging{
val BDP_SERVER_EXCLUDE_ANNOTATION = CommonVars("wds.linkis.server.component.exclude.annotation", "")
val BDP_SERVER_SPRING_APPLICATION_LISTENERS = CommonVars("wds.linkis.server.spring.application.listeners", "")
- val BDP_SERVER_VERSION = CommonVars("wds.linkis.server.version", "").getValue
+ val BDP_SERVER_VERSION: String = CommonVars("wds.linkis.server.version", "").getValue
if(StringUtils.isBlank(BDP_SERVER_VERSION)) {
throw new BDPInitServerException(10010, "DataWorkCloud service must set the version, please add property [[wds.linkis.server.version]] to properties file.")
}
@@ -65,19 +65,19 @@ object ServerConfiguration extends Logging{
val BDP_TEST_USER = CommonVars("wds.linkis.test.user", "")
val BDP_SERVER_HOME = CommonVars("wds.linkis.server.home", CommonVars("LINKIS_HOME", "").getValue)
- val BDP_SERVER_DISTINCT_MODE = CommonVars("wds.linkis.server.distinct.mode", new Boolean(true))
+ val BDP_SERVER_DISTINCT_MODE: CommonVars[lang.Boolean] = CommonVars("wds.linkis.server.distinct.mode", lang.Boolean.TRUE)
if (!BDP_SERVER_DISTINCT_MODE.getValue && StringUtils.isEmpty(BDP_SERVER_HOME.getValue)) {
throw new BDPInitServerException(11000, "wds.linkis.server.home或BDP_SERVER_HOME haven't set!")
}
- val BDP_SERVER_SOCKET_MODE = CommonVars("wds.linkis.server.socket.mode", new Boolean(false))
+ val BDP_SERVER_SOCKET_MODE: CommonVars[lang.Boolean] = CommonVars("wds.linkis.server.socket.mode", lang.Boolean.FALSE)
val BDP_SERVER_IDENT_STRING = CommonVars("wds.linkis.server.ident.string", "true")
val BDP_SERVER_SERVER_JETTY_NAME = CommonVars("wds.linkis.server.jetty.name", "")
val BDP_SERVER_ADDRESS = CommonVars("wds.linkis.server.address", Utils.getLocalHostname)
val BDP_SERVER_PORT = CommonVars("wds.linkis.server.port", 20303)
val BDP_SERVER_SECURITY_FILTER = CommonVars("wds.linkis.server.security.filter", "org.apache.linkis.server.security.SecurityFilter")
val BDP_SERVER_SECURITY_REFERER_VALIDATE = CommonVars("wds.linkis.server.security.referer.validate", false)
- val BDP_SERVER_SECURITY_SSL = CommonVars("wds.linkis.server.security.ssl", false)
+ val BDP_SERVER_SECURITY_SSL: CommonVars[Boolean] = CommonVars("wds.linkis.server.security.ssl", false)
val BDP_SERVER_SECURITY_SSL_EXCLUDE_PROTOCOLS = CommonVars("wds.linkis.server.security.ssl.excludeProtocols", "SSLv2,SSLv3")
val BDP_SERVER_SECURITY_SSL_KEYSTORE_PATH = CommonVars("wds.linkis.server.security.ssl.keystore.path",
new File(BDP_SERVER_HOME.getValue, "keystore").getPath)
@@ -88,7 +88,7 @@ object ServerConfiguration extends Logging{
"")
val BDP_SERVER_SERVER_CONTEXT_PATH = CommonVars("wds.linkis.server.context.path", "/")
- val BDP_SERVER_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION)
+ val BDP_SERVER_RESTFUL_URI: CommonVars[String] = CommonVars("wds.linkis.server.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION)
val BDP_SERVER_USER_URI = CommonVars("wds.linkis.server.user.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION + "/user")
val BDP_SERVER_RESTFUL_LOGIN_URI = CommonVars("wds.linkis.server.user.restful.login.uri", new File(BDP_SERVER_USER_URI.getValue, "login").getPath)
val BDP_SERVER_RESTFUL_PASS_AUTH_REQUEST_URI = CommonVars("wds.linkis.server.user.restful.uri.pass.auth", "").getValue.split(",")
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/package.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/package.scala
index 858b7e950..8abdad880 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/package.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/package.scala
@@ -18,17 +18,18 @@
package org.apache.linkis
import java.util
-
import org.apache.linkis.common.exception.{ErrorException, ExceptionManager, FatalException, WarnException}
import org.apache.linkis.common.utils.Utils
import org.apache.linkis.server.exception.{BDPServerErrorException, NonLoginException}
import org.apache.linkis.server.security.SecurityFilter
+
import javax.servlet.http.HttpServletRequest
-import org.apache.commons.lang.StringUtils
-import org.apache.commons.lang.exception.ExceptionUtils
+import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.exception.ExceptionUtils
import org.slf4j.Logger
-import scala.collection.{JavaConversions, mutable}
+import scala.collection.JavaConverters._
+import scala.collection.mutable
package object server {
@@ -40,8 +41,9 @@ package object server {
def validateFailed(message: String): Message = Message(status = 2).setMessage(message)
def validate[T](json: util.Map[String, T], keys: String*): Unit = {
- keys.foreach(k => if(!json.contains(k) || json.get(k) == null || StringUtils.isEmpty(json.get(k).toString))
- throw new BDPServerErrorException(11001, s"Verification failed, $k cannot be empty!(验证失败,$k 不能为空!)"))
+ keys.foreach(k => if (!json.contains(k) || json.get(k) == null || StringUtils.isEmpty(json.get(k).toString)) {
+ throw new BDPServerErrorException(11001, s"Verification failed, $k cannot be empty!(验证失败,$k 不能为空!)")
+ })
}
def error(message: String): Message = Message.error(message)
implicit def ok(msg: String): Message = Message.ok(msg)
@@ -53,7 +55,7 @@ package object server {
// case nonLogin: NonLoginException => Message.noLogin(msg = nonLogin.getMessage)
// case t => catchOp(t)
// }
- def catchMsg(tryOp: => Message)(msg: String)(implicit log: Logger): Message = Utils.tryCatch(tryOp){
+ def catchMsg(tryOp: => Message)(msg: String)(implicit log: Logger): Message = Utils.tryCatch(tryOp) {
case fatal: FatalException =>
log.error("Fatal Error, system exit...", fatal)
System.exit(fatal.getErrCode)
@@ -81,13 +83,15 @@ package object server {
case t =>
log.error(msg, t)
val errorMsg = ExceptionUtils.getRootCauseMessage(t)
- val message = if(StringUtils.isNotEmpty(errorMsg) && "operation failed(操作失败)" != msg) error(msg + "!the reason(原因):" + errorMsg)
- else if(StringUtils.isNotEmpty(errorMsg)) error(errorMsg) else error(msg)
+ val message = if (StringUtils.isNotEmpty(errorMsg) && "operation failed(操作失败)" != msg) error(msg + "!the reason(原因):" + errorMsg)
+ else if (StringUtils.isNotEmpty(errorMsg)) error(errorMsg) else error(msg)
message.data(EXCEPTION_MSG, ExceptionManager.unknownException(message.getMessage))
}
+
def catchIt(tryOp: => Message)(implicit log: Logger): Message = catchMsg(tryOp)("operation failed(操作失败)s")
- implicit def toScalaBuffer[T](list: util.List[T]): mutable.Buffer[T] = JavaConversions.asScalaBuffer(list)
- implicit def toScalaMap[K, V](map: util.Map[K, V]): mutable.Map[K, V] = JavaConversions.mapAsScalaMap(map)
+
+ implicit def toScalaBuffer[T](list: util.List[T]): mutable.Buffer[T] = list.asScala
+ implicit def toScalaMap[K, V](map: util.Map[K, V]): mutable.Map[K, V] = map.asScala
implicit def toJavaList[T](list: mutable.Buffer[T]): util.List[T] = {
val arrayList = new util.ArrayList[T]
list.foreach(arrayList.add)
@@ -98,11 +102,13 @@ package object server {
map.foreach(m => hashMap.put(m._1, m._2))
hashMap
}
+
implicit def toJavaMap[K, V](map: Map[K, V]): JMap[K, V] = {
val hashMap = new util.HashMap[K, V]()
map.foreach(m => hashMap.put(m._1, m._2))
hashMap
}
+
implicit def asString(mapWithKey: (util.Map[String, Object], String)): String = mapWithKey._1.get(mapWithKey._2).asInstanceOf[String]
implicit def getString(mapWithKey: (util.Map[String, String], String)): String = mapWithKey._1.get(mapWithKey._2)
implicit def asInt(map: util.Map[String, Object], key: String): Int = map.get(key).asInstanceOf[Int]
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
index 605f633fe..ae897bddf 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
@@ -24,7 +24,7 @@ import org.apache.linkis.common.utils.{Logging, RSAUtils, Utils}
import org.apache.linkis.server.conf.ServerConfiguration
import org.apache.linkis.server.exception.{IllegalUserTicketException, LoginExpireException, NonLoginException}
import javax.servlet.http.Cookie
-import org.apache.commons.lang.time.DateFormatUtils
+import org.apache.commons.lang3.time.DateFormatUtils
import scala.collection.JavaConverters._
object SSOUtils extends Logging {
@@ -58,11 +58,12 @@ object SSOUtils extends Logging {
)
private[security] def getUserAndLoginTime(userTicketId: String): Option[(String, Long)] = {
- ServerConfiguration.getUsernameByTicket(userTicketId).map { userAndLoginTime =>
- if(userAndLoginTime.indexOf(",") < 0) throw new IllegalUserTicketException(s"Illegal user token information(非法的用户token信息).")
+ ServerConfiguration.getUsernameByTicket(userTicketId).map { userAndLoginTime => {
+ if (userAndLoginTime.indexOf(",") < 0) throw new IllegalUserTicketException(s"Illegal user token information(非法的用户token信息).")
val index = userAndLoginTime.lastIndexOf(",")
(userAndLoginTime.substring(0, index), userAndLoginTime.substring(index + 1).toLong)
}
+ }
}
//Determine the unique ID by username and timestamp(通过用户名和时间戳,确定唯一ID)
@@ -127,7 +128,7 @@ object SSOUtils extends Logging {
def getLoginUser(getUserTicketId: String => Option[String]): Option[String] = getUserTicketId(USER_TICKET_ID_STRING).map { t =>
isTimeoutOrNot(t)
- getUserAndLoginTime(t).getOrElse(throw new IllegalUserTicketException( s"Illegal user token information(非法的用户token信息)."))._1
+ getUserAndLoginTime(t).getOrElse(throw new IllegalUserTicketException(s"Illegal user token information(非法的用户token信息)."))._1
}
def getLoginUsername(getUserTicketId: String => Option[String]): String = getLoginUser(getUserTicketId).getOrElse(throw new NonLoginException(s"You are not logged in, please login first(您尚未登录,请先登录!)"))
@@ -139,6 +140,7 @@ object SSOUtils extends Logging {
def updateLastAccessTime(getUserTicketId: String => Option[String]): Unit = getUserTicketId(USER_TICKET_ID_STRING).foreach(isTimeoutOrNot)
+ @throws(classOf[LoginExpireException])
private def isTimeoutOrNot(userTicketId: String): Unit = if (!userTicketIdToLastAccessTime.containsKey(userTicketId)) {
throw new LoginExpireException("You are not logged in, please login first!(您尚未登录,请先登录!)")
} else {
@@ -155,6 +157,4 @@ object SSOUtils extends Logging {
def getSessionTimeOut(): Long = sessionTimeout
-
-
}
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SecurityFilter.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SecurityFilter.scala
index 4588cca5b..169edb39f 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SecurityFilter.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SecurityFilter.scala
@@ -28,7 +28,7 @@ import org.apache.linkis.server.security.SSOUtils.sslEnable
import org.apache.linkis.server.{Message, _}
import javax.servlet._
import javax.servlet.http.{Cookie, HttpServletRequest, HttpServletResponse}
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
class SecurityFilter extends Filter {
@@ -120,8 +120,10 @@ class SecurityFilter extends Filter {
object SecurityFilter extends Logging {
private[linkis] val OTHER_SYSTEM_IGNORE_UM_USER = "dataworkcloud_rpc_user"
private[linkis] val ALLOW_ACCESS_WITHOUT_TIMEOUT = "dataworkcloud_inner_request"
+
def getLoginUserThrowsExceptionWhenTimeout(req: HttpServletRequest): Option[String] = Option(req.getCookies).flatMap(cs => SSOUtils.getLoginUser(cs))
.orElse(SSOUtils.getLoginUserIgnoreTimeout(key => Option(req.getHeader(key))).filter(_ == OTHER_SYSTEM_IGNORE_UM_USER))
+
def getLoginUser(req: HttpServletRequest): Option[String] = Utils.tryCatch(getLoginUserThrowsExceptionWhenTimeout(req)) {
case _: LoginExpireException =>
SSOUtils.getLoginUserIgnoreTimeout(key => Option(req.getCookies).flatMap(_.find(_.getName == key).map(_.getValue))).filter(user => user != OTHER_SYSTEM_IGNORE_UM_USER &&
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/job/EntranceExecutionJob.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/job/EntranceExecutionJob.java
index 3133f6280..bd3d681a3 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/job/EntranceExecutionJob.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/job/EntranceExecutionJob.java
@@ -18,11 +18,15 @@
package org.apache.linkis.entrance.job;
import org.apache.linkis.common.log.LogUtils;
-import org.apache.linkis.common.utils.Utils;
+import org.apache.linkis.common.utils.ByteTimeUtils;
import org.apache.linkis.entrance.exception.EntranceErrorCode;
import org.apache.linkis.entrance.exception.EntranceErrorException;
import org.apache.linkis.entrance.execute.EntranceJob;
-import org.apache.linkis.entrance.log.*;
+import org.apache.linkis.entrance.log.LogHandler;
+import org.apache.linkis.entrance.log.LogReader;
+import org.apache.linkis.entrance.log.LogWriter;
+import org.apache.linkis.entrance.log.WebSocketCacheLogReader;
+import org.apache.linkis.entrance.log.WebSocketLogWriter;
import org.apache.linkis.entrance.persistence.PersistenceManager;
import org.apache.linkis.governance.common.conf.GovernanceCommonConf;
import org.apache.linkis.governance.common.constant.job.JobRequestConstants;
@@ -47,7 +51,12 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import scala.Option;
@@ -313,7 +322,7 @@ public class EntranceExecutionJob extends EntranceJob implements LogHandler {
String runTime;
if (metricsMap.containsKey(TaskConstant.ENTRANCEJOB_COMPLETE_TIME)) {
runTime =
- Utils.msDurationToString(
+ ByteTimeUtils.msDurationToString(
(((Date) metricsMap.get(TaskConstant.ENTRANCEJOB_COMPLETE_TIME)))
.getTime()
- (((Date)
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
index 4642828b8..627924c82 100644
--- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
@@ -242,7 +242,7 @@ class LoadInstanceResource(val memory: Long, val cores: Int, val instances: Int)
case l: LoadResource => new LoadInstanceResource(l.memory, l.cores, 0)
case m: MemoryResource => new LoadInstanceResource(m.memory, 0, 0)
case c: CPUResource => new LoadInstanceResource(0, c.cores, 0)
- case d: DriverAndYarnResource => d.loadInstanceResource // yarn resource has special logic
+ case d: DriverAndYarnResource => d.loadInstanceResource // yarn resource has special logic
case _ => new LoadInstanceResource(Long.MaxValue, Integer.MAX_VALUE, Integer.MAX_VALUE)
}
@@ -285,7 +285,7 @@ class LoadInstanceResource(val memory: Long, val cores: Int, val instances: Int)
class InstanceResource(val instances: Int) extends CPUResource(instances) {
override protected def toResource(cores: Int): Resource = new InstanceResource(cores)
- override def toJson: String = s"Instance:$instances"
+ override def toJson: String = s"Instance: $instances"
override def toString: String = toJson
}
diff --git a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/executor/HiveEngineConnExecutor.scala b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/executor/HiveEngineConnExecutor.scala
index 53bf60169..f7af9cc24 100644
--- a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/executor/HiveEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/executor/HiveEngineConnExecutor.scala
@@ -18,7 +18,7 @@
package org.apache.linkis.engineplugin.hive.executor
import org.apache.linkis.common.exception.ErrorException
-import org.apache.linkis.common.utils.{Logging, Utils}
+import org.apache.linkis.common.utils.{ByteTimeUtils, Logging, Utils}
import org.apache.linkis.engineconn.computation.executor.execute.{ComputationExecutor, EngineExecutionContext}
import org.apache.linkis.engineconn.core.EngineConnObject
import org.apache.linkis.engineplugin.hive.cs.CSHiveHelper
@@ -198,8 +198,8 @@ class HiveEngineConnExecutor(id: Int,
// todo check uncleared context ?
return ErrorExecuteResponse(hiveResponse.getErrorMessage, hiveResponse.getException)
}
- engineExecutorContext.appendStdout(s"Time taken: ${Utils.msDurationToString(System.currentTimeMillis() - startTime)}, begin to fetch results.")
- LOG.info(s"$getId >> Time taken: ${Utils.msDurationToString(System.currentTimeMillis() - startTime)}, begin to fetch results.")
+ engineExecutorContext.appendStdout(s"Time taken: ${ByteTimeUtils.msDurationToString(System.currentTimeMillis() - startTime)}, begin to fetch results.")
+ LOG.info(s"$getId >> Time taken: ${ByteTimeUtils.msDurationToString(System.currentTimeMillis() - startTime)}, begin to fetch results.")
val fieldSchemas = if (hiveResponse.getSchema != null) hiveResponse.getSchema.getFieldSchemas
else if (driver.getSchema != null) driver.getSchema.getFieldSchemas
diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/log4j2.xml b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/log4j2.xml
index b1a39f3ab..83186732f 100644
--- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/log4j2.xml
+++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/log4j2.xml
@@ -18,7 +18,7 @@
<configuration status="error" monitorInterval="30">
<appenders>
- <RollingFile name="RollingFile" append="true" fileName="${env:LOG_DIRS}/stdout"
+ <RollingFile name="RollingFile" append="true" fileName="${env:LOG_DIRS:-logs}/stdout"
filePattern="${env:LOG_DIRS}/$${date:yyyy-MM}/linkis-log-%d{yyyy-MM-dd-hh}-%i.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%-40t] %c{1.} (%L) [%M] - %msg%xEx%n"/>
<Policies>
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/test/rpcTest.scala b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/test/rpcTest.scala
index df4eb9ceb..36845f176 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/test/rpcTest.scala
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/test/rpcTest.scala
@@ -21,7 +21,7 @@ import org.apache.linkis.configuration.service.CategoryService
object rpcTest {
def main(args: Array[String]): Unit = {
val categoryService = new CategoryService
- categoryService.createFirstCategory("easyide","null")
+ categoryService.createFirstCategory("easyide", "null")
}
}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/discovery/DefaultConfigDiscovery.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/discovery/DefaultConfigDiscovery.scala
index 6b3fdd3e4..6ab8f532d 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/discovery/DefaultConfigDiscovery.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/discovery/DefaultConfigDiscovery.scala
@@ -23,7 +23,7 @@ import org.apache.linkis.httpclient.config.HttpClientConstant
import org.apache.linkis.httpclient.discovery.{AbstractDiscovery, HeartbeatAction, HeartbeatResult}
import org.apache.linkis.httpclient.dws.request.DWSHeartbeatAction
import org.apache.linkis.httpclient.dws.response.DWSHeartbeatResult
-import org.apache.commons.lang.StringUtils
+import org.apache.commons.lang3.StringUtils
import org.apache.http.HttpResponse
class DefaultConfigDiscovery extends AbstractDiscovery {
@@ -49,5 +49,4 @@ class DefaultConfigDiscovery extends AbstractDiscovery {
case h: DWSHeartbeatAction => new DWSHeartbeatResult(response, h.serverUrl)
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org
[incubator-linkis] 02/03: fix: deprecated JavaLog and Logging's method, fix InstanceResource code not reach pr
Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
commit cebc771ae297793ccb133649ee7c520d80f97ade
Author: Jack Xu <xu...@126.com>
AuthorDate: Thu Jun 23 10:42:46 2022 +0800
fix: deprecated JavaLog and Logging's method, fix InstanceResource code not reach pr
---
.../org/apache/linkis/common/utils/JavaLog.scala | 73 +++++-----------------
.../org/apache/linkis/common/utils/Logging.scala | 13 +++-
.../apache/linkis/common/utils/VariableUtils.scala | 11 ++--
.../httpclient/discovery/AbstractDiscovery.scala | 24 +++----
.../linkis/mybatis/conf/MybatisConfiguration.java | 22 +++----
.../rm/service/RequestResourceService.scala | 4 +-
.../manager/common/entity/resource/Resource.scala | 2 +-
.../manager/common/utils/ResourceUtils.scala | 39 ++++++------
8 files changed, 78 insertions(+), 110 deletions(-)
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/JavaLog.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/JavaLog.scala
index c9787b7b2..b1352ea65 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/JavaLog.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/JavaLog.scala
@@ -14,76 +14,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
package org.apache.linkis.common.utils
import org.slf4j.LoggerFactory
-
+/**
+ * every define the logger by self
+ * this class is deprecated
+ */
+@deprecated("do not use this class for log")
class JavaLog {
- // if(!JavaLog.initialized) {
- // JavaLog.initLock synchronized {
- // if(!JavaLog.initialized) {
- // JavaLog.initializeLogging
- // JavaLog.initialized = true
- // }
- // }
- // }
+
+
protected implicit lazy val logger = LoggerFactory.getLogger(getClass)
def debug(message: Object): Unit = if (logger.isDebugEnabled && message != null) logger.debug(message.toString)
- def info(message: Object): Unit = if(logger.isInfoEnabled && message != null) logger.info(message.toString)
+ def info(message: Object): Unit = if (logger.isInfoEnabled && message != null) logger.info(message.toString)
- def info(message: Object, t: Throwable): Unit = if(logger.isInfoEnabled && message != null) logger.info(message.toString, t)
+ def info(message: Object, t: Throwable): Unit = if (logger.isInfoEnabled && message != null) logger.info(message.toString, t)
- def warn(message: Object): Unit = if(logger.isWarnEnabled && message != null) logger.warn(message.toString)
+ def warn(message: Object): Unit = if (logger.isWarnEnabled && message != null) logger.warn(message.toString)
- def warn(message: Object, t: Throwable): Unit = if(logger.isWarnEnabled && message != null) logger.warn(message.toString, t)
+ def warn(message: Object, t: Throwable): Unit = if (logger.isWarnEnabled && message != null) logger.warn(message.toString, t)
- def error(message: Object): Unit = if(logger.isErrorEnabled && message != null) logger.error(message.toString)
+ def error(message: Object): Unit = if (logger.isErrorEnabled && message != null) logger.error(message.toString)
- def error(message: Object, t: Throwable): Unit = if(logger.isErrorEnabled && message != null) logger.error(message.toString, t)
+ def error(message: Object, t: Throwable): Unit = if (logger.isErrorEnabled && message != null) logger.error(message.toString, t)
-}
-//private[utils] object JavaLog {
-// @volatile private var initialized = false
-// private val initLock = new Array[Byte](0)
-// Utils.tryQuietly {
-// val bridgeClass = Class.forName("org.slf4j.bridge.SLF4JBridgeHandler")
-// bridgeClass.getMethod("removeHandlersForRootLogger").invoke(null)
-// val installed = bridgeClass.getMethod("isInstalled").invoke(null).asInstanceOf[Boolean]
-// if (!installed) {
-// bridgeClass.getMethod("install").invoke(null)
-// }
-// }
-// if(!initialized) {
-// initLock synchronized {
-// if(!initialized) {
-// initializeLogging
-// initialized = true
-// }
-// }
-// }
-// private def initializeLogging: Unit = {
-// val binderClass = StaticLoggerBinder.getSingleton.getLoggerFactoryClassStr
-// val usingLog4j12 = "org.slf4j.impl.Log4jLoggerFactory".equals(binderClass)
-// if (usingLog4j12) {
-// val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
-// if (!log4j12Initialized) {
-// val defaultLogProps = System.getProperty("log4j.configuration", "log4j.properties")
-// var url = Thread.currentThread.getContextClassLoader.getResource(defaultLogProps)
-// if(url == null) {
-// if(!new File(defaultLogProps).exists()) {
-// System.err.println(s"BDP Server was unable to load $defaultLogProps.")
-// return
-// }
-// url = if(defaultLogProps.startsWith("file:/")) new URL(defaultLogProps)
-// else new URL("file:///" + defaultLogProps)
-// }
-// PropertyConfigurator.configure(url)
-// System.err.println(s"Using BDP Server's log4j profile: $defaultLogProps.")
-// }
-// }
-// }
-//}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
index a761df81b..0983d160a 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/Logging.scala
@@ -19,45 +19,56 @@ package org.apache.linkis.common.utils
import org.slf4j.LoggerFactory
-
+/**
+ * use the class's method will miss the real info line number, so deprecated all the method
+ * and this trait will be deprecated too
+ */
trait Logging {
protected lazy implicit val logger = LoggerFactory.getLogger(getClass)
+ @deprecated
def trace(message: => String): Unit = {
if (logger.isTraceEnabled) {
logger.trace(message)
}
}
+ @deprecated
def debug(message: => String): Unit = {
if (logger.isDebugEnabled) {
logger.debug(message)
}
}
+ @deprecated
def info(message: => String): Unit = {
if (logger.isInfoEnabled) {
logger.info(message)
}
}
+ @deprecated
def info(message: => String, t: Throwable): Unit = {
logger.info(message, t)
}
+ @deprecated
def warn(message: => String): Unit = {
logger.warn(message)
}
+ @deprecated
def warn(message: => String, t: Throwable): Unit = {
logger.warn(message, t)
}
+ @deprecated
def error(message: => String, t: Throwable): Unit = {
logger.error(message, t)
}
+ @deprecated
def error(message: => String): Unit = {
logger.error(message)
}
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
index 926ecc796..4c7de924b 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/VariableUtils.scala
@@ -217,18 +217,18 @@ object VariableUtils extends Logging {
val rightValue = ma.group(3)
if (name == null || name.trim.isEmpty) {
- throw new LinkisCommonErrorException(20041, s"[$str] replaced var is null")
+ throw new LinkisCommonErrorException(20041, s"[$str] replaced var is null")
} else {
var expression = name.trim
val varType = nameAndType.get(name.trim).orNull
if (varType == null) {
- warn(s"Use undefined variables or use the set method: [$str](使用了未定义的变量或者使用了set方式:[$str])")
+ logger.warn(s"Use undefined variables or use the set method: [$str](使用了未定义的变量或者使用了set方式:[$str])")
parseCode ++= codes(i - 1) ++ str
} else {
var res: String = varType.getValue
if (signal != null && !signal.trim.isEmpty) {
if (rightValue == null || rightValue.trim.isEmpty) {
- throw new LinkisCommonErrorException(20042, s"[$str] expression is not right, please check")
+ throw new LinkisCommonErrorException(20042, s"[$str] expression is not right, please check")
} else {
expression = expression + "_" + signal.trim + "_" + rightValue.trim
val rightToken = rightValue.trim
@@ -241,7 +241,7 @@ object VariableUtils extends Logging {
}
}
if (!expressionCache.contains(expression)) {
- info(s"Variable expression [$str] = $res(变量表达式[$str] = $res)")
+ logger.info(s"Variable expression [$str] = $res(变量表达式[$str] = $res)")
expressionCache += expression
}
parseCode ++= codes(i - 1) ++ res
@@ -257,7 +257,6 @@ object VariableUtils extends Logging {
}
-
/**
* Get user-defined variables and values
*
@@ -302,7 +301,7 @@ object VariableUtils extends Logging {
}
}
case errRegex() =>
- warn(s"The variable definition is incorrect:$str,if it is not used, it will not run the error, but it is recommended to use the correct specification to define")
+ logger.warn(s"The variable definition is incorrect:$str,if it is not used, it will not run the error, but it is recommended to use the correct specification to define")
case _ =>
}
}
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
index 414e72789..01b4be66b 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/discovery/AbstractDiscovery.scala
@@ -17,17 +17,17 @@
package org.apache.linkis.httpclient.discovery
-import java.io.Closeable
-import java.net.ConnectException
-import java.util
-import java.util.concurrent.ScheduledFuture
import org.apache.commons.lang3.StringUtils
+import org.apache.http.HttpResponse
import org.apache.linkis.common.utils.{Logging, Utils}
import org.apache.linkis.httpclient.Client
-import org.apache.linkis.httpclient.exception.DiscoveryException
-import org.apache.http.HttpResponse
import org.apache.linkis.httpclient.config.HttpClientConstant
+import org.apache.linkis.httpclient.exception.DiscoveryException
+import java.io.Closeable
+import java.net.ConnectException
+import java.util
+import java.util.concurrent.ScheduledFuture
import scala.collection.JavaConverters._
import scala.concurrent.duration.TimeUnit
@@ -70,12 +70,12 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
}
def startHealthyCheck(delayTime: Long): ScheduledFuture[_] = {
- info("start HealthyCheck thread")
+ logger.info("start HealthyCheck thread")
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
override def run(): Unit = {
serverInstances.asScala.foreach { serverUrl =>
val action = getHeartbeatAction(serverUrl)
- info("heartbeat to healthy gateway " + serverUrl)
+ logger.info("heartbeat to healthy gateway " + serverUrl)
Utils.tryCatch(client.execute(action, 3000) match {
case heartbeat: HeartbeatResult =>
if (!heartbeat.isHealthy) {
@@ -91,7 +91,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
}
def startDiscovery(): ScheduledFuture[_] = {
- info("start Discovery thread")
+ logger.info("start Discovery thread")
client.execute(getHeartbeatAction(serverUrl), 3000) match {
case heartbeat: HeartbeatResult => if (!heartbeat.isHealthy) throw new DiscoveryException(s"connect to serverUrl $serverUrl failed! Reason: gateway server is unhealthy!")
else discoveryListeners.asScala.foreach(_.onServerDiscovered(serverUrl))
@@ -99,7 +99,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
Utils.defaultScheduler.scheduleAtFixedRate(new Runnable {
override def run(): Unit = Utils.tryAndWarn {
- info("to discovery gateway" + serverUrl)
+ logger.info("to discovery gateway" + serverUrl)
val serverUrls = discovery()
addServerInstances(serverUrls)
}
@@ -149,7 +149,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
}
def addUnhealthyServerInstances(unhealthyUrl: String): Unit = {
- info(s"add ${unhealthyUrl} to unhealthy list ")
+ logger.info(s"add ${unhealthyUrl} to unhealthy list ")
val updateUnhealthyUrl = if (serverInstances.contains(unhealthyUrl)) {
unhealthyUrl
} else if (serverInstances.contains(unhealthyUrl + HttpClientConstant.PATH_SPLIT_TOKEN)) {
@@ -158,7 +158,7 @@ abstract class AbstractDiscovery extends Discovery with Closeable with Logging {
""
}
if (StringUtils.isBlank(updateUnhealthyUrl)) {
- info(s"${unhealthyUrl} unhealthy url not exists")
+ logger.info(s"${unhealthyUrl} unhealthy url not exists")
} else {
unhealthyServerInstances synchronized unhealthyServerInstances.add(updateUnhealthyUrl)
discoveryListeners.asScala.foreach(_.onServerUnhealthy(updateUnhealthyUrl))
diff --git a/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java b/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
index 69cde69bb..d58d01c23 100644
--- a/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
+++ b/linkis-commons/linkis-mybatis/src/main/java/org/apache/linkis/mybatis/conf/MybatisConfiguration.java
@@ -41,40 +41,40 @@ public class MybatisConfiguration {
"wds.linkis.server.mybatis.datasource.driver-class-name",
"com.mysql.jdbc.Driver");
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_INITIALSIZE =
- CommonVars.apply("wds.linkis.server.mybatis.datasource.initialSize", new Integer(1));
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.initialSize", 1);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_MINIDLE =
- CommonVars.apply("wds.linkis.server.mybatis.datasource.minIdle", new Integer(1));
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.minIdle", 1);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_MAXACTIVE =
- CommonVars.apply("wds.linkis.server.mybatis.datasource.maxActive", new Integer(20));
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.maxActive", 20);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_MAXWAIT =
- CommonVars.apply("wds.linkis.server.mybatis.datasource.maxWait", new Integer(6000));
+ CommonVars.apply("wds.linkis.server.mybatis.datasource.maxWait", 6000);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_TBERM =
CommonVars.apply(
"wds.linkis.server.mybatis.datasource.timeBetweenEvictionRunsMillis",
- new Integer(60000));
+ 60000);
public static final CommonVars<Integer> BDP_SERVER_MYBATIS_DATASOURCE_MEITM =
CommonVars.apply(
"wds.linkis.server.mybatis.datasource.minEvictableIdleTimeMillis",
- new Integer(300000));
+ 300000);
public static final CommonVars<String> BDP_SERVER_MYBATIS_DATASOURCE_VALIDATIONQUERY =
CommonVars.apply("wds.linkis.server.mybatis.datasource.validationQuery", "SELECT 1");
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTWHILEIDLE =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testWhileIdle", new Boolean(true));
+ "wds.linkis.server.mybatis.datasource.testWhileIdle", Boolean.TRUE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTONBORROW =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testOnBorrow", new Boolean(false));
+ "wds.linkis.server.mybatis.datasource.testOnBorrow", Boolean.FALSE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_TESTONRETURN =
CommonVars.apply(
- "wds.linkis.server.mybatis.datasource.testOnReturn", new Boolean(false));
+ "wds.linkis.server.mybatis.datasource.testOnReturn", Boolean.FALSE);
public static final CommonVars<Boolean> BDP_SERVER_MYBATIS_DATASOURCE_POOLPREPAREDSTATEMENTS =
CommonVars.apply(
"wds.linkis.server.mybatis.datasource.poolPreparedStatements",
- new Boolean(true));
+ Boolean.TRUE);
public static final CommonVars<Boolean> MYBATIS_DATASOURCE_REMOVE_ABANDONED_ENABLED =
CommonVars.apply(
- "wds.linkis.server.mybatis.remove.abandoned.enabled", new Boolean(true));
+ "wds.linkis.server.mybatis.remove.abandoned.enabled", Boolean.TRUE);
public static final CommonVars<Integer> MYBATIS_DATASOURCE_REMOVE_ABANDONED_TIMEOUT =
CommonVars.apply("wds.linkis.server.mybatis.remove.abandoned.timeout", 300);
}
diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/service/RequestResourceService.scala b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/service/RequestResourceService.scala
index 8714c3297..5b61ff789 100644
--- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/service/RequestResourceService.scala
+++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/service/RequestResourceService.scala
@@ -122,10 +122,10 @@ abstract class RequestResourceService(labelResourceService: LabelResourceService
requestResource match {
case m: MemoryResource =>
(RMErrorCode.DRIVER_MEMORY_INSUFFICIENT.getCode, RMErrorCode.DRIVER_MEMORY_INSUFFICIENT.getMessage)
- case c: CPUResource =>
- (RMErrorCode.DRIVER_CPU_INSUFFICIENT.getCode, RMErrorCode.DRIVER_CPU_INSUFFICIENT.getMessage)
case i: InstanceResource =>
(RMErrorCode.INSTANCES_INSUFFICIENT.getCode, RMErrorCode.INSTANCES_INSUFFICIENT.getMessage)
+ case c: CPUResource =>
+ (RMErrorCode.DRIVER_CPU_INSUFFICIENT.getCode, RMErrorCode.DRIVER_CPU_INSUFFICIENT.getMessage)
case l: LoadResource =>
val loadAvailable = availableResource.asInstanceOf[LoadResource]
if(l.cores > loadAvailable.cores) {
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
index 627924c82..ae899c3e7 100644
--- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/entity/resource/Resource.scala
@@ -96,8 +96,8 @@ object Resource extends Logging {
def getZeroResource(resource: Resource): Resource = resource match {
case m: MemoryResource => new MemoryResource(0)
- case c: CPUResource => new CPUResource(0)
case i: InstanceResource => new InstanceResource(0)
+ case c: CPUResource => new CPUResource(0)
case l: LoadResource => new LoadResource(0, 0)
case li: LoadInstanceResource => new LoadInstanceResource(0, 0, 0)
case yarn: YarnResource => new YarnResource(0, 0, 0)
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/utils/ResourceUtils.scala b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/utils/ResourceUtils.scala
index 8f8507afa..dbe561ec8 100644
--- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/utils/ResourceUtils.scala
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/scala/org/apache/linkis/manager/common/utils/ResourceUtils.scala
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
package org.apache.linkis.manager.common.utils
import org.apache.linkis.manager.common.entity.persistence.PersistenceResource
@@ -81,27 +81,27 @@ object ResourceUtils {
}
def getResourceTypeByResource(resource: Resource): ResourceType = resource match {
- case cpuResource: CPUResource => ResourceType.CPU
- case loadResource: LoadResource => ResourceType.Load
- case instanceResource: InstanceResource => ResourceType.Instance
- case loadInstanceResource: LoadInstanceResource => ResourceType.LoadInstance
- case yarnResource: YarnResource => ResourceType.Yarn
- case driverAndYarnResource: DriverAndYarnResource => ResourceType.DriverAndYarn
- case specialResource: SpecialResource => ResourceType.Special
+ case _: LoadResource => ResourceType.Load
+ case _: InstanceResource => ResourceType.Instance
+ case _: CPUResource => ResourceType.CPU
+ case _: LoadInstanceResource => ResourceType.LoadInstance
+ case _: YarnResource => ResourceType.Yarn
+ case _: DriverAndYarnResource => ResourceType.DriverAndYarn
+ case _: SpecialResource => ResourceType.Special
case _ => ResourceType.LoadInstance
}
- def convertTo(nodeResource: NodeResource, resourceType: ResourceType) : NodeResource = {
- if(nodeResource.getResourceType.equals(resourceType)) return nodeResource
- if(resourceType.equals(ResourceType.LoadInstance)){
- if(nodeResource.getResourceType.equals(ResourceType.DriverAndYarn)){
+ def convertTo(nodeResource: NodeResource, resourceType: ResourceType): NodeResource = {
+ if (nodeResource.getResourceType.equals(resourceType)) return nodeResource
+ if (resourceType.equals(ResourceType.LoadInstance)) {
+ if (nodeResource.getResourceType.equals(ResourceType.DriverAndYarn)) {
nodeResource.setResourceType(resourceType)
- if(nodeResource.getMaxResource != null) nodeResource.setMaxResource(nodeResource.getMaxResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
- if(nodeResource.getMinResource != null) nodeResource.setMinResource(nodeResource.getMinResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
- if(nodeResource.getUsedResource != null) nodeResource.setUsedResource(nodeResource.getUsedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
- if(nodeResource.getLockedResource != null) nodeResource.setLockedResource(nodeResource.getLockedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
- if(nodeResource.getExpectedResource != null) nodeResource.setExpectedResource(nodeResource.getExpectedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
- if(nodeResource.getLeftResource != null && nodeResource.getLeftResource.isInstanceOf[DriverAndYarnResource]){
+ if (nodeResource.getMaxResource != null) nodeResource.setMaxResource(nodeResource.getMaxResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
+ if (nodeResource.getMinResource != null) nodeResource.setMinResource(nodeResource.getMinResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
+ if (nodeResource.getUsedResource != null) nodeResource.setUsedResource(nodeResource.getUsedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
+ if (nodeResource.getLockedResource != null) nodeResource.setLockedResource(nodeResource.getLockedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
+ if (nodeResource.getExpectedResource != null) nodeResource.setExpectedResource(nodeResource.getExpectedResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
+ if (nodeResource.getLeftResource != null && nodeResource.getLeftResource.isInstanceOf[DriverAndYarnResource]) {
nodeResource.setLeftResource(nodeResource.getLeftResource.asInstanceOf[DriverAndYarnResource].loadInstanceResource)
}
return nodeResource
@@ -112,6 +112,7 @@ object ResourceUtils {
/**
* Get the proportion of left resources, and return the smallest CPU, memory, and instance
+ *
* @param leftResource
* @param maxResource
* @return
@@ -123,7 +124,7 @@ object ResourceUtils {
case leftLoadInstanceResource: LoadInstanceResource =>
maxResource match {
case maxLoadInstanceResource: LoadInstanceResource =>
- val cpuRate = if (maxLoadInstanceResource.cores > 0) (leftLoadInstanceResource.cores * 1.0F) / maxLoadInstanceResource.cores else 1F
+ val cpuRate = if (maxLoadInstanceResource.cores > 0) (leftLoadInstanceResource.cores * 1.0F) / maxLoadInstanceResource.cores else 1F
val memoryRate = if (maxLoadInstanceResource.memory > 0) (leftLoadInstanceResource.memory * 1.0F) / maxLoadInstanceResource.memory else 1F
val instanceRate = if (maxLoadInstanceResource.instances > 0) (leftLoadInstanceResource.instances * 1.0F) / maxLoadInstanceResource.instances else 1F
Math.min(Math.min(cpuRate, memoryRate), instanceRate)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org