Skip to content

Commit

Permalink
[#9903] system metric host management
Browse files Browse the repository at this point in the history
  • Loading branch information
donghun-cho committed May 11, 2023
1 parent 704bd85 commit dc08248
Show file tree
Hide file tree
Showing 18 changed files with 792 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.navercorp.pinpoint.metric.web;


import com.navercorp.pinpoint.metric.web.config.MetricWebMysqlDaoConfiguration;
import com.navercorp.pinpoint.metric.web.config.MetricWebPinotDaoConfiguration;
import com.navercorp.pinpoint.pinot.config.PinotConfiguration;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -14,7 +15,8 @@
@Import({
WebMetricPropertySources.class,
MetricWebPinotDaoConfiguration.class,
PinotConfiguration.class
PinotConfiguration.class,
MetricWebMysqlDaoConfiguration.class
})
@Profile("metric")
public class MetricWebApp {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.navercorp.pinpoint.metric.web.authorization.controller;

import com.navercorp.pinpoint.metric.web.service.SystemMetricHostExclusionService;
import com.navercorp.pinpoint.metric.web.view.SystemMetricHostGroupInfo;
import com.navercorp.pinpoint.pinot.tenant.TenantProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

@RestController
@RequestMapping(value = "/exclusion/systemMetric")
public class SystemMetricExclusionController {
private final Logger logger = LogManager.getLogger(this.getClass());

Check warning on line 20 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L20

Added line #L20 was not covered by tests

private final SystemMetricHostExclusionService systemMetricHostExclusionService;
private final TenantProvider tenantProvider;

public SystemMetricExclusionController(SystemMetricHostExclusionService systemMetricHostExclusionService, TenantProvider tenantProvider) {
this.systemMetricHostExclusionService = systemMetricHostExclusionService;
this.tenantProvider = tenantProvider;
}

Check warning on line 28 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L25-L28

Added lines #L25 - L28 were not covered by tests

@GetMapping(value = "/hostGroup")
public SystemMetricHostGroupInfo getHostGroupExclusionInfo(@RequestParam("hostGroupName") String hostGroupName) {
String tenantId = tenantProvider.getTenantId();
return systemMetricHostExclusionService.getHostGroupInfo(tenantId, hostGroupName);

Check warning on line 33 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L32-L33

Added lines #L32 - L33 were not covered by tests
}

@PostMapping(value = "/hostGroup")
public String insertHostGroupExclusion(@RequestParam("hostGroupName") String hostGroupName) {
logger.debug("add hostGroup exclusion - hostGroupName: [{}]", hostGroupName);

Check warning on line 38 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L38

Added line #L38 was not covered by tests
try {
systemMetricHostExclusionService.insertHostGroupExclusion(hostGroupName);
return "OK";
} catch (Exception e) {
logger.error("error while adding hostGroup exclusion", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 44 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L40-L44

Added lines #L40 - L44 were not covered by tests
}
}

@DeleteMapping(value = "/hostGroup")
public String deleteHostGroupExclusion(@RequestParam("hostGroupName") String hostGroupName) {
logger.debug("delete host group exclusion - hostGroupName: [{}]", hostGroupName);

Check warning on line 50 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L50

Added line #L50 was not covered by tests
try {
systemMetricHostExclusionService.deleteHostGroupExclusion(hostGroupName);
return "OK";
} catch (Exception e) {
logger.error("error while deleting hostGroup exclusion", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 56 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L52-L56

Added lines #L52 - L56 were not covered by tests
}
}

@PostMapping(value = "/hostGroup/host")
public String insertHostExclusion(@RequestParam String hostGroupName,
@RequestParam String hostName) {
logger.debug("add host exclusion - hostGroupName: [{}], hostName: [{}]", hostGroupName, hostName);

Check warning on line 63 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L63

Added line #L63 was not covered by tests
try {
systemMetricHostExclusionService.insertHostExclusion(hostGroupName, hostName);
return "OK";
} catch (Exception e) {
logger.error("error while adding host exclusion", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 69 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L65-L69

Added lines #L65 - L69 were not covered by tests
}
}

@DeleteMapping(value = "/hostGroup/host")
public String deleteHostExclusion(@RequestParam("hostGroupName") String hostGroupName,
@RequestParam("hostName") String hostName) {
logger.debug("delete host exclusion - hostGroupName: [{}], hostName: [{}]", hostGroupName, hostName);

Check warning on line 76 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L76

Added line #L76 was not covered by tests
try {
systemMetricHostExclusionService.deleteHostExclusion(hostGroupName, hostName);
return "OK";
} catch (Exception e) {
logger.error("error while deleting host exclusion", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 82 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L78-L82

Added lines #L78 - L82 were not covered by tests
}
}

@DeleteMapping(value = "/hostGroup/unusedHosts")
public String deleteUnusedHostExclusions(@RequestParam("hostGroupName") String hostGroupName) {
logger.debug("delete unused host exclusions - hostGroupName: [{}]", hostGroupName);
String tenantId = tenantProvider.getTenantId();

Check warning on line 89 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L88-L89

Added lines #L88 - L89 were not covered by tests
try {
systemMetricHostExclusionService.deleteUnusedHostExclusions(tenantId, hostGroupName);
return "OK";
} catch (Exception e) {
logger.error("error while deleting unused host exclusions", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 95 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L91-L95

Added lines #L91 - L95 were not covered by tests
}
}

@DeleteMapping(value = "/unusedGroups")
public String deleteUnusedGroupExclusions() {
logger.debug("delete exclusions from unused groups");
String tenantId = tenantProvider.getTenantId();

Check warning on line 102 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L101-L102

Added lines #L101 - L102 were not covered by tests
try {
systemMetricHostExclusionService.deleteUnusedGroupExclusions(tenantId);
return "OK";
} catch (Exception e) {
logger.error("error while deleting exclusions from unused groups", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());

Check warning on line 108 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/authorization/controller/SystemMetricExclusionController.java#L104-L108

Added lines #L104 - L108 were not covered by tests
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.navercorp.pinpoint.metric.web.config;

import com.navercorp.pinpoint.metric.collector.config.MyBatisRegistryHandler;
import com.navercorp.pinpoint.pinot.mybatis.MyBatisConfiguration;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.Resource;

import javax.sql.DataSource;

@org.springframework.context.annotation.Configuration
public class MetricWebMysqlDaoConfiguration {
private final Logger logger = LogManager.getLogger(MetricWebMysqlDaoConfiguration.class);

Check warning on line 20 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L19-L20

Added lines #L19 - L20 were not covered by tests

@Bean
public SqlSessionFactoryBean metricSqlSessionFactory(
@Qualifier("dataSource") DataSource dataSource,
@Value("classpath*:/pinot-web/mapper/mysql/*Mapper.xml") Resource[] mappers) {

for (Resource mapper : mappers) {
logger.info("Mapper location: {}", mapper.getDescription());

Check warning on line 28 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L28

Added line #L28 was not covered by tests
}

SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
sessionFactoryBean.setMapperLocations(mappers);

Check warning on line 33 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L31-L33

Added lines #L31 - L33 were not covered by tests

Configuration config = MyBatisConfiguration.defaultConfiguration();
sessionFactoryBean.setConfiguration(config);

Check warning on line 36 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L35-L36

Added lines #L35 - L36 were not covered by tests

MyBatisRegistryHandler registry = registryHandler();
registry.registerTypeAlias(config.getTypeAliasRegistry());

Check warning on line 39 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L38-L39

Added lines #L38 - L39 were not covered by tests

sessionFactoryBean.setFailFast(true);

Check warning on line 41 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L41

Added line #L41 was not covered by tests

return sessionFactoryBean;

Check warning on line 43 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L43

Added line #L43 was not covered by tests
}

private MyBatisRegistryHandler registryHandler() {
return new WebRegistryHandler();

Check warning on line 47 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L47

Added line #L47 was not covered by tests
}

@Bean
public SqlSessionTemplate metricSqlSessionTemplate(
@Qualifier("metricSqlSessionFactory") SqlSessionFactory sessionFactory) {
return new SqlSessionTemplate(sessionFactory);

Check warning on line 53 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/MetricWebMysqlDaoConfiguration.java#L53

Added line #L53 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.navercorp.pinpoint.metric.collector.config.MyBatisRegistryHandler;
import com.navercorp.pinpoint.metric.common.config.CommonRegistryHandler;
import com.navercorp.pinpoint.metric.common.model.Tag;
import com.navercorp.pinpoint.metric.web.dao.model.HostExclusionSearchKey;
import com.navercorp.pinpoint.metric.web.dao.model.HostInfoSearchKey;
import com.navercorp.pinpoint.metric.web.dao.model.MetricInfoSearchKey;
import com.navercorp.pinpoint.metric.web.dao.model.MetricTagsSearchKey;
Expand Down Expand Up @@ -45,6 +46,8 @@ public void registerTypeAlias(TypeAliasRegistry typeAliasRegistry) {
typeAliasRegistry.registerAlias("metricInfoSearchKey", MetricInfoSearchKey.class);
typeAliasRegistry.registerAlias("metricTagsSearchKey", MetricTagsSearchKey.class);
typeAliasRegistry.registerAlias("hostInfoSearchKey", HostInfoSearchKey.class);

typeAliasRegistry.registerAlias("hostExclusionSearchKey", HostExclusionSearchKey.class);

Check warning on line 50 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/WebRegistryHandler.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/config/WebRegistryHandler.java#L50

Added line #L50 was not covered by tests
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class SystemMetricController {
private final TenantProvider tenantProvider;

private final TimeWindowSampler DEFAULT_TIME_WINDOW_SAMPLER = new TimeWindowSlotCentricSampler(10000L, 200);

public SystemMetricController(SystemMetricDataService systemMetricDataService,
SystemMetricHostInfoService systemMetricHostInfoService,
YMLSystemMetricBasicGroupManager systemMetricBasicGroupManager,
Expand All @@ -62,15 +62,16 @@ public SystemMetricController(SystemMetricDataService systemMetricDataService,
}

@GetMapping(value = "/hostGroup")
public List<String> getHostGroup() {
public List<String> getHostGroup(@RequestParam(value = "showAll", defaultValue = "false", required = false) boolean showAll) {
String tenantId = tenantProvider.getTenantId();
return systemMetricHostInfoService.getHostGroupNameList(tenantId);
return systemMetricHostInfoService.getHostGroupNameList(tenantId, showAll);

Check warning on line 67 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/controller/SystemMetricController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/controller/SystemMetricController.java#L67

Added line #L67 was not covered by tests
}

@GetMapping(value = "/hostGroup/host")
public List<String> getHostGroup(@RequestParam("hostGroupName") String hostGroupName) {
public List<String> getHostGroup(@RequestParam("hostGroupName") String hostGroupName,
@RequestParam(value = "showAll", defaultValue = "false", required = false) boolean showAll) {
String tenantId = tenantProvider.getTenantId();
return systemMetricHostInfoService.getHostList(tenantId, hostGroupName);
return systemMetricHostInfoService.getHostList(tenantId, hostGroupName, showAll);

Check warning on line 74 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/controller/SystemMetricController.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/controller/SystemMetricController.java#L74

Added line #L74 was not covered by tests
}

@GetMapping(value = "/hostGroup/host/collectedMetricInfoV2")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.navercorp.pinpoint.metric.web.dao;

import java.util.List;

public interface SystemMetricHostExclusionDao {

List<String> selectExcludedHostGroupNameList();

void insertHostGroupExclusion(String hostGroupName);

void deleteHostGroupExclusion(String hostGroupName);

List<String> selectExcludedHostNameList(String hostGroupName);

void insertHostExclusion(String hostGroupName, String hostName);

void deleteHostExclusion(String hostGroupName, String hostName);

void deleteHostExclusions(String hostGroupName);

List<String> selectGroupNameListFromHostExclusion();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed 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 com.navercorp.pinpoint.metric.web.dao.model;

import java.util.Objects;

public class HostExclusionSearchKey {
private final String hostGroupName;
private final String hostName;

public HostExclusionSearchKey(String hostGroupName, String hostName) {
this.hostGroupName = Objects.requireNonNull(hostGroupName, "hostGroupName");
this.hostName = Objects.requireNonNull(hostName, "hostName");
}

Check warning on line 28 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java#L25-L28

Added lines #L25 - L28 were not covered by tests

public String getHostGroupName() {
return hostGroupName;

Check warning on line 31 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java#L31

Added line #L31 was not covered by tests
}

public String getHostName() {
return hostName;

Check warning on line 35 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/model/HostExclusionSearchKey.java#L35

Added line #L35 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.navercorp.pinpoint.metric.web.dao.mysql;

import com.navercorp.pinpoint.metric.web.dao.SystemMetricHostExclusionDao;
import com.navercorp.pinpoint.metric.web.dao.model.HostExclusionSearchKey;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;

@Primary
@Repository
public class MysqlSystemMetricHostExclusionDao implements SystemMetricHostExclusionDao {

private static final String NAMESPACE = MysqlSystemMetricHostExclusionDao.class.getName() + ".";

Check warning on line 17 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L17

Added line #L17 was not covered by tests

private final SqlSessionTemplate sqlMetricSessionTemplate;

public MysqlSystemMetricHostExclusionDao(@Qualifier("metricSqlSessionTemplate") SqlSessionTemplate sqlMetricSessionTemplate) {
this.sqlMetricSessionTemplate = Objects.requireNonNull(sqlMetricSessionTemplate, "sqlSessionTemplate");
}

Check warning on line 23 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L21-L23

Added lines #L21 - L23 were not covered by tests

@Override
public List<String> selectExcludedHostGroupNameList() {
return sqlMetricSessionTemplate.selectList(NAMESPACE + "selectExcludedHostGroupNames");

Check warning on line 27 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L27

Added line #L27 was not covered by tests
}

@Override
public void insertHostGroupExclusion(String hostGroupName) {
sqlMetricSessionTemplate.insert(NAMESPACE + "insertHostGroupExclusion", hostGroupName);
}

Check warning on line 33 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L32-L33

Added lines #L32 - L33 were not covered by tests

@Override
public void deleteHostGroupExclusion(String hostGroupName) {
sqlMetricSessionTemplate.delete(NAMESPACE + "deleteHostGroupExclusion", hostGroupName);
}

Check warning on line 38 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L37-L38

Added lines #L37 - L38 were not covered by tests

@Override
public List<String> selectExcludedHostNameList(String hostGroupName) {
return sqlMetricSessionTemplate.selectList(NAMESPACE + "selectExcludedHostNames", hostGroupName);

Check warning on line 42 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L42

Added line #L42 was not covered by tests
}

@Override
public void insertHostExclusion(String hostGroupName, String hostName) {
sqlMetricSessionTemplate.insert(NAMESPACE + "insertHostExclusion", new HostExclusionSearchKey(hostGroupName, hostName));
}

Check warning on line 48 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L47-L48

Added lines #L47 - L48 were not covered by tests

@Override
public void deleteHostExclusion(String hostGroupName, String hostName) {
sqlMetricSessionTemplate.delete(NAMESPACE + "deleteHostExclusion", new HostExclusionSearchKey(hostGroupName, hostName));
}

Check warning on line 53 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L52-L53

Added lines #L52 - L53 were not covered by tests

@Override
public void deleteHostExclusions(String hostGroupName) {
sqlMetricSessionTemplate.delete(NAMESPACE + "deleteHostExclusions", hostGroupName);
}

Check warning on line 58 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L57-L58

Added lines #L57 - L58 were not covered by tests

@Override
public List<String> selectGroupNameListFromHostExclusion() {
return sqlMetricSessionTemplate.selectList(NAMESPACE + "selectGroupNamesFromHostExclusion");

Check warning on line 62 in metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java

View check run for this annotation

Codecov / codecov/patch

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/dao/mysql/MysqlSystemMetricHostExclusionDao.java#L62

Added line #L62 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.navercorp.pinpoint.metric.web.service;

import com.navercorp.pinpoint.metric.web.view.SystemMetricHostGroupInfo;

public interface SystemMetricHostExclusionService {

SystemMetricHostGroupInfo getHostGroupInfo(String tenantId, String hostGroupName);

void insertHostGroupExclusion(String hostGroupName);

void deleteHostGroupExclusion(String hostGroupName);

void insertHostExclusion(String hostGroupName, String hostName);

void deleteHostExclusion(String hostGroupName, String hostName);

void deleteUnusedHostExclusions(String tenantId, String hostGroupName);

void deleteUnusedGroupExclusions(String tenantId);
}

0 comments on commit dc08248

Please sign in to comment.