Skip to content

Commit

Permalink
Merge pull request #3 from alibaba/develop
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
binbin0325 authored Sep 20, 2020
2 parents b519af0 + 7fd4d9a commit 8582c0d
Show file tree
Hide file tree
Showing 145 changed files with 1,965 additions and 1,275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
public class NamingUtils {

public static String getGroupedName(final String serviceName, final String groupName) {
if (StringUtils.isBlank(serviceName)) {
throw new IllegalArgumentException("Param 'serviceName' is illegal, serviceName is blank");
}
final String resultGroupedName = groupName + Constants.SERVICE_INFO_SPLITER + serviceName;
return resultGroupedName.intern();
}
Expand Down
4 changes: 4 additions & 0 deletions auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<groupId>${project.groupId}</groupId>
<artifactId>nacos-common</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nacos-sys</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

package com.alibaba.nacos.auth.common;

import com.alibaba.nacos.auth.common.env.ReloadableConfigs;
import com.alibaba.nacos.common.JustForTest;
import com.alibaba.nacos.sys.utils.ApplicationUtils;
import io.jsonwebtoken.io.Decoders;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

Expand All @@ -40,9 +39,6 @@ public class AuthConfigs {
@JustForTest
private static Boolean cachingEnabled = null;

@Autowired
private ReloadableConfigs reloadableConfigs;

/**
* secret key.
*/
Expand Down Expand Up @@ -93,7 +89,7 @@ public boolean isAuthEnabled() {
return BooleanUtils.toBoolean(enabled);
}
return BooleanUtils
.toBoolean(reloadableConfigs.getProperties().getProperty("nacos.core.auth.enabled", "false"));
.toBoolean(ApplicationUtils.getProperty("nacos.core.auth.enabled", "false"));
}

/**
Expand All @@ -106,7 +102,7 @@ public boolean isCachingEnabled() {
return cachingEnabled;
}
return BooleanUtils
.toBoolean(reloadableConfigs.getProperties().getProperty("nacos.core.auth.caching.enabled", "true"));
.toBoolean(ApplicationUtils.getProperty("nacos.core.auth.caching.enabled", "true"));
}

@JustForTest
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ public abstract class AbstractApacheHttpClientFactory extends AbstractHttpClient

@Override
public final NacosRestTemplate createNacosRestTemplate() {
final HttpClientConfig originalRequestConfig = buildHttpClientConfig();
final RequestConfig requestConfig = getRequestConfig();
return new NacosRestTemplate(assignLogger(),
new DefaultHttpClientRequest(HttpClients.custom().setDefaultRequestConfig(requestConfig).build()));
return new NacosRestTemplate(assignLogger(), new DefaultHttpClientRequest(
HttpClients.custom().setDefaultRequestConfig(requestConfig)
.setUserAgent(originalRequestConfig.getUserAgent())
.setMaxConnTotal(originalRequestConfig.getMaxConnTotal())
.setMaxConnPerRoute(originalRequestConfig.getMaxConnPerRoute())
.setConnectionTimeToLive(originalRequestConfig.getConnTimeToLive(),
originalRequestConfig.getConnTimeToLiveTimeUnit()).build()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ public void onChanged(String filePath) {

@Override
public NacosAsyncRestTemplate createNacosAsyncRestTemplate() {
RequestConfig requestConfig = getRequestConfig();
final HttpClientConfig originalRequestConfig = buildHttpClientConfig();
final RequestConfig requestConfig = getRequestConfig();
return new NacosAsyncRestTemplate(assignLogger(), new DefaultAsyncHttpClientRequest(
HttpAsyncClients.custom().setDefaultRequestConfig(requestConfig).build()));
HttpAsyncClients.custom().setDefaultRequestConfig(requestConfig)
.setMaxConnTotal(originalRequestConfig.getMaxConnTotal())
.setMaxConnPerRoute(originalRequestConfig.getMaxConnPerRoute())
.setUserAgent(originalRequestConfig.getUserAgent()).build()));
}

protected RequestConfig getRequestConfig() {
HttpClientConfig httpClientConfig = buildHttpClientConfig();
return RequestConfig.custom().setConnectTimeout(httpClientConfig.getConTimeOutMillis())
.setSocketTimeout(httpClientConfig.getReadTimeOutMillis())
.setConnectionRequestTimeout(httpClientConfig.getConnectionRequestTimeout())
.setMaxRedirects(httpClientConfig.getMaxRedirects()).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.alibaba.nacos.common.http;

import com.alibaba.nacos.common.constant.HttpHeaderConsts;
import com.alibaba.nacos.common.http.handler.ResponseHandler;
import com.alibaba.nacos.common.http.param.Header;
import com.alibaba.nacos.common.http.param.Query;
Expand Down Expand Up @@ -103,7 +102,7 @@ protected HttpRequestBase build(String url, Header header, Object body, String m
final BaseHttpMethod httpMethod = BaseHttpMethod.sourceOf(method);
final HttpRequestBase httpRequestBase = httpMethod.init(url);
HttpUtils.initRequestHeader(httpRequestBase, header);
HttpUtils.initRequestEntity(httpRequestBase, body, header.getValue(HttpHeaderConsts.CONTENT_TYPE));
HttpUtils.initRequestEntity(httpRequestBase, body, header);
return httpRequestBase;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ protected HttpRequestBase createRequest(String url) {
}
},

/**
* delete Large request.
*/
DELETE_LARGE(HttpMethod.DELETE_LARGE) {
@Override
protected HttpRequestBase createRequest(String url) {
return new HttpDeleteWithEntity(url);
}
},

/**
* head request.
*/
Expand Down Expand Up @@ -155,6 +165,10 @@ public static BaseHttpMethod sourceOf(String name) {

/**
* get Large implemented.
* <p>
* Mainly used for GET request parameters are relatively large, can not be placed on the URL, so it needs to be
* placed in the body.
* </p>
*/
public static class HttpGetWithEntity extends HttpEntityEnclosingRequestBase {

Expand All @@ -171,4 +185,26 @@ public String getMethod() {
}
}

/**
* delete Large implemented.
* <p>
* Mainly used for DELETE request parameters are relatively large, can not be placed on the URL, so it needs to be
* placed in the body.
* </p>
*/
public static class HttpDeleteWithEntity extends HttpEntityEnclosingRequestBase {

public static final String METHOD_NAME = "DELETE";

public HttpDeleteWithEntity(String url) {
super();
setURI(URI.create(url));
}

@Override
public String getMethod() {
return METHOD_NAME;
}
}

}
Loading

0 comments on commit 8582c0d

Please sign in to comment.