Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature][manager] Modify the code according to the prototype #7346

Merged
merged 76 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
00c4c30
[fix]:merge code
Aug 26, 2021
4f221a9
1. Ensure the idempotence of fe, be service installation
weajun Aug 30, 2021
566949c
Fix the problem that the code checkstyle failed
weajun Aug 30, 2021
2a55f8d
[style]:server code format
Aug 31, 2021
68b5d5d
server change
Sep 5, 2021
0661622
style
Sep 5, 2021
086b6c0
build change
Sep 5, 2021
356e35f
Merge branch 'doris-manager' into manager03
Oct 15, 2021
5775d40
Merge branch 'doris-manager' into manager03
hf200012 Oct 19, 2021
293b03c
Remove the use of javafx
weajun Oct 19, 2021
c248f87
remove unuse javafx package
weajun Oct 19, 2021
e990417
[Fix] remove dm-server propertiesUtil
Oct 19, 2021
4e21fa2
Merge branch 'manager03' of https://github.com/weajun/incubator-doris…
Oct 19, 2021
a0056cc
Merge branch 'doris-manager' into manager03
Oct 19, 2021
f1ae149
[Manager] Optimize agent-server code
Oct 27, 2021
1963d57
[Manager] Code style
Oct 27, 2021
bd606b1
[Manager] Fix some bug
Oct 28, 2021
658a212
[Manager] Fix server
Oct 28, 2021
8a4d9a5
[Manager] code style
Oct 28, 2021
4f30be3
[Manager] code style
Oct 28, 2021
f4edf71
[Manager] submit agent-server code
Oct 29, 2021
522126e
[Fix] fix type bug
Oct 29, 2021
021c04c
[Manager] Submit agent-server code
Nov 1, 2021
7026bc7
fix
Nov 1, 2021
64c9a08
[Manager] fix agent-server
Nov 1, 2021
ae376e5
fix
Nov 1, 2021
30daacc
fix
Nov 1, 2021
2083706
fix
Nov 2, 2021
0398e62
fix
Nov 2, 2021
3a249d1
fix
Nov 2, 2021
0039a9b
fix
Nov 2, 2021
2e7a163
fix
Nov 2, 2021
c1dac44
fix confilict
Nov 2, 2021
233d0b9
change jdbc connection to rest api
Nov 5, 2021
cae427f
add be rest
Nov 5, 2021
3bd889f
fix
Nov 5, 2021
30740eb
fix service log
Nov 5, 2021
6c0d878
Merge branch 'doris-manager' into manager03
Nov 5, 2021
9f95007
fix
Nov 5, 2021
f911b15
fix
Nov 5, 2021
63a8bf6
fix
Nov 5, 2021
607b9fb
fix
Nov 5, 2021
d1ac193
Optimize logs and optimize access to task status
weajun Nov 5, 2021
1e53202
fix
Nov 5, 2021
04e0ff0
change rest api add be to jdbc
Nov 6, 2021
dd0855a
fix
Nov 6, 2021
b4103c3
[Manager] add quote
Nov 8, 2021
ce442a4
[Manager] remove quote
Nov 9, 2021
e0c0f17
[Manager] refresh env
Nov 9, 2021
961f2a5
update optimization
Nov 9, 2021
b7cd4bb
[Fix] add retry task ,skip task,record task json
Nov 11, 2021
f3b033d
change log to lombok
Nov 11, 2021
112c86d
[Fix] rename Duplicate name class
Nov 12, 2021
b6ff24d
fix
Nov 15, 2021
1c77073
add retry task, cancel task and update doc etc
Nov 15, 2021
19c69a0
[Fix] add skip,and imporve code
Nov 19, 2021
927952c
fix
Nov 19, 2021
bdbbb66
update doc and log
Nov 19, 2021
4046ad7
Support multiple fe
Nov 22, 2021
8bc6d85
Merge branch 'manage04' into manager03
Nov 22, 2021
ccfe216
fix
Nov 23, 2021
566a109
Merge branch 'manage04' into manager03
Nov 23, 2021
e7aabe2
add hardware info
Nov 24, 2021
a038922
Merge branch 'manage04' into manager03
Nov 24, 2021
9bcad4a
add broker request model
Nov 26, 2021
0682dd0
add broker
Nov 26, 2021
8e5b838
manager broker
weajun Dec 1, 2021
62eac33
broker change
Dec 2, 2021
dc6f147
fix
Dec 2, 2021
e0097b3
update doc
Dec 2, 2021
88763b3
Merge branch 'manage04' into manager03
Dec 2, 2021
8223f8a
add hardware
Dec 2, 2021
a3cd9d0
Merge branch 'manage04' into manager03
Dec 2, 2021
463b561
add status message
Dec 7, 2021
c848154
Merge branch 'manage04' into manager03
Dec 7, 2021
feed391
merge confilct
Dec 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions manager/dm-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
<version>2.33</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.github.oshi/oshi-core -->
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.0.0</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.manager.agent.api;

