Skip to content

Commit

Permalink
Merge branch 'apache:main' into dev-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq authored Dec 4, 2024
2 parents ccdfe65 + 42a1721 commit ed2cef8
Show file tree
Hide file tree
Showing 175 changed files with 2,660 additions and 3,207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import static org.apache.bigtop.manager.common.constants.CacheFiles.CONFIGURATIONS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.HOSTS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.REPOS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.SETTINGS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.USERS_INFO;

@Slf4j
Expand Down Expand Up @@ -71,7 +70,6 @@ public void doExecute() {
}
}

JsonUtils.writeToFile(cacheDir + SETTINGS_INFO, cacheMessagePayload.getSettings());
JsonUtils.writeToFile(cacheDir + CONFIGURATIONS_INFO, cacheMessagePayload.getConfigurations());
JsonUtils.writeToFile(cacheDir + HOSTS_INFO, cacheMessagePayload.getClusterHostInfo());
JsonUtils.writeToFile(cacheDir + USERS_INFO, cacheMessagePayload.getUserInfo());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.common.message.entity.payload.CommandPayload;
import org.apache.bigtop.manager.common.message.entity.pojo.ScriptInfo;
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusReply;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusRequest;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusServiceGrpc;
Expand All @@ -44,12 +42,13 @@ public void getComponentStatus(
try {
CommandPayload commandPayload = new CommandPayload();
commandPayload.setCommand(Command.STATUS);
commandPayload.setStackName(request.getStackName());
commandPayload.setStackVersion(request.getStackVersion());
commandPayload.setServiceName(request.getServiceName());
commandPayload.setServiceUser(request.getServiceUser());
commandPayload.setComponentName(request.getComponentName());
commandPayload.setCommandScript(JsonUtils.readFromString(request.getCommandScript(), ScriptInfo.class));
ShellResult shellResult = StackExecutor.execute(commandPayload);

ShellResult shellResult = StackExecutor.execute(commandPayload);
ComponentStatusReply reply = ComponentStatusReply.newBuilder()
.setStatus(shellResult.getExitCode())
.build();
Expand Down
6 changes: 3 additions & 3 deletions bigtop-manager-agent/src/main/resources/assembly/agent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>agent</id>
<formats>
<format>dir</format>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<baseDirectory>agent</baseDirectory>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>bigtop-manager-agent</baseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

public class ComponentCategories {

public static final String MASTER = "master";

public static final String SLAVE = "slave";
public static final String SERVER = "server";

public static final String CLIENT = "client";
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ private Constants() {
/**
* permission 644
*/
public static final String PERMISSION_644 = "rw-r--r--";
public static final String PERMISSION_644 = "644";

/**
* permission 755
*/
public static final String PERMISSION_755 = "rwxr-xr-x";
public static final String PERMISSION_755 = "755";

/**
* permission 775
*/
public static final String PERMISSION_775 = "rwxrwxr-x";
public static final String PERMISSION_775 = "775";

/**
* permission 777
*/
public static final String PERMISSION_777 = "rwwrwxrwx";
public static final String PERMISSION_777 = "777";

/**
* root user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ public enum OSArchType {
X86_64,

AARCH64,

PPC64LE,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ public enum OSType {
FEDORA36,

OPENEULER22,

OPENEULER24,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
@NoArgsConstructor
public class CacheMessagePayload extends BasePayload {

private Map<String, Object> settings;

private ClusterInfo clusterInfo;

private Map<String, String> userInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package org.apache.bigtop.manager.common.message.entity.payload;

import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.common.message.entity.pojo.CustomCommandInfo;
import org.apache.bigtop.manager.common.message.entity.pojo.PackageSpecificInfo;
import org.apache.bigtop.manager.common.message.entity.pojo.ScriptInfo;

import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -42,18 +40,12 @@ public class CommandPayload extends BasePayload {

private String customCommand;

private List<CustomCommandInfo> customCommands;

private ScriptInfo commandScript;

private String serviceUser;

private String stackName;

private String stackVersion;

private String rootDir;

private String componentName;

private List<PackageSpecificInfo> packageSpecifics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public class ComponentInfo {

private String displayName;

private String commandScript;

private String customCommands;

private String category;

private String serviceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
@Data
public class PackageSpecificInfo {

private List<String> os;

private List<String> arch;

private List<PackageInfo> packages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

@Slf4j
public class ProjectPathUtils {
Expand All @@ -38,10 +39,28 @@ public static String getKeyStorePath() {
return getProjectStoreDir() + File.separator + "keys";
}

public static String getServerStackPath() {
return getProjectResourcesDir() + File.separator + "stacks";
}

public static String getAgentCachePath() {
return getProjectStoreDir() + File.separator + "agent-caches";
}

private static String getProjectResourcesDir() {
if (Environments.isDevMode()) {
return Objects.requireNonNull(ProjectPathUtils.class.getResource("/"))
.getPath();
} else {
File file = new File(ProjectPathUtils.class
.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath());
return file.getParentFile().getParentFile().getPath();
}
}

private static String getProjectBaseDir() {
if (Environments.isDevMode()) {
return SystemUtils.getUserDir().getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
*/
package org.apache.bigtop.manager.common.utils.os;

import org.apache.bigtop.manager.common.enums.OSArchType;
import org.apache.bigtop.manager.common.enums.OSType;
import org.apache.bigtop.manager.common.shell.ShellExecutor;
import org.apache.bigtop.manager.common.shell.ShellResult;

import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.SystemUtils;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -55,9 +52,7 @@ public class OSDetection {

public static String getOS() {
if (SystemUtils.IS_OS_LINUX) {
String os = getOSType() + getOSVersion().toLowerCase();
ifSupportedOS(os);
return os;
return getOSType() + getOSVersion().toLowerCase();
} else {
return System.getProperty("os.name");
}
Expand Down Expand Up @@ -151,25 +146,9 @@ private static String getOSArch() {
ShellResult shellResult = ShellExecutor.execCommand(builderParameters);
String output = shellResult.getOutput().replace("\n", "");
log.debug("getArch: {}", output);

ifSupportedArch(output);
return output;
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private static void ifSupportedOS(String os) {
if (!EnumUtils.isValidEnumIgnoreCase(OSType.class, os)) {
throw new RuntimeException("Unsupported OS: [" + os + "]");
}
log.debug("OS [{}] is Supported", os);
}

private static void ifSupportedArch(String arch) {
if (!EnumUtils.isValidEnumIgnoreCase(OSArchType.class, arch)) {
throw new RuntimeException("Unsupported Arch: [" + arch + "]");
}
log.debug("Arch [{}] is Supported", arch);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class ComponentPO extends BasePO implements Serializable {
@Transient
private String serviceName;

@Transient
private String serviceUser;

@Transient
private String serviceDisplayName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ public class PlatformPO extends BasePO implements Serializable {

@Column(name = "support_models", length = 255)
private String supportModels;

@Column(name = "desc")
private String desc;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="comp"/>
</include>, s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname
</include>, s.name as service_name, s.user as service_user, s.display_name as service_display_name, s.stack, h.hostname
from
component comp
left join service s on comp.service_id = s.id
Expand Down Expand Up @@ -75,7 +75,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="comp"/>
</include>, s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname
</include>, s.name as service_name, s.user as service_user, s.display_name as service_display_name, s.stack, h.hostname
from
component comp
left join service s on comp.service_id = s.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="comp"/>
</include>, s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname
</include>, s.name as service_name, s.user as service_user, s.display_name as service_display_name, s.stack, h.hostname
from
component comp
left join service s on comp.service_id = s.id
Expand Down Expand Up @@ -75,7 +75,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="comp"/>
</include>, s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname
</include>, s.name as service_name, s.user as service_user, s.display_name as service_display_name, s.stack, h.hostname
from
component comp
left join service s on comp.service_id = s.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ service ComponentStatusService {
}

message ComponentStatusRequest {
string service_name = 1;
string service_user = 2;
string component_name = 3;
string command_script = 4;
// TODO Unnecessary, should be removed in the future
string root = 5;
string stack_name = 6;
string stack_version = 7;
string stack_name = 1;
string stack_version = 2;
string service_name = 3;
string service_user = 4;
string component_name = 5;
}

message ComponentStatusReply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,9 @@ protected String findServiceNameByComponentName(String componentName) {
return StackUtils.getServiceDTOByComponentName(componentName).getName();
}

protected Boolean isMasterComponent(String componentName) {
protected Boolean isServerComponent(String componentName) {
ComponentDTO componentDTO = StackUtils.getComponentDTO(componentName);
return componentDTO.getCategory().equalsIgnoreCase(ComponentCategories.MASTER);
}

protected Boolean isSlaveComponent(String componentName) {
ComponentDTO componentDTO = StackUtils.getComponentDTO(componentName);
return componentDTO.getCategory().equalsIgnoreCase(ComponentCategories.SLAVE);
return componentDTO.getCategory().equalsIgnoreCase(ComponentCategories.SERVER);
}

protected Boolean isClientComponent(String componentName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ protected TaskContext createTaskContext(HostDTO hostDTO) {
taskContext.setComponentName(componentDTO.getName());
taskContext.setComponentDisplayName(componentDTO.getDisplayName());
taskContext.setServiceUser(serviceDTO.getUser());
taskContext.setUserGroup(clusterPO.getUserGroup());
taskContext.setRootDir(clusterPO.getRootDir());

Map<String, Object> properties = new HashMap<>();
properties.put("customCommands", componentDTO.getCustomCommands());
properties.put("packageSpecifics", serviceDTO.getPackageSpecifics());
properties.put("commandScript", componentDTO.getCommandScript());
taskContext.setProperties(properties);
return taskContext;
}
Expand Down
Loading

0 comments on commit ed2cef8

Please sign in to comment.