Skip to content

Commit

Permalink
[improve] extra project configuration common filed to constants (apac…
Browse files Browse the repository at this point in the history
…he#2540)

Signed-off-by: yuluo-yx <[email protected]>
Co-authored-by: Calvin <[email protected]>
Co-authored-by: tomsun28 <[email protected]>
  • Loading branch information
3 people authored Aug 22, 2024
1 parent eea68d2 commit bad28bc
Show file tree
Hide file tree
Showing 25 changed files with 341 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

import lombok.Getter;
import lombok.Setter;
import org.apache.hertzbeat.common.config.BaseKafkaProperties;
import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* alerter prop config
*/
@Component
@ConfigurationProperties(prefix = "alerter")

@Getter
@Setter
@Component
@ConfigurationProperties(prefix =
ConfigConstants.FunctionModuleConstants.ALERTER)
public class AlerterProperties {

/**
Expand Down Expand Up @@ -92,25 +96,13 @@ public static class EntranceProperties {
*/
@Getter
@Setter
public static class KafkaProperties {
public static class KafkaProperties extends BaseKafkaProperties {

/**
* Whether the kafka data entry is started
*/
private boolean enabled = true;

/**
* kafka's connection server url
*/
private String servers = "127.0.0.1:9092";
/**
* The name of the topic that receives the data
*/
private String topic;
/**
* Consumer Group ID
*/
private String groupId;

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.hertzbeat.alert.config;

import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

Expand All @@ -25,6 +27,8 @@
*/

@AutoConfiguration
@ComponentScan(basePackages = "org.apache.hertzbeat.alert")
@ComponentScan(basePackages = ConfigConstants.PkgConstant.PKG
+ SignConstants.DOT
+ ConfigConstants.FunctionModuleConstants.ALERT)
public class AlerterAutoConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.hertzbeat.collector.config;

import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

Expand All @@ -26,6 +28,8 @@
*/

@AutoConfiguration
@ComponentScan(basePackages = "org.apache.hertzbeat.collector")
@ComponentScan(basePackages = ConfigConstants.PkgConstant.PKG
+ SignConstants.DOT
+ ConfigConstants.FunctionModuleConstants.COLLECTOR)
public class CollectorAutoConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@

package org.apache.hertzbeat.collector.dispatch;

import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* Collector info configuration Properties
*/
@Component
@ConfigurationProperties(prefix = CollectorInfoProperties.INFO_PREFIX)
@ConfigurationProperties(prefix = ConfigConstants.FunctionModuleConstants.COLLECTOR
+ SignConstants.DOT
+ ConfigConstants.FunctionModuleConstants.INFO)
public class CollectorInfoProperties {
protected static final String INFO_PREFIX = "collector.info";

private String version;
private String ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@

package org.apache.hertzbeat.collector.dispatch;

import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* Schedule Distribution Task Configuration Properties
*/
@Component
@ConfigurationProperties(prefix = DispatchProperties.DISPATCH_PREFIX)
@ConfigurationProperties(prefix = ConfigConstants.FunctionModuleConstants.COLLECTOR
+ SignConstants.DOT
+ ConfigConstants.FunctionModuleConstants.DISPATCH)
public class DispatchProperties {

/**
* Schedule Distribution Task Configuration Properties
*/
protected static final String DISPATCH_PREFIX = "collector.dispatch";

/**
* Scheduling entry configuration properties
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 org.apache.hertzbeat.common.config;

import lombok.Getter;
import lombok.Setter;

/**
* Kafka properties
*/

@Getter
@Setter
public class BaseKafkaProperties {

/**
* kafka's connection server url
*/
private String servers = "127.0.0.1:9092";

/**
* The name of the topic that receives the data
*/
private String topic;

/**
* Consumer Group ID
*/
private String groupId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.hertzbeat.common.config;

import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.apache.hertzbeat.common.util.AesUtil;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -27,7 +29,9 @@
*/

@AutoConfiguration
@ComponentScan(basePackages = "org.apache.hertzbeat.common")
@ComponentScan(basePackages = ConfigConstants.PkgConstant.PKG
+ SignConstants.DOT
+ ConfigConstants.FunctionModuleConstants.COMMON)
@EnableConfigurationProperties(CommonProperties.class)
public class CommonConfig {

Expand Down
Loading

0 comments on commit bad28bc

Please sign in to comment.