For new codeStyle in nacos-api module (#3190)
This commit is contained in:
parent
51c0eb25ad
commit
c9bf5f2f70
@ -15,7 +15,7 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<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>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-all</artifactId>
|
||||
|
@ -13,27 +13,28 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* 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.ConfigService;
|
||||
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.NamingMaintainService;
|
||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Nacos Factory
|
||||
* Nacos Factory.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public class NacosFactory {
|
||||
|
||||
/**
|
||||
* Create config service
|
||||
* Create config service.
|
||||
*
|
||||
* @param properties init param
|
||||
* @return config
|
||||
@ -44,7 +45,7 @@ public class NacosFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create config service
|
||||
* Create config service.
|
||||
*
|
||||
* @param serverAddr server list
|
||||
* @return config
|
||||
@ -55,7 +56,7 @@ public class NacosFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create naming service
|
||||
* Create naming service.
|
||||
*
|
||||
* @param serverAddr server list
|
||||
* @return Naming
|
||||
@ -66,7 +67,7 @@ public class NacosFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create naming service
|
||||
* Create naming service.
|
||||
*
|
||||
* @param properties init param
|
||||
* @return Naming
|
||||
@ -77,9 +78,9 @@ public class NacosFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create maintain service
|
||||
* Create maintain service.
|
||||
*
|
||||
* @param serverAddr
|
||||
* @param serverAddr server address
|
||||
* @return NamingMaintainService
|
||||
* @throws NacosException Exception
|
||||
*/
|
||||
@ -88,9 +89,9 @@ public class NacosFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create maintain service
|
||||
* Create maintain service.
|
||||
*
|
||||
* @param properties
|
||||
* @param properties server address
|
||||
* @return NamingMaintainService
|
||||
* @throws NacosException Exception
|
||||
*/
|
||||
|
@ -13,59 +13,60 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api;
|
||||
|
||||
/**
|
||||
* Property Key Const
|
||||
* Property Key Const.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
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 {
|
||||
|
||||
|
@ -13,16 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Support for reading the value of the specified variable from the -D parameter
|
||||
* </P>
|
||||
* Properties that are preferred to which in {@link PropertyKeyConst}
|
||||
* Support for reading the value of the specified variable from the -D parameter.
|
||||
*
|
||||
* <p>Properties that are preferred to which in {@link PropertyKeyConst}
|
||||
*
|
||||
* @author pbting
|
||||
* @date 2019-02-22 3:38 PM
|
||||
*/
|
||||
public interface SystemPropertyKeyConst {
|
||||
|
||||
@ -31,8 +30,8 @@ public interface SystemPropertyKeyConst {
|
||||
String NAMING_WEB_CONTEXT = "nacos.naming.web.context";
|
||||
|
||||
/**
|
||||
* In the cloud (Alibaba Cloud or other cloud vendors) environment,
|
||||
* whether to enable namespace resolution in the cloud environment.
|
||||
* In the cloud (Alibaba Cloud or other cloud vendors) environment, whether to enable namespace resolution in the
|
||||
* cloud environment.
|
||||
* <p>
|
||||
* The default is on.
|
||||
* </p>
|
||||
@ -40,8 +39,8 @@ public interface SystemPropertyKeyConst {
|
||||
String IS_USE_CLOUD_NAMESPACE_PARSING = "nacos.use.cloud.namespace.parsing";
|
||||
|
||||
/**
|
||||
* In the cloud environment, if the process level requires a globally uniform namespace,
|
||||
* it can be specified with the -D parameter.
|
||||
* In the cloud environment, if the process level requires a globally uniform namespace, it can be specified with
|
||||
* the -D parameter.
|
||||
*/
|
||||
String ANS_NAMESPACE = "ans.namespace";
|
||||
|
||||
|
@ -13,12 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.annotation;
|
||||
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
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.
|
||||
|
@ -13,14 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.annotation;
|
||||
|
||||
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>
|
||||
* @see PropertyKeyConst
|
||||
@ -32,153 +37,156 @@ import java.lang.annotation.*;
|
||||
public @interface NacosProperties {
|
||||
|
||||
/**
|
||||
* The prefix of property name of Nacos
|
||||
* The prefix of property name of Nacos.
|
||||
*/
|
||||
String PREFIX = "nacos.";
|
||||
|
||||
/**
|
||||
* The property name of "endpoint"
|
||||
* The property name of "endpoint".
|
||||
*/
|
||||
String ENDPOINT = "endpoint";
|
||||
|
||||
/**
|
||||
* The property name of "namespace"
|
||||
* The property name of "namespace".
|
||||
*/
|
||||
String NAMESPACE = "namespace";
|
||||
|
||||
/**
|
||||
* The property name of "access-key"
|
||||
* The property name of "access-key".
|
||||
*/
|
||||
String ACCESS_KEY = "access-key";
|
||||
|
||||
/**
|
||||
* The property name of "secret-key"
|
||||
* The property name of "secret-key".
|
||||
*/
|
||||
String SECRET_KEY = "secret-key";
|
||||
|
||||
/**
|
||||
* The property name of "server-addr"
|
||||
* The property name of "server-addr".
|
||||
*/
|
||||
String SERVER_ADDR = "server-addr";
|
||||
|
||||
/**
|
||||
* The property name of "context-path"
|
||||
* The property name of "context-path".
|
||||
*/
|
||||
String CONTEXT_PATH = "context-path";
|
||||
|
||||
/**
|
||||
* The property name of "cluster-name"
|
||||
* The property name of "cluster-name".
|
||||
*/
|
||||
String CLUSTER_NAME = "cluster-name";
|
||||
|
||||
/**
|
||||
* The property name of "encode"
|
||||
* The property name of "encode".
|
||||
*/
|
||||
String ENCODE = "encode";
|
||||
|
||||
/**
|
||||
* The property name of "long-poll.timeout"
|
||||
* The property name of "long-poll.timeout".
|
||||
*/
|
||||
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";
|
||||
|
||||
/**
|
||||
* The property name of "maxRetry"
|
||||
* The property name of "maxRetry".
|
||||
*/
|
||||
String MAX_RETRY = "maxRetry";
|
||||
|
||||
/**
|
||||
* The property name of "enableRemoteSyncConfig"
|
||||
* The property name of "enableRemoteSyncConfig".
|
||||
*/
|
||||
String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
||||
|
||||
/**
|
||||
* The property name of "username"
|
||||
* The property name of "username".
|
||||
*/
|
||||
String USERNAME = "username";
|
||||
|
||||
/**
|
||||
* The property name of "password"
|
||||
* The property name of "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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* 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 + ":}";
|
||||
|
||||
/**
|
||||
* The property of "endpoint"
|
||||
* The property of "endpoint".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #ENDPOINT_PLACEHOLDER
|
||||
@ -186,7 +194,7 @@ public @interface NacosProperties {
|
||||
String endpoint() default ENDPOINT_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "namespace"
|
||||
* The property of "namespace".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #NAMESPACE_PLACEHOLDER
|
||||
@ -194,7 +202,7 @@ public @interface NacosProperties {
|
||||
String namespace() default NAMESPACE_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "access-key"
|
||||
* The property of "access-key".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #ACCESS_KEY_PLACEHOLDER
|
||||
@ -202,7 +210,7 @@ public @interface NacosProperties {
|
||||
String accessKey() default ACCESS_KEY_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "secret-key"
|
||||
* The property of "secret-key".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #SECRET_KEY_PLACEHOLDER
|
||||
@ -210,7 +218,7 @@ public @interface NacosProperties {
|
||||
String secretKey() default SECRET_KEY_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "server-addr"
|
||||
* The property of "server-addr".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #SERVER_ADDR_PLACEHOLDER
|
||||
@ -218,7 +226,7 @@ public @interface NacosProperties {
|
||||
String serverAddr() default SERVER_ADDR_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "context-path"
|
||||
* The property of "context-path".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #CONTEXT_PATH_PLACEHOLDER
|
||||
@ -226,7 +234,7 @@ public @interface NacosProperties {
|
||||
String contextPath() default CONTEXT_PATH_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "cluster-name"
|
||||
* The property of "cluster-name".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #CLUSTER_NAME_PLACEHOLDER
|
||||
@ -234,7 +242,7 @@ public @interface NacosProperties {
|
||||
String clusterName() default CLUSTER_NAME_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "encode"
|
||||
* The property of "encode".
|
||||
*
|
||||
* @return "UTF-8" as default value
|
||||
* @see #ENCODE_PLACEHOLDER
|
||||
@ -242,7 +250,7 @@ public @interface NacosProperties {
|
||||
String encode() default ENCODE_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "configLongPollTimeout"
|
||||
* The property of "configLongPollTimeout".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER
|
||||
@ -250,7 +258,7 @@ public @interface NacosProperties {
|
||||
String configLongPollTimeout() default CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "configRetryTime"
|
||||
* The property of "configRetryTime".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #CONFIG_RETRY_TIME_PLACEHOLDER
|
||||
@ -258,7 +266,7 @@ public @interface NacosProperties {
|
||||
String configRetryTime() default CONFIG_RETRY_TIME_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "maxRetry"
|
||||
* The property of "maxRetry".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #MAX_RETRY
|
||||
@ -266,7 +274,7 @@ public @interface NacosProperties {
|
||||
String maxRetry() default MAX_RETRY_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "enableRemoteSyncConfig"
|
||||
* The property of "enableRemoteSyncConfig".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #ENABLE_REMOTE_SYNC_CONFIG
|
||||
@ -274,7 +282,7 @@ public @interface NacosProperties {
|
||||
String enableRemoteSyncConfig() default ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "username"
|
||||
* The property of "username".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #USERNAME_PLACEHOLDER
|
||||
@ -282,7 +290,7 @@ public @interface NacosProperties {
|
||||
String username() default USERNAME_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "password"
|
||||
* The property of "password".
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #PASSWORD_PLACEHOLDER
|
||||
|
@ -13,18 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.pojo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CMDB entity.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public class Entity {
|
||||
|
||||
private String type;
|
||||
|
||||
private String name;
|
||||
|
||||
private Map<String, String> labels;
|
||||
|
||||
public String getType() {
|
||||
|
@ -13,16 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.pojo;
|
||||
|
||||
/**
|
||||
* CMDB entity event.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public class EntityEvent {
|
||||
|
||||
private EntityEventType type;
|
||||
|
||||
private String entityName;
|
||||
|
||||
private String entityType;
|
||||
|
||||
public EntityEventType getType() {
|
||||
|
@ -13,19 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.pojo;
|
||||
|
||||
/**
|
||||
* CMDB entity event type.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public enum EntityEventType {
|
||||
|
||||
/**
|
||||
*
|
||||
* Add or update entity.
|
||||
*/
|
||||
ENTITY_ADD_OR_UPDATE,
|
||||
/**
|
||||
*
|
||||
* Remove entity.
|
||||
*/
|
||||
ENTITY_REMOVE
|
||||
}
|
||||
|
@ -13,18 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.pojo;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* CMDB lable.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public class Label {
|
||||
|
||||
private String name;
|
||||
|
||||
private Set<String> values;
|
||||
|
||||
private String description;
|
||||
|
||||
public String getName() {
|
||||
|
@ -13,19 +13,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.pojo;
|
||||
|
||||
/**
|
||||
* CMDB preserverd entity type.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public enum PreservedEntityTypes {
|
||||
/**
|
||||
* Ip
|
||||
* Ip.
|
||||
*/
|
||||
ip,
|
||||
/**
|
||||
* Service
|
||||
* Service.
|
||||
*/
|
||||
service
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.cmdb.spi;
|
||||
|
||||
import com.alibaba.nacos.api.cmdb.pojo.Entity;
|
||||
@ -24,7 +25,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Service to visit CMDB store
|
||||
* Service to visit CMDB store.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
@ -32,21 +33,21 @@ import java.util.Set;
|
||||
public interface CmdbService {
|
||||
|
||||
/**
|
||||
* Get all label names stored in CMDB
|
||||
* Get all label names stored in CMDB.
|
||||
*
|
||||
* @return label name set
|
||||
*/
|
||||
Set<String> getLabelNames();
|
||||
|
||||
/**
|
||||
* Get all possible entity types in CMDB
|
||||
* Get all possible entity types in CMDB.
|
||||
*
|
||||
* @return all entity types
|
||||
*/
|
||||
Set<String> getEntityTypes();
|
||||
|
||||
/**
|
||||
* Get label info
|
||||
* Get label info.
|
||||
*
|
||||
* @param labelName label name
|
||||
* @return label info
|
||||
@ -54,33 +55,33 @@ public interface CmdbService {
|
||||
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 entityType entity type
|
||||
* @param labelName target label name
|
||||
* @param entityType entity type
|
||||
* @param labelName target label name
|
||||
* @return label value
|
||||
*/
|
||||
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 entityType entity type
|
||||
* @param entityType entity type
|
||||
* @return all label values
|
||||
*/
|
||||
Map<String, String> getLabelValues(String entityName, String entityType);
|
||||
|
||||
/**
|
||||
* Dump all entities in CMDB
|
||||
* Dump all entities in CMDB.
|
||||
*
|
||||
* @return all entities
|
||||
*/
|
||||
Map<String, Map<String, Entity>> getAllEntities();
|
||||
|
||||
/**
|
||||
* get label change events
|
||||
* get label change events.
|
||||
*
|
||||
* @param timestamp start time of generated events
|
||||
* @return label events
|
||||
@ -88,7 +89,7 @@ public interface CmdbService {
|
||||
List<EntityEvent> getEntityEvents(long timestamp);
|
||||
|
||||
/**
|
||||
* Get single entity
|
||||
* Get single entity.
|
||||
*
|
||||
* @param entityName name of entity
|
||||
* @param entityType type of entity
|
||||
|
@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.common;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Constant
|
||||
* Constants.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
@ -26,7 +27,7 @@ public class Constants {
|
||||
|
||||
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";
|
||||
|
||||
@ -83,47 +84,47 @@ public class Constants {
|
||||
public static final String TOKEN_REFRESH_WINDOW = "tokenRefreshWindow";
|
||||
|
||||
/**
|
||||
* second
|
||||
* second.
|
||||
*/
|
||||
public static final int ASYNC_UPDATE_ADDRESS_INTERVAL = 300;
|
||||
|
||||
/**
|
||||
* second
|
||||
* second.
|
||||
*/
|
||||
public static final int POLLING_INTERVAL_TIME = 15;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int ONCE_TIMEOUT = 2000;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int SO_TIMEOUT = 60000;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int CONFIG_LONG_POLL_TIMEOUT = 30000;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int MIN_CONFIG_LONG_POLL_TIMEOUT = 10000;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int CONFIG_RETRY_TIME = 2000;
|
||||
|
||||
/**
|
||||
* Maximum number of retries
|
||||
* Maximum number of retries.
|
||||
*/
|
||||
public static final int MAX_RETRY = 3;
|
||||
|
||||
/**
|
||||
* millisecond
|
||||
* millisecond.
|
||||
*/
|
||||
public static final int RECV_WAIT_TIMEOUT = ONCE_TIMEOUT * 5;
|
||||
|
||||
@ -146,13 +147,17 @@ public class Constants {
|
||||
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";
|
||||
|
||||
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_TOKEN_HEADER = "Client-RequestToken";
|
||||
|
||||
public static final int ATOMIC_MAX_SIZE = 1000;
|
||||
|
||||
public static final String NAMING_INSTANCE_ID_SPLITTER = "#";
|
||||
|
||||
public static final int NAMING_INSTANCE_ID_SEG_COUNT = 4;
|
||||
|
||||
public static final String NAMING_HTTP_HEADER_SPILIER = "\\|";
|
||||
|
||||
public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";
|
||||
|
@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.nacos.api.common;
|
||||
|
||||
package com.alibaba.nacos.api.common;
|
||||
|
||||
/**
|
||||
* Response code definitions.
|
||||
* <p>
|
||||
* This class and inherited classes define codes separated from HTTP code to provide richer and preciser
|
||||
* information of the API results. A recommended rule for defining response code is:
|
||||
*
|
||||
* <p>This class and inherited classes define codes separated from HTTP code to provide richer and preciser information of
|
||||
* the API results. A recommended rule for defining response code is:
|
||||
* <li> Global and common code starts with 10001.
|
||||
* <li> Naming module code starts with 20001.
|
||||
* <li> Config module code starts with 30001.
|
||||
@ -31,7 +31,7 @@ package com.alibaba.nacos.api.common;
|
||||
public class ResponseCode {
|
||||
|
||||
/**
|
||||
* Everything normal
|
||||
* Everything normal.
|
||||
*/
|
||||
public static final int OK = 10200;
|
||||
}
|
||||
|
@ -13,20 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* 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.Map;
|
||||
|
||||
/**
|
||||
* ConfigChangeEvent
|
||||
* ConfigChangeEvent.
|
||||
*
|
||||
* @author rushsky518
|
||||
*/
|
||||
public class ConfigChangeEvent {
|
||||
private Map<String, ConfigChangeItem> data;
|
||||
|
||||
private final Map<String, ConfigChangeItem> data;
|
||||
|
||||
public ConfigChangeEvent(Map<String, ConfigChangeItem> data) {
|
||||
this.data = data;
|
||||
|
@ -13,16 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
/**
|
||||
* ConfigChangeItem
|
||||
* ConfigChangeItem.
|
||||
*
|
||||
* @author rushsky518
|
||||
*/
|
||||
public class ConfigChangeItem {
|
||||
|
||||
private String key;
|
||||
|
||||
private String oldValue;
|
||||
|
||||
private String newValue;
|
||||
|
||||
private PropertyChangeType type;
|
||||
@ -67,11 +71,7 @@ public class ConfigChangeItem {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigChangeItem{" +
|
||||
"key='" + key + '\'' +
|
||||
", oldValue='" + oldValue + '\'' +
|
||||
", newValue='" + newValue + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
return "ConfigChangeItem{" + "key='" + key + '\'' + ", oldValue='" + oldValue + '\'' + ", newValue='" + newValue
|
||||
+ '\'' + ", type=" + type + '}';
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Properties;
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Config Factory
|
||||
* Config Factory.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public class ConfigFactory {
|
||||
|
||||
/**
|
||||
* Create Config
|
||||
* Create Config.
|
||||
*
|
||||
* @param properties init param
|
||||
* @return ConfigService
|
||||
@ -47,7 +48,7 @@ public class ConfigFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Config
|
||||
* Create Config.
|
||||
*
|
||||
* @param serverAddr serverList
|
||||
* @return Config
|
||||
|
@ -13,20 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
import com.alibaba.nacos.api.config.listener.Listener;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
/**
|
||||
* Config Service Interface
|
||||
* Config Service Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface ConfigService {
|
||||
|
||||
/**
|
||||
* Get config
|
||||
* Get config.
|
||||
*
|
||||
* @param dataId dataId
|
||||
* @param group group
|
||||
@ -37,29 +38,28 @@ public interface ConfigService {
|
||||
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,
|
||||
* and the registered Listener is used for future configuration updates, you can keep the original
|
||||
* code unchanged, just add the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead);
|
||||
* therefore we recommend that you use this interface directly
|
||||
* <p>If you want to pull it yourself when the program starts to get the configuration for the first time, and the
|
||||
* registered Listener is used for future configuration updates, you can keep the original code unchanged, just add
|
||||
* the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead); therefore we recommend
|
||||
* that you use this interface directly
|
||||
*
|
||||
* @param dataId dataId
|
||||
* @param group group
|
||||
* @param timeoutMs read timeout
|
||||
* @param listener {@link Listener}
|
||||
* @param listener {@link Listener}
|
||||
* @return config value
|
||||
* @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
|
||||
* configuration, the client will use the incoming listener callback.
|
||||
* Recommended asynchronous processing, the application can implement the
|
||||
* getExecutor method in the ManagerListener, provide a thread pool of
|
||||
* execution. If provided, use the main thread callback, May block other
|
||||
* configurations or be blocked by other configurations.
|
||||
* Add a listener to the configuration, after the server modified the configuration, the client will use the
|
||||
* incoming listener callback. Recommended asynchronous processing, the application can implement the getExecutor
|
||||
* method in the ManagerListener, provide a thread pool of execution. If provided, use the main thread callback, May
|
||||
* block other configurations or be blocked by other configurations.
|
||||
*
|
||||
* @param dataId dataId
|
||||
* @param group group
|
||||
@ -80,7 +80,7 @@ public interface ConfigService {
|
||||
boolean publishConfig(String dataId, String group, String content) throws NacosException;
|
||||
|
||||
/**
|
||||
* Remove config
|
||||
* Remove config.
|
||||
*
|
||||
* @param dataId dataId
|
||||
* @param group group
|
||||
@ -90,7 +90,7 @@ public interface ConfigService {
|
||||
boolean removeConfig(String dataId, String group) throws NacosException;
|
||||
|
||||
/**
|
||||
* Remove listener
|
||||
* Remove listener.
|
||||
*
|
||||
* @param dataId dataId
|
||||
* @param group group
|
||||
@ -99,14 +99,14 @@ public interface ConfigService {
|
||||
void removeListener(String dataId, String group, Listener listener);
|
||||
|
||||
/**
|
||||
* Get server status
|
||||
* Get server status.
|
||||
*
|
||||
* @return whether health
|
||||
*/
|
||||
String getServerStatus();
|
||||
|
||||
/**
|
||||
* Shutdown the resource service
|
||||
* Shutdown the resource service.
|
||||
*
|
||||
* @throws NacosException exception.
|
||||
*/
|
||||
|
@ -17,38 +17,39 @@
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
/**
|
||||
* Config data type.
|
||||
*
|
||||
* @author liaochuntao
|
||||
* @date 2019-06-14 21:12
|
||||
**/
|
||||
public enum ConfigType {
|
||||
|
||||
/**
|
||||
* config type is "properties"
|
||||
* config type is "properties".
|
||||
*/
|
||||
PROPERTIES("properties"),
|
||||
|
||||
/**
|
||||
* config type is "xml"
|
||||
* config type is "xml".
|
||||
*/
|
||||
XML("xml"),
|
||||
|
||||
/**
|
||||
* config type is "json"
|
||||
* config type is "json".
|
||||
*/
|
||||
JSON("json"),
|
||||
|
||||
/**
|
||||
* config type is "text"
|
||||
* config type is "text".
|
||||
*/
|
||||
TEXT("text"),
|
||||
|
||||
/**
|
||||
* config type is "html"
|
||||
* config type is "html".
|
||||
*/
|
||||
HTML("html"),
|
||||
|
||||
/**
|
||||
* config type is "yaml"
|
||||
* config type is "yaml".
|
||||
*/
|
||||
YAML("yaml");
|
||||
|
||||
|
@ -13,18 +13,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config;
|
||||
|
||||
/**
|
||||
* Property Change Type
|
||||
* Property Change Type.
|
||||
*
|
||||
* @author rushsky518
|
||||
*/
|
||||
public enum PropertyChangeType {
|
||||
/** add */
|
||||
/**
|
||||
* add.
|
||||
*/
|
||||
ADDED,
|
||||
/** modified */
|
||||
/**
|
||||
* modified.
|
||||
*/
|
||||
MODIFIED,
|
||||
/** deleted */
|
||||
/**
|
||||
* deleted.
|
||||
*/
|
||||
DELETED
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.annotation;
|
||||
|
||||
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.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;
|
||||
|
||||
@ -36,21 +41,21 @@ import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||
public @interface NacosConfigListener {
|
||||
|
||||
/**
|
||||
* Nacos Group ID
|
||||
* Nacos Group ID.
|
||||
*
|
||||
* @return default value {@link Constants#DEFAULT_GROUP};
|
||||
*/
|
||||
String groupId() default DEFAULT_GROUP;
|
||||
|
||||
/**
|
||||
* Nacos Data ID
|
||||
* Nacos Data ID.
|
||||
*
|
||||
* @return required value.
|
||||
*/
|
||||
String dataId();
|
||||
|
||||
/**
|
||||
* Nacos Config type
|
||||
* Nacos Config type.
|
||||
*
|
||||
* @return "properties"
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.annotation;
|
||||
|
||||
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.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;
|
||||
|
||||
@ -37,37 +42,35 @@ import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||
public @interface NacosConfigurationProperties {
|
||||
|
||||
/**
|
||||
* config prefix name
|
||||
* config prefix name.
|
||||
*
|
||||
* @return default value is <code>""</code>
|
||||
*/
|
||||
String prefix() default "";
|
||||
|
||||
/**
|
||||
* Nacos Group ID
|
||||
* Nacos Group ID.
|
||||
*
|
||||
* @return default value {@link Constants#DEFAULT_GROUP};
|
||||
*/
|
||||
String groupId() default DEFAULT_GROUP;
|
||||
|
||||
/**
|
||||
* Nacos Data ID
|
||||
* Nacos Data ID.
|
||||
*
|
||||
* @return required value.
|
||||
*/
|
||||
String dataId();
|
||||
|
||||
/**
|
||||
* set config type is yaml
|
||||
* this method is deprecated, we support you use {@link #type()} to set config type
|
||||
* set config type is yaml this method is deprecated, we support you use {@link #type()} to set config type.
|
||||
*
|
||||
* @return default value <code>false</code>
|
||||
*/
|
||||
@Deprecated
|
||||
boolean yaml() default false;
|
||||
@Deprecated boolean yaml() default false;
|
||||
|
||||
/**
|
||||
* config style
|
||||
* config style.
|
||||
*
|
||||
* @return default value is {@link ConfigType#PROPERTIES}
|
||||
*/
|
||||
|
@ -13,9 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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.
|
||||
@ -29,4 +34,5 @@ import java.lang.annotation.*;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface NacosIgnore {
|
||||
|
||||
}
|
||||
|
@ -13,9 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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
|
||||
@ -32,7 +37,7 @@ import java.lang.annotation.*;
|
||||
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
|
||||
*/
|
||||
|
@ -13,12 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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>
|
||||
* @since 0.2.0
|
||||
|
@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.convert;
|
||||
|
||||
/**
|
||||
* Nacos Config Converter
|
||||
* Nacos Config Converter.
|
||||
*
|
||||
* @param <T> the target type that wanted
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
@ -25,7 +26,7 @@ package com.alibaba.nacos.api.config.convert;
|
||||
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
|
||||
* @return If can , return <code>true</code>, or <code>false</code>
|
||||
|
@ -13,24 +13,26 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
/**
|
||||
* Config Context Interface
|
||||
* Config Context Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IConfigContext {
|
||||
|
||||
/**
|
||||
* Get context param by key
|
||||
* Get context param by key.
|
||||
*
|
||||
* @param key
|
||||
* @param key parameter key
|
||||
* @return context
|
||||
*/
|
||||
Object getParameter(String key);
|
||||
|
||||
/**
|
||||
* Set context param
|
||||
* Set context param.
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
|
@ -13,25 +13,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
/**
|
||||
* Config Filter Interface
|
||||
* Config Filter Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IConfigFilter {
|
||||
|
||||
/**
|
||||
* Init
|
||||
* Init.
|
||||
*
|
||||
* @param filterConfig Filter Config
|
||||
*/
|
||||
void init(IFilterConfig filterConfig);
|
||||
|
||||
/**
|
||||
* do filter
|
||||
* do filter.
|
||||
*
|
||||
* @param request request
|
||||
* @param response response
|
||||
@ -42,19 +44,19 @@ public interface IConfigFilter {
|
||||
throws NacosException;
|
||||
|
||||
/**
|
||||
* deploy
|
||||
* deploy.
|
||||
*/
|
||||
void deploy();
|
||||
|
||||
/**
|
||||
* Get order
|
||||
* Get order.
|
||||
*
|
||||
* @return order number
|
||||
*/
|
||||
int getOrder();
|
||||
|
||||
/**
|
||||
* Get filterName
|
||||
* Get filterName.
|
||||
*
|
||||
* @return filter name
|
||||
*/
|
||||
|
@ -13,18 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
/**
|
||||
* Config Filter Chain Interface
|
||||
* Config Filter Chain Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IConfigFilterChain {
|
||||
|
||||
/**
|
||||
* Filter aciton
|
||||
* Filter action.
|
||||
*
|
||||
* @param request request
|
||||
* @param response response
|
||||
|
@ -13,16 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
/**
|
||||
* Config Request Interface
|
||||
* Config Request Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IConfigRequest {
|
||||
|
||||
/**
|
||||
* get param
|
||||
* get param.
|
||||
*
|
||||
* @param key key
|
||||
* @return value
|
||||
@ -30,9 +32,9 @@ public interface IConfigRequest {
|
||||
Object getParameter(String key);
|
||||
|
||||
/**
|
||||
* get config context
|
||||
* get config context.
|
||||
*
|
||||
* @return
|
||||
* @return {@link IConfigContext}
|
||||
*/
|
||||
IConfigContext getConfigContext();
|
||||
|
||||
|
@ -13,16 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
/**
|
||||
* Config Response Interface
|
||||
* Config Response Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IConfigResponse {
|
||||
|
||||
/**
|
||||
* get param
|
||||
* get param.
|
||||
*
|
||||
* @param key key
|
||||
* @return value
|
||||
@ -30,7 +32,7 @@ public interface IConfigResponse {
|
||||
Object getParameter(String key);
|
||||
|
||||
/**
|
||||
* Get config context
|
||||
* Get config context.
|
||||
*
|
||||
* @return configContext
|
||||
*/
|
||||
|
@ -13,26 +13,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.filter;
|
||||
|
||||
/**
|
||||
* Filter Config Interface
|
||||
* Filter Config Interface.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface IFilterConfig {
|
||||
|
||||
/**
|
||||
* get filter name
|
||||
* get filter name.
|
||||
*
|
||||
* @return
|
||||
* @return filter name
|
||||
*/
|
||||
String getFilterName();
|
||||
|
||||
/**
|
||||
* Get init param
|
||||
* Get init param.
|
||||
*
|
||||
* @param name
|
||||
* @param name parameter name
|
||||
* @return param
|
||||
*/
|
||||
Object getInitParameter(String name);
|
||||
|
@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.listener;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Listener Adapter,use default notify thread
|
||||
* Listener Adapter,use default notify thread.
|
||||
*
|
||||
* @author water.lyl
|
||||
*/
|
||||
@ -26,7 +27,7 @@ import java.util.concurrent.Executor;
|
||||
public abstract class AbstractListener implements Listener {
|
||||
|
||||
/**
|
||||
* Use default executor
|
||||
* Use default executor.
|
||||
*/
|
||||
@Override
|
||||
public Executor getExecutor() {
|
||||
|
@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.listener;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Shared Listener
|
||||
* Shared Listener.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
@ -26,6 +27,7 @@ import java.util.concurrent.Executor;
|
||||
public abstract class AbstractSharedListener implements Listener {
|
||||
|
||||
private volatile String dataId;
|
||||
|
||||
private volatile String group;
|
||||
|
||||
public final void fillContext(String dataId, String group) {
|
||||
@ -44,7 +46,7 @@ public abstract class AbstractSharedListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* receive
|
||||
* receive.
|
||||
*
|
||||
* @param dataId data ID
|
||||
* @param group group
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.listener;
|
||||
|
||||
import com.alibaba.nacos.api.config.ConfigChangeItem;
|
||||
@ -21,25 +22,28 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ConfigChangeParser
|
||||
* ConfigChangeParser.
|
||||
*
|
||||
* @author rushsky518
|
||||
*/
|
||||
public interface ConfigChangeParser {
|
||||
|
||||
/**
|
||||
* judge type
|
||||
* @param type
|
||||
* @return
|
||||
* Judge type.
|
||||
*
|
||||
* @param type data type
|
||||
* @return true if is responsible type, otherwise false
|
||||
*/
|
||||
boolean isResponsibleFor(String type);
|
||||
|
||||
/**
|
||||
* compare old and new data
|
||||
* @param oldContent
|
||||
* @param newContent
|
||||
* @param type
|
||||
* @return
|
||||
* @throws IOException
|
||||
* Compare old and new data.
|
||||
*
|
||||
* @param oldContent old content
|
||||
* @param newContent new content
|
||||
* @param type data type
|
||||
* @return key and change item map
|
||||
* @throws IOException io exception
|
||||
*/
|
||||
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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.config.listener;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Listener for watch config
|
||||
* Listener for watch config.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Get executor for execute this receive
|
||||
* Get executor for execute this receive.
|
||||
*
|
||||
* @return Executor
|
||||
*/
|
||||
Executor getExecutor();
|
||||
|
||||
/**
|
||||
* Receive config info
|
||||
* Receive config info.
|
||||
*
|
||||
* @param configInfo config info
|
||||
*/
|
||||
|
@ -61,10 +61,6 @@ public class NacosDeserializationException extends NacosRuntimeException {
|
||||
super(ERROR_CODE, String.format(MSG_FOR_SPECIFIED_CLASS, targetType.toString()), throwable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Class<?> getTargetClass() {
|
||||
return targetClass;
|
||||
}
|
||||
|
@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming;
|
||||
|
||||
/**
|
||||
* Common parameters for service discovery
|
||||
* Common parameters for service discovery.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 1.0.0
|
||||
|
@ -13,36 +13,51 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
/**
|
||||
* Naming Factory
|
||||
* Naming Factory.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
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 {
|
||||
try {
|
||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
||||
Constructor constructor = driverImplClass.getConstructor(String.class);
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(serverList);
|
||||
NamingService vendorImpl = (NamingService) constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable 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 {
|
||||
try {
|
||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingService");
|
||||
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(properties);
|
||||
NamingService vendorImpl = (NamingService) constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
|
@ -22,27 +22,43 @@ import java.lang.reflect.Constructor;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Maintain service factory.
|
||||
*
|
||||
* @author liaochuntao
|
||||
* @since 1.0.1
|
||||
*/
|
||||
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 {
|
||||
try {
|
||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
||||
Constructor constructor = driverImplClass.getConstructor(String.class);
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(serverList);
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService) constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable 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 {
|
||||
try {
|
||||
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.naming.NacosNamingMaintainService");
|
||||
Constructor constructor = driverImplClass.getConstructor(Properties.class);
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(properties);
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService) constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
|
@ -24,7 +24,7 @@ import com.alibaba.nacos.api.selector.AbstractSelector;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Operations related to Nacos
|
||||
* Operations related to Nacos.
|
||||
*
|
||||
* @author liaochuntao
|
||||
* @since 1.0.1
|
||||
@ -32,136 +32,138 @@ import java.util.Map;
|
||||
public interface NamingMaintainService {
|
||||
|
||||
/**
|
||||
* update instance info
|
||||
* update instance info.
|
||||
*
|
||||
* @param serviceName
|
||||
* @param instance
|
||||
* @throws NacosException
|
||||
* @param serviceName service name
|
||||
* @param instance instance
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void updateInstance(String serviceName, Instance instance) throws NacosException;
|
||||
|
||||
/**
|
||||
* update instance info
|
||||
* update instance info.
|
||||
*
|
||||
* @param serviceName
|
||||
* @param groupName
|
||||
* @param instance
|
||||
* @throws NacosException
|
||||
* @param serviceName service name
|
||||
* @param groupName group name
|
||||
* @param instance instance
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void updateInstance(String serviceName, String groupName, Instance instance) throws NacosException;
|
||||
|
||||
/**
|
||||
* query service
|
||||
* query service.
|
||||
*
|
||||
* @param serviceName
|
||||
* @return
|
||||
* @throws NacosException
|
||||
* @param serviceName service name
|
||||
* @return service
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
Service queryService(String serviceName) throws NacosException;
|
||||
|
||||
/**
|
||||
* query service
|
||||
* query service.
|
||||
*
|
||||
* @param serviceName
|
||||
* @param groupName
|
||||
* @return
|
||||
* @throws NacosException
|
||||
* @param serviceName service name
|
||||
* @param groupName group name
|
||||
* @return service
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
Service queryService(String serviceName, String groupName) throws NacosException;
|
||||
|
||||
/**
|
||||
* create service to Nacos
|
||||
* create service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void createService(String serviceName) throws NacosException;
|
||||
|
||||
/**
|
||||
* create service to Nacos
|
||||
* create service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void createService(String serviceName, String groupName) throws NacosException;
|
||||
|
||||
/**
|
||||
* create service to Nacos
|
||||
* create service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @throws NacosException
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void createService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
||||
|
||||
/**
|
||||
* create service to Nacos
|
||||
* create service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @param expression expression of selector
|
||||
* @throws NacosException
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @param expression expression of selector
|
||||
* @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 selector selector
|
||||
* @throws NacosException
|
||||
* @param service name of service
|
||||
* @param selector selector
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void createService(Service service, AbstractSelector selector) throws NacosException;
|
||||
|
||||
/**
|
||||
* delete service from Nacos
|
||||
* delete service from Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @return if delete service success return true
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
boolean deleteService(String serviceName) throws NacosException;
|
||||
|
||||
/**
|
||||
* delete service from Nacos
|
||||
* delete service from Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @return if delete service success return true
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
boolean deleteService(String serviceName, String groupName) throws NacosException;
|
||||
|
||||
/**
|
||||
* update service to Nacos
|
||||
* update service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @throws NacosException
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void updateService(String serviceName, String groupName, float protectThreshold) throws NacosException;
|
||||
|
||||
/**
|
||||
* update service to Nacos
|
||||
* update service to Nacos.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @param metadata metadata of service
|
||||
* @throws NacosException
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param protectThreshold protectThreshold of service
|
||||
* @param metadata metadata of service
|
||||
* @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 selector {@link AbstractSelector} pojo of selector
|
||||
* @throws NacosException
|
||||
* @param service {@link Service} pojo of service
|
||||
* @param selector {@link AbstractSelector} pojo of selector
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void updateService(Service service, AbstractSelector selector) throws NacosException;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming;
|
||||
|
||||
import com.alibaba.nacos.api.common.ResponseCode;
|
||||
@ -20,7 +21,7 @@ import com.alibaba.nacos.api.common.ResponseCode;
|
||||
/**
|
||||
* Business response code of naming module
|
||||
*
|
||||
* Every code stays between 20001 to 29999.
|
||||
* <p>Every code stays between 20001 to 29999.
|
||||
*
|
||||
* @author nkorange
|
||||
* @author 1.2.0
|
||||
@ -28,7 +29,7 @@ import com.alibaba.nacos.api.common.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;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
@ -25,302 +26,309 @@ import com.alibaba.nacos.api.selector.AbstractSelector;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Naming Service
|
||||
* Naming Service.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public interface NamingService {
|
||||
|
||||
/**
|
||||
* register a instance to service
|
||||
* register a instance to service.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param ip instance ip
|
||||
* @param port instance port
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param ip instance ip
|
||||
* @param port instance port
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 ip instance ip
|
||||
* @param port instance port
|
||||
* @param clusterName instance cluster name
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param ip instance ip
|
||||
* @param port instance port
|
||||
* @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 instance instance to register
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param instance instance to register
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 ip instance ip
|
||||
* @param port instance port
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param ip instance ip
|
||||
* @param port instance port
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 ip instance ip
|
||||
* @param port instance port
|
||||
* @param clusterName instance cluster name
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param ip instance ip
|
||||
* @param port instance port
|
||||
* @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
|
||||
* @param serviceName
|
||||
* @param instance
|
||||
* @throws NacosException
|
||||
* deregister instance with full instance information and default groupName.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param instance instance
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param instance instance information
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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
|
||||
* @return A list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @return A list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 subscribe if subscribe the service
|
||||
* @return A list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param subscribe if subscribe the service
|
||||
* @return A list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 clusters list of cluster
|
||||
* @return A list of qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters list of cluster
|
||||
* @return A list of qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 clusters list of cluster
|
||||
* @param subscribe if subscribe the service
|
||||
* @return A list of qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters list of cluster
|
||||
* @param subscribe if subscribe the service
|
||||
* @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
|
||||
* @return A qualified list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @return A qualified list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @param subscribe if subscribe the service
|
||||
* @return A qualified list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @param subscribe if subscribe the service
|
||||
* @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 clusters list of cluster
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @return A qualified list of instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters list of cluster
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @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 clusters list of cluster
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @param subscribe if subscribe the service
|
||||
* @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 groupName group of service
|
||||
@ -328,229 +336,236 @@ public interface NamingService {
|
||||
* @param healthy a flag to indicate returning healthy or unhealthy instances
|
||||
* @param subscribe if subscribe the service
|
||||
* @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
|
||||
* @return qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @return qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 subscribe if subscribe the service
|
||||
* @return qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param subscribe if subscribe the service
|
||||
* @return qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 clusters a list of clusters should the instance belongs to
|
||||
* @return qualified instance
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters a list of clusters should the instance belongs to
|
||||
* @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 clusters a list of clusters should the instance belongs to
|
||||
* @param subscribe if subscribe the service
|
||||
* @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 groupName group of service
|
||||
* @param clusters a list of clusters should the instance belongs to
|
||||
* @param subscribe if subscribe the service
|
||||
* @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 listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 clusters list of cluster
|
||||
* @param listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters list of cluster
|
||||
* @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 listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
void unsubscribe(String serviceName, EventListener listener) throws NacosException;
|
||||
|
||||
/**
|
||||
* unsubscribe event listener of service
|
||||
* unsubscribe event listener of service.
|
||||
*
|
||||
* @param serviceName name of service
|
||||
* @param groupName group of service
|
||||
* @param listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 clusters list of cluster
|
||||
* @param listener event listener
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 groupName group of service
|
||||
* @param clusters list of cluster
|
||||
* @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 pageSize page size
|
||||
* @return list of service names
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 pageSize page size
|
||||
* @param groupName group name
|
||||
* @return list of service names
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
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 pageSize page size
|
||||
* @param selector selector to filter the resource
|
||||
* @return list of service names
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
* @since 0.7.0
|
||||
*/
|
||||
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 pageSize page size
|
||||
* @param groupName group name
|
||||
* @param selector selector to filter the resource
|
||||
* @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
|
||||
* @throws NacosException
|
||||
* @throws NacosException nacos exception
|
||||
*/
|
||||
List<ServiceInfo> getSubscribeServices() throws NacosException;
|
||||
|
||||
/**
|
||||
* get server health status
|
||||
* get server health status.
|
||||
*
|
||||
* @return is server healthy
|
||||
*/
|
||||
|
@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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
|
||||
* @since 1.0.0
|
||||
|
@ -13,12 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.listener;
|
||||
|
||||
/**
|
||||
* Event Interface
|
||||
* Event Interface.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public interface Event {
|
||||
|
||||
}
|
||||
|
@ -13,18 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.listener;
|
||||
|
||||
/**
|
||||
* Event Listener
|
||||
* Event Listener.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
public interface EventListener {
|
||||
|
||||
/**
|
||||
* callback event
|
||||
* callback event.
|
||||
*
|
||||
* @param event
|
||||
* @param event event
|
||||
*/
|
||||
void onEvent(Event event);
|
||||
}
|
||||
|
@ -13,14 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* 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 java.util.List;
|
||||
|
||||
/**
|
||||
* Naming Event
|
||||
* Naming Event.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
|
@ -13,33 +13,38 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker;
|
||||
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
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:abbreviationaswordinname")
|
||||
public class Cluster {
|
||||
|
||||
/**
|
||||
* Name of belonging service
|
||||
* Name of belonging service.
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* Name of cluster
|
||||
* Name of cluster.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Health check config of this cluster
|
||||
* Health check config of this cluster.
|
||||
*/
|
||||
private AbstractHealthChecker healthChecker = new Tcp();
|
||||
|
||||
|
@ -182,10 +182,10 @@ public class Instance {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Instance{" + "instanceId='" + instanceId + '\'' + ", ip='" + ip + '\'' + ", port=" + port
|
||||
+ ", weight=" + weight + ", healthy=" + healthy + ", enabled=" + enabled + ", ephemeral="
|
||||
+ ephemeral + ", clusterName='" + clusterName + '\'' + ", serviceName='" + serviceName
|
||||
+ '\'' + ", metadata=" + metadata + '}';
|
||||
return "Instance{" + "instanceId='" + instanceId + '\'' + ", ip='" + ip + '\'' + ", port=" + port + ", weight="
|
||||
+ weight + ", healthy=" + healthy + ", enabled=" + enabled + ", ephemeral=" + ephemeral
|
||||
+ ", clusterName='" + clusterName + '\'' + ", serviceName='" + serviceName + '\'' + ", metadata="
|
||||
+ metadata + '}';
|
||||
}
|
||||
|
||||
public String toInetAddr() {
|
||||
|
@ -13,18 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ListView
|
||||
* ListView.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public class ListView<T> {
|
||||
|
||||
private List<T> data;
|
||||
|
||||
private int count;
|
||||
|
||||
public List<T> getData() {
|
||||
@ -45,9 +47,6 @@ public class ListView<T> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListView{" +
|
||||
"data=" + data +
|
||||
", count=" + count +
|
||||
'}';
|
||||
return "ListView{" + "data=" + data + ", count=" + count + '}';
|
||||
}
|
||||
}
|
||||
|
@ -13,34 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Service of Nacos
|
||||
* <p>
|
||||
* We introduce a 'service --> cluster --> instance' model, in which service stores a list of clusters,
|
||||
* which contains a list of instances.
|
||||
* <p>
|
||||
* Typically we put some unique properties between instances to service level.
|
||||
* Service of Nacos.
|
||||
*
|
||||
* <p>We introduce a 'service --> cluster --> instance' model, in which service stores a list of clusters, which contains a
|
||||
* list of instances.
|
||||
*
|
||||
* <p>Typically we put some unique properties between instances to service level.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public class Service {
|
||||
|
||||
/**
|
||||
* service name
|
||||
* service name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* protect threshold
|
||||
* protect threshold.
|
||||
*/
|
||||
private float protectThreshold = 0.0F;
|
||||
|
||||
/**
|
||||
* application name of this service
|
||||
* application name of this service.
|
||||
*/
|
||||
private String appName;
|
||||
|
||||
@ -104,12 +106,7 @@ public class Service {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Service{" +
|
||||
"name='" + name + '\'' +
|
||||
", protectThreshold=" + protectThreshold +
|
||||
", appName='" + appName + '\'' +
|
||||
", groupName='" + groupName + '\'' +
|
||||
", metadata=" + metadata +
|
||||
'}';
|
||||
return "Service{" + "name='" + name + '\'' + ", protectThreshold=" + protectThreshold + ", appName='" + appName
|
||||
+ '\'' + ", groupName='" + groupName + '\'' + ", metadata=" + metadata + '}';
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
@ -27,7 +28,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ServiceInfo
|
||||
* ServiceInfo.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
@ -146,6 +147,11 @@ public class ServiceInfo {
|
||||
return new ArrayList<Instance>(hosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Judge whether service info is validate.
|
||||
*
|
||||
* @return true if validate, otherwise false
|
||||
*/
|
||||
public boolean validate() {
|
||||
if (isAllIPs()) {
|
||||
return true;
|
||||
@ -179,6 +185,16 @@ public class ServiceInfo {
|
||||
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
|
||||
public String getKeyEncoded() {
|
||||
try {
|
||||
@ -188,11 +204,17 @@ public class ServiceInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link ServiceInfo} from key.
|
||||
*
|
||||
* @param key key of service info
|
||||
* @return new service info
|
||||
*/
|
||||
public static ServiceInfo fromKey(String key) {
|
||||
ServiceInfo serviceInfo = new ServiceInfo();
|
||||
int maxSegCount = 3;
|
||||
String[] segs = key.split(Constants.SERVICE_INFO_SPLITER);
|
||||
if (segs.length == maxSegCount -1) {
|
||||
if (segs.length == maxSegCount - 1) {
|
||||
serviceInfo.setGroupName(segs[0]);
|
||||
serviceInfo.setName(segs[1]);
|
||||
} else if (segs.length == maxSegCount) {
|
||||
@ -203,16 +225,6 @@ public class 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
|
||||
public String toString() {
|
||||
return getKey();
|
||||
@ -230,14 +242,14 @@ public class ServiceInfo {
|
||||
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) {
|
||||
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 ALL_IPS = "000--00-ALL_IPS--00--000";
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
||||
@ -25,15 +26,14 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||
|
||||
/**
|
||||
* Abstract health checker.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
|
||||
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = None.class)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(name = Http.TYPE, value = Http.class),
|
||||
@JsonSubTypes.Type(name = Mysql.TYPE, value = Mysql.class),
|
||||
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class)
|
||||
})
|
||||
@JsonSubTypes({@JsonSubTypes.Type(name = Http.TYPE, value = Http.class),
|
||||
@JsonSubTypes.Type(name = Mysql.TYPE, value = Mysql.class),
|
||||
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class)})
|
||||
public abstract class AbstractHealthChecker implements Cloneable {
|
||||
|
||||
@JsonIgnore
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
|
||||
@ -25,57 +26,75 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Health check type.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public enum HealthCheckType {
|
||||
/**
|
||||
* TCP type
|
||||
* TCP type.
|
||||
*/
|
||||
TCP(Tcp.class),
|
||||
/**
|
||||
* HTTP type
|
||||
* HTTP type.
|
||||
*/
|
||||
HTTP(Http.class),
|
||||
/**
|
||||
* MySQL type
|
||||
* MySQL type.
|
||||
*/
|
||||
MYSQL(Mysql.class),
|
||||
/**
|
||||
* No check
|
||||
* No check.
|
||||
*/
|
||||
NONE(AbstractHealthChecker.None.class);
|
||||
|
||||
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>>();
|
||||
|
||||
HealthCheckType(Class<? extends AbstractHealthChecker> 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)) {
|
||||
EXTEND.put(type, healthCheckerClass);
|
||||
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;
|
||||
try {
|
||||
enumType = valueOf(type);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return EXTEND.get(type);
|
||||
}
|
||||
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>>();
|
||||
for(HealthCheckType type : values()){
|
||||
for (HealthCheckType type : values()) {
|
||||
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());
|
||||
}
|
||||
return all;
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker.None;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.NamedType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* health checker factory.
|
||||
*
|
||||
@ -50,9 +50,10 @@ public class HealthCheckerFactory {
|
||||
* Register new sub type of health checker to factory for serialize and deserialize.
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ public class HealthCheckerFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a instance of health checker to json
|
||||
* Serialize a instance of health checker to json.
|
||||
*
|
||||
* @param healthChecker health checker instance
|
||||
* @return son string after serializing
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.selector;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@ -20,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||
|
||||
/**
|
||||
* Abstract selector that only contains a type
|
||||
* Abstract selector that only contains a type.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.selector;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,8 @@
|
||||
package com.alibaba.nacos.api.selector;
|
||||
|
||||
/**
|
||||
* None selector.
|
||||
*
|
||||
* @author liaochuntao
|
||||
* @since 1.0.1
|
||||
*/
|
||||
|
@ -13,25 +13,26 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.selector;
|
||||
|
||||
/**
|
||||
* The types of selector accepted by Nacos
|
||||
* The types of selector accepted by Nacos.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public enum SelectorType {
|
||||
/**
|
||||
* not match any type
|
||||
* not match any type.
|
||||
*/
|
||||
unknown,
|
||||
/**
|
||||
* not filter out any entity
|
||||
* not filter out any entity.
|
||||
*/
|
||||
none,
|
||||
/**
|
||||
* select by label
|
||||
* select by label.
|
||||
*/
|
||||
label
|
||||
}
|
||||
|
@ -13,5 +13,4 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
version=${project.version}
|
||||
|
@ -13,20 +13,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.api.annotation;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
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 {
|
||||
|
||||
@Test
|
||||
@ -68,7 +70,8 @@ public class NacosPropertiesTest {
|
||||
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();
|
||||
environment.setProperty(propertyName, propertyValue);
|
||||
String resolvedValue = environment.resolvePlaceholders(placeholder);
|
||||
|
@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -57,6 +58,7 @@ public class ServiceInfoTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("checkstyle:linelength")
|
||||
public void testDeserialize() throws IOException {
|
||||
String example = "{\"name\":\"testName\",\"clusters\":\"testClusters\",\"cacheMillis\":1000,\"hosts\":[],\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"valid\":true,\"groupName\":\"\"}";
|
||||
ServiceInfo actual = mapper.readValue(example, ServiceInfo.class);
|
||||
|
@ -16,18 +16,18 @@
|
||||
|
||||
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.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AbstractHealthCheckerTest {
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package com.alibaba.nacos.api.naming.pojo.healthcheck;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
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.assertTrue;
|
||||
|
@ -16,18 +16,17 @@
|
||||
|
||||
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.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
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;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class HttpTest {
|
||||
|
||||
|
@ -16,13 +16,12 @@
|
||||
|
||||
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.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
Loading…
Reference in New Issue
Block a user