This is an automated email from the ASF dual-hosted git repository.
jiafengzheng pushed a commit to branch doris-manager
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/doris-manager by this push:
new ffc843c [Manager] Improve agent part code (#6878)
ffc843c is described below
commit ffc843c0a9e20a9f221765f40a6f619497f56a69
Author: wudi <[email protected]>
AuthorDate: Tue Oct 19 04:32:10 2021 -0500
[Manager] Improve agent part code (#6878)
* [fix]:merge code
* [Fix] remove dm-server propertiesUtil
Co-authored-by: wudi <[email protected]>
Co-authored-by: weiyongxu <[email protected]>
Co-authored-by: jiafeng.zhang <[email protected]>
---
manager/dm-server/pom.xml | 4 ++
.../apache/doris/stack/constants/Constants.java | 4 +-
.../doris/stack/controller/ServerController.java | 8 ----
.../stack/service/impl/ServerProcessImpl.java | 11 +++--
.../apache/doris/stack/util/PropertiesUtil.java | 51 ----------------------
5 files changed, 10 insertions(+), 68 deletions(-)
diff --git a/manager/dm-server/pom.xml b/manager/dm-server/pom.xml
index 2be0212..5388e6f 100644
--- a/manager/dm-server/pom.xml
+++ b/manager/dm-server/pom.xml
@@ -22,6 +22,10 @@
<groupId>org.apache.doris</groupId>
<artifactId>dm-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.doris</groupId>
+ <artifactId>general</artifactId>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
diff --git
a/manager/dm-server/src/main/java/org/apache/doris/stack/constants/Constants.java
b/manager/dm-server/src/main/java/org/apache/doris/stack/constants/Constants.java
index 31a27d0..6584f95 100644
---
a/manager/dm-server/src/main/java/org/apache/doris/stack/constants/Constants.java
+++
b/manager/dm-server/src/main/java/org/apache/doris/stack/constants/Constants.java
@@ -19,9 +19,7 @@ package org.apache.doris.stack.constants;
public class Constants {
- public static final String KEY_SERVER_PORT = "server.port";
- public static final String KEY_DORIS_AGENT_INSTALL_DIR =
"doris.manager.agent.install.dir";
- public static final String KEY_DORIS_AGENT_START_SCRIPT =
"doris.manager.agent.start-script";
+ public static final String KEY_DORIS_AGENT_START_SCRIPT =
"agent/bin/agent_start.sh";
public static final String KEY_FE_QUERY_PORT = "query_port";
public static final String KEY_BE_HEARTBEAT_PORT =
"heartbeat_service_port";
diff --git
a/manager/dm-server/src/main/java/org/apache/doris/stack/controller/ServerController.java
b/manager/dm-server/src/main/java/org/apache/doris/stack/controller/ServerController.java
index a9217e4..6419995 100644
---
a/manager/dm-server/src/main/java/org/apache/doris/stack/controller/ServerController.java
+++
b/manager/dm-server/src/main/java/org/apache/doris/stack/controller/ServerController.java
@@ -19,14 +19,11 @@ package org.apache.doris.stack.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
import org.apache.doris.manager.common.domain.RResult;
-import org.apache.doris.stack.constants.Constants;
import org.apache.doris.stack.req.AgentCommon;
import org.apache.doris.stack.req.AgentRegister;
import org.apache.doris.stack.req.SshInfo;
import org.apache.doris.stack.service.ServerProcess;
-import org.apache.doris.stack.util.PropertiesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,8 +37,6 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class ServerController {
- private static final String AGENT_INSTALL_DIR =
PropertiesUtil.getPropValue(Constants.KEY_DORIS_AGENT_INSTALL_DIR);
-
@Autowired
private ServerProcess serverProcess;
@@ -50,9 +45,6 @@ public class ServerController {
*/
@RequestMapping(value = "/installAgent", method = RequestMethod.POST)
public RResult installAgent(@RequestBody SshInfo sshInfo) {
- if (StringUtils.isBlank(sshInfo.getInstallDir())) {
- sshInfo.setInstallDir(AGENT_INSTALL_DIR);
- }
serverProcess.initAgent(sshInfo);
serverProcess.startAgent(sshInfo);
return RResult.success();
diff --git
a/manager/dm-server/src/main/java/org/apache/doris/stack/service/impl/ServerProcessImpl.java
b/manager/dm-server/src/main/java/org/apache/doris/stack/service/impl/ServerProcessImpl.java
index fb5d7ca..0a33138 100644
---
a/manager/dm-server/src/main/java/org/apache/doris/stack/service/impl/ServerProcessImpl.java
+++
b/manager/dm-server/src/main/java/org/apache/doris/stack/service/impl/ServerProcessImpl.java
@@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.doris.stack.agent.AgentCache;
import org.apache.doris.stack.component.AgentComponent;
import org.apache.doris.stack.component.AgentRoleComponent;
+import org.apache.doris.stack.constant.EnvironmentDefine;
import org.apache.doris.stack.constants.Constants;
import org.apache.doris.stack.entity.AgentEntity;
import org.apache.doris.stack.entity.AgentRoleEntity;
@@ -33,7 +34,6 @@ import org.apache.doris.stack.service.ServerProcess;
import org.apache.doris.stack.shell.SCP;
import org.apache.doris.stack.shell.SSH;
import org.apache.doris.stack.util.Preconditions;
-import org.apache.doris.stack.util.PropertiesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
@@ -57,8 +57,7 @@ import java.util.Set;
@Slf4j
public class ServerProcessImpl implements ServerProcess {
- private static final String AGENT_INSTALL_DIR =
PropertiesUtil.getPropValue(Constants.KEY_DORIS_AGENT_INSTALL_DIR);
- private static final String AGENT_START_SCRIPT =
PropertiesUtil.getPropValue(Constants.KEY_DORIS_AGENT_START_SCRIPT);
+ private static final String AGENT_START_SCRIPT =
Constants.KEY_DORIS_AGENT_START_SCRIPT;
@Autowired
private AgentComponent agentComponent;
@@ -78,12 +77,12 @@ public class ServerProcessImpl implements ServerProcess {
Preconditions.checkNotNull(sshInfo.getHosts(), "hosts is empty");
File sshKeyFile = buildSshKeyFile();
writeSshKeyFile(sshInfo.getSshKey(), sshKeyFile);
- scpFile(sshInfo, agentHome, AGENT_INSTALL_DIR);
+ scpFile(sshInfo, agentHome, sshInfo.getInstallDir());
}
@Override
public void startAgent(SshInfo sshInfo) {
- String command = "sh " + AGENT_INSTALL_DIR + File.separator +
AGENT_START_SCRIPT + " --server " + getServerAddr() + " --agent %s";
+ String command = "sh " + sshInfo.getInstallDir() + File.separator +
AGENT_START_SCRIPT + " --server " + getServerAddr() + " --agent %s";
List<String> hosts = sshInfo.getHosts();
for (String host : hosts) {
File sshKeyFile = buildSshKeyFile();
@@ -197,7 +196,7 @@ public class ServerProcessImpl implements ServerProcess {
} catch (UnknownHostException e) {
throw new ServerException("get server ip fail");
}
- String port = PropertiesUtil.getPropValue(Constants.KEY_SERVER_PORT);
+ String port = System.getenv(EnvironmentDefine.STUDIO_PORT_ENV);
return host + ":" + port;
}
diff --git
a/manager/dm-server/src/main/java/org/apache/doris/stack/util/PropertiesUtil.java
b/manager/dm-server/src/main/java/org/apache/doris/stack/util/PropertiesUtil.java
deleted file mode 100644
index 4d3a02d..0000000
---
a/manager/dm-server/src/main/java/org/apache/doris/stack/util/PropertiesUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.stack.util;
-
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Properties;
-
-@Slf4j
-public class PropertiesUtil {
-
- private static final String DEFAULT_PROPERTIES = "/application.properties";
-
- /**
- * get properties key
- *
- * @param propKey
- * @return
- */
- public static String getPropValue(String propKey) {
- try {
- Properties props = new Properties();
- InputStream inputStream =
PropertiesUtil.class.getResourceAsStream(DEFAULT_PROPERTIES);
- BufferedReader bf = new BufferedReader(new
InputStreamReader(inputStream, "UTF-8"));
- props.load(bf);
- return props.getProperty(propKey);
- } catch (IOException e) {
- log.error("get propKey error:", e);
- }
- return null;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]