Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync code #2

Merged
merged 90 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e189cca
Fix #1865
ly641921791 Sep 25, 2019
0d304c0
#2237 1. use ByteArrayEntity 2. getDeclaredMethods
rushsky518 Jan 10, 2020
c997476
revert
rushsky518 Jan 13, 2020
b1ffbad
#2237 directly use byte[]
rushsky518 Jan 15, 2020
8fe3eba
#2237 add a IT_test
rushsky518 Jan 24, 2020
93e730d
wait for async op
rushsky518 Jan 25, 2020
9c5bead
remove blank lines
rushsky518 Jan 27, 2020
7179cc3
[ISSUE #2749]dumpAllTaskMgr did not add the correct processor
wangweizZZ May 21, 2020
ba5098e
fix:#2839
lin-mt May 22, 2020
a7bc539
fix the style
lin-mt May 22, 2020
0ddbe7d
Merge pull request #2875 from alibaba/develop
yanlinly May 25, 2020
6086089
fix #2858 Provide nacosRestTemplate implementation
Maijh97 May 27, 2020
d08eac6
change http client implementation, Unified apacheHttpClient
Maijh97 May 28, 2020
377bbb8
Add some callouts
Maijh97 May 28, 2020
52426d4
change http client implementation, Unified apacheHttpClient
Maijh97 May 28, 2020
238b238
change http client implementation, Unified apacheHttpClient
Maijh97 May 28, 2020
0d775ea
change http client implementation, Unified apacheHttpClient
Maijh97 May 28, 2020
92ca0e1
Remove extra lines
Maijh97 May 28, 2020
886fe6d
[#1815]define LifeCycle interface and related abstract class.
zongtanghu May 29, 2020
57ca56c
add async http request client
Maijh97 May 29, 2020
6981fbc
[#1815]add ResourceLifeCycleManager,adjust some code and fix some uni…
zongtanghu May 29, 2020
ea03121
add NacosRestTemplate and NacosAsyncRestTemplate test example
Maijh97 May 30, 2020
a3a64c5
change annotate
Maijh97 May 30, 2020
066968e
Merge branch 'develop' into develop
Maijh97 May 30, 2020
11cc8da
Resolve conflicts
Maijh97 May 30, 2020
6f3b3e3
test change
Maijh97 May 30, 2020
2b7ebbf
test change
Maijh97 May 30, 2020
6d1baed
[#1815]add the related lifecycle test cases codes.
zongtanghu May 31, 2020
2cb690a
[#1815]add class file license.
zongtanghu May 31, 2020
ab3b234
[#1815]add class file license.
zongtanghu May 31, 2020
031c9ef
perfect NacosRestTemplate and restResult
Maijh97 May 31, 2020
7e05f3e
add class file license.
Maijh97 May 31, 2020
0c02111
add class file license.
Maijh97 May 31, 2020
4fc79b0
code format.
Maijh97 Jun 1, 2020
177b8aa
Merge branch 'develop' into develop
Maijh97 Jun 1, 2020
8768de4
Merge code.
Maijh97 Jun 1, 2020
379aa15
Added syntax compatible with Java 6
Maijh97 Jun 1, 2020
8d6dd8f
[#1815]adjust codes and reput the lifecycle to ConfigService class le…
zongtanghu Jun 1, 2020
a832412
optimize response handler, remove AsyncRestOperations,RestOperations.
Maijh97 Jun 1, 2020
2ab2742
[#1815]adjust and optimize codes, reput the lifecycle to ConfigServic…
zongtanghu Jun 2, 2020
5e2840a
[#1815]adjust and optimize codes.
zongtanghu Jun 3, 2020
aae7b34
Merge remote-tracking branch 'alibaba/develop' into issue_2749
wangweizZZ Jun 3, 2020
dc0c537
Merge remote-tracking branch 'alibaba/develop' into issue_2749
wangweizZZ Jun 3, 2020
0320e58
Merge remote-tracking branch 'upstream/master' into feature_lifecycle
zongtanghu Jun 3, 2020
e86c158
resolve codes conflicts
zongtanghu Jun 3, 2020
c726dd0
Merge branch 'feature_lifecycle' of https://github.com/zongtanghu/nac…
zongtanghu Jun 3, 2020
09752e3
[#1815]adjust this keywords which just includes constructor and set m…
zongtanghu Jun 3, 2020
94c41e1
[#1815]fix unit test cases.
zongtanghu Jun 3, 2020
860a2d0
resolve codes conflicts
zongtanghu Jun 3, 2020
15fad5d
[#1815]remove destroyService from Factory Class.
zongtanghu Jun 3, 2020
8a2921e
[#1815]remove no used package name from Factory Class.
zongtanghu Jun 4, 2020
bf74511
simplify code
J-Cod3r Jun 7, 2020
5191838
fix: fixed Raft RPC being submitted to the Leader, error could not be…
chuntaojun Jun 7, 2020
d916d22
refactor: add ut
chuntaojun Jun 7, 2020
c2e3530
Merge pull request #2981 from alibaba/hotfix_jraft
KomachiSion Jun 7, 2020
7121715
fix: fix task executable judgment logic problems
chuntaojun Jun 7, 2020
99539dd
Merge pull request #2986 from alibaba/hotfix_job_execute_condition
chuntaojun Jun 7, 2020
ab22fc7
Merge pull request #2976 from J-Cod3r/develop
KomachiSion Jun 8, 2020
795005b
fix: where config publish could not trigger horizontal notification i…
chuntaojun Jun 8, 2020
5203ee3
Merge pull request #2990 from alibaba/hotfix_standalone_notify
yanlinly Jun 8, 2020
902d609
perf: optimize configuration change event publishing
chuntaojun Jun 8, 2020
769fe02
ci: modify travis.yml
chuntaojun Jun 8, 2020
38f33b4
Merge pull request #2984 from showkawa/develop
chuntaojun Jun 8, 2020
8f7fb0f
[#1815]remove no used package name from Factory Class and adjust test…
zongtanghu Jun 9, 2020
2efe317
FIX ISSUE #3007 : MaxHistory字段名称和Nacos默认的命名风格不统一
zhouhailin Jun 9, 2020
510ffb5
Merge pull request #2995 from alibaba/perf_config_notify
TsingLiang Jun 10, 2020
ecf65ee
Merge pull request #2849 from lin-mt/develop
KomachiSion Jun 10, 2020
e6c578f
Merge pull request #3008 from zhouhailin/develop
KomachiSion Jun 10, 2020
7f7ee0d
Merge pull request #1877 from ly641921791/issue_1865
KomachiSion Jun 10, 2020
f49eba3
Merge pull request #2287 from rushsky518/sync_content
KomachiSion Jun 10, 2020
d21bbf4
a power of two size for hashmap
jzdayz Jun 10, 2020
0a47bc7
Merge pull request #3021 from jzdayz/develop
KomachiSion Jun 10, 2020
6d24d37
修针对mysql5.6版本使用innodb存储引擎,permissions表resouce字段长度过长,无法建表问题
baolongcheng Jun 10, 2020
990a01b
Update application.properties
alloevil Jun 10, 2020
8d79eb6
Merge pull request #3025 from alloevil/patch-4
KomachiSion Jun 11, 2020
7ae7400
Merge pull request #3023 from baolongcheng/develop
KomachiSion Jun 11, 2020
fa6bf99
remove extra blank lines
Maijh97 Jun 11, 2020
eb39830
[#1815]remove lifeCycle, lifeCycleManager, and adjust some related co…
zongtanghu Jun 11, 2020
e6e3161
resolve the codes conflicts
zongtanghu Jun 11, 2020
9b87379
[#1815]fix ut.
zongtanghu Jun 11, 2020
d2b9806
[#1815]remove code comments.
zongtanghu Jun 11, 2020
e7796b3
[#1815]adjust codes for instance class attribute init.
zongtanghu Jun 11, 2020
4c38fe1
Merge pull request #2927 from zongtanghu/feature_lifecycle
yanlinly Jun 11, 2020
65c6c8c
Merge pull request #2781 from wangweizZZ/issue_2749
yanlinly Jun 11, 2020
95272fe
adjust some codes
Maijh97 Jun 11, 2020
315a6c3
1.update beatinfo when received instance modify info
horizonzy Jun 11, 2020
c6d9426
Merge pull request #3037 from horizonzy/fix-2800
KomachiSion Jun 12, 2020
2f2a329
Add issue robot
KomachiSion Jun 12, 2020
81f9eff
Merge pull request #2926 from Maijh97/develop
KomachiSion Jun 12, 2020
a13aec6
Merge pull request #3054 from KomachiSion/develop-issue-rot
TsingLiang Jun 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change http client implementation, Unified apacheHttpClient
  • Loading branch information
Maijh97 committed May 28, 2020
commit d08eac68823fe7ff31b5d825173df9efc0048439
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.alibaba.nacos.common.http;

import com.alibaba.nacos.common.http.client.ApacheHttpClientRequest;
import com.alibaba.nacos.common.http.client.NacosRestTemplate;
import com.alibaba.nacos.common.utils.ShutdownUtils;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClients;
Expand Down Expand Up @@ -44,6 +46,9 @@ public class HttpClientManager {
private static final NAsyncHttpClient ASYNC_HTTP_CLIENT = new NacosAsyncHttpClient(
HttpAsyncClients.custom().setDefaultRequestConfig(DEFAULT_CONFIG).build());

private static final NacosRestTemplate NACOS_REST_TEMPLATE = new NacosRestTemplate
(new ApacheHttpClientRequest(HttpClients.custom().setDefaultRequestConfig(DEFAULT_CONFIG).build()));

static {
ShutdownUtils.addShutdownHook(new Runnable() {
@Override
Expand All @@ -69,4 +74,8 @@ public static NAsyncHttpClient getAsyncHttpClient() {
return ASYNC_HTTP_CLIENT;
}

public static NacosRestTemplate getNacosRestTemplate() {
return NACOS_REST_TEMPLATE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* 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.common.http.client;

import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.common.http.BaseHttpMethod;
import com.alibaba.nacos.common.http.param.Header;
import com.alibaba.nacos.common.model.RequestHttpEntity;
import com.alibaba.nacos.common.utils.HttpMethod;
import com.alibaba.nacos.common.utils.IoUtils;
import com.google.common.net.HttpHeaders;
import org.apache.http.HttpEntity;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPInputStream;

/**
* {@link HttpClientRequest} implementation that uses apache http client to
* execute streaming requests
*
* @author mai.jh
* @date 2020/5/24
*/
public class ApacheHttpClientRequest implements HttpClientRequest {

private static final Logger logger = LoggerFactory.getLogger(NacosRestTemplate.class);


private CloseableHttpClient client;

public ApacheHttpClientRequest(CloseableHttpClient client) {
this.client = client;
}

@Override
public HttpClientResponse execute(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity) throws Exception {
HttpRequestBase request = build(uri, httpMethod, requestHttpEntity);
CloseableHttpResponse response = client.execute(request);
if (logger.isDebugEnabled()) {
logger.debug("Request from server: " + request.getURI().toString());
}
return handleResponse(response);
}

private HttpClientResponse handleResponse(CloseableHttpResponse response) throws IOException{
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
int responseCode = statusLine.getStatusCode();
String responseMessage = statusLine.getReasonPhrase();
org.apache.http.Header[] allHeaders = response.getAllHeaders();
Header responseHeader = Header.newInstance();

for (org.apache.http.Header header : allHeaders) {
responseHeader.addParam(header.getName(), header.getValue());
}

return new DefaultClientHttpResponse(responseHeader,responseCode, responseMessage, entity.getContent());
}


protected HttpRequestBase build(URI uri, String method, RequestHttpEntity requestHttpEntity) throws Exception {
Header headers = requestHttpEntity.getHeaders();
BaseHttpMethod httpMethod = BaseHttpMethod.sourceOf(method);
httpMethod.init(uri.toString());
httpMethod.initHeader(headers);
httpMethod.initEntity(requestHttpEntity.getBody(), headers.getValue("Content-Type"));
return httpMethod.getRequestBase();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@


/**
* DefaultClientHttpResponse implementation {@link ClientHttpResponse}
* DefaultClientHttpResponse implementation {@link HttpClientResponse}
*
* @author mai.jh
* @date 2020/5/25
*/
public class DefaultClientHttpResponse implements ClientHttpResponse {
public class DefaultClientHttpResponse implements HttpClientResponse {

private Header header;

Expand All @@ -50,12 +50,12 @@ public DefaultClientHttpResponse(Header header, int responseCode, String respons
}

@Override
public int getStatusCode() throws IOException {
public int getStatusCode() {
return responseCode;
}

@Override
public String getStatusText() throws IOException {
public String getStatusText() {
return responseCodeMessage;
}

Expand Down

This file was deleted.

This file was deleted.

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

import com.alibaba.nacos.common.model.RequestHttpEntity;

import java.io.IOException;
import java.net.URI;

/**
Expand All @@ -28,15 +27,15 @@
* @author mai.jh
* @date 2020/5/23
*/
public interface ClientHttpRequest {
public interface HttpClientRequest {

/**
* execute http request
* @param uri http url
* @param httpMethod http request method
* @param requestHttpEntity http request entity
* @return ClientHttpResponse
* @throws IOException IOException
* @return HttpClientResponse
* @throws Exception ex
*/
ClientHttpResponse execute(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity) throws IOException;
HttpClientResponse execute(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity) throws Exception;
}
Loading