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/08/31 10:12:38 UTC
[incubator-linkis] branch dev-1.3.1 updated: feat:Scala code format alarm clear in linkis-storage-script-dev-server (#3140)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new a53fc8aca feat:Scala code format alarm clear in linkis-storage-script-dev-server (#3140)
a53fc8aca is described below
commit a53fc8aca29ea3b7168957fd518f62da2997089b
Author: ruY <43...@users.noreply.github.com>
AuthorDate: Wed Aug 31 18:12:33 2022 +0800
feat:Scala code format alarm clear in linkis-storage-script-dev-server (#3140)
---
.../apache/linkis/filesystem/bml/BMLHelper.scala | 43 +++++++++++-----------
.../apache/linkis/filesystem/entity/FSInfo.scala | 2 +-
.../linkis/filesystem/service/FsService.scala | 16 ++++----
.../filesystem/validator/PathValidator.scala | 7 ++--
4 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/bml/BMLHelper.scala b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/bml/BMLHelper.scala
index b092bbba7..c269c2b35 100644
--- a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/bml/BMLHelper.scala
+++ b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/bml/BMLHelper.scala
@@ -27,7 +27,7 @@ import java.io.{ByteArrayInputStream, InputStream}
import java.util
import java.util.UUID
-import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
@Component
class BMLHelper {
@@ -38,9 +38,9 @@ class BMLHelper {
val resource: BmlUploadResponse = client.uploadResource(userName, fileName, inputStream)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80021)
val map = new util.HashMap[String, Object]
- map += "resourceId" -> resource.resourceId
- map += "version" -> resource.version
- }
+ map.asScala += "resourceId" -> resource.resourceId
+ map.asScala += "version" -> resource.version
+ }.asJava
def upload(
userName: String,
@@ -53,9 +53,9 @@ class BMLHelper {
client.uploadShareResource(userName, projectName, fileName, inputStream)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80021)
val map = new util.HashMap[String, Object]
- map += "resourceId" -> resource.resourceId
- map += "version" -> resource.version
- }
+ map.asScala += "resourceId" -> resource.resourceId
+ map.asScala += "version" -> resource.version
+ }.asJava
def upload(
userName: String,
@@ -66,9 +66,9 @@ class BMLHelper {
val resource: BmlUploadResponse = client.uploadResource(userName, fileName, inputStream)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80021)
val map = new util.HashMap[String, Object]
- map += "resourceId" -> resource.resourceId
- map += "version" -> resource.version
- }
+ map.asScala += "resourceId" -> resource.resourceId
+ map.asScala += "version" -> resource.version
+ }.asJava
def update(
userName: String,
@@ -80,9 +80,9 @@ class BMLHelper {
client.updateShareResource(userName, resourceId, "", inputStream)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80022)
val map = new util.HashMap[String, Object]
- map += "resourceId" -> resource.resourceId
- map += "version" -> resource.version
- }
+ map.asScala += "resourceId" -> resource.resourceId
+ map.asScala += "version" -> resource.version
+ }.asJava
def update(userName: String, resourceId: String, content: String): util.Map[String, Object] = {
val inputStream = new ByteArrayInputStream(content.getBytes("utf-8"))
@@ -95,9 +95,9 @@ class BMLHelper {
)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80022)
val map = new util.HashMap[String, Object]
- map += "resourceId" -> resource.resourceId
- map += "version" -> resource.version
- }
+ map.asScala += "resourceId" -> resource.resourceId
+ map.asScala += "version" -> resource.version
+ }.asJava
def query(userName: String, resourceId: String, version: String): util.Map[String, Object] = {
val client: BmlClient = createBMLClient(userName)
@@ -106,16 +106,17 @@ class BMLHelper {
else resource = client.downloadShareResource(userName, resourceId, version)
if (!resource.isSuccess) throw WorkspaceExceptionManager.createException(80023)
val map = new util.HashMap[String, Object]
- map += "path" -> resource.fullFilePath
- map += "stream" -> resource.inputStream
- }
+ map.asScala += "path" -> resource.fullFilePath
+ map.asScala += "stream" -> resource.inputStream
+ }.asJava
private def inputstremToString(inputStream: InputStream): String =
scala.io.Source.fromInputStream(inputStream).mkString
- private def createBMLClient(userName: String): BmlClient = if (userName == null)
+ private def createBMLClient(userName: String): BmlClient = if (userName == null) {
BmlClientFactory.createBmlClient()
- else
+ } else {
BmlClientFactory.createBmlClient(userName)
+ }
}
diff --git a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/entity/FSInfo.scala b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/entity/FSInfo.scala
index 8c8b470aa..c5e7a6443 100644
--- a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/entity/FSInfo.scala
+++ b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/entity/FSInfo.scala
@@ -26,7 +26,7 @@ class FSInfo(
var lastAccessTime: Long = System.currentTimeMillis()
) {
- def timeout = System
+ def timeout: Boolean = System
.currentTimeMillis() - lastAccessTime > (StorageConfiguration.IO_FS_EXPIRE_TIME.getValue - 120 * 1000)
}
diff --git a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/service/FsService.scala b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/service/FsService.scala
index a5e0def50..574953ce0 100644
--- a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/service/FsService.scala
+++ b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/service/FsService.scala
@@ -30,7 +30,7 @@ import org.springframework.stereotype.Service
import java.util.concurrent.{Callable, ExecutionException, FutureTask, TimeoutException, TimeUnit}
-import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
import scala.collection.mutable.ArrayBuffer
@Service
@@ -52,7 +52,7 @@ class FsService extends Logging {
} else {
FsCache.fsInfo synchronized {
if (FsCache.fsInfo.get(user) == null) {
- FsCache.fsInfo += user -> ArrayBuffer(produceFSInfo(user, fsPath))
+ FsCache.fsInfo.asScala += user -> ArrayBuffer(produceFSInfo(user, fsPath))
}
}
// (43-49) Prevent file and hdfs from entering 37 lines at the same time, causing 51 lines to report the cross mark
@@ -65,7 +65,7 @@ class FsService extends Logging {
}
}
}
- FsCache.fsInfo(user).filter(_.fs.fsName().equals(fsPath.getFsType))(0).fs
+ FsCache.fsInfo.asScala(user).filter(_.fs.fsName().equals(fsPath.getFsType))(0).fs
}
@throws(classOf[WorkSpaceException])
@@ -95,12 +95,13 @@ class FsService extends Logging {
s"${user} gets the ${fsPath.getFsType} type filesystem using a total of ${end - start} milliseconds(${user}获取${fsPath.getFsType}类型的filesystem一共使用了${end - start}毫秒)"
)
}
- if (fs == null)
+ if (fs == null) {
throw WorkspaceExceptionManager.createException(
80002,
timeout.asInstanceOf[AnyRef],
timeout.asInstanceOf[AnyRef]
)
+ }
fs
}
@@ -113,14 +114,13 @@ class FsService extends Logging {
new FSInfo(user, fs, System.currentTimeMillis())
} catch {
// If rpc fails to get fs, for example, io-engine restarts or hangs.(如果rpc获取fs失败了 比如io-engine重启或者挂掉)
- case e: Exception => {
+ case e: Exception =>
logger.error("Requesting IO-Engine to initialize fileSystem failed", e)
// todo Clean up the cache(清理缓存 目前先遗留)
- /*FsCache.fsInfo.foreach{
+ /* FsCache.fsInfo.foreach{
case (_,list) =>list synchronized list.filter(f =>true).foreach(f =>list -=f)
- }*/
+ } */
throw WorkspaceExceptionManager.createException(80001)
- }
}
}
diff --git a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/validator/PathValidator.scala b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/validator/PathValidator.scala
index be1239d8b..da4481659 100644
--- a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/validator/PathValidator.scala
+++ b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/org/apache/linkis/filesystem/validator/PathValidator.scala
@@ -72,7 +72,7 @@ class PathValidator extends Logging {
var username: String = null
paramNames.indexOf("req") match {
case -1 =>
- case index: Int => {
+ case index: Int =>
val proxyUser = paramNames.indexOf("proxyUser")
if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) {
username =
@@ -81,12 +81,11 @@ class PathValidator extends Logging {
// 增加proxyuser的判断
username = args(proxyUser).toString
}
- }
}
username
}
- def checkPath(path: String, username: String) = {
+ def checkPath(path: String, username: String): Unit = {
// 校验path的逻辑
val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) +
username
@@ -110,7 +109,7 @@ class PathValidator extends Logging {
}
}
- def validate(args: Array[Object], paramNames: Array[String]) = {
+ def validate(args: Array[Object], paramNames: Array[String]): Unit = {
// 获取path:String,json:JsonNode,json:Map中的path 参数
val path: String = getPath(args, paramNames)
val username: String = getUserName(args, paramNames)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org