Skip to content

Commit

Permalink
[alerter,collector,common,warehouse] refactor auto import component (#…
Browse files Browse the repository at this point in the history
…576)

  [web-app] fix history echarts chart tooltip only show one instance (#365)

  [workflow] upgrade issues-translator version 2.7 (#367)

  [manger] add mockito unit test

  [manger] add globalExceptionHandler mockito unit test (#368)

  [manager] impl appController unit test case (#370)

  英文注释的补充

  Supplement of English notes

  Supplementary English notes

  Supplement of English notes

  AppControllerTest Implementation of unit tests

Co-authored-by: gaoxingcun <gxc01514416@alibaba-inc.com>

  [warehouse] support Iotdb metrics data storage (#372)

  add iotdb storage (saveData part)

  implement getHistoryMetricData

  save multiple instances at the same time
implement getHistoryIntervalMetricData

  [warehouse] reformat code

  [warehouse] refactor code

  [warehouse] refactor code

  [warehouse] refactor code

  [warehouse] fix insert node path container   '  parsed error

  [warehouse] fix insert node path container   '    parsed error

  [warehouse] support iotdb rpc-port

  support iotdb version 0.12
fix save data and select bug

  replace Session with SessionPool

  rule fix, 修复魔法值问题

Co-authored-by: tomsun28 <tomsun28@outlook.com>
Co-authored-by: hujiaofen <hujiaofen@2dfire.com>

  [webapp,warehouse] support historical interval aggregate data chart (#373)

  [manger] add mockito unit test

  [manger] impl unit test ParamDaoTest #360

  [manager] fix NoticeRuleDaoTest

  [manger] impl unit test ParamDefineDaoTest #361

  [manger] impl unit test TagDaoTest #362

  [manger] add manger sql dao mockito unit test (#375)

  [manger] add mockito unit test

  [manger] add mockito unit test

  [manger] impl unit test ParamDaoTest #360

  [manager] fix NoticeRuleDaoTest

  [manger] impl unit test ParamDefineDaoTest #361

  [manger] impl unit test TagDaoTest #362

  [manager] I18nControllerTest and MonitorControllerTest Unit tests are written (#376)

  I18ControllerTest Completion of the test class

  MonitorControllerTest Unit tests are written

  [manger] impl unit test AppServiceTest #355

  [hertzbeat] update use PromQL to collect metrics from promethues server (#456)

  [manager] enhancement manager-monitors-page added gmtUpdate desc (#455)

  [manager-monitors](增强)应用服务检测-网站检测-分页:添加默认name升序 (enhancement)manager-monitors-page added name asc

  [manager-monitors](增强)应用服务检测-网站检测-分页:添加默认gmtUpdate降序 (enhancement)manager-monitors-page added gmtUpdate desc

  [webapp] support monitors list sort by name, date (#458)

  [manager] bugfix the gmtUpdate time not change when update monitor params (#459)

  [alerter,collector,common,warehouse] refactor auto import component

Co-authored-by: tomsun28 <tomsun28@outlook.com>
Co-authored-by: 铁甲小宝 <85919258+TJxiaobao@users.noreply.github.com>
Co-authored-by: gaoxingcun <gxc01514416@alibaba-inc.com>
Co-authored-by: zcx <48920254+Ceilzcx@users.noreply.github.com>
Co-authored-by: hujiaofen <hujiaofen@2dfire.com>
Co-authored-by: luxx <58515565+luxx-lq@users.noreply.github.com>
  • Loading branch information
7 people committed Jan 15, 2023
1 parent 5797cdc commit 86fff32
Show file tree
Hide file tree
Showing 17 changed files with 213 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 com.usthe.alert.config;

import org.springframework.context.annotation.ComponentScan;

/**
* @author <a href="mailto:gcwm99@gmail.com">gcdd1993</a>
* @version 2.1
* Created by Musk.Chen on 2023/1/14
*/
@ComponentScan(basePackages = "com.usthe.alert")
public class AlerterAutoConfiguration {
}
9 changes: 1 addition & 8 deletions alerter/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,4 @@
# limitations under the License.

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.usthe.alert.service.impl.AlertDefineServiceImpl,\
com.usthe.alert.service.impl.AlertServiceImpl,\
com.usthe.alert.controller.AlertDefineController,\
com.usthe.alert.AlerterWorkerPool,\
com.usthe.alert.AlerterProperties,\
com.usthe.alert.calculate.CalculateAlarm,\
com.usthe.alert.controller.AlertsController,\
com.usthe.alert.controller.AlertDefinesController
com.usthe.alert.config.AlerterAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 com.usthe.collector.config;

import org.springframework.context.annotation.ComponentScan;

/**
* @author <a href="mailto:gcwm99@gmail.com">gcdd1993</a>
* @version 2.1
* Created by Musk.Chen on 2023/1/14
*/
@ComponentScan(basePackages = "com.usthe.collector")
public class CollectorAutoConfiguration {
}
11 changes: 1 addition & 10 deletions collector/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,5 @@
# limitations under the License.

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.usthe.collector.dispatch.timer.TimerDispatcher,\
com.usthe.collector.dispatch.CommonDispatcher,\
com.usthe.collector.dispatch.DispatchProperties,\
com.usthe.collector.dispatch.MetricsCollectorQueue,\
com.usthe.collector.dispatch.WorkerPool,\
com.usthe.collector.dispatch.entrance.internal.CollectJobService,\
com.usthe.collector.collect.database.JdbcSpiLoader,\
com.usthe.collector.collect.http.promethus.PrometheusParseCreater,\
com.usthe.collector.dispatch.unit.impl.DataSizeConvert,\
com.usthe.collector.collect.strategy.CollectStrategyFactory
com.usthe.collector.config.CollectorAutoConfiguration

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
package com.usthe.common.config;

import com.usthe.common.util.AesUtil;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
* @author tom
* @date 2022/6/30 09:23
*/
@ComponentScan(basePackages = "com.usthe.common")
@EnableConfigurationProperties(CommonProperties.class)
@Configuration
public class CommonConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
package com.usthe.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* common properties
*
* @author tom
* @date 2021/11/24 10:38
*/
@Component
@ConfigurationProperties(prefix = "common")
public class CommonProperties {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import com.usthe.common.support.exception.SendMessageException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
* sms service client for tencent cloud
* @author tom
* @date 2022/12/17 17:41
*/
@Configuration
@Component
@ConditionalOnProperty("common.sms.tencent.app-id")
@Slf4j
public class TencentSmsClient {
Expand Down
7 changes: 1 addition & 6 deletions common/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@


org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.usthe.common.config.CommonProperties,\
com.usthe.common.config.CommonConfig,\
com.usthe.common.config.AviatorConfiguration,\
com.usthe.common.queue.impl.InMemoryCommonDataQueue,\
com.usthe.common.service.TencentSmsClient,\
com.usthe.common.support.SpringContextHolder
com.usthe.common.config.CommonConfig
99 changes: 99 additions & 0 deletions manager/src/test/java/com/usthe/manager/ManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.usthe.manager;

import com.usthe.alert.AlerterProperties;
import com.usthe.alert.AlerterWorkerPool;
import com.usthe.alert.calculate.CalculateAlarm;
import com.usthe.alert.controller.AlertDefineController;
import com.usthe.alert.controller.AlertDefinesController;
import com.usthe.alert.controller.AlertsController;
import com.usthe.alert.service.impl.AlertDefineServiceImpl;
import com.usthe.alert.service.impl.AlertServiceImpl;
import com.usthe.collector.collect.database.JdbcSpiLoader;
import com.usthe.collector.collect.http.promethus.PrometheusParseCreater;
import com.usthe.collector.collect.strategy.CollectStrategyFactory;
import com.usthe.collector.dispatch.CommonDispatcher;
import com.usthe.collector.dispatch.DispatchProperties;
import com.usthe.collector.dispatch.MetricsCollectorQueue;
import com.usthe.collector.dispatch.WorkerPool;
import com.usthe.collector.dispatch.entrance.internal.CollectJobService;
import com.usthe.collector.dispatch.timer.TimerDispatcher;
import com.usthe.collector.dispatch.unit.impl.DataSizeConvert;
import com.usthe.common.config.AviatorConfiguration;
import com.usthe.common.config.CommonConfig;
import com.usthe.common.config.CommonProperties;
import com.usthe.common.queue.impl.InMemoryCommonDataQueue;
import com.usthe.common.service.TencentSmsClient;
import com.usthe.common.support.SpringContextHolder;
import com.usthe.warehouse.WarehouseWorkerPool;
import com.usthe.warehouse.config.WarehouseProperties;
import com.usthe.warehouse.controller.MetricsDataController;
import com.usthe.warehouse.store.HistoryIotDbDataStorage;
import com.usthe.warehouse.store.HistoryTdEngineDataStorage;
import com.usthe.warehouse.store.RealTimeMemoryDataStorage;
import com.usthe.warehouse.store.RealTimeRedisDataStorage;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;

import javax.annotation.Resource;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* @author <a href="mailto:gcwm99@gmail.com">gcdd1993</a>
* @version 2.1
* Created by Musk.Chen on 2023/1/14
*/
class ManagerTest extends AbstractSpringIntegrationTest {

@Resource
private ApplicationContext ctx;

@Test
void testAutoImport() {
// test alert module
assertNotNull(ctx.getBean(AlertDefineServiceImpl.class));
assertNotNull(ctx.getBean(AlertServiceImpl.class));
assertNotNull(ctx.getBean(AlertDefineController.class));
assertNotNull(ctx.getBean(AlerterWorkerPool.class));
assertNotNull(ctx.getBean(AlerterProperties.class));
assertNotNull(ctx.getBean(CalculateAlarm.class));
assertNotNull(ctx.getBean(AlertsController.class));
assertNotNull(ctx.getBean(AlertDefinesController.class));

// test collector module
assertNotNull(ctx.getBean(TimerDispatcher.class));
assertNotNull(ctx.getBean(CommonDispatcher.class));
assertNotNull(ctx.getBean(DispatchProperties.class));
assertNotNull(ctx.getBean(MetricsCollectorQueue.class));
assertNotNull(ctx.getBean(WorkerPool.class));
assertNotNull(ctx.getBean(CollectJobService.class));
assertNotNull(ctx.getBean(JdbcSpiLoader.class));
assertNotNull(ctx.getBean(PrometheusParseCreater.class));
assertNotNull(ctx.getBean(DataSizeConvert.class));
assertNotNull(ctx.getBean(CollectStrategyFactory.class));

// test common module
assertNotNull(ctx.getBean(CommonProperties.class));
assertNotNull(ctx.getBean(CommonConfig.class));
assertNotNull(ctx.getBean(AviatorConfiguration.class));
assertNotNull(ctx.getBean(InMemoryCommonDataQueue.class));
// condition on common.sms.tencent.app-id
assertThrows(NoSuchBeanDefinitionException.class, () -> ctx.getBean(TencentSmsClient.class));
assertNotNull(ctx.getBean(SpringContextHolder.class));

// test warehouse module
assertNotNull(ctx.getBean(WarehouseProperties.class));
assertNotNull(ctx.getBean(WarehouseWorkerPool.class));

// default DataStorage is RealTimeMemoryDataStorage
assertNotNull(ctx.getBean(RealTimeMemoryDataStorage.class));
assertThrows(NoSuchBeanDefinitionException.class, () -> ctx.getBean(RealTimeRedisDataStorage.class));
assertThrows(NoSuchBeanDefinitionException.class, () -> ctx.getBean(HistoryTdEngineDataStorage.class));
assertThrows(NoSuchBeanDefinitionException.class, () -> ctx.getBean(HistoryIotDbDataStorage.class));

assertNotNull(ctx.getBean(MetricsDataController.class));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 com.usthe.warehouse.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;

/**
* @author <a href="mailto:gcwm99@gmail.com">gcdd1993</a>
* @version 2.1
* Created by Musk.Chen on 2023/1/14
*/
@ComponentScan(basePackages = "com.usthe.warehouse")
@EnableConfigurationProperties(WarehouseProperties.class)
public class WarehouseAutoConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* limitations under the License.
*/

package com.usthe.warehouse;
package com.usthe.warehouse.config;

import org.apache.iotdb.session.util.Version;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.time.ZoneId;
import java.util.List;
Expand All @@ -29,7 +28,6 @@
* @author tom
* @date 2021/11/24 10:38
*/
@Component
@ConfigurationProperties(prefix = "warehouse")
public class WarehouseProperties {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.usthe.common.entity.dto.Value;
import com.usthe.common.entity.message.CollectRep;
import com.usthe.common.queue.CommonDataQueue;
import com.usthe.warehouse.WarehouseProperties;
import com.usthe.warehouse.config.WarehouseProperties;
import com.usthe.warehouse.WarehouseWorkerPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.usthe.common.entity.message.CollectRep;
import com.usthe.common.queue.CommonDataQueue;
import com.usthe.common.util.CommonConstants;
import com.usthe.warehouse.WarehouseProperties;
import com.usthe.warehouse.WarehouseWorkerPool;
import com.usthe.warehouse.config.WarehouseProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
Expand All @@ -16,9 +16,8 @@
import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.write.record.Tablet;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
Expand All @@ -30,8 +29,7 @@
* @author ceilzcx
* @since 2022/10/12
*/
@Configuration
@AutoConfigureAfter(value = {WarehouseProperties.class})
@Component
@ConditionalOnProperty(prefix = "warehouse.store.iot-db",
name = "enabled", havingValue = "true")
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import com.usthe.common.entity.message.CollectRep;
import com.usthe.common.queue.CommonDataQueue;
import com.usthe.common.util.CommonConstants;
import com.usthe.warehouse.WarehouseProperties;
import com.usthe.warehouse.WarehouseWorkerPool;
import com.usthe.warehouse.config.WarehouseProperties;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
Expand All @@ -47,10 +46,9 @@
* @date 2021/11/24 18:23
*/
@Primary
@Configuration
@AutoConfigureAfter(value = {WarehouseProperties.class})
@Component
@ConditionalOnProperty(prefix = "warehouse.store.td-engine",
name = "enabled", havingValue = "true", matchIfMissing = false)
name = "enabled", havingValue = "true")
@Slf4j
public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {

Expand Down
Loading

0 comments on commit 86fff32

Please sign in to comment.