Skip to content

Commit

Permalink
Add the loading mode of the legacy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
HmhWz committed Apr 21, 2023
1 parent a3a9a73 commit 5b2f25b
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 106 deletions.
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)
}
}
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)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import com.webank.wedatasphere.dss.orchestrator.publish.entity.OrchestratorExpor
import com.webank.wedatasphere.dss.orchestrator.publish.{ExportDSSOrchestratorPlugin, ImportDSSOrchestratorPlugin}
import com.webank.wedatasphere.dss.orchestrator.server.service.{OrchestratorPluginService, OrchestratorService}
import org.apache.linkis.rpc.{Receiver, Sender}
import org.slf4j.{Logger, LoggerFactory}

import java.util
import scala.concurrent.duration.Duration


class DSSOrchestratorReceiver(orchestratorService: OrchestratorService, orchestratorPluginService: OrchestratorPluginService, orchestratorContext: DSSOrchestratorContext) extends Receiver {

private val LOGGER = LoggerFactory.getLogger(classOf[DSSOrchestratorReceiver])

override def receive(message: Any, sender: Sender): Unit = {}

override def receiveAndReply(message: Any, sender: Sender): Any = message match {
Expand Down Expand Up @@ -69,6 +72,7 @@ class DSSOrchestratorReceiver(orchestratorService: OrchestratorService, orchestr

case requestConversionOrchestration: RequestFrameworkConvertOrchestration =>
//发布调度,请注意
LOGGER.info("received requestConversionOrchestration, the class is: {}", requestConversionOrchestration)
orchestratorPluginService.convertOrchestration(requestConversionOrchestration)
case requestConversionOrchestrationStatus: RequestFrameworkConvertOrchestrationStatus =>
orchestratorPluginService.getConvertOrchestrationStatus(requestConversionOrchestrationStatus.getId)
Expand Down
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)
}
}

This file was deleted.

10 changes: 4 additions & 6 deletions sbin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,13 @@ status()
}

function setServerName(){
if [[ $PROJECT_NAME == *"project"* ]]; then
SERVER_NAME=dss-framework-project-server
elif [[ $PROJECT_NAME == *"orchestrator"* ]]; then
SERVER_NAME=dss-framework-orchestrator-server
elif [[ $PROJECT_NAME == *"dss-server"* ]]; then
SERVER_NAME=dss-server
elif [[ $PROJECT_NAME == *"apps"* ]]; then
SERVER_NAME=dss-apps-server
else
echo "please input: sh dss-daemon.sh [start,restart,stop] [server name]; for example : sh dss-daemon.sh restart project "
echo "server name : project、orchestrator、apps"
echo "please input: sh dss-daemon.sh [start,restart,stop] [server name]; for example : sh dss-daemon.sh restart dss-server "
echo "server name : dss-server、apps-server"
exit 1
fi
}
Expand Down
41 changes: 6 additions & 35 deletions sbin/dss-start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,55 +80,26 @@ echo "<-------------------------------->"
sleep 3
}


function startDssProject(){
SERVER_NAME=dss-framework-project-server
SERVER_IP=$DSS_FRAMEWORK_PROJECT_SERVER_INSTALL_IP
startApp
sleep 5

# echo "------------------------Start to check whether the project service is registered to eureka successfully-----------------------------"
# #project服务启动并注册到eureka后再启动其他服务
# i=1
# while [[ -z $result ]] && [[ $i -le 24 ]]
# do
# sleep 5
# if [ -z $EUREKA_USERNAME ] || [ -z $EUREKA_PASSWORD ];then
# response=`curl http://${EUREKA_INSTALL_IP}:${EUREKA_PORT}/eureka/apps/DSS-FRAMEWORK-PROJECT-SERVER`
# else
# response=`curl http://${EUREKA_USENAME}:${EUREKA_PASSWORD}@${EUREKA_INSTALL_IP}:${EUREKA_PORT}/eureka/apps/DSS-FRAMEWORK-PROJECT-SERVER`
# fi
# let i++
# result=$(echo $response |grep 'DSS-FRAMEWORK-PROJECT-SERVER')
# done
# if [[ $i -eq 25 ]]; then
# echo "the project server start failed in two minutes,please check the log to find more error details."
# exit
# fi
# echo "------------------------the project service is registered to eureka successfully------------------------------------------------"

SERVER_NAME=dss-apps-server
SERVER_IP=$DSS_APPS_SERVER_INSTALL_IP
startApp

SERVER_NAME=dss-framework-orchestrator-server
SERVER_IP=$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_INSTALL_IP
SERVER_NAME=dss-server
SERVER_IP=$DSS_SERVER_INSTALL_IP
startApp

}

function checkDssService(){
SERVER_NAME=dss-framework-project-server
SERVER_IP=$DSS_FRAMEWORK_PROJECT_SERVER_INSTALL_IP
SERVER_NAME=dss-apps-server
SERVER_IP=$DSS_APPS_SERVER_INSTALL_IP
checkServer

SERVER_NAME=dss-framework-orchestrator-server
SERVER_IP=$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_INSTALL_IP
SERVER_NAME=dss-server
SERVER_IP=$DSS_SERVER_INSTALL_IP
checkServer

SERVER_NAME=dss-data-api-server
SERVER_IP=$DSS_DATA_API_SERVER_INSTALL_IP
checkServer
}


Expand Down
8 changes: 2 additions & 6 deletions sbin/dss-stop-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ echo "<-------------------------------->"
}

function stopDssProject(){
SERVER_NAME=dss-framework-project-server
SERVER_IP=$DSS_FRAMEWORK_PROJECT_SERVER_INSTALL_IP
stopApp

SERVER_NAME=dss-framework-orchestrator-server
SERVER_IP=$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_INSTALL_IP
SERVER_NAME=dss-server
SERVER_IP=$DSS_SERVER_INSTALL_IP
stopApp

SERVER_NAME=dss-apps-server
Expand Down
Loading

0 comments on commit 5b2f25b

Please sign in to comment.