-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the loading mode of the legacy configuration
- Loading branch information
Showing
9 changed files
with
239 additions
and
106 deletions.
There are no files selected for viewing
51 changes: 33 additions & 18 deletions
51
...pps-server/src/main/scala/com/webank/wedatasphere/dss/apps/DSSAppsServerApplication.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,55 @@ | ||
/* | ||
* | ||
* * Copyright 2019 WeBank | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
/* | ||
* | ||
* * Copyright 2019 WeBank | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedatasphere.dss.apps | ||
|
||
import com.webank.wedatasphere.dss.common.utils.DSSMainHelper | ||
import org.apache.linkis.DataWorkCloudApplication | ||
import org.apache.linkis.common.conf.DSSConfiguration | ||
import org.apache.linkis.common.utils.{Logging, Utils} | ||
|
||
import java.io.File | ||
|
||
object DSSAppsServerApplication extends Logging { | ||
|
||
val userName: String = System.getProperty("user.name") | ||
val hostName: String = Utils.getComputerName | ||
|
||
val legacyServerConfigs: Array[String] = Array("dss-apiservice-server.properties", "dss-datapipe-server.properties", | ||
"dss-guide-server.properties", "dss-scriptis-server.properties") | ||
|
||
def main(args: Array[String]): Unit = { | ||
val serviceName = System.getProperty("serviceName")//ProjectConf.SERVICE_NAME.getValue | ||
val serviceName = System.getProperty("serviceName") //ProjectConf.SERVICE_NAME.getValue | ||
DSSMainHelper.formatPropertyFiles(serviceName) | ||
// 若dss-apps-server配置不存在,则加载先前配置 | ||
val serverConfFileURL = getClass.getClassLoader.getResource(serviceName + ".properties") | ||
if (serverConfFileURL == null || !new File(serverConfFileURL.getPath).exists) { | ||
logger.info(s"$serviceName.properties is not exists, now try to load legacy configs.") | ||
DSSConfiguration.addLegacyConfiguration(legacyServerConfigs) | ||
// server.port使用dss-scriptis-server.properties设置的值 | ||
DSSConfiguration.setSpringApplicationName("dss-apps-server") | ||
} | ||
val allArgs = args ++ DSSMainHelper.getExtraSpringOptions | ||
System.setProperty("hostName", hostName) | ||
System.setProperty("userName", userName) | ||
info(s"Ready to start $serviceName with args: ${allArgs.toList}.") | ||
println(s"Test Ready to start $serviceName with args: ${allArgs.toList}.") | ||
|
||
DataWorkCloudApplication.main(allArgs) | ||
} | ||
} |
70 changes: 69 additions & 1 deletion
70
dss-commons/dss-common/src/main/scala/org/apache/linkis/common/conf/DSSConfiguration.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,77 @@ | ||
package org.apache.linkis.common.conf | ||
|
||
import org.apache.commons.io.IOUtils | ||
import org.apache.linkis.common.utils.{Logging, Utils} | ||
|
||
import java.io.{File, FileInputStream, IOException, InputStream} | ||
import java.util | ||
import java.util.Properties | ||
import scala.collection.JavaConverters._ | ||
|
||
object DSSConfiguration extends Logging { | ||
|
||
object DSSConfiguration { | ||
private val MAPPER_LOCATIONS = "wds.linkis.server.mybatis.mapperLocations" | ||
private val TYPE_ALIASES_PACKAGE = "wds.linkis.server.mybatis.typeAliasesPackage" | ||
private val BASE_PACKAGE = "wds.linkis.server.mybatis.BasePackage" | ||
private val RESTFUL_SCAN_PACKAGES = "wds.linkis.server.restful.scan.packages" | ||
|
||
def getAllProperties: Properties = BDPConfiguration.properties | ||
|
||
def addLegacyConfiguration(serverConfs: Array[String]): Unit = { | ||
val config = new Properties | ||
val mapperLocationList = new util.ArrayList[String](); | ||
val typeAliasesPackageList = new util.ArrayList[String](); | ||
val basePackageList = new util.ArrayList[String](); | ||
val restfulScanPackagesList = new util.ArrayList[String](); | ||
|
||
serverConfs.foreach { serverConf => | ||
val serverConfFileURL = getClass.getClassLoader.getResource(serverConf) | ||
if (serverConfFileURL != null && new File(serverConfFileURL.getPath).exists) { | ||
logger.info( | ||
s"*********************** Notice: The DSS serverConf file is $serverConf ! ******************" | ||
) | ||
initConfig(config, serverConfFileURL.getPath) | ||
} else { | ||
logger.warn( | ||
s"**************** Notice: The DSS serverConf file $serverConf does not exist! *******************" | ||
) | ||
} | ||
} | ||
config.asScala.toMap.foreach { case (k, v) => | ||
k match { | ||
case MAPPER_LOCATIONS => mapperLocationList.add(v) | ||
case TYPE_ALIASES_PACKAGE => typeAliasesPackageList.add(v) | ||
case BASE_PACKAGE => basePackageList.add(v) | ||
case RESTFUL_SCAN_PACKAGES => restfulScanPackagesList.add(v) | ||
case _ => BDPConfiguration.set(k, v) | ||
} | ||
} | ||
BDPConfiguration.set(MAPPER_LOCATIONS, String.join(",", mapperLocationList)) | ||
BDPConfiguration.set(TYPE_ALIASES_PACKAGE, String.join(",", typeAliasesPackageList)) | ||
BDPConfiguration.set(BASE_PACKAGE, String.join(",", basePackageList)) | ||
BDPConfiguration.set(RESTFUL_SCAN_PACKAGES, String.join(",", restfulScanPackagesList)) | ||
} | ||
|
||
private def initConfig(config: Properties, filePath: String): Unit = { | ||
var inputStream: InputStream = null | ||
Utils.tryFinally { | ||
Utils.tryCatch { | ||
inputStream = new FileInputStream(filePath) | ||
config.load(inputStream) | ||
} { case e: IOException => | ||
logger.error("Can't load " + filePath, e) | ||
} | ||
} { | ||
IOUtils.closeQuietly(inputStream) | ||
} | ||
} | ||
|
||
def setConfig(key: String, value: String): Unit = { | ||
BDPConfiguration.set(key, value) | ||
} | ||
|
||
def setSpringApplicationName(name: String): Unit = { | ||
BDPConfiguration.set("spring.spring.application.name", name) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
dss-server/src/main/scala/com/webank/wedatasphere/dss/DSSServerApplication.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.webank.wedatasphere.dss | ||
|
||
import com.webank.wedatasphere.dss.common.utils.DSSMainHelper | ||
import org.apache.linkis.DataWorkCloudApplication | ||
import org.apache.linkis.common.conf.DSSConfiguration | ||
import org.apache.linkis.common.utils.{Logging, Utils} | ||
|
||
import java.io.File | ||
|
||
object DSSServerApplication extends Logging { | ||
|
||
val userName: String = System.getProperty("user.name") | ||
val hostName: String = Utils.getComputerName | ||
|
||
val legacyServerConfigs: Array[String] = Array("dss-framework-project-server.properties", "dss-framework-orchestrator-server.properties", | ||
"dss-workflow-server.properties", "dss-flow-execution-server.properties") | ||
|
||
def main(args: Array[String]): Unit = { | ||
val serviceName = System.getProperty("serviceName") //ProjectConf.SERVICE_NAME.getValue | ||
DSSMainHelper.formatPropertyFiles(serviceName) | ||
// 若dss-server配置不存在,则加载先前配置 | ||
val serverConfFileURL = getClass.getClassLoader.getResource(serviceName + ".properties") | ||
if (serverConfFileURL == null || !new File(serverConfFileURL.getPath).exists) { | ||
logger.info(s"$serviceName.properties is not exists, now try to load legacy configs.") | ||
DSSConfiguration.addLegacyConfiguration(legacyServerConfigs) | ||
DSSConfiguration.setSpringApplicationName("dss-server-dev") | ||
} | ||
val allArgs = args ++ DSSMainHelper.getExtraSpringOptions | ||
System.setProperty("hostName", hostName) | ||
System.setProperty("userName", userName) | ||
info(s"Ready to start $serviceName with args: ${allArgs.toList}.") | ||
println(s"Test Ready to start $serviceName with args: ${allArgs.toList}.") | ||
DataWorkCloudApplication.main(allArgs) | ||
} | ||
} |
40 changes: 0 additions & 40 deletions
40
dss-server/src/main/scala/com/webank/wedatasphere/dss/apps/DSSServerApplication.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.