Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[INLONG-696] modify the status of the entities after approval #537

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public enum BizErrorCodeEnum {

CLUSTER_NOT_FOUND(1101, "Cluster information does not exist"),


DATA_STREAM_NOT_FOUND(1201, "Data stream does not exist/no operation permission"),
DATA_STREAM_ID_DUPLICATE(1202, "The current business has a data stream with the same ID"),
DATA_STREAM_OPT_NOT_ALLOWED(1203,
Expand Down Expand Up @@ -72,10 +71,6 @@ public enum BizErrorCodeEnum {
STORAGE_HIVE_FIELD_SAVE_FAILED(1404, "Failed to save/update HIVE data storage field"),
STORAGE_OPT_NOT_ALLOWED(1405,
"The current business status does not allow adding/modifying/deleting data storage information"),
STORAGE_CLUSTER_UPDATE_NOT_ALLOWED(1406,
"Current business status does not allow modification of storage cluster information"),
STORAGE_APP_GROUP_UPDATE_NOT_ALLOWED(1407,
"Current business status does not allow modification of storage application group information"),
STORAGE_DB_NAME_UPDATE_NOT_ALLOWED(1408,
"The current business status does not allow modification of the storage target database name"),
STORAGE_TB_NAME_UPDATE_NOT_ALLOWED(1409,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ public enum EntityStatus {
DELETED(40, "deleted"),

// Business related status
BIZ_WAIT_APPLYING(100, "waiting to applying"),
BIZ_WAIT_APPROVE(101, "waiting to approve"),
BIZ_APPROVE_REJECT(102, "approval reject"),
BIZ_APPROVE_PASS(103, "approval pass"),
BIZ_CONFIG_ING(110, "configuring"),
BIZ_CONFIG_FAILURE(120, "failed to config"),
BIZ_CONFIG_SUCCESS(130, "successfully config"),
BIZ_WAIT_SUBMIT(100, "waiting for submit"),
BIZ_WAIT_APPROVAL(101, "waiting for approval"),
BIZ_APPROVE_REJECTED(102, "approval rejected"),
BIZ_APPROVE_PASSED(103, "approval passed"),
BIZ_CONFIG_ING(110, "in configure"),
BIZ_CONFIG_FAILED(120, "configuration failed"),
BIZ_CONFIG_SUCCESSFUL(130, "configuration successful"),

// Data stream related status
DATA_STREAM_NEW(100, "new"),
DATA_STREAM_CONFIG_ING(110, "configuring"),
DATA_STREAM_CONFIG_FAILURE(120, "failed to config"),
DATA_STREAM_CONFIG_SUCCESS(130, "successfully config"),
DATA_STREAM_CONFIG_ING(110, "in configure"),
DATA_STREAM_CONFIG_FAILED(120, "configuration failed"),
DATA_STREAM_CONFIG_SUCCESSFUL(130, "configuration successful"),

// Data storage related status
DATA_STORAGE_NEW(100, "new"),
DATA_STORAGE_CONFIG_ING(110, "configuring"),
DATA_STORAGE_CONFIG_FAILURE(120, "failed to config"),
DATA_STORAGE_CONFIG_SUCCESS(130, "successfully config"),
DATA_STORAGE_CONFIG_ING(110, "in configure"),
DATA_STORAGE_CONFIG_FAILED(120, "configuration failed"),
DATA_STORAGE_CONFIG_SUCCESSFUL(130, "configuration successful"),

// Data source related status
DATA_RESOURCE_NEW(200, "new"),
Expand All @@ -67,69 +67,51 @@ public enum EntityStatus {
AGENT_WAIT_DELETE(204, "wait delete"),
AGENT_WAIT_UPDATE(205, "wait update"),

AGENT_ISSUED_CREATE(300, "created and issued"),
AGENT_ISSUED_STOP(302, "stop has been issued"),
AGENT_ISSUED_START(303, "start has been issued"),
AGENT_ISSUED_DELETE(304, "deletion has been issued"),
AGENT_ISSUED_UPDATE(305, "modification has been issued"),

DEPLOY_WAIT(311, "waiting to change deployment"),
DEPLOY_ING(312, "deploying"),
DEPLOY_FAILURE(313, "deployment failed"),
DEPLOY_SUCCESS(314, "deployed successfully"),

ISSUE_WAIT(321, "waiting to issue"),
ISSUE_ING(322, "issuing"),
ISSUE_FAILURE(323, "failed to issue"),
ISSUE_SUCCESS(324, "successfully issued"),
;

/**
* The status of the business that can initiate the approval process:
* <p/>[BIZ_WAIT_APPLYING] [BIZ_APPROVE_REJECT] [BIZ_CONFIG_FAILURE] [BIZ_CONFIG_SUCCESS]
* <p/>[BIZ_WAIT_SUBMIT] [BIZ_APPROVE_REJECTED] [BIZ_CONFIG_FAILED] [BIZ_CONFIG_SUCCESSFUL]
*/
public static final List<Integer> ALLOW_START_WORKFLOW_STATUS = Arrays.asList(
BIZ_WAIT_APPLYING.getCode(), BIZ_APPROVE_REJECT.getCode(), BIZ_CONFIG_FAILURE.getCode(),
BIZ_CONFIG_SUCCESS.getCode());
BIZ_WAIT_SUBMIT.getCode(), BIZ_APPROVE_REJECTED.getCode(), BIZ_CONFIG_FAILED.getCode(),
BIZ_CONFIG_SUCCESSFUL.getCode());

/**
* The status of the business that can be modified:
* <p/>[DRAFT] [BIZ_WAIT_APPLYING] [BIZ_APPROVE_REJECT] [BIZ_CONFIG_FAILURE] [BIZ_CONFIG_SUCCESS]
* <p/>[DRAFT] [BIZ_WAIT_SUBMIT] [BIZ_APPROVE_REJECTED] [BIZ_CONFIG_FAILED] [BIZ_CONFIG_SUCCESSFUL]
* <p/>[BIZ_CONFIG_ING] status cannot be modified
*/
public static final List<Integer> ALLOW_UPDATE_BIZ_STATUS = Arrays.asList(
DRAFT.getCode(), BIZ_WAIT_APPLYING.getCode(), BIZ_APPROVE_REJECT.getCode(),
BIZ_CONFIG_FAILURE.getCode(), BIZ_CONFIG_SUCCESS.getCode());
DRAFT.getCode(), BIZ_WAIT_SUBMIT.getCode(), BIZ_APPROVE_REJECTED.getCode(),
BIZ_CONFIG_FAILED.getCode(), BIZ_CONFIG_SUCCESSFUL.getCode());

/**
* The status of the service that can be deleted:
* <p/>[DRAFT] [BIZ_WAIT_APPLYING] [BIZ_APPROVE_REJECT] [BIZ_CONFIG_FAILURE] [BIZ_CONFIG_SUCCESS]
* <p/>[BIZ_CONFIG_FAILURE] [BIZ_CONFIG_SUCCESS] status cannot be deleted
* The status of the service that can be deleted - all status
* <p/>[DRAFT] [BIZ_WAIT_SUBMIT] [BIZ_APPROVE_REJECTED] [BIZ_CONFIG_ING] [BIZ_CONFIG_FAILED] [BIZ_CONFIG_SUCCESSFUL]
* <p/>[BIZ_WAIT_APPROVAL] [BIZ_APPROVE_PASSED] status cannot be deleted
*/
public static final List<Integer> ALLOW_DELETE_BIZ_STATUS = Arrays.asList(
DRAFT.getCode(), BIZ_WAIT_APPLYING.getCode(), BIZ_APPROVE_REJECT.getCode(),
BIZ_CONFIG_FAILURE.getCode(), BIZ_CONFIG_SUCCESS.getCode());
DRAFT.getCode(), BIZ_WAIT_SUBMIT.getCode(), BIZ_APPROVE_REJECTED.getCode(),
BIZ_CONFIG_ING.getCode(), BIZ_CONFIG_FAILED.getCode(), BIZ_CONFIG_SUCCESSFUL.getCode());

/**
* The business can cascade to delete the status of the associated data:
* <p/>[DRAFT] [BIZ_WAIT_APPLYING]
*/
public static final List<Integer> ALLOW_DELETE_BIZ_CASCADE_STATUS = Arrays.asList(
DRAFT.getCode(), BIZ_WAIT_APPLYING.getCode());
DRAFT.getCode(), BIZ_WAIT_SUBMIT.getCode());

/**
* Status of business approval:
* <p/>[BIZ_CONFIG_FAILURE] [BIZ_CONFIG_SUCCESS]
* Status of business approval
*/
public static final List<Integer> BIZ_APPROVE_PASS_STATUS = Arrays.asList(
BIZ_CONFIG_FAILURE.getCode(), BIZ_CONFIG_SUCCESS.getCode());
BIZ_CONFIG_FAILED.getCode(), BIZ_CONFIG_SUCCESSFUL.getCode());

/**
* Temporary business status, adding, deleting and modifying operations are not allowed:
* <p/>[BIZ_WAIT_APPROVE] [BIZ_CONFIG_ING]
* Temporary business status, adding, deleting and modifying operations are not allowed
*/
public static final List<Integer> BIZ_TEMP_STATUS = Arrays.asList(
BIZ_WAIT_APPROVE.getCode(), BIZ_CONFIG_ING.getCode());
BIZ_WAIT_APPROVAL.getCode(), BIZ_CONFIG_ING.getCode());

