mirror of https://github.com/ZhongFuCheng3y/austin
commit
8ed6ec7bae
@ -0,0 +1,18 @@
|
||||
package com.java3y.austin.common.constant;
|
||||
|
||||
public class CommonConstant {
|
||||
public final static String PERIOD = ".";
|
||||
public final static String COMMA = ",";
|
||||
public final static String COLON = ":";
|
||||
public final static String SEMICOLON = ";";
|
||||
public final static String POUND = "#";
|
||||
public final static String SLASH = "/";
|
||||
public final static String BACKSLASH = "\\";
|
||||
public final static String EMPTY_STRING = "";
|
||||
//
|
||||
public final static String ONE = "1";
|
||||
public final static String ZERO = "0";
|
||||
public final static String MINUS_ONE = "-1";
|
||||
public final static String YES = "Y";
|
||||
public final static String NO = "N";
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.java3y.austin.support.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @program: austin
|
||||
* @description:
|
||||
* @author: Giorno
|
||||
* @create: 2022-07-28
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NacosUtils {
|
||||
@Value("${austin.nacos.server}")
|
||||
private String nacosServer;
|
||||
@Value("${austin.nacos.group}")
|
||||
private String nacosGroup;
|
||||
@Value("${austin.nacos.dataId}")
|
||||
private String nacosDataId;
|
||||
@Value("${austin.nacos.namespace}")
|
||||
private String nacosNamespace;
|
||||
private final Properties request = new Properties();
|
||||
private final Properties properties = new Properties();
|
||||
|
||||
public String getProperty(String key, String defaultValue) {
|
||||
try {
|
||||
String property = this.getContext();
|
||||
if (StringUtils.hasText(property)) {
|
||||
properties.load(new StringReader(property));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Nacos error:{}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
String property = properties.getProperty(key);
|
||||
return StrUtil.isBlank(property) ? defaultValue : property;
|
||||
}
|
||||
|
||||
private String getContext() {
|
||||
String context = null;
|
||||
try {
|
||||
request.put(PropertyKeyConst.SERVER_ADDR, nacosServer);
|
||||
request.put(PropertyKeyConst.NAMESPACE, nacosNamespace);
|
||||
context = NacosFactory.createConfigService(request)
|
||||
.getConfig(nacosDataId, nacosGroup, 5000);
|
||||
} catch (NacosException e) {
|
||||
log.error("Nacos error:{}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
return context;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
nacos1:
|
||||
container_name: nacos-server-1
|
||||
hostname: nacos-server01
|
||||
image: nacos/nacos-server
|
||||
environment:
|
||||
- MODE=cluster
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- NACOS_SERVERS=nacos-server01:8848 nacos-server02:8848 nacos-server03:8848
|
||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
||||
- MYSQL_SERVICE_HOST=mysql
|
||||
- MYSQL_SERVICE_PORT=3306
|
||||
- MYSQL_SERVICE_USER=root
|
||||
- MYSQL_SERVICE_PASSWORD=123456
|
||||
- MYSQL_SERVICE_DB_NAME=nacos-db
|
||||
- JVM_XMS=128m
|
||||
- JVM_XMX=128m
|
||||
- JVM_XMN=128m
|
||||
volumes:
|
||||
- /home/nacos/cluster-logs/nacos-server01:/home/nacos/logs
|
||||
- /home/nacos/init.d:/home/nacos/init.d
|
||||
ports:
|
||||
- 8846:8848
|
||||
- 9555:9555
|
||||
restart: on-failure
|
||||
|
||||
nacos2:
|
||||
container_name: nacos-server-2
|
||||
hostname: nacos-server02
|
||||
image: nacos/nacos-server
|
||||
environment:
|
||||
- MODE=cluster
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- NACOS_SERVERS=nacos-server01:8848 nacos-server02:8848 nacos-server03:8848
|
||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
||||
- MYSQL_SERVICE_HOST=mysql
|
||||
- MYSQL_SERVICE_PORT=3306
|
||||
- MYSQL_SERVICE_USER=root
|
||||
- MYSQL_SERVICE_PASSWORD=123456
|
||||
- MYSQL_SERVICE_DB_NAME=nacos-db
|
||||
- JVM_XMS=128m
|
||||
- JVM_XMX=128m
|
||||
- JVM_XMN=128m
|
||||
volumes:
|
||||
- /home/nacos/cluster-logs/nacos-server02:/home/nacos/logs
|
||||
- /home/nacos/init.d:/home/nacos/init.d
|
||||
ports:
|
||||
- 8847:8848
|
||||
restart: on-failure
|
||||
|
||||
nacos3:
|
||||
container_name: nacos-server-3
|
||||
hostname: nacos-server03
|
||||
image: nacos/nacos-server
|
||||
environment:
|
||||
- MODE=cluster
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- NACOS_SERVERS=nacos-server01:8848 nacos-server02:8848 nacos-server03:8848
|
||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
||||
- MYSQL_SERVICE_HOST=mysql
|
||||
- MYSQL_SERVICE_PORT=3306
|
||||
- MYSQL_SERVICE_USER=root
|
||||
- MYSQL_SERVICE_PASSWORD=123456
|
||||
- MYSQL_SERVICE_DB_NAME=nacos-db
|
||||
- JVM_XMS=128m
|
||||
- JVM_XMX=128m
|
||||
- JVM_XMN=128m
|
||||
volumes:
|
||||
- /home/nacos/cluster-logs/nacos-server03:/home/nacos/logs
|
||||
- /home/nacos/init.d:/home/nacos/init.d
|
||||
ports:
|
||||
- 8848:8848
|
||||
restart: on-failure
|
@ -0,0 +1,25 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
nacos1:
|
||||
container_name: nacos-server
|
||||
hostname: nacos-server
|
||||
image: nacos/nacos-server
|
||||
environment:
|
||||
- MODE=standalone
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
||||
- MYSQL_SERVICE_HOST=mysql
|
||||
- MYSQL_SERVICE_PORT=3306
|
||||
- MYSQL_SERVICE_USER=root
|
||||
- MYSQL_SERVICE_PASSWORD=123456
|
||||
- MYSQL_SERVICE_DB_NAME=nacos-db
|
||||
- JVM_XMS=128m
|
||||
- JVM_XMX=128m
|
||||
- JVM_XMN=128m
|
||||
volumes:
|
||||
- /home/nacos/single-logs/nacos-server:/home/nacos/logs
|
||||
- /home/nacos/init.d:/home/nacos/init.d
|
||||
ports:
|
||||
- 8848:8848
|
||||
restart: on-failure
|
Loading…
Reference in new issue