mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
add constant for MigrateRefreshEventListener and AnsServerList
This commit is contained in:
parent
b16ef5efea
commit
bea88fb2c8
@ -19,6 +19,8 @@ import com.netflix.loadbalancer.ILoadBalancer;
|
||||
@Component
|
||||
public class MigrateRefreshEventListener implements ApplicationListener<RefreshEvent> {
|
||||
|
||||
private final static int CHECK_INTERVAL = 1;
|
||||
|
||||
private final static String MIGRATE_SWITCH = "sca.migrate.ans.switch";
|
||||
|
||||
private volatile String lastScaMigrateAnsSwitchValue = "true";
|
||||
@ -36,7 +38,8 @@ public class MigrateRefreshEventListener implements ApplicationListener<RefreshE
|
||||
@PostConstruct
|
||||
public void initTimerCheck() {
|
||||
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(
|
||||
() -> onApplicationEvent(null), 1, 1, TimeUnit.SECONDS);
|
||||
() -> onApplicationEvent(null), CHECK_INTERVAL, CHECK_INTERVAL,
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,19 +16,21 @@
|
||||
|
||||
package org.springframework.cloud.alicloud.ans.ribbon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.ans.core.NamingService;
|
||||
import com.alibaba.ans.shaded.com.taobao.vipserver.client.core.Host;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
public class AnsServerList extends AbstractServerList<AnsServer> {
|
||||
|
||||
private final static int CONNECT_TIME_OUT = 3;
|
||||
|
||||
private String dom;
|
||||
|
||||
public AnsServerList(String dom) {
|
||||
@ -61,7 +63,7 @@ public class AnsServerList extends AbstractServerList<AnsServer> {
|
||||
for (Host host : hosts) {
|
||||
if (host.isValid()) {
|
||||
AnsServer ansServer = hostToServer(host);
|
||||
if (ansServer.isAlive(3)) {
|
||||
if (ansServer.isAlive(CONNECT_TIME_OUT)) {
|
||||
result.add(ansServer);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user