Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format code #1345

Merged
merged 6 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public class ServerHttpAgent implements HttpAgent {
public HttpResult httpGet(String path, List<String> headers, List<String> paramValues, String encoding,
long readTimeoutMs) throws IOException {
final long endTime = System.currentTimeMillis() + readTimeoutMs;

boolean isSSL = false;
final boolean isSSL = false;

do {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ public void run() {
}
}

// =================

public boolean isHealthServer() {
return isHealthServer;
}
Expand All @@ -525,16 +523,16 @@ private void setHealthServer(boolean isHealthServer) {
this.isHealthServer = isHealthServer;
}

final ScheduledExecutorService executor;
final ExecutorService executorService;
private final ScheduledExecutorService executor;
private final ExecutorService executorService;
/**
* groupKey -> cacheData
*/
AtomicReference<Map<String, CacheData>> cacheMap = new AtomicReference<Map<String, CacheData>>(
private final AtomicReference<Map<String, CacheData>> cacheMap = new AtomicReference<Map<String, CacheData>>(
new HashMap<String, CacheData>());

HttpAgent agent;
ConfigFilterChainManager configFilterChainManager;
private final HttpAgent agent;
private final ConfigFilterChainManager configFilterChainManager;
private boolean isHealthServer = true;
private double currentLongingTaskCount = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
*/
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
public class NacosNamingService implements NamingService {
private static final String DEFAULT_PORT = "8080";

/**
* Each Naming instance should have different namespace.
*/
Expand Down Expand Up @@ -82,7 +84,6 @@ public NacosNamingService(String serverList) {
}

public NacosNamingService(Properties properties) {

init(properties);
}

Expand Down Expand Up @@ -151,15 +152,14 @@ private void initCacheDir() {

private void initEndpoint(final Properties properties) {
if (properties == null) {

return;
}
//这里通过 dubbo/sca 侧来初始化默认传入的是 true
boolean isUseEndpointParsingRule = Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE));
String endpointUrl;
if (isUseEndpointParsingRule) {
endpointUrl = ParamUtil.parsingEndpointRule(properties.getProperty(PropertyKeyConst.ENDPOINT));
if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrl)) {
if (StringUtils.isNotBlank(endpointUrl)) {
serverList = "";
}
} else {
Expand All @@ -181,7 +181,7 @@ public String call() {
endpointPort = TemplateUtils.stringEmptyAndThenExecute(endpointPort, new Callable<String>() {
@Override
public String call() {
return "8080";
return DEFAULT_PORT;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ private static void sleep(int time) {
}
}

static final int RETRY_COUNT = 10;
static final int SLEEP_BASETIME = 10;
private static final int RETRY_COUNT = 10;
private static final int SLEEP_BASETIME = 10;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
*/
public class HostReactor {

public static final long DEFAULT_DELAY = 1000L;
private static final long DEFAULT_DELAY = 1000L;

public long updateHoldInterval = 5000L;
private static final long UPDATE_HOLD_INTERVAL = 5000L;

private final Map<String, ScheduledFuture<?>> futureMap = new HashMap<String, ScheduledFuture<?>>();

Expand Down Expand Up @@ -234,11 +234,11 @@ public ServiceInfo getServiceInfo(final String serviceName, final String cluster

} else if (updatingMap.containsKey(serviceName)) {

if (updateHoldInterval > 0) {
if (UPDATE_HOLD_INTERVAL > 0) {
// hold a moment waiting for update finish
synchronized (serviceObj) {
try {
serviceObj.wait(updateHoldInterval);
serviceObj.wait(UPDATE_HOLD_INTERVAL);
} catch (InterruptedException e) {
NAMING_LOGGER.error("[getServiceInfo] serviceName:" + serviceName + ", clusters:" + clusters, e);
}
Expand Down
20 changes: 7 additions & 13 deletions client/src/main/java/com/alibaba/nacos/client/utils/EnvUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,22 @@ public static String getSelfLocationTag() {
return selfLocationTag;
}

public static String listToString(List<String> list) {
if (list == null) {
private static String listToString(List<String> list) {
if (list == null || list.isEmpty()) {
return null;
}
StringBuilder result = new StringBuilder();
boolean first = true;
// 第一个前面不拼接","
for (String string : list) {
if (first) {
first = false;
} else {
result.append(",");
}
result.append(string);
result.append(",");
}
return result.toString();
return result.toString().substring(0, result.length() - 1);
}

private static String selfAmorayTag;
private static String selfVipserverTag;
private static String selfLocationTag;
public final static String AMORY_TAG = "Amory-Tag";
public final static String VIPSERVER_TAG = "Vipserver-Tag";
public final static String LOCATION_TAG = "Location-Tag";
private final static String AMORY_TAG = "Amory-Tag";
private final static String VIPSERVER_TAG = "Vipserver-Tag";
private final static String LOCATION_TAG = "Location-Tag";
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ public static boolean isBlank(String str) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
}

public static boolean isNotBlank(String str) {

return !isBlank(str);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Component("serverListManager")
public class ServerListManager {

public static final int STABLE_PERIOD = 60 * 1000;
private static final int STABLE_PERIOD = 60 * 1000;

@Autowired
private SwitchDomain switchDomain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ public JSONObject beat(HttpServletRequest request) throws Exception {

String clusterName = clientBeat.getCluster();

if (StringUtils.isBlank(clusterName)) {
clusterName = UtilsAndCommons.DEFAULT_CLUSTER_NAME;
}

if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("[CLIENT-BEAT] full arguments: beat: {}, serviceName: {}", clientBeat, serviceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.alibaba.nacos.naming.boot.RunningConfig;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
import org.springframework.util.StringUtils;

import java.net.HttpURLConnection;
import java.util.HashMap;
Expand All @@ -31,7 +32,7 @@
public class ServerStatusSynchronizer implements Synchronizer {
@Override
public void send(final String serverIP, Message msg) {
if (serverIP == null) {
if (StringUtils.isEmpty(serverIP)) {
return;
}

Expand Down