import org.apache.doris.manager.common.domain.HardwareInfo;
import org.apache.doris.manager.common.domain.RResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import oshi.SystemInfo;
import oshi.util.FormatUtil;

/**
* hardware info
**/
@RestController
@RequestMapping("/hardware/view")
public class HardwareInfoController {

@GetMapping
public RResult info() {
HardwareInfo hardwareInfo = new HardwareInfo();
SystemInfo systemInfo = new SystemInfo();
hardwareInfo.setCpu(systemInfo.getHardware().getProcessor().toString());
hardwareInfo.setTotalMemory(FormatUtil.formatBytes(systemInfo.getHardware().getMemory().getTotal()));
return RResult.success(hardwareInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.doris.manager.agent.exception.AgentException;
import org.apache.doris.manager.agent.register.AgentContext;
import org.apache.doris.manager.agent.service.BeService;
import org.apache.doris.manager.agent.service.Service;
import org.apache.doris.manager.agent.service.ServiceContext;
import org.apache.doris.manager.agent.task.ITaskHandlerFactory;
import org.apache.doris.manager.agent.task.QueuedTaskHandlerFactory;
Expand All @@ -32,7 +31,6 @@
import org.apache.doris.manager.agent.task.TaskHook;
import org.apache.doris.manager.common.domain.BeInstallCommandRequestBody;
import org.apache.doris.manager.common.domain.CommandType;
import org.apache.doris.manager.common.domain.ServiceRole;

import java.util.Objects;

Expand Down Expand Up @@ -74,11 +72,6 @@ public CommandType setupCommandType() {
}

private void validCommand() {
Service service = ServiceContext.getServiceMap().get(ServiceRole.BE);
if (Objects.nonNull(service)) {
throw new AgentException("service be has installed");
}

if (Objects.isNull(requestBody.getInstallDir()) || Objects.isNull(requestBody.getPackageUrl())) {
throw new AgentException("required parameters are missing in body param");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.manager.agent.command;

import org.apache.doris.manager.agent.exception.AgentException;
import org.apache.doris.manager.agent.service.Service;
import org.apache.doris.manager.agent.service.ServiceContext;
import org.apache.doris.manager.common.domain.ServiceRole;

import java.util.Objects;

public abstract class BrokerCommand extends ExpandCommand {
@Override
void beforeSetup() {
Service service = ServiceContext.getServiceMap().get(ServiceRole.BROKER);
if (Objects.isNull(service)) {
throw new AgentException("service broker not installed or register");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// 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.manager.agent.command;

import org.apache.doris.manager.agent.common.AgentConstants;
import org.apache.doris.manager.agent.exception.AgentException;
import org.apache.doris.manager.agent.register.AgentContext;
import org.apache.doris.manager.agent.service.BrokerService;
import org.apache.doris.manager.agent.service.ServiceContext;
import org.apache.doris.manager.agent.task.ITaskHandlerFactory;
import org.apache.doris.manager.agent.task.QueuedTaskHandlerFactory;
import org.apache.doris.manager.agent.task.ScriptTask;
import org.apache.doris.manager.agent.task.ScriptTaskDesc;
import org.apache.doris.manager.agent.task.Task;
import org.apache.doris.manager.agent.task.TaskHandlerFactory;
import org.apache.doris.manager.agent.task.TaskHook;
import org.apache.doris.manager.common.domain.BrokerInstallCommandRequestBody;
import org.apache.doris.manager.common.domain.CommandType;

import java.util.Objects;

public class BrokerInstallCommand extends Command {
private BrokerInstallCommandRequestBody requestBody;

public BrokerInstallCommand(BrokerInstallCommandRequestBody requestBody) {
this.requestBody = requestBody;
}

@Override
public Task setupTask() {
validCommand();

if (requestBody.getInstallDir().endsWith("/")) {
requestBody.setInstallDir(requestBody.getInstallDir().substring(0, requestBody.getInstallDir().length() - 1));
}

BrokerInstallTaskDesc taskDesc = new BrokerInstallTaskDesc();

String scriptCmd = AgentConstants.BASH_BIN;
scriptCmd += AgentContext.getAgentInstallDir() + "/bin/install_broker.sh ";
scriptCmd += " --installDir " + requestBody.getInstallDir();
scriptCmd += " --url " + requestBody.getPackageUrl();

taskDesc.setScriptCmd(scriptCmd);
taskDesc.setInstallDir(requestBody.getInstallDir());
return new ScriptTask(taskDesc, new BrokerInstallTaskHook());
}

@Override
public ITaskHandlerFactory setupTaskHandlerFactory() {
return TaskHandlerFactory.getTaskHandlerFactory(QueuedTaskHandlerFactory.class);
}

@Override
public CommandType setupCommandType() {
return CommandType.INSTALL_BROKER;
}

private void validCommand() {
if (Objects.isNull(requestBody.getInstallDir()) || Objects.isNull(requestBody.getPackageUrl())) {
throw new AgentException("required parameters are missing in body param");
}

if (!requestBody.getInstallDir().startsWith("/")) {
throw new AgentException("the installation path must use an absolute path");
}
}

private static class BrokerInstallTaskDesc extends ScriptTaskDesc {
private String installDir;

public String getInstallDir() {
return installDir;
}

public void setInstallDir(String installDir) {
this.installDir = installDir;
}
}

private static class BrokerInstallTaskHook extends TaskHook<BrokerInstallTaskDesc> {
@Override
public void onSuccess(BrokerInstallTaskDesc taskDesc) {
BrokerService brokerService = new BrokerService(taskDesc.getInstallDir());
ServiceContext.register(brokerService);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.manager.agent.command;

import org.apache.doris.manager.agent.common.AgentConstants;
import org.apache.doris.manager.agent.service.ServiceContext;
import org.apache.doris.manager.agent.task.ITaskHandlerFactory;
import org.apache.doris.manager.agent.task.QueuedTaskHandlerFactory;
import org.apache.doris.manager.agent.task.ScriptTask;
import org.apache.doris.manager.agent.task.ScriptTaskDesc;
import org.apache.doris.manager.agent.task.Task;
import org.apache.doris.manager.agent.task.TaskHandlerFactory;
import org.apache.doris.manager.common.domain.CommandType;
import org.apache.doris.manager.common.domain.ServiceRole;

public class BrokerStartCommand extends BrokerCommand {
@Override
public Task setupTask() {
ScriptTaskDesc taskDesc = new ScriptTaskDesc();

String scriptCmd = AgentConstants.BASH_BIN;
scriptCmd += ServiceContext.getServiceMap().get(ServiceRole.BROKER).getInstallDir() + "/bin/start_broker.sh --daemon";
taskDesc.setScriptCmd(scriptCmd);
return new ScriptTask(taskDesc);
}

@Override
public ITaskHandlerFactory setupTaskHandlerFactory() {
return TaskHandlerFactory.getTaskHandlerFactory(QueuedTaskHandlerFactory.class);

}

@Override
public CommandType setupCommandType() {
return CommandType.START_BROKER;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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.manager.agent.command;

import org.apache.doris.manager.agent.common.AgentConstants;
import org.apache.doris.manager.agent.service.ServiceContext;
import org.apache.doris.manager.agent.task.ITaskHandlerFactory;
import org.apache.doris.manager.agent.task.QueuedTaskHandlerFactory;
import org.apache.doris.manager.agent.task.ScriptTask;
import org.apache.doris.manager.agent.task.ScriptTaskDesc;
import org.apache.doris.manager.agent.task.Task;
import org.apache.doris.manager.agent.task.TaskHandlerFactory;
import org.apache.doris.manager.common.domain.CommandType;
import org.apache.doris.manager.common.domain.ServiceRole;

public class BrokerStopCommand extends BrokerCommand {
@Override
public Task setupTask() {
ScriptTaskDesc taskDesc = new ScriptTaskDesc();

String scriptCmd = AgentConstants.BASH_BIN;
scriptCmd += ServiceContext.getServiceMap().get(ServiceRole.BROKER).getInstallDir() + "/bin/stop_broker.sh ";
taskDesc.setScriptCmd(scriptCmd);
return new ScriptTask(taskDesc);
}

@Override
public ITaskHandlerFactory setupTaskHandlerFactory() {
return TaskHandlerFactory.getTaskHandlerFactory(QueuedTaskHandlerFactory.class);
}

@Override
public CommandType setupCommandType() {
return CommandType.STOP_BROKER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import com.alibaba.fastjson.JSON;
import org.apache.doris.manager.agent.exception.AgentException;
import org.apache.doris.manager.common.domain.BeInstallCommandRequestBody;
import org.apache.doris.manager.common.domain.BrokerInstallCommandRequestBody;
import org.apache.doris.manager.common.domain.CommandRequest;
import org.apache.doris.manager.common.domain.CommandType;
import org.apache.doris.manager.common.domain.FeInstallCommandRequestBody;
import org.apache.doris.manager.common.domain.FeStartCommandRequestBody;
import org.apache.doris.manager.common.domain.WriteBeConfCommandRequestBody;
import org.apache.doris.manager.common.domain.WriteBrokerConfCommandRequestBody;
import org.apache.doris.manager.common.domain.WriteFeConfCommandRequestBody;

import java.io.UnsupportedEncodingException;
Expand All @@ -51,6 +53,9 @@ public static Command get(CommandRequest commandRequest) {
case INSTALL_BE:
validBody(body);
return new BeInstallCommand(JSON.parseObject(body, BeInstallCommandRequestBody.class));
case INSTALL_BROKER:
validBody(body);
return new BrokerInstallCommand(JSON.parseObject(body, BrokerInstallCommandRequestBody.class));
case START_FE:
return new FeStartCommand(JSON.parseObject(body, FeStartCommandRequestBody.class));
case STOP_FE:
Expand All @@ -59,6 +64,10 @@ public static Command get(CommandRequest commandRequest) {
return new BeStartCommand();
case STOP_BE:
return new BeStopCommand();
case START_BROKER:
return new BrokerStartCommand();
case STOP_BROKER:
return new BrokerStopCommand();
case WRITE_FE_CONF:
validBody(body);
WriteFeConfCommandRequestBody writeFeConfCommandRequestBody = JSON.parseObject(body, WriteFeConfCommandRequestBody.class);
Expand All @@ -79,6 +88,16 @@ public static Command get(CommandRequest commandRequest) {
e.printStackTrace();
}
return new WriteBeConfCommand(writeBeConfCommandRequestBody);
case WRITE_BROKER_CONF:
validBody(body);
WriteBrokerConfCommandRequestBody writeBrokerConfCommandRequestBody = JSON.parseObject(body, WriteBrokerConfCommandRequestBody.class);
Base64.Decoder decoder3 = Base64.getDecoder();
try {
writeBrokerConfCommandRequestBody.setContent(new String(decoder3.decode(writeBrokerConfCommandRequestBody.getContent()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return new WriteBrokerConfCommand(writeBrokerConfCommandRequestBody);
default:
throw new AgentException("unkown CommandType");
}
Expand Down
Loading