Merge pull request #376 from alibaba/feature_iplist_persist

Feature iplist persist
This commit is contained in:
JianweiWang 2018-12-02 16:39:53 +08:00 committed by GitHub
commit 0f0cbd2e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 80 additions and 75 deletions

View File

@ -21,7 +21,7 @@ import java.util.Properties;
import com.alibaba.nacos.api.exception.NacosException;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingFactory {

View File

@ -24,7 +24,7 @@ import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public interface NamingService {

View File

@ -17,7 +17,7 @@ package com.alibaba.nacos.api.naming.listener;
/**
* event interface
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public interface Event {
}

View File

@ -20,7 +20,7 @@ import java.util.List;
import com.alibaba.nacos.api.naming.pojo.Instance;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingEvent implements Event {

View File

@ -25,7 +25,7 @@ import java.util.Map;
import java.util.Objects;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public abstract class AbstractHealthChecker implements Cloneable {

View File

@ -21,7 +21,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Cluster {

View File

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Instance {

View File

@ -20,7 +20,7 @@ import com.alibaba.fastjson.JSON;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ListView<T> {

View File

@ -19,7 +19,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Service {

View File

@ -22,7 +22,7 @@ import java.util.Collection;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ServiceInfo {

View File

@ -42,7 +42,7 @@ import java.util.List;
import java.util.Properties;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
public class NacosNamingService implements NamingService {

View File

@ -33,7 +33,7 @@ import java.util.*;
import java.util.concurrent.*;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class FailoverReactor {

View File

@ -20,7 +20,7 @@ import com.alibaba.fastjson.JSON;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class BeatInfo {

View File

@ -30,7 +30,7 @@ import com.alibaba.nacos.client.logger.Logger;
import com.alibaba.nacos.client.naming.utils.LogUtils;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ConcurrentDiskUtil {

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.client.naming.core;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ProtectMode {

View File

@ -31,7 +31,7 @@ import java.util.*;
import java.util.zip.GZIPInputStream;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class HttpClient {

View File

@ -34,7 +34,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingProxy {

View File

@ -20,7 +20,7 @@ import java.util.Arrays;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Chooser<K, T> {

View File

@ -20,7 +20,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class GenericPoller<T> implements Poller<T> {

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.zip.GZIPInputStream;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class IoUtils {

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.client.naming.utils;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Pair<T> {

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.client.naming.utils;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public interface Poller<T> {
/**

View File

@ -22,7 +22,7 @@ import java.util.Collection;
import java.util.Locale;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class StringUtils {
public static boolean isEmpty(String str) {

View File

@ -25,7 +25,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingTest {

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.common.util;
import java.util.UUID;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class UuidUtil {

View File

@ -24,7 +24,7 @@ import javax.servlet.ServletContext;
/**
* Running config
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@Component
public class RunningConfigUtils implements ApplicationListener<WebServerInitializedEvent> {

View File

@ -25,7 +25,7 @@ import com.alibaba.nacos.api.naming.listener.EventListener;
import com.alibaba.nacos.api.naming.listener.NamingEvent;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingExample {

View File

@ -30,7 +30,7 @@ import java.security.AccessControlException;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@Component
public class AuthChecker {

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.acl;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class AuthInfo {
private String operator;

View File

@ -26,9 +26,8 @@ import org.springframework.stereotype.Component;
import javax.servlet.ServletContext;
/**
* @author dungu.zpf
* @author nkorange
*/
@Component
public class RunningConfig implements ApplicationListener<WebServerInitializedEvent> {

View File

@ -48,7 +48,7 @@ import java.util.List;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RestController

View File

@ -36,7 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/cluster")

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.controllers;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class CmdbController {
}

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.controllers;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class HealthController {
}

View File

@ -37,7 +37,7 @@ import java.util.List;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT)

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.controllers;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class OperatorController {
}

View File

@ -36,7 +36,7 @@ import java.util.List;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/service")

View File

@ -30,7 +30,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implements Cloneable {

View File

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class DistroMapper {

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.naming.core;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public interface Domain {
/**

View File

@ -39,7 +39,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@Component
public class DomainsManager {

View File

@ -30,7 +30,7 @@ import java.util.regex.Pattern;
/**
* IP under domain
*
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class IpAddress extends Instance implements Comparable {

View File

@ -40,7 +40,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class VirtualClusterDomain implements Domain, RaftListener {

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.exception;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NacosException extends Exception {

View File

@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@ControllerAdvice
public class ResponseExceptionHandler {

View File

@ -29,7 +29,7 @@ import java.net.HttpURLConnection;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ClientBeatCheckTask implements Runnable {
private VirtualClusterDomain domain;

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ClientBeatProcessor implements Runnable {
public static final long CLIENT_BEAT_TIMEOUT = TimeUnit.SECONDS.toMillis(15);

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.naming.healthcheck;
/**
* Health check mode
*
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public enum HealthCheckMode {
/**

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.healthcheck;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public enum HealthCheckType {
/**

View File

@ -29,7 +29,7 @@ import java.io.IOException;
import java.lang.reflect.Type;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class JsonAdapter implements ObjectDeserializer, ObjectSerializer {

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.naming.misc;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class SwitchEntry {

View File

@ -102,6 +102,10 @@ public class UtilsAndCommons {
public static final String API_DOM = "/api/dom";
public static final String INSTANCE_LIST_PERSISTED_PROPERTY_KEY = "nacos.instanceListPersisted";
public static final boolean INSTANCE_LIST_PERSISTED = Boolean.getBoolean(INSTANCE_LIST_PERSISTED_PROPERTY_KEY);
public static final ScheduledExecutorService SERVER_STATUS_EXECUTOR;
public static final ScheduledExecutorService DOMAIN_SYNCHRONIZATION_EXECUTOR;

View File

@ -396,9 +396,10 @@ public class RaftCore {
}
// do apply
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID) || UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
RaftStore.write(datum);
}
RaftCore.datums.put(datum.key, datum);
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
@ -797,7 +798,8 @@ public class RaftCore {
continue;
}
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID) ||
UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
RaftStore.write(datum);
}

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ServiceDetailView {

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.naming.view;
import com.alibaba.fastjson.JSON;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ServiceView {

View File

@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class AuthFilter implements Filter {

View File

@ -24,7 +24,7 @@ import java.security.Principal;
import java.util.*;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class MockHttpRequest implements HttpServletRequest {

View File

@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@Configuration

View File

@ -26,7 +26,7 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class BaseTest {

View File

@ -46,7 +46,7 @@ import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MockServletContext.class)

View File

@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class ClusterTest {

View File

@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class DomainTest {

View File

@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MockServletContext.class)

View File

@ -25,7 +25,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class IpAddressTest {

View File

@ -20,7 +20,7 @@ import org.junit.Before;
import org.junit.Test;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class SwitchTest {

View File

@ -19,7 +19,7 @@ import org.junit.Assert;
import org.junit.Test;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class RaftStoreTest {

View File

@ -25,7 +25,7 @@ import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.Service;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class NamingBase {

View File

@ -19,7 +19,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Params {

View File

@ -41,7 +41,7 @@ import java.net.URL;
import static org.junit.Assert.assertTrue;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = NamingApp.class, properties = {"server.servlet.context-path=/nacos",

View File

@ -32,7 +32,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = NamingApp.class, properties = {"server.servlet.context-path=/nacos"},

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.test.naming;
/**
* @author dungu.zpf
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
*/
public class Starter_ITCase {
}