Skip to content

Commit

Permalink
[Improve] Effective entity rename to FlinkEffective
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys committed Sep 27, 2024
1 parent 9260116 commit ede5bac
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Data
@TableName("t_flink_effective")
@Slf4j
public class Effective {
public class FlinkEffective {

@TableId(type = IdType.AUTO)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.streampark.console.core.mapper;

import org.apache.streampark.console.core.entity.Effective;
import org.apache.streampark.console.core.entity.FlinkEffective;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

public interface EffectiveMapper extends BaseMapper<Effective> {
public interface FlinkEffectiveMapper extends BaseMapper<FlinkEffective> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.streampark.console.core.service;

import org.apache.streampark.console.core.entity.Effective;
import org.apache.streampark.console.core.entity.FlinkEffective;
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;

import com.baomidou.mybatisplus.extension.service.IService;

public interface EffectiveService extends IService<Effective> {
public interface FlinkEffectiveService extends IService<FlinkEffective> {

void remove(Long appId, EffectiveTypeEnum config);

Effective get(Long appId, EffectiveTypeEnum config);
FlinkEffective get(Long appId, EffectiveTypeEnum config);

void saveOrUpdate(Long appId, EffectiveTypeEnum type, Long id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
import org.apache.streampark.console.core.mapper.FlinkApplicationBackUpMapper;
import org.apache.streampark.console.core.service.EffectiveService;
import org.apache.streampark.console.core.service.FlinkEffectiveService;
import org.apache.streampark.console.core.service.FlinkSqlService;
import org.apache.streampark.console.core.service.application.FlinkApplicationBackUpService;
import org.apache.streampark.console.core.service.application.FlinkApplicationConfigService;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class FlinkApplicationBackUpServiceImpl
private FlinkApplicationConfigService configService;

@Autowired
private EffectiveService effectiveService;
private FlinkEffectiveService effectiveService;

@Autowired
private FlinkSqlService flinkSqlService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.streampark.console.core.enums.ConfigFileTypeEnum;
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;
import org.apache.streampark.console.core.mapper.FlinkApplicationConfigMapper;
import org.apache.streampark.console.core.service.EffectiveService;
import org.apache.streampark.console.core.service.FlinkEffectiveService;
import org.apache.streampark.console.core.service.application.FlinkApplicationConfigService;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
Expand Down Expand Up @@ -64,7 +64,7 @@ public class FlinkApplicationConfigServiceImpl
private ResourceLoader resourceLoader;

@Autowired
private EffectiveService effectiveService;
private FlinkEffectiveService effectiveService;

@Override
public synchronized void create(FlinkApplication appParam, Boolean latest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import org.apache.streampark.console.core.enums.OptionStateEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
import org.apache.streampark.console.core.mapper.FlinkApplicationMapper;
import org.apache.streampark.console.core.service.EffectiveService;
import org.apache.streampark.console.core.service.FlinkClusterService;
import org.apache.streampark.console.core.service.FlinkEffectiveService;
import org.apache.streampark.console.core.service.FlinkSqlService;
import org.apache.streampark.console.core.service.ProjectService;
import org.apache.streampark.console.core.service.ResourceService;
Expand Down Expand Up @@ -126,7 +126,7 @@ public class FlinkApplicationManageServiceImpl extends ServiceImpl<FlinkApplicat
private SavepointService savepointService;

@Autowired
private EffectiveService effectiveService;
private FlinkEffectiveService effectiveService;

@Autowired
private SettingService settingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.streampark.console.core.service.impl;

import org.apache.streampark.console.core.entity.Effective;
import org.apache.streampark.console.core.entity.FlinkEffective;
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;
import org.apache.streampark.console.core.mapper.EffectiveMapper;
import org.apache.streampark.console.core.service.EffectiveService;
import org.apache.streampark.console.core.mapper.FlinkEffectiveMapper;
import org.apache.streampark.console.core.service.FlinkEffectiveService;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
Expand All @@ -35,51 +35,52 @@
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class EffectiveServiceImpl extends ServiceImpl<EffectiveMapper, Effective>
public class FlinkEffectiveServiceImpl extends ServiceImpl<FlinkEffectiveMapper, FlinkEffective>
implements
EffectiveService {
FlinkEffectiveService {

@Override
public void remove(Long appId, EffectiveTypeEnum effectiveTypeEnum) {
LambdaQueryWrapper<Effective> queryWrapper = new LambdaQueryWrapper<Effective>()
.eq(Effective::getAppId, appId)
.eq(Effective::getTargetType, effectiveTypeEnum.getType());
LambdaQueryWrapper<FlinkEffective> queryWrapper = new LambdaQueryWrapper<FlinkEffective>()
.eq(FlinkEffective::getAppId, appId)
.eq(FlinkEffective::getTargetType, effectiveTypeEnum.getType());
baseMapper.delete(queryWrapper);
}

@Override
public Effective get(Long appId, EffectiveTypeEnum effectiveTypeEnum) {
LambdaQueryWrapper<Effective> queryWrapper = new LambdaQueryWrapper<Effective>()
.eq(Effective::getAppId, appId)
.eq(Effective::getTargetType, effectiveTypeEnum.getType());
public FlinkEffective get(Long appId, EffectiveTypeEnum effectiveTypeEnum) {
LambdaQueryWrapper<FlinkEffective> queryWrapper = new LambdaQueryWrapper<FlinkEffective>()
.eq(FlinkEffective::getAppId, appId)
.eq(FlinkEffective::getTargetType, effectiveTypeEnum.getType());
return this.getOne(queryWrapper);
}

@Override
public void saveOrUpdate(Long appId, EffectiveTypeEnum type, Long id) {
LambdaQueryWrapper<Effective> queryWrapper = new LambdaQueryWrapper<Effective>()
.eq(Effective::getAppId, appId)
.eq(Effective::getTargetType, type.getType());
LambdaQueryWrapper<FlinkEffective> queryWrapper = new LambdaQueryWrapper<FlinkEffective>()
.eq(FlinkEffective::getAppId, appId)
.eq(FlinkEffective::getTargetType, type.getType());
long count = count(queryWrapper);
if (count == 0) {
Effective effective = new Effective();
FlinkEffective effective = new FlinkEffective();
effective.setAppId(appId);
effective.setTargetType(type.getType());
effective.setTargetId(id);
effective.setCreateTime(new Date());
save(effective);
} else {
update(
new LambdaUpdateWrapper<Effective>()
.eq(Effective::getAppId, appId)
.eq(Effective::getTargetType, type.getType())
.set(Effective::getTargetId, id));
new LambdaUpdateWrapper<FlinkEffective>()
.eq(FlinkEffective::getAppId, appId)
.eq(FlinkEffective::getTargetType, type.getType())
.set(FlinkEffective::getTargetId, id));
}
}

@Override
public void removeByAppId(Long appId) {
LambdaQueryWrapper<Effective> queryWrapper = new LambdaQueryWrapper<Effective>().eq(Effective::getAppId, appId);
LambdaQueryWrapper<FlinkEffective> queryWrapper =
new LambdaQueryWrapper<FlinkEffective>().eq(FlinkEffective::getAppId, appId);
this.remove(queryWrapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.streampark.console.core.enums.CandidateTypeEnum;
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;
import org.apache.streampark.console.core.mapper.FlinkSqlMapper;
import org.apache.streampark.console.core.service.EffectiveService;
import org.apache.streampark.console.core.service.FlinkEffectiveService;
import org.apache.streampark.console.core.service.FlinkEnvService;
import org.apache.streampark.console.core.service.FlinkSqlService;
import org.apache.streampark.console.core.service.application.FlinkApplicationBackUpService;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class FlinkSqlServiceImpl extends ServiceImpl<FlinkSqlMapper, FlinkSql>
FlinkSqlService {

@Autowired
private EffectiveService effectiveService;
private FlinkEffectiveService effectiveService;

@Autowired
private FlinkApplicationBackUpService backUpService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
~ 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.streampark.console.core.mapper.EffectiveMapper">
<mapper namespace="org.apache.streampark.console.core.mapper.FlinkEffectiveMapper">

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import static org.assertj.core.api.Assertions.assertThat;

/** org.apache.streampark.console.core.service.ApplicationServiceUnitTest. */
class ApplicationManageServiceTest extends SpringUnitTestBase {
class FlinkApplicationManageServiceTest extends SpringUnitTestBase {

@Autowired
private FlinkApplicationManageService applicationManageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.assertj.core.api.Assertions.assertThat;

/** CatalogService Tests */
public class CatalogServiceTest extends SpringUnitTestBase {
public class FlinkCatalogServiceTest extends SpringUnitTestBase {

@Autowired
private FlinkCatalogService catalogService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.apache.streampark.common.enums.FlinkJobType;
import org.apache.streampark.common.util.DeflaterUtils;
import org.apache.streampark.console.SpringUnitTestBase;
import org.apache.streampark.console.core.entity.Effective;
import org.apache.streampark.console.core.entity.FlinkApplication;
import org.apache.streampark.console.core.entity.FlinkApplicationConfig;
import org.apache.streampark.console.core.entity.FlinkEffective;
import org.apache.streampark.console.core.entity.FlinkEnv;
import org.apache.streampark.console.core.enums.ConfigFileTypeEnum;
import org.apache.streampark.console.core.enums.EffectiveTypeEnum;
Expand All @@ -48,7 +48,7 @@
* FlinkSavepointServiceImpl} of {@link
* SavepointService}.
*/
class SavepointServiceTest extends SpringUnitTestBase {
class FlinkSavepointServiceTest extends SpringUnitTestBase {

@Autowired
private SavepointService savepointService;
Expand All @@ -57,7 +57,7 @@ class SavepointServiceTest extends SpringUnitTestBase {
private FlinkApplicationConfigService configService;

@Autowired
private EffectiveService effectiveService;
private FlinkEffectiveService effectiveService;

@Autowired
private FlinkEnvService flinkEnvService;
Expand Down Expand Up @@ -138,7 +138,7 @@ void testGetSavepointFromAppCfgIfStreamParkOrSQLJob() {
+ String.format("%s=%s", CHECKPOINTING_INTERVAL.key(),
"3min")));
configService.updateById(appCfg);
Effective effective = new Effective();
FlinkEffective effective = new FlinkEffective();
effective.setTargetId(appCfg.getId());
effective.setAppId(appId);
effective.setTargetType(EffectiveTypeEnum.CONFIG.getType());
Expand Down

0 comments on commit ede5bac

Please sign in to comment.