Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
9670f6ec
Commit
9670f6ec
authored
Apr 28, 2017
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize find items interface
parent
26e377c6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
17 deletions
+43
-17
NamespaceUnlockAspect.java
...mework/apollo/adminservice/aop/NamespaceUnlockAspect.java
+1
-2
ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+1
-1
NamespaceUnlockAspectTest.java
...rk/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
+7
-7
ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+2
-0
ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+20
-3
ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+1
-3
NamespaceServiceIntegrationTest.java
...k/apollo/biz/service/NamespaceServiceIntegrationTest.java
+1
-1
pom.xml
pom.xml
+10
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspect.java
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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
View file @
9670f6ec
...
...
@@ -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 -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment