fix:refactor the project and optimize the configuration loading method
This commit is contained in:
259
src/main/java/com/zdjizhi/conf/DosConfigs.java
Normal file
259
src/main/java/com/zdjizhi/conf/DosConfigs.java
Normal file
@@ -0,0 +1,259 @@
|
||||
package com.zdjizhi.conf;
|
||||
|
||||
import org.apache.flink.configuration.ConfigOption;
|
||||
import org.apache.flink.configuration.ConfigOptions;
|
||||
|
||||
public class DosConfigs {
|
||||
|
||||
|
||||
/**
|
||||
* The prefix for Kafka properties used in the source.
|
||||
*/
|
||||
public static final String SOURCE_KAFKA_PROPERTIES_PREFIX = "source.kafka.props.";
|
||||
|
||||
/**
|
||||
* The prefix for Kafka properties used in the sink.
|
||||
*/
|
||||
public static final String SINK_KAFKA_PROPERTIES_PREFIX = "sink.kafka.props.";
|
||||
|
||||
/**
|
||||
* Configuration option for the Kafka topic used in the source.
|
||||
*/
|
||||
public static final ConfigOption<String> SOURCE_KAFKA_TOPIC =
|
||||
ConfigOptions.key("source.kafka.topic")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
public static final ConfigOption<Long> FLINK_WINDOW_MAX_TIME =
|
||||
ConfigOptions.key("flink.window.max.time")
|
||||
.longType()
|
||||
.noDefaultValue();
|
||||
|
||||
public static final ConfigOption<Long> FLINK_WATERMARK_MAX_ORDERNESS =
|
||||
ConfigOptions.key("flink.watermark.max.orderness")
|
||||
.longType()
|
||||
.noDefaultValue();
|
||||
/**
|
||||
* Configuration option for the Kafka topic used in the sink.
|
||||
*/
|
||||
public static final ConfigOption<String> KAFKA_SINK_EVENT_TOPIC =
|
||||
ConfigOptions.key("kafka.sink.event.topic.name")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
public static final ConfigOption<String> KAFKA_SINK_METRIC_TOPIC =
|
||||
ConfigOptions.key("kafka.sink.metric.topic")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
|
||||
public static final ConfigOption<String> HBASE_ZOOKEEPER_QUORUM =
|
||||
ConfigOptions.key("hbase.zookeeper.quorum")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_URI =
|
||||
ConfigOptions.key("bifang.server.uri")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
public static final ConfigOption<String> KNOWLEDGE_BASE_URL =
|
||||
ConfigOptions.key("knowledge.base.uri")
|
||||
.stringType()
|
||||
.noDefaultValue();
|
||||
|
||||
|
||||
//==============================The following variables have default values=====================================
|
||||
/**
|
||||
* Configuration option for the source parallelism used in the source.
|
||||
*/
|
||||
public static final ConfigOption<Integer> SOURCE_PARALLELISM =
|
||||
ConfigOptions.key("source.parallelism")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<Integer> Flink_FIRST_AGG_PATALLELISM =
|
||||
ConfigOptions.key("flink.first.agg.parallelism")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<Integer> FLINK_DETECTION_MAP_PARALLELISM =
|
||||
ConfigOptions.key("flink.detection.map.parallelism")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<Integer> KAFKA_SINK_EVENT_PARALLELISM =
|
||||
ConfigOptions.key("kafka.sink.event.parallelism")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<Integer> KAFKA_SINK_METRIC_PARALLELISM =
|
||||
ConfigOptions.key("kafka.sink.metric.parallelism")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<String> IP_BUILTIN_KD_ID =
|
||||
ConfigOptions.key("ip.builtin.kd.id")
|
||||
.stringType()
|
||||
.defaultValue("64af7077-eb9b-4b8f-80cf-2ceebc89bea9");
|
||||
|
||||
public static final ConfigOption<String> IP_USER_DEFINED_KD_ID =
|
||||
ConfigOptions.key("ip.user.defined.kd.id")
|
||||
.stringType()
|
||||
.defaultValue("004390bc-3135-4a6f-a492-3662ecb9e289");
|
||||
|
||||
public static final ConfigOption<Integer> HTTP_SOCKET_TIMEOUT =
|
||||
ConfigOptions.key("http.socket.timeout")
|
||||
.intType()
|
||||
.defaultValue(90000);
|
||||
|
||||
|
||||
public static final ConfigOption<String> KNOWLEDGE_BASE_PATH =
|
||||
ConfigOptions.key("knowledge.base.path")
|
||||
.stringType()
|
||||
.defaultValue("/v1/knowledge_base");
|
||||
|
||||
|
||||
public static final ConfigOption<Integer> STATIC_THRESHOLD_SCHEDULE_MINUTES =
|
||||
ConfigOptions.key("static.threshold.schedule.minutes")
|
||||
.intType()
|
||||
.defaultValue(10);
|
||||
|
||||
|
||||
public static final ConfigOption<Integer> BASELINE_THRESHOLD_SCHEDULE_DAYS =
|
||||
ConfigOptions.key("baseline.threshold.schedule.days")
|
||||
.intType()
|
||||
.defaultValue(7);
|
||||
|
||||
public static final ConfigOption<Integer> STATIC_SENSITIVITY_THRESHOLD =
|
||||
ConfigOptions.key("static.sensitivity.threshold")
|
||||
.intType()
|
||||
.defaultValue(1);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SENSITIVITY_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sensitivity.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(0.2);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SESSIONS_MINOR_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sessions.minor.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(0.2);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SESSIONS_WARNING_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sessions.warning.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(1.0);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SESSIONS_MAJOR_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sessions.major.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(2.5);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SESSIONS_SEVERE_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sessions.severe.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(5.0);
|
||||
|
||||
public static final ConfigOption<Double> BASELINE_SESSIONS_CRITICAL_THRESHOLD =
|
||||
ConfigOptions.key("baseline.sessions.critical.threshold")
|
||||
.doubleType()
|
||||
.defaultValue(8.0);
|
||||
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_ENCRYPTPWD_PATH =
|
||||
ConfigOptions.key("bifang.server.encryptpwd.path")
|
||||
.stringType()
|
||||
.defaultValue("/v1/user/encryptpwd");
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_POLICY_VSYSID_PATH =
|
||||
ConfigOptions.key("bifang.server.policy.vaysid.path")
|
||||
.stringType()
|
||||
.defaultValue("/v1/admin/vsys");
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_TOKEN =
|
||||
ConfigOptions.key("bifang.server.token")
|
||||
.stringType()
|
||||
.defaultValue("aa2bdec5518ad131f71944b13ce5c298&1&");
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_POLICY_THRESHOLD_PATH =
|
||||
ConfigOptions.key("bifang.server.policy.threshold.path")
|
||||
.stringType()
|
||||
.defaultValue("/v1/policy/profile/dos_detection");
|
||||
|
||||
public static final ConfigOption<String> BIFANG_SERVER_LOGIN_PATH =
|
||||
ConfigOptions.key("bifang.server.login.path")
|
||||
.stringType()
|
||||
.defaultValue("/v1/user/login");
|
||||
|
||||
public static final ConfigOption<Integer> HTTP_POOL_MAX_CONNECTION =
|
||||
ConfigOptions.key("http.pool.max.connection")
|
||||
.intType()
|
||||
.defaultValue(400);
|
||||
|
||||
public static final ConfigOption<Integer> HTTP_POOL_MAX_PER_ROUTE =
|
||||
ConfigOptions.key("http.pool.max.per.route")
|
||||
.intType()
|
||||
.defaultValue(80);
|
||||
|
||||
public static final ConfigOption<Integer> HTTP_POOL_REQUEST_TIMEOUT =
|
||||
ConfigOptions.key("http.pool.request.timeout")
|
||||
.intType()
|
||||
.defaultValue(60000);
|
||||
|
||||
public static final ConfigOption<Integer> HTTP_POOL_CONNECT_TIMEOUT =
|
||||
ConfigOptions.key("http.pool.connect.timeout")
|
||||
.intType()
|
||||
.defaultValue(60000);
|
||||
|
||||
public static final ConfigOption<Integer> DATA_CENTER_ID_NUM =
|
||||
ConfigOptions.key("data.center.id.num")
|
||||
.intType()
|
||||
.defaultValue(15);
|
||||
|
||||
public static final ConfigOption<Integer> HBASE_CLIENT_OPERATION_TIMEOUT =
|
||||
ConfigOptions.key("hbase.client.operation.timeout")
|
||||
.intType()
|
||||
.defaultValue(30000);
|
||||
|
||||
public static final ConfigOption<Integer> HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD =
|
||||
ConfigOptions.key("hbase.client.scanner.timeout.period")
|
||||
.intType()
|
||||
.defaultValue(30000);
|
||||
|
||||
public static final ConfigOption<String> HBASE_BASELINE_TABLE_NAME =
|
||||
ConfigOptions.key("hbase.baseline.table.name")
|
||||
.stringType()
|
||||
.defaultValue("dos:ddos_traffic_baselines");
|
||||
|
||||
public static final ConfigOption<Integer> HBASE_BASELINE_TTL =
|
||||
ConfigOptions.key("hbase.baseline.ttl")
|
||||
.intType()
|
||||
.defaultValue(10);
|
||||
|
||||
|
||||
public static final ConfigOption<Integer> HBASE_BASELINE_TOTAL_NUM =
|
||||
ConfigOptions.key("hbase.baseline.total.num")
|
||||
.intType()
|
||||
.defaultValue(1000000);
|
||||
|
||||
public static final ConfigOption<Integer> DESTINATION_IP_PARTITION_NUM =
|
||||
ConfigOptions.key("destination.ip.partition.num")
|
||||
.intType()
|
||||
.defaultValue(10000);
|
||||
|
||||
public static final ConfigOption<Integer> SOURCE_IP_LIST_LIMIT =
|
||||
ConfigOptions.key("source.ip.list.limit")
|
||||
.intType()
|
||||
.defaultValue(10000);
|
||||
|
||||
/**
|
||||
* Knowledge base scheduling cycle, in minutes
|
||||
*/
|
||||
public static final ConfigOption<Long> KNOWLEDGE_BASE_SCHEDULE_MINUTES =
|
||||
ConfigOptions.key("knowledge.base.schedule.minutes")
|
||||
.longType()
|
||||
.defaultValue(60L);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user