Skip to content

Commit

Permalink
Merge pull request #1359 from alibaba/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Fury Zhu authored Jun 12, 2019
2 parents 54d58b9 + a60bed8 commit 3af86ae
Show file tree
Hide file tree
Showing 121 changed files with 5,189 additions and 2,249 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
24 changes: 24 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/NacosFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
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.NamingMaintainFactory;
import com.alibaba.nacos.api.naming.NamingMaintainService;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;

Expand Down Expand Up @@ -74,4 +76,26 @@ public static NamingService createNamingService(Properties properties) throws Na
return NamingFactory.createNamingService(properties);
}

/**
* Create maintain service
*
* @param serverAddr
* @return NamingMaintainService
* @throws NacosException Exception
*/
public static NamingMaintainService createMaintainService(String serverAddr) throws NacosException {
return NamingMaintainFactory.createMaintainService(serverAddr);
}

/**
* Create maintain service
*
* @param properties
* @return NamingMaintainService
* @throws NacosException Exception
*/
public static NamingMaintainService createMaintainService(Properties properties) throws NacosException {
return NamingMaintainFactory.createMaintainService(properties);
}

}
12 changes: 12 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
public class PropertyKeyConst {

public final static String IS_USE_CLOUD_NAMESPACE_PARSING = "isUseCloudNamespaceParsing";

public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";

public final static String ENDPOINT = "endpoint";
Expand All @@ -44,12 +46,21 @@ public class PropertyKeyConst {

public final static String ENCODE = "encode";

public final static String CONFIG_LONG_POLL_TIMEOUT = "config.long-poll.timeout";

public final static String CONFIG_RETRY_TIME = "config.retry.time";

public final static String MAX_RETRY = "maxRetry";

public final static String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";

public final static String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";

public final static String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";

/**
* Get the key value of some variable value from the system property
*/
public static class SystemEnv {

public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
Expand All @@ -58,4 +69,5 @@ public static class SystemEnv {

public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
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}
*
* @author pbting
Expand All @@ -27,5 +30,23 @@ public interface SystemPropertyKeyConst {

String NAMING_WEB_CONTEXT = "nacos.naming.web.context";

String NACOS_NAMING_REQUEST_MODULE = "nacos.naming.request.module";
/**
* 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>
*/
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.
*/
String ANS_NAMESPACE = "ans.namespace";

/**
* It is also supported by the -D parameter.
*/
String IS_USE_ENDPOINT_PARSING_RULE = "nacos.use.endpoint.parsing.rule";
}
28 changes: 26 additions & 2 deletions api/src/main/java/com/alibaba/nacos/api/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ public class Constants {
*/
public static final int SO_TIMEOUT = 60000;

/**
* millisecond
*/
public static final int CONFIG_LONG_POLL_TIMEOUT = 30000;

/**
* millisecond
*/
public static final int MIN_CONFIG_LONG_POLL_TIMEOUT = 10000;

/**
* millisecond
*/
public static final int CONFIG_RETRY_TIME = 2000;

/**
* Maximum number of retries
*/
public static final int MAX_RETRY = 3;

/**
* millisecond
*/
Expand All @@ -103,9 +123,11 @@ public class Constants {

public static final int FLOW_CONTROL_INTERVAL = 1000;

public static final String LINE_SEPARATOR = Character.toString((char)1);
public static final float DEFAULT_PROTECT_THRESHOLD = 0.0F;

public static final String WORD_SEPARATOR = Character.toString((char)2);
public static final String LINE_SEPARATOR = Character.toString((char) 1);

public static final String WORD_SEPARATOR = Character.toString((char) 2);

public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";

Expand All @@ -123,6 +145,8 @@ public class Constants {

public static final String DEFAULT_NAMESPACE_ID = "public";

public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;

public static final int WRITE_REDIRECT_CODE = 307;

public static final String SERVICE_INFO_SPLITER = "@@";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
*/
String dataId();

/**
* if the config style is yaml
*
* @return default value is <code>false</code>
*/
boolean yaml() default false;

/**
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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;

/**
* @author liaochuntao
* @since 1.0.1
*/
public class NamingMaintainFactory {

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);
return vendorImpl;
} catch (Throwable e) {
throw new NacosException(-400, e.getMessage());
}
}

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);
return vendorImpl;
} catch (Throwable e) {
throw new NacosException(-400, e.getMessage());
}
}

}
Loading

0 comments on commit 3af86ae

Please sign in to comment.