Skip to content

Commit

Permalink
事件上报entity和dao模块
Browse files Browse the repository at this point in the history
  • Loading branch information
xuezechao1 committed Mar 28, 2023
1 parent e56e893 commit f9f661e
Show file tree
Hide file tree
Showing 17 changed files with 1,484 additions and 15 deletions.
52 changes: 43 additions & 9 deletions sermant-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
<io.netty.version>4.1.75.Final</io.netty.version>
<spring-boot.version>2.5.8</spring-boot.version>
<frontend-maven-plugin.version>1.12.1</frontend-maven-plugin.version>
<protobuf-java.version>3.9.1</protobuf-java.version>
<lombok.version>1.18.12</lombok.version>
<fastjson.version>1.2.83</fastjson.version>
<commons-lang.version>2.6</commons-lang.version>
<junit.version>4.13.1</junit.version>
<junit-jupiter.version>5.6.2</junit-jupiter.version>
<mockito-core.version>2.28.2</mockito-core.version>
<slf4j-api.version>1.7.32</slf4j-api.version>
<commons-lang3.version>3.9</commons-lang3.version>
<jedis.version>4.3.1</jedis.version>
<powermock.version>2.0.9</powermock.version>
<webapp.path>${project.basedir}/src/main/webapp/frontend</webapp.path>
</properties>

Expand Down Expand Up @@ -85,50 +96,73 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.9.1</version>
<version>${protobuf-java.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
* 启动类
Expand All @@ -29,6 +30,7 @@
*/
@SpringBootApplication
@ConfigurationPropertiesScan
@EnableScheduling
public class Backend {
public static void main(String[] args) {
SpringApplication.run(Backend.class, args);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* 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.huaweicloud.sermant.backend.common.conf;

import com.huaweicloud.sermant.backend.dao.DatabaseType;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Locale;

/**
* 事件配置
*
* @author xuezechao
* @since 2023-03-02
*/
@Component
@Configuration
public class BackendConfig {

/**
* 数据库类型
*/
@Value("${database.type}")
private String database;

/**
* 数据库地址
*/
@Value("${database.address}")
private String url;

@Value("${database.user}")
private String user;

@Value("${database.password}")
private String password;

@Value("${database.expire}")
private String expire;

@Value("${webhook.eventpush.level}")
private String webhookPushEventThreshold;

@Value("${database.version}")
private String version;

@Value("${database.max.total}")
private String maxTotal;

@Value("${database.max.idle}")
private String maxIdle;

@Value("${database.timeout}")
private String timeout;

@Value("${session.expire}")
private String sessionTimeout;

@Value("${database.filter.thread.num}")
private String filterThreadNum;

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public DatabaseType getDatabase() {
return DatabaseType.valueOf(database.toUpperCase(Locale.ROOT));
}

public void setDatabase(String db) {
this.database = db;
}

public void setPassword(String password) {
this.password = password;
}

public String getPassword() {
return password;
}

public String getExpire() {
return expire;
}

public void setExpire(String expire) {
this.expire = expire;
}

public void setWebhookPushEventThreshold(String webhookPushEventThreshold) {
this.webhookPushEventThreshold = webhookPushEventThreshold;
}

public String getWebhookPushEventThreshold() {
return webhookPushEventThreshold;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getMaxIdle() {
return maxIdle;
}

public void setMaxIdle(String maxIdle) {
this.maxIdle = maxIdle;
}

public String getMaxTotal() {
return maxTotal;
}

public void setMaxTotal(String maxTotal) {
this.maxTotal = maxTotal;
}

public String getTimeout() {
return timeout;
}

public void setTimeout(String timeout) {
this.timeout = timeout;
}

public String getSessionTimeout() {
return sessionTimeout;
}

public void setSessionTimeout(String sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}

public String getFilterThreadNum() {
return filterThreadNum;
}

public void setFilterThreadNum(String filterThreadNum) {
this.filterThreadNum = filterThreadNum;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* 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.huaweicloud.sermant.backend.common.conf;

/**
* 公共配置常量
*
* @author xuezechao
* @since 2023-03-02
*/
public class CommonConst {

/**
* 钉钉webhook名称
*/
public static final String DINGDING_WEBHOOK_NAME = "DingDing";

/**
* 钉钉webhook id
*/
public static final int DINGDING_WEBHOOK_ID = 1;

/**
* 飞书webhook名称
*/
public static final String FEISHU_WEBHOOK_NAME = "Feishu";

/**
* 飞书webhook id
*/
public static final int FEISHU_WEBHOOK_ID = 0;

/**
* welink WEBHOOK名称
*/
public static final String WELINK_WEBHOOK_NAME = "Welink";

/**
* welink WEBHOOK id
*/
public static final int WELINK_WEBHOOK_ID = 2;

/**
* 默认redis地址
*/
public static final String DEFAULT_REDIS_ADDRESS = "127.0.0.1";

/**
* 默认redis端口
*/
public static final int DEFAULT_REDIS_PORT = 6379;

/**
* redis 实例元数据key
*/
public static final String REDIS_HASH_KEY_OF_INSTANCE_META = "sermant_meta";

/**
* redis 事件key
*/
public static final String REDIS_EVENT_KEY = "sermant_events_hash";

/**
* redis 事件field集合的key
*/
public static final String REDIS_EVENT_FIELD_SET_KEY = "sermant_event_keyset";

/**
* redis 全匹配字符*
*/
public static final String FULL_MATCH_KEY = ".*";

/**
* 拼接redis key 字符
*/
public static final String JOIN_REDIS_KEY = "_";

/**
* redis 地址切分字符
*/
public static final String REDIS_ADDRESS_SPLIT = ":";

/**
* 前端页面事件每页展示默认数量
*/
public static final int DEFAULT_PAGE_SIZE = 10;

private CommonConst() {

}
}
Loading

0 comments on commit f9f661e

Please sign in to comment.