You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by wu...@apache.org on 2024/08/29 09:18:38 UTC
(bigtop-manager) branch main updated: BIGTOP-4192: Switch ORM framework from JPA to MyBatis (#54)
This is an automated email from the ASF dual-hosted git repository.
wuzhiguo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/bigtop-manager.git
The following commit(s) were added to refs/heads/main by this push:
new 1c84d15 BIGTOP-4192: Switch ORM framework from JPA to MyBatis (#54)
1c84d15 is described below
commit 1c84d15a04cc6c3fd24712076fcccb2e5be0caf9
Author: timyuer <52...@qq.com>
AuthorDate: Thu Aug 29 17:18:33 2024 +0800
BIGTOP-4192: Switch ORM framework from JPA to MyBatis (#54)
---
bigtop-manager-bom/pom.xml | 36 ++--
.../bigtop/manager/common/enums/Command.java | 28 ++-
.../bigtop/manager/common/enums/JobState.java | 18 +-
.../bigtop/manager/common/enums/MaintainState.java | 17 +-
.../bigtop/manager/common/utils/ClassUtils.java | 27 ++-
bigtop-manager-dao/pom.xml | 5 +-
.../apache/bigtop/manager/dao/po/AuditLogPO.java | 21 +-
.../org/apache/bigtop/manager/dao/po/BasePO.java | 18 +-
.../apache/bigtop/manager/dao/po/ClusterPO.java | 49 ++---
.../apache/bigtop/manager/dao/po/ComponentPO.java | 61 ++----
.../bigtop/manager/dao/po/HostComponentPO.java | 89 ++++++---
.../org/apache/bigtop/manager/dao/po/HostPO.java | 39 +---
.../org/apache/bigtop/manager/dao/po/JobPO.java | 35 +---
.../org/apache/bigtop/manager/dao/po/RepoPO.java | 30 +--
.../bigtop/manager/dao/po/ServiceConfigPO.java | 43 ++--
.../apache/bigtop/manager/dao/po/ServicePO.java | 52 ++---
.../apache/bigtop/manager/dao/po/SettingPO.java | 21 +-
.../org/apache/bigtop/manager/dao/po/StackPO.java | 19 +-
.../org/apache/bigtop/manager/dao/po/StagePO.java | 49 +----
.../org/apache/bigtop/manager/dao/po/TaskPO.java | 56 ++----
.../apache/bigtop/manager/dao/po/TypeConfigPO.java | 30 +--
.../org/apache/bigtop/manager/dao/po/UserPO.java | 14 +-
.../{AuditLogRepository.java => AuditLogDao.java} | 7 +-
.../bigtop/manager/dao/repository/BaseDao.java | 80 ++++++++
.../{ClusterRepository.java => ClusterDao.java} | 16 +-
...{ComponentRepository.java => ComponentDao.java} | 19 +-
.../manager/dao/repository/HostComponentDao.java | 51 +++++
.../dao/repository/HostComponentRepository.java | 47 -----
.../{JobRepository.java => HostDao.java} | 22 +-
.../manager/dao/repository/HostRepository.java | 43 ----
.../{StageRepository.java => JobDao.java} | 15 +-
.../{RepoRepository.java => RepoDao.java} | 15 +-
.../{JobRepository.java => ServiceConfigDao.java} | 18 +-
.../dao/repository/ServiceConfigRepository.java | 49 -----
.../{ServiceRepository.java => ServiceDao.java} | 20 +-
.../{SettingRepository.java => SettingDao.java} | 7 +-
.../{StackRepository.java => StackDao.java} | 10 +-
.../{StageRepository.java => StageDao.java} | 12 +-
.../{UserRepository.java => TaskDao.java} | 13 +-
.../manager/dao/repository/TaskRepository.java | 38 ----
...ypeConfigRepository.java => TypeConfigDao.java} | 7 +-
.../{UserRepository.java => UserDao.java} | 9 +-
.../bigtop/manager/dao/sql/BaseSqlProvider.java | 115 +++++++++++
.../org/apache/bigtop/manager/dao/sql/DBType.java | 43 ++--
.../apache/bigtop/manager/dao/sql/SQLBuilder.java | 205 +++++++++++++++++++
.../bigtop/manager/dao/sql/TableMetaData.java | 135 +++++++++++++
.../main/resources/mapper/mysql/ClusterMapper.xml | 81 ++++++++
.../resources/mapper/mysql/ComponentMapper.xml | 109 ++++++++++
.../resources/mapper/mysql/HostComponentMapper.xml | 222 +++++++++++++++++++++
.../src/main/resources/mapper/mysql/HostMapper.xml | 111 +++++++++++
.../src/main/resources/mapper/mysql/JobMapper.xml | 130 ++++++++++++
.../src/main/resources/mapper/mysql/RepoMapper.xml | 64 ++++++
.../resources/mapper/mysql/ServiceConfigMapper.xml | 118 +++++++++++
.../main/resources/mapper/mysql/ServiceMapper.xml | 133 ++++++++++++
.../main/resources/mapper/mysql/StackMapper.xml | 46 +++++
.../main/resources/mapper/mysql/StageMapper.xml | 39 ++++
.../src/main/resources/mapper/mysql/TaskMapper.xml | 39 ++++
.../src/main/resources/mapper/mysql/UserMapper.xml | 43 ++++
bigtop-manager-server/pom.xml | 31 +--
.../bigtop/manager/server/ServerApplication.java | 8 +-
.../bigtop/manager/server/aop/AuditAspect.java | 6 +-
.../manager/server/command/job/AbstractJob.java | 58 +++---
.../server/command/job/AbstractServiceJob.java | 35 ++--
.../server/command/job/ClusterCreateJob.java | 18 +-
.../server/command/job/ServiceInstallJob.java | 45 ++---
.../command/stage/AbstractComponentStage.java | 8 +-
.../server/command/stage/AbstractStage.java | 19 +-
.../server/command/stage/CacheFileUpdateStage.java | 8 +-
.../server/command/stage/HostCheckStage.java | 12 +-
.../server/command/task/AbstractComponentTask.java | 6 +-
.../manager/server/command/task/AbstractTask.java | 21 +-
.../server/command/task/CacheFileUpdateTask.java | 88 ++++----
.../server/command/task/ComponentInstallTask.java | 7 +-
.../server/command/task/ComponentStartTask.java | 7 +-
.../server/command/task/ComponentStopTask.java | 7 +-
.../command/validator/ClusterCreateValidator.java | 6 +-
.../command/validator/ClusterHostValidator.java | 6 +-
.../server/command/validator/HostAddValidator.java | 6 +-
.../validator/RequiredServicesValidator.java | 17 +-
.../command/validator/ServiceHostValidator.java | 6 +-
.../server/command/validator/StackValidator.java | 6 +-
.../manager/server/config/EclipseLinkConfig.java | 55 -----
.../server/model/converter/ClusterConverter.java | 6 +-
.../server/model/converter/ComponentConverter.java | 6 +-
.../model/converter/HostComponentConverter.java | 7 -
.../server/model/converter/HostConverter.java | 2 -
.../server/model/converter/JobConverter.java | 1 -
.../server/model/converter/RepoConverter.java | 4 +-
.../model/converter/ServiceConfigConverter.java | 2 -
.../server/model/converter/ServiceConverter.java | 6 +-
.../server/model/converter/StageConverter.java | 1 -
.../manager/server/model/query/PageQuery.java | 4 +-
.../bigtop/manager/server/model/vo/ClusterVO.java | 4 +-
.../manager/server/model/vo/HostComponentVO.java | 4 +-
.../bigtop/manager/server/model/vo/HostVO.java | 4 +-
.../bigtop/manager/server/model/vo/JobVO.java | 4 +-
.../bigtop/manager/server/model/vo/PageVO.java | 10 +-
.../bigtop/manager/server/model/vo/StageVO.java | 4 +-
.../bigtop/manager/server/model/vo/TaskVO.java | 4 +-
.../server/scheduler/ComponentStatusScheduler.java | 50 ++---
.../server/scheduler/HostInfoScheduler.java | 12 +-
.../server/service/impl/ClusterServiceImpl.java | 39 ++--
.../server/service/impl/CommandServiceImpl.java | 51 ++---
.../server/service/impl/ComponentServiceImpl.java | 10 +-
.../server/service/impl/ConfigServiceImpl.java | 42 ++--
.../service/impl/HostComponentServiceImpl.java | 19 +-
.../server/service/impl/HostServiceImpl.java | 30 ++-
.../server/service/impl/JobServiceImpl.java | 56 +++---
.../server/service/impl/LoginServiceImpl.java | 6 +-
.../server/service/impl/ServiceServiceImpl.java | 95 ++++-----
.../server/service/impl/TaskLogServiceImpl.java | 11 +-
.../server/service/impl/UserServiceImpl.java | 10 +-
.../manager/server/stack/StackInitializer.java | 8 +-
.../bigtop/manager/server/utils/PageUtils.java | 8 +-
.../src/main/resources/application.yml | 40 ++--
.../src/main/resources/assembly/server.xml | 4 +
.../src/main/resources/ddl/MySQL-DDL-CREATE.sql | 55 ++---
.../src/main/resources/logback-spring.xml | 4 +-
.../bigtop/manager/server/aop/AuditAspectTest.java | 10 +-
dev-support/docker/rocky8/build-containers.sh | 1 +
120 files changed, 2611 insertions(+), 1397 deletions(-)
diff --git a/bigtop-manager-bom/pom.xml b/bigtop-manager-bom/pom.xml
index 72f101a..55ea3d0 100644
--- a/bigtop-manager-bom/pom.xml
+++ b/bigtop-manager-bom/pom.xml
@@ -42,15 +42,15 @@
<commons-compress.version>1.26.2</commons-compress.version>
<jwt.version>4.4.0</jwt.version>
<janino.version>3.0.16</janino.version>
- <eclipse-link.version>4.0.2</eclipse-link.version>
<jaxb-runtime.version>4.0.4</jaxb-runtime.version>
- <hibernate-core.version>6.2.5.Final</hibernate-core.version>
<commons-text.version>1.11.0</commons-text.version>
<prometheus-java-client.version>1.0.0</prometheus-java-client.version>
<oshi-core.version>6.4.11</oshi-core.version>
<micrometer.version>1.12.4</micrometer.version>
<jdbc.dm.version>8.1.2.192</jdbc.dm.version>
<langchain4j.version>0.33.0</langchain4j.version>
+ <mybatis-spring-boot-starter.version>3.0.3</mybatis-spring-boot-starter.version>
+ <pagehelper-spring-boot-starter.version>2.1.0</pagehelper-spring-boot-starter.version>
</properties>
<dependencyManagement>
@@ -69,18 +69,6 @@
<version>${springdoc.version}</version>
</dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.jpa</artifactId>
- <version>${eclipse-link.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.extension</artifactId>
- <version>${eclipse-link.version}</version>
- </dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
@@ -159,13 +147,6 @@
<version>${jaxb-runtime.version}</version>
</dependency>
- <dependency>
- <groupId>org.hibernate.orm</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${hibernate-core.version}</version>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
@@ -203,6 +184,19 @@
<version>${oshi-core.version}</version>
</dependency>
+ <!-- mybatis -->
+ <dependency>
+ <groupId>org.mybatis.spring.boot</groupId>
+ <artifactId>mybatis-spring-boot-starter</artifactId>
+ <version>${mybatis-spring-boot-starter.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.github.pagehelper</groupId>
+ <artifactId>pagehelper-spring-boot-starter</artifactId>
+ <version>${pagehelper-spring-boot-starter.version}</version>
+ </dependency>
+
<!-- dameng -->
<dependency>
<groupId>com.dameng</groupId>
diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/Command.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/Command.java
index c6d3786..a379fca 100644
--- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/Command.java
+++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/Command.java
@@ -22,29 +22,37 @@ import org.apache.bigtop.manager.common.utils.CaseUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+@AllArgsConstructor
+@Getter
public enum Command {
- CREATE,
+ CREATE("create", "Create"),
- INSTALL,
+ INSTALL("install", "Install"),
- UNINSTALL,
+ UNINSTALL("uninstall", "Uninstall"),
- START,
+ START("start", "Start"),
- STOP,
+ STOP("stop", "Stop"),
- STATUS,
+ STATUS("status", "Status"),
- RESTART,
+ RESTART("restart", "Restart"),
- CONFIGURE,
+ CONFIGURE("configure", "Configure"),
- CHECK,
+ CHECK("check", "Check"),
- CUSTOM,
+ CUSTOM("custom", "Custom"),
;
+ private final String code;
+
+ private final String name;
+
@JsonCreator
public static Command fromString(String value) {
return Command.valueOf(value.toUpperCase());
diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/JobState.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/JobState.java
index 1789bea..04e1a80 100644
--- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/JobState.java
+++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/JobState.java
@@ -22,19 +22,27 @@ import org.apache.bigtop.manager.common.utils.CaseUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+@AllArgsConstructor
+@Getter
public enum JobState {
- PENDING,
+ PENDING("pending", "Pending"),
- PROCESSING,
+ PROCESSING("processing", "Processing"),
- SUCCESSFUL,
+ SUCCESSFUL("successful", "Successful"),
- FAILED,
+ FAILED("failed", "Failed"),
- CANCELED,
+ CANCELED("canceled", "Canceled"),
;
+ private final String code;
+
+ private final String name;
+
@JsonCreator
public static JobState fromString(String value) {
return JobState.valueOf(value.toUpperCase());
diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/MaintainState.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/MaintainState.java
index 81617b7..6c9df31 100644
--- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/MaintainState.java
+++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/enums/MaintainState.java
@@ -22,20 +22,25 @@ import org.apache.bigtop.manager.common.utils.CaseUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.AllArgsConstructor;
import lombok.Getter;
+@AllArgsConstructor
@Getter
public enum MaintainState {
- UNINSTALLED,
+ UNINSTALLED("uninstalled", "Uninstalled"),
- INSTALLED,
+ INSTALLED("installed", "Installed"),
- MAINTAINED,
+ MAINTAINED("maintained", "Maintained"),
- STARTED,
+ STARTED("started", "Started"),
- STOPPED,
- ;
+ STOPPED("stopped", "Stopped");
+
+ private final String code;
+
+ private final String name;
@JsonCreator
public static MaintainState fromString(String value) {
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ClassUtils.java
similarity index 58%
copy from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java
copy to bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ClassUtils.java
index 39d629f..8c43ea5 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java
+++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/ClassUtils.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,16 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.bigtop.manager.dao.repository;
-
-import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.po.RepoPO;
-
-import org.springframework.data.jpa.repository.JpaRepository;
+package org.apache.bigtop.manager.common.utils;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-public interface RepoRepository extends JpaRepository<RepoPO, Long> {
+public class ClassUtils {
+
+ /**
+ * Get all Fields
+ */
+ public static List<Field> getFields(Class<?> loadClass) {
+ List<Field> fieldList = new ArrayList<>();
- List<RepoPO> findAllByClusterPO(ClusterPO clusterPO);
+ while (loadClass != null) {
+ fieldList.addAll(Arrays.asList(loadClass.getDeclaredFields()));
+ loadClass = loadClass.getSuperclass();
+ }
+ return fieldList;
+ }
}
diff --git a/bigtop-manager-dao/pom.xml b/bigtop-manager-dao/pom.xml
index 8bf7a51..6fed3ad 100644
--- a/bigtop-manager-dao/pom.xml
+++ b/bigtop-manager-dao/pom.xml
@@ -49,9 +49,10 @@
</dependency>
<dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-jpa</artifactId>
+ <groupId>org.mybatis.spring.boot</groupId>
+ <artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
+
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/AuditLogPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/AuditLogPO.java
index 6136657..095b2ad 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/AuditLogPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/AuditLogPO.java
@@ -21,39 +21,24 @@ package org.apache.bigtop.manager.dao.po;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Lob;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
@Table(name = "audit_log")
-@TableGenerator(
- name = "audit_log_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class AuditLogPO extends BasePO {
+public class AuditLogPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "audit_log_generator")
@Column(name = "id")
private Long id;
@Column(name = "uri")
private String uri;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "args", length = 16777216)
+ @Column(name = "args")
private String args;
@Column(name = "tag_name")
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/BasePO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/BasePO.java
index 819f0c6..7fe37f9 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/BasePO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/BasePO.java
@@ -18,37 +18,23 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.springframework.data.annotation.CreatedBy;
-import org.springframework.data.annotation.CreatedDate;
-import org.springframework.data.annotation.LastModifiedBy;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
import lombok.Data;
import jakarta.persistence.Column;
-import jakarta.persistence.EntityListeners;
-import jakarta.persistence.MappedSuperclass;
import java.sql.Timestamp;
@Data
-@MappedSuperclass
-@EntityListeners(AuditingEntityListener.class)
public abstract class BasePO {
- @CreatedDate
- @Column(name = "create_time", updatable = false)
+ @Column(name = "create_time")
private Timestamp createTime;
- @LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
- @CreatedBy
- @Column(name = "create_by", updatable = false)
+ @Column(name = "create_by")
private Long createBy;
- @LastModifiedBy
@Column(name = "update_by")
private Long updateBy;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ClusterPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ClusterPO.java
index 5e6015b..3b70c0a 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ClusterPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ClusterPO.java
@@ -18,45 +18,21 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "\"cluster\"",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_cluster_name",
- columnNames = {"cluster_name"})
- },
- indexes = {@Index(name = "idx_cluster_stack_id", columnList = "stack_id")})
-@TableGenerator(
- name = "cluster_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class ClusterPO extends BasePO {
+@Table(name = "cluster")
+public class ClusterPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "cluster_generator")
@Column(name = "id")
private Long id;
@@ -66,7 +42,7 @@ public class ClusterPO extends BasePO {
@Column(name = "cluster_type")
private Integer clusterType;
- @Column(name = "\"root\"")
+ @Column(name = "root")
private String root;
@Column(name = "user_group")
@@ -79,12 +55,19 @@ public class ClusterPO extends BasePO {
private String repoTemplate;
@Column(name = "state")
- private MaintainState state;
+ private String state;
@Column(name = "selected")
private Boolean selected;
- @ManyToOne
- @JoinColumn(name = "stack_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private StackPO stackPO;
+ @Column(name = "stack_id")
+ private Long stackId;
+
+ @Transient
+ @Column(name = "stack_name")
+ private String stackName;
+
+ @Transient
+ @Column(name = "stack_version")
+ private String stackVersion;
}
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 d5e530a..bc0a410 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
@@ -21,46 +21,18 @@ package org.apache.bigtop.manager.dao.po;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "component",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_component_name",
- columnNames = {"component_name", "cluster_id"})
- },
- indexes = {
- @Index(name = "idx_component_cluster_id", columnList = "cluster_id"),
- @Index(name = "idx_component_service_id", columnList = "service_id")
- })
-@TableGenerator(
- name = "component_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class ComponentPO extends BasePO {
+@Table(name = "component")
+public class ComponentPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "component_generator")
@Column(name = "id")
private Long id;
@@ -73,9 +45,7 @@ public class ComponentPO extends BasePO {
@Column(name = "command_script")
private String commandScript;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "custom_commands", length = 16777216)
+ @Column(name = "custom_commands")
private String customCommands;
@Column(name = "category")
@@ -84,11 +54,20 @@ public class ComponentPO extends BasePO {
@Column(name = "quick_link")
private String quickLink;
- @ManyToOne
- @JoinColumn(name = "service_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ServicePO servicePO;
+ @Column(name = "cardinality")
+ private String cardinality;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "service_id")
+ private Long serviceId;
+
+ @Column(name = "cluster_id")
+ private Long clusterId;
+
+ @Transient
+ @Column(name = "service_name")
+ private String serviceName;
+
+ @Transient
+ @Column(name = "cluster_name")
+ private String clusterName;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostComponentPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostComponentPO.java
index 74fe6af..accf5d3 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostComponentPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostComponentPO.java
@@ -18,53 +18,78 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "host_component",
- indexes = {
- @Index(name = "idx_hc_component_id", columnList = "component_id"),
- @Index(name = "idx_hc_host_id", columnList = "host_id")
- })
-@TableGenerator(
- name = "host_component_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class HostComponentPO extends BasePO {
+@Table(name = "host_component")
+public class HostComponentPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "host_component_generator")
@Column(name = "id")
private Long id;
@Column(name = "state")
- private MaintainState state;
+ private String state;
+
+ @Column(name = "host_id")
+ private Long hostId;
+
+ @Column(name = "component_id")
+ private Long componentId;
+
+ @Transient
+ @Column(name = "stack_name")
+ private String stackName;
+
+ @Transient
+ @Column(name = "stack_version")
+ private String stackVersion;
+
+ @Transient
+ @Column(name = "service_id")
+ private Long serviceId;
+
+ @Transient
+ @Column(name = "cluster_name")
+ private String clusterName;
+
+ @Transient
+ @Column(name = "root")
+ private String root;
+
+ @Transient
+ @Column(name = "service_name")
+ private String serviceName;
+
+ @Transient
+ @Column(name = "service_user")
+ private String serviceUser;
+
+ @Transient
+ @Column(name = "component_name")
+ private String componentName;
+
+ @Transient
+ @Column(name = "display_name")
+ private String displayName;
+
+ @Transient
+ @Column(name = "category")
+ private String category;
- @ManyToOne
- @JoinColumn(name = "host_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private HostPO hostPO;
+ @Transient
+ @Column(name = "command_script")
+ private String commandScript;
- @ManyToOne
- @JoinColumn(name = "component_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ComponentPO componentPO;
+ @Transient
+ @Column(name = "hostname")
+ private String hostname;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostPO.java
index 36df7fe..f0b3054 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/HostPO.java
@@ -18,41 +18,21 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "host",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_hostname",
- columnNames = {"hostname", "cluster_id"})
- },
- indexes = {@Index(name = "idx_host_cluster_id", columnList = "cluster_id")})
-@TableGenerator(name = "host_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class HostPO extends BasePO {
+@Table(name = "host")
+public class HostPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "host_generator")
@Column(name = "id")
private Long id;
@@ -87,9 +67,12 @@ public class HostPO extends BasePO {
private Long totalDisk;
@Column(name = "state")
- private MaintainState state;
+ private String state;
+
+ @Column(name = "cluster_id")
+ private Long clusterId;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Transient
+ @Column(name = "cluster_name")
+ private String clusterName;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/JobPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/JobPO.java
index f7ffceb..30adbb6 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/JobPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/JobPO.java
@@ -18,60 +18,41 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "\"job\"",
- indexes = {@Index(name = "idx_job_cluster_id", columnList = "cluster_id")})
-@TableGenerator(name = "job_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class JobPO extends BasePO {
+@Table(name = "job")
+public class JobPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "job_generator")
@Column(name = "id")
private Long id;
@Column(name = "state")
- private JobState state;
+ private String state;
@Column(name = "name")
private String name;
@Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "\"context\"", length = 16777216)
+ @Column(name = "context")
private String context;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
@ToString.Exclude
@OneToMany(mappedBy = "jobPO")
- private List<StagePO> stagePOList;
+ private List<StagePO> stages;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/RepoPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/RepoPO.java
index d0a922a..00030d2 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/RepoPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/RepoPO.java
@@ -22,35 +22,16 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "repo",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_repo_id",
- columnNames = {"repo_id", "os", "arch", "cluster_id"})
- },
- indexes = {@Index(name = "idx_repo_cluster_id", columnList = "cluster_id")})
-@TableGenerator(name = "repo_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class RepoPO extends BasePO {
+@Table(name = "repo")
+public class RepoPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "repo_generator")
@Column(name = "id")
private Long id;
@@ -72,7 +53,6 @@ public class RepoPO extends BasePO {
@Column(name = "repo_type")
private String repoType;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServiceConfigPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServiceConfigPO.java
index fe8856d..4c622ce 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServiceConfigPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServiceConfigPO.java
@@ -23,38 +23,18 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "service_config",
- indexes = {
- @Index(name = "idx_sc_cluster_id", columnList = "cluster_id"),
- @Index(name = "idx_sc_service_id", columnList = "service_id")
- })
-@TableGenerator(
- name = "service_config_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class ServiceConfigPO extends BasePO {
+@Table(name = "service_config")
+public class ServiceConfigPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "service_config_generator")
@Column(name = "id")
private Long id;
@@ -68,14 +48,15 @@ public class ServiceConfigPO extends BasePO {
private Boolean selected;
@ToString.Exclude
- @OneToMany(mappedBy = "serviceConfigPO")
private List<TypeConfigPO> configs;
- @ManyToOne
- @JoinColumn(name = "service_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ServicePO servicePO;
+ @Column(name = "service_id")
+ private Long serviceId;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
+
+ @Transient
+ @Column(name = "service_name")
+ private String serviceName;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServicePO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServicePO.java
index 51a7369..4584d7f 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServicePO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/ServicePO.java
@@ -20,41 +20,21 @@ package org.apache.bigtop.manager.dao.po;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import lombok.ToString;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import jakarta.persistence.Transient;
+import java.io.Serializable;
+import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "service",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_service_name",
- columnNames = {"service_name", "cluster_id"})
- },
- indexes = {@Index(name = "idx_service_cluster_id", columnList = "cluster_id")})
-@TableGenerator(
- name = "service_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class ServicePO extends BasePO {
+@Table(name = "service")
+public class ServicePO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "service_generator")
@Column(name = "id")
private Long id;
@@ -64,13 +44,13 @@ public class ServicePO extends BasePO {
@Column(name = "display_name")
private String displayName;
- @Column(name = "service_desc", length = 1024)
+ @Column(name = "service_desc")
private String serviceDesc;
@Column(name = "service_version")
private String serviceVersion;
- @Column(name = "package_specifics", length = 1024)
+ @Column(name = "package_specifics")
private String packageSpecifics;
@Column(name = "service_user")
@@ -79,7 +59,17 @@ public class ServicePO extends BasePO {
@Column(name = "required_services")
private String requiredServices;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
+
+ @Transient
+ @Column(name = "cluster_name")
+ private String clusterName;
+
+ @Transient
+ @Column(name = "user_group")
+ private String userGroup;
+
+ @ToString.Exclude
+ private List<ComponentPO> components;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/SettingPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/SettingPO.java
index dac0181..e0c85d8 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/SettingPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/SettingPO.java
@@ -21,38 +21,23 @@ package org.apache.bigtop.manager.dao.po;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Lob;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
@Table(name = "setting")
-@TableGenerator(
- name = "settings_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class SettingPO extends BasePO {
+public class SettingPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "settings_generator")
@Column(name = "id")
private Long id;
@Column(name = "type_name")
private String typeName;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "config_data", length = 16777216)
+ @Column(name = "config_data")
private String configData;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StackPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StackPO.java
index 0f8211a..76db3ea 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StackPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StackPO.java
@@ -22,29 +22,16 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-import jakarta.persistence.UniqueConstraint;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "stack",
- uniqueConstraints = {
- @UniqueConstraint(
- name = "uk_stack",
- columnNames = {"stack_name", "stack_version"})
- })
-@TableGenerator(name = "stack_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class StackPO extends BasePO {
+@Table(name = "stack")
+public class StackPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "stack_generator")
@Column(name = "id")
private Long id;
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StagePO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StagePO.java
index 7678a39..22a2d94 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StagePO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/StagePO.java
@@ -18,44 +18,22 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "stage",
- indexes = {
- @Index(name = "idx_stage_cluster_id", columnList = "cluster_id"),
- @Index(name = "idx_stage_job_id", columnList = "job_id")
- })
-@TableGenerator(name = "stage_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class StagePO extends BasePO {
+@Table(name = "stage")
+public class StagePO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "stage_generator")
@Column(name = "id")
private Long id;
@@ -63,9 +41,9 @@ public class StagePO extends BasePO {
private String name;
@Column(name = "state")
- private JobState state;
+ private String state;
- @Column(name = "\"order\"")
+ @Column(name = "order")
private Integer order;
@Column(name = "service_name")
@@ -74,20 +52,15 @@ public class StagePO extends BasePO {
@Column(name = "component_name")
private String componentName;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "\"context\"", length = 16777216)
+ @Column(name = "context")
private String context;
- @ManyToOne
- @JoinColumn(name = "job_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private JobPO jobPO;
+ @Column(name = "job_id")
+ private Long jobId;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
@ToString.Exclude
- @OneToMany(mappedBy = "stagePO")
- private List<TaskPO> taskPOList;
+ private List<TaskPO> tasks;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TaskPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TaskPO.java
index c58e5c4..54b5071 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TaskPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TaskPO.java
@@ -18,56 +18,31 @@
*/
package org.apache.bigtop.manager.dao.po;
-import org.apache.bigtop.manager.common.enums.Command;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "\"task\"",
- indexes = {
- @Index(name = "idx_task_cluster_id", columnList = "cluster_id"),
- @Index(name = "idx_task_job_id", columnList = "job_id"),
- @Index(name = "idx_task_stage_id", columnList = "stage_id")
- })
-@TableGenerator(name = "task_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class TaskPO extends BasePO {
+@Table(name = "task")
+public class TaskPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "task_generator")
@Column(name = "id")
private Long id;
@Column(name = "name")
private String name;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "context", length = 16777216)
+ @Column(name = "context")
private String context;
@Column(name = "state")
- private JobState state;
+ private String state;
@Column(name = "service_name")
private String serviceName;
@@ -76,7 +51,7 @@ public class TaskPO extends BasePO {
private String componentName;
@Column(name = "command")
- private Command command;
+ private String command;
@Column(name = "custom_command")
private String customCommand;
@@ -93,20 +68,15 @@ public class TaskPO extends BasePO {
@Column(name = "service_user")
private String serviceUser;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "content", length = 16777216)
+ @Column(name = "content")
private String content;
- @ManyToOne
- @JoinColumn(name = "job_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private JobPO jobPO;
+ @Column(name = "stage_id")
+ private Long stageId;
- @ManyToOne
- @JoinColumn(name = "stage_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private StagePO stagePO;
+ @Column(name = "job_id")
+ private Long jobId;
- @ManyToOne
- @JoinColumn(name = "cluster_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ClusterPO clusterPO;
+ @Column(name = "cluster_id")
+ private Long clusterId;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TypeConfigPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TypeConfigPO.java
index 919060c..1fb21bf 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TypeConfigPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/TypeConfigPO.java
@@ -21,46 +21,26 @@ package org.apache.bigtop.manager.dao.po;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.Basic;
import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
@Table(name = "type_config")
-@TableGenerator(
- name = "type_config_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class TypeConfigPO extends BasePO {
+public class TypeConfigPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "type_config_generator")
@Column(name = "id")
private Long id;
@Column(name = "type_name")
private String typeName;
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "properties_json", length = 16777216)
+ @Column(name = "properties_json")
private String propertiesJson;
- @ManyToOne
- @JoinColumn(name = "service_config_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private ServiceConfigPO serviceConfigPO;
+ @Column(name = "service_config_id")
+ private Long serviceConfigId;
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/UserPO.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/UserPO.java
index d568428..e684ea7 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/UserPO.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/po/UserPO.java
@@ -22,29 +22,23 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
+import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(name = "\"user\"")
-@TableGenerator(name = "user_generator", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_count")
-public class UserPO extends BasePO {
+@Table(name = "user")
+public class UserPO extends BasePO implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "user_generator")
@Column(name = "id")
private Long id;
@Column(name = "username")
private String username;
- @Column(name = "\"password\"")
+ @Column(name = "password")
private String password;
@Column(name = "nickname")
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogDao.java
similarity index 81%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogDao.java
index 7564a4e..a12f51a 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/AuditLogDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,10 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.AuditLogPO;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface AuditLogRepository extends JpaRepository<AuditLogPO, Long> {}
+public interface AuditLogDao extends BaseDao<AuditLogPO> {}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/BaseDao.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/BaseDao.java
new file mode 100644
index 0000000..ff8b969
--- /dev/null
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/BaseDao.java
@@ -0,0 +1,80 @@
+/*
+ * 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.sql.BaseSqlProvider;
+
+import org.apache.ibatis.annotations.DeleteProvider;
+import org.apache.ibatis.annotations.InsertProvider;
+import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.apache.ibatis.annotations.UpdateProvider;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+
+public interface BaseDao<Entity> {
+
+ /**
+ * Insert the entity.
+ */
+ @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
+ @InsertProvider(type = BaseSqlProvider.class, method = "insert")
+ int save(Entity entity);
+
+ /**
+ * Update the entity by primary key.
+ */
+ @UpdateProvider(type = BaseSqlProvider.class, method = "updateById")
+ int updateById(Entity entity);
+
+ /**
+ * Query the entity by primary key.
+ */
+ @SelectProvider(type = BaseSqlProvider.class, method = "selectById")
+ Entity findById(Serializable id);
+
+ /**
+ * Query the entity by primary key.
+ */
+ default Optional<Entity> findOptionalById(Serializable id) {
+ return Optional.ofNullable(findById(id));
+ }
+
+ /**
+ * Query the entity by primary key.
+ */
+ @SelectProvider(type = BaseSqlProvider.class, method = "selectByIds")
+ List<Entity> findByIds(Collection<? extends Serializable> ids);
+
+ /**
+ * Query all entities.
+ */
+ @SelectProvider(type = BaseSqlProvider.class, method = "selectAll")
+ List<Entity> findAll();
+
+ @DeleteProvider(type = BaseSqlProvider.class, method = "deleteById")
+ boolean deleteById(Serializable id);
+
+ @DeleteProvider(type = BaseSqlProvider.class, method = "deleteByIds")
+ boolean deleteByIds(Collection<? extends Serializable> ids);
+}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterDao.java
similarity index 70%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterDao.java
index fceb8bf..de2ec32 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ClusterDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,15 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
+import java.util.List;
import java.util.Optional;
-public interface ClusterRepository extends JpaRepository<ClusterPO, Long> {
+public interface ClusterDao extends BaseDao<ClusterPO> {
+
+ Optional<ClusterPO> findByClusterName(@Param("clusterName") String clusterName);
+
+ Integer count();
+
+ ClusterPO findByIdJoin(@Param("clusterId") Long clusterId);
- Optional<ClusterPO> findByClusterName(String clusterName);
+ List<ClusterPO> findAllByJoin();
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentDao.java
similarity index 58%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentDao.java
index 074f5b6..70d0570 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ComponentDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,21 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.ComponentPO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
-public interface ComponentRepository extends JpaRepository<ComponentPO, Long> {
+public interface ComponentDao extends BaseDao<ComponentPO> {
+
+ ComponentPO findByClusterIdAndComponentName(
+ @Param("clusterId") Long clusterId, @Param("componentName") String componentName);
- ComponentPO findByClusterPOIdAndComponentName(Long clusterId, String componentName);
+ ComponentPO findByIdJoin(@Param("id") Long id);
- List<ComponentPO> findAllByClusterPOIdAndComponentNameIn(Long clusterId, List<String> componentNames);
+ List<ComponentPO> findAllByClusterId(@Param("clusterId") Long clusterId);
- List<ComponentPO> findAllByClusterPOId(Long clusterId);
+ List<ComponentPO> findAllJoinService();
- List<ComponentPO> findAllByClusterPOIdAndServicePOServiceNameIn(Long clusterId, List<String> serviceNames);
+ List<ComponentPO> findAllByClusterIdAndServiceServiceNameIn(
+ @Param("clusterId") Long clusterId, @Param("serviceNames") List<String> serviceNames);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentDao.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentDao.java
new file mode 100644
index 0000000..d298875
--- /dev/null
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentDao.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.bigtop.manager.dao.repository;
+
+import org.apache.bigtop.manager.dao.po.HostComponentPO;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface HostComponentDao extends BaseDao<HostComponentPO> {
+
+ List<HostComponentPO> findAllJoin();
+
+ List<HostComponentPO> findAllByClusterIdAndComponentName(
+ @Param("clusterId") Long clusterId, @Param("componentName") String componentName);
+
+ HostComponentPO findByClusterIdAndComponentNameAndHostname(
+ @Param("clusterId") Long clusterId,
+ @Param("componentName") String componentName,
+ @Param("hostname") String hostname);
+
+ List<HostComponentPO> findAllByClusterIdAndComponentNameAndHostnameIn(
+ @Param("clusterId") Long clusterId,
+ @Param("componentName") String componentName,
+ @Param("hostnames") List<String> hostnames);
+
+ List<HostComponentPO> findAllByClusterId(@Param("clusterId") Long clusterId);
+
+ List<HostComponentPO> findAllByClusterIdAndHostId(@Param("clusterId") Long clusterId, @Param("hostId") Long hostId);
+
+ List<HostComponentPO> findAllByClusterIdAndServiceId(
+ @Param("clusterId") Long clusterId, @Param("serviceId") Long serviceId);
+}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentRepository.java
deleted file mode 100644
index 4b67725..0000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostComponentRepository.java
+++ /dev/null
@@ -1,47 +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.dao.repository;
-
-import org.apache.bigtop.manager.dao.po.HostComponentPO;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.util.List;
-
-public interface HostComponentRepository extends JpaRepository<HostComponentPO, Long> {
-
- List<HostComponentPO> findAllByComponentPOClusterPOIdAndComponentPOComponentName(
- Long clusterId, String componentName);
-
- HostComponentPO findByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostname(
- Long clusterId, String componentName, String hostnames);
-
- List<HostComponentPO> findAllByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostnameIn(
- Long clusterId, String componentName, List<String> hostnames);
-
- List<HostComponentPO> findAllByComponentPOClusterPOId(Long clusterId);
-
- HostComponentPO findByComponentPOComponentNameAndHostPOHostname(String componentName, String hostName);
-
- List<HostComponentPO> findAllByComponentPOClusterPOIdAndHostPOId(Long clusterId, Long componentId);
-
- List<HostComponentPO> findAllByComponentPOClusterPOIdAndComponentPOServicePOId(Long clusterId, Long serviceId);
-
- List<HostComponentPO> findAllByComponentPOServicePOId(Long serviceId);
-}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostDao.java
similarity index 60%
copy from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java
copy to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostDao.java
index 7aafcf3..335a5e5 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,21 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
-import org.apache.bigtop.manager.dao.po.JobPO;
+import org.apache.bigtop.manager.dao.po.HostPO;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
+import java.util.Collection;
import java.util.List;
-public interface JobRepository extends JpaRepository<JobPO, Long> {
+public interface HostDao extends BaseDao<HostPO> {
+
+ int saveAll(@Param("hosts") List<HostPO> hosts);
+
+ HostPO findByHostname(@Param("hostname") String hostname);
- Page<JobPO> findAllByClusterPOIsNull(Pageable pageable);
+ List<HostPO> findAllByHostnameIn(@Param("hostnames") Collection<String> hostnames);
- Page<JobPO> findAllByClusterPOId(Long clusterId, Pageable pageable);
+ List<HostPO> findAllByClusterId(@Param("clusterId") Long clusterId);
- List<JobPO> findAllByClusterPOId(Long clusterId);
+ HostPO findByIdJoin(@Param("id") Long id);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostRepository.java
deleted file mode 100644
index 49db05e..0000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/HostRepository.java
+++ /dev/null
@@ -1,43 +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.dao.repository;
-
-import org.apache.bigtop.manager.dao.po.HostPO;
-
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.util.Collection;
-import java.util.List;
-
-public interface HostRepository extends JpaRepository<HostPO, Long> {
-
- HostPO findByHostname(String hostname);
-
- List<HostPO> findAllByHostnameIn(Collection<String> hostnames);
-
- List<HostPO> findAllByClusterPOIdAndHostnameIn(Long clusterId, Collection<String> hostnames);
-
- List<HostPO> findAllByClusterPOId(Long clusterId);
-
- Page<HostPO> findAllByClusterPOId(Long clusterId, Pageable pageable);
-
- List<HostPO> findAllByClusterPOClusterName(String clusterName);
-}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobDao.java
similarity index 72%
copy from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java
copy to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobDao.java
index d37128e..82efe16 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,16 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.JobPO;
-import org.apache.bigtop.manager.dao.po.StagePO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Optional;
+
+public interface JobDao extends BaseDao<JobPO> {
+
+ List<JobPO> findAllByClusterId(@Param("clusterId") Long clusterId);
-public interface StageRepository extends JpaRepository<StagePO, Long> {
+ Optional<JobPO> findByIdJoin(@Param("id") Long id);
- List<StagePO> findByJobPO(JobPO jobPO);
+ List<JobPO> findAllByClusterIsNull();
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoDao.java
similarity index 70%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoDao.java
index 39d629f..c951dfb 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/RepoDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,16 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
-import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.RepoPO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Optional;
+
+public interface RepoDao extends BaseDao<RepoPO> {
+
+ Optional<RepoPO> findByRepoName(@Param("repoName") String clusterName);
-public interface RepoRepository extends JpaRepository<RepoPO, Long> {
+ int saveAll(@Param("clusters") List<RepoPO> repos);
- List<RepoPO> findAllByClusterPO(ClusterPO clusterPO);
+ List<RepoPO> findAllByClusterId(@Param("clusterId") Long clusterId);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigDao.java
similarity index 60%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigDao.java
index 7aafcf3..ddfd24c 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/JobRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,21 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
-import org.apache.bigtop.manager.dao.po.JobPO;
+import org.apache.bigtop.manager.dao.po.ServiceConfigPO;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
-public interface JobRepository extends JpaRepository<JobPO, Long> {
+public interface ServiceConfigDao extends BaseDao<ServiceConfigPO> {
- Page<JobPO> findAllByClusterPOIsNull(Pageable pageable);
+ List<ServiceConfigPO> findAllByClusterId(@Param("clusterId") Long clusterId);
- Page<JobPO> findAllByClusterPOId(Long clusterId, Pageable pageable);
+ ServiceConfigPO findByClusterIdAndServiceIdAndSelectedIsTrue(
+ @Param("clusterId") Long clusterId, @Param("serviceId") Long serviceId);
- List<JobPO> findAllByClusterPOId(Long clusterId);
+ List<ServiceConfigPO> findAllByClusterIdAndSelectedIsTrue(@Param("clusterId") Long clusterId);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigRepository.java
deleted file mode 100644
index 12ff2e4..0000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceConfigRepository.java
+++ /dev/null
@@ -1,49 +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.dao.repository;
-
-import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.po.ServiceConfigPO;
-import org.apache.bigtop.manager.dao.po.ServicePO;
-
-import org.springframework.data.domain.Sort;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-public interface ServiceConfigRepository extends JpaRepository<ServiceConfigPO, Long> {
-
- List<ServiceConfigPO> findAllByClusterPO(ClusterPO clusterPO);
-
- List<ServiceConfigPO> findAllByClusterPO(ClusterPO clusterPO, Sort sort);
-
- List<ServiceConfigPO> findAllByClusterPOAndServicePO(ClusterPO clusterPO, ServicePO servicePO);
-
- ServiceConfigPO findByClusterPOAndServicePOAndSelectedIsTrue(ClusterPO clusterPO, ServicePO servicePO);
-
- List<ServiceConfigPO> findAllByClusterPOAndSelectedIsTrue(ClusterPO clusterPO);
-
- @Transactional
- @Modifying
- @Query("UPDATE ServiceConfigPO s SET s.selected = false WHERE s.clusterPO = :cluster AND s.servicePO = :service")
- void setAllSelectedToFalseByClusterAndService(ClusterPO clusterPO, ServicePO servicePO);
-}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceDao.java
similarity index 59%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceDao.java
index f84df78..57d2980 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,23 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.ServicePO;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Optional;
-public interface ServiceRepository extends JpaRepository<ServicePO, Long> {
+public interface ServiceDao extends BaseDao<ServicePO> {
- List<ServicePO> findAllByClusterPOId(Long clusterId);
+ List<ServicePO> findAllByClusterId(@Param("clusterId") Long clusterId);
- Page<ServicePO> findAllByClusterPOId(Long clusterId, Pageable pageable);
+ Optional<ServicePO> findByIdJoin(@Param("id") Long id);
- ServicePO findByClusterPOIdAndServiceName(Long clusterId, String serviceName);
+ ServicePO findByClusterIdAndServiceName(
+ @Param("clusterId") Long clusterId, @Param("serviceName") String serviceName);
- List<ServicePO> findByClusterPOIdAndServiceNameIn(Long clusterId, List<String> serviceNames);
+ List<ServicePO> findByClusterIdAndServiceNameIn(
+ @Param("clusterId") Long clusterId, @Param("serviceNames") List<String> serviceNames);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java
similarity index 82%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java
index 67cfbd6..c719b76 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/SettingDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,10 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.SettingPO;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface SettingRepository extends JpaRepository<SettingPO, Long> {}
+public interface SettingDao extends BaseDao<SettingPO> {}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackDao.java
similarity index 75%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackDao.java
index 797e2d5..8523d2b 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StackDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,13 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.StackPO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
-public interface StackRepository extends JpaRepository<StackPO, Long> {
+public interface StackDao extends BaseDao<StackPO> {
- StackPO findByStackNameAndStackVersion(String stackName, String stackVersion);
+ StackPO findByStackNameAndStackVersion(
+ @Param("stackName") String stackName, @Param("stackVersion") String stackVersion);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageDao.java
similarity index 76%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageDao.java
index d37128e..993c57d 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/StageDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,16 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
-import org.apache.bigtop.manager.dao.po.JobPO;
import org.apache.bigtop.manager.dao.po.StagePO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
-public interface StageRepository extends JpaRepository<StagePO, Long> {
+public interface StageDao extends BaseDao<StagePO> {
+
+ List<StagePO> findByJobId(@Param("jobId") Long jobId);
- List<StagePO> findByJobPO(JobPO jobPO);
+ void updateStateByIds(@Param("stages") List<StagePO> stages);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskDao.java
similarity index 74%
copy from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java
copy to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskDao.java
index ee55af2..7f74e53 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,13 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
-import org.apache.bigtop.manager.dao.po.UserPO;
+import org.apache.bigtop.manager.dao.po.TaskPO;
+
+import org.apache.ibatis.annotations.Param;
-import org.springframework.data.jpa.repository.JpaRepository;
+import java.util.List;
-public interface UserRepository extends JpaRepository<UserPO, Long> {
+public interface TaskDao extends BaseDao<TaskPO> {
- UserPO findByUsername(String username);
+ void updateStateByIds(@Param("tasks") List<TaskPO> tasks);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskRepository.java
deleted file mode 100644
index 045ee6d..0000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TaskRepository.java
+++ /dev/null
@@ -1,38 +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.dao.repository;
-
-import org.apache.bigtop.manager.common.enums.JobState;
-import org.apache.bigtop.manager.dao.po.StagePO;
-import org.apache.bigtop.manager.dao.po.TaskPO;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.util.List;
-
-public interface TaskRepository extends JpaRepository<TaskPO, Long> {
-
- List<TaskPO> findByStagePO(StagePO stagePO);
-
- List<TaskPO> findAllByJobPOId(Long jobId);
-
- List<TaskPO> findAllByJobPOIdAndState(Long jobId, JobState state);
-
- List<TaskPO> findAllByJobPOIdAndHostnameAndState(Long jobId, String hostname, JobState state);
-}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigDao.java
similarity index 81%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigDao.java
index ea03ead..0dd4b47 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/TypeConfigDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,10 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.TypeConfigPO;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface TypeConfigRepository extends JpaRepository<TypeConfigPO, Long> {}
+public interface TypeConfigDao extends BaseDao<TypeConfigPO> {}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserDao.java
similarity index 79%
rename from bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserDao.java
index ee55af2..e1cfeeb 100644
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserRepository.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/UserDao.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,13 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bigtop.manager.dao.repository;
import org.apache.bigtop.manager.dao.po.UserPO;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.apache.ibatis.annotations.Param;
-public interface UserRepository extends JpaRepository<UserPO, Long> {
+public interface UserDao extends BaseDao<UserPO> {
- UserPO findByUsername(String username);
+ UserPO findByUsername(@Param("username") String username);
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/BaseSqlProvider.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/BaseSqlProvider.java
new file mode 100644
index 0000000..52966b4
--- /dev/null
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/BaseSqlProvider.java
@@ -0,0 +1,115 @@
+/*
+ * 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.sql;
+
+import org.apache.bigtop.manager.dao.repository.BaseDao;
+
+import org.apache.ibatis.builder.annotation.ProviderContext;
+
+import org.springframework.core.ResolvableType;
+import org.springframework.util.Assert;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import java.util.Collection;
+
+@Slf4j
+public class BaseSqlProvider {
+
+ public <Entity> String insert(Entity entity, ProviderContext context) {
+ Assert.notNull(entity, "entity must not null");
+
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = entity.getClass();
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.insert(tableMetaData, entity, databaseId);
+ }
+
+ public <Entity> String updateById(Entity entity, ProviderContext context) {
+ Assert.notNull(entity, "entity must not null");
+
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = entity.getClass();
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.update(tableMetaData, entity, databaseId);
+ }
+
+ public String selectById(Serializable id, ProviderContext context) {
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = getEntityClass(context);
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.selectById(tableMetaData, databaseId, id);
+ }
+
+ public String selectByIds(Collection<? extends Serializable> ids, ProviderContext context) {
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = getEntityClass(context);
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.selectByIds(tableMetaData, databaseId, ids);
+ }
+
+ public String selectAll(ProviderContext context) {
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = getEntityClass(context);
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.selectAll(tableMetaData, databaseId);
+ }
+
+ public String deleteById(Serializable id, ProviderContext context) {
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = getEntityClass(context);
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.deleteById(tableMetaData, databaseId, id);
+ }
+
+ public String deleteByIds(Collection<? extends Serializable> ids, ProviderContext context) {
+ String databaseId = context.getDatabaseId();
+
+ Class<?> entityClass = getEntityClass(context);
+ TableMetaData tableMetaData = TableMetaData.forClass(entityClass);
+
+ return SQLBuilder.deleteByIds(tableMetaData, databaseId, ids);
+ }
+
+ private Class<?> getEntityClass(ProviderContext context) {
+ Class<?> mapperType = context.getMapperType();
+ for (Type parent : mapperType.getGenericInterfaces()) {
+ ResolvableType parentType = ResolvableType.forType(parent);
+ if (parentType.getRawClass() == BaseDao.class) {
+ return parentType.getGeneric(0).getRawClass();
+ }
+ }
+ return null;
+ }
+}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/JpaAuditConfig.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/DBType.java
similarity index 52%
rename from bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/JpaAuditConfig.java
rename to bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/DBType.java
index 6bba2ad..c280c95 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/JpaAuditConfig.java
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/DBType.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,26 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.bigtop.manager.server.config;
-import org.apache.bigtop.manager.server.holder.SessionUserHolder;
+package org.apache.bigtop.manager.dao.sql;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.domain.AuditorAware;
+import java.util.stream.Stream;
-import jakarta.annotation.Nonnull;
-import java.util.Optional;
+public enum DBType {
+ MYSQL("mysql", "MYSQL"),
+ DM("dm", "DaMeng");
-@Configuration
-public class JpaAuditConfig implements AuditorAware<Long> {
+ DBType(String code, String desc) {
+ this.code = code;
+ this.desc = desc;
+ }
+
+ private final String code;
+ private final String desc;
+
+ public String getCode() {
+ return this.code;
+ }
+
+ public String getDesc() {
+ return this.desc;
+ }
- @Nonnull
- @Override
- public Optional<Long> getCurrentAuditor() {
- try {
- return Optional.of(SessionUserHolder.getUserId());
- } catch (Exception e) {
- return Optional.empty();
- }
+ public static DBType toType(String databaseId) {
+ return Stream.of(DBType.values())
+ .filter(p -> p.getCode().equals(databaseId))
+ .findFirst()
+ .orElse(null);
}
}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/SQLBuilder.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/SQLBuilder.java
new file mode 100644
index 0000000..2f3b120
--- /dev/null
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/SQLBuilder.java
@@ -0,0 +1,205 @@
+/*
+ * 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.sql;
+
+import org.apache.ibatis.jdbc.SQL;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.ReflectionUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.beans.PropertyDescriptor;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * Multiple data source support
+ */
+@Slf4j
+public class SQLBuilder {
+
+ public static <Entity> String insert(TableMetaData tableMetaData, Entity entity, String databaseId) {
+ Class<?> entityClass = entity.getClass();
+ Map<String, String> fieldColumnMap = tableMetaData.getFieldColumnMap();
+
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ sql.INSERT_INTO(tableMetaData.getTableName());
+ for (Map.Entry<String, String> entry : fieldColumnMap.entrySet()) {
+ // Ignore primary key
+ if (Objects.equals(entry.getKey(), tableMetaData.getPkProperty())) {
+ continue;
+ }
+ PropertyDescriptor ps = BeanUtils.getPropertyDescriptor(entityClass, entry.getKey());
+ if (ps == null || ps.getReadMethod() == null) {
+ continue;
+ }
+ Object value = ReflectionUtils.invokeMethod(ps.getReadMethod(), entity);
+ if (!ObjectUtils.isEmpty(value)) {
+ sql.VALUES("`" + entry.getValue() + "`", getTokenParam(entry.getKey()));
+ }
+ }
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static <Entity> String update(TableMetaData tableMetaData, Entity entity, String databaseId) {
+ Class<?> entityClass = entity.getClass();
+ Map<String, String> fieldColumnMap = tableMetaData.getFieldColumnMap();
+
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ sql.UPDATE(tableMetaData.getTableName());
+ for (Map.Entry<String, String> entry : fieldColumnMap.entrySet()) {
+ // Ignore primary key
+ if (Objects.equals(entry.getKey(), tableMetaData.getPkProperty())) {
+ continue;
+ }
+ PropertyDescriptor ps = BeanUtils.getPropertyDescriptor(entityClass, entry.getKey());
+ if (ps == null || ps.getReadMethod() == null) {
+ continue;
+ }
+ Object value = ReflectionUtils.invokeMethod(ps.getReadMethod(), entity);
+ if (!ObjectUtils.isEmpty(value)) {
+ sql.SET("`" + getEquals(entry.getValue() + "`", entry.getKey()));
+ }
+ }
+
+ sql.WHERE(getEquals(tableMetaData.getPkColumn(), tableMetaData.getPkProperty()));
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static String selectById(TableMetaData tableMetaData, String databaseId, Serializable id) {
+
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ sql.SELECT(tableMetaData.getBaseColumns());
+ sql.FROM(tableMetaData.getTableName());
+ sql.WHERE(tableMetaData.getPkColumn() + " = '" + id + "'");
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static String selectByIds(
+ TableMetaData tableMetaData, String databaseId, Collection<? extends Serializable> ids) {
+
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ String idsStr = ids.stream().map(String::valueOf).collect(Collectors.joining("', '"));
+ sql.SELECT(tableMetaData.getBaseColumns());
+ sql.FROM(tableMetaData.getTableName());
+ sql.WHERE(tableMetaData.getPkColumn() + " in ('" + idsStr + "')");
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static String selectAll(TableMetaData tableMetaData, String databaseId) {
+
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ sql.SELECT(tableMetaData.getBaseColumns());
+ sql.FROM(tableMetaData.getTableName());
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static String deleteById(TableMetaData tableMetaData, String databaseId, Serializable id) {
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ sql.DELETE_FROM(tableMetaData.getTableName());
+ sql.WHERE(tableMetaData.getPkColumn() + " = '" + id + "'");
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ public static String deleteByIds(
+ TableMetaData tableMetaData, String databaseId, Collection<? extends Serializable> ids) {
+ SQL sql = new SQL();
+ switch (DBType.toType(databaseId)) {
+ case MYSQL: {
+ String idsStr = ids.stream().map(String::valueOf).collect(Collectors.joining("', '"));
+ sql.DELETE_FROM(tableMetaData.getTableName());
+ sql.WHERE(tableMetaData.getPkColumn() + " in ('" + idsStr + "')");
+ break;
+ }
+ default: {
+ log.error("Unsupported data source");
+ }
+ }
+
+ return sql.toString();
+ }
+
+ private static String getEquals(String column, String property) {
+ return column + " = " + getTokenParam(property);
+ }
+
+ private static String getTokenParam(String property) {
+ return "#{" + property + "}";
+ }
+}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/TableMetaData.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/TableMetaData.java
new file mode 100644
index 0000000..a464a81
--- /dev/null
+++ b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/sql/TableMetaData.java
@@ -0,0 +1,135 @@
+/*
+ * 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.sql;
+
+import org.apache.bigtop.manager.common.utils.CaseUtils;
+import org.apache.bigtop.manager.common.utils.ClassUtils;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+
+import lombok.Getter;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import jakarta.persistence.Transient;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Getter
+public class TableMetaData {
+
+ private static final Map<Class<?>, TableMetaData> TABLE_CACHE = new ConcurrentHashMap<>(64);
+
+ /**
+ * tableName
+ */
+ private String tableName;
+
+ /**
+ * primaryField
+ */
+ private String pkProperty;
+
+ /**
+ * primaryKey
+ */
+ private String pkColumn;
+
+ /**
+ * {entityField,column}
+ */
+ private final Map<String, String> fieldColumnMap = new HashMap<>();
+
+ /**
+ * {column,columnType}
+ */
+ private final Map<String, Class<?>> fieldTypeMap = new HashMap<>();
+
+ private TableMetaData(Class<?> clazz) {
+ initTableInfo(clazz);
+ }
+
+ public static TableMetaData forClass(Class<?> entityClass) {
+ TableMetaData tableMetaData = TABLE_CACHE.get(entityClass);
+ if (tableMetaData == null) {
+ tableMetaData = new TableMetaData(entityClass);
+ TABLE_CACHE.put(entityClass, tableMetaData);
+ }
+
+ return tableMetaData;
+ }
+
+ public String getBaseColumns() {
+ Collection<String> columns = fieldColumnMap.values();
+ if (CollectionUtils.isEmpty(columns)) {
+ return "";
+ }
+ Iterator<String> iterator = columns.iterator();
+ StringBuilder sb = new StringBuilder();
+ while (iterator.hasNext()) {
+ String next = iterator.next();
+ sb.append(tableName).append(".").append(next);
+ if (iterator.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ return sb.toString();
+ }
+
+ private void initTableInfo(Class<?> clazz) {
+ tableName = clazz.isAnnotationPresent(Table.class)
+ ? clazz.getAnnotation(Table.class).name()
+ : CaseUtils.toUnderScoreCase(clazz.getSimpleName());
+
+ // 获取父类字段
+ List<Field> fields = ClassUtils.getFields(clazz);
+ for (Field field : fields) {
+
+ if (Modifier.isStatic(field.getModifiers())
+ || field.isAnnotationPresent(Transient.class)
+ || !BeanUtils.isSimpleValueType(field.getType())) {
+ continue;
+ }
+
+ String property = field.getName();
+ Column column = field.getAnnotation(Column.class);
+ String columnName = column != null ? column.name() : CaseUtils.toUnderScoreCase(property);
+
+ if (field.isAnnotationPresent(Id.class) || (property.equalsIgnoreCase("id") && pkProperty == null)) {
+ pkProperty = property;
+ pkColumn = columnName;
+ }
+ PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(clazz, property);
+ if (descriptor != null && descriptor.getReadMethod() != null && descriptor.getWriteMethod() != null) {
+ fieldColumnMap.put(property, columnName);
+ fieldTypeMap.put(property, field.getType());
+ }
+ }
+ }
+}
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/ClusterMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/ClusterMapper.xml
new file mode 100644
index 0000000..75caa42
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/ClusterMapper.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.ClusterDao">
+
+ <sql id="baseColumns">
+ id, cluster_name, cluster_type, root, user_group, packages, repo_template, state, selected, stack_id
+ </sql>
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.cluster_name, ${alias}.cluster_type, ${alias}.root, ${alias}.user_group, ${alias}.packages, ${alias}.repo_template, ${alias}.state, ${alias}.selected, ${alias}.stack_id
+ </sql>
+
+ <select id="findByClusterName" resultType="org.apache.bigtop.manager.dao.po.ClusterPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ cluster
+ <where>
+ <if test="clusterName!=null">
+ cluster_name=#{clusterName}
+ </if>
+ </where>
+ limit 1
+ </select>
+
+ <select id="count" resultType="java.lang.Integer">
+ select count(*) from cluster
+ </select>
+
+ <select id="findByIdJoin"
+ resultType="org.apache.bigtop.manager.dao.po.ClusterPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.stack_name, s.stack_version
+ from
+ cluster r
+ inner join stack s
+ on r.stack_id = s.id
+ <where>
+ <if test="clusterId!=0">
+ r.id=#{clusterId}
+ </if>
+ </where>
+ </select>
+
+ <select id="findAllByJoin"
+ resultType="org.apache.bigtop.manager.dao.po.ClusterPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.stack_name, s.stack_version
+ from
+ cluster r
+ inner join stack s
+ on r.stack_id = s.id
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml
new file mode 100644
index 0000000..cc1c93d
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/ComponentMapper.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.ComponentDao">
+
+ <sql id="baseColumns">
+ id, component_name, display_name, command_script, custom_commands, category, quick_link, cardinality, service_id, cluster_id
+ </sql>
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.component_name, ${alias}.display_name, ${alias}.command_script, ${alias}.custom_commands, ${alias}.category, ${alias}.quick_link, ${alias}.cardinality, ${alias}.service_id, ${alias}.cluster_id
+ </sql>
+
+ <select id="findByClusterIdAndComponentName"
+ resultType="org.apache.bigtop.manager.dao.po.ComponentPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ component
+ <where>
+ <if test="componentName != null">
+ component_name = #{componentName}
+ </if>
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ </where>
+ </select>
+
+ <select id="findAllByClusterId"
+ resultType="org.apache.bigtop.manager.dao.po.ComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ ,c.cluster_name, s.service_name
+ from
+ component r
+ inner join cluster c
+ on r.cluster_id = c.id
+ inner join service s
+ on r.service_id = s.id
+ <where>
+ <if test="clusterId != 0">
+ r.cluster_id = #{clusterId}
+ </if>
+ </where>
+ </select>
+
+ <select id="findAllByClusterIdAndServiceServiceNameIn"
+ resultType="org.apache.bigtop.manager.dao.po.ComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ from
+ (select * from component
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) r
+ inner join (select * from service
+ <where>
+ <if test="serviceNames != null">
+ service_name in
+ <foreach collection="serviceNames" item="serviceName" index="index" open="(" close=")" separator=",">
+ #{serviceName}
+ </foreach>
+ </if>
+ </where>
+ ) s
+ on r.service_id = s.id and r.cluster_id = s.cluster_id
+ </select>
+
+ <select id="findAllJoinService"
+ resultType="org.apache.bigtop.manager.dao.po.ComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.service_name
+ from
+ component r
+ inner join service s
+ on r.service_id = s.id and r.cluster_id = s.cluster_id
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/HostComponentMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/HostComponentMapper.xml
new file mode 100644
index 0000000..5106000
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/HostComponentMapper.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.HostComponentDao">
+
+ <sql id="baseColumns">
+ id, state, host_id, component_id
+ </sql>
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.state, ${alias}.host_id, ${alias}.component_id
+ </sql>
+
+ <select id="findAllByClusterIdAndComponentName"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ from
+ host_component hc
+ inner join (select * from component
+ <where>
+ <if test="componentName != null">
+ component_name = #{componentName}
+ </if>
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) c
+ on hc.component_id = c.id
+ </select>
+
+ <select id="findAllByClusterIdAndServiceId"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ , c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
+ from
+ host_component hc
+ inner join (select * from component
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ <if test="serviceId != 0">
+ and service_id = #{serviceId}
+ </if>
+ </where>
+ ) c
+ on hc.component_id = c.id
+ inner join service s
+ on c.service_id = s.id
+ inner join cluster clus
+ on c.cluster_id = clus.id
+ inner join host ht
+ on hc.host_id = ht.id
+ </select>
+
+ <select id="findByClusterIdAndComponentNameAndHostname"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ from
+ host_component hc
+ inner join (select * from host
+ <where>
+ <if test="hostname != null">
+ hostname = #{hostname}
+ </if>
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) h
+ on hc.host_id = h.id
+ inner join (select * from component
+ <where>
+ <if test="componentName != null">
+ component_name = #{componentName}
+ </if>
+ </where>
+ ) c
+ on hc.component_id = c.id and h.cluster_id = c.cluster_id
+ limit 1
+ </select>
+
+ <select id="findAllByClusterIdAndComponentNameAndHostnameIn"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ , c.component_name
+ from
+ host_component hc
+ inner join (select * from host
+ <where>
+ <if test="hostnames != null">
+ hostname in
+ <foreach collection="hostnames" item="hostname" index="index" open="(" close=")" separator=",">
+ #{hostname}
+ </foreach>
+ </if>
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) h
+ on hc.host_id = h.id
+ inner join (select * from component
+ <where>
+ <if test="componentName != 0">
+ component_name = #{componentName}
+ </if>
+ </where>
+ ) c
+ on hc.component_id = c.id and h.cluster_id = c.cluster_id
+ </select>
+
+ <select id="findAllByClusterIdAndHostId"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ , c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
+ from
+ host_component hc
+ inner join component c
+ on hc.component_id = c.id
+ inner join service s
+ on c.service_id = s.id
+ inner join cluster clus
+ on c.cluster_id = clus.id
+ inner join (select * from host
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ <if test="hostId != 0">
+ and id = #{hostId}
+ </if>
+ </where>
+ ) ht
+ on hc.host_id = ht.id
+ </select>
+
+ <select id="findAllByClusterId"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ , c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
+ from
+ host_component hc
+ inner join (select * from component
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) c
+ on hc.component_id = c.id
+ inner join service s
+ on c.service_id = s.id
+ inner join cluster clus
+ on c.cluster_id = clus.id
+ inner join host ht
+ on hc.host_id = ht.id
+ </select>
+
+ <select id="findAllJoin"
+ resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="hc"/>
+ </include>
+ ,st.stack_name,st.stack_version,ser.service_name,ser.service_user,clu.root,c.component_name,c.command_script,hst.hostname
+ from
+ host_component hc
+ inner join host hst
+ on hc.host_id = hst.id
+ inner join
+ component c
+ on hc.component_id = c.id
+ inner join
+ cluster clu
+ on c.cluster_id = clu.id
+ inner join
+ service ser
+ on c.service_id=ser.id and c.cluster_id = ser.cluster_id
+ inner join stack st
+ on clu.stack_id = st.id
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/HostMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/HostMapper.xml
new file mode 100644
index 0000000..a1143a3
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/HostMapper.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.HostDao">
+
+ <sql id="baseColumns">
+ id, hostname, ipv4, ipv6, os, arch, available_processors, free_memory_size, total_memory_size, free_disk, total_disk, state, cluster_id
+ </sql>
+
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.hostname, ${alias}.ipv4, ${alias}.ipv6, ${alias}.os, ${alias}.arch, ${alias}.available_processors, ${alias}.free_memory_size, ${alias}.total_memory_size, ${alias}.free_disk, ${alias}.total_disk, ${alias}.state, ${alias}.cluster_id
+ </sql>
+
+ <select id="findByHostname" resultType="org.apache.bigtop.manager.dao.po.HostPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ host
+ <where>
+ <if test="hostname != null">
+ hostname = #{hostname}
+ </if>
+ </where>
+ limit 1
+ </select>
+
+ <select id="findByIdJoin" resultType="org.apache.bigtop.manager.dao.po.HostPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="h"/>
+ </include>
+ ,clus.cluster_name
+ from
+ (select * from host
+ <where>
+ <if test="id != 0">
+ id = #{id}
+ </if>
+ </where>
+ ) h
+ inner join
+ cluster clus
+ on h.cluster_id = clus.id
+ limit 1
+ </select>
+
+ <select id="findAllByClusterId" parameterType="java.lang.Long"
+ resultType="org.apache.bigtop.manager.dao.po.HostPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="h"/>
+ </include>
+ ,clus.cluster_name
+ from
+ host h
+ inner join
+ (select * from cluster
+ <where>
+ <if test="clusterId != 0">
+ id = #{clusterId}
+ </if>
+ </where>
+ ) clus
+ on h.cluster_id = clus.id
+ </select>
+
+ <select id="findAllByHostnameIn"
+ resultType="org.apache.bigtop.manager.dao.po.HostPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ host
+ <where>
+ <if test="hostnames != null and hostnames.size() > 0">
+ hostname in
+ <foreach collection="hostnames" item="hostname" index="index" open="(" close=")" separator=", ">
+ #{hostname}
+ </foreach>
+ </if>
+ </where>
+ </select>
+
+ <insert id="saveAll">
+ insert into host (hostname, ipv4, ipv6, os, arch, available_processors, free_memory_size, total_memory_size, free_disk, total_disk, state, cluster_id)
+ values
+ <foreach collection='hosts' item='host' separator=','>
+ (#{host.hostname}, #{host.ipv4}, #{host.ipv6}, #{host.os}, #{host.arch}, #{host.availableProcessors}, #{host.freeMemorySize}, #{host.totalMemorySize}, #{host.freeDisk}, #{host.totalDisk}, #{host.state}, #{host.clusterId})
+ </foreach>
+ </insert>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/JobMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/JobMapper.xml
new file mode 100644
index 0000000..6efb75b
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/JobMapper.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.JobDao">
+
+ <sql id="baseColumns">
+ id, state, name, context, cluster_id, create_time, update_time
+ </sql>
+
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.state, ${alias}.name, ${alias}.context, ${alias}.cluster_id, ${alias}.create_time, ${alias}.update_time
+ </sql>
+
+ <resultMap id="jobMap" type="org.apache.bigtop.manager.dao.po.JobPO">
+ <id column="id" property="id"/>
+ <result column="state" property="state"/>
+ <result column="name" property="name"/>
+ <result column="context" property="context"/>
+ <result column="cluster_id" property="clusterId"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_time" property="updateTime"/>
+ <collection property="stages" ofType="org.apache.bigtop.manager.dao.po.StagePO">
+ <id column="s_id" property="id"/>
+ <result column="s_state" property="state"/>
+ <result column="s_name" property="name"/>
+ <result column="order" property="order"/>
+ <result column="service_name" property="serviceName"/>
+ <result column="component_name" property="componentName"/>
+ <result column="cluster_id" property="clusterId"/>
+ <result column="job_id" property="jobId"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_time" property="updateTime"/>
+ <collection property="tasks" ofType="org.apache.bigtop.manager.dao.po.TaskPO">
+ <id column="t_id" property="id"/>
+ <result column="state" property="state"/>
+ <result column="t_name" property="name"/>
+ <result column="t_state" property="state"/>
+ <result column="service_name" property="serviceName"/>
+ <result column="component_name" property="componentName"/>
+ <result column="command" property="command"/>
+ <result column="custom_command" property="customCommand"/>
+ <result column="hostname" property="hostname"/>
+ <result column="stack_name" property="stackName"/>
+ <result column="stack_version" property="stackVersion"/>
+ <result column="service_user" property="serviceUser"/>
+ <result column="content" property="content"/>
+ <result column="stage_id" property="stageId"/>
+ <result column="job_id" property="jobId"/>
+ <result column="cluster_id" property="clusterId"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_time" property="updateTime"/>
+ </collection>
+ </collection>
+ </resultMap>
+
+ <select id="findAllByClusterId" parameterType="java.lang.Long" resultMap="jobMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="h"/>
+ </include>
+ , st.id as s_id, st.name as s_name, st.state as s_state, st.order
+ , tk.id as t_id, tk.name as t_name, tk.state as t_state, tk.hostname
+ from
+ (select * from job
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) h
+ inner join stage st
+ on h.id = st.job_id
+ inner join task tk
+ on tk.job_id = h.id and st.id = tk.stage_id
+ </select>
+
+ <select id="findByIdJoin" parameterType="java.lang.Long" resultMap="jobMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="h"/>
+ </include>
+ , st.id as s_id, st.name as s_name, st.state as s_state, st.order
+ , tk.id as t_id, tk.name as t_name, tk.state as t_state, tk.hostname
+ from
+ (select * from job
+ <where>
+ <if test="id != 0">
+ id = #{id}
+ </if>
+ </where>
+ ) h
+ inner join stage st
+ on h.id = st.job_id
+ inner join task tk
+ on tk.job_id = h.id and st.id = tk.stage_id
+ </select>
+
+ <select id="findAllByClusterIsNull"
+ resultType="org.apache.bigtop.manager.dao.po.JobPO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="h"/>
+ </include>
+ from
+ (select * from job where cluster_id is null) h
+ inner join stage st
+ on h.id = st.job_id
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/RepoMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/RepoMapper.xml
new file mode 100644
index 0000000..1382507
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/RepoMapper.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.RepoDao">
+
+ <sql id="baseColumns">
+ id, base_url, os, arch, repo_id, repo_name, cluster_id
+ </sql>
+
+ <select id="findByRepoName" resultType="org.apache.bigtop.manager.dao.po.RepoPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ repo
+ <where>
+ <if test="repoName!=null">
+ repo_name=#{repoName}
+ </if>
+ </where>
+ limit 1
+ </select>
+
+ <insert id="saveAll">
+ insert into repo (base_url, os, arch, repo_id, repo_name, cluster_id)
+ values
+ <foreach collection='clusters' item='cluster' separator=','>
+ (#{cluster.baseUrl},#{cluster.os},#{cluster.arch},#{cluster.repoId},#{cluster.repoName},#{cluster.clusterId})
+ </foreach>
+ </insert>
+
+ <select id="findAllByClusterId" parameterType="java.lang.Long"
+ resultType="org.apache.bigtop.manager.dao.po.RepoPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ repo
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceConfigMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceConfigMapper.xml
new file mode 100644
index 0000000..52a30d6
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceConfigMapper.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.ServiceConfigDao">
+
+ <sql id="baseColumns">
+ id, config_desc, version, selected, service_id, cluster_id, create_time, update_time
+ </sql>
+
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.config_desc, ${alias}.version, ${alias}.selected, ${alias}.service_id, ${alias}.cluster_id, ${alias}.create_time, ${alias}.update_time
+ </sql>
+
+ <resultMap id="serviceConfigMap" type="org.apache.bigtop.manager.dao.po.ServiceConfigPO">
+ <id column="id" property="id"/>
+ <result column="config_desc" property="configDesc"/>
+ <result column="version" property="version"/>
+ <result column="selected" property="selected"/>
+ <result column="service_id" property="serviceId"/>
+ <result column="cluster_id" property="clusterId"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_time" property="updateTime"/>
+ <result column="service_name" property="serviceName"/>
+ <collection property="configs" ofType="org.apache.bigtop.manager.dao.po.TypeConfigPO">
+ <id column="tc_id" property="id"/>
+ <result column="type_name" property="typeName"/>
+ <result column="properties_json" property="propertiesJson"/>
+ </collection>
+ </resultMap>
+
+ <select id="findAllByClusterId" parameterType="java.lang.Long" resultMap="serviceConfigMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.service_name, tc.type_name, tc.properties_json, tc.id as tc_id
+ from
+ (select * from service_config
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) r
+ inner join service s
+ on r.service_id = s.id
+ inner join type_config tc
+ on r.id = tc.service_config_id
+ order by version desc
+ </select>
+
+ <select id="findByClusterIdAndServiceIdAndSelectedIsTrue" resultMap="serviceConfigMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.service_name, tc.type_name, tc.properties_json
+ from
+ (select * from service_config
+ <where>
+ selected = 1
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ <if test="serviceId != 0">
+ and service_id = #{serviceId}
+ </if>
+ </where>
+ ) r
+ inner join service s
+ on r.service_id = s.id
+ inner join type_config tc
+ on r.id = tc.service_config_id
+ limit 1
+ </select>
+
+ <select id="findAllByClusterIdAndSelectedIsTrue" resultMap="serviceConfigMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="r"/>
+ </include>
+ , s.service_name, tc.type_name, tc.properties_json
+ from
+ (select * from service_config
+ <where>
+ selected = 1
+ <if test="clusterId != 0">
+ and cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) r
+ inner join service s
+ on r.service_id = s.id
+ inner join type_config tc
+ on r.id = tc.service_config_id
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceMapper.xml
new file mode 100644
index 0000000..5a40565
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceMapper.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.ServiceDao">
+
+ <sql id="baseColumns">
+ id, service_name, display_name, service_desc, service_version, package_specifics, service_user, required_services, cluster_id
+ </sql>
+
+ <sql id="baseColumnsV2">
+ ${alias}.id, ${alias}.service_name, ${alias}.display_name, ${alias}.service_desc, ${alias}.service_version, ${alias}.package_specifics, ${alias}.service_user, ${alias}.required_services, ${alias}.cluster_id
+ </sql>
+
+ <resultMap id="serviceMap" type="org.apache.bigtop.manager.dao.po.ServicePO">
+ <id column="id" property="id"/>
+ <result column="service_name" property="serviceName"/>
+ <result column="display_name" property="displayName"/>
+ <result column="service_desc" property="serviceDesc"/>
+ <result column="service_version" property="serviceVersion"/>
+ <result column="package_specifics" property="packageSpecifics"/>
+ <result column="service_user" property="serviceUser"/>
+ <result column="required_services" property="requiredServices"/>
+ <result column="cluster_id" property="clusterId"/>
+ <result column="cluster_name" property="clusterName"/>
+ <result column="user_group" property="userGroup"/>
+ <collection property="components" ofType="org.apache.bigtop.manager.dao.po.ComponentPO">
+ <id column="cid" property="id"/>
+ <result column="component_name" property="componentName"/>
+ <result column="category" property="category"/>
+ <result column="quick_link" property="quickLink"/>
+ <result column="service_id" property="serviceId"/>
+ <result column="cluster_id" property="clusterId"/>
+ </collection>
+ </resultMap>
+
+ <select id="findAllByClusterId" parameterType="java.lang.Long" resultMap="serviceMap">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="s"/>
+ </include>
+ , clus.cluster_name, clus.user_group, c.component_name, c.category, c.quick_link, c.id as cid
+ from
+ (select * from service
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ </where>
+ ) s
+ inner join
+ cluster clus
+ on s.cluster_id = clus.id
+ inner join
+ component c
+ on c.service_id = s.id
+ </select>
+
+ <select id="findByIdJoin" parameterType="java.lang.Long"
+ resultType="org.apache.bigtop.manager.dao.po.ServicePO">
+ select
+ <include refid="baseColumnsV2">
+ <property name="alias" value="s"/>
+ </include>
+ , clus.cluster_name, clus.user_group
+ from
+ (select * from service
+ <where>
+ <if test="id != 0">
+ id = #{id}
+ </if>
+ </where>
+ ) s
+ inner join
+ cluster clus
+ on s.cluster_id = clus.id
+ </select>
+
+ <select id="findByClusterIdAndServiceName"
+ resultType="org.apache.bigtop.manager.dao.po.ServicePO">
+ select
+ <include refid="baseColumns"/>
+ from
+ service
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ <if test="serviceName != null">
+ and service_name = #{serviceName}
+ </if>
+ </where>
+ </select>
+
+ <select id="findByClusterIdAndServiceNameIn"
+ resultType="org.apache.bigtop.manager.dao.po.ServicePO">
+ select
+ <include refid="baseColumns"/>
+ from
+ service
+ <where>
+ <if test="clusterId != 0">
+ cluster_id = #{clusterId}
+ </if>
+ <if test="serviceNames != null and serviceNames.size() > 0">
+ and service_name = in
+ <foreach collection="serviceNames" item="serviceName" index="index" open="(" close=")" separator=", ">
+ #{serviceName}
+ </foreach>
+ </if>
+ </where>
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/StackMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/StackMapper.xml
new file mode 100644
index 0000000..d654df9
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/StackMapper.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.StackDao">
+
+ <sql id="baseColumns">
+ id, stack_name, stack_version
+ </sql>
+
+ <select id="findByStackNameAndStackVersion" resultType="org.apache.bigtop.manager.dao.po.StackPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ stack
+ <where>
+ <if test="stackName!=null">
+ stack_name=#{stackName}
+ </if>
+ <if test="stackVersion!=null">
+ and stack_version=#{stackVersion}
+ </if>
+ </where>
+ limit 1
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/StageMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/StageMapper.xml
new file mode 100644
index 0000000..6b567ce
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/StageMapper.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.StageDao">
+
+ <update id="updateStateByIds" parameterType="java.util.List">
+ UPDATE stage
+ SET `state` = CASE
+ <foreach collection="stages" item="item" index="index">
+ WHEN id = #{item.id} THEN #{item.state}
+ </foreach>
+ END
+ WHERE id IN
+ <foreach collection="stages" index="index" item="item" open="(" separator="," close=")">
+ #{item.id}
+ </foreach>
+ </update>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/TaskMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/TaskMapper.xml
new file mode 100644
index 0000000..7f9d74b
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/TaskMapper.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.TaskDao">
+
+ <update id="updateStateByIds" parameterType="java.util.List">
+ UPDATE task
+ SET `state` = CASE
+ <foreach collection="tasks" item="item" index="index">
+ WHEN id = #{item.id} THEN #{item.state}
+ </foreach>
+ END
+ WHERE id IN
+ <foreach collection="tasks" index="index" item="item" open="(" separator="," close=")">
+ #{item.id}
+ </foreach>
+ </update>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-dao/src/main/resources/mapper/mysql/UserMapper.xml b/bigtop-manager-dao/src/main/resources/mapper/mysql/UserMapper.xml
new file mode 100644
index 0000000..e05f926
--- /dev/null
+++ b/bigtop-manager-dao/src/main/resources/mapper/mysql/UserMapper.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+-->
+
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.bigtop.manager.dao.repository.UserDao">
+
+ <sql id="baseColumns">
+ id, username, password, nickname, status
+ </sql>
+
+ <select id="findByUsername" resultType="org.apache.bigtop.manager.dao.po.UserPO">
+ select
+ <include refid="baseColumns"/>
+ from
+ user
+ <where>
+ <if test="username!=null">
+ username=#{username}
+ </if>
+ </where>
+ limit 1
+ </select>
+
+</mapper>
\ No newline at end of file
diff --git a/bigtop-manager-server/pom.xml b/bigtop-manager-server/pom.xml
index c3e6ccf..408b7f9 100644
--- a/bigtop-manager-server/pom.xml
+++ b/bigtop-manager-server/pom.xml
@@ -60,32 +60,6 @@
<artifactId>bigtop-manager-ui</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.hibernate.orm</groupId>
- <artifactId>hibernate-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate.orm</groupId>
- <artifactId>hibernate-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.jpa</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.extension</artifactId>
- </dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -101,6 +75,11 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.github.pagehelper</groupId>
+ <artifactId>pagehelper-spring-boot-starter</artifactId>
+ </dependency>
+
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ServerApplication.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ServerApplication.java
index 5eafb01..07d844e 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ServerApplication.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ServerApplication.java
@@ -18,19 +18,15 @@
*/
package org.apache.bigtop.manager.server;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableAsync
@EnableScheduling
-@EnableJpaAuditing
-@EntityScan("org.apache.bigtop.manager.dao")
-@EnableJpaRepositories("org.apache.bigtop.manager.dao")
+@MapperScan("org.apache.bigtop.manager.dao")
@SpringBootApplication(scanBasePackages = {"org.apache.bigtop.manager.server", "org.apache.bigtop.manager.common"})
public class ServerApplication {
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/aop/AuditAspect.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/aop/AuditAspect.java
index 4599260..0833183 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/aop/AuditAspect.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/aop/AuditAspect.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.aop;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.dao.po.AuditLogPO;
-import org.apache.bigtop.manager.dao.repository.AuditLogRepository;
+import org.apache.bigtop.manager.dao.repository.AuditLogDao;
import org.apache.bigtop.manager.server.holder.SessionUserHolder;
import org.aspectj.lang.JoinPoint;
@@ -44,7 +44,7 @@ import jakarta.servlet.http.HttpServletRequest;
public class AuditAspect {
@Resource
- private AuditLogRepository auditLogRepository;
+ private AuditLogDao auditLogDao;
@Before(value = "@annotation(org.apache.bigtop.manager.server.annotations.Audit)")
public void before(JoinPoint joinPoint) {
@@ -87,7 +87,7 @@ public class AuditAspect {
log.debug("auditLog: {}", auditLogPO);
log.debug("request method:{}.{}", joinPoint.getSignature().getDeclaringTypeName(), methodName);
- auditLogRepository.save(auditLogPO);
+ auditLogDao.save(auditLogPO);
}
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractJob.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractJob.java
index 2dc180e..902311b 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractJob.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/AbstractJob.java
@@ -24,10 +24,11 @@ import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.JobPO;
import org.apache.bigtop.manager.dao.po.StagePO;
import org.apache.bigtop.manager.dao.po.TaskPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.JobRepository;
-import org.apache.bigtop.manager.dao.repository.StageRepository;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
+import org.apache.bigtop.manager.dao.repository.JobDao;
+import org.apache.bigtop.manager.dao.repository.StackDao;
+import org.apache.bigtop.manager.dao.repository.StageDao;
+import org.apache.bigtop.manager.dao.repository.TaskDao;
import org.apache.bigtop.manager.server.command.stage.Stage;
import org.apache.bigtop.manager.server.command.task.Task;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
@@ -38,10 +39,11 @@ import java.util.concurrent.LinkedBlockingQueue;
public abstract class AbstractJob implements Job {
- protected ClusterRepository clusterRepository;
- protected JobRepository jobRepository;
- protected StageRepository stageRepository;
- protected TaskRepository taskRepository;
+ protected StackDao stackDao;
+ protected ClusterDao clusterDao;
+ protected JobDao jobDao;
+ protected StageDao stageDao;
+ protected TaskDao taskDao;
protected JobContext jobContext;
protected List<Stage> stages;
@@ -65,24 +67,25 @@ public abstract class AbstractJob implements Job {
}
protected void injectBeans() {
- this.clusterRepository = SpringContextHolder.getBean(ClusterRepository.class);
- this.jobRepository = SpringContextHolder.getBean(JobRepository.class);
- this.stageRepository = SpringContextHolder.getBean(StageRepository.class);
- this.taskRepository = SpringContextHolder.getBean(TaskRepository.class);
+ this.stackDao = SpringContextHolder.getBean(StackDao.class);
+ this.clusterDao = SpringContextHolder.getBean(ClusterDao.class);
+
+ this.jobDao = SpringContextHolder.getBean(JobDao.class);
+ this.stageDao = SpringContextHolder.getBean(StageDao.class);
+ this.taskDao = SpringContextHolder.getBean(TaskDao.class);
}
protected void beforeCreateStages() {
Long clusterId = jobContext.getCommandDTO().getClusterId();
- this.clusterPO = clusterId == null ? new ClusterPO() : clusterRepository.getReferenceById(clusterId);
+ this.clusterPO = clusterId == null ? new ClusterPO() : clusterDao.findById(clusterId);
}
protected abstract void createStages();
@Override
public void beforeRun() {
- JobPO jobPO = getJobPO();
- jobPO.setState(JobState.PROCESSING);
- jobRepository.save(jobPO);
+ jobPO.setState(JobState.PROCESSING.getName());
+ jobDao.updateById(jobPO);
}
@Override
@@ -116,8 +119,8 @@ public abstract class AbstractJob implements Job {
@Override
public void onSuccess() {
JobPO jobPO = getJobPO();
- jobPO.setState(JobState.SUCCESSFUL);
- jobRepository.save(jobPO);
+ jobPO.setState(JobState.SUCCESSFUL.getName());
+ jobDao.updateById(jobPO);
}
@Override
@@ -126,25 +129,28 @@ public abstract class AbstractJob implements Job {
List<StagePO> stagePOList = new ArrayList<>();
List<TaskPO> taskPOList = new ArrayList<>();
- jobPO.setState(JobState.FAILED);
+ jobPO.setState(JobState.FAILED.getName());
for (Stage stage : getStages()) {
StagePO stagePO = stage.getStagePO();
- if (stagePO.getState() == JobState.PENDING) {
- stagePO.setState(JobState.CANCELED);
+ if (JobState.fromString(stagePO.getState()) == JobState.PENDING) {
+ stagePO.setState(JobState.CANCELED.getName());
stagePOList.add(stagePO);
for (Task task : stage.getTasks()) {
TaskPO taskPO = task.getTaskPO();
- taskPO.setState(JobState.CANCELED);
+ taskPO.setState(JobState.CANCELED.getName());
taskPOList.add(taskPO);
}
}
}
-
- taskRepository.saveAll(taskPOList);
- stageRepository.saveAll(stagePOList);
- jobRepository.save(jobPO);
+ if (!taskPOList.isEmpty()) {
+ taskDao.updateStateByIds(taskPOList);
+ }
+ if (!stagePOList.isEmpty()) {
+ stageDao.updateStateByIds(stagePOList);
+ }
+ jobDao.updateById(jobPO);
}
@Override
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 a5bd909..5192d61 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
@@ -24,8 +24,10 @@ import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.dao.po.ComponentPO;
import org.apache.bigtop.manager.dao.po.HostComponentPO;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.ComponentRepository;
-import org.apache.bigtop.manager.dao.repository.HostComponentRepository;
+import org.apache.bigtop.manager.dao.po.StackPO;
+import org.apache.bigtop.manager.dao.repository.ComponentDao;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.command.stage.CacheFileUpdateStage;
import org.apache.bigtop.manager.server.command.stage.ComponentCheckStage;
import org.apache.bigtop.manager.server.command.stage.ComponentConfigureStage;
@@ -51,8 +53,9 @@ import java.util.List;
public abstract class AbstractServiceJob extends AbstractJob {
- protected ComponentRepository componentRepository;
- protected HostComponentRepository hostComponentRepository;
+ protected ComponentDao componentDao;
+ protected HostComponentDao hostComponentDao;
+ protected HostDao hostDao;
protected String stackName;
protected String stackVersion;
@@ -66,16 +69,18 @@ public abstract class AbstractServiceJob extends AbstractJob {
protected void injectBeans() {
super.injectBeans();
- this.componentRepository = SpringContextHolder.getBean(ComponentRepository.class);
- this.hostComponentRepository = SpringContextHolder.getBean(HostComponentRepository.class);
+ this.componentDao = SpringContextHolder.getBean(ComponentDao.class);
+ this.hostComponentDao = SpringContextHolder.getBean(HostComponentDao.class);
+ this.hostDao = SpringContextHolder.getBean(HostDao.class);
}
@Override
protected void beforeCreateStages() {
super.beforeCreateStages();
+ StackPO stackPO = stackDao.findById(clusterPO.getStackId());
- stackName = clusterPO.getStackPO().getStackName();
- stackVersion = clusterPO.getStackPO().getStackVersion();
+ stackName = stackPO.getStackName();
+ stackVersion = stackPO.getStackVersion();
dag = StackUtils.getStackDagMap().get(StackUtils.fullStackName(stackName, stackVersion));
}
@@ -115,7 +120,7 @@ public abstract class AbstractServiceJob extends AbstractJob {
protected List<String> getComponentNames() {
List<String> serviceNames = getServiceNames();
List<ComponentPO> componentPOList =
- componentRepository.findAllByClusterPOIdAndServicePOServiceNameIn(clusterPO.getId(), serviceNames);
+ componentDao.findAllByClusterIdAndServiceServiceNameIn(clusterPO.getId(), serviceNames);
return componentPOList.stream().map(ComponentPO::getComponentName).toList();
}
@@ -149,15 +154,15 @@ public abstract class AbstractServiceJob extends AbstractJob {
protected List<String> findHostnamesByComponentName(String componentName) {
List<HostComponentPO> hostComponentPOList =
- hostComponentRepository.findAllByComponentPOClusterPOIdAndComponentPOComponentName(
- clusterPO.getId(), componentName);
+ hostComponentDao.findAllByClusterIdAndComponentName(clusterPO.getId(), componentName);
if (hostComponentPOList == null) {
return new ArrayList<>();
} else {
- return hostComponentPOList.stream()
- .map(HostComponentPO::getHostPO)
- .map(HostPO::getHostname)
- .toList();
+
+ List<HostPO> hostPOList = hostDao.findByIds(
+ hostComponentPOList.stream().map(HostComponentPO::getHostId).toList());
+
+ return hostPOList.stream().map(HostPO::getHostname).toList();
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ClusterCreateJob.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ClusterCreateJob.java
index 4282a2c..47a2744 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ClusterCreateJob.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ClusterCreateJob.java
@@ -71,28 +71,28 @@ public class ClusterCreateJob extends AbstractJob {
super.onSuccess();
CommandDTO commandDTO = jobContext.getCommandDTO();
- ClusterPO clusterPO = clusterRepository
+ ClusterPO clusterPO = clusterDao
.findByClusterName(commandDTO.getClusterCommand().getClusterName())
.orElse(new ClusterPO());
// Update cluster state to installed
- clusterPO.setState(MaintainState.INSTALLED);
- clusterRepository.save(clusterPO);
+ clusterPO.setState(MaintainState.INSTALLED.getName());
+ clusterDao.updateById(clusterPO);
// Link job to cluster after cluster successfully added
JobPO jobPO = getJobPO();
- jobPO.setClusterPO(clusterPO);
- jobRepository.save(jobPO);
+ jobPO.setClusterId(clusterPO.getId());
+ jobDao.updateById(jobPO);
for (Stage stage : getStages()) {
StagePO stagePO = stage.getStagePO();
- stagePO.setClusterPO(clusterPO);
- stageRepository.save(stagePO);
+ stagePO.setClusterId(clusterPO.getId());
+ stageDao.updateById(stagePO);
for (Task task : stage.getTasks()) {
TaskPO taskPO = task.getTaskPO();
- taskPO.setClusterPO(clusterPO);
- taskRepository.save(taskPO);
+ taskPO.setClusterId(clusterPO.getId());
+ taskDao.updateById(taskPO);
}
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ServiceInstallJob.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ServiceInstallJob.java
index dd5c727..100ccdf 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ServiceInstallJob.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/job/ServiceInstallJob.java
@@ -24,8 +24,8 @@ import org.apache.bigtop.manager.dao.po.ComponentPO;
import org.apache.bigtop.manager.dao.po.HostComponentPO;
import org.apache.bigtop.manager.dao.po.HostPO;
import org.apache.bigtop.manager.dao.po.ServicePO;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
+import org.apache.bigtop.manager.dao.repository.ServiceDao;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
import org.apache.bigtop.manager.server.model.converter.ComponentConverter;
import org.apache.bigtop.manager.server.model.converter.ServiceConverter;
@@ -43,8 +43,8 @@ import java.util.List;
public class ServiceInstallJob extends AbstractServiceJob {
private ConfigService configService;
- private ServiceRepository serviceRepository;
- private HostRepository hostRepository;
+ private ServiceDao serviceDao;
+ private HostDao hostDao;
public ServiceInstallJob(JobContext jobContext) {
super(jobContext);
@@ -55,8 +55,8 @@ public class ServiceInstallJob extends AbstractServiceJob {
super.injectBeans();
this.configService = SpringContextHolder.getBean(ConfigService.class);
- this.serviceRepository = SpringContextHolder.getBean(ServiceRepository.class);
- this.hostRepository = SpringContextHolder.getBean(HostRepository.class);
+ this.serviceDao = SpringContextHolder.getBean(ServiceDao.class);
+ this.hostDao = SpringContextHolder.getBean(HostDao.class);
}
@Override
@@ -99,11 +99,11 @@ public class ServiceInstallJob extends AbstractServiceJob {
if (componentHost.getComponentName().equals(componentName)) {
List<String> hostnames = new ArrayList<>(componentHost.getHostnames());
if (serviceCommand.getInstalled()) {
- List<String> existHostnames = hostComponentRepository
- .findAllByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostnameIn(
+ List<String> existHostnames = hostComponentDao
+ .findAllByClusterIdAndComponentNameAndHostnameIn(
clusterPO.getId(), componentName, hostnames)
.stream()
- .map(hostComponent -> hostComponent.getHostPO().getHostname())
+ .map(HostComponentPO::getHostname)
.toList();
hostnames.removeAll(existHostnames);
@@ -128,7 +128,7 @@ public class ServiceInstallJob extends AbstractServiceJob {
// Persist service, component and hostComponent metadata to database
for (ServiceCommandDTO serviceCommand : serviceCommands) {
String serviceName = serviceCommand.getServiceName();
- ServicePO servicePO = serviceRepository.findByClusterPOIdAndServiceName(clusterId, serviceName);
+ ServicePO servicePO = serviceDao.findByClusterIdAndServiceName(clusterId, serviceName);
upsertService(servicePO, serviceCommand);
}
}
@@ -137,16 +137,16 @@ public class ServiceInstallJob extends AbstractServiceJob {
CommandDTO commandDTO = jobContext.getCommandDTO();
Long clusterId = commandDTO.getClusterId();
String serviceName = serviceCommand.getServiceName();
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
+ ClusterPO clusterPO = clusterDao.findByIdJoin(clusterId);
- String stackName = clusterPO.getStackPO().getStackName();
- String stackVersion = clusterPO.getStackPO().getStackVersion();
+ String stackName = clusterPO.getStackName();
+ String stackVersion = clusterPO.getStackVersion();
// 1. Persist service and components
if (servicePO == null) {
ServiceDTO serviceDTO = StackUtils.getServiceDTO(stackName, stackVersion, serviceName);
servicePO = ServiceConverter.INSTANCE.fromDTO2PO(serviceDTO, clusterPO);
- servicePO = serviceRepository.save(servicePO);
+ serviceDao.save(servicePO);
}
// 2. Update configs
@@ -156,26 +156,25 @@ public class ServiceInstallJob extends AbstractServiceJob {
String componentName = componentHostDTO.getComponentName();
// 3. Persist component
- ComponentPO componentPO = componentRepository.findByClusterPOIdAndComponentName(clusterId, componentName);
+ ComponentPO componentPO = componentDao.findByClusterIdAndComponentName(clusterId, componentName);
if (componentPO == null) {
ComponentDTO componentDTO = StackUtils.getComponentDTO(stackName, stackVersion, componentName);
componentPO = ComponentConverter.INSTANCE.fromDTO2PO(componentDTO, servicePO, clusterPO);
- componentPO = componentRepository.save(componentPO);
+ componentDao.save(componentPO);
}
// 4. Persist hostComponent
for (String hostname : componentHostDTO.getHostnames()) {
HostComponentPO hostComponentPO =
- hostComponentRepository.findByComponentPOComponentNameAndHostPOHostname(
- componentName, hostname);
+ hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
if (hostComponentPO == null) {
- HostPO hostPO = hostRepository.findByHostname(hostname);
+ HostPO hostPO = hostDao.findByHostname(hostname);
hostComponentPO = new HostComponentPO();
- hostComponentPO.setHostPO(hostPO);
- hostComponentPO.setComponentPO(componentPO);
- hostComponentPO.setState(MaintainState.UNINSTALLED);
- hostComponentRepository.save(hostComponentPO);
+ hostComponentPO.setHostId(hostPO.getId());
+ hostComponentPO.setComponentId(componentPO.getId());
+ hostComponentPO.setState(MaintainState.UNINSTALLED.getName());
+ hostComponentDao.save(hostComponentPO);
}
}
}
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 fb6029a..54b2728 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
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.command.stage;
import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
import org.apache.bigtop.manager.server.command.task.TaskContext;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
import org.apache.bigtop.manager.server.model.dto.ComponentDTO;
@@ -30,7 +30,7 @@ import java.util.Map;
public abstract class AbstractComponentStage extends AbstractStage {
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
private ClusterPO clusterPO;
@@ -42,12 +42,12 @@ public abstract class AbstractComponentStage extends AbstractStage {
protected void injectBeans() {
super.injectBeans();
- this.clusterRepository = SpringContextHolder.getBean(ClusterRepository.class);
+ this.clusterDao = SpringContextHolder.getBean(ClusterDao.class);
}
@Override
protected void beforeCreateTasks() {
- this.clusterPO = clusterRepository.getReferenceById(stageContext.getClusterId());
+ this.clusterPO = clusterDao.findById(stageContext.getClusterId());
}
@Override
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractStage.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractStage.java
index fd30373..2081f7c 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractStage.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/AbstractStage.java
@@ -21,7 +21,7 @@ package org.apache.bigtop.manager.server.command.stage;
import org.apache.bigtop.manager.common.enums.JobState;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.dao.po.StagePO;
-import org.apache.bigtop.manager.dao.repository.StageRepository;
+import org.apache.bigtop.manager.dao.repository.StageDao;
import org.apache.bigtop.manager.server.command.task.Task;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
@@ -31,7 +31,7 @@ import java.util.concurrent.CompletableFuture;
public abstract class AbstractStage implements Stage {
- protected StageRepository stageRepository;
+ protected StageDao stageDao;
protected StageContext stageContext;
protected List<Task> tasks;
@@ -55,7 +55,7 @@ public abstract class AbstractStage implements Stage {
}
protected void injectBeans() {
- this.stageRepository = SpringContextHolder.getBean(StageRepository.class);
+ this.stageDao = SpringContextHolder.getBean(StageDao.class);
}
protected abstract void beforeCreateTasks();
@@ -72,9 +72,8 @@ public abstract class AbstractStage implements Stage {
@Override
public void beforeRun() {
- StagePO stagePO = getStagePO();
- stagePO.setState(JobState.PROCESSING);
- stageRepository.save(stagePO);
+ stagePO.setState(JobState.PROCESSING.getName());
+ stageDao.updateById(stagePO);
}
@Override
@@ -116,15 +115,15 @@ public abstract class AbstractStage implements Stage {
@Override
public void onSuccess() {
StagePO stagePO = getStagePO();
- stagePO.setState(JobState.SUCCESSFUL);
- stageRepository.save(stagePO);
+ stagePO.setState(JobState.SUCCESSFUL.getName());
+ stageDao.updateById(stagePO);
}
@Override
public void onFailure() {
StagePO stagePO = getStagePO();
- stagePO.setState(JobState.FAILED);
- stageRepository.save(stagePO);
+ stagePO.setState(JobState.FAILED.getName());
+ stageDao.updateById(stagePO);
}
@Override
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 9223af7..37d8f40 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
@@ -20,7 +20,7 @@ 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.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.command.task.CacheFileUpdateTask;
import org.apache.bigtop.manager.server.command.task.Task;
import org.apache.bigtop.manager.server.command.task.TaskContext;
@@ -33,7 +33,7 @@ import java.util.Map;
public class CacheFileUpdateStage extends AbstractStage {
- private HostRepository hostRepository;
+ private HostDao hostDao;
public CacheFileUpdateStage(StageContext stageContext) {
super(stageContext);
@@ -43,7 +43,7 @@ public class CacheFileUpdateStage extends AbstractStage {
protected void injectBeans() {
super.injectBeans();
- this.hostRepository = SpringContextHolder.getBean(HostRepository.class);
+ this.hostDao = SpringContextHolder.getBean(HostDao.class);
}
@Override
@@ -54,7 +54,7 @@ public class CacheFileUpdateStage extends AbstractStage {
hostnames.addAll(stageContext.getHostnames());
} else {
hostnames.addAll(stageContext.getHostnames() == null ? List.of() : stageContext.getHostnames());
- hostnames.addAll(hostRepository.findAllByClusterPOId(stageContext.getClusterId()).stream()
+ hostnames.addAll(hostDao.findAllByClusterId(stageContext.getClusterId()).stream()
.map(HostPO::getHostname)
.toList());
}
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 8e8a5fe..5167cb3 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
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.stage;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
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;
@@ -28,7 +28,7 @@ import org.apache.bigtop.manager.server.holder.SpringContextHolder;
public class HostCheckStage extends AbstractStage {
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
public HostCheckStage(StageContext stageContext) {
super(stageContext);
@@ -38,16 +38,16 @@ public class HostCheckStage extends AbstractStage {
protected void injectBeans() {
super.injectBeans();
- this.clusterRepository = SpringContextHolder.getBean(ClusterRepository.class);
+ this.clusterDao = SpringContextHolder.getBean(ClusterDao.class);
}
@Override
protected void beforeCreateTasks() {
if (stageContext.getClusterId() != null) {
- ClusterPO clusterPO = clusterRepository.getReferenceById(stageContext.getClusterId());
+ ClusterPO clusterPO = clusterDao.findByIdJoin(stageContext.getClusterId());
- stageContext.setStackName(clusterPO.getStackPO().getStackName());
- stageContext.setStackVersion(clusterPO.getStackPO().getStackVersion());
+ stageContext.setStackName(clusterPO.getStackName());
+ stageContext.setStackVersion(clusterPO.getStackVersion());
}
}
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 763bf0a..03414e6 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
@@ -24,7 +24,7 @@ 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.HostComponentRepository;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
import org.apache.bigtop.manager.grpc.generated.CommandRequest;
import org.apache.bigtop.manager.grpc.generated.CommandType;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
@@ -39,7 +39,7 @@ import java.util.Map;
public abstract class AbstractComponentTask extends AbstractTask {
- protected HostComponentRepository hostComponentRepository;
+ protected HostComponentDao hostComponentDao;
public AbstractComponentTask(TaskContext taskContext) {
super(taskContext);
@@ -49,7 +49,7 @@ public abstract class AbstractComponentTask extends AbstractTask {
protected void injectBeans() {
super.injectBeans();
- this.hostComponentRepository = SpringContextHolder.getBean(HostComponentRepository.class);
+ this.hostComponentDao = SpringContextHolder.getBean(HostComponentDao.class);
}
@Override
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractTask.java
index fc750b7..fc0871a 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractTask.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/AbstractTask.java
@@ -23,7 +23,7 @@ import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.common.enums.JobState;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.dao.po.TaskPO;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
+import org.apache.bigtop.manager.dao.repository.TaskDao;
import org.apache.bigtop.manager.grpc.generated.CommandReply;
import org.apache.bigtop.manager.grpc.generated.CommandRequest;
import org.apache.bigtop.manager.grpc.generated.CommandServiceGrpc;
@@ -33,7 +33,7 @@ import org.apache.bigtop.manager.server.holder.SpringContextHolder;
public abstract class AbstractTask implements Task {
- protected TaskRepository taskRepository;
+ protected TaskDao taskDao;
protected TaskContext taskContext;
@@ -51,7 +51,7 @@ public abstract class AbstractTask implements Task {
}
protected void injectBeans() {
- this.taskRepository = SpringContextHolder.getBean(TaskRepository.class);
+ this.taskDao = SpringContextHolder.getBean(TaskDao.class);
}
protected abstract Command getCommand();
@@ -64,9 +64,8 @@ public abstract class AbstractTask implements Task {
@Override
public void beforeRun() {
- TaskPO taskPO = getTaskPO();
- taskPO.setState(JobState.PROCESSING);
- taskRepository.save(taskPO);
+ taskPO.setState(JobState.PROCESSING.getName());
+ taskDao.updateById(taskPO);
}
@Override
@@ -102,16 +101,16 @@ public abstract class AbstractTask implements Task {
public void onSuccess() {
TaskPO taskPO = getTaskPO();
taskPO.setContent(ProtobufUtil.toJson(commandRequest));
- taskPO.setState(JobState.SUCCESSFUL);
- taskRepository.save(taskPO);
+ taskPO.setState(JobState.SUCCESSFUL.getName());
+ taskDao.updateById(taskPO);
}
@Override
public void onFailure() {
TaskPO taskPO = getTaskPO();
taskPO.setContent(ProtobufUtil.toJson(commandRequest));
- taskPO.setState(JobState.FAILED);
- taskRepository.save(taskPO);
+ taskPO.setState(JobState.FAILED.getName());
+ taskDao.updateById(taskPO);
}
@Override
@@ -136,7 +135,7 @@ public abstract class AbstractTask implements Task {
taskPO.setServiceName(taskContext.getServiceName());
taskPO.setServiceUser(taskContext.getServiceUser());
taskPO.setComponentName(taskContext.getComponentName());
- taskPO.setCommand(getCommand());
+ taskPO.setCommand(getCommand().getName());
taskPO.setCustomCommand(getCustomCommand());
}
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 3c1fabb..4d67906 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
@@ -34,14 +34,14 @@ 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.po.TypeConfigPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.ComponentRepository;
-import org.apache.bigtop.manager.dao.repository.HostComponentRepository;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
-import org.apache.bigtop.manager.dao.repository.RepoRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceConfigRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceRepository;
-import org.apache.bigtop.manager.dao.repository.SettingRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
+import org.apache.bigtop.manager.dao.repository.ComponentDao;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
+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;
@@ -69,14 +69,14 @@ import static org.apache.bigtop.manager.common.constants.Constants.ALL_HOST_KEY;
public class CacheFileUpdateTask extends AbstractTask {
- private ClusterRepository clusterRepository;
- private HostComponentRepository hostComponentRepository;
- private ServiceRepository serviceRepository;
- private ServiceConfigRepository serviceConfigRepository;
- private RepoRepository repoRepository;
- private SettingRepository settingRepository;
- private HostRepository hostRepository;
- private ComponentRepository componentRepository;
+ private ClusterDao clusterDao;
+ private HostComponentDao hostComponentDao;
+ private ServiceDao serviceDao;
+ private ServiceConfigDao serviceConfigDao;
+ private RepoDao repoDao;
+ private SettingDao settingDao;
+ private HostDao hostDao;
+ private ComponentDao componentDao;
private ClusterInfo clusterInfo;
private Map<String, ComponentInfo> componentInfoMap;
@@ -94,14 +94,14 @@ public class CacheFileUpdateTask extends AbstractTask {
protected void injectBeans() {
super.injectBeans();
- this.clusterRepository = SpringContextHolder.getBean(ClusterRepository.class);
- this.hostComponentRepository = SpringContextHolder.getBean(HostComponentRepository.class);
- this.serviceRepository = SpringContextHolder.getBean(ServiceRepository.class);
- this.serviceConfigRepository = SpringContextHolder.getBean(ServiceConfigRepository.class);
- this.repoRepository = SpringContextHolder.getBean(RepoRepository.class);
- this.settingRepository = SpringContextHolder.getBean(SettingRepository.class);
- this.hostRepository = SpringContextHolder.getBean(HostRepository.class);
- this.componentRepository = SpringContextHolder.getBean(ComponentRepository.class);
+ this.clusterDao = SpringContextHolder.getBean(ClusterDao.class);
+ this.hostComponentDao = SpringContextHolder.getBean(HostComponentDao.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);
}
@Override
@@ -120,20 +120,21 @@ public class CacheFileUpdateTask extends AbstractTask {
}
private void genFullCaches() {
- ClusterPO clusterPO = clusterRepository.getReferenceById(taskContext.getClusterId());
+ ClusterPO clusterPO = clusterDao.findByIdJoin(taskContext.getClusterId());
Long clusterId = clusterPO.getId();
String clusterName = clusterPO.getClusterName();
- String stackName = clusterPO.getStackPO().getStackName();
- String stackVersion = clusterPO.getStackPO().getStackVersion();
- List<ServicePO> servicePOList = serviceRepository.findAllByClusterPOId(clusterId);
+ String stackName = clusterPO.getStackName();
+ String stackVersion = clusterPO.getStackVersion();
+
+ List<ServicePO> servicePOList = serviceDao.findAllByClusterId(clusterId);
List<ServiceConfigPO> serviceConfigPOList =
- serviceConfigRepository.findAllByClusterPOAndSelectedIsTrue(clusterPO);
- List<HostComponentPO> hostComponentPOList = hostComponentRepository.findAllByComponentPOClusterPOId(clusterId);
- List<RepoPO> repoPOList = repoRepository.findAllByClusterPO(clusterPO);
- Iterable<SettingPO> settings = settingRepository.findAll();
- List<HostPO> hostPOList = hostRepository.findAllByClusterPOId(clusterId);
+ serviceConfigDao.findAllByClusterIdAndSelectedIsTrue(clusterPO.getId());
+ List<HostComponentPO> hostComponentPOList = hostComponentDao.findAllByClusterId(clusterId);
+ List<RepoPO> repoPOList = repoDao.findAllByClusterId(clusterPO.getId());
+ Iterable<SettingPO> settings = settingDao.findAll();
+ List<HostPO> hostPOList = hostDao.findAllByClusterId(clusterId);
clusterInfo = new ClusterInfo();
clusterInfo.setClusterName(clusterName);
@@ -151,29 +152,28 @@ public class CacheFileUpdateTask extends AbstractTask {
JsonUtils.readFromString(typeConfigPO.getPropertiesJson(), new TypeReference<>() {});
String configMapStr = JsonUtils.writeAsString(StackConfigUtils.extractConfigMap(properties));
- if (serviceConfigMap.containsKey(serviceConfigPO.getServicePO().getServiceName())) {
+ if (serviceConfigMap.containsKey(serviceConfigPO.getServiceName())) {
serviceConfigMap
- .get(serviceConfigPO.getServicePO().getServiceName())
+ .get(serviceConfigPO.getServiceName())
.put(typeConfigPO.getTypeName(), configMapStr);
} else {
Map<String, Object> hashMap = new HashMap<>();
hashMap.put(typeConfigPO.getTypeName(), configMapStr);
- serviceConfigMap.put(serviceConfigPO.getServicePO().getServiceName(), hashMap);
+ serviceConfigMap.put(serviceConfigPO.getServiceName(), hashMap);
}
}
}
hostMap = new HashMap<>();
hostComponentPOList.forEach(x -> {
- if (hostMap.containsKey(x.getComponentPO().getComponentName())) {
- hostMap.get(x.getComponentPO().getComponentName())
- .add(x.getHostPO().getHostname());
+ if (hostMap.containsKey(x.getComponentName())) {
+ hostMap.get(x.getComponentName()).add(x.getHostname());
} else {
Set<String> set = new HashSet<>();
- set.add(x.getHostPO().getHostname());
- hostMap.put(x.getComponentPO().getComponentName(), set);
+ set.add(x.getHostname());
+ hostMap.put(x.getComponentName(), set);
}
- hostMap.get(x.getComponentPO().getComponentName()).add(x.getHostPO().getHostname());
+ hostMap.get(x.getComponentName()).add(x.getHostname());
});
Set<String> hostNameSet = hostPOList.stream().map(HostPO::getHostname).collect(Collectors.toSet());
@@ -192,7 +192,7 @@ public class CacheFileUpdateTask extends AbstractTask {
settings.forEach(x -> settingsMap.put(x.getTypeName(), x.getConfigData()));
componentInfoMap = new HashMap<>();
- List<ComponentPO> componentPOList = componentRepository.findAll();
+ List<ComponentPO> componentPOList = componentDao.findAllJoinService();
componentPOList.forEach(c -> {
ComponentInfo componentInfo = new ComponentInfo();
componentInfo.setComponentName(c.getComponentName());
@@ -200,7 +200,7 @@ public class CacheFileUpdateTask extends AbstractTask {
componentInfo.setDisplayName(c.getDisplayName());
componentInfo.setCategory(c.getCategory());
componentInfo.setCustomCommands(c.getCustomCommands());
- componentInfo.setServiceName(c.getServicePO().getServiceName());
+ componentInfo.setServiceName(c.getServiceName());
componentInfoMap.put(c.getComponentName(), componentInfo);
});
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentInstallTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentInstallTask.java
index 8bc9530..91f003c 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentInstallTask.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentInstallTask.java
@@ -41,10 +41,9 @@ public class ComponentInstallTask extends AbstractComponentTask {
String componentName = taskContext.getComponentName();
String hostname = taskContext.getHostname();
HostComponentPO hostComponentPO =
- hostComponentRepository.findByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostname(
- clusterId, componentName, hostname);
- hostComponentPO.setState(MaintainState.INSTALLED);
- hostComponentRepository.save(hostComponentPO);
+ hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
+ hostComponentPO.setState(MaintainState.INSTALLED.getName());
+ hostComponentDao.updateById(hostComponentPO);
}
@Override
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStartTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStartTask.java
index 3160fe8..fca02aa 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStartTask.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStartTask.java
@@ -41,10 +41,9 @@ public class ComponentStartTask extends AbstractComponentTask {
String componentName = taskContext.getComponentName();
String hostname = taskContext.getHostname();
HostComponentPO hostComponentPO =
- hostComponentRepository.findByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostname(
- clusterId, componentName, hostname);
- hostComponentPO.setState(MaintainState.STARTED);
- hostComponentRepository.save(hostComponentPO);
+ hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
+ hostComponentPO.setState(MaintainState.STARTED.getName());
+ hostComponentDao.updateById(hostComponentPO);
}
@Override
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStopTask.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStopTask.java
index 3c946fe..b779aa4 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStopTask.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/ComponentStopTask.java
@@ -41,10 +41,9 @@ public class ComponentStopTask extends AbstractComponentTask {
String componentName = taskContext.getComponentName();
String hostname = taskContext.getHostname();
HostComponentPO hostComponentPO =
- hostComponentRepository.findByComponentPOClusterPOIdAndComponentPOComponentNameAndHostPOHostname(
- clusterId, componentName, hostname);
- hostComponentPO.setState(MaintainState.STOPPED);
- hostComponentRepository.save(hostComponentPO);
+ hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
+ hostComponentPO.setState(MaintainState.STOPPED.getName());
+ hostComponentDao.updateById(hostComponentPO);
}
@Override
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterCreateValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterCreateValidator.java
index 9229e17..adc9dc3 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterCreateValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterCreateValidator.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -37,7 +37,7 @@ import java.util.Optional;
public class ClusterCreateValidator implements CommandValidator {
@Resource
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -49,7 +49,7 @@ public class ClusterCreateValidator implements CommandValidator {
ClusterCommandDTO clusterCommand = context.getCommandDTO().getClusterCommand();
String clusterName = clusterCommand.getClusterName();
- Optional<ClusterPO> clusterOptional = clusterRepository.findByClusterName(clusterName);
+ Optional<ClusterPO> clusterOptional = clusterDao.findByClusterName(clusterName);
if (clusterOptional.isPresent()) {
throw new ApiException(ApiExceptionEnum.CLUSTER_IS_INSTALLED, clusterName);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterHostValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterHostValidator.java
index 9d2509f..d007f20 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterHostValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ClusterHostValidator.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -39,7 +39,7 @@ import java.util.List;
public class ClusterHostValidator implements CommandValidator {
@Resource
- private HostRepository hostRepository;
+ private HostDao hostDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -51,7 +51,7 @@ public class ClusterHostValidator implements CommandValidator {
ClusterCommandDTO clusterCommand = context.getCommandDTO().getClusterCommand();
List<String> hostnames = clusterCommand.getHostnames();
- List<HostPO> hostPOList = hostRepository.findAllByHostnameIn(hostnames);
+ List<HostPO> hostPOList = hostDao.findAllByHostnameIn(hostnames);
if (CollectionUtils.isNotEmpty(hostPOList)) {
List<String> existsHostnames =
hostPOList.stream().map(HostPO::getHostname).toList();
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/HostAddValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/HostAddValidator.java
index c57c734..1003f84 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/HostAddValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/HostAddValidator.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -38,7 +38,7 @@ import java.util.List;
public class HostAddValidator implements CommandValidator {
@Resource
- private HostRepository hostRepository;
+ private HostDao hostDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -51,7 +51,7 @@ public class HostAddValidator implements CommandValidator {
.map(HostCommandDTO::getHostname)
.toList();
- List<HostPO> hostPOList = hostRepository.findAllByHostnameIn(hostnames);
+ List<HostPO> hostPOList = hostDao.findAllByHostnameIn(hostnames);
if (CollectionUtils.isNotEmpty(hostPOList)) {
List<String> existsHostnames =
hostPOList.stream().map(HostPO::getHostname).toList();
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/RequiredServicesValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/RequiredServicesValidator.java
index 8248578..0daefc7 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/RequiredServicesValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/RequiredServicesValidator.java
@@ -21,8 +21,8 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.ServicePO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
+import org.apache.bigtop.manager.dao.repository.ServiceDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -43,10 +43,10 @@ import java.util.List;
public class RequiredServicesValidator implements CommandValidator {
@Resource
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
@Resource
- private ServiceRepository serviceRepository;
+ private ServiceDao serviceDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -59,9 +59,9 @@ public class RequiredServicesValidator implements CommandValidator {
List<ServiceCommandDTO> serviceCommands = commandDTO.getServiceCommands();
Long clusterId = commandDTO.getClusterId();
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
- String stackName = clusterPO.getStackPO().getStackName();
- String stackVersion = clusterPO.getStackPO().getStackVersion();
+ ClusterPO clusterPO = clusterDao.findByIdJoin(clusterId);
+ String stackName = clusterPO.getStackName();
+ String stackVersion = clusterPO.getStackVersion();
List<String> serviceNames =
serviceCommands.stream().map(ServiceCommandDTO::getServiceName).toList();
@@ -73,8 +73,7 @@ public class RequiredServicesValidator implements CommandValidator {
return;
}
- List<ServicePO> servicePOList =
- serviceRepository.findByClusterPOIdAndServiceNameIn(clusterId, requiredServices);
+ List<ServicePO> servicePOList = serviceDao.findByClusterIdAndServiceNameIn(clusterId, requiredServices);
List<String> list =
servicePOList.stream().map(ServicePO::getServiceName).toList();
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ServiceHostValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ServiceHostValidator.java
index f6a4dd1..73b0924 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ServiceHostValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/ServiceHostValidator.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
public class ServiceHostValidator implements CommandValidator {
@Resource
- private HostRepository hostRepository;
+ private HostDao hostDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -56,7 +56,7 @@ public class ServiceHostValidator implements CommandValidator {
.flatMap(x -> x.getHostnames().stream())
.collect(Collectors.toSet());
- List<HostPO> hostnames = hostRepository.findAllByHostnameIn(hostnameSet);
+ List<HostPO> hostnames = hostDao.findAllByHostnameIn(hostnameSet);
if (hostnames.size() != hostnameSet.size()) {
throw new ApiException(ApiExceptionEnum.HOST_NOT_FOUND);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/StackValidator.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/StackValidator.java
index 42404c0..387462d 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/StackValidator.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/validator/StackValidator.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.command.validator;
import org.apache.bigtop.manager.common.enums.Command;
import org.apache.bigtop.manager.dao.po.StackPO;
-import org.apache.bigtop.manager.dao.repository.StackRepository;
+import org.apache.bigtop.manager.dao.repository.StackDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.enums.CommandLevel;
@@ -36,7 +36,7 @@ import java.util.List;
public class StackValidator implements CommandValidator {
@Resource
- private StackRepository stackRepository;
+ private StackDao stackDao;
@Override
public List<CommandIdentifier> getCommandIdentifiers() {
@@ -49,7 +49,7 @@ public class StackValidator implements CommandValidator {
String stackName = clusterCommand.getStackName();
String stackVersion = clusterCommand.getStackVersion();
- StackPO stackPO = stackRepository.findByStackNameAndStackVersion(stackName, stackVersion);
+ StackPO stackPO = stackDao.findByStackNameAndStackVersion(stackName, stackVersion);
if (stackPO == null) {
throw new ApiException(ApiExceptionEnum.STACK_NOT_FOUND);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/EclipseLinkConfig.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/EclipseLinkConfig.java
deleted file mode 100644
index 96e612e..0000000
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/config/EclipseLinkConfig.java
+++ /dev/null
@@ -1,55 +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.config;
-
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
-import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
-import org.springframework.transaction.jta.JtaTransactionManager;
-
-import jakarta.annotation.Resource;
-import javax.sql.DataSource;
-import java.util.HashMap;
-import java.util.Map;
-
-@Configuration
-@ConditionalOnProperty(value = "bigtop.manager.orm.type", havingValue = "eclipselink", matchIfMissing = true)
-public class EclipseLinkConfig extends JpaBaseConfiguration {
-
- @Resource
- private JpaProperties properties;
-
- protected EclipseLinkConfig(DataSource ds, JpaProperties props, ObjectProvider<JtaTransactionManager> txm) {
- super(ds, props, txm);
- }
-
- @Override
- protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
- return new EclipseLinkJpaVendorAdapter();
- }
-
- @Override
- protected Map<String, Object> getVendorProperties() {
- return new HashMap<>(properties.getProperties());
- }
-}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ClusterConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ClusterConverter.java
index b093dfd..70f9093 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ClusterConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ClusterConverter.java
@@ -45,10 +45,10 @@ public interface ClusterConverter {
ClusterDTO fromPO2DTO(ClusterPO clusterPO);
- @Mapping(target = "stackName", source = "stackPO.stackName")
- @Mapping(target = "stackVersion", source = "stackPO.stackVersion")
ClusterVO fromEntity2VO(ClusterPO clusterPO);
- @Mapping(target = "stackPO", expression = "java(stackPO)")
+ @Mapping(target = "stackName", expression = "java(stackPO.getStackName())")
+ @Mapping(target = "stackVersion", expression = "java(stackPO.getStackVersion())")
+ @Mapping(target = "stackId", expression = "java(stackPO.getId())")
ClusterPO fromDTO2PO(ClusterDTO clusterDTO, StackDTO stackDTO, @Context StackPO stackPO);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ComponentConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ComponentConverter.java
index d630b2a..7a3cb2d 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ComponentConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ComponentConverter.java
@@ -43,8 +43,8 @@ public interface ComponentConverter {
@Mapping(target = "commandScript", source = "commandScript", qualifiedByName = "obj2Json")
@Mapping(target = "customCommands", source = "customCommands", qualifiedByName = "obj2Json")
@Mapping(target = "quickLink", source = "quickLink", qualifiedByName = "obj2Json")
- @Mapping(target = "servicePO", expression = "java(servicePO)")
- @Mapping(target = "clusterPO", expression = "java(clusterPO)")
+ @Mapping(target = "serviceId", expression = "java(servicePO.getId())")
+ @Mapping(target = "clusterId", expression = "java(clusterPO.getId())")
ComponentPO fromDTO2PO(ComponentDTO componentDTO, @Context ServicePO servicePO, @Context ClusterPO clusterPO);
ComponentVO fromDTO2VO(ComponentDTO componentDTO);
@@ -54,8 +54,6 @@ public interface ComponentConverter {
@Mapping(target = "componentName", source = "name")
ComponentDTO fromModel2DTO(ComponentModel componentModel);
- @Mapping(target = "serviceName", source = "servicePO.serviceName")
- @Mapping(target = "clusterName", source = "clusterPO.clusterName")
ComponentVO fromPO2VO(ComponentPO componentPO);
List<ComponentVO> fromPO2VO(List<ComponentPO> componentPOList);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostComponentConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostComponentConverter.java
index 1ed9df1..8d536dd 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostComponentConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostComponentConverter.java
@@ -23,7 +23,6 @@ import org.apache.bigtop.manager.server.config.MapStructSharedConfig;
import org.apache.bigtop.manager.server.model.vo.HostComponentVO;
import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -33,12 +32,6 @@ public interface HostComponentConverter {
HostComponentConverter INSTANCE = Mappers.getMapper(HostComponentConverter.class);
- @Mapping(target = "componentName", source = "componentPO.componentName")
- @Mapping(target = "displayName", source = "componentPO.displayName")
- @Mapping(target = "category", source = "componentPO.category")
- @Mapping(target = "serviceName", source = "componentPO.servicePO.serviceName")
- @Mapping(target = "clusterName", source = "componentPO.clusterPO.clusterName")
- @Mapping(target = "hostname", source = "hostPO.hostname")
HostComponentVO fromPO2VO(HostComponentPO hostComponentPO);
List<HostComponentVO> fromPO2VO(List<HostComponentPO> hostComponentPOList);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostConverter.java
index 175555b..66eeb12 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/HostConverter.java
@@ -25,7 +25,6 @@ import org.apache.bigtop.manager.server.model.req.HostReq;
import org.apache.bigtop.manager.server.model.vo.HostVO;
import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -39,7 +38,6 @@ public interface HostConverter {
HostPO fromDTO2PO(HostDTO hostDTO);
- @Mapping(target = "clusterName", source = "clusterPO.clusterName")
HostVO fromPO2VO(HostPO hostPO);
List<HostVO> fromPO2VO(List<HostPO> hostPOList);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/JobConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/JobConverter.java
index aaac4de..b526c79 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/JobConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/JobConverter.java
@@ -38,7 +38,6 @@ public interface JobConverter {
@Mapping(target = "createTime", source = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
@Mapping(target = "updateTime", source = "updateTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
- @Mapping(target = "stages", source = "stagePOList")
JobVO fromPO2VO(JobPO jobPO);
List<JobVO> fromPO2VO(List<JobPO> jobPO);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/RepoConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/RepoConverter.java
index 4f1e210..84599d0 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/RepoConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/RepoConverter.java
@@ -36,10 +36,10 @@ public interface RepoConverter {
RepoConverter INSTANCE = Mappers.getMapper(RepoConverter.class);
- @Mapping(target = "clusterPO", expression = "java(clusterPO)")
+ @Mapping(target = "clusterId", expression = "java(clusterPO.getId())")
RepoPO fromDTO2PO(RepoDTO repoDTO, @Context ClusterPO clusterPO);
- @Mapping(target = "clusterPO", expression = "java(clusterPO)")
+ @Mapping(target = "clusterId", expression = "java(clusterPO.getId())")
List<RepoPO> fromDTO2PO(List<RepoDTO> repoDTOList, @Context ClusterPO clusterPO);
RepoInfo fromPO2Message(RepoPO repoPO);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConfigConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConfigConverter.java
index a5a29f4..6a163a0 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConfigConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConfigConverter.java
@@ -23,7 +23,6 @@ import org.apache.bigtop.manager.server.config.MapStructSharedConfig;
import org.apache.bigtop.manager.server.model.vo.ServiceConfigVO;
import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -35,7 +34,6 @@ public interface ServiceConfigConverter {
ServiceConfigConverter INSTANCE = Mappers.getMapper(ServiceConfigConverter.class);
- @Mapping(target = "serviceName", source = "servicePO.serviceName")
ServiceConfigVO fromPO2VO(ServiceConfigPO serviceConfigPO);
List<ServiceConfigVO> fromPO2VO(List<ServiceConfigPO> serviceConfigPOList);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConverter.java
index 320f204..b12b852 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/ServiceConverter.java
@@ -43,7 +43,8 @@ public interface ServiceConverter {
@Mapping(target = "packageSpecifics", source = "packageSpecifics", qualifiedByName = "obj2Json")
@Mapping(target = "requiredServices", source = "requiredServices", qualifiedByName = "obj2Json")
- @Mapping(target = "clusterPO", expression = "java(clusterPO)")
+ @Mapping(target = "clusterId", expression = "java(clusterPO.getId())")
+ @Mapping(target = "components", ignore = true)
ServicePO fromDTO2PO(ServiceDTO serviceDTO, @Context ClusterPO clusterPO);
ServiceVO fromDTO2VO(ServiceDTO serviceDTO);
@@ -66,8 +67,7 @@ public interface ServiceConverter {
ServiceDTO fromModel2DTO(ServiceModel serviceModel);
@Mapping(target = "requiredServices", source = "requiredServices", qualifiedByName = "json2List")
- @Mapping(target = "clusterName", source = "clusterPO.clusterName")
- @Mapping(target = "serviceGroup", source = "clusterPO.userGroup")
+ @Mapping(target = "serviceGroup", source = "userGroup")
ServiceVO fromPO2VO(ServicePO servicePO);
List<ServiceVO> fromPO2VO(List<ServicePO> servicePOList);
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/StageConverter.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/StageConverter.java
index 65a4380..eb7b254 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/StageConverter.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/converter/StageConverter.java
@@ -35,6 +35,5 @@ public interface StageConverter {
@Mapping(target = "createTime", source = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
@Mapping(target = "updateTime", source = "updateTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
- @Mapping(target = "tasks", source = "taskPOList")
StageVO fromPO2VO(StagePO stagePO);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/query/PageQuery.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/query/PageQuery.java
index d33cd9a..03ac79a 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/query/PageQuery.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/query/PageQuery.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.query;
-import org.springframework.data.domain.Sort;
-
import lombok.Data;
@Data
@@ -29,5 +27,5 @@ public class PageQuery {
private Integer pageSize;
- private Sort sort;
+ private String orderBy;
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ClusterVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ClusterVO.java
index dca7b9f..d9c168a 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ClusterVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ClusterVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
@Data
@@ -37,5 +35,5 @@ public class ClusterVO {
private Boolean selected;
- private MaintainState state;
+ private String state;
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostComponentVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostComponentVO.java
index 8611000..4e06cc2 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostComponentVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostComponentVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
@Data
@@ -39,5 +37,5 @@ public class HostComponentVO {
private String hostname;
- private MaintainState state;
+ private String state;
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostVO.java
index 2a9c472..c52ea3e 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.MaintainState;
-
import lombok.Data;
@Data
@@ -49,5 +47,5 @@ public class HostVO {
private Long totalDisk;
- private MaintainState state;
+ private String state;
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/JobVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/JobVO.java
index 0998630..d36ed3a 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/JobVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/JobVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
import java.util.List;
@@ -31,7 +29,7 @@ public class JobVO {
private List<StageVO> stages;
- private JobState state;
+ private String state;
private String name;
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PageVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PageVO.java
index cd8cd56..d28dc05 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PageVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/PageVO.java
@@ -21,8 +21,8 @@ package org.apache.bigtop.manager.server.model.vo;
import org.apache.bigtop.manager.server.exception.ServerException;
import org.mapstruct.factory.Mappers;
-import org.springframework.data.domain.Page;
+import com.github.pagehelper.PageInfo;
import lombok.Data;
import java.lang.reflect.Method;
@@ -44,17 +44,17 @@ public class PageVO<T> {
}
@SuppressWarnings("unchecked")
- public static <T, S> PageVO<T> of(Page<S> page) {
+ public static <T, S> PageVO<T> of(PageInfo<S> page) {
List<T> content = new ArrayList<>();
if (page.hasContent()) {
try {
- Class<S> clz = (Class<S>) page.getContent().get(0).getClass();
+ Class<S> clz = (Class<S>) page.getList().get(0).getClass();
String className = "org.apache.bigtop.manager.server.model.converter."
+ clz.getSimpleName().replace("PO", "") + "Converter";
Class<?> mapper = Class.forName(className);
Object o = Mappers.getMapper(mapper);
Method method = o.getClass().getDeclaredMethod("fromPO2VO", List.class);
- content = (List<T>) method.invoke(o, page.getContent());
+ content = (List<T>) method.invoke(o, page.getList());
} catch (Exception e) {
throw new ServerException(e);
}
@@ -62,7 +62,7 @@ public class PageVO<T> {
PageVO<T> res = new PageVO<>();
res.setContent(content);
- res.setTotal(page.getTotalElements());
+ res.setTotal(page.getTotal());
return res;
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/StageVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/StageVO.java
index 302adef..f47429f 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/StageVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/StageVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
import java.util.List;
@@ -33,7 +31,7 @@ public class StageVO {
private List<TaskVO> tasks;
- private JobState state;
+ private String state;
private Integer order;
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TaskVO.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TaskVO.java
index 18208e0..78911ec 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TaskVO.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/TaskVO.java
@@ -18,8 +18,6 @@
*/
package org.apache.bigtop.manager.server.model.vo;
-import org.apache.bigtop.manager.common.enums.JobState;
-
import lombok.Data;
@Data
@@ -29,7 +27,7 @@ public class TaskVO {
private String name;
- private JobState state;
+ private String state;
private String hostname;
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/ComponentStatusScheduler.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/ComponentStatusScheduler.java
index 43882ab..4c0d99c 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/ComponentStatusScheduler.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/ComponentStatusScheduler.java
@@ -19,13 +19,8 @@
package org.apache.bigtop.manager.server.scheduler;
import org.apache.bigtop.manager.common.enums.MaintainState;
-import org.apache.bigtop.manager.dao.po.ClusterPO;
-import org.apache.bigtop.manager.dao.po.ComponentPO;
import org.apache.bigtop.manager.dao.po.HostComponentPO;
-import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.po.ServicePO;
-import org.apache.bigtop.manager.dao.po.StackPO;
-import org.apache.bigtop.manager.dao.repository.HostComponentRepository;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusReply;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusRequest;
import org.apache.bigtop.manager.grpc.generated.ComponentStatusServiceGrpc;
@@ -46,46 +41,43 @@ import java.util.concurrent.TimeUnit;
public class ComponentStatusScheduler {
@Resource
- private HostComponentRepository hostComponentRepository;
+ private HostComponentDao hostComponentDao;
@Async
@Scheduled(fixedDelay = 30, timeUnit = TimeUnit.SECONDS)
public void execute() {
- List<HostComponentPO> hostComponentPOList = hostComponentRepository.findAll();
+ List<HostComponentPO> hostComponentPOList = hostComponentDao.findAllJoin();
for (HostComponentPO hostComponentPO : hostComponentPOList) {
// Only check services which should be in running
- if (!List.of(MaintainState.STARTED, MaintainState.STOPPED).contains(hostComponentPO.getState())) {
+ if (!List.of(MaintainState.STARTED, MaintainState.STOPPED)
+ .contains(MaintainState.fromString(hostComponentPO.getState()))) {
continue;
}
- HostPO hostPO = hostComponentPO.getHostPO();
- ComponentPO componentPO = hostComponentPO.getComponentPO();
- ServicePO servicePO = componentPO.getServicePO();
- ClusterPO clusterPO = hostPO.getClusterPO();
- StackPO stackPO = clusterPO.getStackPO();
-
ComponentStatusRequest request = ComponentStatusRequest.newBuilder()
- .setServiceName(servicePO.getServiceName())
- .setServiceUser(servicePO.getServiceUser())
- .setComponentName(componentPO.getComponentName())
- .setCommandScript(componentPO.getCommandScript())
- .setRoot(clusterPO.getRoot())
- .setStackName(stackPO.getStackName())
- .setStackVersion(stackPO.getStackVersion())
+ .setServiceName(hostComponentPO.getServiceName())
+ .setServiceUser(hostComponentPO.getServiceUser())
+ .setComponentName(hostComponentPO.getComponentName())
+ .setCommandScript(hostComponentPO.getCommandScript())
+ .setRoot(hostComponentPO.getRoot())
+ .setStackName(hostComponentPO.getStackName())
+ .setStackVersion(hostComponentPO.getStackVersion())
.build();
ComponentStatusServiceGrpc.ComponentStatusServiceBlockingStub blockingStub = GrpcClient.getBlockingStub(
- hostPO.getHostname(), ComponentStatusServiceGrpc.ComponentStatusServiceBlockingStub.class);
+ hostComponentPO.getHostname(), ComponentStatusServiceGrpc.ComponentStatusServiceBlockingStub.class);
ComponentStatusReply reply = blockingStub.getComponentStatus(request);
// Status 0 means the service is running
- if (reply.getStatus() == 0 && hostComponentPO.getState() == MaintainState.STOPPED) {
- hostComponentPO.setState(MaintainState.STARTED);
- hostComponentRepository.save(hostComponentPO);
+ if (reply.getStatus() == 0
+ && MaintainState.fromString(hostComponentPO.getState()) == MaintainState.STOPPED) {
+ hostComponentPO.setState(MaintainState.STARTED.getName());
+ hostComponentDao.updateById(hostComponentPO);
}
- if (reply.getStatus() != 0 && hostComponentPO.getState() == MaintainState.STARTED) {
- hostComponentPO.setState(MaintainState.STOPPED);
- hostComponentRepository.save(hostComponentPO);
+ if (reply.getStatus() != 0
+ && MaintainState.fromString(hostComponentPO.getState()) == MaintainState.STARTED) {
+ hostComponentPO.setState(MaintainState.STOPPED.getName());
+ hostComponentDao.updateById(hostComponentPO);
}
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/HostInfoScheduler.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/HostInfoScheduler.java
index 7c0b937..f314661 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/HostInfoScheduler.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/scheduler/HostInfoScheduler.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.scheduler;
import org.apache.bigtop.manager.common.enums.MaintainState;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.grpc.generated.HostInfoReply;
import org.apache.bigtop.manager.grpc.generated.HostInfoRequest;
import org.apache.bigtop.manager.grpc.generated.HostInfoServiceGrpc;
@@ -41,12 +41,12 @@ import java.util.concurrent.TimeUnit;
public class HostInfoScheduler {
@Resource
- private HostRepository hostRepository;
+ private HostDao hostDao;
@Async
@Scheduled(fixedDelay = 30, timeUnit = TimeUnit.SECONDS)
public void execute() {
- List<HostPO> hostPOList = hostRepository.findAll();
+ List<HostPO> hostPOList = hostDao.findAll();
for (HostPO hostPO : hostPOList) {
getHostInfo(hostPO);
}
@@ -69,12 +69,12 @@ public class HostInfoScheduler {
hostPO.setFreeDisk(reply.getFreeDisk());
hostPO.setTotalDisk(reply.getTotalDisk());
- hostPO.setState(MaintainState.STARTED);
+ hostPO.setState(MaintainState.STARTED.getName());
} catch (Exception e) {
log.error("Error getting host info", e);
- hostPO.setState(MaintainState.STOPPED);
+ hostPO.setState(MaintainState.STOPPED.getName());
}
- hostRepository.save(hostPO);
+ hostDao.updateById(hostPO);
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ClusterServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ClusterServiceImpl.java
index 7b53820..19604a1 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ClusterServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ClusterServiceImpl.java
@@ -22,9 +22,9 @@ import org.apache.bigtop.manager.common.enums.MaintainState;
import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.RepoPO;
import org.apache.bigtop.manager.dao.po.StackPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.RepoRepository;
-import org.apache.bigtop.manager.dao.repository.StackRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
+import org.apache.bigtop.manager.dao.repository.RepoDao;
+import org.apache.bigtop.manager.dao.repository.StackDao;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.model.converter.ClusterConverter;
@@ -49,13 +49,13 @@ import java.util.List;
public class ClusterServiceImpl implements ClusterService {
@Resource
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
@Resource
- private RepoRepository repoRepository;
+ private RepoDao repoDao;
@Resource
- private StackRepository stackRepository;
+ private StackDao stackDao;
@Resource
private HostService hostService;
@@ -63,7 +63,7 @@ public class ClusterServiceImpl implements ClusterService {
@Override
public List<ClusterVO> list() {
List<ClusterVO> clusterVOList = new ArrayList<>();
- clusterRepository.findAll().forEach(cluster -> {
+ clusterDao.findAllByJoin().forEach(cluster -> {
ClusterVO clusterVO = ClusterConverter.INSTANCE.fromEntity2VO(cluster);
clusterVOList.add(clusterVO);
});
@@ -75,26 +75,28 @@ public class ClusterServiceImpl implements ClusterService {
public ClusterVO save(ClusterDTO clusterDTO) {
// Save cluster
StackPO stackPO =
- stackRepository.findByStackNameAndStackVersion(clusterDTO.getStackName(), clusterDTO.getStackVersion());
+ stackDao.findByStackNameAndStackVersion(clusterDTO.getStackName(), clusterDTO.getStackVersion());
StackDTO stackDTO = StackUtils.getStackKeyMap()
.get(StackUtils.fullStackName(clusterDTO.getStackName(), clusterDTO.getStackVersion()))
.getLeft();
ClusterPO clusterPO = ClusterConverter.INSTANCE.fromDTO2PO(clusterDTO, stackDTO, stackPO);
- clusterPO.setSelected(clusterRepository.count() == 0);
- clusterPO.setState(MaintainState.UNINSTALLED);
+ clusterPO.setSelected(clusterDao.count() == 0);
+ clusterPO.setState(MaintainState.UNINSTALLED.getName());
ClusterPO oldClusterPO =
- clusterRepository.findByClusterName(clusterDTO.getClusterName()).orElse(new ClusterPO());
+ clusterDao.findByClusterName(clusterDTO.getClusterName()).orElse(new ClusterPO());
if (oldClusterPO.getId() != null) {
clusterPO.setId(oldClusterPO.getId());
+ clusterDao.updateById(clusterPO);
+ } else {
+ clusterDao.save(clusterPO);
}
- clusterRepository.save(clusterPO);
hostService.batchSave(clusterPO.getId(), clusterDTO.getHostnames());
// Save repo
List<RepoPO> repoPOList = RepoConverter.INSTANCE.fromDTO2PO(clusterDTO.getRepoInfoList(), clusterPO);
- List<RepoPO> oldrepoPOList = repoRepository.findAllByClusterPO(clusterPO);
+ List<RepoPO> oldrepoPOList = repoDao.findAllByClusterId(clusterPO.getId());
for (RepoPO repoPO : repoPOList) {
for (RepoPO oldRepoPO : oldrepoPOList) {
@@ -105,14 +107,17 @@ public class ClusterServiceImpl implements ClusterService {
}
}
- repoRepository.saveAll(repoPOList);
+ repoDao.saveAll(repoPOList);
return ClusterConverter.INSTANCE.fromEntity2VO(clusterPO);
}
@Override
public ClusterVO get(Long id) {
- ClusterPO clusterPO =
- clusterRepository.findById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.CLUSTER_NOT_FOUND));
+ ClusterPO clusterPO = clusterDao.findByIdJoin(id);
+
+ if (clusterPO == null) {
+ throw new ApiException(ApiExceptionEnum.CLUSTER_NOT_FOUND);
+ }
return ClusterConverter.INSTANCE.fromEntity2VO(clusterPO);
}
@@ -121,7 +126,7 @@ public class ClusterServiceImpl implements ClusterService {
public ClusterVO update(Long id, ClusterDTO clusterDTO) {
ClusterPO clusterPO = ClusterConverter.INSTANCE.fromDTO2PO(clusterDTO);
clusterPO.setId(id);
- clusterRepository.save(clusterPO);
+ clusterDao.updateById(clusterPO);
return ClusterConverter.INSTANCE.fromEntity2VO(clusterPO);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandServiceImpl.java
index 64d8b02..9ebd0a6 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandServiceImpl.java
@@ -19,14 +19,12 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.common.enums.JobState;
-import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.JobPO;
import org.apache.bigtop.manager.dao.po.StagePO;
import org.apache.bigtop.manager.dao.po.TaskPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.JobRepository;
-import org.apache.bigtop.manager.dao.repository.StageRepository;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
+import org.apache.bigtop.manager.dao.repository.JobDao;
+import org.apache.bigtop.manager.dao.repository.StageDao;
+import org.apache.bigtop.manager.dao.repository.TaskDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.command.factory.JobFactories;
import org.apache.bigtop.manager.server.command.factory.JobFactory;
@@ -56,16 +54,13 @@ public class CommandServiceImpl implements CommandService {
private JobScheduler jobScheduler;
@Resource
- private ClusterRepository clusterRepository;
+ private JobDao jobDao;
@Resource
- private JobRepository jobRepository;
+ private StageDao stageDao;
@Resource
- private StageRepository stageRepository;
-
- @Resource
- private TaskRepository taskRepository;
+ private TaskDao taskDao;
@Override
public CommandVO command(CommandDTO commandDTO) {
@@ -94,30 +89,38 @@ public class CommandServiceImpl implements CommandService {
protected JobPO saveJob(Job job) {
Long clusterId = job.getJobContext().getCommandDTO().getClusterId();
- ClusterPO clusterPO = clusterId == null ? null : clusterRepository.getReferenceById(clusterId);
JobPO jobPO = job.getJobPO();
- jobPO.setClusterPO(clusterPO);
- jobPO.setState(JobState.PENDING);
- jobRepository.save(jobPO);
+ if (clusterId != null) {
+ jobPO.setClusterId(clusterId);
+ }
+ jobPO.setState(JobState.PENDING.getName());
+ jobDao.save(jobPO);
+ job.loadJobPO(jobPO);
for (int i = 0; i < job.getStages().size(); i++) {
Stage stage = job.getStages().get(i);
StagePO stagePO = stage.getStagePO();
- stagePO.setClusterPO(clusterPO);
- stagePO.setJobPO(jobPO);
+ if (clusterId != null) {
+ stagePO.setClusterId(clusterId);
+ }
+ stagePO.setJobId(jobPO.getId());
stagePO.setOrder(i + 1);
- stagePO.setState(JobState.PENDING);
- stageRepository.save(stagePO);
+ stagePO.setState(JobState.PENDING.getName());
+ stageDao.save(stagePO);
+ stage.loadStagePO(stagePO);
for (int j = 0; j < stage.getTasks().size(); j++) {
Task task = stage.getTasks().get(j);
TaskPO taskPO = task.getTaskPO();
- taskPO.setClusterPO(clusterPO);
- taskPO.setJobPO(jobPO);
- taskPO.setStagePO(stagePO);
- taskPO.setState(JobState.PENDING);
- taskRepository.save(taskPO);
+ if (clusterId != null) {
+ taskPO.setClusterId(clusterId);
+ }
+ taskPO.setJobId(jobPO.getId());
+ taskPO.setStageId(stagePO.getId());
+ taskPO.setState(JobState.PENDING.getName());
+ taskDao.save(taskPO);
+ task.loadTaskPO(taskPO);
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ComponentServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ComponentServiceImpl.java
index 20526c2..150de59 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ComponentServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ComponentServiceImpl.java
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.dao.po.ComponentPO;
-import org.apache.bigtop.manager.dao.repository.ComponentRepository;
+import org.apache.bigtop.manager.dao.repository.ComponentDao;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.model.converter.ComponentConverter;
@@ -39,12 +39,12 @@ import java.util.List;
public class ComponentServiceImpl implements ComponentService {
@Resource
- private ComponentRepository componentRepository;
+ private ComponentDao componentDao;
@Override
public List<ComponentVO> list(Long clusterId) {
List<ComponentVO> componentVOList = new ArrayList<>();
- componentRepository.findAllByClusterPOId(clusterId).forEach(component -> {
+ componentDao.findAllByClusterId(clusterId).forEach(component -> {
ComponentVO componentVO = ComponentConverter.INSTANCE.fromPO2VO(component);
componentVOList.add(componentVO);
});
@@ -54,8 +54,8 @@ public class ComponentServiceImpl implements ComponentService {
@Override
public ComponentVO get(Long id) {
- ComponentPO componentPO = componentRepository
- .findById(id)
+ ComponentPO componentPO = componentDao
+ .findOptionalById(id)
.orElseThrow(() -> new ApiException(ApiExceptionEnum.COMPONENT_NOT_FOUND));
return ComponentConverter.INSTANCE.fromPO2VO(componentPO);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ConfigServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ConfigServiceImpl.java
index e06500e..1f5ac9f 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ConfigServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ConfigServiceImpl.java
@@ -23,10 +23,10 @@ import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.ServiceConfigPO;
import org.apache.bigtop.manager.dao.po.ServicePO;
import org.apache.bigtop.manager.dao.po.TypeConfigPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceConfigRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceRepository;
-import org.apache.bigtop.manager.dao.repository.TypeConfigRepository;
+import org.apache.bigtop.manager.dao.repository.ClusterDao;
+import org.apache.bigtop.manager.dao.repository.ServiceConfigDao;
+import org.apache.bigtop.manager.dao.repository.ServiceDao;
+import org.apache.bigtop.manager.dao.repository.TypeConfigDao;
import org.apache.bigtop.manager.server.model.converter.ServiceConfigConverter;
import org.apache.bigtop.manager.server.model.converter.TypeConfigConverter;
import org.apache.bigtop.manager.server.model.dto.PropertyDTO;
@@ -34,7 +34,6 @@ import org.apache.bigtop.manager.server.model.dto.TypeConfigDTO;
import org.apache.bigtop.manager.server.model.vo.ServiceConfigVO;
import org.apache.bigtop.manager.server.service.ConfigService;
-import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
@@ -47,37 +46,34 @@ import java.util.List;
public class ConfigServiceImpl implements ConfigService {
@Resource
- private ClusterRepository clusterRepository;
+ private ClusterDao clusterDao;
@Resource
- private ServiceRepository serviceRepository;
+ private ServiceDao serviceDao;
@Resource
- private ServiceConfigRepository serviceConfigRepository;
+ private ServiceConfigDao serviceConfigDao;
@Resource
- private TypeConfigRepository typeConfigRepository;
+ private TypeConfigDao typeConfigDao;
@Override
public List<ServiceConfigVO> list(Long clusterId) {
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
- Sort sort = Sort.by(Sort.Direction.DESC, "version");
- List<ServiceConfigPO> list = serviceConfigRepository.findAllByClusterPO(clusterPO, sort);
+ List<ServiceConfigPO> list = serviceConfigDao.findAllByClusterId(clusterId);
return ServiceConfigConverter.INSTANCE.fromPO2VO(list);
}
@Override
public List<ServiceConfigVO> latest(Long clusterId) {
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
- List<ServiceConfigPO> list = serviceConfigRepository.findAllByClusterPOAndSelectedIsTrue(clusterPO);
+ List<ServiceConfigPO> list = serviceConfigDao.findAllByClusterIdAndSelectedIsTrue(clusterId);
return ServiceConfigConverter.INSTANCE.fromPO2VO(list);
}
@Override
public void upsert(Long clusterId, Long serviceId, List<TypeConfigDTO> configs) {
// Save configs
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
- ServicePO servicePO = serviceRepository.getReferenceById(serviceId);
+ ClusterPO clusterPO = clusterDao.findById(clusterId);
+ ServicePO servicePO = serviceDao.findById(serviceId);
ServiceConfigPO serviceCurrentConfig = findServiceCurrentConfig(clusterPO, servicePO);
if (serviceCurrentConfig == null) {
// Add config for new service
@@ -89,7 +85,7 @@ public class ConfigServiceImpl implements ConfigService {
}
private ServiceConfigPO findServiceCurrentConfig(ClusterPO clusterPO, ServicePO servicePO) {
- return serviceConfigRepository.findByClusterPOAndServicePOAndSelectedIsTrue(clusterPO, servicePO);
+ return serviceConfigDao.findByClusterIdAndServiceIdAndSelectedIsTrue(clusterPO.getId(), servicePO.getId());
}
private void upsertServiceConfig(
@@ -98,7 +94,7 @@ public class ConfigServiceImpl implements ConfigService {
if (shouldUpdateConfig(existConfigs, configs)) {
// Unselect current config
currentConfig.setSelected(false);
- serviceConfigRepository.save(currentConfig);
+ serviceConfigDao.updateById(currentConfig);
// Create a new config
String configDesc = "Update config for " + servicePO.getServiceName();
@@ -134,12 +130,12 @@ public class ConfigServiceImpl implements ConfigService {
private void addServiceConfig(
ClusterPO clusterPO, ServicePO servicePO, List<TypeConfigDTO> configs, String configDesc, Integer version) {
ServiceConfigPO serviceConfigPO = new ServiceConfigPO();
- serviceConfigPO.setClusterPO(clusterPO);
- serviceConfigPO.setServicePO(servicePO);
+ serviceConfigPO.setClusterId(clusterPO.getId());
+ serviceConfigPO.setServiceId(servicePO.getId());
serviceConfigPO.setConfigDesc(configDesc);
serviceConfigPO.setVersion(version);
serviceConfigPO.setSelected(true);
- serviceConfigRepository.save(serviceConfigPO);
+ serviceConfigDao.save(serviceConfigPO);
for (TypeConfigDTO typeConfigDTO : configs) {
String typeName = typeConfigDTO.getTypeName();
@@ -147,8 +143,8 @@ public class ConfigServiceImpl implements ConfigService {
TypeConfigPO typeConfigPO = new TypeConfigPO();
typeConfigPO.setTypeName(typeName);
typeConfigPO.setPropertiesJson(JsonUtils.writeAsString(properties));
- typeConfigPO.setServiceConfigPO(serviceConfigPO);
- typeConfigRepository.save(typeConfigPO);
+ typeConfigPO.setServiceConfigId(serviceConfigPO.getId());
+ typeConfigDao.save(typeConfigPO);
}
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostComponentServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostComponentServiceImpl.java
index 72b093e..b001b52 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostComponentServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostComponentServiceImpl.java
@@ -19,9 +19,7 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.dao.po.HostComponentPO;
-import org.apache.bigtop.manager.dao.repository.ComponentRepository;
-import org.apache.bigtop.manager.dao.repository.HostComponentRepository;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
import org.apache.bigtop.manager.server.model.converter.HostComponentConverter;
import org.apache.bigtop.manager.server.model.vo.HostComponentVO;
import org.apache.bigtop.manager.server.service.HostComponentService;
@@ -38,31 +36,24 @@ import java.util.List;
public class HostComponentServiceImpl implements HostComponentService {
@Resource
- private HostComponentRepository hostComponentRepository;
-
- @Resource
- private ComponentRepository componentRepository;
-
- @Resource
- private HostRepository hostRepository;
+ private HostComponentDao hostComponentDao;
@Override
public List<HostComponentVO> list(Long clusterId) {
- List<HostComponentPO> hostComponentPOList = hostComponentRepository.findAllByComponentPOClusterPOId(clusterId);
+ List<HostComponentPO> hostComponentPOList = hostComponentDao.findAllByClusterId(clusterId);
return HostComponentConverter.INSTANCE.fromPO2VO(hostComponentPOList);
}
@Override
public List<HostComponentVO> listByHost(Long clusterId, Long hostId) {
- List<HostComponentPO> hostComponentPOList =
- hostComponentRepository.findAllByComponentPOClusterPOIdAndHostPOId(clusterId, clusterId);
+ List<HostComponentPO> hostComponentPOList = hostComponentDao.findAllByClusterIdAndHostId(clusterId, hostId);
return HostComponentConverter.INSTANCE.fromPO2VO(hostComponentPOList);
}
@Override
public List<HostComponentVO> listByService(Long clusterId, Long serviceId) {
List<HostComponentPO> hostComponentPOList =
- hostComponentRepository.findAllByComponentPOClusterPOIdAndComponentPOServicePOId(clusterId, serviceId);
+ hostComponentDao.findAllByClusterIdAndServiceId(clusterId, serviceId);
return HostComponentConverter.INSTANCE.fromPO2VO(hostComponentPOList);
}
}
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 2cdfc97..7127d0e 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
@@ -19,10 +19,8 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.common.enums.MaintainState;
-import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.HostPO;
-import org.apache.bigtop.manager.dao.repository.ClusterRepository;
-import org.apache.bigtop.manager.dao.repository.HostRepository;
+import org.apache.bigtop.manager.dao.repository.HostDao;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.grpc.GrpcClient;
@@ -48,14 +46,11 @@ import java.util.stream.Collectors;
public class HostServiceImpl implements HostService {
@Resource
- private ClusterRepository clusterRepository;
-
- @Resource
- private HostRepository hostRepository;
+ private HostDao hostDao;
@Override
public List<HostVO> list(Long clusterId) {
- List<HostPO> hostPOList = hostRepository.findAllByClusterPOId(clusterId);
+ List<HostPO> hostPOList = hostDao.findAllByClusterId(clusterId);
if (CollectionUtils.isEmpty(hostPOList)) {
throw new ApiException(ApiExceptionEnum.HOST_NOT_FOUND);
}
@@ -65,9 +60,8 @@ public class HostServiceImpl implements HostService {
@Override
public List<HostVO> batchSave(Long clusterId, List<String> hostnames) {
- ClusterPO clusterPO = clusterRepository.getReferenceById(clusterId);
- List<HostPO> hostnameIn = hostRepository.findAllByHostnameIn(hostnames);
+ List<HostPO> hostnameIn = hostDao.findAllByHostnameIn(hostnames);
List<HostPO> hostPOList = new ArrayList<>();
Map<String, HostPO> hostInMap =
@@ -76,8 +70,8 @@ public class HostServiceImpl implements HostService {
for (String hostname : hostnames) {
HostPO hostPO = new HostPO();
hostPO.setHostname(hostname);
- hostPO.setClusterPO(clusterPO);
- hostPO.setState(MaintainState.INSTALLED);
+ hostPO.setClusterId(clusterId);
+ hostPO.setState(MaintainState.INSTALLED.getName());
if (hostInMap.containsKey(hostname)) {
hostPO.setId(hostInMap.get(hostname).getId());
@@ -86,15 +80,17 @@ public class HostServiceImpl implements HostService {
hostPOList.add(hostPO);
}
- hostRepository.saveAll(hostPOList);
+ hostDao.saveAll(hostPOList);
return HostConverter.INSTANCE.fromPO2VO(hostPOList);
}
@Override
public HostVO get(Long id) {
- HostPO hostPO =
- hostRepository.findById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.HOST_NOT_FOUND));
+ HostPO hostPO = hostDao.findByIdJoin(id);
+ if (hostPO == null) {
+ throw new ApiException(ApiExceptionEnum.HOST_NOT_FOUND);
+ }
return HostConverter.INSTANCE.fromPO2VO(hostPO);
}
@@ -103,14 +99,14 @@ public class HostServiceImpl implements HostService {
public HostVO update(Long id, HostDTO hostDTO) {
HostPO hostPO = HostConverter.INSTANCE.fromDTO2PO(hostDTO);
hostPO.setId(id);
- hostRepository.save(hostPO);
+ hostDao.updateById(hostPO);
return HostConverter.INSTANCE.fromPO2VO(hostPO);
}
@Override
public Boolean delete(Long id) {
- hostRepository.deleteById(id);
+ hostDao.deleteById(id);
return true;
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java
index 05aa6de..820eab3 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java
@@ -23,9 +23,9 @@ import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.dao.po.JobPO;
import org.apache.bigtop.manager.dao.po.StagePO;
import org.apache.bigtop.manager.dao.po.TaskPO;
-import org.apache.bigtop.manager.dao.repository.JobRepository;
-import org.apache.bigtop.manager.dao.repository.StageRepository;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
+import org.apache.bigtop.manager.dao.repository.JobDao;
+import org.apache.bigtop.manager.dao.repository.StageDao;
+import org.apache.bigtop.manager.dao.repository.TaskDao;
import org.apache.bigtop.manager.server.command.CommandIdentifier;
import org.apache.bigtop.manager.server.command.factory.JobFactories;
import org.apache.bigtop.manager.server.command.factory.JobFactory;
@@ -44,11 +44,11 @@ import org.apache.bigtop.manager.server.service.JobService;
import org.apache.bigtop.manager.server.utils.ClusterUtils;
import org.apache.bigtop.manager.server.utils.PageUtils;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+
import jakarta.annotation.Resource;
import java.util.List;
@@ -56,13 +56,13 @@ import java.util.List;
public class JobServiceImpl implements JobService {
@Resource
- private JobRepository jobRepository;
+ private JobDao jobDao;
@Resource
- private StageRepository stageRepository;
+ private StageDao stageDao;
@Resource
- private TaskRepository taskRepository;
+ private TaskDao taskDao;
@Resource
private JobScheduler jobScheduler;
@@ -70,27 +70,29 @@ public class JobServiceImpl implements JobService {
@Override
public PageVO<JobVO> list(Long clusterId) {
PageQuery pageQuery = PageUtils.getPageQuery();
- Pageable pageable = PageRequest.of(pageQuery.getPageNum(), pageQuery.getPageSize(), pageQuery.getSort());
- Page<JobPO> page;
+
+ PageHelper.startPage(pageQuery.getPageNum(), pageQuery.getPageSize(), pageQuery.getOrderBy());
+ List<JobPO> jobPOList;
if (ClusterUtils.isNoneCluster(clusterId)) {
- page = jobRepository.findAllByClusterPOIsNull(pageable);
+ jobPOList = jobDao.findAllByClusterIsNull();
} else {
- page = jobRepository.findAllByClusterPOId(clusterId, pageable);
+ jobPOList = jobDao.findAllByClusterId(clusterId);
}
+ PageInfo<JobPO> pageInfo = new PageInfo<>(jobPOList);
- return PageVO.of(page);
+ return PageVO.of(pageInfo);
}
@Override
public JobVO get(Long id) {
- JobPO jobPO = jobRepository.getReferenceById(id);
+ JobPO jobPO = jobDao.findByIdJoin(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.JOB_NOT_FOUND));
return JobConverter.INSTANCE.fromPO2VO(jobPO);
}
@Override
public JobVO retry(Long id) {
- JobPO jobPO = jobRepository.getReferenceById(id);
- if (jobPO.getState() != JobState.FAILED) {
+ JobPO jobPO = jobDao.findByIdJoin(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.JOB_NOT_FOUND));
+ if (JobState.fromString(jobPO.getState()) != JobState.FAILED) {
throw new ApiException(ApiExceptionEnum.JOB_NOT_RETRYABLE);
}
@@ -102,18 +104,18 @@ public class JobServiceImpl implements JobService {
}
private void resetJobStatusInDB(JobPO jobPO) {
- for (StagePO stagePO : jobPO.getStagePOList()) {
- for (TaskPO taskPO : stagePO.getTaskPOList()) {
- taskPO.setState(JobState.PENDING);
- taskRepository.save(taskPO);
+ for (StagePO stagePO : jobPO.getStages()) {
+ for (TaskPO taskPO : stagePO.getTasks()) {
+ taskPO.setState(JobState.PENDING.getName());
+ taskDao.updateById(taskPO);
}
- stagePO.setState(JobState.PENDING);
- stageRepository.save(stagePO);
+ stagePO.setState(JobState.PENDING.getName());
+ stageDao.updateById(stagePO);
}
- jobPO.setState(JobState.PENDING);
- jobRepository.save(jobPO);
+ jobPO.setState(JobState.PENDING.getName());
+ jobDao.updateById(jobPO);
}
private Job recreateJob(JobPO jobPO) {
@@ -127,7 +129,7 @@ public class JobServiceImpl implements JobService {
job.loadJobPO(jobPO);
for (int i = 0; i < job.getStages().size(); i++) {
Stage stage = job.getStages().get(i);
- StagePO stagePO = findCorrectStagePO(jobPO.getStagePOList(), i + 1);
+ StagePO stagePO = findCorrectStagePO(jobPO.getStages(), i + 1);
if (stagePO == null) {
throw new ApiException(ApiExceptionEnum.JOB_NOT_RETRYABLE);
}
@@ -137,7 +139,7 @@ public class JobServiceImpl implements JobService {
for (int j = 0; j < stage.getTasks().size(); j++) {
Task task = stage.getTasks().get(j);
TaskPO taskPO = findCorrectTaskPO(
- stagePO.getTaskPOList(), task.getTaskContext().getHostname());
+ stagePO.getTasks(), task.getTaskContext().getHostname());
if (taskPO == null) {
throw new ApiException(ApiExceptionEnum.JOB_NOT_RETRYABLE);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LoginServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LoginServiceImpl.java
index 2d8ac25..a88c022 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LoginServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LoginServiceImpl.java
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.dao.po.UserPO;
-import org.apache.bigtop.manager.dao.repository.UserRepository;
+import org.apache.bigtop.manager.dao.repository.UserDao;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.model.dto.LoginDTO;
@@ -35,11 +35,11 @@ import jakarta.annotation.Resource;
public class LoginServiceImpl implements LoginService {
@Resource
- private UserRepository userRepository;
+ private UserDao userDao;
@Override
public LoginVO login(LoginDTO loginDTO) {
- UserPO userPO = userRepository.findByUsername(loginDTO.getUsername());
+ UserPO userPO = userDao.findByUsername(loginDTO.getUsername());
if (userPO == null || !loginDTO.getPassword().equalsIgnoreCase(userPO.getPassword())) {
throw new ApiException(ApiExceptionEnum.INCORRECT_USERNAME_OR_PASSWORD);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
index e3643be..73df785 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
@@ -21,16 +21,16 @@ package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.common.constants.ComponentCategories;
import org.apache.bigtop.manager.common.enums.MaintainState;
import org.apache.bigtop.manager.common.utils.JsonUtils;
-import org.apache.bigtop.manager.dao.po.ClusterPO;
import org.apache.bigtop.manager.dao.po.ComponentPO;
import org.apache.bigtop.manager.dao.po.HostComponentPO;
-import org.apache.bigtop.manager.dao.po.HostPO;
import org.apache.bigtop.manager.dao.po.ServiceConfigPO;
import org.apache.bigtop.manager.dao.po.ServicePO;
import org.apache.bigtop.manager.dao.po.TypeConfigPO;
-import org.apache.bigtop.manager.dao.repository.HostComponentRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceConfigRepository;
-import org.apache.bigtop.manager.dao.repository.ServiceRepository;
+import org.apache.bigtop.manager.dao.repository.HostComponentDao;
+import org.apache.bigtop.manager.dao.repository.ServiceConfigDao;
+import org.apache.bigtop.manager.dao.repository.ServiceDao;
+import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
+import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.model.converter.ServiceConverter;
import org.apache.bigtop.manager.server.model.converter.TypeConfigConverter;
import org.apache.bigtop.manager.server.model.dto.PropertyDTO;
@@ -57,51 +57,50 @@ import java.util.stream.Collectors;
public class ServiceServiceImpl implements ServiceService {
@Resource
- private ServiceRepository serviceRepository;
+ private ServiceDao serviceDao;
@Resource
- private HostComponentRepository hostComponentRepository;
+ private HostComponentDao hostComponentDao;
@Resource
- private ServiceConfigRepository serviceConfigRepository;
+ private ServiceConfigDao serviceConfigDao;
@Override
public List<ServiceVO> list(Long clusterId) {
List<ServiceVO> res = new ArrayList<>();
+
+ List<ServicePO> servicePOList = serviceDao.findAllByClusterId(clusterId);
+ List<HostComponentPO> allByClusterId = hostComponentDao.findAllByClusterId(clusterId);
Map<Long, List<HostComponentPO>> serviceIdToHostComponent =
- hostComponentRepository.findAllByComponentPOClusterPOId(clusterId).stream()
- .collect(Collectors.groupingBy(hostComponent ->
- hostComponent.getComponentPO().getServicePO().getId()));
+ allByClusterId.stream().collect(Collectors.groupingBy(HostComponentPO::getServiceId));
+ Map<Long, List<HostComponentPO>> componentIdToHostComponent =
+ allByClusterId.stream().collect(Collectors.groupingBy(HostComponentPO::getComponentId));
- for (Map.Entry<Long, List<HostComponentPO>> entry : serviceIdToHostComponent.entrySet()) {
- List<HostComponentPO> hostComponentPOList = entry.getValue();
- ServicePO servicePO = hostComponentPOList.get(0).getComponentPO().getServicePO();
+ for (ServicePO servicePO : servicePOList) {
+ Long serviceId = servicePO.getId();
ServiceVO serviceVO = ServiceConverter.INSTANCE.fromPO2VO(servicePO);
+ List<ComponentPO> components = servicePO.getComponents();
serviceVO.setQuickLinks(new ArrayList<>());
- boolean isHealthy = true;
- boolean isClient = true;
- for (HostComponentPO hostComponentPO : hostComponentPOList) {
- ComponentPO componentPO = hostComponentPO.getComponentPO();
+ for (ComponentPO componentPO : components) {
+ Long componentId = componentPO.getId();
+ List<HostComponentPO> hostComponentPOList = componentIdToHostComponent.get(componentId);
String quickLink = componentPO.getQuickLink();
if (StringUtils.isNotBlank(quickLink)) {
- QuickLinkVO quickLinkVO = resolveQuickLink(hostComponentPO, quickLink);
- serviceVO.getQuickLinks().add(quickLinkVO);
- }
-
- String category = componentPO.getCategory();
- if (!category.equalsIgnoreCase(ComponentCategories.CLIENT)) {
- isClient = false;
+ List<QuickLinkVO> quickLinkVOList =
+ resolveQuickLink(hostComponentPOList, quickLink, clusterId, serviceId);
+ serviceVO.getQuickLinks().addAll(quickLinkVOList);
}
-
- MaintainState expectedState = category.equalsIgnoreCase(ComponentCategories.CLIENT)
+ }
+ boolean isClient = components.stream()
+ .allMatch(componentPO -> componentPO.getCategory().equalsIgnoreCase(ComponentCategories.CLIENT));
+ boolean isHealthy = serviceIdToHostComponent.get(serviceId).stream().allMatch(hostComponentPO -> {
+ MaintainState expectedState = hostComponentPO.getCategory().equalsIgnoreCase(ComponentCategories.CLIENT)
? MaintainState.INSTALLED
: MaintainState.STARTED;
- if (!hostComponentPO.getState().equals(expectedState)) {
- isHealthy = false;
- }
- }
+ return hostComponentPO.getState().equals(expectedState.getName());
+ });
serviceVO.setIsClient(isClient);
serviceVO.setIsHealthy(isHealthy);
@@ -113,41 +112,43 @@ public class ServiceServiceImpl implements ServiceService {
@Override
public ServiceVO get(Long id) {
- ServicePO servicePO = serviceRepository.findById(id).orElse(new ServicePO());
+ ServicePO servicePO =
+ serviceDao.findByIdJoin(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.SERVICE_NOT_FOUND));
return ServiceConverter.INSTANCE.fromPO2VO(servicePO);
}
- private QuickLinkVO resolveQuickLink(HostComponentPO hostComponentPO, String quickLinkJson) {
- QuickLinkVO quickLinkVO = new QuickLinkVO();
+ private List<QuickLinkVO> resolveQuickLink(
+ List<HostComponentPO> hostComponentPOList, String quickLinkJson, Long clusterId, Long serviceId) {
+ List<QuickLinkVO> quickLinkVOList = new ArrayList<>();
QuickLinkDTO quickLinkDTO = JsonUtils.readFromString(quickLinkJson, QuickLinkDTO.class);
- quickLinkVO.setDisplayName(quickLinkDTO.getDisplayName());
- ComponentPO componentPO = hostComponentPO.getComponentPO();
- ClusterPO clusterPO = componentPO.getClusterPO();
- HostPO hostPO = hostComponentPO.getHostPO();
- ServicePO servicePO = componentPO.getServicePO();
ServiceConfigPO serviceConfigPO =
- serviceConfigRepository.findByClusterPOAndServicePOAndSelectedIsTrue(clusterPO, servicePO);
+ serviceConfigDao.findByClusterIdAndServiceIdAndSelectedIsTrue(clusterId, serviceId);
List<TypeConfigPO> typeConfigPOList = serviceConfigPO.getConfigs();
+ String httpPort = quickLinkDTO.getHttpPortDefault();
// Use HTTP for now, need to handle https in the future
for (TypeConfigPO typeConfigPO : typeConfigPOList) {
TypeConfigDTO typeConfigDTO = TypeConfigConverter.INSTANCE.fromPO2DTO(typeConfigPO);
for (PropertyDTO propertyDTO : typeConfigDTO.getProperties()) {
if (propertyDTO.getName().equals(quickLinkDTO.getHttpPortProperty())) {
- String port = propertyDTO.getValue().contains(":")
+
+ httpPort = propertyDTO.getValue().contains(":")
? propertyDTO.getValue().split(":")[1]
: propertyDTO.getValue();
- String url = "http://" + hostPO.getHostname() + ":" + port;
- quickLinkVO.setUrl(url);
- return quickLinkVO;
}
}
}
- String url = "http://" + hostPO.getHostname() + ":" + quickLinkDTO.getHttpPortDefault();
- quickLinkVO.setUrl(url);
- return quickLinkVO;
+ for (HostComponentPO hostComponentPO : hostComponentPOList) {
+ QuickLinkVO quickLinkVO = new QuickLinkVO();
+ quickLinkVO.setDisplayName(quickLinkDTO.getDisplayName());
+ String url = "http://" + hostComponentPO.getHostname() + ":" + httpPort;
+ quickLinkVO.setUrl(url);
+ quickLinkVOList.add(quickLinkVO);
+ }
+
+ return quickLinkVOList;
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/TaskLogServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/TaskLogServiceImpl.java
index 62b5613..be24d94 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/TaskLogServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/TaskLogServiceImpl.java
@@ -20,7 +20,7 @@ package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.common.enums.JobState;
import org.apache.bigtop.manager.dao.po.TaskPO;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
+import org.apache.bigtop.manager.dao.repository.TaskDao;
import org.apache.bigtop.manager.grpc.generated.TaskLogReply;
import org.apache.bigtop.manager.grpc.generated.TaskLogRequest;
import org.apache.bigtop.manager.grpc.generated.TaskLogServiceGrpc;
@@ -38,16 +38,17 @@ import jakarta.annotation.Resource;
public class TaskLogServiceImpl implements TaskLogService {
@Resource
- private TaskRepository taskRepository;
+ private TaskDao taskDao;
public void registerSink(Long taskId, FluxSink<String> sink) {
- TaskPO taskPO = taskRepository.getReferenceById(taskId);
+ TaskPO taskPO = taskDao.findById(taskId);
String hostname = taskPO.getHostname();
- if (taskPO.getState() == JobState.PENDING || taskPO.getState() == JobState.CANCELED) {
+ if (JobState.fromString(taskPO.getState()) == JobState.PENDING
+ || JobState.fromString(taskPO.getState()) == JobState.CANCELED) {
new Thread(() -> {
sink.next("There is no log when task is in status: "
- + taskPO.getState().name().toLowerCase()
+ + taskPO.getState().toLowerCase()
+ ", please reopen the window when status changed");
sink.complete();
})
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/UserServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/UserServiceImpl.java
index c8165fc..eaa01d2 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/UserServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/UserServiceImpl.java
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.service.impl;
import org.apache.bigtop.manager.dao.po.UserPO;
-import org.apache.bigtop.manager.dao.repository.UserRepository;
+import org.apache.bigtop.manager.dao.repository.UserDao;
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum;
import org.apache.bigtop.manager.server.exception.ApiException;
import org.apache.bigtop.manager.server.holder.SessionUserHolder;
@@ -36,21 +36,21 @@ import jakarta.annotation.Resource;
public class UserServiceImpl implements UserService {
@Resource
- private UserRepository userRepository;
+ private UserDao userDao;
@Override
public UserVO current() {
Long id = SessionUserHolder.getUserId();
- UserPO userPO = userRepository.findById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.NEED_LOGIN));
+ UserPO userPO = userDao.findOptionalById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.NEED_LOGIN));
return UserConverter.INSTANCE.fromPO2VO(userPO);
}
@Override
public UserVO update(UserDTO userDTO) {
Long id = SessionUserHolder.getUserId();
- UserPO userPO = userRepository.findById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.NEED_LOGIN));
+ UserPO userPO = userDao.findOptionalById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.NEED_LOGIN));
userPO.setNickname(userDTO.getNickname());
- userRepository.save(userPO);
+ userDao.updateById(userPO);
return UserConverter.INSTANCE.fromPO2VO(userPO);
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/StackInitializer.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/StackInitializer.java
index b3c76c8..3604ba7 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/StackInitializer.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/stack/StackInitializer.java
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.stack;
import org.apache.bigtop.manager.dao.po.StackPO;
-import org.apache.bigtop.manager.dao.repository.StackRepository;
+import org.apache.bigtop.manager.dao.repository.StackDao;
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;
@@ -46,7 +46,7 @@ import java.util.Map;
public class StackInitializer implements ApplicationListener<ApplicationStartedEvent> {
@Resource
- private StackRepository stackRepository;
+ private StackDao stackDao;
@Override
public void onApplicationEvent(@Nonnull ApplicationStartedEvent event) {
@@ -58,13 +58,13 @@ public class StackInitializer implements ApplicationListener<ApplicationStartedE
String stackName = stackDTO.getStackName();
String stackVersion = stackDTO.getStackVersion();
- StackPO stackPO = stackRepository.findByStackNameAndStackVersion(stackName, stackVersion);
+ StackPO stackPO = stackDao.findByStackNameAndStackVersion(stackName, stackVersion);
if (stackPO == null) {
stackPO = new StackPO();
stackPO.setStackName(stackName);
stackPO.setStackVersion(stackVersion);
- stackRepository.save(stackPO);
+ stackDao.save(stackPO);
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/PageUtils.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/PageUtils.java
index 1c8d0f3..34e2c50 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/PageUtils.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/PageUtils.java
@@ -23,8 +23,6 @@ import org.apache.bigtop.manager.server.model.query.PageQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
-import org.springframework.data.domain.Sort;
-
public class PageUtils {
private static final String PAGE_NUM = "pageNum";
@@ -47,15 +45,15 @@ public class PageUtils {
public static PageQuery getPageQuery() {
PageQuery query = new PageQuery();
- query.setPageNum(NumberUtils.toInt(ServletUtils.getParameter(PAGE_NUM), DEFAULT_PAGE_NUM) - 1);
+ query.setPageNum(NumberUtils.toInt(ServletUtils.getParameter(PAGE_NUM), DEFAULT_PAGE_NUM));
query.setPageSize(NumberUtils.toInt(ServletUtils.getParameter(PAGE_SIZE), DEFAULT_PAGE_SIZE));
String orderBy = StringUtils.defaultIfBlank(ServletUtils.getParameter(ORDER_BY), DEFAULT_ORDER_BY);
String sort = StringUtils.defaultIfBlank(ServletUtils.getParameter(SORT), SORT_ASC);
if (SORT_DESC.equals(sort)) {
- query.setSort(Sort.by(orderBy).descending());
+ query.setOrderBy(orderBy + " DESC ");
} else {
- query.setSort(Sort.by(orderBy).ascending());
+ query.setOrderBy(orderBy + " ASC ");
}
return query;
diff --git a/bigtop-manager-server/src/main/resources/application.yml b/bigtop-manager-server/src/main/resources/application.yml
index 8cb54a7..f394fbd 100644
--- a/bigtop-manager-server/src/main/resources/application.yml
+++ b/bigtop-manager-server/src/main/resources/application.yml
@@ -19,9 +19,6 @@
bigtop:
manager:
- orm:
- # hibernate/eclipselink(default=eclipselink)
- type: eclipselink
grpc:
port: 8835
@@ -54,29 +51,6 @@ spring:
jackson:
default-property-inclusion: non-null
- jpa:
- show-sql: true
- properties:
- eclipselink:
- ddl-generation: create-or-extend-tables
- weaving: false
- persistence-context:
- persist-on-commit: false
- cache:
- shared:
- default: false
- logging:
- connection: false
- logger: org.eclipse.persistence.logging.slf4j.SLF4JLogger
- parameters: true
- session: false
- thread: false
- timestamp: false
- level:
- connection: FINE
- sql: FINEST
- jpa: FINER
-
messages:
basename: i18n/messages
@@ -90,4 +64,16 @@ springdoc:
monitoring:
prometheus-host: "http://localhost:9090"
- agent-host-job-name: "bm-agent-host"
\ No newline at end of file
+ agent-host-job-name: "bm-agent-host"
+
+mybatis:
+ mapper-locations: classpath*:mapper/**/*Mapper.xml
+ configuration:
+ map-underscore-to-camel-case: true
+ database-id: mysql
+ use-generated-keys: true
+
+pagehelper:
+ reasonable: false
+ supportMethodsArguments: true
+ params: count=countSql
\ No newline at end of file
diff --git a/bigtop-manager-server/src/main/resources/assembly/server.xml b/bigtop-manager-server/src/main/resources/assembly/server.xml
index 3049ca5..c8f303f 100644
--- a/bigtop-manager-server/src/main/resources/assembly/server.xml
+++ b/bigtop-manager-server/src/main/resources/assembly/server.xml
@@ -47,6 +47,10 @@
<fileMode>0755</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
+ <fileSet>
+ <directory>${basedir}/src/main/resources/ddl</directory>
+ <outputDirectory>ddl</outputDirectory>
+ </fileSet>
<fileSet>
<directory>${basedir}/../bigtop-manager-ui/dist</directory>
<outputDirectory>./ui</outputDirectory>
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 ba9147f..94a4ab5 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
@@ -38,7 +38,7 @@ DEALLOCATE PREPARE statement;
CREATE TABLE `audit_log`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`args` LONGTEXT,
`create_by` BIGINT,
`create_time` DATETIME,
@@ -53,15 +53,6 @@ CREATE TABLE `audit_log`
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-CREATE TABLE `sequence`
-(
- `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
- `seq_name` VARCHAR(100) NOT NULL,
- `seq_count` BIGINT(20) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `uk_seq_name` (`seq_name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
CREATE TABLE `user`
(
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -95,12 +86,13 @@ CREATE TABLE `cluster`
`user_group` VARCHAR(255),
`stack_id` BIGINT,
PRIMARY KEY (`id`),
- UNIQUE KEY `uk_cluster_name` (`cluster_name`)
+ UNIQUE KEY `uk_cluster_name` (`cluster_name`),
+ KEY `idx_cluster_stack_id` (`stack_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `component`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`category` VARCHAR(255),
`command_script` VARCHAR(255),
`component_name` VARCHAR(255),
@@ -109,6 +101,7 @@ CREATE TABLE `component`
`custom_commands` LONGTEXT,
`display_name` VARCHAR(255),
`quick_link` VARCHAR(255),
+ `cardinality` VARCHAR(255),
`update_by` BIGINT,
`update_time` DATETIME,
`cluster_id` BIGINT,
@@ -121,7 +114,7 @@ CREATE TABLE `component`
CREATE TABLE `host_component`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`create_by` BIGINT,
`create_time` DATETIME,
`state` VARCHAR(255),
@@ -156,7 +149,8 @@ CREATE TABLE `host`
`total_memory_size` BIGINT,
`update_by` BIGINT,
PRIMARY KEY (`id`),
- UNIQUE KEY `uk_hostname` (`hostname`)
+ UNIQUE KEY `uk_hostname` (`hostname`, `cluster_id`),
+ KEY `idx_host_cluster_id` (cluster_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `repo`
@@ -187,17 +181,13 @@ CREATE TABLE `stack`
`update_time` DATETIME DEFAULT NULL,
`create_by` BIGINT,
`update_by` BIGINT,
- `component_name` VARCHAR(255),
- `context` LONGTEXT,
- `order` INTEGER,
- `service_name` VARCHAR(255),
PRIMARY KEY (`id`),
UNIQUE KEY `uk_stack` (`stack_name`, `stack_version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `task`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`command` VARCHAR(255),
`component_name` VARCHAR(255),
`content` LONGTEXT,
@@ -240,7 +230,7 @@ CREATE TABLE `job`
CREATE TABLE `type_config`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`create_by` BIGINT,
`create_time` DATETIME,
`properties_json` LONGTEXT,
@@ -253,7 +243,7 @@ CREATE TABLE `type_config`
CREATE TABLE `service`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`create_by` BIGINT,
`create_time` DATETIME,
`display_name` VARCHAR(255),
@@ -273,7 +263,7 @@ CREATE TABLE `service`
CREATE TABLE `service_config`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`config_desc` VARCHAR(255),
`create_by` BIGINT,
`create_time` DATETIME,
@@ -290,7 +280,7 @@ CREATE TABLE `service_config`
CREATE TABLE `setting`
(
- `id` BIGINT NOT NULL,
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
`config_data` LONGTEXT,
`create_by` BIGINT,
`create_time` DATETIME,
@@ -307,7 +297,6 @@ CREATE TABLE `stage`
`cluster_id` BIGINT(20) UNSIGNED DEFAULT NULL,
`job_id` BIGINT(20) UNSIGNED NOT NULL,
`state` VARCHAR(32) NOT NULL,
- `stage_order` INT UNSIGNED DEFAULT NULL,
`create_time` DATETIME DEFAULT NULL,
`update_time` DATETIME DEFAULT NULL,
`component_name` VARCHAR(255),
@@ -321,24 +310,6 @@ CREATE TABLE `stage`
KEY `idx_job_id` (`job_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--- Initialize sequence table.
-INSERT INTO sequence(seq_name, seq_count)
-VALUES ('audit_log_generator', 0),
- ('cluster_generator', 0),
- ('stack_generator', 0),
- ('service_generator', 0),
- ('task_generator', 0),
- ('host_generator', 0),
- ('user_generator', 0),
- ('repo_generator', 0),
- ('host_component_generator', 0),
- ('service_config_generator', 0),
- ('job_generator', 0),
- ('type_config_generator', 0),
- ('component_generator', 0),
- ('stage_generator', 0),
- ('settings_generator', 0);
-
-- Adding default admin user
INSERT INTO bigtop_manager.user (id, create_time, update_time, nickname, password, status, username)
VALUES (1, now(), now(), 'Administrator', '21232f297a57a5a743894a0e4a801fc3', true, 'admin');
\ No newline at end of file
diff --git a/bigtop-manager-server/src/main/resources/logback-spring.xml b/bigtop-manager-server/src/main/resources/logback-spring.xml
index 4a42d85..0da8ba3 100644
--- a/bigtop-manager-server/src/main/resources/logback-spring.xml
+++ b/bigtop-manager-server/src/main/resources/logback-spring.xml
@@ -44,9 +44,7 @@
</encoder>
</appender>
- <logger name="eclipselink.logging" level="DEBUG" additivity="true" />
-
- <root level="INFO">
+ <root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="SERVER_LOG_FILE" />
</root>
diff --git a/bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/aop/AuditAspectTest.java b/bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/aop/AuditAspectTest.java
index 60ecd0f..a7c9dba 100644
--- a/bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/aop/AuditAspectTest.java
+++ b/bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/aop/AuditAspectTest.java
@@ -19,7 +19,7 @@
package org.apache.bigtop.manager.server.aop;
import org.apache.bigtop.manager.dao.po.AuditLogPO;
-import org.apache.bigtop.manager.dao.repository.AuditLogRepository;
+import org.apache.bigtop.manager.dao.repository.AuditLogDao;
import org.apache.bigtop.manager.server.holder.SessionUserHolder;
import org.aspectj.lang.JoinPoint;
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.when;
class AuditAspectTest {
@Mock
- private AuditLogRepository auditLogRepository;
+ private AuditLogDao auditLogDao;
@Mock
private JoinPoint joinPoint;
@@ -86,7 +86,7 @@ class AuditAspectTest {
auditAspect.before(joinPoint);
- verify(auditLogRepository, times(1)).save(any(AuditLogPO.class));
+ verify(auditLogDao, times(1)).save(any(AuditLogPO.class));
}
@Test
@@ -95,7 +95,7 @@ class AuditAspectTest {
auditAspect.before(joinPoint);
- verify(auditLogRepository, never()).save(any(AuditLogPO.class));
+ verify(auditLogDao, never()).save(any(AuditLogPO.class));
}
@Test
@@ -104,6 +104,6 @@ class AuditAspectTest {
auditAspect.before(joinPoint);
- verify(auditLogRepository, never()).save(any(AuditLogPO.class));
+ verify(auditLogDao, never()).save(any(AuditLogPO.class));
}
}
diff --git a/dev-support/docker/rocky8/build-containers.sh b/dev-support/docker/rocky8/build-containers.sh
index effd34f..86f4184 100755
--- a/dev-support/docker/rocky8/build-containers.sh
+++ b/dev-support/docker/rocky8/build-containers.sh
@@ -115,6 +115,7 @@ docker exec bigtop-manager-server bash -c "sed -i 's/host: localhost/host: $BIGT
docker exec bigtop-manager-agent-01 bash -c "sed -i 's/host: localhost/host: $BIGTOP_MANAGER_SERVER_IP/' /opt/bigtop-manager-agent/conf/application.yml"
docker exec bigtop-manager-agent-02 bash -c "sed -i 's/host: localhost/host: $BIGTOP_MANAGER_SERVER_IP/' /opt/bigtop-manager-agent/conf/application.yml"
+docker exec bigtop-manager-server bash -c "mysql -uroot -proot -Dbigtop_manager < /opt/bigtop-manager-server/ddl/MySQL-DDL-CREATE.sql"
docker exec bigtop-manager-server bash -c "nohup /bin/bash /opt/bigtop-manager-server/bin/start.sh --debug > /dev/null 2>&1 &"
docker exec bigtop-manager-server bash -c "nohup /bin/bash /opt/bigtop-manager-agent/bin/start.sh --debug > /dev/null 2>&1 &"
docker exec bigtop-manager-agent-01 bash -c "nohup /bin/bash /opt/bigtop-manager-agent/bin/start.sh > /dev/null 2>&1 &"