format code
This commit is contained in:
parent
781273faa6
commit
34025a5132
@ -56,7 +56,7 @@ public class NacosConfigService implements ConfigService {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.logger(NacosConfigService.class);
|
private static final Logger LOGGER = LogUtils.logger(NacosConfigService.class);
|
||||||
|
|
||||||
private final long POST_TIMEOUT = 3000L;
|
private static final long POST_TIMEOUT = 3000L;
|
||||||
|
|
||||||
private static final String EMPTY = "";
|
private static final String EMPTY = "";
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ public class Limiter {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.logger(Limiter.class);
|
private static final Logger LOGGER = LogUtils.logger(Limiter.class);
|
||||||
|
|
||||||
private static int CAPACITY_SIZE = 1000;
|
private static final int CAPACITY_SIZE = 1000;
|
||||||
private static int LIMIT_TIME = 1000;
|
private static final int LIMIT_TIME = 1000;
|
||||||
private static Cache<String, RateLimiter> cache = CacheBuilder.newBuilder()
|
private static Cache<String, RateLimiter> cache = CacheBuilder.newBuilder()
|
||||||
.initialCapacity(CAPACITY_SIZE).expireAfterAccess(1, TimeUnit.MINUTES)
|
.initialCapacity(CAPACITY_SIZE).expireAfterAccess(1, TimeUnit.MINUTES)
|
||||||
.build();
|
.build();
|
||||||
|
@ -100,6 +100,6 @@ public class SpasAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String GROUP_KEY = "group";
|
private static final String GROUP_KEY = "group";
|
||||||
private static String TENANT_KEY = "tenant";
|
private static final String TENANT_KEY = "tenant";
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class JVMUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean isMultiInstance = false;
|
private static Boolean isMultiInstance = false;
|
||||||
private static String TRUE = "true";
|
private static final String TRUE = "true";
|
||||||
private static final Logger LOGGER = LogUtils.logger(JVMUtil.class);
|
private static final Logger LOGGER = LogUtils.logger(JVMUtil.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -32,8 +32,6 @@ public class BeatReactor {
|
|||||||
|
|
||||||
private ScheduledExecutorService executorService;
|
private ScheduledExecutorService executorService;
|
||||||
|
|
||||||
private volatile long clientBeatInterval = 5 * 1000;
|
|
||||||
|
|
||||||
private NamingProxy serverProxy;
|
private NamingProxy serverProxy;
|
||||||
|
|
||||||
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<String, BeatInfo>();
|
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<String, BeatInfo>();
|
||||||
|
@ -195,7 +195,7 @@ public class HostReactor {
|
|||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceInfo getSerivceInfo0(String serviceName, String clusters) {
|
private ServiceInfo getServiceInfo0(String serviceName, String clusters) {
|
||||||
|
|
||||||
String key = ServiceInfo.getKey(serviceName, clusters);
|
String key = ServiceInfo.getKey(serviceName, clusters);
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ public class HostReactor {
|
|||||||
return failoverReactor.getService(key);
|
return failoverReactor.getService(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceInfo serviceObj = getSerivceInfo0(serviceName, clusters);
|
ServiceInfo serviceObj = getServiceInfo0(serviceName, clusters);
|
||||||
|
|
||||||
if (null == serviceObj) {
|
if (null == serviceObj) {
|
||||||
serviceObj = new ServiceInfo(serviceName, clusters);
|
serviceObj = new ServiceInfo(serviceName, clusters);
|
||||||
@ -264,7 +264,7 @@ public class HostReactor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateServiceNow(String serviceName, String clusters) {
|
public void updateServiceNow(String serviceName, String clusters) {
|
||||||
ServiceInfo oldService = getSerivceInfo0(serviceName, clusters);
|
ServiceInfo oldService = getServiceInfo0(serviceName, clusters);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String result = serverProxy.queryList(serviceName, clusters, pushReceiver.getUDPPort(), false);
|
String result = serverProxy.queryList(serviceName, clusters, pushReceiver.getUDPPort(), false);
|
||||||
|
@ -138,7 +138,7 @@ public class Chooser<K, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double doublePrecisionDelta = 0.0001;
|
double doublePrecisionDelta = 0.0001;
|
||||||
if (index != 0 && !(Math.abs(weights[index - 1] - 1) < doublePrecisionDelta)) {
|
if (index == 0 || (Math.abs(weights[index - 1] - 1) < doublePrecisionDelta)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Cumulative Weight caculate wrong , the sum of probabilities does not equals 1.");
|
"Cumulative Weight caculate wrong , the sum of probabilities does not equals 1.");
|
||||||
}
|
}
|
||||||
|
@ -178,15 +178,22 @@ public class IoUtils {
|
|||||||
if (!isGzipStream(raw)) {
|
if (!isGzipStream(raw)) {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
GZIPInputStream gis = null;
|
||||||
|
ByteArrayOutputStream out = null;
|
||||||
|
|
||||||
GZIPInputStream gis
|
try {
|
||||||
= new GZIPInputStream(new ByteArrayInputStream(raw));
|
gis = new GZIPInputStream(new ByteArrayInputStream(raw));
|
||||||
ByteArrayOutputStream out
|
out = new ByteArrayOutputStream();
|
||||||
= new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
IoUtils.copy(gis, out);
|
IoUtils.copy(gis, out);
|
||||||
|
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
if (gis != null) {
|
||||||
|
gis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class RandomUtils {
|
|||||||
/**
|
/**
|
||||||
* An instance of {@link JvmRandom}.
|
* An instance of {@link JvmRandom}.
|
||||||
*/
|
*/
|
||||||
public static final Random JVM_RANDOM = new JvmRandom();
|
private static final Random JVM_RANDOM = new JvmRandom();
|
||||||
|
|
||||||
// should be possible for JVM_RANDOM?
|
// should be possible for JVM_RANDOM?
|
||||||
// public static void nextBytes(byte[]) {
|
// public static void nextBytes(byte[]) {
|
||||||
|
@ -26,31 +26,23 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
||||||
public class IPUtil {
|
public class IPUtil {
|
||||||
|
|
||||||
|
private static final String IPV4_PATTERN = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$";
|
||||||
|
private static final String IPV6_PATTERN = "^([\\da-fA-F]{1,4}:){7}[\\da-fA-F]{1,4}$";
|
||||||
|
|
||||||
public static boolean isIPV4(String addr) {
|
public static boolean isIPV4(String addr) {
|
||||||
if (null == addr) {
|
return isMatch(addr, IPV4_PATTERN);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String rexp = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$";
|
|
||||||
|
|
||||||
Pattern pat = Pattern.compile(rexp);
|
|
||||||
|
|
||||||
Matcher mat = pat.matcher(addr);
|
|
||||||
|
|
||||||
boolean ipAddress = mat.find();
|
|
||||||
return ipAddress;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIPV6(String addr) {
|
public static boolean isIPV6(String addr) {
|
||||||
if (null == addr) {
|
return isMatch(addr, IPV6_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isMatch(String data, String pattern) {
|
||||||
|
if (StringUtils.isBlank(data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String rexp = "^([\\da-fA-F]{1,4}:){7}[\\da-fA-F]{1,4}$";
|
Pattern pat = Pattern.compile(pattern);
|
||||||
|
Matcher mat = pat.matcher(data);
|
||||||
Pattern pat = Pattern.compile(rexp);
|
return mat.find();
|
||||||
|
|
||||||
Matcher mat = pat.matcher(addr);
|
|
||||||
|
|
||||||
boolean ipAddress = mat.find();
|
|
||||||
return ipAddress;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
||||||
public class JSONUtils {
|
public class JSONUtils {
|
||||||
|
|
||||||
static ObjectMapper mapper = new ObjectMapper();
|
private static ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Locale;
|
|||||||
*/
|
*/
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
|
|
||||||
public static final int INDEX_NOT_FOUND = -1;
|
private static final int INDEX_NOT_FOUND = -1;
|
||||||
|
|
||||||
public static final String EMPTY = "";
|
public static final String EMPTY = "";
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class CmdbProvider implements CmdbReader, CmdbWriter {
|
|||||||
|
|
||||||
private CmdbService cmdbService;
|
private CmdbService cmdbService;
|
||||||
|
|
||||||
ServiceLoader<CmdbService> serviceLoader = ServiceLoader.load(CmdbService.class);
|
private ServiceLoader<CmdbService> serviceLoader = ServiceLoader.load(CmdbService.class);
|
||||||
|
|
||||||
private Map<String, Map<String, Entity>> entityMap = new ConcurrentHashMap<>();
|
private Map<String, Map<String, Entity>> entityMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.ThreadFactory;
|
|||||||
*/
|
*/
|
||||||
public class UtilsAndCommons {
|
public class UtilsAndCommons {
|
||||||
|
|
||||||
public static final String NACOS_SERVER_VERSION = "/v1";
|
private static final String NACOS_SERVER_VERSION = "/v1";
|
||||||
|
|
||||||
public static final String NACOS_CMDB_CONTEXT = NACOS_SERVER_VERSION + "/cmdb";
|
public static final String NACOS_CMDB_CONTEXT = NACOS_SERVER_VERSION + "/cmdb";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user