Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhangjian1949
apollo
提交
dc493792
apollo
项目概览
zhangjian1949
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc493792
编写于
5月 12, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #185 from nobodyiam/performance-tuning-merge
Performance tunning and misc improvement.
上级
94d583d9
f6e69aca
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
118 addition
and
14 deletion
+118
-14
apollo-adminservice/src/main/java/com/ctrip/apollo/AdminServiceApplication.java
...c/main/java/com/ctrip/apollo/AdminServiceApplication.java
+2
-0
apollo-adminservice/src/test/java/com/ctrip/apollo/AdminServiceTestConfiguration.java
.../java/com/ctrip/apollo/AdminServiceTestConfiguration.java
+4
-3
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/AbstractControllerTest.java
...pollo/adminservice/controller/AbstractControllerTest.java
+2
-2
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ReleaseControllerTest.java
...apollo/adminservice/controller/ReleaseControllerTest.java
+5
-1
apollo-biz/src/main/java/com/ctrip/apollo/biz/aop/RepositoryAspect.java
.../main/java/com/ctrip/apollo/biz/aop/RepositoryAspect.java
+41
-0
apollo-common/src/main/java/com/ctrip/apollo/common/auth/RestTemplateFactory.java
...ava/com/ctrip/apollo/common/auth/RestTemplateFactory.java
+6
-1
apollo-common/src/main/java/com/ctrip/apollo/common/controller/HttpMessageConverterConfiguration.java
.../common/controller/HttpMessageConverterConfiguration.java
+37
-0
apollo-common/src/main/java/com/ctrip/apollo/common/controller/WebMvcConfig.java
...java/com/ctrip/apollo/common/controller/WebMvcConfig.java
+4
-3
apollo-configservice/src/main/java/com/ctrip/apollo/ConfigServiceApplication.java
.../main/java/com/ctrip/apollo/ConfigServiceApplication.java
+2
-0
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/integration/AbstractBaseIntegrationTest.java
...onfigservice/integration/AbstractBaseIntegrationTest.java
+1
-0
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
...ain/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
+5
-1
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ServiceLocator.java
.../java/com/ctrip/apollo/portal/service/ServiceLocator.java
+7
-1
apollo-portal/src/test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
...test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
+2
-2
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/apollo/AdminServiceApplication.java
浏览文件 @
dc493792
...
...
@@ -6,10 +6,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
@SpringBootApplication
@EnableEurekaClient
@EnableAspectJAutoProxy
public
class
AdminServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
AdminServiceApplication
.
class
).
run
(
args
);
...
...
apollo-adminservice/src/test/java/com/ctrip/apollo/AdminServiceTestConfiguration.java
浏览文件 @
dc493792
package
com.ctrip.apollo
;
import
com.ctrip.apollo.common.controller.HttpMessageConverterConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.FilterType
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
@Configuration
@ComponentScan
(
excludeFilters
=
{
@Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
value
=
{
SampleAdminServiceApplication
.
class
,
AdminServiceApplication
.
class
})})
SampleAdminServiceApplication
.
class
,
AdminServiceApplication
.
class
,
HttpMessageConverterConfiguration
.
class
})})
@EnableAutoConfiguration
public
class
AdminServiceTestConfiguration
{
...
...
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/AbstractControllerTest.java
浏览文件 @
dc493792
package
com.ctrip.apollo.adminservice.controller
;
import
javax.annotation.PostConstruct
;
import
com.ctrip.apollo.AdminServiceTestConfiguration
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.apollo.AdminServiceTestConfiguration
;
import
javax.annotation.PostConstruct
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
AdminServiceTestConfiguration
.
class
)
...
...
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ReleaseControllerTest.java
浏览文件 @
dc493792
...
...
@@ -20,7 +20,9 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.test.context.jdbc.Sql
;
...
...
@@ -69,11 +71,13 @@ public class ReleaseControllerTest extends AbstractControllerTest {
ItemDTO
[].
class
);
Assert
.
assertEquals
(
3
,
items
.
length
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<
String
,
String
>();
parameters
.
add
(
"name"
,
"someReleaseName"
);
parameters
.
add
(
"comment"
,
"someComment"
);
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
null
);
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
headers
);
ResponseEntity
<
ReleaseDTO
>
response
=
restTemplate
.
postForEntity
(
"http://localhost:"
+
port
+
"/apps/"
+
app
.
getAppId
()
+
"/clusters/"
+
cluster
.
getName
()
+
"/namespaces/"
+
namespace
.
getNamespaceName
()
+
"/releases"
,
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/aop/RepositoryAspect.java
0 → 100644
浏览文件 @
dc493792
package
com.ctrip.apollo.biz.aop
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.stereotype.Component
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Aspect
@Component
public
class
RepositoryAspect
{
@Pointcut
(
"execution(public * org.springframework.data.repository.Repository+.*(..))"
)
public
void
anyRepositoryMethod
()
{
}
@Around
(
"anyRepositoryMethod()"
)
public
Object
invokeWithCatTransaction
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
String
name
=
joinPoint
.
getSignature
().
getDeclaringType
().
getSimpleName
()
+
"."
+
joinPoint
.
getSignature
()
.
getName
();
Transaction
catTransaction
=
Cat
.
newTransaction
(
"SQL"
,
name
);
try
{
Object
result
=
joinPoint
.
proceed
();
catTransaction
.
setStatus
(
Message
.
SUCCESS
);
return
result
;
}
catch
(
Throwable
ex
)
{
catTransaction
.
setStatus
(
ex
);
throw
ex
;
}
finally
{
catTransaction
.
complete
();
}
}
}
apollo-common/src/main/java/com/ctrip/apollo/common/auth/RestTemplateFactory.java
浏览文件 @
dc493792
...
...
@@ -13,6 +13,8 @@ import org.apache.http.impl.client.HttpClientBuilder;
import
org.apache.http.message.BasicHeader
;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConverters
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -21,6 +23,8 @@ import com.google.common.io.BaseEncoding;
@Component
public
class
RestTemplateFactory
implements
FactoryBean
<
RestTemplate
>,
InitializingBean
{
@Autowired
private
HttpMessageConverters
httpMessageConverters
;
private
RestTemplate
restTemplate
;
...
...
@@ -49,7 +53,8 @@ public class RestTemplateFactory implements FactoryBean<RestTemplate>, Initializ
HttpClientBuilder
.
create
().
setDefaultCredentialsProvider
(
credentialsProvider
)
.
setDefaultHeaders
(
defaultHeaders
).
build
();
restTemplate
=
new
RestTemplate
(
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
restTemplate
=
new
RestTemplate
(
httpMessageConverters
.
getConverters
());
restTemplate
.
setRequestFactory
(
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
}
}
apollo-common/src/main/java/com/ctrip/apollo/common/controller/HttpMessageConverterConfiguration.java
0 → 100644
浏览文件 @
dc493792
package
com.ctrip.apollo.common.controller
;
import
com.google.common.collect.Lists
;
import
com.google.gson.GsonBuilder
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConverters
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.converter.ByteArrayHttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.http.converter.json.GsonHttpMessageConverter
;
import
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
;
import
java.util.List
;
/**
* Created by Jason on 5/11/16.
*/
@Configuration
public
class
HttpMessageConverterConfiguration
{
@Bean
public
HttpMessageConverters
messageConverters
()
{
GsonHttpMessageConverter
gsonHttpMessageConverter
=
new
GsonHttpMessageConverter
();
gsonHttpMessageConverter
.
setGson
(
new
GsonBuilder
().
setDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
).
create
());
final
List
<
HttpMessageConverter
<?>>
converters
=
Lists
.
newArrayList
(
new
ByteArrayHttpMessageConverter
(),
new
StringHttpMessageConverter
(),
new
AllEncompassingFormHttpMessageConverter
(),
gsonHttpMessageConverter
);
return
new
HttpMessageConverters
()
{
@Override
public
List
<
HttpMessageConverter
<?>>
getConverters
()
{
return
converters
;
}
};
}
}
apollo-common/src/main/java/com/ctrip/apollo/common/controller/WebMvcConfig.java
浏览文件 @
dc493792
package
com.ctrip.apollo.common.controller
;
import
java.util.List
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
...
...
@@ -10,6 +8,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
java.util.List
;
@Configuration
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
...
...
@@ -26,4 +26,5 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
configurer
.
ignoreAcceptHeader
(
true
).
defaultContentType
(
MediaType
.
APPLICATION_JSON
);
}
}
apollo-configservice/src/main/java/com/ctrip/apollo/ConfigServiceApplication.java
浏览文件 @
dc493792
...
...
@@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
/**
* Spring boot application entry point
...
...
@@ -14,6 +15,7 @@ import org.springframework.context.ConfigurableApplicationContext;
*/
@SpringBootApplication
@EnableEurekaServer
@EnableAspectJAutoProxy
public
class
ConfigServiceApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
...
...
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/integration/AbstractBaseIntegrationTest.java
浏览文件 @
dc493792
...
...
@@ -22,6 +22,7 @@ import javax.annotation.PostConstruct;
@SpringApplicationConfiguration
(
classes
=
AbstractBaseIntegrationTest
.
TestConfiguration
.
class
)
@WebIntegrationTest
(
randomPort
=
true
)
public
abstract
class
AbstractBaseIntegrationTest
{
RestTemplate
restTemplate
=
new
TestRestTemplate
(
"user"
,
""
);
@PostConstruct
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
浏览文件 @
dc493792
...
...
@@ -11,6 +11,8 @@ import com.ctrip.apollo.core.dto.NamespaceDTO;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
...
...
@@ -130,11 +132,13 @@ public class AdminServiceAPI {
public
ReleaseDTO
release
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseBy
,
String
comment
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<
String
,
String
>();
parameters
.
add
(
"name"
,
releaseBy
);
parameters
.
add
(
"comment"
,
comment
);
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
null
);
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
headers
);
ResponseEntity
<
ReleaseDTO
>
response
=
restTemplate
.
postForEntity
(
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ServiceLocator.java
浏览文件 @
dc493792
...
...
@@ -11,6 +11,8 @@ import javax.annotation.PostConstruct;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConverters
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.stereotype.Service
;
...
...
@@ -31,7 +33,10 @@ public class ServiceLocator {
private
static
final
int
DEFAULT_TIMEOUT_MS
=
1000
;
private
RestTemplate
restTemplate
=
new
RestTemplate
();
private
RestTemplate
restTemplate
;
@Autowired
private
HttpMessageConverters
httpMessageConverters
;
private
Map
<
Env
,
List
<
ServiceDTO
>>
serviceCaches
=
new
ConcurrentHashMap
<
Env
,
List
<
ServiceDTO
>>();
...
...
@@ -81,6 +86,7 @@ public class ServiceLocator {
@PostConstruct
private
void
postConstruct
()
{
restTemplate
=
new
RestTemplate
(
httpMessageConverters
.
getConverters
());
if
(
restTemplate
.
getRequestFactory
()
instanceof
SimpleClientHttpRequestFactory
)
{
SimpleClientHttpRequestFactory
rf
=
(
SimpleClientHttpRequestFactory
)
restTemplate
.
getRequestFactory
();
...
...
apollo-portal/src/test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
浏览文件 @
dc493792
package
com.ctrip.apollo.portal
;
import
javax.annotation.PostConstruct
;
import
com.ctrip.apollo.PortalApplication
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.apollo.PortalApplication
;
import
javax.annotation.PostConstruct
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
PortalApplication
.
class
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录