This commit is contained in:
mercyblitz 2018-10-01 22:54:37 +08:00
parent 3b5eb060e8
commit c0a25c148a
20 changed files with 297 additions and 260 deletions

View File

@ -16,18 +16,23 @@
package com.alibaba.nacos.common.util;
import com.sun.management.OperatingSystemMXBean;
import org.apache.commons.lang3.StringUtils;
import java.lang.management.ManagementFactory;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.sun.management.OperatingSystemMXBean;
/**
* @author nacos
*/
public class SystemUtil {
public class SystemUtils {
/**
* Standalone mode or not
*/
public static final boolean STANDALONE_MODE = Boolean.getBoolean("nacos.standalone");
private static OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();

View File

@ -104,7 +104,7 @@
// * 事务的超时时间需要与普通操作区分开
// */
// tjt.setTimeout(TRANSACTION_QUERY_TIMEOUT);
// if (!PropertyUtil.isStandaloneMode()) {
// if (!STANDALONE_MODE) {
// try {
// reload();
// } catch (IOException e) {

View File

@ -0,0 +1,29 @@
/*
* 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 com.alibaba.nacos.config.server.configuration;
import org.springframework.context.annotation.Configuration;
/**
* Nacos Config {@link Configuration} includes required Spring components.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 0.2.2
*/
@Configuration
public class NacosConfigConfiguration {
}

View File

@ -41,6 +41,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.pullLog;
/**
@ -133,7 +134,7 @@ public class ConfigServletInner {
if (isBeta) {
md5 = cacheItem.getMd54Beta();
lastModified = cacheItem.getLastModifiedTs4Beta();
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
configInfoBase = persistService.findConfigInfo4Beta(dataId, group,tenant);
} else {
file = DiskUtil.targetBetaFile(dataId, group, tenant);
@ -150,7 +151,7 @@ public class ConfigServletInner {
lastModified = cacheItem.tagLastModifiedTs.get(autoTag);
}
}
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
configInfoBase = persistService.findConfigInfo4Tag(dataId, group, tenant, autoTag);
} else {
file = DiskUtil.targetTagFile(dataId, group, tenant, autoTag);
@ -161,7 +162,7 @@ public class ConfigServletInner {
} else {
md5 = cacheItem.getMd5();
lastModified = cacheItem.getLastModifiedTs();
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
configInfoBase = persistService.findConfigInfo(dataId, group, tenant);
} else {
file = DiskUtil.targetFile(dataId, group, tenant);
@ -193,7 +194,7 @@ public class ConfigServletInner {
}
}
}
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
configInfoBase = persistService.findConfigInfo4Tag(dataId, group, tenant, tag);
} else {
file = DiskUtil.targetTagFile(dataId, group, tenant, tag);
@ -222,7 +223,7 @@ public class ConfigServletInner {
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache,no-store");
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
response.setDateHeader("Last-Modified", lastModified);
} else {
fis = new FileInputStream(file);
@ -230,7 +231,7 @@ public class ConfigServletInner {
}
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
out = response.getWriter();
out.print(configInfoBase.getContent());
out.flush();

View File

@ -19,6 +19,7 @@ import com.alibaba.nacos.config.server.constant.Constants;
import org.springframework.core.annotation.Order;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog;
@ -30,8 +31,8 @@ import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog;
*
*/
@Order(1)
@javax.servlet.annotation.WebFilter(filterName = "webFilter", urlPatterns = "/*")
public class WebFilter implements Filter {
@WebFilter(filterName = "webFilter", urlPatterns = "/*")
public class NacosWebFilter implements Filter {
static private String webRootPath;

View File

@ -15,7 +15,6 @@
*/
package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
@ -37,6 +36,7 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.service.PersistService.CONFIG_INFO4BETA_ROW_MAPPER;
import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog;
import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog;
@ -105,7 +105,7 @@ public class BasicDataSourceServiceImpl implements DataSourceService {
* 事务的超时时间需要与普通操作区分开
*/
tjt.setTimeout(TRANSACTION_QUERY_TIMEOUT);
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
try {
reload();
} catch (IOException e) {

View File

@ -21,7 +21,6 @@ import com.alibaba.nacos.config.server.model.ConfigInfoBase;
import com.alibaba.nacos.config.server.utils.GroupKey;
import com.alibaba.nacos.config.server.utils.GroupKey2;
import com.alibaba.nacos.config.server.utils.MD5;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -33,6 +32,7 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.*;
/**
@ -74,7 +74,7 @@ public class ConfigService {
"[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
} else if (!STANDALONE_MODE) {
DiskUtil.saveToDisk(dataId, group, tenant, content);
}
updateMd5(groupKey, md5, lastModifiedTs);
@ -118,7 +118,7 @@ public class ConfigService {
"[dump-beta-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
} else if (!STANDALONE_MODE) {
DiskUtil.saveBetaToDisk(dataId, group, tenant, content);
}
String[] betaIpsArr = betaIps.split(",");
@ -156,7 +156,7 @@ public class ConfigService {
"[dump-tag-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
} else if (!STANDALONE_MODE) {
DiskUtil.saveTagToDisk(dataId, group, tenant, tag, content);
}
@ -188,7 +188,7 @@ public class ConfigService {
try {
final String md5 = MD5.getInstance().getMD5String(content);
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
String loacalMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant);
if(md5.equals(loacalMd5)) {
dumpLog.warn(
@ -214,7 +214,7 @@ public class ConfigService {
{
String aggreds = null;
try {
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
ConfigInfoBase config = persistService.findConfigInfoBase(AggrWhitelist.AGGRIDS_METADATA, "DEFAULT_GROUP");
if (config != null) {
aggreds = config.getContent();
@ -232,7 +232,7 @@ public class ConfigService {
String clientIpWhitelist = null;
try {
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
ConfigInfoBase config = persistService.findConfigInfoBase(ClientIpWhiteList.CLIENT_IP_WHITELIST_METADATA, "DEFAULT_GROUP");
if (config != null) {
clientIpWhitelist = config.getContent();
@ -251,7 +251,7 @@ public class ConfigService {
String switchContent= null;
try {
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
ConfigInfoBase config = persistService.findConfigInfoBase(SwitchService.SWITCH_META_DATAID, "DEFAULT_GROUP");
if (config != null) {
switchContent = config.getContent();
@ -318,7 +318,7 @@ public class ConfigService {
}
try {
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
DiskUtil.removeConfigInfo(dataId, group, tenant);
}
CACHE.remove(groupKey);
@ -351,7 +351,7 @@ public class ConfigService {
}
try {
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
DiskUtil.removeConfigInfo4Beta(dataId, group, tenant);
}
EventDispatcher.fireEvent(new LocalDataChangeEvent(groupKey, true, CACHE.get(groupKey).getIps4Beta()));
@ -386,7 +386,7 @@ public class ConfigService {
}
try {
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
DiskUtil.removeConfigInfo4Tag(dataId, group, tenant, tag);
}

View File

@ -15,11 +15,12 @@
*/
package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* datasource adapter
* @author Nacos
@ -40,7 +41,7 @@ public class DynamicDataSource implements ApplicationContextAware {
public DataSourceService getDataSource() {
DataSourceService dataSourceService = null;
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
dataSourceService = (DataSourceService)applicationContext.getBean("localDataSourceService");
} else {
dataSourceService = (DataSourceService)applicationContext.getBean("basicDataSourceService");

View File

@ -17,7 +17,6 @@ package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.StringUtils;
import org.apache.commons.dbcp.BasicDataSource;
import org.slf4j.Logger;
@ -39,6 +38,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* local data source
*
@ -88,7 +89,7 @@ public class LocalDataSourceServiceImpl implements DataSourceService {
tm.setDataSource(ds);
tjt.setTimeout(5000);
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
reload();
}
}

View File

@ -47,6 +47,7 @@ import java.util.*;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog;
import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog;
@ -240,7 +241,7 @@ public class ServerListService implements ApplicationListener<WebServerInitializ
defaultLog.error("nacos-XXXX", "[serverlist] failed to get serverlist from disk!", e);
}
if (isUseAddressServer() && !PropertyUtil.isStandaloneMode()) {
if (isUseAddressServer() && !STANDALONE_MODE) {
try {
HttpResult result = NotifyService.invokeURL(addressServerUrl, null, null);

View File

@ -19,7 +19,6 @@ import com.alibaba.nacos.config.server.model.capacity.Capacity;
import com.alibaba.nacos.config.server.model.capacity.GroupCapacity;
import com.alibaba.nacos.config.server.service.DataSourceService;
import com.alibaba.nacos.config.server.service.DynamicDataSource;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.TimeUtils;
import com.google.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -35,6 +34,7 @@ import javax.annotation.PostConstruct;
import java.sql.*;
import java.util.List;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog;
/**
@ -279,7 +279,7 @@ public class GroupCapacityPersistService {
public List<GroupCapacity> getCapacityList4CorrectUsage(long lastId, int pageSize) {
String sql = "select id, group_id from group_capacity where id>? limit ?";
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
sql = "select id, group_id from group_capacity where id>? OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY";
}
try {

View File

@ -18,7 +18,6 @@ package com.alibaba.nacos.config.server.service.capacity;
import com.alibaba.nacos.config.server.model.capacity.TenantCapacity;
import com.alibaba.nacos.config.server.service.DataSourceService;
import com.alibaba.nacos.config.server.service.DynamicDataSource;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.TimeUtils;
import com.google.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -34,6 +33,7 @@ import javax.annotation.PostConstruct;
import java.sql.*;
import java.util.List;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog;
/**
@ -229,7 +229,7 @@ public class TenantCapacityPersistService {
public List<TenantCapacity> getCapacityList4CorrectUsage(long lastId, int pageSize) {
String sql = "select id, tenant_id from tenant_capacity where id>? limit ?";
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
sql = "select id, tenant_id from tenant_capacity where id>? OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY";
}

View File

@ -46,6 +46,7 @@ import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog;
/**
@ -152,7 +153,7 @@ public class DumpService {
throw new RuntimeException(
"Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage());
}
if (!PropertyUtil.isStandaloneMode()) {
if (!STANDALONE_MODE) {
Runnable heartbeat = new Runnable() {
@Override
public void run() {

View File

@ -21,6 +21,8 @@ import org.springframework.jdbc.core.RowMapper;
import java.util.List;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* 分页辅助类
@ -87,7 +89,7 @@ public class PaginationHelper<E> {
final int startRow = (pageNo - 1) * pageSize;
String selectSQL = "";
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
selectSQL = sqlFetchRows + " OFFSET "+startRow+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY";
} else if (lastMaxId != null) {
selectSQL = sqlFetchRows + " and id > " + lastMaxId + " order by id asc" + " limit " + 0 + "," + pageSize;
@ -131,7 +133,7 @@ public class PaginationHelper<E> {
}
String selectSQL = sqlFetchRows;
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
selectSQL = selectSQL.replaceAll("(?i)LIMIT \\?,\\?", "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
}
@ -171,7 +173,7 @@ public class PaginationHelper<E> {
}
String selectSQL = sqlFetchRows;
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
selectSQL = selectSQL.replaceAll("(?i)LIMIT \\?,\\?", "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
}
@ -191,7 +193,7 @@ public class PaginationHelper<E> {
final Page<E> page = new Page<E>();
String selectSQL = sqlFetchRows;
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
selectSQL = selectSQL.replaceAll("(?i)LIMIT \\?,\\?", "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
}
@ -205,7 +207,7 @@ public class PaginationHelper<E> {
public void updateLimit(final JdbcTemplate jt, final String sql, final Object args[]) {
String sqlUpdate = sql;
if (PropertyUtil.isStandaloneMode()) {
if (STANDALONE_MODE) {
sqlUpdate = sqlUpdate.replaceAll("limit \\?", "OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY");
}

View File

@ -22,11 +22,12 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* properties utils
*
* @author Nacos
*
*/
@Component
public class PropertyUtil {
@ -80,15 +81,9 @@ public class PropertyUtil {
*/
private static int correctUsageDelay = 10 * 60;
private static boolean standaloneMode = false;
@Autowired
private Environment env;
static {
setStandaloneMode(Boolean.parseBoolean(System.getProperty("nacos.standalone", "false")));
}
@PostConstruct
public void init() {
try {
@ -206,11 +201,7 @@ public class PropertyUtil {
}
public static boolean isStandaloneMode() {
return standaloneMode;
}
public static void setStandaloneMode(boolean standaloneMode) {
PropertyUtil.standaloneMode = standaloneMode;
return STANDALONE_MODE;
}
public static void setNotifyConnectTimeout(int notifyConnectTimeout) {

View File

@ -15,13 +15,12 @@
*/
package com.alibaba.nacos.naming.misc;
import com.alibaba.nacos.common.util.SystemUtil;
import com.alibaba.nacos.common.util.SystemUtils;
import com.alibaba.nacos.naming.boot.RunningConfig;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
@ -32,6 +31,8 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* @author nacos
*/
@ -62,7 +63,7 @@ public class NamingProxy {
private static String jmenv;
public static String getJmenv() {
jmenv = SystemUtil.getSystemEnv("nacos_jmenv_domain");
jmenv = SystemUtils.getSystemEnv("nacos_jmenv_domain");
if (StringUtils.isEmpty(jmenv)) {
jmenv = System.getProperty("com.alibaba.nacos.naming.jmenv", "jmenv.tbsite.net");
@ -106,7 +107,7 @@ public class NamingProxy {
return;
}
if (UtilsAndCommons.STANDALONE_MODE) {
if (STANDALONE_MODE) {
servers = new ArrayList<>();
servers.add(InetAddress.getLocalHost().getHostAddress() + ":" + RunningConfig.getServerPort());
return;
@ -165,7 +166,7 @@ public class NamingProxy {
//use system env
if (CollectionUtils.isEmpty(result)) {
result = SystemUtil.getIPsBySystemEnv(UtilsAndCommons.SELF_SERVICE_CLUSTER_ENV);
result = SystemUtils.getIPsBySystemEnv(UtilsAndCommons.SELF_SERVICE_CLUSTER_ENV);
Loggers.DEBUG_LOG.debug("REFRESH-SERVER-LIST4: " + result);
}

View File

@ -80,8 +80,6 @@ public class UtilsAndCommons {
public static final String SELF_SERVICE_CLUSTER_ENV = "naming_self_service_cluster_ips";
public static final boolean STANDALONE_MODE = Boolean.parseBoolean(System.getProperty("nacos.standalone", "false"));
public static final String CACHE_KEY_SPLITER = "@@@@";
public static final String LOCAL_HOST_IP = "127.0.0.1";

View File

@ -19,7 +19,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.naming.misc.HttpClient;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.NetUtils;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
import org.apache.commons.collections.SortedBag;
@ -30,6 +29,8 @@ import org.apache.commons.lang3.StringUtils;
import java.net.HttpURLConnection;
import java.util.*;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* @author nacos
*/
@ -45,7 +46,7 @@ public class PeerSet {
}
public RaftPeer getLeader() {
if (UtilsAndCommons.STANDALONE_MODE) {
if (STANDALONE_MODE) {
return local();
}
return leader;
@ -63,7 +64,7 @@ public class PeerSet {
peers.put(server, peer);
}
if (UtilsAndCommons.STANDALONE_MODE) {
if (STANDALONE_MODE) {
RaftPeer local = local();
local.state = RaftPeer.State.LEADER;
local.voteFor = NetUtils.localIP();
@ -83,7 +84,7 @@ public class PeerSet {
}
public boolean isLeader(String ip) {
if (UtilsAndCommons.STANDALONE_MODE) {
if (STANDALONE_MODE) {
return true;
}

View File

@ -37,6 +37,8 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.zip.GZIPOutputStream;
import static com.alibaba.nacos.common.util.SystemUtils.STANDALONE_MODE;
/**
* @author nacos
*/
@ -525,7 +527,7 @@ public class RaftCore {
public static void sendBeat() throws IOException, InterruptedException {
RaftPeer local = peers.local();
if (local.state != RaftPeer.State.LEADER && !UtilsAndCommons.STANDALONE_MODE) {
if (local.state != RaftPeer.State.LEADER && !STANDALONE_MODE) {
return;
}

View File

@ -19,9 +19,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.nacos.common.util.IoUtils;
import com.alibaba.nacos.common.util.Md5Utils;
import com.alibaba.nacos.common.util.SystemUtil;
import com.alibaba.nacos.common.util.SystemUtils;
import com.alibaba.nacos.naming.boot.RunningConfig;
import com.alibaba.nacos.naming.core.*;
import com.alibaba.nacos.naming.exception.NacosException;
@ -50,7 +49,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -2002,9 +2004,9 @@ public class ApiCommands {
result.put("ipCount", ipCount);
result.put("responsibleDomCount", responsibleDomCount);
result.put("responsibleIPCount", responsibleIPCount);
result.put("cpu", SystemUtil.getCPU());
result.put("load", SystemUtil.getLoad());
result.put("mem", SystemUtil.getMem());
result.put("cpu", SystemUtils.getCPU());
result.put("load", SystemUtils.getLoad());
result.put("mem", SystemUtils.getMem());
return result;
}