add multi tenant testcases
This commit is contained in:
commit
55e750e3d2
@ -16,7 +16,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -31,5 +31,7 @@ public class PropertyKeyConst {
|
|||||||
public final static String CLUSTER_NAME = "clusterName";
|
public final static String CLUSTER_NAME = "clusterName";
|
||||||
public final static String ENCODE = "encode";
|
public final static String ENCODE = "encode";
|
||||||
public final static String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";
|
public final static String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";
|
||||||
|
public final static String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";
|
||||||
|
public final static String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import com.alibaba.nacos.client.naming.utils.LogUtils;
|
|||||||
import com.alibaba.nacos.client.naming.utils.StringUtils;
|
import com.alibaba.nacos.client.naming.utils.StringUtils;
|
||||||
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -101,7 +102,7 @@ public class NacosNamingService implements NamingService {
|
|||||||
eventDispatcher = new EventDispatcher();
|
eventDispatcher = new EventDispatcher();
|
||||||
serverProxy = new NamingProxy(namespace, endpoint, serverList);
|
serverProxy = new NamingProxy(namespace, endpoint, serverList);
|
||||||
beatReactor = new BeatReactor(serverProxy);
|
beatReactor = new BeatReactor(serverProxy);
|
||||||
hostReactor = new HostReactor(eventDispatcher, serverProxy, cacheDir, false);
|
hostReactor = new HostReactor(eventDispatcher, serverProxy, cacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosNamingService(Properties properties) {
|
public NacosNamingService(Properties properties) {
|
||||||
@ -131,10 +132,16 @@ public class NacosNamingService implements NamingService {
|
|||||||
properties.getProperty(PropertyKeyConst.NAMING_LOAD_CACHE_AT_START));
|
properties.getProperty(PropertyKeyConst.NAMING_LOAD_CACHE_AT_START));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int clientBeatThreadCount = NumberUtils.toInt(properties.getProperty(PropertyKeyConst.NAMING_CLIENT_BEAT_THREAD_COUNT),
|
||||||
|
UtilAndComs.DEFAULT_CLIENT_BEAT_THREAD_COUNT);
|
||||||
|
|
||||||
|
int pollingThreadCount = NumberUtils.toInt(properties.getProperty(PropertyKeyConst.NAMING_POLLING_THREAD_COUNT),
|
||||||
|
UtilAndComs.DEFAULT_POLLING_THREAD_COUNT);
|
||||||
|
|
||||||
eventDispatcher = new EventDispatcher();
|
eventDispatcher = new EventDispatcher();
|
||||||
serverProxy = new NamingProxy(namespace, endpoint, serverList);
|
serverProxy = new NamingProxy(namespace, endpoint, serverList);
|
||||||
beatReactor = new BeatReactor(serverProxy);
|
beatReactor = new BeatReactor(serverProxy, clientBeatThreadCount);
|
||||||
hostReactor = new HostReactor(eventDispatcher, serverProxy, cacheDir, loadCacheAtStart);
|
hostReactor = new HostReactor(eventDispatcher, serverProxy, cacheDir, loadCacheAtStart, pollingThreadCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.client.naming.beat;
|
|||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.client.naming.net.NamingProxy;
|
import com.alibaba.nacos.client.naming.net.NamingProxy;
|
||||||
import com.alibaba.nacos.client.naming.utils.LogUtils;
|
import com.alibaba.nacos.client.naming.utils.LogUtils;
|
||||||
|
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
@ -27,15 +28,7 @@ import java.util.concurrent.*;
|
|||||||
*/
|
*/
|
||||||
public class BeatReactor {
|
public class BeatReactor {
|
||||||
|
|
||||||
private ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
|
private ScheduledExecutorService executorService;
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
Thread thread = new Thread(r);
|
|
||||||
thread.setDaemon(true);
|
|
||||||
thread.setName("com.alibaba.nacos.naming.beat.sender");
|
|
||||||
return thread;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
private long clientBeatInterval = 5 * 1000;
|
private long clientBeatInterval = 5 * 1000;
|
||||||
|
|
||||||
@ -44,7 +37,22 @@ public class BeatReactor {
|
|||||||
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<String, BeatInfo>();
|
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<String, BeatInfo>();
|
||||||
|
|
||||||
public BeatReactor(NamingProxy serverProxy) {
|
public BeatReactor(NamingProxy serverProxy) {
|
||||||
|
this(serverProxy, UtilAndComs.DEFAULT_CLIENT_BEAT_THREAD_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeatReactor(NamingProxy serverProxy, int threadCount) {
|
||||||
this.serverProxy = serverProxy;
|
this.serverProxy = serverProxy;
|
||||||
|
|
||||||
|
executorService = new ScheduledThreadPoolExecutor(threadCount, new ThreadFactory() {
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.setName("com.alibaba.nacos.naming.beat.sender");
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
executorService.scheduleAtFixedRate(new BeatProcessor(), 0, clientBeatInterval, TimeUnit.MILLISECONDS);
|
executorService.scheduleAtFixedRate(new BeatProcessor(), 0, clientBeatInterval, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,14 +16,12 @@
|
|||||||
package com.alibaba.nacos.client.naming.core;
|
package com.alibaba.nacos.client.naming.core;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||||
import com.alibaba.nacos.client.naming.backups.FailoverReactor;
|
import com.alibaba.nacos.client.naming.backups.FailoverReactor;
|
||||||
import com.alibaba.nacos.client.naming.cache.DiskCache;
|
import com.alibaba.nacos.client.naming.cache.DiskCache;
|
||||||
import com.alibaba.nacos.client.naming.net.NamingProxy;
|
import com.alibaba.nacos.client.naming.net.NamingProxy;
|
||||||
import com.alibaba.nacos.client.naming.utils.LogUtils;
|
import com.alibaba.nacos.client.naming.utils.LogUtils;
|
||||||
import com.alibaba.nacos.client.naming.utils.NetUtils;
|
|
||||||
import com.alibaba.nacos.client.naming.utils.StringUtils;
|
import com.alibaba.nacos.client.naming.utils.StringUtils;
|
||||||
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
@ -56,8 +54,25 @@ public class HostReactor {
|
|||||||
|
|
||||||
private String cacheDir;
|
private String cacheDir;
|
||||||
|
|
||||||
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
|
public HostReactor(EventDispatcher eventDispatcher, NamingProxy serverProxy, String cacheDir) {
|
||||||
|
this(eventDispatcher, serverProxy, cacheDir, false, UtilAndComs.DEFAULT_POLLING_THREAD_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
public HostReactor(EventDispatcher eventDispatcher, NamingProxy serverProxy, String cacheDir,
|
public HostReactor(EventDispatcher eventDispatcher, NamingProxy serverProxy, String cacheDir,
|
||||||
boolean loadCacheAtStart) {
|
boolean loadCacheAtStart, int pollingThreadCount) {
|
||||||
|
|
||||||
|
executor = new ScheduledThreadPoolExecutor(pollingThreadCount, new ThreadFactory() {
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread thread = new Thread(r);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.setName("com.alibaba.nacos.client.naming.updater");
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
this.serverProxy = serverProxy;
|
this.serverProxy = serverProxy;
|
||||||
this.cacheDir = cacheDir;
|
this.cacheDir = cacheDir;
|
||||||
@ -72,16 +87,6 @@ public class HostReactor {
|
|||||||
this.pushRecver = new PushRecver(this);
|
this.pushRecver = new PushRecver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
Thread thread = new Thread(r, "com.alibaba.nacos.client.naming.updater");
|
|
||||||
thread.setDaemon(true);
|
|
||||||
|
|
||||||
return thread;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
public Map<String, ServiceInfo> getServiceInfoMap() {
|
public Map<String, ServiceInfo> getServiceInfoMap() {
|
||||||
return serviceInfoMap;
|
return serviceInfoMap;
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,10 @@ public class UtilAndComs {
|
|||||||
public static final String NACOS_NAMING_LOG_LEVEL = "com.alibaba.nacos.naming.log.level";
|
public static final String NACOS_NAMING_LOG_LEVEL = "com.alibaba.nacos.naming.log.level";
|
||||||
|
|
||||||
public static final String SERVER_ADDR_IP_SPLITER = ":";
|
public static final String SERVER_ADDR_IP_SPLITER = ":";
|
||||||
|
|
||||||
|
public static final int DEFAULT_CLIENT_BEAT_THREAD_COUNT = Runtime.getRuntime().availableProcessors() > 1 ?
|
||||||
|
Runtime.getRuntime().availableProcessors() / 2 : 1;
|
||||||
|
|
||||||
|
public static final int DEFAULT_POLLING_THREAD_COUNT = Runtime.getRuntime().availableProcessors() > 1 ?
|
||||||
|
Runtime.getRuntime().availableProcessors() / 2 : 1;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -31,7 +31,7 @@ public class HttpMethod {
|
|||||||
|
|
||||||
public static final String PATCH = "PATCH";
|
public static final String PATCH = "PATCH";
|
||||||
|
|
||||||
public static final String DELETE = "PATCH";
|
public static final String DELETE = "DELETE";
|
||||||
|
|
||||||
public static final String OPTIONS = "PATCH";
|
public static final String OPTIONS = "PATCH";
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>nacos-console</artifactId>
|
<artifactId>nacos-console</artifactId>
|
||||||
<!--<packaging>war</packaging>-->
|
<!--<packaging>war</packaging>-->
|
||||||
@ -72,6 +72,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.1.1.RELEASE</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>com.alibaba.nacos.Nacos</mainClass>
|
<mainClass>com.alibaba.nacos.Nacos</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
|
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController("namingHealthController")
|
||||||
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_HEALTH_CONTEXT)
|
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_HEALTH_CONTEXT)
|
||||||
public class HealthController extends ApiCommands {
|
public class HealthController extends ApiCommands {
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -21,7 +21,7 @@
|
|||||||
<inceptionYear>2018</inceptionYear>
|
<inceptionYear>2018</inceptionYear>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Alibaba NACOS ${project.version}</name>
|
<name>Alibaba NACOS ${project.version}</name>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
Loading…
Reference in New Issue
Block a user