diff --git a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheFileUpdateCommandExecutor.java b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheFileUpdateCommandExecutor.java index 28fd8ae5..74b014cf 100644 --- a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheFileUpdateCommandExecutor.java +++ b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheFileUpdateCommandExecutor.java @@ -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 @@ -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()); diff --git a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/service/ComponentStatusServiceGrpcImpl.java b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/service/ComponentStatusServiceGrpcImpl.java index 75e6e6e7..7413b354 100644 --- a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/service/ComponentStatusServiceGrpcImpl.java +++ b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/service/ComponentStatusServiceGrpcImpl.java @@ -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; @@ -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(); diff --git a/bigtop-manager-agent/src/main/resources/assembly/agent.xml b/bigtop-manager-agent/src/main/resources/assembly/agent.xml index a8d51bb9..e464a927 100644 --- a/bigtop-manager-agent/src/main/resources/assembly/agent.xml +++ b/bigtop-manager-agent/src/main/resources/assembly/agent.xml @@ -22,10 +22,10 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> agent - dir + tar.gz - false - agent + true + bigtop-manager-agent ${basedir}/src/main/resources diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/ComponentCategories.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/ComponentCategories.java index a0a6bfef..5bb0d4a1 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/ComponentCategories.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/ComponentCategories.java @@ -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"; } diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java index 77094fd8..628929c0 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java @@ -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 diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSArchType.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSArchType.java index 382de48b..2516d550 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSArchType.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSArchType.java @@ -25,7 +25,5 @@ public enum OSArchType { X86_64, AARCH64, - - PPC64LE, ; } diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSType.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSType.java index 521f081e..d212a520 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSType.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/OSType.java @@ -37,5 +37,7 @@ public enum OSType { FEDORA36, OPENEULER22, + + OPENEULER24, ; } diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CacheMessagePayload.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CacheMessagePayload.java index aff34fab..9d289bc2 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CacheMessagePayload.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CacheMessagePayload.java @@ -37,8 +37,6 @@ @NoArgsConstructor public class CacheMessagePayload extends BasePayload { - private Map settings; - private ClusterInfo clusterInfo; private Map userInfo; diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CommandPayload.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CommandPayload.java index 142f7d4f..6f9402ae 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CommandPayload.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/payload/CommandPayload.java @@ -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; @@ -42,18 +40,12 @@ public class CommandPayload extends BasePayload { private String customCommand; - private List customCommands; - - private ScriptInfo commandScript; - private String serviceUser; private String stackName; private String stackVersion; - private String rootDir; - private String componentName; private List packageSpecifics; diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/ComponentInfo.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/ComponentInfo.java index b573228d..4026fedb 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/ComponentInfo.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/ComponentInfo.java @@ -27,10 +27,6 @@ public class ComponentInfo { private String displayName; - private String commandScript; - - private String customCommands; - private String category; private String serviceName; diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/PackageSpecificInfo.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/PackageSpecificInfo.java index 13be0345..0cf4dfa8 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/PackageSpecificInfo.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/PackageSpecificInfo.java @@ -25,8 +25,6 @@ @Data public class PackageSpecificInfo { - private List os; - private List arch; private List packages; diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ProjectPathUtils.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ProjectPathUtils.java index 779f209d..44d03999 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ProjectPathUtils.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ProjectPathUtils.java @@ -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 { @@ -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(); diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/OSDetection.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/OSDetection.java index e5b50bd1..593e5b3a 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/OSDetection.java +++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/OSDetection.java @@ -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; @@ -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"); } @@ -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); - } } diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ComponentPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ComponentPO.java index c1171076..cbc98275 100644 --- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ComponentPO.java +++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ComponentPO.java @@ -57,6 +57,9 @@ public class ComponentPO extends BasePO implements Serializable { @Transient private String serviceName; + @Transient + private String serviceUser; + @Transient private String serviceDisplayName; diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/PlatformPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/PlatformPO.java index df68a303..99c1071f 100644 --- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/PlatformPO.java +++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/PlatformPO.java @@ -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; } diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java deleted file mode 100644 index c719b760..00000000 --- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java +++ /dev/null @@ -1,24 +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.bigtop.manager.dao.repository; - -import org.apache.bigtop.manager.dao.po.SettingPO; - -public interface SettingDao extends BaseDao {} diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml index ace3d4c4..964295af 100644 --- a/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml +++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml @@ -41,7 +41,7 @@ select - , s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname + , 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 @@ -75,7 +75,7 @@ select - , s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname + , 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 diff --git a/bigtop-manager-dao/src/main/resources/mapper/postgresql/ComponentMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/postgresql/ComponentMapper.xml index ace3d4c4..964295af 100644 --- a/bigtop-manager-dao/src/main/resources/mapper/postgresql/ComponentMapper.xml +++ b/bigtop-manager-dao/src/main/resources/mapper/postgresql/ComponentMapper.xml @@ -41,7 +41,7 @@ select - , s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname + , 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 @@ -75,7 +75,7 @@ select - , s.name as service_name, s.display_name as service_display_name, s.stack, h.hostname + , 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 diff --git a/bigtop-manager-grpc/src/main/resources/proto/component_status.proto b/bigtop-manager-grpc/src/main/resources/proto/component_status.proto index 7431b63f..8be8b48d 100644 --- a/bigtop-manager-grpc/src/main/resources/proto/component_status.proto +++ b/bigtop-manager-grpc/src/main/resources/proto/component_status.proto @@ -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 { diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractServiceJob.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractServiceJob.java index 6b73c848..a5765570 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractServiceJob.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractServiceJob.java @@ -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) { diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractComponentStage.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractComponentStage.java index 15d8bbdc..04f2d6cb 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractComponentStage.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractComponentStage.java @@ -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 properties = new HashMap<>(); - properties.put("customCommands", componentDTO.getCustomCommands()); properties.put("packageSpecifics", serviceDTO.getPackageSpecifics()); - properties.put("commandScript", componentDTO.getCommandScript()); taskContext.setProperties(properties); return taskContext; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/CacheFileUpdateStage.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/CacheFileUpdateStage.java index 1e2b7081..0d25c0a8 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/CacheFileUpdateStage.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/CacheFileUpdateStage.java @@ -18,7 +18,6 @@ */ package org.apache.bigtop.manager.server.command.stage; -import org.apache.bigtop.manager.common.enums.Command; import org.apache.bigtop.manager.dao.po.HostPO; import org.apache.bigtop.manager.server.command.task.CacheFileUpdateTask; import org.apache.bigtop.manager.server.command.task.Task; @@ -63,14 +62,15 @@ protected Task createTask(HostDTO hostDTO) { taskContext.setHostDTO(hostDTO); taskContext.setClusterId(stageContext.getClusterId()); taskContext.setClusterName(stageContext.getClusterName()); + taskContext.setUserGroup(stageContext.getUserGroup()); + taskContext.setRootDir(stageContext.getRootDir()); taskContext.setServiceName("cluster"); taskContext.setServiceUser("root"); taskContext.setComponentName("agent"); taskContext.setComponentDisplayName("Agent"); - taskContext.setCommand(Command.CUSTOM); - taskContext.setCustomCommand("update_cache_files"); Map properties = new HashMap<>(); + properties.put("hostIds", stageContext.getHostIds()); taskContext.setProperties(properties); return new CacheFileUpdateTask(taskContext); diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/HostCheckStage.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/HostCheckStage.java index 808ea635..49ca5f62 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/HostCheckStage.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/HostCheckStage.java @@ -18,7 +18,6 @@ */ package org.apache.bigtop.manager.server.command.stage; -import org.apache.bigtop.manager.common.enums.Command; import org.apache.bigtop.manager.server.command.task.HostCheckTask; import org.apache.bigtop.manager.server.command.task.Task; import org.apache.bigtop.manager.server.command.task.TaskContext; @@ -48,8 +47,6 @@ protected Task createTask(HostDTO hostDTO) { taskContext.setServiceUser("root"); taskContext.setComponentName("agent"); taskContext.setComponentDisplayName("Agent"); - taskContext.setCommand(Command.CUSTOM); - taskContext.setCustomCommand("check_host"); return new HostCheckTask(taskContext); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/StageContext.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/StageContext.java index 0b23cf00..ec699506 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/StageContext.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/StageContext.java @@ -35,6 +35,10 @@ public class StageContext { private String clusterName; + private String userGroup; + + private String rootDir; + private List hostIds; private ServiceDTO serviceDTO; @@ -65,6 +69,8 @@ private static void fromClusterCommandPayload(StageContext context, CommandDTO c context.setClusterName(clusterCommand.getName()); context.setHostIds(clusterCommand.getHostIds()); + context.setUserGroup(clusterCommand.getUserGroup()); + context.setRootDir(clusterCommand.getRootDir()); } private static void fromHostCommandPayload(StageContext context, CommandDTO commandDTO) { diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractComponentTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractComponentTask.java index 5aeb19e8..4071ae66 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractComponentTask.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractComponentTask.java @@ -19,19 +19,17 @@ package org.apache.bigtop.manager.server.command.task; import org.apache.bigtop.manager.common.message.entity.payload.CommandPayload; -import org.apache.bigtop.manager.common.message.entity.pojo.CustomCommandInfo; import org.apache.bigtop.manager.common.message.entity.pojo.PackageInfo; import org.apache.bigtop.manager.common.message.entity.pojo.PackageSpecificInfo; -import org.apache.bigtop.manager.common.message.entity.pojo.ScriptInfo; import org.apache.bigtop.manager.common.utils.JsonUtils; import org.apache.bigtop.manager.dao.repository.ComponentDao; import org.apache.bigtop.manager.grpc.generated.CommandRequest; import org.apache.bigtop.manager.grpc.generated.CommandType; import org.apache.bigtop.manager.server.holder.SpringContextHolder; -import org.apache.bigtop.manager.server.model.dto.CustomCommandDTO; import org.apache.bigtop.manager.server.model.dto.PackageDTO; import org.apache.bigtop.manager.server.model.dto.PackageSpecificDTO; -import org.apache.bigtop.manager.server.model.dto.ScriptDTO; +import org.apache.bigtop.manager.server.model.dto.StackDTO; +import org.apache.bigtop.manager.server.utils.StackUtils; import java.util.ArrayList; import java.util.List; @@ -55,20 +53,20 @@ protected void injectBeans() { @Override @SuppressWarnings("unchecked") protected CommandRequest getCommandRequest() { + StackDTO stackDTO = StackUtils.getServiceStack(taskContext.getServiceName()); CommandPayload commandPayload = new CommandPayload(); commandPayload.setServiceName(taskContext.getServiceName()); - commandPayload.setCommand(getCommand()); - commandPayload.setServiceUser(taskContext.getServiceUser()); commandPayload.setComponentName(taskContext.getComponentName()); - commandPayload.setRootDir(taskContext.getRootDir()); + commandPayload.setServiceUser(taskContext.getServiceUser()); + commandPayload.setStackName(stackDTO.getStackName()); + commandPayload.setStackVersion(stackDTO.getStackVersion()); + commandPayload.setCommand(getCommand()); + commandPayload.setCustomCommand(getCustomCommand()); Map properties = taskContext.getProperties(); - commandPayload.setCustomCommands( - convertCustomCommandInfo((List) properties.get("customCommands"))); commandPayload.setPackageSpecifics( convertPackageSpecificInfo((List) properties.get("packageSpecifics"))); - commandPayload.setCommandScript(convertScriptInfo((ScriptDTO) properties.get("commandScript"))); CommandRequest.Builder builder = CommandRequest.newBuilder(); builder.setType(CommandType.COMPONENT); @@ -77,18 +75,6 @@ protected CommandRequest getCommandRequest() { return builder.build(); } - private ScriptInfo convertScriptInfo(ScriptDTO scriptDTO) { - if (scriptDTO == null) { - return null; - } - - ScriptInfo scriptInfo = new ScriptInfo(); - scriptInfo.setScriptId(scriptDTO.getScriptId()); - scriptInfo.setScriptType(scriptDTO.getScriptType()); - scriptInfo.setTimeout(scriptDTO.getTimeout()); - return scriptInfo; - } - private List convertPackageSpecificInfo(List packageSpecificDTOList) { if (packageSpecificDTOList == null) { return new ArrayList<>(); @@ -97,7 +83,6 @@ private List convertPackageSpecificInfo(List packageSpecificInfos = new ArrayList<>(); for (PackageSpecificDTO packageSpecificDTO : packageSpecificDTOList) { PackageSpecificInfo packageSpecificInfo = new PackageSpecificInfo(); - packageSpecificInfo.setOs(packageSpecificDTO.getOs()); packageSpecificInfo.setArch(packageSpecificDTO.getArch()); List packageInfoList = new ArrayList<>(); for (PackageDTO packageDTO : packageSpecificDTO.getPackages()) { @@ -112,20 +97,4 @@ private List convertPackageSpecificInfo(List convertCustomCommandInfo(List customCommandDTOs) { - if (customCommandDTOs == null) { - return new ArrayList<>(); - } - - List customCommandInfos = new ArrayList<>(); - for (CustomCommandDTO customCommandDTO : customCommandDTOs) { - CustomCommandInfo customCommandInfo = new CustomCommandInfo(); - customCommandInfo.setName(customCommandDTO.getName()); - customCommandInfo.setCommandScript(convertScriptInfo(customCommandDTO.getCommandScript())); - customCommandInfos.add(customCommandInfo); - } - - return customCommandInfos; - } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java index cbd45153..ab26d21a 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java @@ -29,20 +29,19 @@ import org.apache.bigtop.manager.dao.po.HostPO; import org.apache.bigtop.manager.dao.po.RepoPO; import org.apache.bigtop.manager.dao.po.ServiceConfigPO; -import org.apache.bigtop.manager.dao.po.ServicePO; -import org.apache.bigtop.manager.dao.po.SettingPO; import org.apache.bigtop.manager.dao.query.ComponentQuery; import org.apache.bigtop.manager.dao.repository.ClusterDao; import org.apache.bigtop.manager.dao.repository.ComponentDao; import org.apache.bigtop.manager.dao.repository.HostDao; import org.apache.bigtop.manager.dao.repository.RepoDao; import org.apache.bigtop.manager.dao.repository.ServiceConfigDao; -import org.apache.bigtop.manager.dao.repository.ServiceDao; -import org.apache.bigtop.manager.dao.repository.SettingDao; import org.apache.bigtop.manager.grpc.generated.CommandRequest; import org.apache.bigtop.manager.grpc.generated.CommandType; import org.apache.bigtop.manager.server.holder.SpringContextHolder; import org.apache.bigtop.manager.server.model.converter.RepoConverter; +import org.apache.bigtop.manager.server.model.dto.ServiceDTO; +import org.apache.bigtop.manager.server.model.dto.StackDTO; +import org.apache.bigtop.manager.server.utils.StackUtils; import java.util.ArrayList; import java.util.HashMap; @@ -57,10 +56,8 @@ public class CacheFileUpdateTask extends AbstractTask { private ClusterDao clusterDao; - private ServiceDao serviceDao; private ServiceConfigDao serviceConfigDao; private RepoDao repoDao; - private SettingDao settingDao; private HostDao hostDao; private ComponentDao componentDao; @@ -70,7 +67,6 @@ public class CacheFileUpdateTask extends AbstractTask { private Map> hostMap; private List repoList; private Map userMap; - private Map settingsMap; public CacheFileUpdateTask(TaskContext taskContext) { super(taskContext); @@ -81,10 +77,8 @@ protected void injectBeans() { super.injectBeans(); this.clusterDao = SpringContextHolder.getBean(ClusterDao.class); - this.serviceDao = SpringContextHolder.getBean(ServiceDao.class); this.serviceConfigDao = SpringContextHolder.getBean(ServiceConfigDao.class); this.repoDao = SpringContextHolder.getBean(RepoDao.class); - this.settingDao = SpringContextHolder.getBean(SettingDao.class); this.hostDao = SpringContextHolder.getBean(HostDao.class); this.componentDao = SpringContextHolder.getBean(ComponentDao.class); } @@ -104,20 +98,19 @@ private void genCaches() { } } + @SuppressWarnings("unchecked") private void genFullCaches() { - ClusterPO clusterPO = clusterDao.findById(taskContext.getClusterId()); - - Long clusterId = clusterPO.getId(); + Long clusterId = taskContext.getClusterId(); + List hostIds = (List) taskContext.getProperties().get("hostIds"); + ClusterPO clusterPO = clusterDao.findById(clusterId); ComponentQuery componentQuery = ComponentQuery.builder().clusterId(clusterId).build(); - List servicePOList = serviceDao.findByClusterId(clusterId); List serviceConfigPOList = serviceConfigDao.findByClusterId(clusterPO.getId()); List componentPOList = componentDao.findByQuery(componentQuery); List repoPOList = repoDao.findAll(); - Iterable settings = settingDao.findAll(); - List hostPOList = hostDao.findAllByClusterId(clusterId); + List hostPOList = hostDao.findByIds(hostIds); clusterInfo = new ClusterInfo(); clusterInfo.setUserGroup(clusterPO.getUserGroup()); @@ -158,21 +151,43 @@ private void genFullCaches() { }); userMap = new HashMap<>(); - servicePOList.forEach(x -> userMap.put(x.getName(), x.getUser())); - - settingsMap = new HashMap<>(); - settings.forEach(x -> settingsMap.put(x.getTypeName(), x.getConfigData())); + for (StackDTO stackDTO : StackUtils.getAllStacks()) { + for (ServiceDTO serviceDTO : StackUtils.getServiceDTOList(stackDTO)) { + userMap.put(serviceDTO.getName(), serviceDTO.getUser()); + } + } } @SuppressWarnings("unchecked") private void genEmptyCaches() { + List hostIds = (List) taskContext.getProperties().get("hostIds"); + + List repoPOList = repoDao.findAll(); + List hostPOList = hostDao.findByIds(hostIds); + componentInfoMap = new HashMap<>(); serviceConfigMap = new HashMap<>(); + + clusterInfo = new ClusterInfo(); + clusterInfo.setUserGroup(taskContext.getUserGroup()); + clusterInfo.setRootDir(taskContext.getRootDir()); + hostMap = new HashMap<>(); - userMap = new HashMap<>(); - settingsMap = new HashMap<>(); + Set hostNameSet = hostPOList.stream().map(HostPO::getHostname).collect(Collectors.toSet()); + hostMap.put(ALL_HOST_KEY, hostNameSet); + repoList = new ArrayList<>(); - clusterInfo = new ClusterInfo(); + repoPOList.forEach(repoPO -> { + RepoInfo repoInfo = RepoConverter.INSTANCE.fromPO2Message(repoPO); + repoList.add(repoInfo); + }); + + userMap = new HashMap<>(); + for (StackDTO stackDTO : StackUtils.getAllStacks()) { + for (ServiceDTO serviceDTO : StackUtils.getServiceDTOList(stackDTO)) { + userMap.put(serviceDTO.getName(), serviceDTO.getUser()); + } + } } @Override @@ -192,7 +207,6 @@ protected CommandRequest getCommandRequest() { messagePayload.setConfigurations(serviceConfigMap); messagePayload.setClusterHostInfo(hostMap); messagePayload.setRepoInfo(repoList); - messagePayload.setSettings(settingsMap); messagePayload.setUserInfo(userMap); messagePayload.setComponentInfo(componentInfoMap); diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/TaskContext.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/TaskContext.java index 69bf8715..934d0d24 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/TaskContext.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/TaskContext.java @@ -18,7 +18,6 @@ */ package org.apache.bigtop.manager.server.command.task; -import org.apache.bigtop.manager.common.enums.Command; import org.apache.bigtop.manager.server.model.dto.HostDTO; import lombok.Data; @@ -40,11 +39,10 @@ public class TaskContext { private String componentName; + // This is for display purpose for task info(eg. task name) only private String componentDisplayName; - private Command command; - - private String customCommand; + private String userGroup; private String rootDir; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java index 5f6890eb..b8fdafcf 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java @@ -21,6 +21,7 @@ import org.apache.bigtop.manager.dao.query.HostQuery; import org.apache.bigtop.manager.server.model.converter.HostConverter; import org.apache.bigtop.manager.server.model.dto.HostDTO; +import org.apache.bigtop.manager.server.model.req.HostPathReq; import org.apache.bigtop.manager.server.model.req.HostReq; import org.apache.bigtop.manager.server.model.vo.HostVO; import org.apache.bigtop.manager.server.model.vo.PageVO; @@ -103,4 +104,10 @@ public ResponseEntity checkConnection(@RequestBody @Validated HostReq h HostDTO hostDTO = HostConverter.INSTANCE.fromReq2DTO(hostReq); return ResponseEntity.success(hostService.checkConnection(hostDTO)); } + + @Operation(summary = "Install dependencies", description = "Install dependencies on a host") + @PostMapping("/install-dependencies") + public ResponseEntity checkConnection(@RequestBody @Validated HostPathReq hostPathReq) { + return ResponseEntity.success(hostService.installDependencies(hostPathReq.getHostIds(), hostPathReq.getPath())); + } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java index 51f24a00..2b27cbb6 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java @@ -56,6 +56,12 @@ public ResponseEntity> platforms() { return ResponseEntity.success(llmConfigService.platforms()); } + @Operation(summary = "get platform", description = "Get platform") + @GetMapping("/platforms/{id}") + public ResponseEntity getPlatform(@PathVariable Long id) { + return ResponseEntity.success(llmConfigService.getPlatform(id)); + } + @Operation(summary = "platform credentials", description = "Get platform auth credentials") @GetMapping("/platforms/{platformId}/auth-credentials") public ResponseEntity> platformsAuthCredential(@PathVariable Long platformId) { diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java index 2613fc47..26d432bb 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java @@ -39,7 +39,8 @@ public enum ApiExceptionEnum { HOST_ASSIGNED(12001, LocaleKeys.HOST_ASSIGNED), HOST_NOT_CONNECTED(12002, LocaleKeys.HOST_NOT_CONNECTED), HOST_UNABLE_TO_CONNECT(12003, LocaleKeys.HOST_UNABLE_TO_CONNECT), - HOST_HAS_COMPONENTS(12004, LocaleKeys.HOST_HAS_COMPONENTS), + HOST_UNABLE_TO_EXEC_COMMAND(12004, LocaleKeys.HOST_UNABLE_TO_EXEC_COMMAND), + HOST_HAS_COMPONENTS(12005, LocaleKeys.HOST_HAS_COMPONENTS), // Stack Exceptions -- 13000 ~ 13999 STACK_NOT_FOUND(13000, LocaleKeys.STACK_NOT_FOUND), diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java index 94314912..e42d177f 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java @@ -41,6 +41,7 @@ public enum LocaleKeys { HOST_ASSIGNED("host.assigned"), HOST_NOT_CONNECTED("host.not.connected"), HOST_UNABLE_TO_CONNECT("host.unable.to.connect"), + HOST_UNABLE_TO_EXEC_COMMAND("host.unable.to.exec.command"), HOST_HAS_COMPONENTS("host.has.components"), STACK_NOT_FOUND("stack.not.found"), diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java index 59aa3fae..b28b3700 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ChatThreadConverter.java @@ -18,12 +18,15 @@ */ package org.apache.bigtop.manager.server.model.converter; +import org.apache.bigtop.manager.dao.po.AuthPlatformPO; import org.apache.bigtop.manager.dao.po.ChatThreadPO; +import org.apache.bigtop.manager.dao.po.PlatformPO; import org.apache.bigtop.manager.server.config.MapStructSharedConfig; import org.apache.bigtop.manager.server.model.dto.ChatThreadDTO; import org.apache.bigtop.manager.server.model.req.ChatbotThreadReq; import org.apache.bigtop.manager.server.model.vo.ChatThreadVO; +import org.mapstruct.Context; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -35,7 +38,10 @@ public interface ChatThreadConverter { ChatThreadConverter INSTANCE = Mappers.getMapper(ChatThreadConverter.class); @Mapping(source = "id", target = "threadId") - ChatThreadVO fromPO2VO(ChatThreadPO platformAuthorizedPO); + @Mapping(target = "model", expression = "java(authPlatformPO.getModel())") + @Mapping(target = "platformName", expression = "java(platformPO.getName())") + ChatThreadVO fromPO2VO( + ChatThreadPO platformAuthorizedPO, @Context AuthPlatformPO authPlatformPO, @Context PlatformPO platformPO); ChatThreadPO fromDTO2PO(ChatThreadDTO chatThreadDTO); diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ComponentDTO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ComponentDTO.java index 9319a22a..114d5c6f 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ComponentDTO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ComponentDTO.java @@ -33,9 +33,7 @@ public class ComponentDTO { private String cardinality; - private ScriptDTO commandScript; - - private List customCommands; + private List customCommands; private QuickLinkDTO quickLink; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/PackageSpecificDTO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/PackageSpecificDTO.java index 23c81a4c..742de7ab 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/PackageSpecificDTO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/PackageSpecificDTO.java @@ -25,8 +25,6 @@ @Data public class PackageSpecificDTO { - private List os; - private List arch; private List packages; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ScriptDTO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/req/HostPathReq.java similarity index 75% rename from bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ScriptDTO.java rename to bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/req/HostPathReq.java index 3702a5f1..a3d39bd4 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/ScriptDTO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/req/HostPathReq.java @@ -16,16 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.bigtop.manager.server.model.dto; +package org.apache.bigtop.manager.server.model.req; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -@Data -public class ScriptDTO { +import java.util.List; - private String scriptType; +@Data +public class HostPathReq { - private String scriptId; + @Schema(example = "[1, 2]") + private List hostIds; - private Long timeout; + @Schema(example = "/opt") + private String path; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java index ce49396b..846bbc39 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ChatThreadVO.java @@ -30,6 +30,10 @@ public class ChatThreadVO { private String name; + private String platformName; + + private String model; + private String createTime; private String updateTime; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PlatformVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PlatformVO.java index 5e127229..1e6c1c1e 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PlatformVO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PlatformVO.java @@ -28,9 +28,5 @@ public class PlatformVO { private String supportModels; - public PlatformVO(Long id, String name, String models) { - this.id = id; - this.name = name; - this.supportModels = models; - } + private String desc; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/CustomCommandDTO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TalkVO.java similarity index 85% rename from bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/CustomCommandDTO.java rename to bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TalkVO.java index e5fea6d3..f52de979 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/dto/CustomCommandDTO.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TalkVO.java @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.bigtop.manager.server.model.dto; +package org.apache.bigtop.manager.server.model.vo; import lombok.Data; @Data -public class CustomCommandDTO { +public class TalkVO { + private String content; - private String name; - - private ScriptDTO commandScript; + private String finishReason; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java index 4de47e85..210cae4b 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java @@ -71,4 +71,13 @@ public interface HostService { * @return true if all hosts are able to connect */ Boolean checkConnection(HostDTO hostDTO); + + /** + * Install dependencies + * + * @param hostIds host ids + * @param path remote host path + * @return true if all dependencies are installed + */ + Boolean installDependencies(List hostIds, String path); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java index c5400002..223b5723 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java @@ -46,4 +46,6 @@ public interface LLMConfigService { boolean deactivateAuthorizedPlatform(Long authId); AuthPlatformVO getAuthorizedPlatform(Long authId); + + PlatformVO getPlatform(Long id); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java index 9a3eeed6..a27b64a9 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java @@ -45,6 +45,7 @@ import org.apache.bigtop.manager.server.model.dto.ChatThreadDTO; import org.apache.bigtop.manager.server.model.vo.ChatMessageVO; import org.apache.bigtop.manager.server.model.vo.ChatThreadVO; +import org.apache.bigtop.manager.server.model.vo.TalkVO; import org.apache.bigtop.manager.server.service.ChatbotService; import org.apache.bigtop.manager.server.tools.AiServiceToolsProvider; @@ -150,7 +151,7 @@ public ChatThreadVO createChatThread(ChatThreadDTO chatThreadDTO) { ChatThreadPO chatThreadPO = ChatThreadConverter.INSTANCE.fromDTO2PO(chatThreadDTO); chatThreadPO.setUserId(userId); chatThreadDao.save(chatThreadPO); - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO, authPlatformPO, platformPO); } @Override @@ -175,6 +176,8 @@ public List getAllChatThreads() { if (authPlatformPO == null) { throw new ApiException(ApiExceptionEnum.NO_PLATFORM_IN_USE); } + PlatformPO platformPO = platformDao.findById(authPlatformPO.getPlatformId()); + Long authId = authPlatformPO.getId(); Long userId = SessionUserHolder.getUserId(); List chatThreadPOS = chatThreadDao.findAllByAuthIdAndUserId(authId, userId); @@ -183,7 +186,8 @@ public List getAllChatThreads() { if (chatThreadPO.getIsDeleted()) { continue; } - ChatThreadVO chatThreadVO = ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + ChatThreadVO chatThreadVO = + ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO, authPlatformPO, platformPO); chatThreads.add(chatThreadVO); } return chatThreads; @@ -226,13 +230,36 @@ public SseEmitter talk(Long threadId, ChatbotCommand command, String message) { stringFlux.subscribe( s -> { try { - emitter.send(s); + TalkVO talkVO = new TalkVO(); + talkVO.setContent(s); + talkVO.setFinishReason(null); + emitter.send(talkVO); } catch (Exception e) { emitter.completeWithError(e); } }, - Throwable::printStackTrace, - emitter::complete); + throwable -> { + try { + TalkVO errorVO = new TalkVO(); + errorVO.setContent(null); + errorVO.setFinishReason("Error: " + throwable.getMessage()); + emitter.send(errorVO); + } catch (Exception sendException) { + sendException.printStackTrace(); + } + emitter.completeWithError(throwable); + }, + () -> { + try { + TalkVO finishVO = new TalkVO(); + finishVO.setContent(null); + finishVO.setFinishReason("completed"); + emitter.send(finishVO); + } catch (Exception e) { + e.printStackTrace(); + } + emitter.complete(); + }); emitter.onTimeout(emitter::complete); return emitter; @@ -277,7 +304,9 @@ public ChatThreadVO updateChatThread(ChatThreadDTO chatThreadDTO) { chatThreadPO.setName(chatThreadDTO.getName()); chatThreadDao.partialUpdateById(chatThreadPO); - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + AuthPlatformPO authPlatformPO = authPlatformDao.findById(chatThreadPO.getAuthId()); + return ChatThreadConverter.INSTANCE.fromPO2VO( + chatThreadPO, authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); } @Override @@ -295,6 +324,8 @@ public ChatThreadVO getChatThread(Long threadId) { if (!chatThreadPO.getUserId().equals(userId)) { throw new ApiException(ApiExceptionEnum.PERMISSION_DENIED); } - return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + AuthPlatformPO authPlatformPO = authPlatformDao.findById(chatThreadPO.getAuthId()); + return ChatThreadConverter.INSTANCE.fromPO2VO( + chatThreadPO, authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java index 30de0974..c8951f6d 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java @@ -18,11 +18,14 @@ */ package org.apache.bigtop.manager.server.service.impl; +import org.apache.bigtop.manager.common.constants.MessageConstants; import org.apache.bigtop.manager.common.shell.ShellResult; import org.apache.bigtop.manager.dao.po.HostPO; +import org.apache.bigtop.manager.dao.po.RepoPO; import org.apache.bigtop.manager.dao.query.HostQuery; import org.apache.bigtop.manager.dao.repository.ComponentDao; import org.apache.bigtop.manager.dao.repository.HostDao; +import org.apache.bigtop.manager.dao.repository.RepoDao; import org.apache.bigtop.manager.server.enums.ApiExceptionEnum; import org.apache.bigtop.manager.server.enums.HealthyStatusEnum; import org.apache.bigtop.manager.server.enums.HostAuthTypeEnum; @@ -53,6 +56,9 @@ @Service public class HostServiceImpl implements HostService { + @Resource + private RepoDao repoDao; + @Resource private HostDao hostDao; @@ -140,25 +146,9 @@ public Boolean delete(Long id) { @Override public Boolean checkConnection(HostDTO hostDTO) { String command = "hostname"; - HostAuthTypeEnum authType = HostAuthTypeEnum.fromCode(hostDTO.getAuthType()); for (String hostname : hostDTO.getHostnames()) { try { - ShellResult result = null; - switch (authType) { - case PASSWORD -> result = RemoteSSHUtils.executeCommand( - hostname, hostDTO.getSshPort(), hostDTO.getSshUser(), hostDTO.getSshPassword(), command); - case KEY -> result = RemoteSSHUtils.executeCommand( - hostname, - hostDTO.getSshPort(), - hostDTO.getSshUser(), - hostDTO.getSshKeyFilename(), - hostDTO.getSshKeyString(), - hostDTO.getSshKeyPassword(), - command); - case NO_AUTH -> result = RemoteSSHUtils.executeCommand( - hostname, hostDTO.getSshPort(), hostDTO.getSshUser(), command); - } - + ShellResult result = execCommandOnRemoteHost(hostDTO, hostname, command); if (result.getExitCode() != 0) { log.error("Unable to connect to host, hostname: {}, msg: {}", hostname, result.getErrMsg()); throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_CONNECT, hostname); @@ -173,4 +163,116 @@ public Boolean checkConnection(HostDTO hostDTO) { return true; } + + @Override + public Boolean installDependencies(List hostIds, String path) { + List repoPOList = repoDao.findAll(); + Map archRepoMap = repoPOList.stream() + .filter(repoPO -> repoPO.getType() == 2) + .collect(Collectors.toMap(RepoPO::getArch, repo -> repo)); + + List hostPOList = hostDao.findByIds(hostIds); + for (HostPO hostPO : hostPOList) { + HostDTO hostDTO = HostConverter.INSTANCE.fromPO2DTO(hostPO); + + // Get host arch + String arch = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(), "arch") + .getOutput() + .trim(); + arch = arch.equals("arm64") ? "aarch64" : arch; + + // Download & Extract agent tarball + String repoUrl = archRepoMap.get(arch).getBaseUrl(); + String tarballUrl = repoUrl + "/bigtop-manager-agent.tar.gz"; + String command = "sudo mkdir -p " + path + " &&" + + " sudo chown -R " + hostDTO.getSshUser() + ":" + hostDTO.getSshUser() + " " + path + + " && curl -L " + tarballUrl + " | tar -xz -C " + path; + ShellResult result = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(), command); + if (result.getExitCode() != MessageConstants.SUCCESS_CODE) { + hostPO.setErrInfo(result.getErrMsg()); + hostDao.updateById(hostPO); + + log.error( + "Unable to download & extract agent tarball, hostname: {}, msg: {}", + hostDTO.getHostname(), + result.getErrMsg()); + throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_EXEC_COMMAND, hostDTO.getHostname()); + } + + // Update agent conf + // Current only grpc port needs to be updated if it's not default port + if (hostDTO.getGrpcPort() != 8835) { + command = "sed -i 's/port: 8835/port: " + hostDTO.getGrpcPort() + "/' " + path + + "/bigtop-manager-agent/conf/application.yml"; + result = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(), command); + if (result.getExitCode() != MessageConstants.SUCCESS_CODE) { + hostPO.setErrInfo(result.getErrMsg()); + hostDao.updateById(hostPO); + + log.error( + "Unable to update agent config, hostname: {}, msg: {}", + hostDTO.getHostname(), + result.getErrMsg()); + throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_EXEC_COMMAND, hostDTO.getHostname()); + } + } + + // Run agent in background + command = "nohup " + path + "/bigtop-manager-agent/bin/start.sh > /dev/null 2>&1 &"; + result = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(), command); + if (result.getExitCode() != MessageConstants.SUCCESS_CODE) { + hostPO.setErrInfo(result.getErrMsg()); + hostDao.updateById(hostPO); + + log.error("Unable to start agent, hostname: {}, msg: {}", hostDTO.getHostname(), result.getErrMsg()); + throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_EXEC_COMMAND, hostDTO.getHostname()); + } + + // Check the process, the agent may encounter some errors and exit when starting + // So we need to wait for a while before the check + try { + Thread.sleep(10 * 1000); + } catch (InterruptedException e) { + log.error("Thread sleep interrupted", e); + } + command = "ps -ef | grep bigtop-manager-agent | grep -v grep"; + result = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(), command); + if (result.getExitCode() != MessageConstants.SUCCESS_CODE + || !result.getOutput().contains("bigtop-manager-agent")) { + hostPO.setErrInfo("Unable to start agent process, please check the log"); + hostDao.updateById(hostPO); + + log.error("Unable to start agent process, hostname: {}", hostDTO.getHostname()); + throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_EXEC_COMMAND, hostDTO.getHostname()); + } + + hostPO.setStatus(HealthyStatusEnum.HEALTHY.getCode()); + hostDao.updateById(hostPO); + } + + return true; + } + + private ShellResult execCommandOnRemoteHost(HostDTO hostDTO, String hostname, String command) { + HostAuthTypeEnum authType = HostAuthTypeEnum.fromCode(hostDTO.getAuthType()); + try { + return switch (authType) { + case PASSWORD -> RemoteSSHUtils.executeCommand( + hostname, hostDTO.getSshPort(), hostDTO.getSshUser(), hostDTO.getSshPassword(), command); + case KEY -> RemoteSSHUtils.executeCommand( + hostname, + hostDTO.getSshPort(), + hostDTO.getSshUser(), + hostDTO.getSshKeyFilename(), + hostDTO.getSshKeyString(), + hostDTO.getSshKeyPassword(), + command); + case NO_AUTH -> RemoteSSHUtils.executeCommand( + hostname, hostDTO.getSshPort(), hostDTO.getSshUser(), command); + }; + } catch (Exception e) { + log.error("Unable to exec command on host, hostname: {}, command: {}", hostname, command, e); + throw new ApiException(ApiExceptionEnum.HOST_UNABLE_TO_EXEC_COMMAND, hostname); + } + } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java index 02cc0a03..7b1e1ead 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java @@ -314,6 +314,21 @@ public AuthPlatformVO updateAuthorizedPlatform(AuthPlatformDTO authPlatformDTO) throw new ApiException(ApiExceptionEnum.PLATFORM_NOT_AUTHORIZED); } + String newModel = authPlatformDTO.getModel(); + if (newModel != null) { + if (AuthPlatformStatus.isActive(authPlatformPO.getStatus())) { + throw new ApiException(ApiExceptionEnum.PLATFORM_IS_ACTIVE); + } + + authPlatformPO.setModel(newModel); + + if (authPlatformDTO.getTestPassed()) { + authPlatformPO.setStatus(AuthPlatformStatus.AVAILABLE.getCode()); + } else { + authPlatformPO.setStatus(AuthPlatformStatus.UNAVAILABLE.getCode()); + } + } + authPlatformPO.setName(authPlatformDTO.getName()); authPlatformPO.setDesc(authPlatformDTO.getDesc()); @@ -366,4 +381,13 @@ public AuthPlatformVO getAuthorizedPlatform(Long authId) { return AuthPlatformConverter.INSTANCE.fromPO2VO( authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); } + + @Override + public PlatformVO getPlatform(Long id) { + PlatformPO platformPO = platformDao.findById(id); + if (platformPO == null) { + throw new ApiException(ApiExceptionEnum.PLATFORM_NOT_FOUND); + } + return PlatformConverter.INSTANCE.fromPO2VO(platformPO); + } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ComponentModel.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ComponentModel.java index 21c8dd79..1c3bdb4b 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ComponentModel.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ComponentModel.java @@ -40,12 +40,9 @@ public class ComponentModel { private String cardinality; - @XmlElement(name = "command-script") - private ScriptModel commandScript; - @XmlElementWrapper(name = "custom-commands") @XmlElements(@XmlElement(name = "custom-command")) - private List customCommands; + private List customCommands; @XmlElement(name = "quick-link") private QuickLinkModel quickLink; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/CustomCommandModel.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/CustomCommandModel.java deleted file mode 100644 index 1517c95a..00000000 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/CustomCommandModel.java +++ /dev/null @@ -1,35 +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 - * - * https://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.bigtop.manager.server.stack.model; - -import lombok.Data; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; - -@Data -@XmlAccessorType(XmlAccessType.FIELD) -public class CustomCommandModel { - - private String name; - - @XmlElement(name = "command-script") - private ScriptModel commandScript; -} diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/PackageSpecificModel.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/PackageSpecificModel.java index a600b763..4d4c38b4 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/PackageSpecificModel.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/PackageSpecificModel.java @@ -31,10 +31,6 @@ @XmlAccessorType(XmlAccessType.FIELD) public class PackageSpecificModel { - @XmlElementWrapper(name = "operating-systems") - @XmlElements(@XmlElement(name = "os")) - private List os; - @XmlElementWrapper(name = "architectures") @XmlElements(@XmlElement(name = "arch")) private List arch; diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java index 43f47da9..a4edcac6 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java @@ -18,6 +18,7 @@ */ package org.apache.bigtop.manager.server.timer; +import org.apache.bigtop.manager.common.utils.CaseUtils; import org.apache.bigtop.manager.dao.po.ComponentPO; import org.apache.bigtop.manager.dao.po.HostPO; import org.apache.bigtop.manager.dao.repository.ComponentDao; @@ -28,32 +29,39 @@ import org.apache.bigtop.manager.server.enums.HealthyStatusEnum; import org.apache.bigtop.manager.server.grpc.GrpcClient; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + import lombok.extern.slf4j.Slf4j; +import jakarta.annotation.Resource; import java.util.List; +import java.util.concurrent.TimeUnit; @Slf4j -// @Component +@Component public class ComponentStatusTimer { - // @Resource + @Resource private ComponentDao componentDao; - // @Resource + @Resource private HostDao hostDao; - // @Async - // @Scheduled(fixedDelay = 30, timeUnit = TimeUnit.SECONDS) + @Async + @Scheduled(fixedDelay = 30, timeUnit = TimeUnit.SECONDS) public void execute() { List componentPOList = componentDao.findAll(); for (ComponentPO componentPO : componentPOList) { + componentPO = componentDao.findDetailsById(componentPO.getId()); HostPO hostPO = hostDao.findById(componentPO.getHostId()); - // TODO need to build the correct request ComponentStatusRequest request = ComponentStatusRequest.newBuilder() - // .setServiceName(hostComponentPO.getServiceName()) - // .setServiceUser(hostComponentPO.getServiceUser()) - // .setComponentName(hostComponentPO.getComponentName()) - // .setCommandScript(hostComponentPO.getCommandScript()) + .setStackName(CaseUtils.toLowerCase(componentPO.getStack().split("-")[0])) + .setStackVersion(componentPO.getStack().split("-")[1]) + .setServiceName(componentPO.getServiceName()) + .setServiceUser(componentPO.getServiceUser()) + .setComponentName(componentPO.getName()) .build(); ComponentStatusServiceGrpc.ComponentStatusServiceBlockingStub blockingStub = GrpcClient.getBlockingStub( hostPO.getHostname(), diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java index 3502b899..b8e7fba4 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java @@ -21,6 +21,7 @@ import org.apache.bigtop.manager.common.enums.Command; import org.apache.bigtop.manager.common.utils.CaseUtils; import org.apache.bigtop.manager.common.utils.JsonUtils; +import org.apache.bigtop.manager.common.utils.ProjectPathUtils; import org.apache.bigtop.manager.server.exception.ApiException; import org.apache.bigtop.manager.server.exception.ServerException; import org.apache.bigtop.manager.server.model.converter.ServiceConverter; @@ -43,7 +44,6 @@ import lombok.extern.slf4j.Slf4j; import java.io.File; -import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -58,8 +58,6 @@ public class StackUtils { private static final String META_FILE = "metainfo.xml"; - private static final String STACKS_FOLDER_NAME = "stacks"; - private static final String SERVICES_FOLDER_NAME = "services"; private static final String CONFIGURATION_FOLDER = "configuration"; @@ -78,9 +76,6 @@ public class StackUtils { parseStack(); } - /** - * - */ private static void parseStack() { File stacksFolder = loadStacksFolder(); File[] stackFolders = Optional.ofNullable(stacksFolder.listFiles()).orElse(new File[0]); @@ -171,7 +166,7 @@ private static void parseDag(File file) { DAG.addNodeIfAbsent(blocked, getCommandWrapper(blocked)); for (String blocker : blockers) { - DAG.addNodeIfAbsent(blocked, getCommandWrapper(blocked)); + DAG.addNodeIfAbsent(blocker, getCommandWrapper(blocker)); DAG.addEdge(blocker, blocked, new DagGraphEdge(blocker, blocked), false); } } @@ -194,12 +189,7 @@ private static ComponentCommandWrapper getCommandWrapper(String roleCommand) { * Load stack folder as file */ private static File loadStacksFolder() throws ApiException { - URL url = StackUtils.class.getClassLoader().getResource(STACKS_FOLDER_NAME); - if (url == null) { - throw new ServerException("Can't find stack folder"); - } - - String stackPath = url.getPath(); + String stackPath = ProjectPathUtils.getServerStackPath(); File file = new File(stackPath); if (!file.exists()) { throw new ServerException("Can't find stack folder"); @@ -213,6 +203,10 @@ public static String getFullStackName(StackDTO stackDTO) { return CaseUtils.toCamelCase(stackDTO.getStackName()) + "-" + stackDTO.getStackVersion(); } + public static List getAllStacks() { + return new ArrayList<>(STACK_SERVICE_MAP.keySet()); + } + public static StackDTO getServiceStack(String serviceName) { for (Map.Entry> entry : STACK_SERVICE_MAP.entrySet()) { for (ServiceDTO serviceDTO : entry.getValue()) { diff --git a/bigtop-manager-server/src/main/resources/assembly/server.xml b/bigtop-manager-server/src/main/resources/assembly/server.xml index c8f303f4..d8310722 100644 --- a/bigtop-manager-server/src/main/resources/assembly/server.xml +++ b/bigtop-manager-server/src/main/resources/assembly/server.xml @@ -22,10 +22,10 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> server - dir + tar.gz - false - server + true + bigtop-manager-server ${basedir}/src/main/resources diff --git a/bigtop-manager-server/src/main/resources/bin/start.sh b/bigtop-manager-server/src/main/resources/bin/start.sh index 7769d50b..9e79c8f9 100755 --- a/bigtop-manager-server/src/main/resources/bin/start.sh +++ b/bigtop-manager-server/src/main/resources/bin/start.sh @@ -62,5 +62,4 @@ cd $BIGTOP_MANAGER_HOME $JAVA_HOME/bin/java $JAVA_OPTS \ -cp "${BIGTOP_MANAGER_HOME}/conf":"${BIGTOP_MANAGER_HOME}/libs/*" \ - -Dbigtop.manager.stack.path="${BIGTOP_MANAGER_HOME}/stacks" \ org.apache.bigtop.manager.server.ServerApplication diff --git a/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql b/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql index 1255de27..79ea4e51 100644 --- a/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql +++ b/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql @@ -109,7 +109,7 @@ CREATE TABLE `host` `total_memory_size` BIGINT, `desc` VARCHAR(255) DEFAULT NULL, `status` INTEGER DEFAULT NULL COMMENT '1-healthy, 2-unhealthy, 3-unknown', - `err_info` VARCHAR(255) DEFAULT NULL, + `err_info` TEXT DEFAULT NULL, `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP, `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `create_by` BIGINT, @@ -265,23 +265,12 @@ CREATE TABLE `task` KEY idx_task_stage_id (stage_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -CREATE TABLE `setting` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `config_data` TEXT, - `create_by` BIGINT, - `create_time` DATETIME, - `type_name` VARCHAR(255), - `update_by` BIGINT, - `update_time` DATETIME, - PRIMARY KEY (id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - CREATE TABLE `llm_platform` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `credential` TEXT DEFAULT NULL, + `desc` TEXT DEFAULT NULL, `support_models` VARCHAR(255) DEFAULT NULL, `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP, `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -358,3 +347,15 @@ VALUES ('{"apiKey": "API Key"}', 'OpenAI', 'gpt-3.5-turbo,gpt-4,gpt-4o,gpt-3.5-turbo-16k,gpt-4-turbo-preview,gpt-4-32k,gpt-4o-mini'), ('{"apiKey": "API Key"}', 'DashScope', 'qwen-1.8b-chat,qwen-max,qwen-plus,qwen-turbo'), ('{"apiKey": "API Key", "secretKey": "Secret Key"}', 'QianFan','Yi-34B-Chat,ERNIE-4.0-8K,ERNIE-3.5-128K,ERNIE-Speed-8K,Llama-2-7B-Chat,Fuyu-8B'); + +UPDATE `llm_platform` +SET `desc` = 'Get your API Key in https://platform.openai.com/api-keys' +WHERE `name` = 'OpenAI'; + +UPDATE `llm_platform` +SET `desc` = 'Get your API Key in https://bailian.console.aliyun.com/?apiKey=1#/api-key' +WHERE `name` = 'DashScope'; + +UPDATE `llm_platform` +SET `desc` = 'Get API Key and Secret Key in https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1' +WHERE `name` = 'QianFan'; \ No newline at end of file diff --git a/bigtop-manager-server/src/main/resources/ddl/PostgreSQL-DDL-CREATE.sql b/bigtop-manager-server/src/main/resources/ddl/PostgreSQL-DDL-CREATE.sql index 98c8173c..e2b5ca39 100644 --- a/bigtop-manager-server/src/main/resources/ddl/PostgreSQL-DDL-CREATE.sql +++ b/bigtop-manager-server/src/main/resources/ddl/PostgreSQL-DDL-CREATE.sql @@ -97,7 +97,7 @@ CREATE TABLE host total_memory_size BIGINT, "desc" VARCHAR(255) DEFAULT NULL, status INT DEFAULT NULL, - err_info VARCHAR(255) DEFAULT NULL, + err_info TEXT DEFAULT NULL, create_time TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP, create_by BIGINT, @@ -275,23 +275,12 @@ CREATE INDEX idx_task_cluster_id ON task (cluster_id); CREATE INDEX idx_task_job_id ON task (job_id); CREATE INDEX idx_task_stage_id ON task (stage_id); -CREATE TABLE setting -( - id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY, - config_data TEXT, - create_by BIGINT, - create_time TIMESTAMP(0), - type_name VARCHAR(255), - update_by BIGINT, - update_time TIMESTAMP(0), - PRIMARY KEY (id) -); - CREATE TABLE llm_platform ( id BIGINT CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY, name VARCHAR(255) NOT NULL, credential TEXT DEFAULT NULL, + "desc" TEXT DEFAULT NULL, support_models VARCHAR(255) DEFAULT NULL, create_time TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP /* ON UPDATE CURRENT_TIMESTAMP */, @@ -369,3 +358,15 @@ VALUES ('{"apiKey": "API Key"}','OpenAI','gpt-3.5-turbo,gpt-4,gpt-4o,gpt-3.5-turbo-16k,gpt-4-turbo-preview,gpt-4-32k,gpt-4o-mini'), ('{"apiKey": "API Key"}','DashScope','qwen-1.8b-chat,qwen-max,qwen-plus,qwen-turbo'), ('{"apiKey": "API Key", "secretKey": "Secret Key"}','QianFan','Yi-34B-Chat,ERNIE-4.0-8K,ERNIE-3.5-128K,ERNIE-Speed-8K,Llama-2-7B-Chat,Fuyu-8B'); + +UPDATE llm_platform +SET "desc" = 'Get your API Key in https://platform.openai.com/api-keys' +WHERE "name" = 'OpenAI'; + +UPDATE llm_platform +SET "desc" = 'Get your API Key in https://bailian.console.aliyun.com/?apiKey=1#/api-key' +WHERE "name" = 'DashScope'; + +UPDATE llm_platform +SET "desc" = 'Get API Key and Secret Key in https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1' +WHERE "name" = 'QianFan'; diff --git a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties index 03f44141..d18f087f 100644 --- a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties +++ b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties @@ -35,6 +35,7 @@ host.not.found=Host not exist host.assigned=Hosts [{0}] already assigned to another cluster host.not.connected=Hosts [{0}] not connected host.unable.to.connect=Unable to connect to host [{0}] +host.unable.to.exec.command=Unable to execute command on host [{0}] host.has.components=Host still has components, please remove them first stack.not.found=Stack not exist diff --git a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties index df922bb3..a12bbc2b 100644 --- a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties +++ b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties @@ -35,6 +35,7 @@ host.not.found=主机不存在 host.assigned=主机 [{0}] 已属于其他集群 host.not.connected=主机 [{0}] 未连接 host.unable.to.connect=无法连接到主机 [{0}] +host.unable.to.exec.command=无法在主机 [{0}] 上执行命令 host.has.components=主机上仍有组件,请先移除 stack.not.found=组件栈不存在 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/flink/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/flink/metainfo.xml index ba3ef91f..dd989a05 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/flink/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/flink/metainfo.xml @@ -30,13 +30,8 @@ flink_history_server Flink History Server - master + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.flink.FlinkHistoryServerScript - java - 1200 - Flink HistoryServer UI historyserver.web.port @@ -50,21 +45,11 @@ Flink Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.flink.FlinkClientScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hdfs/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hdfs/metainfo.xml index 830a9a52..2d8215b0 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hdfs/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hdfs/metainfo.xml @@ -30,30 +30,11 @@ namenode NameNode - master + server 1-2 - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.NameNodeScript - java - 1200 - - - rebalance_hdfs - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.NameNodeScript - java - 600 - - - - print_topology - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.NameNodeScript - java - 600 - - + rebalance_hdfs + print_topology NameNode UI @@ -66,45 +47,25 @@ datanode DataNode - slave + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.DataNodeScript - java - 1200 - secondary_namenode SNameNode - master + server 1 - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.SNameNodeScript - java - 1200 - hdfs_client HDFS Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.hdfs.HdfsClientScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/kafka/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/kafka/metainfo.xml index 4722ea7a..2c113d53 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/kafka/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/kafka/metainfo.xml @@ -34,33 +34,13 @@ kafka_broker Kafka Broker - master + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.kafka.KafkaBrokerScript - java - 1200 - - - - test - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.kafka.KafkaBrokerScript - java - 600 - - - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/mapred/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/mapred/metainfo.xml index c920e2c6..698fdcd7 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/mapred/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/mapred/metainfo.xml @@ -30,13 +30,8 @@ history_server History Server - master + server 1 - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.mapred.HistoryServerScript - java - 1200 - JobHistory UI mapreduce.jobhistory.webapp.address @@ -50,21 +45,11 @@ MapReduce2 Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.mapred.MapredClientScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/solr/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/solr/metainfo.xml index 506669c0..95ee24a0 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/solr/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/solr/metainfo.xml @@ -31,13 +31,8 @@ solr_instance Solr Instance - master + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.solr.SolrServerScript - java - 1200 - Solr UI solr_port @@ -50,11 +45,6 @@ - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/tez/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/tez/metainfo.xml index 7ce3bbd8..3ca39261 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/tez/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/tez/metainfo.xml @@ -32,21 +32,11 @@ Tez Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.tez.TezClientScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/yarn/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/yarn/metainfo.xml index f725d49c..ffc8eb33 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/yarn/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/yarn/metainfo.xml @@ -30,31 +30,8 @@ resourcemanager ResourceManager - master + server 1-2 - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.yarn.ResourceManagerScript - java - 1200 - - - - decommission - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.yarn.ResourceManagerScript - java - 600 - - - - refreshqueues - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.yarn.ResourceManagerScript - java - 600 - - - ResourceManager UI yarn.resourcemanager.webapp.address @@ -66,34 +43,19 @@ nodemanager NodeManager - slave + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.yarn.NodeManagerScript - java - 1200 - yarn_client YARN Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.yarn.YarnClientScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 diff --git a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml index 52115a5e..29a95f92 100644 --- a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml @@ -33,13 +33,8 @@ zookeeper_server ZooKeeper Server - master + server 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.zookeeper.ZookeeperServerScript - java - 1200 - @@ -47,26 +42,19 @@ ZooKeeper Client client 1+ - - org.apache.bigtop.manager.stack.bigtop.v3_3_0.zookeeper.ZookeeperClientScript - java - - - centos7 - rocky8 - openeuler22 - x86_64 + aarch64 - zookeeper_3_3_0 + zookeeper-3.7.2-1.tar.gz + 380f15d55c0282e33fdc7c2ec551bc5586f0ac126c243cd84347ccb775b846f3 diff --git a/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/metainfo.xml b/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/metainfo.xml index ec1ec1e9..b0e7b606 100644 --- a/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/metainfo.xml +++ b/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/metainfo.xml @@ -34,23 +34,13 @@ prometheus_server Prometheus Server - master + server 1+ - - org.apache.bigtop.manager.stack.infra.v1_0_0.prometheus.PrometheusServerScript - java - 1200 - - - centos7 - rocky8 - openeuler22 - x86_64 @@ -62,9 +52,6 @@ - - openeuler22 - aarch64 diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/param/BigtopParams.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/param/BigtopParams.java index b79bb0a0..b30efc93 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/param/BigtopParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/param/BigtopParams.java @@ -26,22 +26,4 @@ public abstract class BigtopParams extends BaseParams { protected BigtopParams(CommandPayload commandPayload) { super(commandPayload); } - - public String stackBinDir() { - return ""; - } - - public String stackLibDir() { - return ""; - } - - /** - * service home dir - */ - @Override - public String serviceHome() { - String rootDir = this.commandPayload.getRootDir(); - String service = this.commandPayload.getServiceName(); - return rootDir + "/" + service.toLowerCase(); - } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkHistoryServerScript.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkHistoryServerScript.java index 34663933..0c4a4103 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkHistoryServerScript.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkHistoryServerScript.java @@ -39,9 +39,9 @@ public ShellResult configure(Params params) { public ShellResult start(Params params) { configure(params); FlinkParams flinkParams = (FlinkParams) params; - String hadoopClasspath = flinkParams.stackBinDir() + "/hadoop classpath"; - String cmd = "export HADOOP_CLASSPATH=`" + hadoopClasspath + "`;" + flinkParams.stackLibDir() - + "/flink/bin/historyserver.sh start"; + String hadoopClasspath = flinkParams.hadoopHome() + "/bin/hadoop classpath"; + String cmd = "export HADOOP_CLASSPATH=`" + hadoopClasspath + "`;" + flinkParams.serviceHome() + + "/bin/historyserver.sh start"; try { return LinuxOSUtils.sudoExecCmd(cmd, flinkParams.user()); } catch (Exception e) { @@ -52,7 +52,7 @@ public ShellResult start(Params params) { @Override public ShellResult stop(Params params) { FlinkParams flinkParams = (FlinkParams) params; - String cmd = flinkParams.stackLibDir() + "/flink/bin/historyserver.sh stop"; + String cmd = flinkParams.serviceHome() + "/bin/historyserver.sh stop"; try { return LinuxOSUtils.sudoExecCmd(cmd, flinkParams.user()); } catch (Exception e) { diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkParams.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkParams.java index 8a16fa58..6d7d4bfb 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkParams.java @@ -119,16 +119,11 @@ public String confDir() { return "/etc/flink/conf"; } - @Override - public String serviceHome() { - return stackLibDir() + "/flink"; - } - public String hadoopConfDir() { return "/etc/hadoop/conf"; } public String hadoopHome() { - return stackLibDir() + "/hadoop"; + return stackHome() + "/hadoop"; } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsParams.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsParams.java index b8fb1217..4d5c3371 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsParams.java @@ -145,16 +145,11 @@ public String confDir() { return "/etc/hadoop/conf"; } - @Override - public String serviceHome() { - return stackLibDir() + "/hadoop"; - } - public String hdfsHome() { - return stackLibDir() + "/hadoop-hdfs"; + return stackHome() + "/hadoop-hdfs"; } public String hdfsExec() { - return stackBinDir() + "/hdfs"; + return serviceHome() + "/bin/hdfs"; } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/mapred/Mapreduce2Params.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/mapred/Mapreduce2Params.java index 8c763420..e5c23e1c 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/mapred/Mapreduce2Params.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/mapred/Mapreduce2Params.java @@ -77,24 +77,19 @@ public String confDir() { return "/etc/hadoop/conf"; } - @Override - public String serviceHome() { - return stackLibDir() + "/hadoop"; - } - public String hdfsHome() { - return stackLibDir() + "/hadoop-hdfs"; + return stackHome() + "/hadoop-hdfs"; } public String yarnHome() { - return stackLibDir() + "/hadoop-yarn"; + return stackHome() + "/hadoop-yarn"; } public String mapredHome() { - return stackLibDir() + "/hadoop-mapreduce"; + return stackHome() + "/hadoop-mapreduce"; } public String mapredExec() { - return stackBinDir() + "/mapred"; + return serviceHome() + "/bin/mapred"; } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/tez/TezParams.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/tez/TezParams.java index 002157b6..c9193447 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/tez/TezParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/tez/TezParams.java @@ -79,24 +79,19 @@ public String confDir() { return "/etc/tez/conf"; } - @Override - public String serviceHome() { - return stackLibDir() + "/tez"; - } - public String hadoopConfDir() { return "/etc/hadoop/conf"; } public String hadoopHome() { - return stackLibDir() + "/hadoop"; + return stackHome() + "/hadoop"; } public String hdfsHome() { - return stackLibDir() + "/hadoop-hdfs"; + return stackHome() + "/hadoop-hdfs"; } public String yarnHome() { - return stackLibDir() + "/hadoop-yarn"; + return stackHome() + "/hadoop-yarn"; } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnParams.java b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnParams.java index ebf6ee5e..16f2095d 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnParams.java @@ -107,24 +107,19 @@ public String confDir() { return "/etc/hadoop/conf"; } - @Override - public String serviceHome() { - return stackLibDir() + "/hadoop"; - } - public String hdfsHome() { - return stackLibDir() + "/hadoop-hdfs"; + return stackHome() + "/hadoop-hdfs"; } public String yarnExec() { - return stackBinDir() + "/yarn"; + return stackHome() + "/yarn"; } public String yarnHome() { - return stackLibDir() + "/hadoop-yarn"; + return stackHome() + "/hadoop-yarn"; } public String mapredHome() { - return stackLibDir() + "/hadoop-mapreduce"; + return stackHome() + "/hadoop-mapreduce"; } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/executor/StackExecutor.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/executor/StackExecutor.java index 7ef3a423..f570bf3a 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/executor/StackExecutor.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/executor/StackExecutor.java @@ -21,7 +21,6 @@ import org.apache.bigtop.manager.common.constants.MessageConstants; 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.CustomCommandInfo; import org.apache.bigtop.manager.common.shell.ShellResult; import org.apache.bigtop.manager.common.utils.CaseUtils; import org.apache.bigtop.manager.common.utils.Environments; @@ -34,7 +33,6 @@ import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; -import java.util.List; import java.util.Map; @Slf4j @@ -44,7 +42,11 @@ public class StackExecutor { private static final Map HOOK_MAP = new PrioritySPIFactory<>(Hook.class).getSPIMap(); - private static Script getCommandScript(String scriptId) { + private static Script getCommandScript(CommandPayload commandPayload) { + String componentName = commandPayload.getComponentName(); + String packageName = getPackageName(commandPayload); + String scriptId = + packageName + "." + CaseUtils.toCamelCase(componentName, CaseUtils.SEPARATOR_UNDERSCORE) + "Script"; Script script = SCRIPT_MAP.get(scriptId); if (script == null) { throw new StackException("Cannot find Script Class {0}", scriptId); @@ -53,19 +55,11 @@ private static Script getCommandScript(String scriptId) { return script; } - private static Script getCustomScript(String customCommand, List customCommands) { - Script script = null; - for (CustomCommandInfo customCommandInfo : customCommands) { - if (customCommandInfo.getName().equals(customCommand)) { - script = getCommandScript(customCommandInfo.getCommandScript().getScriptId()); - } - } - - if (script == null) { - throw new StackException("Cannot find script class {0}", customCommand); - } - - return script; + private static String getPackageName(CommandPayload commandPayload) { + return "org.apache.bigtop.manager.stack" + "." + + CaseUtils.toLowerCase(commandPayload.getStackName()) + ".v" + + commandPayload.getStackVersion().replaceAll("\\.", "_") + "." + + CaseUtils.toLowerCase(commandPayload.getServiceName()); } private static void runBeforeHook(String command, Params params) { @@ -84,20 +78,15 @@ private static void runAfterHook(String command, Params params) { public static ShellResult execute(CommandPayload commandPayload) { try { - String command; - Script script; - if (commandPayload.getCommand().name().equals(Command.CUSTOM.name())) { - command = commandPayload.getCustomCommand(); - script = getCustomScript(command, commandPayload.getCustomCommands()); - } else { - command = commandPayload.getCommand().name(); - script = getCommandScript(commandPayload.getCommandScript().getScriptId()); - } + String command = commandPayload.getCommand() == Command.CUSTOM + ? commandPayload.getCustomCommand() + : commandPayload.getCommand().name(); + Script script = getCommandScript(commandPayload); String methodName = CaseUtils.toCamelCase(command, CaseUtils.SEPARATOR_UNDERSCORE, false); Method method = script.getClass().getMethod(methodName, Params.class); - String paramsClassName = script.getClass().getPackageName() + "." + String paramsClassName = getPackageName(commandPayload) + "." + CaseUtils.toCamelCase(commandPayload.getServiceName()) + "Params"; Class paramsClass = Class.forName(paramsClassName); Params params = (Params) diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java index 514ae5fb..b0e689c6 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java @@ -29,8 +29,6 @@ import org.apache.bigtop.manager.stack.core.exception.StackException; import org.apache.bigtop.manager.stack.core.utils.LocalSettings; -import org.apache.commons.lang3.StringUtils; - import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -41,8 +39,6 @@ import java.util.List; import java.util.Map; -import static org.apache.bigtop.manager.common.constants.Constants.ROOT_USER; - @Slf4j public abstract class BaseParams implements Params { @@ -90,9 +86,7 @@ public String confDir() { @Override public String user() { - return StringUtils.isNotBlank(this.commandPayload.getServiceUser()) - ? this.commandPayload.getServiceUser() - : ROOT_USER; + return this.commandPayload.getServiceUser(); } @Override @@ -103,7 +97,8 @@ public String group() { @Override public RepoInfo repo() { return LocalSettings.repos().stream() - .filter(r -> OSDetection.getArch().equals(r.getArch())) + // Use service tarballs repo(type == 1) + .filter(r -> OSDetection.getArch().equals(r.getArch()) && r.getType() == 1) .findFirst() .orElseThrow(() -> new StackException( "Cannot find repo for os: [{0}] and arch: [{1}]", OSDetection.getOS(), OSDetection.getArch())); @@ -114,7 +109,7 @@ public List packages() { RepoInfo repo = this.repo(); List packageInfoList = new ArrayList<>(); for (PackageSpecificInfo packageSpecificInfo : this.commandPayload.getPackageSpecifics()) { - if (packageSpecificInfo.getArch().contains(repo.getArch())) { + if (!packageSpecificInfo.getArch().contains(repo.getArch())) { continue; } @@ -131,9 +126,13 @@ public String serviceName() { @Override public String stackHome() { - String stackName = this.commandPayload.getStackName(); - String stackVersion = this.commandPayload.getStackVersion(); - String root = this.commandPayload.getRootDir(); - return MessageFormat.format("{0}/{1}/{2}", root, stackName.toLowerCase(), stackVersion); + String root = LocalSettings.cluster().getRootDir(); + return MessageFormat.format("{0}/services", root); + } + + @Override + public String serviceHome() { + String service = this.commandPayload.getServiceName(); + return MessageFormat.format("{0}/{1}", stackHome(), service.toLowerCase()); } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/InstallHook.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/AddHook.java similarity index 94% rename from bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/InstallHook.java rename to bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/AddHook.java index 2ef0c28b..4ec0cd6a 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/InstallHook.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/hook/AddHook.java @@ -29,9 +29,9 @@ */ @Slf4j @AutoService(Hook.class) -public class InstallHook extends AbstractHook { +public class AddHook extends AbstractHook { - public static final String NAME = "install"; + public static final String NAME = "add"; @Override public void doBefore(Params params) { diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java index f0554857..42f4c39f 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java @@ -18,16 +18,21 @@ */ package org.apache.bigtop.manager.stack.core.spi.script; +import org.apache.bigtop.manager.common.constants.Constants; import org.apache.bigtop.manager.common.message.entity.pojo.PackageInfo; import org.apache.bigtop.manager.common.message.entity.pojo.RepoInfo; import org.apache.bigtop.manager.common.shell.ShellResult; import org.apache.bigtop.manager.stack.core.param.Params; import org.apache.bigtop.manager.stack.core.utils.TarballUtils; +import org.apache.bigtop.manager.stack.core.utils.linux.LinuxAccountUtils; +import org.apache.bigtop.manager.stack.core.utils.linux.LinuxFileUtils; import org.apache.commons.lang3.StringUtils; import lombok.extern.slf4j.Slf4j; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import java.util.Properties; @@ -47,9 +52,21 @@ public ShellResult add(Params params, Properties properties) { String stackHome = params.stackHome(); String serviceHome = params.serviceHome(); + if (!Files.exists(Path.of(stackHome))) { + String user = System.getProperty("user.name"); + String group = params.group(); + + LinuxAccountUtils.assignUserToSupGroups(user, List.of(group)); + LinuxFileUtils.createDirectories(stackHome, user, group, Constants.PERMISSION_755, true); + } + for (PackageInfo packageInfo : packages) { Integer skipLevels = Integer.parseInt(properties.getProperty(PROPERTY_KEY_SKIP_LEVELS, "0")); TarballUtils.installPackage(repo.getBaseUrl(), stackHome, serviceHome, packageInfo, skipLevels); + + // Dir already created by TarballUtils, this changes the owner and permission for the service + LinuxFileUtils.createDirectories( + serviceHome, params.user(), params.group(), Constants.PERMISSION_755, true); } return ShellResult.success(); diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java index cb6bf087..b05c3c9f 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java @@ -23,10 +23,13 @@ import org.apache.bigtop.manager.stack.core.tarball.ChecksumValidator; import org.apache.bigtop.manager.stack.core.tarball.TarballDownloader; import org.apache.bigtop.manager.stack.core.tarball.TarballExtractor; +import org.apache.bigtop.manager.stack.core.utils.linux.LinuxFileUtils; import lombok.extern.slf4j.Slf4j; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; @Slf4j public class TarballUtils { @@ -34,6 +37,11 @@ public class TarballUtils { @SuppressWarnings("ResultOfMethodCallIgnored") public static void installPackage( String repoUrl, String stackHome, String serviceHome, PackageInfo packageInfo, Integer skipLevels) { + if (Files.exists(Path.of(serviceHome))) { + log.info("Service home [{}] exists, deleting...", serviceHome); + LinuxFileUtils.removeDirectories(serviceHome); + } + String remoteUrl = repoUrl + File.separator + packageInfo.getName(); File localFile = new File(stackHome + File.separator + packageInfo.getName()); String algorithm = packageInfo.getChecksum().split(":")[0]; diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java index 99de7d82..0144d134 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java @@ -18,6 +18,7 @@ */ package org.apache.bigtop.manager.stack.core.utils.linux; +import org.apache.bigtop.manager.common.constants.MessageConstants; import org.apache.bigtop.manager.common.shell.ShellExecutor; import org.apache.bigtop.manager.common.shell.ShellResult; import org.apache.bigtop.manager.common.utils.FileUtils; @@ -67,7 +68,10 @@ public static void userDel(String user) { builderParameters.add(user); try { - ShellExecutor.execCommand(builderParameters); + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } } catch (IOException e) { throw new StackException(e); } @@ -154,7 +158,10 @@ public static void userAdd( builderParameters.add(user); try { - ShellExecutor.execCommand(builderParameters); + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } } catch (IOException e) { throw new StackException(e); } @@ -179,7 +186,10 @@ public static void groupDel(String group) { builderParameters.add(group); try { - ShellExecutor.execCommand(builderParameters); + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } } catch (IOException e) { throw new StackException(e); } @@ -227,7 +237,37 @@ public static void groupAdd(String group, String gid, String password) { builderParameters.add(group); try { - ShellExecutor.execCommand(builderParameters); + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } + } catch (IOException e) { + throw new StackException(e); + } + } + + /** + * Assign user to supplementary groups + * + * @param user user + * @param groups groups + */ + public static void assignUserToSupGroups(String user, List groups) { + Objects.requireNonNull(user); + Objects.requireNonNull(groups); + + List builderParameters = new ArrayList<>(); + + builderParameters.add("usermod"); + builderParameters.add("-aG"); + builderParameters.add(String.join(",", groups)); + builderParameters.add(user); + + try { + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } } catch (IOException e) { throw new StackException(e); } @@ -249,7 +289,7 @@ public static boolean isGroupExists(String group) { builderParameters.add("awk -F':' '{print $1}' /etc/group | grep " + group); try { - ShellResult output = ShellExecutor.execCommand(builderParameters); + ShellResult output = sudoExecCmd(builderParameters); return output.getExitCode() == 0; } catch (IOException e) { throw new StackException(e); @@ -271,7 +311,7 @@ public static boolean isUserExists(String user) { builderParameters.add("awk -F':' '{print $1}' /etc/passwd | grep " + user); try { - ShellResult output = ShellExecutor.execCommand(builderParameters); + ShellResult output = sudoExecCmd(builderParameters); return output.getExitCode() == 0; } catch (IOException e) { throw new StackException(e); @@ -314,4 +354,16 @@ public static String getUserPrimaryGroup(String user) { return null; } + + private static ShellResult sudoExecCmd(List params) throws IOException { + if ("root".equals(System.getProperty("user.name"))) { + return ShellExecutor.execCommand(params); + } else { + List sudoParams = new ArrayList<>(); + sudoParams.add("sudo"); + sudoParams.addAll(params); + + return ShellExecutor.execCommand(sudoParams); + } + } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java index a143afae..65b48949 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java +++ b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java @@ -19,6 +19,9 @@ package org.apache.bigtop.manager.stack.core.utils.linux; import org.apache.bigtop.manager.common.constants.Constants; +import org.apache.bigtop.manager.common.constants.MessageConstants; +import org.apache.bigtop.manager.common.shell.ShellExecutor; +import org.apache.bigtop.manager.common.shell.ShellResult; import org.apache.bigtop.manager.common.utils.JsonUtils; import org.apache.bigtop.manager.common.utils.YamlUtils; import org.apache.bigtop.manager.stack.core.enums.ConfigType; @@ -29,18 +32,12 @@ import lombok.extern.slf4j.Slf4j; -import java.io.File; import java.io.IOException; -import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.attribute.GroupPrincipal; -import java.nio.file.attribute.PosixFileAttributeView; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; -import java.nio.file.attribute.UserPrincipal; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; /** * Only support Linux @@ -130,85 +127,6 @@ public static void toFileByTemplate( updatePermissions(filename, permissions, false); } - /** - * Update file Permissions - * - * @param dir file path - * @param permissions {@code rwxr--r--} - * @param recursive recursive - */ - public static void updatePermissions(String dir, String permissions, boolean recursive) { - if (StringUtils.isBlank(dir)) { - log.error("dir must not be null"); - return; - } - permissions = StringUtils.isBlank(permissions) ? Constants.PERMISSION_644 : permissions; - - Path path = Paths.get(dir); - Set perms = PosixFilePermissions.fromString(permissions); - try { - log.info("Changing permissions to [{}] for [{}]", permissions, dir); - Files.setPosixFilePermissions(path, perms); - } catch (IOException e) { - log.error("Error when change permissions", e); - } - - // When is a directory, recursive update - if (recursive && Files.isDirectory(path)) { - try (DirectoryStream ds = Files.newDirectoryStream(path)) { - for (Path subPath : ds) { - updatePermissions(dir + File.separator + subPath.getFileName(), permissions, true); - } - } catch (IOException e) { - log.error("Error when change permissions", e); - } - } - } - - /** - * Update file owner - * - * @param dir file path - * @param owner owner - * @param group group - * @param recursive recursive - */ - public static void updateOwner(String dir, String owner, String group, boolean recursive) { - if (StringUtils.isBlank(dir)) { - log.error("dir must not be null"); - return; - } - owner = StringUtils.isBlank(owner) ? "root" : owner; - group = StringUtils.isBlank(group) ? "root" : group; - - Path path = Paths.get(dir); - try { - log.info("Changing owner to [{}:{}] for [{}]", owner, group, dir); - UserPrincipal userPrincipal = - path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName(owner); - - GroupPrincipal groupPrincipal = - path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByGroupName(group); - - PosixFileAttributeView fileAttributeView = Files.getFileAttributeView(path, PosixFileAttributeView.class); - fileAttributeView.setOwner(userPrincipal); - fileAttributeView.setGroup(groupPrincipal); - } catch (IOException e) { - log.error("Error when change owner", e); - } - - // When it is a directory, recursively set the file owner - if (recursive && Files.isDirectory(path)) { - try (DirectoryStream ds = Files.newDirectoryStream(path)) { - for (Path subPath : ds) { - updateOwner(dir + File.separator + subPath.getFileName(), owner, group, true); - } - } catch (IOException e) { - log.error("Error when change owner", e); - } - } - } - /** * create directories * @@ -231,25 +149,45 @@ public static void createDirectories( return; } + List builderParameters = new ArrayList<>(); + builderParameters.add("mkdir"); + builderParameters.add("-p"); + builderParameters.add(dirPath); + try { - log.info("Creating directory: [{}]", path); - if (Files.exists(path)) { - if (Files.isDirectory(path)) { - log.info("Directory already exists: [{}], skip creating", path); - } else { - throw new IOException("Path exists and is not a directory: " + path); - } - } else { - Files.createDirectories(path); + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); } } catch (IOException e) { - log.error("Error when create directory", e); + throw new StackException(e); } updateOwner(dirPath, owner, group, recursive); updatePermissions(dirPath, permissions, recursive); } + public static void removeDirectories(String dirPath) { + if (StringUtils.isBlank(dirPath)) { + log.error("dirPath must not be null"); + return; + } + + List builderParameters = new ArrayList<>(); + builderParameters.add("rm"); + builderParameters.add("-rf"); + builderParameters.add(dirPath); + + try { + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } + } catch (IOException e) { + throw new StackException(e); + } + } + /** * create symbolic link * @@ -285,4 +223,85 @@ public static void createSymbolicLink(String target, String source) { throw new StackException(e); } } + + /** + * Update file Permissions + * + * @param dir file path + * @param permissions {@code rwxr--r--} + * @param recursive recursive + */ + public static void updatePermissions(String dir, String permissions, boolean recursive) { + if (StringUtils.isBlank(dir)) { + log.error("dir must not be null"); + return; + } + + permissions = StringUtils.isBlank(permissions) ? Constants.PERMISSION_644 : permissions; + + List builderParameters = new ArrayList<>(); + builderParameters.add("chmod"); + if (recursive && Files.isDirectory(Paths.get(dir))) { + builderParameters.add("-R"); + } + builderParameters.add(permissions); + builderParameters.add(dir); + + try { + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } + } catch (IOException e) { + throw new StackException(e); + } + } + + /** + * Update file owner + * + * @param dir file path + * @param owner owner + * @param group group + * @param recursive recursive + */ + public static void updateOwner(String dir, String owner, String group, boolean recursive) { + if (StringUtils.isBlank(dir)) { + log.error("dir must not be null"); + return; + } + + owner = StringUtils.isBlank(owner) ? "root" : owner; + group = StringUtils.isBlank(group) ? "root" : group; + + List builderParameters = new ArrayList<>(); + + builderParameters.add("chown"); + if (recursive && Files.isDirectory(Paths.get(dir))) { + builderParameters.add("-R"); + } + builderParameters.add(owner + ":" + group); + builderParameters.add(dir); + + try { + ShellResult shellResult = sudoExecCmd(builderParameters); + if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) { + throw new StackException(shellResult.getErrMsg()); + } + } catch (IOException e) { + throw new StackException(e); + } + } + + private static ShellResult sudoExecCmd(List params) throws IOException { + if ("root".equals(System.getProperty("user.name"))) { + return ShellExecutor.execCommand(params); + } else { + List sudoParams = new ArrayList<>(); + sudoParams.add("sudo"); + sudoParams.addAll(params); + + return ShellExecutor.execCommand(sudoParams); + } + } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/param/InfraParams.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/param/InfraParams.java index f78f8058..89e5ad3b 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/param/InfraParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/param/InfraParams.java @@ -23,21 +23,10 @@ import lombok.extern.slf4j.Slf4j; -import java.text.MessageFormat; - @Slf4j public abstract class InfraParams extends BaseParams { protected InfraParams(CommandPayload commandPayload) { super(commandPayload); } - - /** - * service home dir - */ - @Override - public String serviceHome() { - String service = this.commandPayload.getServiceName(); - return MessageFormat.format("{0}/{1}", stackHome(), service.toLowerCase()); - } } diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java index 78efa805..69a32846 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java @@ -54,7 +54,10 @@ public ShellResult start(Params params) { "nohup {0}/prometheus --config.file={0}/prometheus.yml --storage.tsdb.path={0}/data > {0}/nohup.out 2>&1 &", prometheusParams.serviceHome()); try { - LinuxOSUtils.sudoExecCmd(cmd, prometheusParams.user()); + ShellResult shellResult = LinuxOSUtils.sudoExecCmd(cmd, prometheusParams.user()); + if (shellResult.getExitCode() != 0) { + throw new StackException("Failed to start Prometheus: {0}", shellResult.getErrMsg()); + } long startTime = System.currentTimeMillis(); long maxWaitTime = 5000; long pollInterval = 500; diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java index 0a1eb357..b4063b91 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java @@ -37,7 +37,6 @@ public static ShellResult config(Params params) { String user = prometheusParams.user(); String group = prometheusParams.group(); - LinuxFileUtils.createDirectories(prometheusParams.serviceHome(), user, group, PERMISSION_755, true); LinuxFileUtils.createDirectories(prometheusParams.dataDir(), user, group, PERMISSION_755, true); return ShellResult.success("Prometheus Configure success!"); diff --git a/bigtop-manager-ui/.prettierignore b/bigtop-manager-ui/.prettierignore index f4211017..1852c01b 100644 --- a/bigtop-manager-ui/.prettierignore +++ b/bigtop-manager-ui/.prettierignore @@ -15,4 +15,9 @@ node_modules dist -public \ No newline at end of file +public + +package.json +pnpm-lock.yaml + +**/*.md \ No newline at end of file diff --git a/bigtop-manager-ui/.prettierrc.js b/bigtop-manager-ui/.prettierrc.js index 6943d21c..a2007ad6 100644 --- a/bigtop-manager-ui/.prettierrc.js +++ b/bigtop-manager-ui/.prettierrc.js @@ -18,15 +18,16 @@ */ module.exports = { - useTabs: false, - semi: false, - vueIndentScriptAndStyle: true, - singleQuote: true, - quoteProps: 'as-needed', - jsxBracketSameLine: false, - jsxSingleQuote: true, - arrowParens: 'always', - htmlWhitespaceSensitivity: 'strict', - endOfLine: 'lf', - trailingComma: 'none' -} \ No newline at end of file + useTabs: false, + printWidth: 120, + semi: false, + vueIndentScriptAndStyle: true, + singleQuote: true, + quoteProps: 'as-needed', + jsxBracketSameLine: false, + jsxSingleQuote: true, + arrowParens: 'always', + htmlWhitespaceSensitivity: 'strict', + endOfLine: 'lf', + trailingComma: 'none' +} diff --git a/bigtop-manager-ui/index.html b/bigtop-manager-ui/index.html index e8559bfd..24db7b5d 100644 --- a/bigtop-manager-ui/index.html +++ b/bigtop-manager-ui/index.html @@ -19,18 +19,16 @@ + + + + + + Bigtop Manager + - - - - - - Bigtop Manager - - - -
- - - - \ No newline at end of file + +
+ + + diff --git a/bigtop-manager-ui/package.json b/bigtop-manager-ui/package.json index 2c7a53d9..e50625af 100644 --- a/bigtop-manager-ui/package.json +++ b/bigtop-manager-ui/package.json @@ -65,4 +65,4 @@ "iOS 7", "last 3 iOS versions" ] -} \ No newline at end of file +} diff --git a/bigtop-manager-ui/pnpm-lock.yaml b/bigtop-manager-ui/pnpm-lock.yaml index c038a751..8202c1a7 100644 --- a/bigtop-manager-ui/pnpm-lock.yaml +++ b/bigtop-manager-ui/pnpm-lock.yaml @@ -616,56 +616,56 @@ packages: engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} dev: true - /@rollup/rollup-android-arm-eabi@4.27.3: - resolution: {integrity: sha512-EzxVSkIvCFxUd4Mgm4xR9YXrcp976qVaHnqom/Tgm+vU79k4vV4eYTjmRvGfeoW8m9LVcsAy/lGjcgVegKEhLQ==} + /@rollup/rollup-android-arm-eabi@4.28.0: + resolution: {integrity: sha512-wLJuPLT6grGZsy34g4N1yRfYeouklTgPhH1gWXCYspenKYD0s3cR99ZevOGw5BexMNywkbV3UkjADisozBmpPQ==} cpu: [arm] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-android-arm64@4.27.3: - resolution: {integrity: sha512-LJc5pDf1wjlt9o/Giaw9Ofl+k/vLUaYsE2zeQGH85giX2F+wn/Cg8b3c5CDP3qmVmeO5NzwVUzQQxwZvC2eQKw==} + /@rollup/rollup-android-arm64@4.28.0: + resolution: {integrity: sha512-eiNkznlo0dLmVG/6wf+Ifi/v78G4d4QxRhuUl+s8EWZpDewgk7PX3ZyECUXU0Zq/Ca+8nU8cQpNC4Xgn2gFNDA==} cpu: [arm64] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-arm64@4.27.3: - resolution: {integrity: sha512-OuRysZ1Mt7wpWJ+aYKblVbJWtVn3Cy52h8nLuNSzTqSesYw1EuN6wKp5NW/4eSre3mp12gqFRXOKTcN3AI3LqA==} + /@rollup/rollup-darwin-arm64@4.28.0: + resolution: {integrity: sha512-lmKx9yHsppblnLQZOGxdO66gT77bvdBtr/0P+TPOseowE7D9AJoBw8ZDULRasXRWf1Z86/gcOdpBrV6VDUY36Q==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-x64@4.27.3: - resolution: {integrity: sha512-xW//zjJMlJs2sOrCmXdB4d0uiilZsOdlGQIC/jjmMWT47lkLLoB1nsNhPUcnoqyi5YR6I4h+FjBpILxbEy8JRg==} + /@rollup/rollup-darwin-x64@4.28.0: + resolution: {integrity: sha512-8hxgfReVs7k9Js1uAIhS6zq3I+wKQETInnWQtgzt8JfGx51R1N6DRVy3F4o0lQwumbErRz52YqwjfvuwRxGv1w==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-freebsd-arm64@4.27.3: - resolution: {integrity: sha512-58E0tIcwZ+12nK1WiLzHOD8I0d0kdrY/+o7yFVPRHuVGY3twBwzwDdTIBGRxLmyjciMYl1B/U515GJy+yn46qw==} + /@rollup/rollup-freebsd-arm64@4.28.0: + resolution: {integrity: sha512-lA1zZB3bFx5oxu9fYud4+g1mt+lYXCoch0M0V/xhqLoGatbzVse0wlSQ1UYOWKpuSu3gyN4qEc0Dxf/DII1bhQ==} cpu: [arm64] os: [freebsd] requiresBuild: true dev: true optional: true - /@rollup/rollup-freebsd-x64@4.27.3: - resolution: {integrity: sha512-78fohrpcVwTLxg1ZzBMlwEimoAJmY6B+5TsyAZ3Vok7YabRBUvjYTsRXPTjGEvv/mfgVBepbW28OlMEz4w8wGA==} + /@rollup/rollup-freebsd-x64@4.28.0: + resolution: {integrity: sha512-aI2plavbUDjCQB/sRbeUZWX9qp12GfYkYSJOrdYTL/C5D53bsE2/nBPuoiJKoWp5SN78v2Vr8ZPnB+/VbQ2pFA==} cpu: [x64] os: [freebsd] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.27.3: - resolution: {integrity: sha512-h2Ay79YFXyQi+QZKo3ISZDyKaVD7uUvukEHTOft7kh00WF9mxAaxZsNs3o/eukbeKuH35jBvQqrT61fzKfAB/Q==} + /@rollup/rollup-linux-arm-gnueabihf@4.28.0: + resolution: {integrity: sha512-WXveUPKtfqtaNvpf0iOb0M6xC64GzUX/OowbqfiCSXTdi/jLlOmH0Ba94/OkiY2yTGTwteo4/dsHRfh5bDCZ+w==} cpu: [arm] os: [linux] libc: [glibc] @@ -673,8 +673,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm-musleabihf@4.27.3: - resolution: {integrity: sha512-Sv2GWmrJfRY57urktVLQ0VKZjNZGogVtASAgosDZ1aUB+ykPxSi3X1nWORL5Jk0sTIIwQiPH7iE3BMi9zGWfkg==} + /@rollup/rollup-linux-arm-musleabihf@4.28.0: + resolution: {integrity: sha512-yLc3O2NtOQR67lI79zsSc7lk31xjwcaocvdD1twL64PK1yNaIqCeWI9L5B4MFPAVGEVjH5k1oWSGuYX1Wutxpg==} cpu: [arm] os: [linux] libc: [musl] @@ -682,8 +682,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.27.3: - resolution: {integrity: sha512-FPoJBLsPW2bDNWjSrwNuTPUt30VnfM8GPGRoLCYKZpPx0xiIEdFip3dH6CqgoT0RnoGXptaNziM0WlKgBc+OWQ==} + /@rollup/rollup-linux-arm64-gnu@4.28.0: + resolution: {integrity: sha512-+P9G9hjEpHucHRXqesY+3X9hD2wh0iNnJXX/QhS/J5vTdG6VhNYMxJ2rJkQOxRUd17u5mbMLHM7yWGZdAASfcg==} cpu: [arm64] os: [linux] libc: [glibc] @@ -691,8 +691,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-musl@4.27.3: - resolution: {integrity: sha512-TKxiOvBorYq4sUpA0JT+Fkh+l+G9DScnG5Dqx7wiiqVMiRSkzTclP35pE6eQQYjP4Gc8yEkJGea6rz4qyWhp3g==} + /@rollup/rollup-linux-arm64-musl@4.28.0: + resolution: {integrity: sha512-1xsm2rCKSTpKzi5/ypT5wfc+4bOGa/9yI/eaOLW0oMs7qpC542APWhl4A37AENGZ6St6GBMWhCCMM6tXgTIplw==} cpu: [arm64] os: [linux] libc: [musl] @@ -700,8 +700,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-powerpc64le-gnu@4.27.3: - resolution: {integrity: sha512-v2M/mPvVUKVOKITa0oCFksnQQ/TqGrT+yD0184/cWHIu0LoIuYHwox0Pm3ccXEz8cEQDLk6FPKd1CCm+PlsISw==} + /@rollup/rollup-linux-powerpc64le-gnu@4.28.0: + resolution: {integrity: sha512-zgWxMq8neVQeXL+ouSf6S7DoNeo6EPgi1eeqHXVKQxqPy1B2NvTbaOUWPn/7CfMKL7xvhV0/+fq/Z/J69g1WAQ==} cpu: [ppc64] os: [linux] libc: [glibc] @@ -709,8 +709,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.27.3: - resolution: {integrity: sha512-LdrI4Yocb1a/tFVkzmOE5WyYRgEBOyEhWYJe4gsDWDiwnjYKjNs7PS6SGlTDB7maOHF4kxevsuNBl2iOcj3b4A==} + /@rollup/rollup-linux-riscv64-gnu@4.28.0: + resolution: {integrity: sha512-VEdVYacLniRxbRJLNtzwGt5vwS0ycYshofI7cWAfj7Vg5asqj+pt+Q6x4n+AONSZW/kVm+5nklde0qs2EUwU2g==} cpu: [riscv64] os: [linux] libc: [glibc] @@ -718,8 +718,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-s390x-gnu@4.27.3: - resolution: {integrity: sha512-d4wVu6SXij/jyiwPvI6C4KxdGzuZOvJ6y9VfrcleHTwo68fl8vZC5ZYHsCVPUi4tndCfMlFniWgwonQ5CUpQcA==} + /@rollup/rollup-linux-s390x-gnu@4.28.0: + resolution: {integrity: sha512-LQlP5t2hcDJh8HV8RELD9/xlYtEzJkm/aWGsauvdO2ulfl3QYRjqrKW+mGAIWP5kdNCBheqqqYIGElSRCaXfpw==} cpu: [s390x] os: [linux] libc: [glibc] @@ -727,8 +727,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-gnu@4.27.3: - resolution: {integrity: sha512-/6bn6pp1fsCGEY5n3yajmzZQAh+mW4QPItbiWxs69zskBzJuheb3tNynEjL+mKOsUSFK11X4LYF2BwwXnzWleA==} + /@rollup/rollup-linux-x64-gnu@4.28.0: + resolution: {integrity: sha512-Nl4KIzteVEKE9BdAvYoTkW19pa7LR/RBrT6F1dJCV/3pbjwDcaOq+edkP0LXuJ9kflW/xOK414X78r+K84+msw==} cpu: [x64] os: [linux] libc: [glibc] @@ -736,8 +736,8 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-musl@4.27.3: - resolution: {integrity: sha512-nBXOfJds8OzUT1qUreT/en3eyOXd2EH5b0wr2bVB5999qHdGKkzGzIyKYaKj02lXk6wpN71ltLIaQpu58YFBoQ==} + /@rollup/rollup-linux-x64-musl@4.28.0: + resolution: {integrity: sha512-eKpJr4vBDOi4goT75MvW+0dXcNUqisK4jvibY9vDdlgLx+yekxSm55StsHbxUsRxSTt3JEQvlr3cGDkzcSP8bw==} cpu: [x64] os: [linux] libc: [musl] @@ -745,24 +745,24 @@ packages: dev: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.27.3: - resolution: {integrity: sha512-ogfbEVQgIZOz5WPWXF2HVb6En+kWzScuxJo/WdQTqEgeyGkaa2ui5sQav9Zkr7bnNCLK48uxmmK0TySm22eiuw==} + /@rollup/rollup-win32-arm64-msvc@4.28.0: + resolution: {integrity: sha512-Vi+WR62xWGsE/Oj+mD0FNAPY2MEox3cfyG0zLpotZdehPFXwz6lypkGs5y38Jd/NVSbOD02aVad6q6QYF7i8Bg==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.27.3: - resolution: {integrity: sha512-ecE36ZBMLINqiTtSNQ1vzWc5pXLQHlf/oqGp/bSbi7iedcjcNb6QbCBNG73Euyy2C+l/fn8qKWEwxr+0SSfs3w==} + /@rollup/rollup-win32-ia32-msvc@4.28.0: + resolution: {integrity: sha512-kN/Vpip8emMLn/eOza+4JwqDZBL6MPNpkdaEsgUtW1NYN3DZvZqSQrbKzJcTL6hd8YNmFTn7XGWMwccOcJBL0A==} cpu: [ia32] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-x64-msvc@4.27.3: - resolution: {integrity: sha512-vliZLrDmYKyaUoMzEbMTg2JkerfBjn03KmAw9CykO0Zzkzoyd7o3iZNam/TpyWNjNT+Cz2iO3P9Smv2wgrR+Eg==} + /@rollup/rollup-win32-x64-msvc@4.28.0: + resolution: {integrity: sha512-Bvno2/aZT6usSa7lRDL2+hMjVAGjuqaymF1ApZm31JXzniR/hvr14jpU+/z4X6Gt5BPlzosscyJZGUvguXIqeQ==} cpu: [x64] os: [win32] requiresBuild: true @@ -845,8 +845,8 @@ packages: resolution: {integrity: sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og==} dev: true - /@types/node@20.17.6: - resolution: {integrity: sha512-VEI7OdvK2wP7XHnsuXbAJnEpEkF6NjSN45QJlL4VGqZSXsnicpesdTWsg9RISeSdYd3yeRj/y3k5KGjUXYnFwQ==} + /@types/node@20.17.9: + resolution: {integrity: sha512-0JOXkRyLanfGPE2QRCwgxhzlBAvaRdCNMcvbd7jFfpmD4eEXll7LRwy5ymJmyeZqk7Nh7eD2LeUyQ68BbndmXw==} dependencies: undici-types: 6.19.8 dev: true @@ -865,6 +865,12 @@ packages: '@types/node': 20.5.3 dev: true + /@types/trusted-types@2.0.7: + resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + requiresBuild: true + dev: false + optional: true + /@types/web-bluetooth@0.0.18: resolution: {integrity: sha512-v/ZHEj9xh82usl8LMR3GarzFY1IrbXJw5L4QfQhokjRV91q+SelFqxQWSep1ucXEZ22+dSTwLFkXeur25sPIbw==} dev: false @@ -892,7 +898,7 @@ packages: ignore: 5.3.2 natural-compare: 1.4.0 semver: 7.6.3 - ts-api-utils: 1.4.0(typescript@5.0.2) + ts-api-utils: 1.4.3(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color @@ -941,7 +947,7 @@ packages: '@typescript-eslint/utils': 6.4.1(eslint@8.47.0)(typescript@5.0.2) debug: 4.3.7 eslint: 8.47.0 - ts-api-utils: 1.4.0(typescript@5.0.2) + ts-api-utils: 1.4.3(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color @@ -967,7 +973,7 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.3 - ts-api-utils: 1.4.0(typescript@5.0.2) + ts-api-utils: 1.4.3(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: - supports-color @@ -1026,8 +1032,8 @@ packages: tinyrainbow: 1.2.0 dev: true - /@vitest/pretty-format@2.1.5: - resolution: {integrity: sha512-4ZOwtk2bqG5Y6xRGHcveZVr+6txkH7M2e+nPFd6guSoN638v/1XQ0K06eOpi0ptVU/2tW/pIU4IoPotY/GZ9fw==} + /@vitest/pretty-format@2.1.8: + resolution: {integrity: sha512-9HiSZ9zpqNLKlbIDRWOnAWqgcA7xu+8YxXSekhr0Ykab7PAYFkhkwoqVArPOtJhPmYeE2YHgKZlj3CP36z2AJQ==} dependencies: tinyrainbow: 1.2.0 dev: true @@ -1043,7 +1049,7 @@ packages: resolution: {integrity: sha512-SgCPUeDFLaM0mIUHfaArq8fD2WbaXG/zVXjRupthYfYGzc8ztbFbu6dUNOblBG7XLMR1kEhS/DNnfCZ2IhdDew==} dependencies: '@vitest/pretty-format': 2.0.5 - magic-string: 0.30.13 + magic-string: 0.30.14 pathe: 1.1.2 dev: true @@ -1121,7 +1127,7 @@ packages: '@vue/compiler-ssr': 3.4.37 '@vue/shared': 3.4.37 estree-walker: 2.0.2 - magic-string: 0.30.13 + magic-string: 0.30.14 postcss: 8.4.41 source-map-js: 1.2.1 @@ -1555,7 +1561,7 @@ packages: postcss: ^8.1.0 dependencies: browserslist: 4.24.2 - caniuse-lite: 1.0.30001680 + caniuse-lite: 1.0.30001686 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.1.1 @@ -1657,8 +1663,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001680 - electron-to-chromium: 1.5.63 + caniuse-lite: 1.0.30001686 + electron-to-chromium: 1.5.68 node-releases: 2.0.18 update-browserslist-db: 1.1.1(browserslist@4.24.2) dev: true @@ -1707,13 +1713,13 @@ packages: resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==} dependencies: browserslist: 4.24.2 - caniuse-lite: 1.0.30001680 + caniuse-lite: 1.0.30001686 lodash.memoize: 4.1.2 lodash.uniq: 4.5.0 dev: true - /caniuse-lite@1.0.30001680: - resolution: {integrity: sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==} + /caniuse-lite@1.0.30001686: + resolution: {integrity: sha512-Y7deg0Aergpa24M3qLC5xjNklnKnhsmSyR/V89dLZ1n0ucJIFNs7PgR2Yfa/Zf6W79SbBicgtGxZr2juHkEUIA==} dev: true /chai@5.1.2: @@ -2111,7 +2117,7 @@ packages: is-arguments: 1.1.1 is-array-buffer: 3.0.4 is-date-object: 1.0.5 - is-regex: 1.1.4 + is-regex: 1.2.0 is-shared-array-buffer: 1.0.3 isarray: 2.0.5 object-is: 1.1.6 @@ -2119,9 +2125,9 @@ packages: object.assign: 4.1.5 regexp.prototype.flags: 1.5.3 side-channel: 1.0.6 - which-boxed-primitive: 1.0.2 + which-boxed-primitive: 1.1.0 which-collection: 1.0.2 - which-typed-array: 1.1.15 + which-typed-array: 1.1.16 dev: true /deep-is@0.1.4: @@ -2134,7 +2140,7 @@ packages: dependencies: es-define-property: 1.0.0 es-errors: 1.3.0 - gopd: 1.0.1 + gopd: 1.1.0 dev: true /define-properties@1.2.1: @@ -2254,8 +2260,10 @@ packages: domelementtype: 2.3.0 dev: true - /dompurify@3.2.0: - resolution: {integrity: sha512-AMdOzK44oFWqHEi0wpOqix/fUNY707OmoeFDnbi3Q5I8uOpy21ufUA5cDJPr0bosxrflOVD/H2DMSvuGKJGfmQ==} + /dompurify@3.2.2: + resolution: {integrity: sha512-YMM+erhdZ2nkZ4fTNRTSI94mb7VG7uVF5vj5Zde7tImgnhZE3R6YW/IACGIHb2ux+QkEXMhe591N+5jWOmL4Zw==} + optionalDependencies: + '@types/trusted-types': 2.0.7 dev: false /domutils@1.7.0: @@ -2303,8 +2311,8 @@ packages: semver: 7.6.3 dev: true - /electron-to-chromium@1.5.63: - resolution: {integrity: sha512-ddeXKuY9BHo/mw145axlyWjlJ1UBt4WK3AlvkT7W2AbqfRQoacVoRUCF6wL3uIx/8wT9oLKXzI+rFqHHscByaA==} + /electron-to-chromium@1.5.68: + resolution: {integrity: sha512-FgMdJlma0OzUYlbrtZ4AeXjKxKPk6KT8WOP8BjcqxWtlg8qyJQjRzPJzUtUn5GBg1oQ26hFs7HOOHJMYiJRnvQ==} dev: true /emoji-regex@8.0.0: @@ -2360,24 +2368,24 @@ packages: es-errors: 1.3.0 es-object-atoms: 1.0.0 es-set-tostringtag: 2.0.3 - es-to-primitive: 1.2.1 + es-to-primitive: 1.3.0 function.prototype.name: 1.1.6 get-intrinsic: 1.2.4 get-symbol-description: 1.0.2 globalthis: 1.0.4 - gopd: 1.0.1 + gopd: 1.1.0 has-property-descriptors: 1.0.2 - has-proto: 1.0.3 - has-symbols: 1.0.3 + has-proto: 1.1.0 + has-symbols: 1.1.0 hasown: 2.0.2 internal-slot: 1.0.7 is-array-buffer: 3.0.4 is-callable: 1.2.7 is-data-view: 1.0.1 is-negative-zero: 2.0.3 - is-regex: 1.1.4 + is-regex: 1.2.0 is-shared-array-buffer: 1.0.3 - is-string: 1.0.7 + is-string: 1.1.0 is-typed-array: 1.1.13 is-weakref: 1.0.2 object-inspect: 1.13.3 @@ -2391,10 +2399,10 @@ packages: string.prototype.trimstart: 1.0.8 typed-array-buffer: 1.0.2 typed-array-byte-length: 1.0.1 - typed-array-byte-offset: 1.0.2 - typed-array-length: 1.0.6 + typed-array-byte-offset: 1.0.3 + typed-array-length: 1.0.7 unbox-primitive: 1.0.2 - which-typed-array: 1.1.15 + which-typed-array: 1.1.16 dev: true /es-define-property@1.0.0: @@ -2414,11 +2422,11 @@ packages: dependencies: call-bind: 1.0.7 get-intrinsic: 1.2.4 - has-symbols: 1.0.3 + has-symbols: 1.1.0 is-arguments: 1.1.1 is-map: 2.0.3 is-set: 2.0.3 - is-string: 1.0.7 + is-string: 1.1.0 isarray: 2.0.5 stop-iteration-iterator: 1.0.0 dev: true @@ -2443,13 +2451,13 @@ packages: hasown: 2.0.2 dev: true - /es-to-primitive@1.2.1: - resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} + /es-to-primitive@1.3.0: + resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==} engines: {node: '>= 0.4'} dependencies: is-callable: 1.2.7 is-date-object: 1.0.5 - is-symbol: 1.0.4 + is-symbol: 1.1.0 dev: true /esbuild@0.21.5: @@ -2904,8 +2912,8 @@ packages: dependencies: es-errors: 1.3.0 function-bind: 1.1.2 - has-proto: 1.0.3 - has-symbols: 1.0.3 + has-proto: 1.1.0 + has-symbols: 1.1.0 hasown: 2.0.2 dev: true @@ -2987,7 +2995,7 @@ packages: engines: {node: '>= 0.4'} dependencies: define-properties: 1.2.1 - gopd: 1.0.1 + gopd: 1.1.0 dev: true /globby@11.1.0: @@ -3008,8 +3016,9 @@ packages: delegate: 3.2.0 dev: false - /gopd@1.0.1: - resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + /gopd@1.1.0: + resolution: {integrity: sha512-FQoVQnqcdk4hVM4JN1eromaun4iuS34oStkdlLENLdpULsuQcTyXj8w7ayhuUfPwEYZ1ZOooOTT6fdA9Vmx/RA==} + engines: {node: '>= 0.4'} dependencies: get-intrinsic: 1.2.4 dev: true @@ -3058,13 +3067,15 @@ packages: es-define-property: 1.0.0 dev: true - /has-proto@1.0.3: - resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} + /has-proto@1.1.0: + resolution: {integrity: sha512-QLdzI9IIO1Jg7f9GT1gXpPpXArAn6cS31R1eEZqz08Gc+uQ8/XiqHWt17Fiw+2p6oTTIq5GXEpQkAlA88YRl/Q==} engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 dev: true - /has-symbols@1.0.3: - resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} + /has-symbols@1.1.0: + resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} engines: {node: '>= 0.4'} dev: true @@ -3072,7 +3083,7 @@ packages: resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} engines: {node: '>= 0.4'} dependencies: - has-symbols: 1.0.3 + has-symbols: 1.1.0 dev: true /has-value@0.3.1: @@ -3215,8 +3226,16 @@ packages: get-intrinsic: 1.2.4 dev: true - /is-bigint@1.0.4: - resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} + /is-async-function@2.0.0: + resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 + dev: true + + /is-bigint@1.1.0: + resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} + engines: {node: '>= 0.4'} dependencies: has-bigints: 1.0.2 dev: true @@ -3228,8 +3247,8 @@ packages: binary-extensions: 2.3.0 dev: true - /is-boolean-object@1.1.2: - resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} + /is-boolean-object@1.2.0: + resolution: {integrity: sha512-kR5g0+dXf/+kXnqI+lu0URKYPKgICtHGGNCDSB10AaUFj3o/HkB3u7WfpRBJGFopxxY0oH3ux7ZsDjLtK7xqvw==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 @@ -3298,11 +3317,25 @@ packages: engines: {node: '>=0.10.0'} dev: true + /is-finalizationregistry@1.1.0: + resolution: {integrity: sha512-qfMdqbAQEwBw78ZyReKnlA8ezmPdb9BemzIIip/JkjaZUhitfXDkkr+3QTboW0JrSXT1QWyYShpvnNHGZ4c4yA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + dev: true + /is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} dev: true + /is-generator-function@1.0.10: + resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 + dev: true + /is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -3320,10 +3353,11 @@ packages: engines: {node: '>= 0.4'} dev: true - /is-number-object@1.0.7: - resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} + /is-number-object@1.1.0: + resolution: {integrity: sha512-KVSZV0Dunv9DTPkhXwcZ3Q+tUc9TsaE1ZwX5J2WMvsSGS6Md8TFPun5uwh0yRdrNerI6vf/tbJxqSx4c1ZI1Lw==} engines: {node: '>= 0.4'} dependencies: + call-bind: 1.0.7 has-tostringtag: 1.0.2 dev: true @@ -3361,12 +3395,14 @@ packages: engines: {node: '>=0.10.0'} dev: false - /is-regex@1.1.4: - resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} + /is-regex@1.2.0: + resolution: {integrity: sha512-B6ohK4ZmoftlUe+uvenXSbPJFo6U37BH7oO1B3nQH8f/7h27N56s85MhUtbFJAziz5dcmuR3i8ovUl35zp8pFA==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 + gopd: 1.1.0 has-tostringtag: 1.0.2 + hasown: 2.0.2 dev: true /is-set@2.0.3: @@ -3386,25 +3422,28 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: true - /is-string@1.0.7: - resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} + /is-string@1.1.0: + resolution: {integrity: sha512-PlfzajuF9vSo5wErv3MJAKD/nqf9ngAs1NFQYm16nUYFO2IzxJ2hcm+IOCg+EEopdykNNUhVq5cz35cAUxU8+g==} engines: {node: '>= 0.4'} dependencies: + call-bind: 1.0.7 has-tostringtag: 1.0.2 dev: true - /is-symbol@1.0.4: - resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} + /is-symbol@1.1.0: + resolution: {integrity: sha512-qS8KkNNXUZ/I+nX6QT8ZS1/Yx0A444yhzdTKxCzKkNjQ9sHErBxJnJAgh+f5YhusYECEcjo4XcyH87hn6+ks0A==} engines: {node: '>= 0.4'} dependencies: - has-symbols: 1.0.3 + call-bind: 1.0.7 + has-symbols: 1.1.0 + safe-regex-test: 1.0.3 dev: true /is-typed-array@1.1.13: resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} engines: {node: '>= 0.4'} dependencies: - which-typed-array: 1.1.15 + which-typed-array: 1.1.16 dev: true /is-weakmap@2.0.2: @@ -3467,7 +3506,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 20.17.6 + '@types/node': 20.17.9 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -3637,8 +3676,8 @@ packages: hasBin: true dev: true - /magic-string@0.30.13: - resolution: {integrity: sha512-8rYBO+MsWkgjDSOvLomYnzhdwEG51olQ4zL5KXnNJWV5MNmrb4rTZdrtkhxjnD/QyZUqR/Z/XDsUs/4ej2nx0g==} + /magic-string@0.30.14: + resolution: {integrity: sha512-5c99P1WKTed11ZC0HMJOj6CDIue6F8ySu+bJL+85q1zBEIY8IklrJ1eiKC2NDRh3Ct3FcvmJPyQHb9erXMTJNw==} dependencies: '@jridgewell/sourcemap-codec': 1.5.0 @@ -3797,8 +3836,8 @@ packages: resolution: {integrity: sha512-ckmWDJjphvd/FvZawgygcUeQCxzvohjFO5RxTjj4eq8kw359gFF3E1brjfI+viLMxss5JrHTDRHZvu2/tuy0Qg==} dev: true - /nanoid@3.3.7: - resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + /nanoid@3.3.8: + resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -3913,7 +3952,7 @@ packages: dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - has-symbols: 1.0.3 + has-symbols: 1.1.0 object-keys: 1.1.1 dev: true @@ -4387,7 +4426,7 @@ packages: resolution: {integrity: sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.7 + nanoid: 3.3.8 picocolors: 1.1.1 source-map-js: 1.2.1 @@ -4504,6 +4543,19 @@ packages: picomatch: 2.3.1 dev: true + /reflect.getprototypeof@1.0.7: + resolution: {integrity: sha512-bMvFGIUKlc/eSfXNX+aZ+EL95/EgZzuwA0OBPTbZZDEJw/0AkentjMuM1oiRfwHrshqk4RzdgiTg5CcDalXN5g==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.5 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + gopd: 1.1.0 + which-builtin-type: 1.2.0 + dev: true + /regenerator-runtime@0.14.1: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} @@ -4567,31 +4619,31 @@ packages: glob: 7.2.3 dev: true - /rollup@4.27.3: - resolution: {integrity: sha512-SLsCOnlmGt9VoZ9Ek8yBK8tAdmPHeppkw+Xa7yDlCEhDTvwYei03JlWo1fdc7YTfLZ4tD8riJCUyAgTbszk1fQ==} + /rollup@4.28.0: + resolution: {integrity: sha512-G9GOrmgWHBma4YfCcX8PjH0qhXSdH8B4HDE2o4/jaxj93S4DPCIDoLcXz99eWMji4hB29UFCEd7B2gwGJDR9cQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true dependencies: '@types/estree': 1.0.6 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.27.3 - '@rollup/rollup-android-arm64': 4.27.3 - '@rollup/rollup-darwin-arm64': 4.27.3 - '@rollup/rollup-darwin-x64': 4.27.3 - '@rollup/rollup-freebsd-arm64': 4.27.3 - '@rollup/rollup-freebsd-x64': 4.27.3 - '@rollup/rollup-linux-arm-gnueabihf': 4.27.3 - '@rollup/rollup-linux-arm-musleabihf': 4.27.3 - '@rollup/rollup-linux-arm64-gnu': 4.27.3 - '@rollup/rollup-linux-arm64-musl': 4.27.3 - '@rollup/rollup-linux-powerpc64le-gnu': 4.27.3 - '@rollup/rollup-linux-riscv64-gnu': 4.27.3 - '@rollup/rollup-linux-s390x-gnu': 4.27.3 - '@rollup/rollup-linux-x64-gnu': 4.27.3 - '@rollup/rollup-linux-x64-musl': 4.27.3 - '@rollup/rollup-win32-arm64-msvc': 4.27.3 - '@rollup/rollup-win32-ia32-msvc': 4.27.3 - '@rollup/rollup-win32-x64-msvc': 4.27.3 + '@rollup/rollup-android-arm-eabi': 4.28.0 + '@rollup/rollup-android-arm64': 4.28.0 + '@rollup/rollup-darwin-arm64': 4.28.0 + '@rollup/rollup-darwin-x64': 4.28.0 + '@rollup/rollup-freebsd-arm64': 4.28.0 + '@rollup/rollup-freebsd-x64': 4.28.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.28.0 + '@rollup/rollup-linux-arm-musleabihf': 4.28.0 + '@rollup/rollup-linux-arm64-gnu': 4.28.0 + '@rollup/rollup-linux-arm64-musl': 4.28.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.28.0 + '@rollup/rollup-linux-riscv64-gnu': 4.28.0 + '@rollup/rollup-linux-s390x-gnu': 4.28.0 + '@rollup/rollup-linux-x64-gnu': 4.28.0 + '@rollup/rollup-linux-x64-musl': 4.28.0 + '@rollup/rollup-win32-arm64-msvc': 4.28.0 + '@rollup/rollup-win32-ia32-msvc': 4.28.0 + '@rollup/rollup-win32-x64-msvc': 4.28.0 fsevents: 2.3.3 dev: true @@ -4607,7 +4659,7 @@ packages: dependencies: call-bind: 1.0.7 get-intrinsic: 1.2.4 - has-symbols: 1.0.3 + has-symbols: 1.1.0 isarray: 2.0.5 dev: true @@ -4621,7 +4673,7 @@ packages: dependencies: call-bind: 1.0.7 es-errors: 1.3.0 - is-regex: 1.1.4 + is-regex: 1.2.0 dev: true /safe-regex@1.1.0: @@ -4703,7 +4755,7 @@ packages: es-errors: 1.3.0 function-bind: 1.1.2 get-intrinsic: 1.2.4 - gopd: 1.0.1 + gopd: 1.1.0 has-property-descriptors: 1.0.2 dev: true @@ -5162,13 +5214,13 @@ packages: resolution: {integrity: sha512-hN4uFRxbK+PX56DxYiGHsTn2dME3TVr9vbNqlQGcGcPhJAn+tdP126iA+TArMpI4YSgnTkMWyoLl5bf81Hi5TA==} engines: {node: '>= 0.4'} dependencies: - gopd: 1.0.1 + gopd: 1.1.0 typedarray.prototype.slice: 1.0.3 - which-typed-array: 1.1.15 + which-typed-array: 1.1.16 dev: true - /ts-api-utils@1.4.0(typescript@5.0.2): - resolution: {integrity: sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==} + /ts-api-utils@1.4.3(typescript@5.0.2): + resolution: {integrity: sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==} engines: {node: '>=16'} peerDependencies: typescript: '>=4.2.0' @@ -5211,33 +5263,34 @@ packages: dependencies: call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 - has-proto: 1.0.3 + gopd: 1.1.0 + has-proto: 1.1.0 is-typed-array: 1.1.13 dev: true - /typed-array-byte-offset@1.0.2: - resolution: {integrity: sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==} + /typed-array-byte-offset@1.0.3: + resolution: {integrity: sha512-GsvTyUHTriq6o/bHcTd0vM7OQ9JEdlvluu9YISaA7+KzDzPaIzEeDFNkTfhdE3MYcNhNi0vq/LlegYgIs5yPAw==} engines: {node: '>= 0.4'} dependencies: available-typed-arrays: 1.0.7 call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 - has-proto: 1.0.3 + gopd: 1.1.0 + has-proto: 1.1.0 is-typed-array: 1.1.13 + reflect.getprototypeof: 1.0.7 dev: true - /typed-array-length@1.0.6: - resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==} + /typed-array-length@1.0.7: + resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 - has-proto: 1.0.3 + gopd: 1.1.0 is-typed-array: 1.1.13 possible-typed-array-names: 1.0.0 + reflect.getprototypeof: 1.0.7 dev: true /typedarray.prototype.slice@1.0.3: @@ -5249,7 +5302,7 @@ packages: es-abstract: 1.23.5 es-errors: 1.3.0 typed-array-buffer: 1.0.2 - typed-array-byte-offset: 1.0.2 + typed-array-byte-offset: 1.0.3 dev: true /typescript@5.0.2: @@ -5262,8 +5315,8 @@ packages: dependencies: call-bind: 1.0.7 has-bigints: 1.0.2 - has-symbols: 1.0.3 - which-boxed-primitive: 1.0.2 + has-symbols: 1.1.0 + which-boxed-primitive: 1.1.0 dev: true /undici-types@6.19.8: @@ -5403,7 +5456,7 @@ packages: '@types/node': 20.5.3 esbuild: 0.21.5 postcss: 8.4.41 - rollup: 4.27.3 + rollup: 4.28.0 sass: 1.66.1 optionalDependencies: fsevents: 2.3.3 @@ -5437,7 +5490,7 @@ packages: '@ampproject/remapping': 2.3.0 '@types/node': 20.5.3 '@vitest/expect': 2.0.5 - '@vitest/pretty-format': 2.1.5 + '@vitest/pretty-format': 2.1.8 '@vitest/runner': 2.0.5 '@vitest/snapshot': 2.0.5 '@vitest/spy': 2.0.5 @@ -5446,7 +5499,7 @@ packages: debug: 4.3.7 execa: 8.0.1 happy-dom: 15.0.0 - magic-string: 0.30.13 + magic-string: 0.30.14 pathe: 1.1.2 std-env: 3.8.0 tinybench: 2.9.0 @@ -5490,7 +5543,7 @@ packages: peerDependencies: vue: ^3.0.0 dependencies: - dompurify: 3.2.0 + dompurify: 3.2.2 vue: 3.4.37(typescript@5.0.2) dev: false @@ -5646,14 +5699,34 @@ packages: engines: {node: '>=12'} dev: true - /which-boxed-primitive@1.0.2: - resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} + /which-boxed-primitive@1.1.0: + resolution: {integrity: sha512-Ei7Miu/AXe2JJ4iNF5j/UphAgRoma4trE6PtisM09bPygb3egMH3YLW/befsWb1A1AxvNSFidOFTB18XtnIIng==} + engines: {node: '>= 0.4'} + dependencies: + is-bigint: 1.1.0 + is-boolean-object: 1.2.0 + is-number-object: 1.1.0 + is-string: 1.1.0 + is-symbol: 1.1.0 + dev: true + + /which-builtin-type@1.2.0: + resolution: {integrity: sha512-I+qLGQ/vucCby4tf5HsLmGueEla4ZhwTBSqaooS+Y0BuxN4Cp+okmGuV+8mXZ84KDI9BA+oklo+RzKg0ONdSUA==} + engines: {node: '>= 0.4'} dependencies: - is-bigint: 1.0.4 - is-boolean-object: 1.1.2 - is-number-object: 1.0.7 - is-string: 1.0.7 - is-symbol: 1.0.4 + call-bind: 1.0.7 + function.prototype.name: 1.1.6 + has-tostringtag: 1.0.2 + is-async-function: 2.0.0 + is-date-object: 1.0.5 + is-finalizationregistry: 1.1.0 + is-generator-function: 1.0.10 + is-regex: 1.2.0 + is-weakref: 1.0.2 + isarray: 2.0.5 + which-boxed-primitive: 1.1.0 + which-collection: 1.0.2 + which-typed-array: 1.1.16 dev: true /which-collection@1.0.2: @@ -5666,14 +5739,14 @@ packages: is-weakset: 2.0.3 dev: true - /which-typed-array@1.1.15: - resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==} + /which-typed-array@1.1.16: + resolution: {integrity: sha512-g+N+GAWiRj66DngFwHvISJd+ITsyphZvD1vChfVg6cEdnzy53GzB3oy0fUNlvhz7H7+MiqhYr26qxQShCpKTTQ==} engines: {node: '>= 0.4'} dependencies: available-typed-arrays: 1.0.7 call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 + gopd: 1.1.0 has-tostringtag: 1.0.2 dev: true diff --git a/bigtop-manager-ui/src/api/ai-assistant/index.ts b/bigtop-manager-ui/src/api/ai-assistant/index.ts new file mode 100644 index 00000000..683fcff6 --- /dev/null +++ b/bigtop-manager-ui/src/api/ai-assistant/index.ts @@ -0,0 +1,93 @@ +/* + * 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 + * + * https://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. + */ + +import request from '@/api/request.ts' +import type { ChatMessageItem, ChatThread, CreateChatThread, ThreadId, UpdateChatThread } from './types' +import axios, { AxiosProgressEvent, AxiosResponse, CancelTokenSource } from 'axios' + +export const getThreadsFromAuthPlatform = (): Promise => { + return request({ + method: 'get', + url: '/llm/chatbot/threads' + }) +} + +export const getThread = (threadId: ThreadId): Promise => { + return request({ + method: 'get', + url: `/llm/chatbot/threads/${threadId}` + }) +} + +export const getThreadRecords = (threadId: ThreadId): Promise => { + return request({ + method: 'get', + url: `/llm/chatbot/threads/${threadId}/history` + }) +} + +export const updateThread = (threadId: ThreadId, data: UpdateChatThread): Promise => { + return request({ + method: 'put', + url: `/llm/chatbot/threads/${threadId}`, + data + }) +} + +export const deleteThread = (threadId: ThreadId): Promise => { + return request({ + method: 'delete', + url: `/llm/chatbot/threads/${threadId}` + }) +} + +export const createChatThread = (data: CreateChatThread): Promise => { + return request({ + method: 'post', + url: '/llm/chatbot/threads', + data + }) +} + +export interface ChatMessagesRes { + promise: Promise + cancel: () => void +} + +export const talkWithChatbot = ( + threadId: ThreadId, + data: { message: string }, + func: Function +): ChatMessagesRes> => { + const source: CancelTokenSource = axios.CancelToken.source() + + const promise = request({ + method: 'post', + url: `/llm/chatbot/threads/${threadId}/talk`, + responseType: 'stream', + data: { + message: data.message + }, + timeout: 0, + cancelToken: source.token, + onDownloadProgress: (progressEvent: AxiosProgressEvent) => func(progressEvent) + }) + + return { promise, cancel: source.cancel } +} diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ScriptModel.java b/bigtop-manager-ui/src/api/ai-assistant/types.ts similarity index 54% rename from bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ScriptModel.java rename to bigtop-manager-ui/src/api/ai-assistant/types.ts index 6b71ac25..602974dd 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/model/ScriptModel.java +++ b/bigtop-manager-ui/src/api/ai-assistant/types.ts @@ -16,23 +16,40 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.bigtop.manager.server.stack.model; -import lombok.Data; +export enum Sender { + USER, + AI, + SYSTEM +} -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; +export type CreateChatThread = { + id?: number | string | null + name?: string | null +} -@Data -@XmlAccessorType(XmlAccessType.FIELD) -public class ScriptModel { +export type SenderType = keyof typeof Sender +export type UpdateChatThread = CreateChatThread +export type ThreadId = number | string - @XmlElement(name = "script-id") - private String scriptId; +export interface ChatThread { + threadId?: number | string + authId?: number | string + platformId?: number | string + platformName?: string + model?: string + name?: string + createTime?: string + updateTime?: string +} - @XmlElement(name = "script-type") - private String scriptType; +export interface ChatMessageItem { + sender: SenderType + message: string + createTime?: string +} - private Long timeout; +export interface ReceivedMessageItem { + content?: string + finishReason?: 'completed' | null } diff --git a/bigtop-manager-ui/src/api/chatbot/index.ts b/bigtop-manager-ui/src/api/chatbot/index.ts deleted file mode 100644 index 0b098576..00000000 --- a/bigtop-manager-ui/src/api/chatbot/index.ts +++ /dev/null @@ -1,108 +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 - * - * https://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. - */ - -import request from '@/api/request.ts' -import { - AuthorizedPlatform, - SupportedPlatform, - CredentialFormItem, - AuthCredentialTestParams, - AuthTestResult, - ChatThread, - ChatThreadCondition, - ChatThreadHistoryCondition, - ChatThreadHistoryItem, - ChatThreadDelCondition -} from '@/api/chatbot/types.ts' - -export const getAuthorizedPlatforms = (): Promise => { - return request({ - method: 'get', - url: '/chatbot/auth-platforms' - }) -} -export const getSupportedPlatforms = (): Promise => { - return request({ - method: 'get', - url: '/chatbot/platforms' - }) -} -export const getCredentialFormModelOfPlatform = ( - platformId: string | number -): Promise => { - return request({ - method: 'get', - url: `/chatbot/platforms/${platformId}/auth-credentials` - }) -} - -export const validateAuthCredentials = ( - data: AuthCredentialTestParams -): Promise => { - return request({ - method: 'post', - url: '/chatbot/auth-platforms', - data - }) -} - -export const getChatThreads = ( - params: ChatThreadCondition -): Promise => { - return request({ - method: 'get', - url: `/chatbot/auth-platforms/${params.authId}/threads`, - params: { - model: params.model - } - }) -} -export const createChatThread = ( - data: ChatThreadCondition -): Promise => { - return request({ - method: 'post', - url: `/chatbot/auth-platforms/${data.authId}/threads?model=${data.model}` - }) -} -export const getThreadChatHistory = ( - params: ChatThreadHistoryCondition -): Promise => { - return request({ - method: 'get', - url: `/chatbot/auth-platforms/${params.authId}/threads/${params.threadId}/history` - }) -} - -export const delAuthorizedPlatform = ( - authId: string | number -): Promise => { - return request({ - method: 'delete', - url: `/chatbot/auth-platforms/${authId}` - }) -} -export const delChatThread = ( - params: ChatThreadDelCondition -): Promise => { - return request({ - method: 'delete', - url: `/chatbot/auth-platforms/${params.authId}/threads/${params.threadId}` - }) -} diff --git a/bigtop-manager-ui/src/api/chatbot/types.ts b/bigtop-manager-ui/src/api/chatbot/types.ts deleted file mode 100644 index 37bc7251..00000000 --- a/bigtop-manager-ui/src/api/chatbot/types.ts +++ /dev/null @@ -1,94 +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 - * - * https://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. - */ - -export interface ChatbotConfig { - authId?: string | number - platformName?: string - supportModels?: string - model?: string - threadId?: string | number - threadName?: string - createTime?: string - updateTime?: string -} -export interface Platform { - id: string | number - platformId: string | number - platformName: string - supportModels: string - currModel?: string -} - -export type AuthorizedPlatform = Platform - -export interface SupportedPlatform extends Platform { - id: string | number - name: string - supportModels: string -} -export interface CredentialFormItem { - name: string - displayName: string -} -export interface ChatThreadCondition { - authId: string | number - model: string -} - -export interface ChatThread extends ChatThreadCondition { - threadId: string | number - threadName: string - createTime: string - updateTime: string -} - -export interface AuthCredential { - key: string - value: string -} - -export interface AuthCredentialTestParams { - platformId: string | number - authCredentials: AuthCredential[] -} - -export interface AuthTestResult { - id: string | number - platformId: string | number - platformName: string - supportModels: string -} - -export type Sender = 'USER' | 'SYSTEM' | 'AI' -export interface ChatThreadHistoryItem { - sender: Sender - message: string - createTime?: string -} - -export interface ChatThreadHistoryCondition { - authId: string | number - threadId: string | number -} - -export interface SendChatMessageCondition extends ChatThreadHistoryCondition { - message: string -} - -export type ChatThreadDelCondition = ChatThreadHistoryCondition diff --git a/bigtop-manager-ui/src/api/component/index.ts b/bigtop-manager-ui/src/api/component/index.ts index 9655ed4d..8a0d4fba 100644 --- a/bigtop-manager-ui/src/api/component/index.ts +++ b/bigtop-manager-ui/src/api/component/index.ts @@ -20,9 +20,7 @@ import { HostComponentVO } from '@/api/component/types.ts' import request from '@/api/request.ts' -export const getHostComponents = ( - clusterId: number -): Promise => { +export const getHostComponents = (clusterId: number): Promise => { return request({ method: 'get', url: '/clusters/' + clusterId + '/host-components' diff --git a/bigtop-manager-ui/src/api/config/index.ts b/bigtop-manager-ui/src/api/config/index.ts index ce50ca5c..5302a770 100644 --- a/bigtop-manager-ui/src/api/config/index.ts +++ b/bigtop-manager-ui/src/api/config/index.ts @@ -20,18 +20,14 @@ import request from '@/api/request.ts' import { ServiceConfigVO } from '@/api/config/types.ts' -export const getLatestConfigs = ( - clusterId: number -): Promise => { +export const getLatestConfigs = (clusterId: number): Promise => { return request({ method: 'get', url: '/clusters/' + clusterId + '/configurations/latest' }) } -export const getAllConfigs = ( - clusterId: number -): Promise => { +export const getAllConfigs = (clusterId: number): Promise => { return request({ method: 'get', url: '/clusters/' + clusterId + '/configurations' diff --git a/bigtop-manager-ui/src/api/job/index.ts b/bigtop-manager-ui/src/api/job/index.ts index d32ceb37..14f8e2aa 100644 --- a/bigtop-manager-ui/src/api/job/index.ts +++ b/bigtop-manager-ui/src/api/job/index.ts @@ -34,10 +34,7 @@ export const retryJob = (id: number, clusterId: number): Promise => { }) } -export const getJobs = ( - clusterId: number, - pagination: Pagination -): Promise<{ content: JobVO[]; total: number }> => { +export const getJobs = (clusterId: number, pagination: Pagination): Promise<{ content: JobVO[]; total: number }> => { return request({ method: 'get', url: `/clusters/${clusterId}/jobs`, diff --git a/bigtop-manager-ui/src/api/llm-config/index.ts b/bigtop-manager-ui/src/api/llm-config/index.ts index e3a8ce1f..4d0702bb 100644 --- a/bigtop-manager-ui/src/api/llm-config/index.ts +++ b/bigtop-manager-ui/src/api/llm-config/index.ts @@ -18,12 +18,7 @@ */ import request from '@/api/request.ts' -import { - Platform, - PlatformCredential, - AuthorizedPlatform, - UpdateAuthorizedPlatformConfig -} from './types' +import { Platform, PlatformCredential, AuthorizedPlatform, UpdateAuthorizedPlatformConfig } from './types' export const getPlatforms = (): Promise => { return request({ @@ -39,18 +34,14 @@ export const getAuthorizedPlatforms = (): Promise => { }) } -export const getPlatformCredentials = ( - platformId: number -): Promise => { +export const getPlatformCredentials = (platformId: number): Promise => { return request({ method: 'get', url: `/llm/config/platforms/${platformId}/auth-credentials` }) } -export const addAuthorizedPlatform = ( - data: UpdateAuthorizedPlatformConfig -): Promise => { +export const addAuthorizedPlatform = (data: UpdateAuthorizedPlatformConfig): Promise => { return request({ method: 'post', url: '/llm/config/auth-platforms', @@ -58,18 +49,14 @@ export const addAuthorizedPlatform = ( }) } -export const getAuthPlatformDetail = ( - authId: number -): Promise => { +export const getAuthPlatformDetail = (authId: number): Promise => { return request({ method: 'get', url: `/llm/config/auth-platforms/${authId}` }) } -export const updateAuthPlatform = ( - data: UpdateAuthorizedPlatformConfig -): Promise => { +export const updateAuthPlatform = (data: UpdateAuthorizedPlatformConfig): Promise => { return request({ method: 'put', url: `/llm/config/auth-platforms/${data.id}`, @@ -84,27 +71,21 @@ export const deleteAuthPlatform = (authId: number): Promise => { }) } -export const deactivateAuthorizedPlatform = ( - authId: number -): Promise => { +export const deactivateAuthorizedPlatform = (authId: number): Promise => { return request({ method: 'post', url: `/llm/config/auth-platforms/${authId}/deactivate` }) } -export const activateAuthorizedPlatform = ( - authId: number -): Promise => { +export const activateAuthorizedPlatform = (authId: number): Promise => { return request({ method: 'post', url: `/llm/config/auth-platforms/${authId}/activate` }) } -export const testAuthorizedPlatform = ( - data: UpdateAuthorizedPlatformConfig -): Promise => { +export const testAuthorizedPlatform = (data: UpdateAuthorizedPlatformConfig): Promise => { return request({ method: 'post', url: '/llm/config/auth-platforms/test', diff --git a/bigtop-manager-ui/src/api/request.ts b/bigtop-manager-ui/src/api/request.ts index 6b431304..b1c7771b 100644 --- a/bigtop-manager-ui/src/api/request.ts +++ b/bigtop-manager-ui/src/api/request.ts @@ -17,11 +17,7 @@ * under the License. */ -import axios, { - AxiosError, - AxiosResponse, - InternalAxiosRequestConfig -} from 'axios' +import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios' import { message } from 'ant-design-vue' import { ResponseEntity } from '@/api/types' import router from '@/router' @@ -35,26 +31,19 @@ const request = axios.create({ timeout: API_EXPIRE_TIME }) -request.interceptors.request.use( - ( - config: InternalAxiosRequestConfig - ): InternalAxiosRequestConfig => { - config.headers = config.headers || {} +request.interceptors.request.use((config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => { + config.headers = config.headers || {} - const locale = i18n.global.locale.value as Locale - config.headers['Accept-Language'] = locale.replace('_', '-') + const locale = i18n.global.locale.value as Locale + config.headers['Accept-Language'] = locale.replace('_', '-') - const token = - localStorage.getItem('Token') ?? - sessionStorage.getItem('Token') ?? - undefined - if (token) { - config.headers['Token'] = token - } - - return config + const token = localStorage.getItem('Token') ?? sessionStorage.getItem('Token') ?? undefined + if (token) { + config.headers['Token'] = token } -) + + return config +}) request.interceptors.response.use( async (res: AxiosResponse) => { diff --git a/bigtop-manager-ui/src/api/sse/index.ts b/bigtop-manager-ui/src/api/sse/index.ts index abcd72d8..6b288b3b 100644 --- a/bigtop-manager-ui/src/api/sse/index.ts +++ b/bigtop-manager-ui/src/api/sse/index.ts @@ -19,14 +19,9 @@ import axios, { type AxiosProgressEvent, type CancelTokenSource } from 'axios' import request from '@/api/request.ts' -import type { chatMessagesRes, LogsRes } from './types' -import type { SendChatMessageCondition } from '@/api/chatbot/types' +import type { LogsRes } from './types' -export const getLogs = ( - clusterId: number, - id: number, - func: Function -): LogsRes => { +export const getLogs = (clusterId: number, id: number, func: Function): LogsRes => { const source: CancelTokenSource = axios.CancelToken.source() const promise = request({ @@ -35,29 +30,7 @@ export const getLogs = ( responseType: 'stream', timeout: 0, cancelToken: source.token, - onDownloadProgress: (progressEvent: AxiosProgressEvent) => - func(progressEvent) - }) - - return { promise, cancel: source.cancel } -} -export const sendChatMessage = ( - data: SendChatMessageCondition, - func: Function -): chatMessagesRes => { - const source: CancelTokenSource = axios.CancelToken.source() - - const promise = request({ - method: 'post', - url: `/chatbot/auth-platforms/${data.authId}/threads/${data.threadId}/talk`, - responseType: 'stream', - data: { - message: data.message - }, - timeout: 0, - cancelToken: source.token, - onDownloadProgress: (progressEvent: AxiosProgressEvent) => - func(progressEvent) + onDownloadProgress: (progressEvent: AxiosProgressEvent) => func(progressEvent) }) return { promise, cancel: source.cancel } diff --git a/bigtop-manager-ui/src/api/sse/types.ts b/bigtop-manager-ui/src/api/sse/types.ts index 7bb9a342..8e169f04 100644 --- a/bigtop-manager-ui/src/api/sse/types.ts +++ b/bigtop-manager-ui/src/api/sse/types.ts @@ -21,7 +21,7 @@ export interface LogsRes { promise: Promise cancel: () => void } -export interface chatMessagesRes { +export interface ChatMessagesRes { promise: Promise cancel: () => void } diff --git a/bigtop-manager-ui/src/api/stack/index.ts b/bigtop-manager-ui/src/api/stack/index.ts index 534add90..f7d40042 100644 --- a/bigtop-manager-ui/src/api/stack/index.ts +++ b/bigtop-manager-ui/src/api/stack/index.ts @@ -29,20 +29,14 @@ export const getStacks = (): Promise => { }) } -export const getStackComponents = ( - stackName: string, - stackVersion: string -): Promise => { +export const getStackComponents = (stackName: string, stackVersion: string): Promise => { return request({ method: 'get', url: '/stacks/' + stackName + '/' + stackVersion + '/components' }) } -export const getStackConfigs = ( - stackName: string, - stackVersion: string -): Promise => { +export const getStackConfigs = (stackName: string, stackVersion: string): Promise => { return request({ method: 'get', url: '/stacks/' + stackName + '/' + stackVersion + '/configurations' diff --git a/bigtop-manager-ui/src/assets/images/ai_disabled.png b/bigtop-manager-ui/src/assets/images/ai_disabled.png new file mode 100644 index 00000000..ac50b603 Binary files /dev/null and b/bigtop-manager-ui/src/assets/images/ai_disabled.png differ diff --git a/bigtop-manager-ui/src/assets/images/ai_helper.png b/bigtop-manager-ui/src/assets/images/ai_helper.png new file mode 100644 index 00000000..95c52903 Binary files /dev/null and b/bigtop-manager-ui/src/assets/images/ai_helper.png differ diff --git a/bigtop-manager-ui/src/assets/images/svg/chat_avatar.svg b/bigtop-manager-ui/src/assets/images/svg/chat_avatar.svg new file mode 100644 index 00000000..ef83998d --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/chat_avatar.svg @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/chatbot.svg b/bigtop-manager-ui/src/assets/images/svg/chatbot.svg new file mode 100644 index 00000000..cdaefe52 --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/chatbot.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/exit_screen.svg b/bigtop-manager-ui/src/assets/images/svg/exit_screen.svg new file mode 100644 index 00000000..58f1168a --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/exit_screen.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/full_screen.svg b/bigtop-manager-ui/src/assets/images/svg/full_screen.svg new file mode 100644 index 00000000..c5bb8c21 --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/full_screen.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/history.svg b/bigtop-manager-ui/src/assets/images/svg/history.svg new file mode 100644 index 00000000..ca067326 --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/history.svg @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/plus_gray.svg b/bigtop-manager-ui/src/assets/images/svg/plus_gray.svg new file mode 100644 index 00000000..29d96ac8 --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/plus_gray.svg @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/assets/images/svg/send.svg b/bigtop-manager-ui/src/assets/images/svg/send.svg new file mode 100644 index 00000000..4d09ab7d --- /dev/null +++ b/bigtop-manager-ui/src/assets/images/svg/send.svg @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/bigtop-manager-ui/src/components/ai-assistant/chat-history.vue b/bigtop-manager-ui/src/components/ai-assistant/chat-history.vue new file mode 100644 index 00000000..ae18febc --- /dev/null +++ b/bigtop-manager-ui/src/components/ai-assistant/chat-history.vue @@ -0,0 +1,281 @@ + + + + + + diff --git a/bigtop-manager-ui/src/components/ai-assistant/chat-input.vue b/bigtop-manager-ui/src/components/ai-assistant/chat-input.vue new file mode 100644 index 00000000..1b0b085b --- /dev/null +++ b/bigtop-manager-ui/src/components/ai-assistant/chat-input.vue @@ -0,0 +1,73 @@ + + + + + + diff --git a/bigtop-manager-ui/src/components/ai-assistant/chat-message.vue b/bigtop-manager-ui/src/components/ai-assistant/chat-message.vue new file mode 100644 index 00000000..4499b183 --- /dev/null +++ b/bigtop-manager-ui/src/components/ai-assistant/chat-message.vue @@ -0,0 +1,71 @@ + + + + + + diff --git a/bigtop-manager-ui/src/components/ai-assistant/empty-content.vue b/bigtop-manager-ui/src/components/ai-assistant/empty-content.vue new file mode 100644 index 00000000..bb63bd66 --- /dev/null +++ b/bigtop-manager-ui/src/components/ai-assistant/empty-content.vue @@ -0,0 +1,103 @@ + + + + + + diff --git a/bigtop-manager-ui/src/components/ai-assistant/index.vue b/bigtop-manager-ui/src/components/ai-assistant/index.vue new file mode 100644 index 00000000..871d5c13 --- /dev/null +++ b/bigtop-manager-ui/src/components/ai-assistant/index.vue @@ -0,0 +1,225 @@ + + + + + + diff --git a/bigtop-manager-ui/src/components/chatbot/chat-msg-item.vue b/bigtop-manager-ui/src/components/chatbot/chat-msg-item.vue deleted file mode 100644 index 2d1ecb5e..00000000 --- a/bigtop-manager-ui/src/components/chatbot/chat-msg-item.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/chat-window.vue b/bigtop-manager-ui/src/components/chatbot/chat-window.vue deleted file mode 100644 index 7a632468..00000000 --- a/bigtop-manager-ui/src/components/chatbot/chat-window.vue +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/chatbot.vue b/bigtop-manager-ui/src/components/chatbot/chatbot.vue deleted file mode 100644 index 38d64603..00000000 --- a/bigtop-manager-ui/src/components/chatbot/chatbot.vue +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/model-selector.vue b/bigtop-manager-ui/src/components/chatbot/model-selector.vue deleted file mode 100644 index a15b8472..00000000 --- a/bigtop-manager-ui/src/components/chatbot/model-selector.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/platform-auth-form.vue b/bigtop-manager-ui/src/components/chatbot/platform-auth-form.vue deleted file mode 100644 index e3c5c19f..00000000 --- a/bigtop-manager-ui/src/components/chatbot/platform-auth-form.vue +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/platform-auth-selector.vue b/bigtop-manager-ui/src/components/chatbot/platform-auth-selector.vue deleted file mode 100644 index b689fd0c..00000000 --- a/bigtop-manager-ui/src/components/chatbot/platform-auth-selector.vue +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/platform-selection.vue b/bigtop-manager-ui/src/components/chatbot/platform-selection.vue deleted file mode 100644 index 58a72083..00000000 --- a/bigtop-manager-ui/src/components/chatbot/platform-selection.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/select-menu.vue b/bigtop-manager-ui/src/components/chatbot/select-menu.vue deleted file mode 100644 index 335c66db..00000000 --- a/bigtop-manager-ui/src/components/chatbot/select-menu.vue +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/chatbot/thread-selector.vue b/bigtop-manager-ui/src/components/chatbot/thread-selector.vue deleted file mode 100644 index 11443fc2..00000000 --- a/bigtop-manager-ui/src/components/chatbot/thread-selector.vue +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - diff --git a/bigtop-manager-ui/src/components/common/auto-form/index.vue b/bigtop-manager-ui/src/components/common/auto-form/index.vue index 79c3046f..9d924006 100644 --- a/bigtop-manager-ui/src/components/common/auto-form/index.vue +++ b/bigtop-manager-ui/src/components/common/auto-form/index.vue @@ -149,20 +149,13 @@ >
- + @@ -171,11 +164,7 @@ v-if="item.type == 'textarea'" v-model:value="formState[item.field]" v-bind="item.controlProps" - :disabled=" - disabledItems - ? disabledItems.includes(item.field) - : item.controlProps.disabled - " + :disabled="disabledItems ? disabledItems.includes(item.field) : item.controlProps.disabled" v-on="formItemEvents[item.field] || {}" /> @@ -184,29 +173,15 @@ v-if="item.type == 'select'" v-model:value="formState[item.field]" v-bind="item.controlProps" - :disabled=" - disabledItems - ? disabledItems.includes(item.field) - : item.controlProps.disabled - " + :disabled="disabledItems ? disabledItems.includes(item.field) : item.controlProps.disabled" v-on="formItemEvents[item.field] || {}" > - {{ - typeof child === 'string' - ? child - : child[(item.fieldMap && item.fieldMap.label) || 'label'] - }} + {{ typeof child === 'string' ? child : child[(item.fieldMap && item.fieldMap.label) || 'label'] }} @@ -215,21 +190,13 @@ v-if="item.type == 'radio'" v-model:value="formState[item.field]" v-bind="item.controlProps" - :disabled=" - disabledItems - ? disabledItems.includes(item.field) - : item.controlProps.disabled - " + :disabled="disabledItems ? disabledItems.includes(item.field) : item.controlProps.disabled" v-on="formItemEvents[item.field] || {}" > {{ child[(item.fieldMap && item.fieldMap.label) || 'label'] }} diff --git a/bigtop-manager-ui/src/components/common/auto-form/template.vue b/bigtop-manager-ui/src/components/common/auto-form/template.vue index b42f7418..08512fbb 100644 --- a/bigtop-manager-ui/src/components/common/auto-form/template.vue +++ b/bigtop-manager-ui/src/components/common/auto-form/template.vue @@ -21,10 +21,7 @@ import { computed, onMounted, onUnmounted, ref, watchPostEffect } from 'vue' import { usePngImage } from '@/utils/tools' import { useI18n } from 'vue-i18n' - import type { - FormItemState, - FormState - } from '@/components/common/auto-form/types' + import type { FormItemState, FormState } from '@/components/common/auto-form/types' const { t } = useI18n() const helper = usePngImage('helper') diff --git a/bigtop-manager-ui/src/components/common/button-group/index.vue b/bigtop-manager-ui/src/components/common/button-group/index.vue new file mode 100644 index 00000000..bc2b6d50 --- /dev/null +++ b/bigtop-manager-ui/src/components/common/button-group/index.vue @@ -0,0 +1,57 @@ + + + + + + + diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/CustomCommandInfo.java b/bigtop-manager-ui/src/components/common/button-group/types.ts similarity index 64% rename from bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/CustomCommandInfo.java rename to bigtop-manager-ui/src/components/common/button-group/types.ts index 5e83dee2..ae481660 100644 --- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/pojo/CustomCommandInfo.java +++ b/bigtop-manager-ui/src/components/common/button-group/types.ts @@ -16,18 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.bigtop.manager.common.message.entity.pojo; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +type BtnType = 'primary' | 'ghost' | 'dashed' | 'link' | 'text' | 'default' +type ShapeType = 'default' | 'circle' | 'round' -@Data -@AllArgsConstructor -@NoArgsConstructor -public class CustomCommandInfo { - - private String name; +export interface GroupItem { + icon?: string + tip?: string + text?: string + action?: T + type?: BtnType + shape?: ShapeType + disabled?: boolean + clickEvent?: (item?: GroupItem, ...args: any[]) => void +} - private ScriptInfo commandScript; +export interface Props { + i18n: string + groups: GroupItem[] + groupType?: BtnType + groupShape?: ShapeType } diff --git a/bigtop-manager-ui/src/components/common/index.ts b/bigtop-manager-ui/src/components/common/index.ts index 61da3360..427e7ed2 100644 --- a/bigtop-manager-ui/src/components/common/index.ts +++ b/bigtop-manager-ui/src/components/common/index.ts @@ -20,9 +20,7 @@ import type { App } from 'vue' const kebabToCamel = (kebab: string): string => { - return kebab - .replace(/-./g, (match) => match.charAt(1).toUpperCase()) - .replace(/^./, (match) => match.toUpperCase()) + return kebab.replace(/-./g, (match) => match.charAt(1).toUpperCase()).replace(/^./, (match) => match.toUpperCase()) } const install = (app: App) => { diff --git a/bigtop-manager-ui/src/components/common/markdown-view/index.vue b/bigtop-manager-ui/src/components/common/markdown-view/index.vue index 573f6b46..15b72209 100644 --- a/bigtop-manager-ui/src/components/common/markdown-view/index.vue +++ b/bigtop-manager-ui/src/components/common/markdown-view/index.vue @@ -57,16 +57,9 @@ const langTag = pre.querySelector('#language') const copyTag = pre.querySelector('#copy') - langTag!.textContent = ( - code?.classList.value.replace('hljs language-', '') as string - ).toLowerCase() - copyTag && - copyTag.removeEventListener('click', () => - copyCode(code?.textContent || '') - ) - copyTag?.addEventListener('click', () => - copyCode(code?.textContent || '') - ) + langTag!.textContent = (code?.classList.value.replace('hljs language-', '') as string).toLowerCase() + copyTag && copyTag.removeEventListener('click', () => copyCode(code?.textContent || '')) + copyTag?.addEventListener('click', () => copyCode(code?.textContent || '')) }) } @@ -99,12 +92,7 @@ diff --git a/bigtop-manager-ui/src/components/user-avatar/index.vue b/bigtop-manager-ui/src/components/user-avatar/index.vue index b8778a0e..8e67e101 100644 --- a/bigtop-manager-ui/src/components/user-avatar/index.vue +++ b/bigtop-manager-ui/src/components/user-avatar/index.vue @@ -18,11 +18,7 @@ --> @@ -86,7 +95,7 @@ } .header { @include flexbox($justify: space-between, $align: center); - padding-inline: 0 16px; + padding-inline: 0 $space-md; height: $layout-header-height; .header-menu { flex: 1; diff --git a/bigtop-manager-ui/src/layouts/index.vue b/bigtop-manager-ui/src/layouts/index.vue index b769b149..7c70c6dc 100644 --- a/bigtop-manager-ui/src/layouts/index.vue +++ b/bigtop-manager-ui/src/layouts/index.vue @@ -30,8 +30,7 @@ const userStore = useUserStore() const menuStore = useMenuStore() const clusterStore = useClusterStore() - const { headerSelectedKey, headerMenus, siderMenuSelectedKey, siderMenus } = - storeToRefs(menuStore) + const { headerSelectedKey, headerMenus, siderMenuSelectedKey, siderMenus } = storeToRefs(menuStore) onMounted(async () => { userStore.getUserInfo() diff --git a/bigtop-manager-ui/src/layouts/sider.vue b/bigtop-manager-ui/src/layouts/sider.vue index ac6ab902..9ace4338 100644 --- a/bigtop-manager-ui/src/layouts/sider.vue +++ b/bigtop-manager-ui/src/layouts/sider.vue @@ -42,9 +42,7 @@ const toggleActivatedIcon = (menuItem: MenuItem) => { const { key, icon } = menuItem if (menuStore.isDynamicRouteMatched) { - return key === RouteExceptions.SPECIAL_ROUTE_PATH - ? `${icon}_activated` - : icon + return key === RouteExceptions.SPECIAL_ROUTE_PATH ? `${icon}_activated` : icon } else { return key === siderMenuSelectedKey.value ? `${icon}_activated` : icon } @@ -61,17 +59,10 @@