Skip to content

Commit

Permalink
开启checkstyle, 统一代码风格,避免代码风格引起的冲突 (#557)
Browse files Browse the repository at this point in the history
* [Bug] Doris] DDP1.2.2,使用doris官方包安装be失败 #539

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* [Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* Update KyuubiServerHandlerStrategy.java

[Feature] 开启checkstyle, 统一代码风格,避免代码风格引起的冲突 #555

* 修改github ci

* 修改github ci

* 修改github ci

* 修改github ci
  • Loading branch information
hawk9821 authored May 17, 2024
1 parent 97444e3 commit f2a0790
Show file tree
Hide file tree
Showing 510 changed files with 6,749 additions and 5,453 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# - name: Check Style
# run: |
# ./mvnw -T 2C -B --no-snapshot-updates clean checkstyle:check
- name: Check Code Style
run: |
./mvnw -T 2C -B --no-snapshot-updates clean checkstyle:check
- name: Build and Package
run: |
./mvnw -Pgoogle-mirror -B clean install \
-Dmaven.test.skip=true \
--no-snapshot-updates \
-pl !datasophon-ui,!datasophon-api,!datasophon-service -am
./mvnw -Pgoogle-mirror -B clean package \
-Dmaven.test.skip=true \
-Dspotless.check.skip=true \
--no-snapshot-updates \
-pl !datasophon-ui,!datasophon-api,!datasophon-service -am
10 changes: 8 additions & 2 deletions datasophon-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.datasophon</groupId>
<artifactId>datasophon-service</artifactId>
Expand All @@ -49,7 +53,8 @@
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>front/**</exclude> <!-- 替换为您要排除的文件夹名称 -->
<exclude>front/**</exclude>
<!-- 替换为您要排除的文件夹名称 -->
</excludes>
</resource>
</resources>
Expand All @@ -72,7 +77,8 @@
<fileset>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>front/**</include> <!-- 替换为要删除的文件名 -->
<include>front/**</include>
<!-- 替换为要删除的文件名 -->
</includes>
</fileset>
</filesets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,47 @@

package com.datasophon.api;

import cn.hutool.extra.spring.EnableSpringUtil;
import com.datasophon.api.master.ActorUtils;
import com.datasophon.common.Constants;
import com.datasophon.common.cache.CacheUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;

import javax.annotation.PostConstruct;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import cn.hutool.extra.spring.EnableSpringUtil;

@SpringBootApplication
@ServletComponentScan
@ComponentScan("com.datasophon")
@MapperScan("com.datasophon.dao")
@EnableSpringUtil
public class DataSophonApplicationServer extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(DataSophonApplicationServer.class, args);
// add shutdown hook, close and shutdown resources
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// add shutdown hook, close and shutdown resources
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
shutdown();
}));
}

@PostConstruct
public void run() throws UnknownHostException, NoSuchAlgorithmException {
String hostName = InetAddress.getLocalHost().getHostName();
CacheUtils.put(Constants.HOSTNAME, hostName);
ActorUtils.init();
}

/**
* Master 关闭时调用
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
*/
@Configuration
public class AppConfiguration implements WebMvcConfigurer {

public static final String LOGIN_INTERCEPTOR_PATH_PATTERN = "/**/*";
public static final String LOGIN_PATH_PATTERN = "/login";
public static final String PATH_PATTERN = "/**";
public static final String LOCALE_LANGUAGE_COOKIE = "language";

@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
Expand All @@ -57,12 +57,12 @@ public CorsFilter corsFilter() {
configSource.registerCorsConfiguration(PATH_PATTERN, config);
return new CorsFilter(configSource);
}

@Bean
public LoginHandlerInterceptor loginInterceptor() {
return new LoginHandlerInterceptor();
}

/**
* Cookie
* @return local resolver
Expand All @@ -77,17 +77,17 @@ public LocaleResolver localeResolver() {
localeResolver.setLanguageTagCompliant(false);
return localeResolver;
}

@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
return new LocaleChangeInterceptor();
}

@Bean
public UserPermissionHandler userPermissionHandler() {
return new UserPermissionHandler();
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
// i18n
Expand All @@ -104,7 +104,7 @@ public void addInterceptors(InterceptorRegistry registry) {
"/",
"/static/**");
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**")
Expand All @@ -114,13 +114,13 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("/ui/**").addResourceLocations("file:ui/");
}

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/ui/").setViewName("forward:/ui/index.html");
registry.addViewController("/").setViewName("index");
}

/**
* Turn off suffix-based content negotiation
*
Expand All @@ -130,5 +130,5 @@ public void addViewControllers(ViewControllerRegistry registry) {
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
package com.datasophon.api.configuration;

import com.datasophon.common.utils.FileUtils;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import lombok.extern.slf4j.Slf4j;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.env.YamlPropertySourceLoader;
Expand All @@ -13,33 +26,29 @@
import org.springframework.core.io.FileSystemResource;
import org.springframework.util.CollectionUtils;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.*;

@Slf4j
public class ConfigPropertiesExtend implements EnvironmentPostProcessor {

private static final String CONFIG_HOME = "conf/datasophon.conf";

private static final String DEFAULT_APPLICATION_CONFIG = "conf/profiles/application-config.yml";

@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();
Properties properties = loadCustomProperties();
checkProfile(environment);
propertySources.addFirst(new PropertiesPropertySource("datasophonConfig", properties));
}

private Properties loadCustomProperties() {
Properties properties = new Properties();
File file = new File(FileUtils.concatPath(System.getProperty("user.dir"), CONFIG_HOME));
try (InputStream inputStream = Files.newInputStream(file.toPath())) {
properties.load(inputStream);
} catch (Exception e) {
System.err.println("Failed to load the datart configuration (config/datart.conf), use application-config.yml");
System.err.println(
"Failed to load the datart configuration (config/datart.conf), use application-config.yml");
return new Properties();
}
List<Object> removeKeys = new ArrayList<>();
Expand All @@ -55,15 +64,16 @@ private Properties loadCustomProperties() {
}
return properties;
}

private void checkProfile(ConfigurableEnvironment environment) {
List<String> activeProfiles = Arrays.asList(environment.getActiveProfiles());
if (!activeProfiles.isEmpty() && !Collections.singletonList("config").containsAll(activeProfiles)) {
// running other profiles
return;
}
try {
List<PropertySource<?>> propertySources = new YamlPropertySourceLoader().load(DEFAULT_APPLICATION_CONFIG, new FileSystemResource(DEFAULT_APPLICATION_CONFIG));
List<PropertySource<?>> propertySources = new YamlPropertySourceLoader().load(DEFAULT_APPLICATION_CONFIG,
new FileSystemResource(DEFAULT_APPLICATION_CONFIG));
if (CollectionUtils.isEmpty(propertySources)) {
System.err.println("Default config application-config not found ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package com.datasophon.api.configuration;

import com.datasophon.api.migration.DatabaseMigration;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
Expand All @@ -30,7 +32,7 @@
@Slf4j
@Component
public class DatabaseMigrationAware implements ApplicationContextAware, Ordered {

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
String migrationEnable = applicationContext.getEnvironment().getProperty("datasophon.migration.enable");
Expand All @@ -45,10 +47,10 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
throw new RuntimeException(e);
}
}

@Override
public int getOrder() {
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.datasophon.dao.entity.AlertGroupEntity;
import com.datasophon.dao.entity.ClusterAlertQuota;

import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -35,31 +37,31 @@
@RestController
@RequestMapping("alert/group")
public class AlertGroupController {

@Autowired
private AlertGroupService alertGroupService;

@Autowired
private ClusterAlertQuotaService alertQuotaService;

/**
* 列表
*/
@RequestMapping("/list")
public Result list(Integer clusterId, String alertGroupName, Integer page, Integer pageSize) {
return alertGroupService.getAlertGroupList(clusterId, alertGroupName, page, pageSize);
}

/**
* 信息
*/
@RequestMapping("/info/{id}")
public Result info(@PathVariable("id") Integer id) {
AlertGroupEntity alertGroup = alertGroupService.getById(id);

return Result.success().put("alertGroup", alertGroup);
}

/**
* 保存
*/
Expand All @@ -68,32 +70,32 @@ public Result save(@RequestBody AlertGroupEntity alertGroup) {
alertGroup.setCreateTime(new Date());
return alertGroupService.saveAlertGroup(alertGroup);
}

/**
* 修改
*/
@RequestMapping("/update")
public Result update(@RequestBody AlertGroupEntity alertGroup) {
alertGroupService.updateById(alertGroup);

return Result.success();
}

/**
* 删除
*/
@RequestMapping("/delete")
public Result delete(@RequestBody Integer[] ids) {

// 校验是否绑定告警指标
List<ClusterAlertQuota> list =
alertQuotaService.lambdaQuery().in(ClusterAlertQuota::getAlertGroupId, ids).list();
if (list.size() > 0) {
return Result.error(Status.ALERT_GROUP_TIPS_ONE.getMsg());
}
alertGroupService.removeByIds(Arrays.asList(ids));

return Result.success();
}

}
Loading

0 comments on commit f2a0790

Please sign in to comment.