private final Integer code;
private final String description;
Expand Down

This file was deleted.

14 changes: 14 additions & 0 deletions inlong-manager/manager-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<exclusions>
<exclusion>
<artifactId>hive-llap-tez</artifactId>
<groupId>org.apache.hive</groupId>
</exclusion>
<exclusion>
<artifactId>hive-vector-code-gen</artifactId>
<groupId>org.apache.hive</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ DataStreamInfoToHiveConfig queryStreamToHiveBaseInfoByIdentifier(@Param("bid") S
*/
int deleteAllByBid(@Param("bid") String bid);

int updateStatusByIdentifier(@Param("bid") String bid, @Param("dsid") String dsid, @Param("status") Integer status,
@Param("modifier") String modifier);

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</resultMap>

<resultMap id="dataStreamFullInfo"
type="org.apache.inlong.manager.common.pojo.datastream.DataStreamInfoToHiveConfig">
type="org.apache.inlong.manager.common.pojo.datastream.DataStreamInfoToHiveConfig">
<result column="id" jdbcType="VARCHAR" property="id"/>
<result column="data_stream_identifier" jdbcType="VARCHAR" property="dataStreamIdentifier"/>
<result column="name" jdbcType="VARCHAR" property="businessIdentifier"/>
Expand Down Expand Up @@ -493,6 +493,17 @@
and data_stream_identifier = #{dataStreamIdentifier, jdbcType=VARCHAR}
and is_deleted = 0
</update>
<update id="updateStatusByIdentifier">
update data_stream
set status = #{status, jdbcType=INTEGER}, modifier = #{modifier, jdbcType=VARCHAR}
<where>
business_identifier = #{bid, jdbcType=VARCHAR}
<if test="dsid != null and dsid != ''">
and data_stream_identifier = #{dsid, jdbcType=VARCHAR}
</if>
and is_deleted = 0
</where>
</update>

<select id="queryStreamToHiveBaseInfoByBid" resultMap="dataStreamFullInfo">
SELECT h.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
from storage_hive
<where>
is_deleted = 0
<if test="bid != null and bid != ''">
and business_identifier = #{bid, jdbcType=VARCHAR}
</if>
and business_identifier = #{bid, jdbcType=VARCHAR}
<if test="dsid != null and dsid != ''">
and data_stream_identifier = #{dsid, jdbcType=VARCHAR}
</if>
Expand Down Expand Up @@ -432,7 +430,7 @@
file_format = #{fileFormat,jdbcType=VARCHAR},
field_splitter = #{fieldSplitter,jdbcType=VARCHAR},
encoding_type = #{encodingType,jdbcType=VARCHAR},
hdfs_default_fs = #{hdfsDefaultFs,jdbcType=VARCHAR},
hdfs_default_fs = #{hdfsDefaultFs,jdbcType=VARCHAR},
warehouse_dir = #{warehouseDir,jdbcType=VARCHAR},
usage_interval = #{usageInterval,jdbcType=VARCHAR},
storage_period = #{storagePeriod,jdbcType=INTEGER},
Expand Down
19 changes: 19 additions & 0 deletions inlong-manager/manager-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>hive-classification</artifactId>
<groupId>org.apache.hive</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<exclusions>
<exclusion>
<artifactId>hive-llap-tez</artifactId>
<groupId>org.apache.hive</groupId>
</exclusion>
<exclusion>
<artifactId>hive-vector-code-gen</artifactId>
<groupId>org.apache.hive</groupId>
</exclusion>
</exclusions>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface BusinessService {
* Modify the status of the specified business
*
* @param businessIdentifier Business identifier
* @param status Modified state
* @param status Modified status
* @param operator Current operator
* @return whether succeed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,16 @@ public interface DataStreamService {
*/
boolean updateAfterApprove(List<DataStreamApproveInfo> streamApproveList, String operator);

/**
* Update stream status
*
* @param bid Business identifier
* @param dsid Data stream identifier
* @param status Modified status
* @param operator Edit person's name
* @return whether succeed
* @apiNote If dsid is null, update all data stream associated with bid
*/
boolean updateStatus(String bid, String dsid, Integer status, String operator);

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public WorkflowResult startProcess(String bid, String operator) {
// Modify business status and other information
entity.setModifier(operator);
entity.setModifyTime(new Date());
entity.setStatus(EntityStatus.BIZ_WAIT_APPROVE.getCode());
entity.setStatus(EntityStatus.BIZ_WAIT_APPROVAL.getCode());
int success = businessMapper.updateByIdentifierSelective(entity);
Preconditions.checkTrue(success == 1, "failed to update business during assign and start process");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public String save(BusinessInfo businessInfo, String operator) {
// Only M0 is currently supported
entity.setSchemaName(BizConstant.SCHEMA_M0_DAY);

// After saving, the status is set to [BIZ_WAIT_APPLYING]
entity.setStatus(EntityStatus.BIZ_WAIT_APPLYING.getCode());
// After saving, the status is set to [BIZ_WAIT_SUBMIT]
entity.setStatus(EntityStatus.BIZ_WAIT_SUBMIT.getCode());

entity.setCreator(operator);
entity.setModifier(operator);
Expand Down Expand Up @@ -161,8 +161,8 @@ public String update(BusinessInfo businessInfo, String operator) {
this.checkBizCanUpdate(entity, businessInfo);

CommonBeanUtils.copyProperties(businessInfo, entity, true);
if (EntityStatus.BIZ_CONFIG_FAILURE.getCode().equals(entity.getStatus())) {
entity.setStatus(EntityStatus.BIZ_WAIT_APPLYING.getCode());
if (EntityStatus.BIZ_CONFIG_FAILED.getCode().equals(entity.getStatus())) {
entity.setStatus(EntityStatus.BIZ_WAIT_SUBMIT.getCode());
}
entity.setModifier(operator);
businessMapper.updateByIdentifierSelective(entity);
Expand Down Expand Up @@ -191,7 +191,7 @@ private void checkBizCanUpdate(BusinessEntity entity, BusinessInfo businessInfo)
throw new BusinessException(BizErrorCodeEnum.BUSINESS_UPDATE_NOT_ALLOWED);
}

// Non-[draft] status, no bid modification allowed
// Non-[DRAFT] status, no bid modification allowed
boolean updateBid = !EntityStatus.DRAFT.getCode().equals(oldStatus)
&& !Objects.equals(entity.getBusinessIdentifier(), businessInfo.getBusinessIdentifier());
if (updateBid) {
Expand All @@ -200,7 +200,7 @@ private void checkBizCanUpdate(BusinessEntity entity, BusinessInfo businessInfo)
}

// [Configuration successful] Status, bid and middleware type are not allowed to be modified
if (EntityStatus.BIZ_CONFIG_SUCCESS.getCode().equals(oldStatus)) {
if (EntityStatus.BIZ_CONFIG_SUCCESSFUL.getCode().equals(oldStatus)) {
if (!Objects.equals(entity.getBusinessIdentifier(), businessInfo.getBusinessIdentifier())) {
LOGGER.error("current status was not allowed to update business identifier");
throw new BusinessException(BizErrorCodeEnum.BUSINESS_BID_UPDATE_NOT_ALLOWED);
Expand Down Expand Up @@ -241,17 +241,17 @@ public boolean delete(String bid, String operator) {
throw new BusinessException(BizErrorCodeEnum.BUSINESS_DELETE_NOT_ALLOWED);
}

// [DRAFT] [BIZ_WAIT_APPLYING] status, all associated data can be logically deleted directly
// [DRAFT] [BIZ_WAIT_SUBMIT] status, all associated data can be logically deleted directly
if (EntityStatus.ALLOW_DELETE_BIZ_CASCADE_STATUS.contains(entity.getStatus())) {
// Logically delete data streams, data sources and data storage information
streamService.logicDeleteAllByBid(entity.getBusinessIdentifier(), operator);
} else {
// In other states, you need to delete the associated "data stream" data before you can delete it
// When deleting a data stream, you also need to check whether there is
// an associated "data source" and "data storage" under it
// In other states, you need to delete the associated "data stream" first.
// When deleting a data stream, you also need to check whether there are
// some associated "data source" and "data storage"
int count = streamService.selectCountByBid(bid);
if (count >= 1) {
LOGGER.error("bid={} have [{}] data stream, deleted failed", bid, count);
LOGGER.error("bid={} have [{}] data streams, deleted failed", bid, count);
throw new BusinessException(BizErrorCodeEnum.BUSINESS_HAS_DATA_STREAM);
}
}
Expand Down Expand Up @@ -291,9 +291,9 @@ public BusinessCountVO countBusinessByUser(String operator) {
countVO.setTotalCount(countVO.getTotalCount() + count);
if (status == EntityStatus.BIZ_CONFIG_ING.getCode()) {
countVO.setWaitAssignCount(countVO.getWaitAssignCount() + count);
} else if (status == EntityStatus.BIZ_WAIT_APPROVE.getCode()) {
} else if (status == EntityStatus.BIZ_WAIT_APPROVAL.getCode()) {
countVO.setWaitApproveCount(countVO.getWaitApproveCount() + count);
} else if (status == EntityStatus.BIZ_APPROVE_REJECT.getCode()) {
} else if (status == EntityStatus.BIZ_APPROVE_REJECTED.getCode()) {
countVO.setRejectCount(countVO.getRejectCount() + count);
}
}
Expand Down
Loading