Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhangjian1949
apollo
提交
bd1832bf
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,发现更多精彩内容 >>
提交
bd1832bf
编写于
4月 28, 2017
作者:
J
Jason Song
提交者:
GitHub
4月 28, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #605 from lepdou/optimize-finditems
optimize find items interface
上级
26e377c6
9670f6ec
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
43 addition
and
17 deletion
+43
-17
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspect.java
...mework/apollo/adminservice/aop/NamespaceUnlockAspect.java
+1
-2
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+1
-1
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
...rk/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
+7
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+2
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+20
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+1
-3
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java
...k/apollo/biz/service/NamespaceServiceIntegrationTest.java
+1
-1
pom.xml
pom.xml
+10
-0
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspect.java
浏览文件 @
bd1832bf
...
...
@@ -26,7 +26,6 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
...
...
@@ -99,7 +98,7 @@ public class NamespaceUnlockAspect {
boolean
isModified
(
Namespace
namespace
)
{
Release
release
=
releaseService
.
findLatestActiveRelease
(
namespace
);
List
<
Item
>
items
=
itemService
.
findItems
(
namespace
.
getId
());
List
<
Item
>
items
=
itemService
.
findItems
WithoutOrdered
(
namespace
.
getId
());
if
(
release
==
null
)
{
return
hasNormalItems
(
items
);
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
浏览文件 @
bd1832bf
...
...
@@ -129,7 +129,7 @@ public class ItemController {
public
List
<
ItemDTO
>
findItems
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
return
BeanUtils
.
batchTransform
(
ItemDTO
.
class
,
itemService
.
findItems
(
appId
,
clusterName
,
namespaceName
));
return
BeanUtils
.
batchTransform
(
ItemDTO
.
class
,
itemService
.
findItems
WithOrdered
(
appId
,
clusterName
,
namespaceName
));
}
@RequestMapping
(
value
=
"/items/{itemId}"
,
method
=
RequestMethod
.
GET
)
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
浏览文件 @
bd1832bf
...
...
@@ -41,7 +41,7 @@ public class NamespaceUnlockAspectTest {
Namespace
namespace
=
createNamespace
(
namespaceId
);
when
(
releaseService
.
findLatestActiveRelease
(
namespace
)).
thenReturn
(
null
);
when
(
itemService
.
findItems
(
namespaceId
)).
thenReturn
(
Collections
.
singletonList
(
createItem
(
""
,
""
)));
when
(
itemService
.
findItems
WithOrdered
(
namespaceId
)).
thenReturn
(
Collections
.
singletonList
(
createItem
(
""
,
""
)));
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
namespace
);
...
...
@@ -57,7 +57,7 @@ public class NamespaceUnlockAspectTest {
List
<
Item
>
items
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v1"
),
createItem
(
"k2"
,
"v2"
));
when
(
releaseService
.
findLatestActiveRelease
(
namespace
)).
thenReturn
(
release
);
when
(
itemService
.
findItems
(
namespaceId
)).
thenReturn
(
items
);
when
(
itemService
.
findItems
WithOrdered
(
namespaceId
)).
thenReturn
(
items
);
when
(
namespaceService
.
findParentNamespace
(
namespace
)).
thenReturn
(
null
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
namespace
);
...
...
@@ -74,7 +74,7 @@ public class NamespaceUnlockAspectTest {
List
<
Item
>
items
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v2"
));
when
(
releaseService
.
findLatestActiveRelease
(
namespace
)).
thenReturn
(
release
);
when
(
itemService
.
findItems
(
namespaceId
)).
thenReturn
(
items
);
when
(
itemService
.
findItems
WithOrdered
(
namespaceId
)).
thenReturn
(
items
);
when
(
namespaceService
.
findParentNamespace
(
namespace
)).
thenReturn
(
null
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
namespace
);
...
...
@@ -91,7 +91,7 @@ public class NamespaceUnlockAspectTest {
List
<
Item
>
items
=
Arrays
.
asList
(
createItem
(
"k2"
,
"v2"
));
when
(
releaseService
.
findLatestActiveRelease
(
namespace
)).
thenReturn
(
release
);
when
(
itemService
.
findItems
(
namespaceId
)).
thenReturn
(
items
);
when
(
itemService
.
findItems
WithOrdered
(
namespaceId
)).
thenReturn
(
items
);
when
(
namespaceService
.
findParentNamespace
(
namespace
)).
thenReturn
(
null
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
namespace
);
...
...
@@ -111,7 +111,7 @@ public class NamespaceUnlockAspectTest {
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
parentRelease
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
WithoutOrdered
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
childNamespace
);
...
...
@@ -131,7 +131,7 @@ public class NamespaceUnlockAspectTest {
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
parentRelease
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
WithoutOrdered
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
childNamespace
);
...
...
@@ -150,7 +150,7 @@ public class NamespaceUnlockAspectTest {
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
null
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
WithOrdered
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
childNamespace
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
浏览文件 @
bd1832bf
...
...
@@ -15,6 +15,8 @@ public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
List
<
Item
>
findByNamespaceIdOrderByLineNumAsc
(
Long
namespaceId
);
List
<
Item
>
findByNamespaceId
(
Long
namespaceId
);
List
<
Item
>
findByNamespaceIdAndDataChangeLastModifiedTimeGreaterThan
(
Long
namespaceId
,
Date
date
);
Item
findFirst1ByNamespaceIdOrderByLineNumDesc
(
Long
namespaceId
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
浏览文件 @
bd1832bf
...
...
@@ -85,7 +85,24 @@ public class ItemService {
return
item
;
}
public
List
<
Item
>
findItems
(
Long
namespaceId
)
{
public
List
<
Item
>
findItemsWithoutOrdered
(
Long
namespaceId
)
{
List
<
Item
>
items
=
itemRepository
.
findByNamespaceId
(
namespaceId
);
if
(
items
==
null
)
{
return
Collections
.
emptyList
();
}
return
items
;
}
public
List
<
Item
>
findItemsWithoutOrdered
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
!=
null
)
{
return
findItemsWithoutOrdered
(
namespace
.
getId
());
}
else
{
return
Collections
.
emptyList
();
}
}
public
List
<
Item
>
findItemsWithOrdered
(
Long
namespaceId
)
{
List
<
Item
>
items
=
itemRepository
.
findByNamespaceIdOrderByLineNumAsc
(
namespaceId
);
if
(
items
==
null
)
{
return
Collections
.
emptyList
();
...
...
@@ -93,10 +110,10 @@ public class ItemService {
return
items
;
}
public
List
<
Item
>
findItems
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
public
List
<
Item
>
findItems
WithOrdered
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
!=
null
)
{
return
findItems
(
namespace
.
getId
());
return
findItems
WithOrdered
(
namespace
.
getId
());
}
else
{
return
Collections
.
emptyList
();
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
浏览文件 @
bd1832bf
...
...
@@ -3,7 +3,6 @@ package com.ctrip.framework.apollo.biz.service;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.GrayReleaseRule
;
...
...
@@ -30,7 +29,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.lang.reflect.Type
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
...
...
@@ -308,7 +306,7 @@ public class ReleaseService {
private
Map
<
String
,
String
>
getNamespaceItems
(
Namespace
namespace
)
{
List
<
Item
>
items
=
itemService
.
findItems
(
namespace
.
getId
());
List
<
Item
>
items
=
itemService
.
findItems
WithoutOrdered
(
namespace
.
getId
());
Map
<
String
,
String
>
configurations
=
new
HashMap
<
String
,
String
>();
for
(
Item
item
:
items
)
{
if
(
StringUtils
.
isEmpty
(
item
.
getKey
()))
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java
浏览文件 @
bd1832bf
...
...
@@ -63,7 +63,7 @@ public class NamespaceServiceIntegrationTest extends AbstractIntegrationTest {
namespaceService
.
deleteNamespace
(
namespace
,
testUser
);
List
<
Item
>
items
=
itemService
.
findItems
(
testApp
,
testCluster
,
testPrivateNamespace
);
List
<
Item
>
items
=
itemService
.
findItems
WithoutOrdered
(
testApp
,
testCluster
,
testPrivateNamespace
);
List
<
Commit
>
commits
=
commitService
.
find
(
testApp
,
testCluster
,
testPrivateNamespace
,
new
PageRequest
(
0
,
10
));
AppNamespace
appNamespace
=
appNamespaceService
.
findOne
(
testApp
,
testPrivateNamespace
);
List
<
Cluster
>
childClusters
=
clusterService
.
findChildClusters
(
testApp
,
testCluster
);
...
...
pom.xml
浏览文件 @
bd1832bf
...
...
@@ -669,6 +669,11 @@
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils-core
</artifactId>
</exclusion>
<!-- duplicated with spring-aop -->
<exclusion>
<groupId>
aopalliance
</groupId>
<artifactId>
aopalliance
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end of eureka -->
...
...
@@ -767,6 +772,11 @@
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils-core
</artifactId>
</exclusion>
<!-- duplicated with spring-aop -->
<exclusion>
<groupId>
aopalliance
</groupId>
<artifactId>
aopalliance
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end of eureka -->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录