Remove unused code

This commit is contained in:
nkorange 2018-07-21 17:08:16 +08:00
parent e6be0f7634
commit 4189d6f178
4 changed files with 26 additions and 73 deletions

View File

@ -49,8 +49,6 @@ public class DistroMapper {
public static final String LOCALHOST_SITE = UtilsAndCommons.UNKNOWN_SITE;
private static long HEALTH_TIME_OUT_MILLIS = TimeUnit.SECONDS.toMillis(30);
private static long LAST_HEALTH_SERVER_MILLIS = 0L;
private static boolean AUTO_DISABLED_HEALTH_CHECK = false;
@ -352,10 +350,6 @@ public class DistroMapper {
return liveSites;
}
public static boolean liveSite(String site) {
return liveSites.contains(site);
}
public static void clean() {
cleanInvalidServers();
@ -370,10 +364,6 @@ public class DistroMapper {
}
}
public static void cleanWithoutDiamond() {
cleanInvalidServers();
}
private static void cleanInvalidServers() {
for (Map.Entry<String, List<Server>> entry : distroConfig.entrySet()) {

View File

@ -53,7 +53,7 @@ public class DomainStatusSynchronizer implements Synchronizer {
@Override
public Integer onCompleted(Response response) throws Exception {
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to requerst domStatus, remote server: " + serverIP);
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to request domStatus, remote server: " + serverIP);
return 1;
}
@ -61,7 +61,7 @@ public class DomainStatusSynchronizer implements Synchronizer {
}
});
} catch (Exception e) {
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to requerst domStatus, remote server: " + serverIP, e);
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to request domStatus, remote server: " + serverIP, e);
}
}

View File

@ -52,7 +52,7 @@ public class ServerStatusSynchronizer implements Synchronizer {
@Override
public Integer onCompleted(Response response) throws Exception {
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to requerst serverStatus, remote server: " + serverIP);
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to request serverStatus, remote server: " + serverIP);
return 1;
}
@ -60,7 +60,7 @@ public class ServerStatusSynchronizer implements Synchronizer {
}
});
} catch (Exception e) {
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to requerst serverStatus, remote server: " + serverIP, e);
Loggers.SRV_LOG.warn("STATUS-SYNCHRONIZE", "failed to request serverStatus, remote server: " + serverIP, e);
}
}

View File

@ -73,43 +73,31 @@ public class ApiCommands {
@Autowired
protected DomainsManager domainsManager;
private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("com.alibaba.nacos.naming.setWeights4AllIPs.thread");
t.setDaemon(true);
return t;
private DataSource pushDataSource = client -> {
Map<String, String[]> params = new HashMap<String, String[]>(10);
params.put("dom", new String[]{client.getDom()});
params.put("clusters", new String[]{client.getClusters()});
// set udp port to 0, otherwise will cause recursion
params.put("udpPort", new String[]{"0"});
InetAddress inetAddress = client.getSocketAddr().getAddress();
params.put("clientIP", new String[]{inetAddress.getHostAddress()});
params.put("header:Client-Version", new String[]{client.getAgent()});
JSONObject result = new JSONObject();
try {
result = srvIPXT(MockHttpRequest.buildRequest(params));
} catch (Exception e) {
Loggers.SRV_LOG.warn("PUSH-SERVICE", "dom is not modified");
}
});
private DataSource pushDataSource = new DataSource() {
@Override
public String getData(PushService.PushClient client) {
// overdrive the cache millis to push mode
result.put("cacheMillis", Switch.getPushCacheMillis(client.getDom()));
Map<String, String[]> params = new HashMap<String, String[]>(10);
params.put("dom", new String[]{client.getDom()});
params.put("clusters", new String[]{client.getClusters()});
// set udp port to 0, otherwise will cause recursion
params.put("udpPort", new String[]{"0"});
InetAddress inetAddress = client.getSocketAddr().getAddress();
params.put("clientIP", new String[]{inetAddress.getHostAddress()});
params.put("header:Client-Version", new String[]{client.getAgent()});
JSONObject result = new JSONObject();
try {
result = srvIPXT(MockHttpRequest.buildRequest(params));
} catch (Exception e) {
Loggers.SRV_LOG.warn("PUSH-SERVICE", "dom is not modified");
}
// overdrive the cache millis to push mode
result.put("cacheMillis", Switch.getPushCacheMillis(client.getDom()));
return result.toJSONString();
}
return result.toJSONString();
};
@ -2424,29 +2412,4 @@ public class ApiCommands {
this.domainsManager = domainsManager;
}
public boolean isEnableTrafficSchedule(String agent) {
ClientInfo clientInfo = new ClientInfo(agent);
if (clientInfo.type == ClientInfo.ClientType.C
&& clientInfo.version.compareTo(VersionUtil.parseVersion(Switch.getTrafficSchedulingCVersion())) >= 0) {
return true;
}
if (clientInfo.type == ClientInfo.ClientType.JAVA
&& clientInfo.version.compareTo(VersionUtil.parseVersion(Switch.getTrafficSchedulingJavaVersion())) >= 0) {
return true;
}
if (clientInfo.type == ClientInfo.ClientType.DNS
&& clientInfo.version.compareTo(VersionUtil.parseVersion(Switch.getTrafficSchedulingPythonVersion())) >= 0) {
return true;
}
if (clientInfo.type == ClientInfo.ClientType.TENGINE
&& clientInfo.version.compareTo(VersionUtil.parseVersion(Switch.getTrafficSchedulingTengineVersion())) >= 0) {
return true;
}
return false;
}
}