For new codeStyle in nacos-api module (#3190)
This commit is contained in:
parent
51c0eb25ad
commit
c9bf5f2f70
12
api/pom.xml
12
api/pom.xml
@ -15,18 +15,18 @@
|
|||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
<artifactId>nacos-all</artifactId>
|
<artifactId>nacos-all</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>nacos-api</artifactId>
|
<artifactId>nacos-api</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>nacos-api ${project.version}</name>
|
<name>nacos-api ${project.version}</name>
|
||||||
<url>http://nacos.io</url>
|
<url>http://nacos.io</url>
|
||||||
<build>
|
<build>
|
||||||
@ -41,11 +41,11 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
@ -13,27 +13,28 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
package com.alibaba.nacos.api;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.config.ConfigFactory;
|
import com.alibaba.nacos.api.config.ConfigFactory;
|
||||||
import com.alibaba.nacos.api.config.ConfigService;
|
import com.alibaba.nacos.api.config.ConfigService;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||||
import com.alibaba.nacos.api.naming.NamingMaintainFactory;
|
import com.alibaba.nacos.api.naming.NamingMaintainFactory;
|
||||||
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
||||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Factory
|
* Nacos Factory.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public class NacosFactory {
|
public class NacosFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create config service
|
* Create config service.
|
||||||
*
|
*
|
||||||
* @param properties init param
|
* @param properties init param
|
||||||
* @return config
|
* @return config
|
||||||
@ -42,9 +43,9 @@ public class NacosFactory {
|
|||||||
public static ConfigService createConfigService(Properties properties) throws NacosException {
|
public static ConfigService createConfigService(Properties properties) throws NacosException {
|
||||||
return ConfigFactory.createConfigService(properties);
|
return ConfigFactory.createConfigService(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create config service
|
* Create config service.
|
||||||
*
|
*
|
||||||
* @param serverAddr server list
|
* @param serverAddr server list
|
||||||
* @return config
|
* @return config
|
||||||
@ -53,9 +54,9 @@ public class NacosFactory {
|
|||||||
public static ConfigService createConfigService(String serverAddr) throws NacosException {
|
public static ConfigService createConfigService(String serverAddr) throws NacosException {
|
||||||
return ConfigFactory.createConfigService(serverAddr);
|
return ConfigFactory.createConfigService(serverAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create naming service
|
* Create naming service.
|
||||||
*
|
*
|
||||||
* @param serverAddr server list
|
* @param serverAddr server list
|
||||||
* @return Naming
|
* @return Naming
|
||||||
@ -64,9 +65,9 @@ public class NacosFactory {
|
|||||||
public static NamingService createNamingService(String serverAddr) throws NacosException {
|
public static NamingService createNamingService(String serverAddr) throws NacosException {
|
||||||
return NamingFactory.createNamingService(serverAddr);
|
return NamingFactory.createNamingService(serverAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create naming service
|
* Create naming service.
|
||||||
*
|
*
|
||||||
* @param properties init param
|
* @param properties init param
|
||||||
* @return Naming
|
* @return Naming
|
||||||
@ -75,22 +76,22 @@ public class NacosFactory {
|
|||||||
public static NamingService createNamingService(Properties properties) throws NacosException {
|
public static NamingService createNamingService(Properties properties) throws NacosException {
|
||||||
return NamingFactory.createNamingService(properties);
|
return NamingFactory.createNamingService(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create maintain service
|
* Create maintain service.
|
||||||
*
|
*
|
||||||
* @param serverAddr
|
* @param serverAddr server address
|
||||||
* @return NamingMaintainService
|
* @return NamingMaintainService
|
||||||
* @throws NacosException Exception
|
* @throws NacosException Exception
|
||||||
*/
|
*/
|
||||||
public static NamingMaintainService createMaintainService(String serverAddr) throws NacosException {
|
public static NamingMaintainService createMaintainService(String serverAddr) throws NacosException {
|
||||||
return NamingMaintainFactory.createMaintainService(serverAddr);
|
return NamingMaintainFactory.createMaintainService(serverAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create maintain service
|
* Create maintain service.
|
||||||
*
|
*
|
||||||
* @param properties
|
* @param properties server address
|
||||||
* @return NamingMaintainService
|
* @return NamingMaintainService
|
||||||
* @throws NacosException Exception
|
* @throws NacosException Exception
|
||||||
*/
|
*/
|
||||||
|
@ -13,67 +13,68 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api;
|
package com.alibaba.nacos.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property Key Const
|
* Property Key Const.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public class PropertyKeyConst {
|
public class PropertyKeyConst {
|
||||||
|
|
||||||
public final static String IS_USE_CLOUD_NAMESPACE_PARSING = "isUseCloudNamespaceParsing";
|
public static final String IS_USE_CLOUD_NAMESPACE_PARSING = "isUseCloudNamespaceParsing";
|
||||||
|
|
||||||
public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";
|
public static final String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";
|
||||||
|
|
||||||
public final static String ENDPOINT = "endpoint";
|
public static final String ENDPOINT = "endpoint";
|
||||||
|
|
||||||
public final static String ENDPOINT_PORT = "endpointPort";
|
public static final String ENDPOINT_PORT = "endpointPort";
|
||||||
|
|
||||||
public final static String NAMESPACE = "namespace";
|
public static final String NAMESPACE = "namespace";
|
||||||
|
|
||||||
public final static String USERNAME = "username";
|
public static final String USERNAME = "username";
|
||||||
|
|
||||||
public final static String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
|
|
||||||
public final static String ACCESS_KEY = "accessKey";
|
public static final String ACCESS_KEY = "accessKey";
|
||||||
|
|
||||||
public final static String SECRET_KEY = "secretKey";
|
public static final String SECRET_KEY = "secretKey";
|
||||||
|
|
||||||
public final static String RAM_ROLE_NAME = "ramRoleName";
|
public static final String RAM_ROLE_NAME = "ramRoleName";
|
||||||
|
|
||||||
public final static String SERVER_ADDR = "serverAddr";
|
public static final String SERVER_ADDR = "serverAddr";
|
||||||
|
|
||||||
public final static String CONTEXT_PATH = "contextPath";
|
public static final String CONTEXT_PATH = "contextPath";
|
||||||
|
|
||||||
public final static String CLUSTER_NAME = "clusterName";
|
public static final String CLUSTER_NAME = "clusterName";
|
||||||
|
|
||||||
public final static String ENCODE = "encode";
|
public static final String ENCODE = "encode";
|
||||||
|
|
||||||
public final static String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";
|
public static final String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";
|
||||||
|
|
||||||
public final static String CONFIG_RETRY_TIME = "configRetryTime";
|
public static final String CONFIG_RETRY_TIME = "configRetryTime";
|
||||||
|
|
||||||
public final static String MAX_RETRY = "maxRetry";
|
public static final String MAX_RETRY = "maxRetry";
|
||||||
|
|
||||||
public final static String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
public static final String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
||||||
|
|
||||||
public final static String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";
|
public static final String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";
|
||||||
|
|
||||||
public final static String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";
|
public static final String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";
|
||||||
|
|
||||||
public final static String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
|
public static final String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the key value of some variable value from the system property
|
* Get the key value of some variable value from the system property.
|
||||||
*/
|
*/
|
||||||
public static class SystemEnv {
|
public static class SystemEnv {
|
||||||
|
|
||||||
public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
|
public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
|
||||||
|
|
||||||
public static final String ALIBABA_ALIWARE_NAMESPACE = "ALIBABA_ALIWARE_NAMESPACE";
|
public static final String ALIBABA_ALIWARE_NAMESPACE = "ALIBABA_ALIWARE_NAMESPACE";
|
||||||
|
|
||||||
public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
|
public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,38 +13,37 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api;
|
package com.alibaba.nacos.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* Support for reading the value of the specified variable from the -D parameter.
|
||||||
* Support for reading the value of the specified variable from the -D parameter
|
*
|
||||||
* </P>
|
* <p>Properties that are preferred to which in {@link PropertyKeyConst}
|
||||||
* Properties that are preferred to which in {@link PropertyKeyConst}
|
|
||||||
*
|
*
|
||||||
* @author pbting
|
* @author pbting
|
||||||
* @date 2019-02-22 3:38 PM
|
|
||||||
*/
|
*/
|
||||||
public interface SystemPropertyKeyConst {
|
public interface SystemPropertyKeyConst {
|
||||||
|
|
||||||
String NAMING_SERVER_PORT = "nacos.naming.exposed.port";
|
String NAMING_SERVER_PORT = "nacos.naming.exposed.port";
|
||||||
|
|
||||||
String NAMING_WEB_CONTEXT = "nacos.naming.web.context";
|
String NAMING_WEB_CONTEXT = "nacos.naming.web.context";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the cloud (Alibaba Cloud or other cloud vendors) environment,
|
* In the cloud (Alibaba Cloud or other cloud vendors) environment, whether to enable namespace resolution in the
|
||||||
* whether to enable namespace resolution in the cloud environment.
|
* cloud environment.
|
||||||
* <p>
|
* <p>
|
||||||
* The default is on.
|
* The default is on.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
String IS_USE_CLOUD_NAMESPACE_PARSING = "nacos.use.cloud.namespace.parsing";
|
String IS_USE_CLOUD_NAMESPACE_PARSING = "nacos.use.cloud.namespace.parsing";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the cloud environment, if the process level requires a globally uniform namespace,
|
* In the cloud environment, if the process level requires a globally uniform namespace, it can be specified with
|
||||||
* it can be specified with the -D parameter.
|
* the -D parameter.
|
||||||
*/
|
*/
|
||||||
String ANS_NAMESPACE = "ans.namespace";
|
String ANS_NAMESPACE = "ans.namespace";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It is also supported by the -D parameter.
|
* It is also supported by the -D parameter.
|
||||||
*/
|
*/
|
||||||
|
@ -13,12 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.annotation;
|
package com.alibaba.nacos.api.annotation;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.config.ConfigService;
|
import com.alibaba.nacos.api.config.ConfigService;
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation to inject {@link ConfigService} or {@link NamingService} instance into the target Bean.
|
* An annotation to inject {@link ConfigService} or {@link NamingService} instance into the target Bean.
|
||||||
@ -33,12 +38,12 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosInjected {
|
public @interface NacosInjected {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
||||||
*
|
*
|
||||||
* @return the default value is {@link NacosProperties}
|
* @return the default value is {@link NacosProperties}
|
||||||
*/
|
*/
|
||||||
NacosProperties properties() default @NacosProperties;
|
NacosProperties properties() default @NacosProperties;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,19 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.annotation;
|
package com.alibaba.nacos.api.annotation;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation for Nacos Properties
|
* An annotation for Nacos Properties.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||||
* @see PropertyKeyConst
|
* @see PropertyKeyConst
|
||||||
@ -30,263 +35,266 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosProperties {
|
public @interface NacosProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix of property name of Nacos
|
* The prefix of property name of Nacos.
|
||||||
*/
|
*/
|
||||||
String PREFIX = "nacos.";
|
String PREFIX = "nacos.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "endpoint"
|
* The property name of "endpoint".
|
||||||
*/
|
*/
|
||||||
String ENDPOINT = "endpoint";
|
String ENDPOINT = "endpoint";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "namespace"
|
* The property name of "namespace".
|
||||||
*/
|
*/
|
||||||
String NAMESPACE = "namespace";
|
String NAMESPACE = "namespace";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "access-key"
|
* The property name of "access-key".
|
||||||
*/
|
*/
|
||||||
String ACCESS_KEY = "access-key";
|
String ACCESS_KEY = "access-key";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "secret-key"
|
* The property name of "secret-key".
|
||||||
*/
|
*/
|
||||||
String SECRET_KEY = "secret-key";
|
String SECRET_KEY = "secret-key";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "server-addr"
|
* The property name of "server-addr".
|
||||||
*/
|
*/
|
||||||
String SERVER_ADDR = "server-addr";
|
String SERVER_ADDR = "server-addr";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "context-path"
|
* The property name of "context-path".
|
||||||
*/
|
*/
|
||||||
String CONTEXT_PATH = "context-path";
|
String CONTEXT_PATH = "context-path";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "cluster-name"
|
* The property name of "cluster-name".
|
||||||
*/
|
*/
|
||||||
String CLUSTER_NAME = "cluster-name";
|
String CLUSTER_NAME = "cluster-name";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "encode"
|
* The property name of "encode".
|
||||||
*/
|
*/
|
||||||
String ENCODE = "encode";
|
String ENCODE = "encode";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "long-poll.timeout"
|
* The property name of "long-poll.timeout".
|
||||||
*/
|
*/
|
||||||
String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";
|
String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "config.retry.time"
|
* The property name of "config.retry.time".
|
||||||
*/
|
*/
|
||||||
String CONFIG_RETRY_TIME = "configRetryTime";
|
String CONFIG_RETRY_TIME = "configRetryTime";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "maxRetry"
|
* The property name of "maxRetry".
|
||||||
*/
|
*/
|
||||||
String MAX_RETRY = "maxRetry";
|
String MAX_RETRY = "maxRetry";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "enableRemoteSyncConfig"
|
* The property name of "enableRemoteSyncConfig".
|
||||||
*/
|
*/
|
||||||
String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "username"
|
* The property name of "username".
|
||||||
*/
|
*/
|
||||||
String USERNAME = "username";
|
String USERNAME = "username";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of "password"
|
* The property name of "password".
|
||||||
*/
|
*/
|
||||||
String PASSWORD = "password";
|
String PASSWORD = "password";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>.
|
||||||
*/
|
*/
|
||||||
String ENDPOINT_PLACEHOLDER = "${" + PREFIX + ENDPOINT + ":}";
|
String ENDPOINT_PLACEHOLDER = "${" + PREFIX + ENDPOINT + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.namespace:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.namespace:}"</code>.
|
||||||
*/
|
*/
|
||||||
String NAMESPACE_PLACEHOLDER = "${" + PREFIX + NAMESPACE + ":}";
|
String NAMESPACE_PLACEHOLDER = "${" + PREFIX + NAMESPACE + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.access-key:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.access-key:}"</code>.
|
||||||
*/
|
*/
|
||||||
String ACCESS_KEY_PLACEHOLDER = "${" + PREFIX + ACCESS_KEY + ":}";
|
String ACCESS_KEY_PLACEHOLDER = "${" + PREFIX + ACCESS_KEY + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.secret-key:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.secret-key:}"</code>.
|
||||||
*/
|
*/
|
||||||
String SECRET_KEY_PLACEHOLDER = "${" + PREFIX + SECRET_KEY + ":}";
|
String SECRET_KEY_PLACEHOLDER = "${" + PREFIX + SECRET_KEY + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>${nacos.server-addr:}"</code>
|
* The placeholder of endpoint, the value is <code>${nacos.server-addr:}"</code>.
|
||||||
*/
|
*/
|
||||||
String SERVER_ADDR_PLACEHOLDER = "${" + PREFIX + SERVER_ADDR + ":}";
|
String SERVER_ADDR_PLACEHOLDER = "${" + PREFIX + SERVER_ADDR + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is ${nacos.context-path:}"
|
* The placeholder of endpoint, the value is ${nacos.context-path:}".
|
||||||
*/
|
*/
|
||||||
String CONTEXT_PATH_PLACEHOLDER = "${" + PREFIX + CONTEXT_PATH + ":}";
|
String CONTEXT_PATH_PLACEHOLDER = "${" + PREFIX + CONTEXT_PATH + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.cluster-name:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.cluster-name:}"</code>.
|
||||||
*/
|
*/
|
||||||
String CLUSTER_NAME_PLACEHOLDER = "${" + PREFIX + CLUSTER_NAME + ":}";
|
String CLUSTER_NAME_PLACEHOLDER = "${" + PREFIX + CLUSTER_NAME + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of {@link NacosProperties#ENCODE encode}, the value is <code>"${nacos.encode:UTF-8}"</code>
|
* The placeholder of {@link NacosProperties#ENCODE encode}, the value is <code>"${nacos.encode:UTF-8}"</code>.
|
||||||
*/
|
*/
|
||||||
String ENCODE_PLACEHOLDER = "${" + PREFIX + ENCODE + ":UTF-8}";
|
String ENCODE_PLACEHOLDER = "${" + PREFIX + ENCODE + ":UTF-8}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of {@link NacosProperties#CONFIG_LONG_POLL_TIMEOUT configLongPollTimeout}, the value is <code>"${nacos.configLongPollTimeout:}"</code>
|
* The placeholder of {@link NacosProperties#CONFIG_LONG_POLL_TIMEOUT configLongPollTimeout}, the value is
|
||||||
|
* <code>"${nacos.configLongPollTimeout:}"</code>.
|
||||||
*/
|
*/
|
||||||
String CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER = "${" + PREFIX + CONFIG_LONG_POLL_TIMEOUT + ":}";
|
String CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER = "${" + PREFIX + CONFIG_LONG_POLL_TIMEOUT + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of {@link NacosProperties#CONFIG_RETRY_TIME configRetryTime}, the value is <code>"${nacos.configRetryTime:}"</code>
|
* The placeholder of {@link NacosProperties#CONFIG_RETRY_TIME configRetryTime}, the value is
|
||||||
|
* <code>"${nacos.configRetryTime:}"</code>.
|
||||||
*/
|
*/
|
||||||
String CONFIG_RETRY_TIME_PLACEHOLDER = "${" + PREFIX + CONFIG_RETRY_TIME + ":}";
|
String CONFIG_RETRY_TIME_PLACEHOLDER = "${" + PREFIX + CONFIG_RETRY_TIME + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of {@link NacosProperties#MAX_RETRY maxRetry}, the value is <code>"${nacos.maxRetry:}"</code>
|
* The placeholder of {@link NacosProperties#MAX_RETRY maxRetry}, the value is <code>"${nacos.maxRetry:}"</code>.
|
||||||
*/
|
*/
|
||||||
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":}";
|
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of {@link NacosProperties#ENABLE_REMOTE_SYNC_CONFIG enableRemoteSyncConfig}, the value is <code>"${nacos.enableRemoteSyncConfig:}"</code>
|
* The placeholder of {@link NacosProperties#ENABLE_REMOTE_SYNC_CONFIG enableRemoteSyncConfig}, the value is
|
||||||
|
* <code>"${nacos.enableRemoteSyncConfig:}"</code>.
|
||||||
*/
|
*/
|
||||||
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + ":}";
|
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.username:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.username:}"</code>.
|
||||||
*/
|
*/
|
||||||
String USERNAME_PLACEHOLDER = "${" + PREFIX + USERNAME + ":}";
|
String USERNAME_PLACEHOLDER = "${" + PREFIX + USERNAME + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder of endpoint, the value is <code>"${nacos.password:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.password:}"</code>.
|
||||||
*/
|
*/
|
||||||
String PASSWORD_PLACEHOLDER = "${" + PREFIX + PASSWORD + ":}";
|
String PASSWORD_PLACEHOLDER = "${" + PREFIX + PASSWORD + ":}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "endpoint"
|
* The property of "endpoint".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #ENDPOINT_PLACEHOLDER
|
* @see #ENDPOINT_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String endpoint() default ENDPOINT_PLACEHOLDER;
|
String endpoint() default ENDPOINT_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "namespace"
|
* The property of "namespace".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #NAMESPACE_PLACEHOLDER
|
* @see #NAMESPACE_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String namespace() default NAMESPACE_PLACEHOLDER;
|
String namespace() default NAMESPACE_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "access-key"
|
* The property of "access-key".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #ACCESS_KEY_PLACEHOLDER
|
* @see #ACCESS_KEY_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String accessKey() default ACCESS_KEY_PLACEHOLDER;
|
String accessKey() default ACCESS_KEY_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "secret-key"
|
* The property of "secret-key".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #SECRET_KEY_PLACEHOLDER
|
* @see #SECRET_KEY_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String secretKey() default SECRET_KEY_PLACEHOLDER;
|
String secretKey() default SECRET_KEY_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "server-addr"
|
* The property of "server-addr".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #SERVER_ADDR_PLACEHOLDER
|
* @see #SERVER_ADDR_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String serverAddr() default SERVER_ADDR_PLACEHOLDER;
|
String serverAddr() default SERVER_ADDR_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "context-path"
|
* The property of "context-path".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #CONTEXT_PATH_PLACEHOLDER
|
* @see #CONTEXT_PATH_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String contextPath() default CONTEXT_PATH_PLACEHOLDER;
|
String contextPath() default CONTEXT_PATH_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "cluster-name"
|
* The property of "cluster-name".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #CLUSTER_NAME_PLACEHOLDER
|
* @see #CLUSTER_NAME_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String clusterName() default CLUSTER_NAME_PLACEHOLDER;
|
String clusterName() default CLUSTER_NAME_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "encode"
|
* The property of "encode".
|
||||||
*
|
*
|
||||||
* @return "UTF-8" as default value
|
* @return "UTF-8" as default value
|
||||||
* @see #ENCODE_PLACEHOLDER
|
* @see #ENCODE_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String encode() default ENCODE_PLACEHOLDER;
|
String encode() default ENCODE_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "configLongPollTimeout"
|
* The property of "configLongPollTimeout".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER
|
* @see #CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String configLongPollTimeout() default CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER;
|
String configLongPollTimeout() default CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "configRetryTime"
|
* The property of "configRetryTime".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #CONFIG_RETRY_TIME_PLACEHOLDER
|
* @see #CONFIG_RETRY_TIME_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String configRetryTime() default CONFIG_RETRY_TIME_PLACEHOLDER;
|
String configRetryTime() default CONFIG_RETRY_TIME_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "maxRetry"
|
* The property of "maxRetry".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #MAX_RETRY
|
* @see #MAX_RETRY
|
||||||
*/
|
*/
|
||||||
String maxRetry() default MAX_RETRY_PLACEHOLDER;
|
String maxRetry() default MAX_RETRY_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "enableRemoteSyncConfig"
|
* The property of "enableRemoteSyncConfig".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #ENABLE_REMOTE_SYNC_CONFIG
|
* @see #ENABLE_REMOTE_SYNC_CONFIG
|
||||||
*/
|
*/
|
||||||
String enableRemoteSyncConfig() default ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER;
|
String enableRemoteSyncConfig() default ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "username"
|
* The property of "username".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #USERNAME_PLACEHOLDER
|
* @see #USERNAME_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String username() default USERNAME_PLACEHOLDER;
|
String username() default USERNAME_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property of "password"
|
* The property of "password".
|
||||||
*
|
*
|
||||||
* @return empty as default value
|
* @return empty as default value
|
||||||
* @see #PASSWORD_PLACEHOLDER
|
* @see #PASSWORD_PLACEHOLDER
|
||||||
*/
|
*/
|
||||||
String password() default PASSWORD_PLACEHOLDER;
|
String password() default PASSWORD_PLACEHOLDER;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,40 +13,45 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.pojo;
|
package com.alibaba.nacos.api.cmdb.pojo;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* CMDB entity.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class Entity {
|
public class Entity {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Map<String, String> labels;
|
private Map<String, String> labels;
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getLabels() {
|
public Map<String, String> getLabels() {
|
||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabels(Map<String, String> labels) {
|
public void setLabels(Map<String, String> labels) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
}
|
}
|
||||||
|
@ -13,38 +13,43 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.pojo;
|
package com.alibaba.nacos.api.cmdb.pojo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* CMDB entity event.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class EntityEvent {
|
public class EntityEvent {
|
||||||
|
|
||||||
private EntityEventType type;
|
private EntityEventType type;
|
||||||
|
|
||||||
private String entityName;
|
private String entityName;
|
||||||
|
|
||||||
private String entityType;
|
private String entityType;
|
||||||
|
|
||||||
public EntityEventType getType() {
|
public EntityEventType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(EntityEventType type) {
|
public void setType(EntityEventType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityName() {
|
public String getEntityName() {
|
||||||
return entityName;
|
return entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntityName(String entityName) {
|
public void setEntityName(String entityName) {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityType() {
|
public String getEntityType() {
|
||||||
return entityType;
|
return entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntityType(String entityType) {
|
public void setEntityType(String entityType) {
|
||||||
this.entityType = entityType;
|
this.entityType = entityType;
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.pojo;
|
package com.alibaba.nacos.api.cmdb.pojo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* CMDB entity event type.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public enum EntityEventType {
|
public enum EntityEventType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Add or update entity.
|
||||||
*/
|
*/
|
||||||
ENTITY_ADD_OR_UPDATE,
|
ENTITY_ADD_OR_UPDATE,
|
||||||
/**
|
/**
|
||||||
*
|
* Remove entity.
|
||||||
*/
|
*/
|
||||||
ENTITY_REMOVE
|
ENTITY_REMOVE
|
||||||
}
|
}
|
||||||
|
@ -13,40 +13,45 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.pojo;
|
package com.alibaba.nacos.api.cmdb.pojo;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* CMDB lable.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class Label {
|
public class Label {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Set<String> values;
|
private Set<String> values;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getValues() {
|
public Set<String> getValues() {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValues(Set<String> values) {
|
public void setValues(Set<String> values) {
|
||||||
this.values = values;
|
this.values = values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,22 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.pojo;
|
package com.alibaba.nacos.api.cmdb.pojo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* CMDB preserverd entity type.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public enum PreservedEntityTypes {
|
public enum PreservedEntityTypes {
|
||||||
/**
|
/**
|
||||||
* Ip
|
* Ip.
|
||||||
*/
|
*/
|
||||||
ip,
|
ip,
|
||||||
/**
|
/**
|
||||||
* Service
|
* Service.
|
||||||
*/
|
*/
|
||||||
service
|
service
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.cmdb.spi;
|
package com.alibaba.nacos.api.cmdb.spi;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.cmdb.pojo.Entity;
|
import com.alibaba.nacos.api.cmdb.pojo.Entity;
|
||||||
@ -24,71 +25,71 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to visit CMDB store
|
* Service to visit CMDB store.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public interface CmdbService {
|
public interface CmdbService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all label names stored in CMDB
|
* Get all label names stored in CMDB.
|
||||||
*
|
*
|
||||||
* @return label name set
|
* @return label name set
|
||||||
*/
|
*/
|
||||||
Set<String> getLabelNames();
|
Set<String> getLabelNames();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all possible entity types in CMDB
|
* Get all possible entity types in CMDB.
|
||||||
*
|
*
|
||||||
* @return all entity types
|
* @return all entity types
|
||||||
*/
|
*/
|
||||||
Set<String> getEntityTypes();
|
Set<String> getEntityTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get label info
|
* Get label info.
|
||||||
*
|
*
|
||||||
* @param labelName label name
|
* @param labelName label name
|
||||||
* @return label info
|
* @return label info
|
||||||
*/
|
*/
|
||||||
Label getLabel(String labelName);
|
Label getLabel(String labelName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get label value of label name of ip
|
* Get label value of label name of ip.
|
||||||
*
|
*
|
||||||
* @param entityName entity name
|
* @param entityName entity name
|
||||||
* @param entityType entity type
|
* @param entityType entity type
|
||||||
* @param labelName target label name
|
* @param labelName target label name
|
||||||
* @return label value
|
* @return label value
|
||||||
*/
|
*/
|
||||||
String getLabelValue(String entityName, String entityType, String labelName);
|
String getLabelValue(String entityName, String entityType, String labelName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all label value of ip
|
* Get all label value of ip.
|
||||||
*
|
*
|
||||||
* @param entityName entity name
|
* @param entityName entity name
|
||||||
* @param entityType entity type
|
* @param entityType entity type
|
||||||
* @return all label values
|
* @return all label values
|
||||||
*/
|
*/
|
||||||
Map<String, String> getLabelValues(String entityName, String entityType);
|
Map<String, String> getLabelValues(String entityName, String entityType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump all entities in CMDB
|
* Dump all entities in CMDB.
|
||||||
*
|
*
|
||||||
* @return all entities
|
* @return all entities
|
||||||
*/
|
*/
|
||||||
Map<String, Map<String, Entity>> getAllEntities();
|
Map<String, Map<String, Entity>> getAllEntities();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get label change events
|
* get label change events.
|
||||||
*
|
*
|
||||||
* @param timestamp start time of generated events
|
* @param timestamp start time of generated events
|
||||||
* @return label events
|
* @return label events
|
||||||
*/
|
*/
|
||||||
List<EntityEvent> getEntityEvents(long timestamp);
|
List<EntityEvent> getEntityEvents(long timestamp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get single entity
|
* Get single entity.
|
||||||
*
|
*
|
||||||
* @param entityName name of entity
|
* @param entityName name of entity
|
||||||
* @param entityType type of entity
|
* @param entityType type of entity
|
||||||
|
@ -13,174 +13,179 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.common;
|
package com.alibaba.nacos.api.common;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant
|
* Constants.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final String CLIENT_VERSION = "3.0.0";
|
public static final String CLIENT_VERSION = "3.0.0";
|
||||||
|
|
||||||
public static int DATA_IN_BODY_VERSION = 204;
|
public static final int DATA_IN_BODY_VERSION = 204;
|
||||||
|
|
||||||
public static final String DEFAULT_GROUP = "DEFAULT_GROUP";
|
public static final String DEFAULT_GROUP = "DEFAULT_GROUP";
|
||||||
|
|
||||||
public static final String APPNAME = "AppName";
|
public static final String APPNAME = "AppName";
|
||||||
|
|
||||||
public static final String UNKNOWN_APP = "UnknownApp";
|
public static final String UNKNOWN_APP = "UnknownApp";
|
||||||
|
|
||||||
public static final String DEFAULT_DOMAINNAME = "commonconfig.config-host.taobao.com";
|
public static final String DEFAULT_DOMAINNAME = "commonconfig.config-host.taobao.com";
|
||||||
|
|
||||||
public static final String DAILY_DOMAINNAME = "commonconfig.taobao.net";
|
public static final String DAILY_DOMAINNAME = "commonconfig.taobao.net";
|
||||||
|
|
||||||
public static final String NULL = "";
|
public static final String NULL = "";
|
||||||
|
|
||||||
public static final String DATAID = "dataId";
|
public static final String DATAID = "dataId";
|
||||||
|
|
||||||
public static final String GROUP = "group";
|
public static final String GROUP = "group";
|
||||||
|
|
||||||
public static final String LAST_MODIFIED = "Last-Modified";
|
public static final String LAST_MODIFIED = "Last-Modified";
|
||||||
|
|
||||||
public static final String ACCEPT_ENCODING = "Accept-Encoding";
|
public static final String ACCEPT_ENCODING = "Accept-Encoding";
|
||||||
|
|
||||||
public static final String CONTENT_ENCODING = "Content-Encoding";
|
public static final String CONTENT_ENCODING = "Content-Encoding";
|
||||||
|
|
||||||
public static final String PROBE_MODIFY_REQUEST = "Listening-Configs";
|
public static final String PROBE_MODIFY_REQUEST = "Listening-Configs";
|
||||||
|
|
||||||
public static final String PROBE_MODIFY_RESPONSE = "Probe-Modify-Response";
|
public static final String PROBE_MODIFY_RESPONSE = "Probe-Modify-Response";
|
||||||
|
|
||||||
public static final String PROBE_MODIFY_RESPONSE_NEW = "Probe-Modify-Response-New";
|
public static final String PROBE_MODIFY_RESPONSE_NEW = "Probe-Modify-Response-New";
|
||||||
|
|
||||||
public static final String USE_ZIP = "true";
|
public static final String USE_ZIP = "true";
|
||||||
|
|
||||||
public static final String CONTENT_MD5 = "Content-MD5";
|
public static final String CONTENT_MD5 = "Content-MD5";
|
||||||
|
|
||||||
public static final String CONFIG_VERSION = "Config-Version";
|
public static final String CONFIG_VERSION = "Config-Version";
|
||||||
|
|
||||||
public static final String CONFIG_TYPE = "Config-Type";
|
public static final String CONFIG_TYPE = "Config-Type";
|
||||||
|
|
||||||
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
||||||
|
|
||||||
public static final String SPACING_INTERVAL = "client-spacing-interval";
|
public static final String SPACING_INTERVAL = "client-spacing-interval";
|
||||||
|
|
||||||
public static final String BASE_PATH = "/v1/cs";
|
public static final String BASE_PATH = "/v1/cs";
|
||||||
|
|
||||||
public static final String CONFIG_CONTROLLER_PATH = BASE_PATH + "/configs";
|
public static final String CONFIG_CONTROLLER_PATH = BASE_PATH + "/configs";
|
||||||
|
|
||||||
public static final String TOKEN = "token";
|
public static final String TOKEN = "token";
|
||||||
|
|
||||||
public static final String ACCESS_TOKEN = "accessToken";
|
public static final String ACCESS_TOKEN = "accessToken";
|
||||||
|
|
||||||
public static final String TOKEN_TTL = "tokenTtl";
|
public static final String TOKEN_TTL = "tokenTtl";
|
||||||
|
|
||||||
public static final String GLOBAL_ADMIN = "globalAdmin";
|
public static final String GLOBAL_ADMIN = "globalAdmin";
|
||||||
|
|
||||||
public static final String TOKEN_REFRESH_WINDOW = "tokenRefreshWindow";
|
public static final String TOKEN_REFRESH_WINDOW = "tokenRefreshWindow";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* second
|
* second.
|
||||||
*/
|
*/
|
||||||
public static final int ASYNC_UPDATE_ADDRESS_INTERVAL = 300;
|
public static final int ASYNC_UPDATE_ADDRESS_INTERVAL = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* second
|
* second.
|
||||||
*/
|
*/
|
||||||
public static final int POLLING_INTERVAL_TIME = 15;
|
public static final int POLLING_INTERVAL_TIME = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int ONCE_TIMEOUT = 2000;
|
public static final int ONCE_TIMEOUT = 2000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int SO_TIMEOUT = 60000;
|
public static final int SO_TIMEOUT = 60000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int CONFIG_LONG_POLL_TIMEOUT = 30000;
|
public static final int CONFIG_LONG_POLL_TIMEOUT = 30000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int MIN_CONFIG_LONG_POLL_TIMEOUT = 10000;
|
public static final int MIN_CONFIG_LONG_POLL_TIMEOUT = 10000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int CONFIG_RETRY_TIME = 2000;
|
public static final int CONFIG_RETRY_TIME = 2000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of retries
|
* Maximum number of retries.
|
||||||
*/
|
*/
|
||||||
public static final int MAX_RETRY = 3;
|
public static final int MAX_RETRY = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* millisecond
|
* millisecond.
|
||||||
*/
|
*/
|
||||||
public static final int RECV_WAIT_TIMEOUT = ONCE_TIMEOUT * 5;
|
public static final int RECV_WAIT_TIMEOUT = ONCE_TIMEOUT * 5;
|
||||||
|
|
||||||
public static final String ENCODE = "UTF-8";
|
public static final String ENCODE = "UTF-8";
|
||||||
|
|
||||||
public static final String MAP_FILE = "map-file.js";
|
public static final String MAP_FILE = "map-file.js";
|
||||||
|
|
||||||
public static final int FLOW_CONTROL_THRESHOLD = 20;
|
public static final int FLOW_CONTROL_THRESHOLD = 20;
|
||||||
|
|
||||||
public static final int FLOW_CONTROL_SLOT = 10;
|
public static final int FLOW_CONTROL_SLOT = 10;
|
||||||
|
|
||||||
public static final int FLOW_CONTROL_INTERVAL = 1000;
|
public static final int FLOW_CONTROL_INTERVAL = 1000;
|
||||||
|
|
||||||
public static final float DEFAULT_PROTECT_THRESHOLD = 0.0F;
|
public static final float DEFAULT_PROTECT_THRESHOLD = 0.0F;
|
||||||
|
|
||||||
public static final String LINE_SEPARATOR = Character.toString((char) 1);
|
public static final String LINE_SEPARATOR = Character.toString((char) 1);
|
||||||
|
|
||||||
public static final String WORD_SEPARATOR = Character.toString((char) 2);
|
public static final String WORD_SEPARATOR = Character.toString((char) 2);
|
||||||
|
|
||||||
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";
|
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";
|
||||||
|
|
||||||
public static final String CLIENT_APPNAME_HEADER = "Client-AppName";
|
public static final String CLIENT_APPNAME_HEADER = "Client-AppName";
|
||||||
|
|
||||||
public static final String CLIENT_REQUEST_TS_HEADER = "Client-RequestTS";
|
public static final String CLIENT_REQUEST_TS_HEADER = "Client-RequestTS";
|
||||||
|
|
||||||
public static final String CLIENT_REQUEST_TOKEN_HEADER = "Client-RequestToken";
|
public static final String CLIENT_REQUEST_TOKEN_HEADER = "Client-RequestToken";
|
||||||
|
|
||||||
public static final int ATOMIC_MAX_SIZE = 1000;
|
public static final int ATOMIC_MAX_SIZE = 1000;
|
||||||
|
|
||||||
public static final String NAMING_INSTANCE_ID_SPLITTER = "#";
|
public static final String NAMING_INSTANCE_ID_SPLITTER = "#";
|
||||||
|
|
||||||
public static final int NAMING_INSTANCE_ID_SEG_COUNT = 4;
|
public static final int NAMING_INSTANCE_ID_SEG_COUNT = 4;
|
||||||
|
|
||||||
public static final String NAMING_HTTP_HEADER_SPILIER = "\\|";
|
public static final String NAMING_HTTP_HEADER_SPILIER = "\\|";
|
||||||
|
|
||||||
public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";
|
public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";
|
||||||
|
|
||||||
public static final long DEFAULT_HEART_BEAT_TIMEOUT = TimeUnit.SECONDS.toMillis(15);
|
public static final long DEFAULT_HEART_BEAT_TIMEOUT = TimeUnit.SECONDS.toMillis(15);
|
||||||
|
|
||||||
public static final long DEFAULT_IP_DELETE_TIMEOUT = TimeUnit.SECONDS.toMillis(30);
|
public static final long DEFAULT_IP_DELETE_TIMEOUT = TimeUnit.SECONDS.toMillis(30);
|
||||||
|
|
||||||
public static final long DEFAULT_HEART_BEAT_INTERVAL = TimeUnit.SECONDS.toMillis(5);
|
public static final long DEFAULT_HEART_BEAT_INTERVAL = TimeUnit.SECONDS.toMillis(5);
|
||||||
|
|
||||||
public static final String DEFAULT_NAMESPACE_ID = "public";
|
public static final String DEFAULT_NAMESPACE_ID = "public";
|
||||||
|
|
||||||
public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;
|
public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;
|
||||||
|
|
||||||
public static final int WRITE_REDIRECT_CODE = 307;
|
public static final int WRITE_REDIRECT_CODE = 307;
|
||||||
|
|
||||||
public static final String SERVICE_INFO_SPLITER = "@@";
|
public static final String SERVICE_INFO_SPLITER = "@@";
|
||||||
|
|
||||||
public static final String NULL_STRING = "null";
|
public static final String NULL_STRING = "null";
|
||||||
|
|
||||||
public static final String NUMBER_PATTERN = "^\\d+$";
|
public static final String NUMBER_PATTERN = "^\\d+$";
|
||||||
|
|
||||||
public static final String ANY_PATTERN = ".*";
|
public static final String ANY_PATTERN = ".*";
|
||||||
|
|
||||||
public static final String DEFAULT_INSTANCE_ID_GENERATOR = "simple";
|
public static final String DEFAULT_INSTANCE_ID_GENERATOR = "simple";
|
||||||
|
|
||||||
public static final String SNOWFLAKE_INSTANCE_ID_GENERATOR = "snowflake";
|
public static final String SNOWFLAKE_INSTANCE_ID_GENERATOR = "snowflake";
|
||||||
|
|
||||||
public static final String HTTP_PREFIX = "http";
|
public static final String HTTP_PREFIX = "http";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api.common;
|
|
||||||
|
|
||||||
|
package com.alibaba.nacos.api.common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response code definitions.
|
* Response code definitions.
|
||||||
* <p>
|
*
|
||||||
* This class and inherited classes define codes separated from HTTP code to provide richer and preciser
|
* <p>This class and inherited classes define codes separated from HTTP code to provide richer and preciser information of
|
||||||
* information of the API results. A recommended rule for defining response code is:
|
* the API results. A recommended rule for defining response code is:
|
||||||
* <li> Global and common code starts with 10001.
|
* <li> Global and common code starts with 10001.
|
||||||
* <li> Naming module code starts with 20001.
|
* <li> Naming module code starts with 20001.
|
||||||
* <li> Config module code starts with 30001.
|
* <li> Config module code starts with 30001.
|
||||||
@ -29,9 +29,9 @@ package com.alibaba.nacos.api.common;
|
|||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class ResponseCode {
|
public class ResponseCode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Everything normal
|
* Everything normal.
|
||||||
*/
|
*/
|
||||||
public static final int OK = 10200;
|
public static final int OK = 10200;
|
||||||
}
|
}
|
||||||
|
@ -13,32 +13,32 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api.config;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.config.ConfigChangeItem;
|
package com.alibaba.nacos.api.config;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigChangeEvent
|
* ConfigChangeEvent.
|
||||||
*
|
*
|
||||||
* @author rushsky518
|
* @author rushsky518
|
||||||
*/
|
*/
|
||||||
public class ConfigChangeEvent {
|
public class ConfigChangeEvent {
|
||||||
private Map<String, ConfigChangeItem> data;
|
|
||||||
|
private final Map<String, ConfigChangeItem> data;
|
||||||
|
|
||||||
public ConfigChangeEvent(Map<String, ConfigChangeItem> data) {
|
public ConfigChangeEvent(Map<String, ConfigChangeItem> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigChangeItem getChangeItem(String key) {
|
public ConfigChangeItem getChangeItem(String key) {
|
||||||
return data.get(key);
|
return data.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ConfigChangeItem> getChangeItems() {
|
public Collection<ConfigChangeItem> getChangeItems() {
|
||||||
return data.values();
|
return data.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,65 +13,65 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config;
|
package com.alibaba.nacos.api.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigChangeItem
|
* ConfigChangeItem.
|
||||||
*
|
*
|
||||||
* @author rushsky518
|
* @author rushsky518
|
||||||
*/
|
*/
|
||||||
public class ConfigChangeItem {
|
public class ConfigChangeItem {
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
private String oldValue;
|
private String oldValue;
|
||||||
|
|
||||||
private String newValue;
|
private String newValue;
|
||||||
|
|
||||||
private PropertyChangeType type;
|
private PropertyChangeType type;
|
||||||
|
|
||||||
public ConfigChangeItem(String key, String oldValue, String newValue) {
|
public ConfigChangeItem(String key, String oldValue, String newValue) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.oldValue = oldValue;
|
this.oldValue = oldValue;
|
||||||
this.newValue = newValue;
|
this.newValue = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKey(String key) {
|
public void setKey(String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOldValue() {
|
public String getOldValue() {
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOldValue(String oldValue) {
|
public void setOldValue(String oldValue) {
|
||||||
this.oldValue = oldValue;
|
this.oldValue = oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNewValue() {
|
public String getNewValue() {
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewValue(String newValue) {
|
public void setNewValue(String newValue) {
|
||||||
this.newValue = newValue;
|
this.newValue = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyChangeType getType() {
|
public PropertyChangeType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(PropertyChangeType type) {
|
public void setType(PropertyChangeType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ConfigChangeItem{" +
|
return "ConfigChangeItem{" + "key='" + key + '\'' + ", oldValue='" + oldValue + '\'' + ", newValue='" + newValue
|
||||||
"key='" + key + '\'' +
|
+ '\'' + ", type=" + type + '}';
|
||||||
", oldValue='" + oldValue + '\'' +
|
|
||||||
", newValue='" + newValue + '\'' +
|
|
||||||
", type=" + type +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,23 +13,24 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api.config;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
package com.alibaba.nacos.api.config;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Factory
|
* Config Factory.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public class ConfigFactory {
|
public class ConfigFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Config
|
* Create Config.
|
||||||
*
|
*
|
||||||
* @param properties init param
|
* @param properties init param
|
||||||
* @return ConfigService
|
* @return ConfigService
|
||||||
@ -45,9 +46,9 @@ public class ConfigFactory {
|
|||||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Config
|
* Create Config.
|
||||||
*
|
*
|
||||||
* @param serverAddr serverList
|
* @param serverAddr serverList
|
||||||
* @return Config
|
* @return Config
|
||||||
|
@ -13,20 +13,21 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config;
|
package com.alibaba.nacos.api.config;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.config.listener.Listener;
|
import com.alibaba.nacos.api.config.listener.Listener;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Service Interface
|
* Config Service Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface ConfigService {
|
public interface ConfigService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config
|
* Get config.
|
||||||
*
|
*
|
||||||
* @param dataId dataId
|
* @param dataId dataId
|
||||||
* @param group group
|
* @param group group
|
||||||
@ -35,31 +36,30 @@ public interface ConfigService {
|
|||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
String getConfig(String dataId, String group, long timeoutMs) throws NacosException;
|
String getConfig(String dataId, String group, long timeoutMs) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config and register Listener
|
* Get config and register Listener.
|
||||||
*
|
*
|
||||||
* If you want to pull it yourself when the program starts to get the configuration for the first time,
|
* <p>If you want to pull it yourself when the program starts to get the configuration for the first time, and the
|
||||||
* and the registered Listener is used for future configuration updates, you can keep the original
|
* registered Listener is used for future configuration updates, you can keep the original code unchanged, just add
|
||||||
* code unchanged, just add the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead);
|
* the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead); therefore we recommend
|
||||||
* therefore we recommend that you use this interface directly
|
* that you use this interface directly
|
||||||
*
|
*
|
||||||
* @param dataId dataId
|
* @param dataId dataId
|
||||||
* @param group group
|
* @param group group
|
||||||
* @param timeoutMs read timeout
|
* @param timeoutMs read timeout
|
||||||
* @param listener {@link Listener}
|
* @param listener {@link Listener}
|
||||||
* @return config value
|
* @return config value
|
||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
String getConfigAndSignListener(String dataId, String group, long timeoutMs, Listener listener) throws NacosException;
|
String getConfigAndSignListener(String dataId, String group, long timeoutMs, Listener listener)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a listener to the configuration, after the server modified the
|
* Add a listener to the configuration, after the server modified the configuration, the client will use the
|
||||||
* configuration, the client will use the incoming listener callback.
|
* incoming listener callback. Recommended asynchronous processing, the application can implement the getExecutor
|
||||||
* Recommended asynchronous processing, the application can implement the
|
* method in the ManagerListener, provide a thread pool of execution. If provided, use the main thread callback, May
|
||||||
* getExecutor method in the ManagerListener, provide a thread pool of
|
* block other configurations or be blocked by other configurations.
|
||||||
* execution. If provided, use the main thread callback, May block other
|
|
||||||
* configurations or be blocked by other configurations.
|
|
||||||
*
|
*
|
||||||
* @param dataId dataId
|
* @param dataId dataId
|
||||||
* @param group group
|
* @param group group
|
||||||
@ -67,7 +67,7 @@ public interface ConfigService {
|
|||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
void addListener(String dataId, String group, Listener listener) throws NacosException;
|
void addListener(String dataId, String group, Listener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish config.
|
* Publish config.
|
||||||
*
|
*
|
||||||
@ -78,9 +78,9 @@ public interface ConfigService {
|
|||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
boolean publishConfig(String dataId, String group, String content) throws NacosException;
|
boolean publishConfig(String dataId, String group, String content) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove config
|
* Remove config.
|
||||||
*
|
*
|
||||||
* @param dataId dataId
|
* @param dataId dataId
|
||||||
* @param group group
|
* @param group group
|
||||||
@ -88,25 +88,25 @@ public interface ConfigService {
|
|||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
boolean removeConfig(String dataId, String group) throws NacosException;
|
boolean removeConfig(String dataId, String group) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove listener
|
* Remove listener.
|
||||||
*
|
*
|
||||||
* @param dataId dataId
|
* @param dataId dataId
|
||||||
* @param group group
|
* @param group group
|
||||||
* @param listener listener
|
* @param listener listener
|
||||||
*/
|
*/
|
||||||
void removeListener(String dataId, String group, Listener listener);
|
void removeListener(String dataId, String group, Listener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get server status
|
* Get server status.
|
||||||
*
|
*
|
||||||
* @return whether health
|
* @return whether health
|
||||||
*/
|
*/
|
||||||
String getServerStatus();
|
String getServerStatus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the resource service
|
* Shutdown the resource service.
|
||||||
*
|
*
|
||||||
* @throws NacosException exception.
|
* @throws NacosException exception.
|
||||||
*/
|
*/
|
||||||
|
@ -17,47 +17,48 @@
|
|||||||
package com.alibaba.nacos.api.config;
|
package com.alibaba.nacos.api.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Config data type.
|
||||||
|
*
|
||||||
* @author liaochuntao
|
* @author liaochuntao
|
||||||
* @date 2019-06-14 21:12
|
|
||||||
**/
|
**/
|
||||||
public enum ConfigType {
|
public enum ConfigType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "properties"
|
* config type is "properties".
|
||||||
*/
|
*/
|
||||||
PROPERTIES("properties"),
|
PROPERTIES("properties"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "xml"
|
* config type is "xml".
|
||||||
*/
|
*/
|
||||||
XML("xml"),
|
XML("xml"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "json"
|
* config type is "json".
|
||||||
*/
|
*/
|
||||||
JSON("json"),
|
JSON("json"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "text"
|
* config type is "text".
|
||||||
*/
|
*/
|
||||||
TEXT("text"),
|
TEXT("text"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "html"
|
* config type is "html".
|
||||||
*/
|
*/
|
||||||
HTML("html"),
|
HTML("html"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config type is "yaml"
|
* config type is "yaml".
|
||||||
*/
|
*/
|
||||||
YAML("yaml");
|
YAML("yaml");
|
||||||
|
|
||||||
String type;
|
String type;
|
||||||
|
|
||||||
ConfigType(String type) {
|
ConfigType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,25 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config;
|
package com.alibaba.nacos.api.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property Change Type
|
* Property Change Type.
|
||||||
*
|
*
|
||||||
* @author rushsky518
|
* @author rushsky518
|
||||||
*/
|
*/
|
||||||
public enum PropertyChangeType {
|
public enum PropertyChangeType {
|
||||||
/** add */
|
/**
|
||||||
|
* add.
|
||||||
|
*/
|
||||||
ADDED,
|
ADDED,
|
||||||
/** modified */
|
/**
|
||||||
|
* modified.
|
||||||
|
*/
|
||||||
MODIFIED,
|
MODIFIED,
|
||||||
/** deleted */
|
/**
|
||||||
|
* deleted.
|
||||||
|
*/
|
||||||
DELETED
|
DELETED
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.annotation;
|
package com.alibaba.nacos.api.config.annotation;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
import com.alibaba.nacos.api.annotation.NacosProperties;
|
||||||
@ -20,7 +21,11 @@ import com.alibaba.nacos.api.common.Constants;
|
|||||||
import com.alibaba.nacos.api.config.ConfigType;
|
import com.alibaba.nacos.api.config.ConfigType;
|
||||||
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
|
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||||
|
|
||||||
@ -34,42 +39,42 @@ import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosConfigListener {
|
public @interface NacosConfigListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Group ID
|
* Nacos Group ID.
|
||||||
*
|
*
|
||||||
* @return default value {@link Constants#DEFAULT_GROUP};
|
* @return default value {@link Constants#DEFAULT_GROUP};
|
||||||
*/
|
*/
|
||||||
String groupId() default DEFAULT_GROUP;
|
String groupId() default DEFAULT_GROUP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Data ID
|
* Nacos Data ID.
|
||||||
*
|
*
|
||||||
* @return required value.
|
* @return required value.
|
||||||
*/
|
*/
|
||||||
String dataId();
|
String dataId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Config type
|
* Nacos Config type.
|
||||||
*
|
*
|
||||||
* @return "properties"
|
* @return "properties"
|
||||||
*/
|
*/
|
||||||
ConfigType type() default ConfigType.PROPERTIES;
|
ConfigType type() default ConfigType.PROPERTIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
|
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
|
||||||
*
|
*
|
||||||
* @return The implementation class of {@link NacosConfigConverter}
|
* @return The implementation class of {@link NacosConfigConverter}
|
||||||
*/
|
*/
|
||||||
Class<? extends NacosConfigConverter> converter() default NacosConfigConverter.class;
|
Class<? extends NacosConfigConverter> converter() default NacosConfigConverter.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
||||||
*
|
*
|
||||||
* @return the default value is {@link NacosProperties}
|
* @return the default value is {@link NacosProperties}
|
||||||
*/
|
*/
|
||||||
NacosProperties properties() default @NacosProperties;
|
NacosProperties properties() default @NacosProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum timeout value of execution in milliseconds, which is used to prevent long-time blocking execution
|
* Maximum timeout value of execution in milliseconds, which is used to prevent long-time blocking execution
|
||||||
* impacting others.
|
* impacting others.
|
||||||
@ -77,5 +82,5 @@ public @interface NacosConfigListener {
|
|||||||
* @return default value is 1000
|
* @return default value is 1000
|
||||||
*/
|
*/
|
||||||
long timeout() default 1000L;
|
long timeout() default 1000L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.annotation;
|
package com.alibaba.nacos.api.config.annotation;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
@ -20,7 +21,11 @@ import com.alibaba.nacos.api.annotation.NacosProperties;
|
|||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.config.ConfigType;
|
import com.alibaba.nacos.api.config.ConfigType;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||||
|
|
||||||
@ -35,51 +40,49 @@ import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosConfigurationProperties {
|
public @interface NacosConfigurationProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config prefix name
|
* config prefix name.
|
||||||
*
|
*
|
||||||
* @return default value is <code>""</code>
|
* @return default value is <code>""</code>
|
||||||
*/
|
*/
|
||||||
String prefix() default "";
|
String prefix() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Group ID
|
* Nacos Group ID.
|
||||||
*
|
*
|
||||||
* @return default value {@link Constants#DEFAULT_GROUP};
|
* @return default value {@link Constants#DEFAULT_GROUP};
|
||||||
*/
|
*/
|
||||||
String groupId() default DEFAULT_GROUP;
|
String groupId() default DEFAULT_GROUP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Data ID
|
* Nacos Data ID.
|
||||||
*
|
*
|
||||||
* @return required value.
|
* @return required value.
|
||||||
*/
|
*/
|
||||||
String dataId();
|
String dataId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set config type is yaml
|
* set config type is yaml this method is deprecated, we support you use {@link #type()} to set config type.
|
||||||
* this method is deprecated, we support you use {@link #type()} to set config type
|
|
||||||
*
|
*
|
||||||
* @return default value <code>false</code>
|
* @return default value <code>false</code>
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated boolean yaml() default false;
|
||||||
boolean yaml() default false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config style
|
* config style.
|
||||||
*
|
*
|
||||||
* @return default value is {@link ConfigType#PROPERTIES}
|
* @return default value is {@link ConfigType#PROPERTIES}
|
||||||
*/
|
*/
|
||||||
ConfigType type() default ConfigType.PROPERTIES;
|
ConfigType type() default ConfigType.PROPERTIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
|
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
|
||||||
*
|
*
|
||||||
* @return default value is <code>false</code>
|
* @return default value is <code>false</code>
|
||||||
*/
|
*/
|
||||||
boolean autoRefreshed() default false;
|
boolean autoRefreshed() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate that when binding to this object invalid fields should be ignored. Invalid means invalid
|
* Flag to indicate that when binding to this object invalid fields should be ignored. Invalid means invalid
|
||||||
* according to the binder that is used, and usually this means fields of the wrong type (or that cannot be coerced
|
* according to the binder that is used, and usually this means fields of the wrong type (or that cannot be coerced
|
||||||
@ -88,14 +91,14 @@ public @interface NacosConfigurationProperties {
|
|||||||
* @return the flag value (default false)
|
* @return the flag value (default false)
|
||||||
*/
|
*/
|
||||||
boolean ignoreInvalidFields() default false;
|
boolean ignoreInvalidFields() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate that when binding to this object fields with periods in their names should be ignored.
|
* Flag to indicate that when binding to this object fields with periods in their names should be ignored.
|
||||||
*
|
*
|
||||||
* @return the flag value (default false)
|
* @return the flag value (default false)
|
||||||
*/
|
*/
|
||||||
boolean ignoreNestedProperties() default false;
|
boolean ignoreNestedProperties() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate that when binding to this object unknown fields should be ignored. An unknown field could be a
|
* Flag to indicate that when binding to this object unknown fields should be ignored. An unknown field could be a
|
||||||
* sign of a mistake in the Properties.
|
* sign of a mistake in the Properties.
|
||||||
@ -103,7 +106,7 @@ public @interface NacosConfigurationProperties {
|
|||||||
* @return the flag value (default true)
|
* @return the flag value (default true)
|
||||||
*/
|
*/
|
||||||
boolean ignoreUnknownFields() default true;
|
boolean ignoreUnknownFields() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate that an exception should be raised if a Validator is available and validation fails. If it is
|
* Flag to indicate that an exception should be raised if a Validator is available and validation fails. If it is
|
||||||
* set to false, validation errors will be swallowed. They will be logged, but not propagated to the caller.
|
* set to false, validation errors will be swallowed. They will be logged, but not propagated to the caller.
|
||||||
@ -111,12 +114,12 @@ public @interface NacosConfigurationProperties {
|
|||||||
* @return the flag value (default true)
|
* @return the flag value (default true)
|
||||||
*/
|
*/
|
||||||
boolean exceptionIfInvalid() default true;
|
boolean exceptionIfInvalid() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
* The {@link NacosProperties} attribute, If not specified, it will use global Nacos Properties.
|
||||||
*
|
*
|
||||||
* @return the default value is {@link NacosProperties}
|
* @return the default value is {@link NacosProperties}
|
||||||
*/
|
*/
|
||||||
NacosProperties properties() default @NacosProperties;
|
NacosProperties properties() default @NacosProperties;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.annotation;
|
package com.alibaba.nacos.api.config.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation for ignore field from annotated {@link NacosConfigurationProperties} Properties Object.
|
* An annotation for ignore field from annotated {@link NacosConfigurationProperties} Properties Object.
|
||||||
@ -29,4 +34,5 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosIgnore {
|
public @interface NacosIgnore {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.annotation;
|
package com.alibaba.nacos.api.config.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation for Nacos Property name of Nacos Configuration to bind a field from annotated {@link
|
* An annotation for Nacos Property name of Nacos Configuration to bind a field from annotated {@link
|
||||||
@ -30,12 +35,12 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosProperty {
|
public @interface NacosProperty {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The property name of Nacos Configuration to bind a field
|
* The property name of Nacos Configuration to bind a field.
|
||||||
*
|
*
|
||||||
* @return property name
|
* @return property name
|
||||||
*/
|
*/
|
||||||
String value();
|
String value();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.annotation;
|
package com.alibaba.nacos.api.config.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation which extends value to support auto-refresh
|
* Annotation which extends value to support auto-refresh.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:huangxiaoyu1018@gmail.com">hxy1991</a>
|
* @author <a href="mailto:huangxiaoyu1018@gmail.com">hxy1991</a>
|
||||||
* @since 0.2.0
|
* @since 0.2.0
|
||||||
@ -27,19 +32,19 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface NacosValue {
|
public @interface NacosValue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual value expression: e.g. "#{systemProperties.myProp}".
|
* The actual value expression: e.g. "#{systemProperties.myProp}".
|
||||||
*
|
*
|
||||||
* @return value expression
|
* @return value expression
|
||||||
*/
|
*/
|
||||||
String value();
|
String value();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It indicates that the currently bound property is auto-refreshed when Nacos configuration is changed.
|
* It indicates that the currently bound property is auto-refreshed when Nacos configuration is changed.
|
||||||
*
|
*
|
||||||
* @return default value is <code>false</code>
|
* @return default value is <code>false</code>
|
||||||
*/
|
*/
|
||||||
boolean autoRefreshed() default false;
|
boolean autoRefreshed() default false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,25 +13,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.convert;
|
package com.alibaba.nacos.api.config.convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos Config Converter
|
* Nacos Config Converter.
|
||||||
*
|
*
|
||||||
* @param <T> the target type that wanted
|
* @param <T> the target type that wanted
|
||||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||||
* @since 0.2.0
|
* @since 0.2.0
|
||||||
*/
|
*/
|
||||||
public interface NacosConfigConverter<T> {
|
public interface NacosConfigConverter<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* can convert to be target type or not
|
* can convert to be target type or not.
|
||||||
*
|
*
|
||||||
* @param targetType the type of target
|
* @param targetType the type of target
|
||||||
* @return If can , return <code>true</code>, or <code>false</code>
|
* @return If can , return <code>true</code>, or <code>false</code>
|
||||||
*/
|
*/
|
||||||
boolean canConvert(Class<T> targetType);
|
boolean canConvert(Class<T> targetType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert the Naocs's config of type S to target type T.
|
* convert the Naocs's config of type S to target type T.
|
||||||
*
|
*
|
||||||
@ -39,5 +40,5 @@ public interface NacosConfigConverter<T> {
|
|||||||
* @return the converted object, which must be an instance of T (potentially {@code null})
|
* @return the converted object, which must be an instance of T (potentially {@code null})
|
||||||
*/
|
*/
|
||||||
T convert(String config);
|
T convert(String config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Context Interface
|
* Config Context Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IConfigContext {
|
public interface IConfigContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get context param by key
|
* Get context param by key.
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key parameter key
|
||||||
* @return context
|
* @return context
|
||||||
*/
|
*/
|
||||||
Object getParameter(String key);
|
Object getParameter(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set context param
|
* Set context param.
|
||||||
*
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @param value value
|
* @param value value
|
||||||
|
@ -13,25 +13,27 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Filter Interface
|
* Config Filter Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IConfigFilter {
|
public interface IConfigFilter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init
|
* Init.
|
||||||
*
|
*
|
||||||
* @param filterConfig Filter Config
|
* @param filterConfig Filter Config
|
||||||
*/
|
*/
|
||||||
void init(IFilterConfig filterConfig);
|
void init(IFilterConfig filterConfig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* do filter
|
* do filter.
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @param response response
|
* @param response response
|
||||||
@ -40,24 +42,24 @@ public interface IConfigFilter {
|
|||||||
*/
|
*/
|
||||||
void doFilter(IConfigRequest request, IConfigResponse response, IConfigFilterChain filterChain)
|
void doFilter(IConfigRequest request, IConfigResponse response, IConfigFilterChain filterChain)
|
||||||
throws NacosException;
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deploy
|
* deploy.
|
||||||
*/
|
*/
|
||||||
void deploy();
|
void deploy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get order
|
* Get order.
|
||||||
*
|
*
|
||||||
* @return order number
|
* @return order number
|
||||||
*/
|
*/
|
||||||
int getOrder();
|
int getOrder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get filterName
|
* Get filterName.
|
||||||
*
|
*
|
||||||
* @return filter name
|
* @return filter name
|
||||||
*/
|
*/
|
||||||
String getFilterName();
|
String getFilterName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,23 +13,25 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Filter Chain Interface
|
* Config Filter Chain Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IConfigFilterChain {
|
public interface IConfigFilterChain {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter aciton
|
* Filter action.
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @param response response
|
* @param response response
|
||||||
* @throws NacosException NacosException
|
* @throws NacosException NacosException
|
||||||
*/
|
*/
|
||||||
void doFilter(IConfigRequest request, IConfigResponse response) throws NacosException;
|
void doFilter(IConfigRequest request, IConfigResponse response) throws NacosException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,27 +13,29 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Request Interface
|
* Config Request Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IConfigRequest {
|
public interface IConfigRequest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get param
|
* get param.
|
||||||
*
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @return value
|
* @return value
|
||||||
*/
|
*/
|
||||||
Object getParameter(String key);
|
Object getParameter(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get config context
|
* get config context.
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@link IConfigContext}
|
||||||
*/
|
*/
|
||||||
IConfigContext getConfigContext();
|
IConfigContext getConfigContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,27 +13,29 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Response Interface
|
* Config Response Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IConfigResponse {
|
public interface IConfigResponse {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get param
|
* get param.
|
||||||
*
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @return value
|
* @return value
|
||||||
*/
|
*/
|
||||||
Object getParameter(String key);
|
Object getParameter(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config context
|
* Get config context.
|
||||||
*
|
*
|
||||||
* @return configContext
|
* @return configContext
|
||||||
*/
|
*/
|
||||||
IConfigContext getConfigContext();
|
IConfigContext getConfigContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,28 +13,29 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.filter;
|
package com.alibaba.nacos.api.config.filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter Config Interface
|
* Filter Config Interface.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface IFilterConfig {
|
public interface IFilterConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get filter name
|
* get filter name.
|
||||||
*
|
*
|
||||||
* @return
|
* @return filter name
|
||||||
*/
|
*/
|
||||||
String getFilterName();
|
String getFilterName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get init param
|
* Get init param.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name parameter name
|
||||||
* @return param
|
* @return param
|
||||||
*/
|
*/
|
||||||
Object getInitParameter(String name);
|
Object getInitParameter(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,25 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.listener;
|
package com.alibaba.nacos.api.config.listener;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener Adapter,use default notify thread
|
* Listener Adapter,use default notify thread.
|
||||||
*
|
*
|
||||||
* @author water.lyl
|
* @author water.lyl
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
|
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
|
||||||
public abstract class AbstractListener implements Listener {
|
public abstract class AbstractListener implements Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use default executor
|
* Use default executor.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Executor getExecutor() {
|
public Executor getExecutor() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,38 +13,40 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.listener;
|
package com.alibaba.nacos.api.config.listener;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared Listener
|
* Shared Listener.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
|
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
|
||||||
public abstract class AbstractSharedListener implements Listener {
|
public abstract class AbstractSharedListener implements Listener {
|
||||||
|
|
||||||
private volatile String dataId;
|
private volatile String dataId;
|
||||||
|
|
||||||
private volatile String group;
|
private volatile String group;
|
||||||
|
|
||||||
public final void fillContext(String dataId, String group) {
|
public final void fillContext(String dataId, String group) {
|
||||||
this.dataId = dataId;
|
this.dataId = dataId;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void receiveConfigInfo(String configInfo) {
|
public final void receiveConfigInfo(String configInfo) {
|
||||||
innerReceive(dataId, group, configInfo);
|
innerReceive(dataId, group, configInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor getExecutor() {
|
public Executor getExecutor() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* receive
|
* receive.
|
||||||
*
|
*
|
||||||
* @param dataId data ID
|
* @param dataId data ID
|
||||||
* @param group group
|
* @param group group
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.listener;
|
package com.alibaba.nacos.api.config.listener;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.config.ConfigChangeItem;
|
import com.alibaba.nacos.api.config.ConfigChangeItem;
|
||||||
@ -21,25 +22,28 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigChangeParser
|
* ConfigChangeParser.
|
||||||
*
|
*
|
||||||
* @author rushsky518
|
* @author rushsky518
|
||||||
*/
|
*/
|
||||||
public interface ConfigChangeParser {
|
public interface ConfigChangeParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* judge type
|
* Judge type.
|
||||||
* @param type
|
*
|
||||||
* @return
|
* @param type data type
|
||||||
|
* @return true if is responsible type, otherwise false
|
||||||
*/
|
*/
|
||||||
boolean isResponsibleFor(String type);
|
boolean isResponsibleFor(String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* compare old and new data
|
* Compare old and new data.
|
||||||
* @param oldContent
|
*
|
||||||
* @param newContent
|
* @param oldContent old content
|
||||||
* @param type
|
* @param newContent new content
|
||||||
* @return
|
* @param type data type
|
||||||
* @throws IOException
|
* @return key and change item map
|
||||||
|
* @throws IOException io exception
|
||||||
*/
|
*/
|
||||||
Map<String, ConfigChangeItem> doParse(String oldContent, String newContent, String type) throws IOException;
|
Map<String, ConfigChangeItem> doParse(String oldContent, String newContent, String type) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -13,26 +13,27 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.config.listener;
|
package com.alibaba.nacos.api.config.listener;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener for watch config
|
* Listener for watch config.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get executor for execute this receive
|
* Get executor for execute this receive.
|
||||||
*
|
*
|
||||||
* @return Executor
|
* @return Executor
|
||||||
*/
|
*/
|
||||||
Executor getExecutor();
|
Executor getExecutor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive config info
|
* Receive config info.
|
||||||
*
|
*
|
||||||
* @param configInfo config info
|
* @param configInfo config info
|
||||||
*/
|
*/
|
||||||
|
@ -24,47 +24,43 @@ import java.lang.reflect.Type;
|
|||||||
* @author yangyi
|
* @author yangyi
|
||||||
*/
|
*/
|
||||||
public class NacosDeserializationException extends NacosRuntimeException {
|
public class NacosDeserializationException extends NacosRuntimeException {
|
||||||
|
|
||||||
public static final int ERROR_CODE = 101;
|
public static final int ERROR_CODE = 101;
|
||||||
|
|
||||||
private static final long serialVersionUID = -2742350751684273728L;
|
private static final long serialVersionUID = -2742350751684273728L;
|
||||||
|
|
||||||
private static final String DEFAULT_MSG = "Nacos deserialize failed. ";
|
private static final String DEFAULT_MSG = "Nacos deserialize failed. ";
|
||||||
|
|
||||||
private static final String MSG_FOR_SPECIFIED_CLASS = "Nacos deserialize for class [%s] failed. ";
|
private static final String MSG_FOR_SPECIFIED_CLASS = "Nacos deserialize for class [%s] failed. ";
|
||||||
|
|
||||||
private Class<?> targetClass;
|
private Class<?> targetClass;
|
||||||
|
|
||||||
public NacosDeserializationException() {
|
public NacosDeserializationException() {
|
||||||
super(ERROR_CODE);
|
super(ERROR_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosDeserializationException(Class<?> targetClass) {
|
public NacosDeserializationException(Class<?> targetClass) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetClass.getName()));
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetClass.getName()));
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosDeserializationException(Type targetType) {
|
public NacosDeserializationException(Type targetType) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetType.toString()));
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetType.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosDeserializationException(Throwable throwable) {
|
public NacosDeserializationException(Throwable throwable) {
|
||||||
super(ERROR_CODE, DEFAULT_MSG, throwable);
|
super(ERROR_CODE, DEFAULT_MSG, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosDeserializationException(Class<?> targetClass, Throwable throwable) {
|
public NacosDeserializationException(Class<?> targetClass, Throwable throwable) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetClass.getName()), throwable);
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetClass.getName()), throwable);
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosDeserializationException(Type targetType, Throwable throwable) {
|
public NacosDeserializationException(Type targetType, Throwable throwable) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetType.toString()), throwable);
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetType.toString()), throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Class<?> getTargetClass() {
|
public Class<?> getTargetClass() {
|
||||||
return targetClass;
|
return targetClass;
|
||||||
}
|
}
|
||||||
|
@ -22,37 +22,37 @@ package com.alibaba.nacos.api.exception.runtime;
|
|||||||
* @author yangyi
|
* @author yangyi
|
||||||
*/
|
*/
|
||||||
public class NacosRuntimeException extends RuntimeException {
|
public class NacosRuntimeException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3513491993982293262L;
|
private static final long serialVersionUID = 3513491993982293262L;
|
||||||
|
|
||||||
public static final String ERROR_MESSAGE_FORMAT = "errCode: %d, errMsg: %s ";
|
public static final String ERROR_MESSAGE_FORMAT = "errCode: %d, errMsg: %s ";
|
||||||
|
|
||||||
private int errCode;
|
private int errCode;
|
||||||
|
|
||||||
public NacosRuntimeException(int errCode) {
|
public NacosRuntimeException(int errCode) {
|
||||||
super();
|
super();
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosRuntimeException(int errCode, String errMsg) {
|
public NacosRuntimeException(int errCode, String errMsg) {
|
||||||
super(String.format(ERROR_MESSAGE_FORMAT, errCode, errMsg));
|
super(String.format(ERROR_MESSAGE_FORMAT, errCode, errMsg));
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosRuntimeException(int errCode, Throwable throwable) {
|
public NacosRuntimeException(int errCode, Throwable throwable) {
|
||||||
super(throwable);
|
super(throwable);
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosRuntimeException(int errCode, String errMsg, Throwable throwable) {
|
public NacosRuntimeException(int errCode, String errMsg, Throwable throwable) {
|
||||||
super(String.format(ERROR_MESSAGE_FORMAT, errCode, errMsg), throwable);
|
super(String.format(ERROR_MESSAGE_FORMAT, errCode, errMsg), throwable);
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getErrCode() {
|
public int getErrCode() {
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErrCode(int errCode) {
|
public void setErrCode(int errCode) {
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
}
|
}
|
||||||
|
@ -22,35 +22,35 @@ package com.alibaba.nacos.api.exception.runtime;
|
|||||||
* @author yangyi
|
* @author yangyi
|
||||||
*/
|
*/
|
||||||
public class NacosSerializationException extends NacosRuntimeException {
|
public class NacosSerializationException extends NacosRuntimeException {
|
||||||
|
|
||||||
public static final int ERROR_CODE = 100;
|
public static final int ERROR_CODE = 100;
|
||||||
|
|
||||||
private static final long serialVersionUID = -4308536346316915612L;
|
private static final long serialVersionUID = -4308536346316915612L;
|
||||||
|
|
||||||
private static final String DEFAULT_MSG = "Nacos serialize failed. ";
|
private static final String DEFAULT_MSG = "Nacos serialize failed. ";
|
||||||
|
|
||||||
private static final String MSG_FOR_SPECIFIED_CLASS = "Nacos serialize for class [%s] failed. ";
|
private static final String MSG_FOR_SPECIFIED_CLASS = "Nacos serialize for class [%s] failed. ";
|
||||||
|
|
||||||
private Class<?> serializedClass;
|
private Class<?> serializedClass;
|
||||||
|
|
||||||
public NacosSerializationException() {
|
public NacosSerializationException() {
|
||||||
super(ERROR_CODE);
|
super(ERROR_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosSerializationException(Class<?> serializedClass) {
|
public NacosSerializationException(Class<?> serializedClass) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, serializedClass.getName()));
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, serializedClass.getName()));
|
||||||
this.serializedClass = serializedClass;
|
this.serializedClass = serializedClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosSerializationException(Throwable throwable) {
|
public NacosSerializationException(Throwable throwable) {
|
||||||
super(ERROR_CODE, DEFAULT_MSG, throwable);
|
super(ERROR_CODE, DEFAULT_MSG, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NacosSerializationException(Class<?> serializedClass, Throwable throwable) {
|
public NacosSerializationException(Class<?> serializedClass, Throwable throwable) {
|
||||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, serializedClass.getName()), throwable);
|
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, serializedClass.getName()), throwable);
|
||||||
this.serializedClass = serializedClass;
|
this.serializedClass = serializedClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?> getSerializedClass() {
|
public Class<?> getSerializedClass() {
|
||||||
return serializedClass;
|
return serializedClass;
|
||||||
}
|
}
|
||||||
|
@ -13,25 +13,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming;
|
package com.alibaba.nacos.api.naming;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common parameters for service discovery
|
* Common parameters for service discovery.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class CommonParams {
|
public class CommonParams {
|
||||||
|
|
||||||
public static final String CODE = "code";
|
public static final String CODE = "code";
|
||||||
|
|
||||||
public static final String SERVICE_NAME = "serviceName";
|
public static final String SERVICE_NAME = "serviceName";
|
||||||
|
|
||||||
public static final String CLUSTER_NAME = "clusterName";
|
public static final String CLUSTER_NAME = "clusterName";
|
||||||
|
|
||||||
public static final String NAMESPACE_ID = "namespaceId";
|
public static final String NAMESPACE_ID = "namespaceId";
|
||||||
|
|
||||||
public static final String GROUP_NAME = "groupName";
|
public static final String GROUP_NAME = "groupName";
|
||||||
|
|
||||||
public static final String LIGHT_BEAT_ENABLED = "lightBeatEnabled";
|
public static final String LIGHT_BEAT_ENABLED = "lightBeatEnabled";
|
||||||
}
|
}
|
||||||
|
@ -13,36 +13,51 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming;
|
package com.alibaba.nacos.api.naming;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Naming Factory
|
* Naming Factory.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public class NamingFactory {
|
public class NamingFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new naming service.
|
||||||
|
*
|
||||||
|
* @param serverList server list
|
||||||
|
* @return new naming service
|
||||||
|
* @throws NacosException nacos exception
|
||||||
|
*/
|
||||||
public static NamingService createNamingService(String serverList) throws NacosException {
|
public static NamingService createNamingService(String serverList) throws NacosException {
|
||||||
try {
|
try {
|
||||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
||||||
Constructor constructor = driverImplClass.getConstructor(String.class);
|
Constructor constructor = driverImplClass.getConstructor(String.class);
|
||||||
NamingService vendorImpl = (NamingService)constructor.newInstance(serverList);
|
NamingService vendorImpl = (NamingService) constructor.newInstance(serverList);
|
||||||
return vendorImpl;
|
return vendorImpl;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new naming service.
|
||||||
|
*
|
||||||
|
* @param properties naming service properties
|
||||||
|
* @return new naming service
|
||||||
|
* @throws NacosException nacos exception
|
||||||
|
*/
|
||||||
public static NamingService createNamingService(Properties properties) throws NacosException {
|
public static NamingService createNamingService(Properties properties) throws NacosException {
|
||||||
try {
|
try {
|
||||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
||||||
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
||||||
NamingService vendorImpl = (NamingService)constructor.newInstance(properties);
|
NamingService vendorImpl = (NamingService) constructor.newInstance(properties);
|
||||||
return vendorImpl;
|
return vendorImpl;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||||
|
@ -22,31 +22,47 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Maintain service factory.
|
||||||
|
*
|
||||||
* @author liaochuntao
|
* @author liaochuntao
|
||||||
* @since 1.0.1
|
* @since 1.0.1
|
||||||
*/
|
*/
|
||||||
public class NamingMaintainFactory {
|
public class NamingMaintainFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a new maintain service.
|
||||||
|
*
|
||||||
|
* @param serverList server list
|
||||||
|
* @return new maintain service
|
||||||
|
* @throws NacosException nacos exception
|
||||||
|
*/
|
||||||
public static NamingMaintainService createMaintainService(String serverList) throws NacosException {
|
public static NamingMaintainService createMaintainService(String serverList) throws NacosException {
|
||||||
try {
|
try {
|
||||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
||||||
Constructor constructor = driverImplClass.getConstructor(String.class);
|
Constructor constructor = driverImplClass.getConstructor(String.class);
|
||||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(serverList);
|
NamingMaintainService vendorImpl = (NamingMaintainService) constructor.newInstance(serverList);
|
||||||
return vendorImpl;
|
return vendorImpl;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a new maintain service.
|
||||||
|
*
|
||||||
|
* @param properties properties
|
||||||
|
* @return new maintain service
|
||||||
|
* @throws NacosException nacos exception
|
||||||
|
*/
|
||||||
public static NamingMaintainService createMaintainService(Properties properties) throws NacosException {
|
public static NamingMaintainService createMaintainService(Properties properties) throws NacosException {
|
||||||
try {
|
try {
|
||||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
||||||
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
||||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(properties);
|
NamingMaintainService vendorImpl = (NamingMaintainService) constructor.newInstance(properties);
|
||||||
return vendorImpl;
|
return vendorImpl;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,145 +24,147 @@ import com.alibaba.nacos.api.selector.AbstractSelector;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operations related to Nacos
|
* Operations related to Nacos.
|
||||||
*
|
*
|
||||||
* @author liaochuntao
|
* @author liaochuntao
|
||||||
* @since 1.0.1
|
* @since 1.0.1
|
||||||
*/
|
*/
|
||||||
public interface NamingMaintainService {
|
public interface NamingMaintainService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update instance info
|
* update instance info.
|
||||||
*
|
*
|
||||||
* @param serviceName
|
* @param serviceName service name
|
||||||
* @param instance
|
* @param instance instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void updateInstance(String serviceName, Instance instance) throws NacosException;
|
void updateInstance(String serviceName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update instance info
|
* update instance info.
|
||||||
*
|
*
|
||||||
* @param serviceName
|
* @param serviceName service name
|
||||||
* @param groupName
|
* @param groupName group name
|
||||||
* @param instance
|
* @param instance instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void updateInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
void updateInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query service
|
* query service.
|
||||||
*
|
*
|
||||||
* @param serviceName
|
* @param serviceName service name
|
||||||
* @return
|
* @return service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Service queryService(String serviceName) throws NacosException;
|
Service queryService(String serviceName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query service
|
* query service.
|
||||||
*
|
*
|
||||||
* @param serviceName
|
* @param serviceName service name
|
||||||
* @param groupName
|
* @param groupName group name
|
||||||
* @return
|
* @return service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Service queryService(String serviceName, String groupName) throws NacosException;
|
Service queryService(String serviceName, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create service to Nacos
|
* create service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void createService(String serviceName) throws NacosException;
|
void createService(String serviceName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create service to Nacos
|
* create service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void createService(String serviceName, String groupName) throws NacosException;
|
void createService(String serviceName, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create service to Nacos
|
* create service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param protectThreshold protectThreshold of service
|
* @param protectThreshold protectThreshold of service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void createService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
void createService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create service to Nacos
|
* create service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param protectThreshold protectThreshold of service
|
* @param protectThreshold protectThreshold of service
|
||||||
* @param expression expression of selector
|
* @param expression expression of selector
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void createService(String serviceName, String groupName, float protectThreshold, String expression) throws NacosException;
|
void createService(String serviceName, String groupName, float protectThreshold, String expression)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create service to Nacos
|
* create service to Nacos.
|
||||||
*
|
*
|
||||||
* @param service name of service
|
* @param service name of service
|
||||||
* @param selector selector
|
* @param selector selector
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void createService(Service service, AbstractSelector selector) throws NacosException;
|
void createService(Service service, AbstractSelector selector) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete service from Nacos
|
* delete service from Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @return if delete service success return true
|
* @return if delete service success return true
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
boolean deleteService(String serviceName) throws NacosException;
|
boolean deleteService(String serviceName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete service from Nacos
|
* delete service from Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @return if delete service success return true
|
* @return if delete service success return true
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
boolean deleteService(String serviceName, String groupName) throws NacosException;
|
boolean deleteService(String serviceName, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update service to Nacos
|
* update service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param protectThreshold protectThreshold of service
|
* @param protectThreshold protectThreshold of service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void updateService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
void updateService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update service to Nacos
|
* update service to Nacos.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param protectThreshold protectThreshold of service
|
* @param protectThreshold protectThreshold of service
|
||||||
* @param metadata metadata of service
|
* @param metadata metadata of service
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void updateService(String serviceName, String groupName, float protectThreshold, Map<String, String> metadata) throws NacosException;
|
void updateService(String serviceName, String groupName, float protectThreshold, Map<String, String> metadata)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update service to Nacos with selector
|
* update service to Nacos with selector.
|
||||||
*
|
*
|
||||||
* @param service {@link Service} pojo of service
|
* @param service {@link Service} pojo of service
|
||||||
* @param selector {@link AbstractSelector} pojo of selector
|
* @param selector {@link AbstractSelector} pojo of selector
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void updateService(Service service, AbstractSelector selector) throws NacosException;
|
void updateService(Service service, AbstractSelector selector) throws NacosException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming;
|
package com.alibaba.nacos.api.naming;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.common.ResponseCode;
|
import com.alibaba.nacos.api.common.ResponseCode;
|
||||||
@ -20,16 +21,16 @@ import com.alibaba.nacos.api.common.ResponseCode;
|
|||||||
/**
|
/**
|
||||||
* Business response code of naming module
|
* Business response code of naming module
|
||||||
*
|
*
|
||||||
* Every code stays between 20001 to 29999.
|
* <p>Every code stays between 20001 to 29999.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @author 1.2.0
|
* @author 1.2.0
|
||||||
*/
|
*/
|
||||||
public class NamingResponseCode extends ResponseCode {
|
public class NamingResponseCode extends ResponseCode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The requested resource is not found
|
* The requested resource is not found.
|
||||||
*/
|
*/
|
||||||
public static final int RESOURCE_NOT_FOUND = 20404;
|
public static final int RESOURCE_NOT_FOUND = 20404;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming;
|
package com.alibaba.nacos.api.naming;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
@ -25,302 +26,309 @@ import com.alibaba.nacos.api.selector.AbstractSelector;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Naming Service
|
* Naming Service.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public interface NamingService {
|
public interface NamingService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service
|
* register a instance to service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, String ip, int port) throws NacosException;
|
void registerInstance(String serviceName, String ip, int port) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service
|
* register a instance to service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, String groupName, String ip, int port) throws NacosException;
|
void registerInstance(String serviceName, String groupName, String ip, int port) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service with specified cluster name
|
* register a instance to service with specified cluster name.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @param clusterName instance cluster name
|
* @param clusterName instance cluster name
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
|
void registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service with specified cluster name
|
* register a instance to service with specified cluster name.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @param clusterName instance cluster name
|
* @param clusterName instance cluster name
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, String groupName, String ip, int port, String clusterName) throws NacosException;
|
void registerInstance(String serviceName, String groupName, String ip, int port, String clusterName)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service with specified instance properties
|
* register a instance to service with specified instance properties.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param instance instance to register
|
* @param instance instance to register
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, Instance instance) throws NacosException;
|
void registerInstance(String serviceName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register a instance to service with specified instance properties
|
* register a instance to service with specified instance properties.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param instance instance to register
|
* @param instance instance to register
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance from a service
|
* deregister instance from a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, String ip, int port) throws NacosException;
|
void deregisterInstance(String serviceName, String ip, int port) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance from a service
|
* deregister instance from a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, String groupName, String ip, int port) throws NacosException;
|
void deregisterInstance(String serviceName, String groupName, String ip, int port) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance with specified cluster name from a service
|
* deregister instance with specified cluster name from a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @param clusterName instance cluster name
|
* @param clusterName instance cluster name
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
|
void deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance with specified cluster name from a service
|
* deregister instance with specified cluster name from a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param ip instance ip
|
* @param ip instance ip
|
||||||
* @param port instance port
|
* @param port instance port
|
||||||
* @param clusterName instance cluster name
|
* @param clusterName instance cluster name
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, String groupName, String ip, int port, String clusterName) throws NacosException;
|
void deregisterInstance(String serviceName, String groupName, String ip, int port, String clusterName)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance with full instance information and default groupName
|
* deregister instance with full instance information and default groupName.
|
||||||
* @param serviceName
|
*
|
||||||
* @param instance
|
* @param serviceName name of service
|
||||||
* @throws NacosException
|
* @param instance instance
|
||||||
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, Instance instance) throws NacosException;
|
void deregisterInstance(String serviceName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deregister instance with full instance information
|
* deregister instance with full instance information.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param instance instance information
|
* @param instance instance information
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void deregisterInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
void deregisterInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all instances of a service
|
* get all instances of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @return A list of instance
|
* @return A list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName) throws NacosException;
|
List<Instance> getAllInstances(String serviceName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all instances of a service
|
* get all instances of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @return A list of instance
|
* @return A list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, String groupName) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances of a service
|
* Get all instances of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A list of instance
|
* @return A list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, boolean subscribe) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances of a service
|
* Get all instances of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A list of instance
|
* @return A list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, String groupName, boolean subscribe) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, String groupName, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances within specified clusters of a service
|
* Get all instances within specified clusters of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @return A list of qualified instance
|
* @return A list of qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, List<String> clusters) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, List<String> clusters) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances within specified clusters of a service
|
* Get all instances within specified clusters of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @return A list of qualified instance
|
* @return A list of qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances within specified clusters of a service
|
* Get all instances within specified clusters of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A list of qualified instance
|
* @return A list of qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, List<String> clusters, boolean subscribe) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, List<String> clusters, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all instances within specified clusters of a service
|
* Get all instances within specified clusters of a service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A list of qualified instance
|
* @return A list of qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException;
|
List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters, boolean subscribe)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances of service
|
* Get qualified instances of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service.
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException;
|
List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances of service
|
* Get qualified instances of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, String groupName, boolean healthy) throws NacosException;
|
List<Instance> selectInstances(String serviceName, String groupName, boolean healthy) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances of service
|
* Get qualified instances of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, boolean healthy, boolean subscribe) throws NacosException;
|
List<Instance> selectInstances(String serviceName, boolean healthy, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances of service
|
* Get qualified instances of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe) throws NacosException;
|
List<Instance> selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances within specified clusters of service
|
* Get qualified instances within specified clusters of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy) throws NacosException;
|
List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances within specified clusters of service
|
* Get qualified instances within specified clusters of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy) throws NacosException;
|
List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances within specified clusters of service
|
* Get qualified instances within specified clusters of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy, boolean subscribe) throws NacosException;
|
List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy, boolean subscribe)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get qualified instances within specified clusters of service
|
* Get qualified instances within specified clusters of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
@ -328,234 +336,241 @@ public interface NamingService {
|
|||||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return A qualified list of instance
|
* @return A qualified list of instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy, boolean subscribe) throws NacosException;
|
List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy,
|
||||||
|
boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, String groupName) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* select one healthy instance of service using predefined load balance strategy
|
* select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, boolean subscribe) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* select one healthy instance of service using predefined load balance strategy
|
* select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters a list of clusters should the instance belongs to
|
* @param clusters a list of clusters should the instance belongs to
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, List<String> clusters) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, List<String> clusters) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters a list of clusters should the instance belongs to
|
* @param clusters a list of clusters should the instance belongs to
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters a list of clusters should the instance belongs to
|
* @param clusters a list of clusters should the instance belongs to
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select one healthy instance of service using predefined load balance strategy
|
* Select one healthy instance of service using predefined load balance strategy.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters a list of clusters should the instance belongs to
|
* @param clusters a list of clusters should the instance belongs to
|
||||||
* @param subscribe if subscribe the service
|
* @param subscribe if subscribe the service
|
||||||
* @return qualified instance
|
* @return qualified instance
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException;
|
Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void subscribe(String serviceName, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void subscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe event listener of service
|
* Unsubscribe event listener of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void unsubscribe(String serviceName, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unsubscribe event listener of service
|
* unsubscribe event listener of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe event listener of service
|
* Unsubscribe event listener of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe event listener of service
|
* Unsubscribe event listener of service.
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all service names from server
|
* Get all service names from server.
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return list of service names
|
* @return list of service names
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all service names from server
|
* Get all service names from server.
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @param groupName group name
|
* @param groupName group name
|
||||||
* @return list of service names
|
* @return list of service names
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all service names from server with selector
|
* Get all service names from server with selector.
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @param selector selector to filter the resource
|
* @param selector selector to filter the resource
|
||||||
* @return list of service names
|
* @return list of service names
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all service names from server with selector
|
* Get all service names from server with selector.
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @param groupName group name
|
* @param groupName group name
|
||||||
* @param selector selector to filter the resource
|
* @param selector selector to filter the resource
|
||||||
* @return list of service names
|
* @return list of service names
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName, AbstractSelector selector)
|
||||||
|
throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all subscribed services of current client
|
* Get all subscribed services of current client.
|
||||||
*
|
*
|
||||||
* @return subscribed services
|
* @return subscribed services
|
||||||
* @throws NacosException
|
* @throws NacosException nacos exception
|
||||||
*/
|
*/
|
||||||
List<ServiceInfo> getSubscribeServices() throws NacosException;
|
List<ServiceInfo> getSubscribeServices() throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get server health status
|
* get server health status.
|
||||||
*
|
*
|
||||||
* @return is server healthy
|
* @return is server healthy
|
||||||
*/
|
*/
|
||||||
String getServerStatus();
|
String getServerStatus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the resource service.
|
* Shutdown the resource service.
|
||||||
*
|
*
|
||||||
|
@ -13,26 +13,27 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming;
|
package com.alibaba.nacos.api.naming;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some keys of metadata that are recognized by Nacos
|
* Some keys of metadata that are recognized by Nacos.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class PreservedMetadataKeys {
|
public class PreservedMetadataKeys {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key to indicate the registry source of service instance, such as Dubbo, SpringCloud, etc.
|
* The key to indicate the registry source of service instance, such as Dubbo, SpringCloud, etc.
|
||||||
*/
|
*/
|
||||||
public static final String REGISTER_SOURCE = "preserved.register.source";
|
public static final String REGISTER_SOURCE = "preserved.register.source";
|
||||||
|
|
||||||
public static final String HEART_BEAT_TIMEOUT = "preserved.heart.beat.timeout";
|
public static final String HEART_BEAT_TIMEOUT = "preserved.heart.beat.timeout";
|
||||||
|
|
||||||
public static final String IP_DELETE_TIMEOUT = "preserved.ip.delete.timeout";
|
public static final String IP_DELETE_TIMEOUT = "preserved.ip.delete.timeout";
|
||||||
|
|
||||||
public static final String HEART_BEAT_INTERVAL = "preserved.heart.beat.interval";
|
public static final String HEART_BEAT_INTERVAL = "preserved.heart.beat.interval";
|
||||||
|
|
||||||
public static final String INSTANCE_ID_GENERATOR = "preserved.instance.id.generator";
|
public static final String INSTANCE_ID_GENERATOR = "preserved.instance.id.generator";
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.listener;
|
package com.alibaba.nacos.api.naming.listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Interface
|
* Event Interface.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public interface Event {
|
public interface Event {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,20 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.listener;
|
package com.alibaba.nacos.api.naming.listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Listener
|
* Event Listener.
|
||||||
*
|
*
|
||||||
* @author Nacos
|
* @author Nacos
|
||||||
*/
|
*/
|
||||||
public interface EventListener {
|
public interface EventListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* callback event
|
* callback event.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event event
|
||||||
*/
|
*/
|
||||||
void onEvent(Event event);
|
void onEvent(Event event);
|
||||||
}
|
}
|
||||||
|
@ -13,67 +13,68 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api.naming.listener;
|
|
||||||
|
|
||||||
import java.util.List;
|
package com.alibaba.nacos.api.naming.listener;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Naming Event
|
* Naming Event.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public class NamingEvent implements Event {
|
public class NamingEvent implements Event {
|
||||||
|
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
|
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
private String clusters;
|
private String clusters;
|
||||||
|
|
||||||
private List<Instance> instances;
|
private List<Instance> instances;
|
||||||
|
|
||||||
public NamingEvent(String serviceName, List<Instance> instances) {
|
public NamingEvent(String serviceName, List<Instance> instances) {
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.instances = instances;
|
this.instances = instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamingEvent(String serviceName, String groupName, String clusters, List<Instance> instances) {
|
public NamingEvent(String serviceName, String groupName, String clusters, List<Instance> instances) {
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.clusters = clusters;
|
this.clusters = clusters;
|
||||||
this.instances = instances;
|
this.instances = instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceName() {
|
public String getServiceName() {
|
||||||
return serviceName;
|
return serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceName(String serviceName) {
|
public void setServiceName(String serviceName) {
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Instance> getInstances() {
|
public List<Instance> getInstances() {
|
||||||
return instances;
|
return instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstances(List<Instance> instances) {
|
public void setInstances(List<Instance> instances) {
|
||||||
this.instances = instances;
|
this.instances = instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupName(String groupName) {
|
public void setGroupName(String groupName) {
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClusters() {
|
public String getClusters() {
|
||||||
return clusters;
|
return clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusters(String clusters) {
|
public void setClusters(String clusters) {
|
||||||
this.clusters = clusters;
|
this.clusters = clusters;
|
||||||
}
|
}
|
||||||
|
@ -13,113 +13,118 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.api.naming.pojo;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
package com.alibaba.nacos.api.naming.pojo;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker;
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cluster
|
* Cluster.
|
||||||
|
*
|
||||||
|
* <p>The class will be serialized to json, and there are some variables and method can't use Camel naming rule for
|
||||||
|
* compatibility
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:abbreviationaswordinname")
|
||||||
public class Cluster {
|
public class Cluster {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of belonging service
|
* Name of belonging service.
|
||||||
*/
|
*/
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of cluster
|
* Name of cluster.
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Health check config of this cluster
|
* Health check config of this cluster.
|
||||||
*/
|
*/
|
||||||
private AbstractHealthChecker healthChecker = new Tcp();
|
private AbstractHealthChecker healthChecker = new Tcp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default registered port for instances in this cluster.
|
* Default registered port for instances in this cluster.
|
||||||
*/
|
*/
|
||||||
private int defaultPort = 80;
|
private int defaultPort = 80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default health check port of instances in this cluster.
|
* Default health check port of instances in this cluster.
|
||||||
*/
|
*/
|
||||||
private int defaultCheckPort = 80;
|
private int defaultCheckPort = 80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not use instance port to do health check.
|
* Whether or not use instance port to do health check.
|
||||||
*/
|
*/
|
||||||
private boolean useIPPort4Check = true;
|
private boolean useIPPort4Check = true;
|
||||||
|
|
||||||
private Map<String, String> metadata = new HashMap<String, String>();
|
private Map<String, String> metadata = new HashMap<String, String>();
|
||||||
|
|
||||||
public Cluster() {
|
public Cluster() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cluster(String clusterName) {
|
public Cluster(String clusterName) {
|
||||||
this.name = clusterName;
|
this.name = clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceName() {
|
public String getServiceName() {
|
||||||
return serviceName;
|
return serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceName(String serviceName) {
|
public void setServiceName(String serviceName) {
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractHealthChecker getHealthChecker() {
|
public AbstractHealthChecker getHealthChecker() {
|
||||||
return healthChecker;
|
return healthChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHealthChecker(AbstractHealthChecker healthChecker) {
|
public void setHealthChecker(AbstractHealthChecker healthChecker) {
|
||||||
this.healthChecker = healthChecker;
|
this.healthChecker = healthChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultPort() {
|
public int getDefaultPort() {
|
||||||
return defaultPort;
|
return defaultPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultPort(int defaultPort) {
|
public void setDefaultPort(int defaultPort) {
|
||||||
this.defaultPort = defaultPort;
|
this.defaultPort = defaultPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultCheckPort() {
|
public int getDefaultCheckPort() {
|
||||||
return defaultCheckPort;
|
return defaultCheckPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultCheckPort(int defaultCheckPort) {
|
public void setDefaultCheckPort(int defaultCheckPort) {
|
||||||
this.defaultCheckPort = defaultCheckPort;
|
this.defaultCheckPort = defaultCheckPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUseIPPort4Check() {
|
public boolean isUseIPPort4Check() {
|
||||||
return useIPPort4Check;
|
return useIPPort4Check;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseIPPort4Check(boolean useIPPort4Check) {
|
public void setUseIPPort4Check(boolean useIPPort4Check) {
|
||||||
this.useIPPort4Check = useIPPort4Check;
|
this.useIPPort4Check = useIPPort4Check;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMetadata() {
|
public Map<String, String> getMetadata() {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadata(Map<String, String> metadata) {
|
public void setMetadata(Map<String, String> metadata) {
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,10 @@ public class Instance {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Instance{" + "instanceId='" + instanceId + '\'' + ", ip='" + ip + '\'' + ", port=" + port
|
return "Instance{" + "instanceId='" + instanceId + '\'' + ", ip='" + ip + '\'' + ", port=" + port + ", weight="
|
||||||
+ ", weight=" + weight + ", healthy=" + healthy + ", enabled=" + enabled + ", ephemeral="
|
+ weight + ", healthy=" + healthy + ", enabled=" + enabled + ", ephemeral=" + ephemeral
|
||||||
+ ephemeral + ", clusterName='" + clusterName + '\'' + ", serviceName='" + serviceName
|
+ ", clusterName='" + clusterName + '\'' + ", serviceName='" + serviceName + '\'' + ", metadata="
|
||||||
+ '\'' + ", metadata=" + metadata + '}';
|
+ metadata + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toInetAddr() {
|
public String toInetAddr() {
|
||||||
|
@ -13,41 +13,40 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo;
|
package com.alibaba.nacos.api.naming.pojo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ListView
|
* ListView.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public class ListView<T> {
|
public class ListView<T> {
|
||||||
|
|
||||||
private List<T> data;
|
private List<T> data;
|
||||||
|
|
||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
public List<T> getData() {
|
public List<T> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<T> data) {
|
public void setData(List<T> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCount(int count) {
|
public void setCount(int count) {
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ListView{" +
|
return "ListView{" + "data=" + data + ", count=" + count + '}';
|
||||||
"data=" + data +
|
|
||||||
", count=" + count +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,103 +13,100 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo;
|
package com.alibaba.nacos.api.naming.pojo;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service of Nacos
|
* Service of Nacos.
|
||||||
* <p>
|
*
|
||||||
* We introduce a 'service --> cluster --> instance' model, in which service stores a list of clusters,
|
* <p>We introduce a 'service --> cluster --> instance' model, in which service stores a list of clusters, which contains a
|
||||||
* which contains a list of instances.
|
* list of instances.
|
||||||
* <p>
|
*
|
||||||
* Typically we put some unique properties between instances to service level.
|
* <p>Typically we put some unique properties between instances to service level.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public class Service {
|
public class Service {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* service name
|
* service name.
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* protect threshold
|
* protect threshold.
|
||||||
*/
|
*/
|
||||||
private float protectThreshold = 0.0F;
|
private float protectThreshold = 0.0F;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* application name of this service
|
* application name of this service.
|
||||||
*/
|
*/
|
||||||
private String appName;
|
private String appName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service group to classify services into different sets.
|
* Service group to classify services into different sets.
|
||||||
*/
|
*/
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
private Map<String, String> metadata = new HashMap<String, String>();
|
private Map<String, String> metadata = new HashMap<String, String>();
|
||||||
|
|
||||||
public Service() {
|
public Service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Service(String name) {
|
public Service(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getProtectThreshold() {
|
public float getProtectThreshold() {
|
||||||
return protectThreshold;
|
return protectThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProtectThreshold(float protectThreshold) {
|
public void setProtectThreshold(float protectThreshold) {
|
||||||
this.protectThreshold = protectThreshold;
|
this.protectThreshold = protectThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAppName() {
|
public String getAppName() {
|
||||||
return appName;
|
return appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppName(String appName) {
|
public void setAppName(String appName) {
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupName(String groupName) {
|
public void setGroupName(String groupName) {
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMetadata() {
|
public Map<String, String> getMetadata() {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadata(Map<String, String> metadata) {
|
public void setMetadata(Map<String, String> metadata) {
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMetadata(String key, String value) {
|
public void addMetadata(String key, String value) {
|
||||||
this.metadata.put(key, value);
|
this.metadata.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Service{" +
|
return "Service{" + "name='" + name + '\'' + ", protectThreshold=" + protectThreshold + ", appName='" + appName
|
||||||
"name='" + name + '\'' +
|
+ '\'' + ", groupName='" + groupName + '\'' + ", metadata=" + metadata + '}';
|
||||||
", protectThreshold=" + protectThreshold +
|
|
||||||
", appName='" + appName + '\'' +
|
|
||||||
", groupName='" + groupName + '\'' +
|
|
||||||
", metadata=" + metadata +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo;
|
package com.alibaba.nacos.api.naming.pojo;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
@ -27,158 +28,173 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServiceInfo
|
* ServiceInfo.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
public class ServiceInfo {
|
public class ServiceInfo {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String jsonFromServer = EMPTY;
|
private String jsonFromServer = EMPTY;
|
||||||
|
|
||||||
public static final String SPLITER = "@@";
|
public static final String SPLITER = "@@";
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
private String clusters;
|
private String clusters;
|
||||||
|
|
||||||
private long cacheMillis = 1000L;
|
private long cacheMillis = 1000L;
|
||||||
|
|
||||||
private List<Instance> hosts = new ArrayList<Instance>();
|
private List<Instance> hosts = new ArrayList<Instance>();
|
||||||
|
|
||||||
private long lastRefTime = 0L;
|
private long lastRefTime = 0L;
|
||||||
|
|
||||||
private String checksum = "";
|
private String checksum = "";
|
||||||
|
|
||||||
private volatile boolean allIPs = false;
|
private volatile boolean allIPs = false;
|
||||||
|
|
||||||
public ServiceInfo() {
|
public ServiceInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllIPs() {
|
public boolean isAllIPs() {
|
||||||
return allIPs;
|
return allIPs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllIPs(boolean allIPs) {
|
public void setAllIPs(boolean allIPs) {
|
||||||
this.allIPs = allIPs;
|
this.allIPs = allIPs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceInfo(String key) {
|
public ServiceInfo(String key) {
|
||||||
|
|
||||||
int maxIndex = 2;
|
int maxIndex = 2;
|
||||||
int clusterIndex = 1;
|
int clusterIndex = 1;
|
||||||
int serviceNameIndex = 0;
|
int serviceNameIndex = 0;
|
||||||
|
|
||||||
String[] keys = key.split(Constants.SERVICE_INFO_SPLITER);
|
String[] keys = key.split(Constants.SERVICE_INFO_SPLITER);
|
||||||
if (keys.length >= maxIndex) {
|
if (keys.length >= maxIndex) {
|
||||||
this.name = keys[serviceNameIndex];
|
this.name = keys[serviceNameIndex];
|
||||||
this.clusters = keys[clusterIndex];
|
this.clusters = keys[clusterIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name = keys[0];
|
this.name = keys[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceInfo(String name, String clusters) {
|
public ServiceInfo(String name, String clusters) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.clusters = clusters;
|
this.clusters = clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ipCount() {
|
public int ipCount() {
|
||||||
return hosts.size();
|
return hosts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean expired() {
|
public boolean expired() {
|
||||||
return System.currentTimeMillis() - lastRefTime > cacheMillis;
|
return System.currentTimeMillis() - lastRefTime > cacheMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHosts(List<Instance> hosts) {
|
public void setHosts(List<Instance> hosts) {
|
||||||
this.hosts = hosts;
|
this.hosts = hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return hosts != null;
|
return hosts != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupName(String groupName) {
|
public void setGroupName(String groupName) {
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastRefTime(long lastRefTime) {
|
public void setLastRefTime(long lastRefTime) {
|
||||||
this.lastRefTime = lastRefTime;
|
this.lastRefTime = lastRefTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastRefTime() {
|
public long getLastRefTime() {
|
||||||
return lastRefTime;
|
return lastRefTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClusters() {
|
public String getClusters() {
|
||||||
return clusters;
|
return clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusters(String clusters) {
|
public void setClusters(String clusters) {
|
||||||
this.clusters = clusters;
|
this.clusters = clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCacheMillis() {
|
public long getCacheMillis() {
|
||||||
return cacheMillis;
|
return cacheMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCacheMillis(long cacheMillis) {
|
public void setCacheMillis(long cacheMillis) {
|
||||||
this.cacheMillis = cacheMillis;
|
this.cacheMillis = cacheMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Instance> getHosts() {
|
public List<Instance> getHosts() {
|
||||||
return new ArrayList<Instance>(hosts);
|
return new ArrayList<Instance>(hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Judge whether service info is validate.
|
||||||
|
*
|
||||||
|
* @return true if validate, otherwise false
|
||||||
|
*/
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
if (isAllIPs()) {
|
if (isAllIPs()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Instance> validHosts = new ArrayList<Instance>();
|
List<Instance> validHosts = new ArrayList<Instance>();
|
||||||
for (Instance host : hosts) {
|
for (Instance host : hosts) {
|
||||||
if (!host.isHealthy()) {
|
if (!host.isHealthy()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < host.getWeight(); i++) {
|
for (int i = 0; i < host.getWeight(); i++) {
|
||||||
validHosts.add(host);
|
validHosts.add(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getJsonFromServer() {
|
public String getJsonFromServer() {
|
||||||
return jsonFromServer;
|
return jsonFromServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJsonFromServer(String jsonFromServer) {
|
public void setJsonFromServer(String jsonFromServer) {
|
||||||
this.jsonFromServer = jsonFromServer;
|
this.jsonFromServer = jsonFromServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return getKey(name, clusters);
|
return getKey(name, clusters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public static String getKey(String name, String clusters) {
|
||||||
|
|
||||||
|
if (!isEmpty(clusters)) {
|
||||||
|
return name + Constants.SERVICE_INFO_SPLITER + clusters;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getKeyEncoded() {
|
public String getKeyEncoded() {
|
||||||
try {
|
try {
|
||||||
@ -187,12 +203,18 @@ public class ServiceInfo {
|
|||||||
return getKey();
|
return getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get {@link ServiceInfo} from key.
|
||||||
|
*
|
||||||
|
* @param key key of service info
|
||||||
|
* @return new service info
|
||||||
|
*/
|
||||||
public static ServiceInfo fromKey(String key) {
|
public static ServiceInfo fromKey(String key) {
|
||||||
ServiceInfo serviceInfo = new ServiceInfo();
|
ServiceInfo serviceInfo = new ServiceInfo();
|
||||||
int maxSegCount = 3;
|
int maxSegCount = 3;
|
||||||
String[] segs = key.split(Constants.SERVICE_INFO_SPLITER);
|
String[] segs = key.split(Constants.SERVICE_INFO_SPLITER);
|
||||||
if (segs.length == maxSegCount -1) {
|
if (segs.length == maxSegCount - 1) {
|
||||||
serviceInfo.setGroupName(segs[0]);
|
serviceInfo.setGroupName(segs[0]);
|
||||||
serviceInfo.setName(segs[1]);
|
serviceInfo.setName(segs[1]);
|
||||||
} else if (segs.length == maxSegCount) {
|
} else if (segs.length == maxSegCount) {
|
||||||
@ -202,43 +224,33 @@ public class ServiceInfo {
|
|||||||
}
|
}
|
||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public static String getKey(String name, String clusters) {
|
|
||||||
|
|
||||||
if (!isEmpty(clusters)) {
|
|
||||||
return name + Constants.SERVICE_INFO_SPLITER + clusters;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getKey();
|
return getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChecksum() {
|
public String getChecksum() {
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChecksum(String checksum) {
|
public void setChecksum(String checksum) {
|
||||||
this.checksum = checksum;
|
this.checksum = checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isEmpty(String str) {
|
private static boolean isEmpty(String str) {
|
||||||
return str == null || str.length() == 0;
|
return str == null || str.length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean strEquals(String str1, String str2) {
|
|
||||||
return str1 == null ? str2 == null : str1.equals(str2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isEmpty(Collection coll) {
|
private static boolean isEmpty(Collection coll) {
|
||||||
return (coll == null || coll.isEmpty());
|
return (coll == null || coll.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean strEquals(String str1, String str2) {
|
||||||
|
return str1 == null ? str2 == null : str1.equals(str2);
|
||||||
|
}
|
||||||
|
|
||||||
private static final String EMPTY = "";
|
private static final String EMPTY = "";
|
||||||
|
|
||||||
private static final String ALL_IPS = "000--00-ALL_IPS--00--000";
|
private static final String ALL_IPS = "000--00-ALL_IPS--00--000";
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
||||||
@ -25,28 +26,27 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Abstract health checker.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = None.class)
|
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = None.class)
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({@JsonSubTypes.Type(name = Http.TYPE, value = Http.class),
|
||||||
@JsonSubTypes.Type(name = Http.TYPE, value = Http.class),
|
@JsonSubTypes.Type(name = Mysql.TYPE, value = Mysql.class),
|
||||||
@JsonSubTypes.Type(name = Mysql.TYPE, value = Mysql.class),
|
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class)})
|
||||||
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class)
|
|
||||||
})
|
|
||||||
public abstract class AbstractHealthChecker implements Cloneable {
|
public abstract class AbstractHealthChecker implements Cloneable {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
protected final String type;
|
protected final String type;
|
||||||
|
|
||||||
protected AbstractHealthChecker(String type) {
|
protected AbstractHealthChecker(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone all fields of this instance to another one.
|
* Clone all fields of this instance to another one.
|
||||||
*
|
*
|
||||||
@ -55,18 +55,18 @@ public abstract class AbstractHealthChecker implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public abstract AbstractHealthChecker clone() throws CloneNotSupportedException;
|
public abstract AbstractHealthChecker clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of Health checker.
|
* Default implementation of Health checker.
|
||||||
*/
|
*/
|
||||||
public static class None extends AbstractHealthChecker {
|
public static class None extends AbstractHealthChecker {
|
||||||
|
|
||||||
public static final String TYPE = "NONE";
|
public static final String TYPE = "NONE";
|
||||||
|
|
||||||
public None() {
|
public None() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractHealthChecker clone() throws CloneNotSupportedException {
|
public AbstractHealthChecker clone() throws CloneNotSupportedException {
|
||||||
return new None();
|
return new None();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
|
||||||
@ -25,57 +26,75 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Health check type.
|
||||||
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
*/
|
*/
|
||||||
public enum HealthCheckType {
|
public enum HealthCheckType {
|
||||||
/**
|
/**
|
||||||
* TCP type
|
* TCP type.
|
||||||
*/
|
*/
|
||||||
TCP(Tcp.class),
|
TCP(Tcp.class),
|
||||||
/**
|
/**
|
||||||
* HTTP type
|
* HTTP type.
|
||||||
*/
|
*/
|
||||||
HTTP(Http.class),
|
HTTP(Http.class),
|
||||||
/**
|
/**
|
||||||
* MySQL type
|
* MySQL type.
|
||||||
*/
|
*/
|
||||||
MYSQL(Mysql.class),
|
MYSQL(Mysql.class),
|
||||||
/**
|
/**
|
||||||
* No check
|
* No check.
|
||||||
*/
|
*/
|
||||||
NONE(AbstractHealthChecker.None.class);
|
NONE(AbstractHealthChecker.None.class);
|
||||||
|
|
||||||
private final Class<? extends AbstractHealthChecker> healthCheckerClass;
|
private final Class<? extends AbstractHealthChecker> healthCheckerClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In JDK 1.6, the map need full class for general. So ignore check style.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:linelength")
|
||||||
private static final Map<String, Class<? extends AbstractHealthChecker>> EXTEND = new ConcurrentHashMap<String, Class<? extends AbstractHealthChecker>>();
|
private static final Map<String, Class<? extends AbstractHealthChecker>> EXTEND = new ConcurrentHashMap<String, Class<? extends AbstractHealthChecker>>();
|
||||||
|
|
||||||
HealthCheckType(Class<? extends AbstractHealthChecker> healthCheckerClass) {
|
HealthCheckType(Class<? extends AbstractHealthChecker> healthCheckerClass) {
|
||||||
this.healthCheckerClass = healthCheckerClass;
|
this.healthCheckerClass = healthCheckerClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerHealthChecker(String type, Class<? extends AbstractHealthChecker> healthCheckerClass){
|
/**
|
||||||
|
* Register extend health checker.
|
||||||
|
*
|
||||||
|
* @param type type name of extend health checker
|
||||||
|
* @param healthCheckerClass class of extend health checker
|
||||||
|
*/
|
||||||
|
public static void registerHealthChecker(String type, Class<? extends AbstractHealthChecker> healthCheckerClass) {
|
||||||
if (!EXTEND.containsKey(type)) {
|
if (!EXTEND.containsKey(type)) {
|
||||||
EXTEND.put(type, healthCheckerClass);
|
EXTEND.put(type, healthCheckerClass);
|
||||||
HealthCheckerFactory.registerSubType(healthCheckerClass, type);
|
HealthCheckerFactory.registerSubType(healthCheckerClass, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends AbstractHealthChecker> ofHealthCheckerClass(String type){
|
/**
|
||||||
|
* Get health checker class from type.
|
||||||
|
*
|
||||||
|
* @param type type name of extend health checker
|
||||||
|
* @return registered class if have, otherwise default class
|
||||||
|
*/
|
||||||
|
public static Class<? extends AbstractHealthChecker> ofHealthCheckerClass(String type) {
|
||||||
HealthCheckType enumType;
|
HealthCheckType enumType;
|
||||||
try {
|
try {
|
||||||
enumType = valueOf(type);
|
enumType = valueOf(type);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
return EXTEND.get(type);
|
return EXTEND.get(type);
|
||||||
}
|
}
|
||||||
return enumType.healthCheckerClass;
|
return enumType.healthCheckerClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Class<? extends AbstractHealthChecker>> getLoadedHealthCheckerClasses(){
|
public static List<Class<? extends AbstractHealthChecker>> getLoadedHealthCheckerClasses() {
|
||||||
List<Class<? extends AbstractHealthChecker>> all = new ArrayList<Class<? extends AbstractHealthChecker>>();
|
List<Class<? extends AbstractHealthChecker>> all = new ArrayList<Class<? extends AbstractHealthChecker>>();
|
||||||
for(HealthCheckType type : values()){
|
for (HealthCheckType type : values()) {
|
||||||
all.add(type.healthCheckerClass);
|
all.add(type.healthCheckerClass);
|
||||||
}
|
}
|
||||||
for(Map.Entry<String, Class<? extends AbstractHealthChecker>> entry : EXTEND.entrySet()){
|
for (Map.Entry<String, Class<? extends AbstractHealthChecker>> entry : EXTEND.entrySet()) {
|
||||||
all.add(entry.getValue());
|
all.add(entry.getValue());
|
||||||
}
|
}
|
||||||
return all;
|
return all;
|
||||||
|
@ -16,27 +16,27 @@
|
|||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.jsontype.NamedType;
|
import com.fasterxml.jackson.databind.jsontype.NamedType;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* health checker factory.
|
* health checker factory.
|
||||||
*
|
*
|
||||||
* @author yangyi
|
* @author yangyi
|
||||||
*/
|
*/
|
||||||
public class HealthCheckerFactory {
|
public class HealthCheckerFactory {
|
||||||
|
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register new sub type of health checker to factory for serialize and deserialize.
|
* Register new sub type of health checker to factory for serialize and deserialize.
|
||||||
*
|
*
|
||||||
@ -45,17 +45,18 @@ public class HealthCheckerFactory {
|
|||||||
public static void registerSubType(AbstractHealthChecker extendHealthChecker) {
|
public static void registerSubType(AbstractHealthChecker extendHealthChecker) {
|
||||||
registerSubType(extendHealthChecker.getClass(), extendHealthChecker.getType());
|
registerSubType(extendHealthChecker.getClass(), extendHealthChecker.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register new sub type of health checker to factory for serialize and deserialize.
|
* Register new sub type of health checker to factory for serialize and deserialize.
|
||||||
*
|
*
|
||||||
* @param extendHealthCheckerClass extend health checker
|
* @param extendHealthCheckerClass extend health checker
|
||||||
* @param typeName typeName of health checker
|
* @param typeName typeName of health checker
|
||||||
*/
|
*/
|
||||||
public static void registerSubType(Class<? extends AbstractHealthChecker> extendHealthCheckerClass, String typeName) {
|
public static void registerSubType(Class<? extends AbstractHealthChecker> extendHealthCheckerClass,
|
||||||
|
String typeName) {
|
||||||
MAPPER.registerSubtypes(new NamedType(extendHealthCheckerClass, typeName));
|
MAPPER.registerSubtypes(new NamedType(extendHealthCheckerClass, typeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create default {@link None} health checker.
|
* Create default {@link None} health checker.
|
||||||
*
|
*
|
||||||
@ -64,7 +65,7 @@ public class HealthCheckerFactory {
|
|||||||
public static None createNoneHealthChecker() {
|
public static None createNoneHealthChecker() {
|
||||||
return new None();
|
return new None();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize and create a instance of health checker.
|
* Deserialize and create a instance of health checker.
|
||||||
*
|
*
|
||||||
@ -79,9 +80,9 @@ public class HealthCheckerFactory {
|
|||||||
throw new RuntimeException("Deserialize health checker from json failed", e);
|
throw new RuntimeException("Deserialize health checker from json failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize a instance of health checker to json
|
* Serialize a instance of health checker to json.
|
||||||
*
|
*
|
||||||
* @param healthChecker health checker instance
|
* @param healthChecker health checker instance
|
||||||
* @return son string after serializing
|
* @return son string after serializing
|
||||||
|
@ -25,23 +25,23 @@ import com.google.common.base.Objects;
|
|||||||
* @author yangyi
|
* @author yangyi
|
||||||
*/
|
*/
|
||||||
public class Tcp extends AbstractHealthChecker {
|
public class Tcp extends AbstractHealthChecker {
|
||||||
|
|
||||||
public static final String TYPE = "TCP";
|
public static final String TYPE = "TCP";
|
||||||
|
|
||||||
public Tcp() {
|
public Tcp() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(TYPE);
|
return Objects.hashCode(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof Tcp;
|
return obj instanceof Tcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tcp clone() throws CloneNotSupportedException {
|
public Tcp clone() throws CloneNotSupportedException {
|
||||||
return new Tcp();
|
return new Tcp();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.selector;
|
package com.alibaba.nacos.api.selector;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
@ -20,24 +21,24 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract selector that only contains a type
|
* Abstract selector that only contains a type.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = NoneSelector.class)
|
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = NoneSelector.class)
|
||||||
public abstract class AbstractSelector {
|
public abstract class AbstractSelector {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of this selector, each child class should announce its own unique type.
|
* The type of this selector, each child class should announce its own unique type.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
protected AbstractSelector(String type) {
|
protected AbstractSelector(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.selector;
|
package com.alibaba.nacos.api.selector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,20 +23,20 @@ package com.alibaba.nacos.api.selector;
|
|||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class ExpressionSelector extends AbstractSelector {
|
public class ExpressionSelector extends AbstractSelector {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label expression of this selector.
|
* Label expression of this selector.
|
||||||
*/
|
*/
|
||||||
private String expression;
|
private String expression;
|
||||||
|
|
||||||
public ExpressionSelector() {
|
public ExpressionSelector() {
|
||||||
super(SelectorType.label.name());
|
super(SelectorType.label.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpression() {
|
public String getExpression() {
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpression(String expression) {
|
public void setExpression(String expression) {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,13 @@
|
|||||||
package com.alibaba.nacos.api.selector;
|
package com.alibaba.nacos.api.selector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* None selector.
|
||||||
|
*
|
||||||
* @author liaochuntao
|
* @author liaochuntao
|
||||||
* @since 1.0.1
|
* @since 1.0.1
|
||||||
*/
|
*/
|
||||||
public class NoneSelector extends AbstractSelector {
|
public class NoneSelector extends AbstractSelector {
|
||||||
|
|
||||||
public NoneSelector() {
|
public NoneSelector() {
|
||||||
super(SelectorType.none.name());
|
super(SelectorType.none.name());
|
||||||
}
|
}
|
||||||
|
@ -13,25 +13,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.selector;
|
package com.alibaba.nacos.api.selector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The types of selector accepted by Nacos
|
* The types of selector accepted by Nacos.
|
||||||
*
|
*
|
||||||
* @author nkorange
|
* @author nkorange
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public enum SelectorType {
|
public enum SelectorType {
|
||||||
/**
|
/**
|
||||||
* not match any type
|
* not match any type.
|
||||||
*/
|
*/
|
||||||
unknown,
|
unknown,
|
||||||
/**
|
/**
|
||||||
* not filter out any entity
|
* not filter out any entity.
|
||||||
*/
|
*/
|
||||||
none,
|
none,
|
||||||
/**
|
/**
|
||||||
* select by label
|
* select by label.
|
||||||
*/
|
*/
|
||||||
label
|
label
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,4 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
version=${project.version}
|
version=${project.version}
|
||||||
|
@ -13,22 +13,24 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.alibaba.nacos.api.annotation;
|
package com.alibaba.nacos.api.annotation;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static com.alibaba.nacos.api.annotation.NacosProperties.*;
|
import static com.alibaba.nacos.api.annotation.NacosProperties.ACCESS_KEY_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.CLUSTER_NAME_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.CONTEXT_PATH_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.ENCODE_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.ENDPOINT_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.NAMESPACE_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.SECRET_KEY_PLACEHOLDER;
|
||||||
|
import static com.alibaba.nacos.api.annotation.NacosProperties.SERVER_ADDR_PLACEHOLDER;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link NacosProperties} Test
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
|
||||||
* @since 0.2.1
|
|
||||||
*/
|
|
||||||
public class NacosPropertiesTest {
|
public class NacosPropertiesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPlaceholders() {
|
public void testPlaceholders() {
|
||||||
Assert.assertEquals("${nacos.endpoint:}", ENDPOINT_PLACEHOLDER);
|
Assert.assertEquals("${nacos.endpoint:}", ENDPOINT_PLACEHOLDER);
|
||||||
@ -40,43 +42,44 @@ public class NacosPropertiesTest {
|
|||||||
Assert.assertEquals("${nacos.cluster-name:}", CLUSTER_NAME_PLACEHOLDER);
|
Assert.assertEquals("${nacos.cluster-name:}", CLUSTER_NAME_PLACEHOLDER);
|
||||||
Assert.assertEquals("${nacos.encode:UTF-8}", ENCODE_PLACEHOLDER);
|
Assert.assertEquals("${nacos.encode:UTF-8}", ENCODE_PLACEHOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResolvePlaceholders() {
|
public void testResolvePlaceholders() {
|
||||||
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "nacos.endpoint", "test-value", "test-value");
|
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "nacos.endpoint", "test-value", "test-value");
|
||||||
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(NAMESPACE_PLACEHOLDER, "nacos.namespace", "test-value", "test-value");
|
testResolvePlaceholder(NAMESPACE_PLACEHOLDER, "nacos.namespace", "test-value", "test-value");
|
||||||
testResolvePlaceholder(NAMESPACE_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(NAMESPACE_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(ACCESS_KEY_PLACEHOLDER, "nacos.access-key", "test-value", "test-value");
|
testResolvePlaceholder(ACCESS_KEY_PLACEHOLDER, "nacos.access-key", "test-value", "test-value");
|
||||||
testResolvePlaceholder(ACCESS_KEY_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(ACCESS_KEY_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(SECRET_KEY_PLACEHOLDER, "nacos.secret-key", "test-value", "test-value");
|
testResolvePlaceholder(SECRET_KEY_PLACEHOLDER, "nacos.secret-key", "test-value", "test-value");
|
||||||
testResolvePlaceholder(SECRET_KEY_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(SECRET_KEY_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(SERVER_ADDR_PLACEHOLDER, "nacos.server-addr", "test-value", "test-value");
|
testResolvePlaceholder(SERVER_ADDR_PLACEHOLDER, "nacos.server-addr", "test-value", "test-value");
|
||||||
testResolvePlaceholder(SERVER_ADDR_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(SERVER_ADDR_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(CONTEXT_PATH_PLACEHOLDER, "nacos.context-path", "test-value", "test-value");
|
testResolvePlaceholder(CONTEXT_PATH_PLACEHOLDER, "nacos.context-path", "test-value", "test-value");
|
||||||
testResolvePlaceholder(CONTEXT_PATH_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(CONTEXT_PATH_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(CLUSTER_NAME_PLACEHOLDER, "nacos.cluster-name", "test-value", "test-value");
|
testResolvePlaceholder(CLUSTER_NAME_PLACEHOLDER, "nacos.cluster-name", "test-value", "test-value");
|
||||||
testResolvePlaceholder(CLUSTER_NAME_PLACEHOLDER, "", "test-value", "");
|
testResolvePlaceholder(CLUSTER_NAME_PLACEHOLDER, "", "test-value", "");
|
||||||
|
|
||||||
testResolvePlaceholder(ENCODE_PLACEHOLDER, "nacos.encode", "test-value", "test-value");
|
testResolvePlaceholder(ENCODE_PLACEHOLDER, "nacos.encode", "test-value", "test-value");
|
||||||
testResolvePlaceholder(ENCODE_PLACEHOLDER, "", "test-value", "UTF-8");
|
testResolvePlaceholder(ENCODE_PLACEHOLDER, "", "test-value", "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testResolvePlaceholder(String placeholder, String propertyName, String propertyValue, String expectValue) {
|
private void testResolvePlaceholder(String placeholder, String propertyName, String propertyValue,
|
||||||
|
String expectValue) {
|
||||||
MockEnvironment environment = new MockEnvironment();
|
MockEnvironment environment = new MockEnvironment();
|
||||||
environment.setProperty(propertyName, propertyValue);
|
environment.setProperty(propertyName, propertyValue);
|
||||||
String resolvedValue = environment.resolvePlaceholders(placeholder);
|
String resolvedValue = environment.resolvePlaceholders(placeholder);
|
||||||
Assert.assertEquals(expectValue, resolvedValue);
|
Assert.assertEquals(expectValue, resolvedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSort() {
|
public void testSort() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -28,18 +29,18 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ServiceInfoTest {
|
public class ServiceInfoTest {
|
||||||
|
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
private ServiceInfo serviceInfo;
|
private ServiceInfo serviceInfo;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
serviceInfo = new ServiceInfo("testName", "testClusters");
|
serviceInfo = new ServiceInfo("testName", "testClusters");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() throws JsonProcessingException {
|
public void testSerialize() throws JsonProcessingException {
|
||||||
String actual = mapper.writeValueAsString(serviceInfo);
|
String actual = mapper.writeValueAsString(serviceInfo);
|
||||||
@ -55,8 +56,9 @@ public class ServiceInfoTest {
|
|||||||
assertFalse(actual.contains("key"));
|
assertFalse(actual.contains("key"));
|
||||||
assertFalse(actual.contains("keyEncoded"));
|
assertFalse(actual.contains("keyEncoded"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("checkstyle:linelength")
|
||||||
public void testDeserialize() throws IOException {
|
public void testDeserialize() throws IOException {
|
||||||
String example = "{\"name\":\"testName\",\"clusters\":\"testClusters\",\"cacheMillis\":1000,\"hosts\":[],\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"valid\":true,\"groupName\":\"\"}";
|
String example = "{\"name\":\"testName\",\"clusters\":\"testClusters\",\"cacheMillis\":1000,\"hosts\":[],\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"valid\":true,\"groupName\":\"\"}";
|
||||||
ServiceInfo actual = mapper.readValue(example, ServiceInfo.class);
|
ServiceInfo actual = mapper.readValue(example, ServiceInfo.class);
|
||||||
|
@ -16,28 +16,28 @@
|
|||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.jsontype.NamedType;
|
import com.fasterxml.jackson.databind.jsontype.NamedType;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class AbstractHealthCheckerTest {
|
public class AbstractHealthCheckerTest {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
objectMapper.registerSubtypes(new NamedType(TestChecker.class, TestChecker.TYPE));
|
objectMapper.registerSubtypes(new NamedType(TestChecker.class, TestChecker.TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() throws JsonProcessingException {
|
public void testSerialize() throws JsonProcessingException {
|
||||||
TestChecker testChecker = new TestChecker();
|
TestChecker testChecker = new TestChecker();
|
||||||
@ -46,7 +46,7 @@ public class AbstractHealthCheckerTest {
|
|||||||
assertTrue(actual.contains("\"testValue\":\"\""));
|
assertTrue(actual.contains("\"testValue\":\"\""));
|
||||||
assertTrue(actual.contains("\"type\":\"TEST\""));
|
assertTrue(actual.contains("\"type\":\"TEST\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize() throws IOException {
|
public void testDeserialize() throws IOException {
|
||||||
String testChecker = "{\"type\":\"TEST\",\"testValue\":\"\"}";
|
String testChecker = "{\"type\":\"TEST\",\"testValue\":\"\"}";
|
||||||
|
@ -16,22 +16,21 @@
|
|||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
|
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class HealthCheckerFactoryTest {
|
public class HealthCheckerFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() {
|
public void testSerialize() {
|
||||||
Tcp tcp = new Tcp();
|
Tcp tcp = new Tcp();
|
||||||
String actual = HealthCheckerFactory.serialize(tcp);
|
String actual = HealthCheckerFactory.serialize(tcp);
|
||||||
assertTrue(actual.contains("\"type\":\"TCP\""));
|
assertTrue(actual.contains("\"type\":\"TCP\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerializeExtend() {
|
public void testSerializeExtend() {
|
||||||
HealthCheckerFactory.registerSubType(TestChecker.class, TestChecker.TYPE);
|
HealthCheckerFactory.registerSubType(TestChecker.class, TestChecker.TYPE);
|
||||||
@ -39,14 +38,14 @@ public class HealthCheckerFactoryTest {
|
|||||||
String actual = HealthCheckerFactory.serialize(testChecker);
|
String actual = HealthCheckerFactory.serialize(testChecker);
|
||||||
assertTrue(actual.contains("\"type\":\"TEST\""));
|
assertTrue(actual.contains("\"type\":\"TEST\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize() {
|
public void testDeserialize() {
|
||||||
String tcpString = "{\"type\":\"TCP\"}";
|
String tcpString = "{\"type\":\"TCP\"}";
|
||||||
AbstractHealthChecker actual = HealthCheckerFactory.deserialize(tcpString);
|
AbstractHealthChecker actual = HealthCheckerFactory.deserialize(tcpString);
|
||||||
assertEquals(Tcp.class, actual.getClass());
|
assertEquals(Tcp.class, actual.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserializeExtend() {
|
public void testDeserializeExtend() {
|
||||||
String tcpString = "{\"type\":\"TEST\",\"testValue\":null}";
|
String tcpString = "{\"type\":\"TEST\",\"testValue\":null}";
|
||||||
|
@ -20,24 +20,24 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||||
|
|
||||||
public class TestChecker extends AbstractHealthChecker {
|
public class TestChecker extends AbstractHealthChecker {
|
||||||
|
|
||||||
@JsonTypeInfo(use = Id.NAME, property = "type")
|
@JsonTypeInfo(use = Id.NAME, property = "type")
|
||||||
public static final String TYPE = "TEST";
|
public static final String TYPE = "TEST";
|
||||||
|
|
||||||
private String testValue;
|
private String testValue;
|
||||||
|
|
||||||
public String getTestValue() {
|
public String getTestValue() {
|
||||||
return testValue;
|
return testValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTestValue(String testValue) {
|
public void setTestValue(String testValue) {
|
||||||
this.testValue = testValue;
|
this.testValue = testValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestChecker() {
|
public TestChecker() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractHealthChecker clone() throws CloneNotSupportedException {
|
public AbstractHealthChecker clone() throws CloneNotSupportedException {
|
||||||
return null;
|
return null;
|
||||||
|
@ -16,37 +16,36 @@
|
|||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
public class HttpTest {
|
public class HttpTest {
|
||||||
|
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
private Http http;
|
private Http http;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper();
|
||||||
http = new Http();
|
http = new Http();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetExpectedResponseCodeWithEmpty() {
|
public void testGetExpectedResponseCodeWithEmpty() {
|
||||||
http.setHeaders("");
|
http.setHeaders("");
|
||||||
assertTrue(http.getCustomHeaders().isEmpty());
|
assertTrue(http.getCustomHeaders().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetExpectedResponseCodeWithoutEmpty() {
|
public void testGetExpectedResponseCodeWithoutEmpty() {
|
||||||
http.setHeaders("x:a|y:");
|
http.setHeaders("x:a|y:");
|
||||||
@ -55,7 +54,7 @@ public class HttpTest {
|
|||||||
assertEquals(1, actual.size());
|
assertEquals(1, actual.size());
|
||||||
assertEquals("a", actual.get("x"));
|
assertEquals("a", actual.get("x"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() throws JsonProcessingException {
|
public void testSerialize() throws JsonProcessingException {
|
||||||
http.setHeaders("x:a|y:");
|
http.setHeaders("x:a|y:");
|
||||||
@ -66,7 +65,7 @@ public class HttpTest {
|
|||||||
assertTrue(actual.contains("\"headers\":\"x:a|y:\""));
|
assertTrue(actual.contains("\"headers\":\"x:a|y:\""));
|
||||||
assertTrue(actual.contains("\"expectedResponseCode\":200"));
|
assertTrue(actual.contains("\"expectedResponseCode\":200"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize() throws IOException {
|
public void testDeserialize() throws IOException {
|
||||||
String testChecker = "{\"type\":\"HTTP\",\"path\":\"/x\",\"headers\":\"x:a|y:\",\"expectedResponseCode\":200}";
|
String testChecker = "{\"type\":\"HTTP\",\"path\":\"/x\",\"headers\":\"x:a|y:\",\"expectedResponseCode\":200}";
|
||||||
|
@ -16,23 +16,22 @@
|
|||||||
|
|
||||||
package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
|
package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
|
||||||
|
|
||||||
import java.io.IOException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import java.io.IOException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class MysqlTest {
|
public class MysqlTest {
|
||||||
|
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
private Mysql mysql;
|
private Mysql mysql;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mysql = new Mysql();
|
mysql = new Mysql();
|
||||||
@ -41,7 +40,7 @@ public class MysqlTest {
|
|||||||
mysql.setCmd("cmd");
|
mysql.setCmd("cmd");
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() throws JsonProcessingException {
|
public void testSerialize() throws JsonProcessingException {
|
||||||
String actual = objectMapper.writeValueAsString(mysql);
|
String actual = objectMapper.writeValueAsString(mysql);
|
||||||
@ -50,7 +49,7 @@ public class MysqlTest {
|
|||||||
assertTrue(actual.contains("\"pwd\":\"pwd\""));
|
assertTrue(actual.contains("\"pwd\":\"pwd\""));
|
||||||
assertTrue(actual.contains("\"cmd\":\"cmd\""));
|
assertTrue(actual.contains("\"cmd\":\"cmd\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize() throws IOException {
|
public void testDeserialize() throws IOException {
|
||||||
String testChecker = "{\"type\":\"MYSQL\",\"user\":\"user\",\"pwd\":\"pwd\",\"cmd\":\"cmd\"}";
|
String testChecker = "{\"type\":\"MYSQL\",\"user\":\"user\",\"pwd\":\"pwd\",\"cmd\":\"cmd\"}";
|
||||||
|
Loading…
Reference in New Issue
Block a user