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
75199e3b
Commit
75199e3b
authored
Jun 30, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix when namespace.lock.switch off
parent
41bfee44
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
15 deletions
+40
-15
NamespaceLockAspect.java
...ramework/apollo/adminservice/aop/NamespaceLockAspect.java
+5
-8
NamespaceLockController.java
...ollo/adminservice/controller/NamespaceLockController.java
+11
-4
ApolloSwitcher.java
.../com/ctrip/framework/apollo/biz/utils/ApolloSwitcher.java
+21
-0
config.html
apollo-portal/src/main/resources/static/config.html
+2
-2
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+1
-1
ConfigBaseInfoController.js
...tic/scripts/controller/config/ConfigBaseInfoController.js
+0
-0
ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+0
-0
SyncConfigController.js
.../static/scripts/controller/config/SyncConfigController.js
+0
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceLockAspect.java
View file @
75199e3b
...
...
@@ -7,7 +7,7 @@ import com.ctrip.framework.apollo.biz.entity.NamespaceLock;
import
com.ctrip.framework.apollo.biz.service.ItemService
;
import
com.ctrip.framework.apollo.biz.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.biz.
service.ServerConfigService
;
import
com.ctrip.framework.apollo.biz.
utils.ApolloSwitcher
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.exception.BadRequestException
;
...
...
@@ -30,16 +30,15 @@ import org.springframework.stereotype.Component;
public
class
NamespaceLockAspect
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NamespaceLockAspect
.
class
);
private
static
final
String
NAMESPACE_LOCK_SWITCH_CONFIG_KEY
=
"namespace.lock.switch"
;
@Autowired
private
ServerConfigService
serverConfigService
;
@Autowired
private
NamespaceLockService
namespaceLockService
;
@Autowired
private
NamespaceService
namespaceService
;
@Autowired
private
ItemService
itemService
;
@Autowired
private
ApolloSwitcher
apolloSwitcher
;
@Before
(
"@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, item, ..)"
)
...
...
@@ -61,7 +60,7 @@ public class NamespaceLockAspect {
}
private
void
acquireLock
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
currentUser
)
{
if
(
isNamespaceLockSwitchOff
())
{
if
(
apolloSwitcher
.
isNamespaceLockSwitchOff
())
{
return
;
}
...
...
@@ -122,8 +121,6 @@ public class NamespaceLockAspect {
throw
new
BadRequestException
(
"namespace:"
+
namespace
.
getNamespaceName
()
+
" is modifying by "
+
lockOwner
);
}
private
boolean
isNamespaceLockSwitchOff
()
{
return
!
"true"
.
equals
(
serverConfigService
.
getValue
(
NAMESPACE_LOCK_SWITCH_CONFIG_KEY
,
"false"
));
}
}
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
View file @
75199e3b
...
...
@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
import
com.ctrip.framework.apollo.biz.entity.NamespaceLock
;
import
com.ctrip.framework.apollo.biz.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.biz.utils.ApolloSwitcher
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.core.exception.BadRequestException
;
...
...
@@ -17,23 +18,29 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public
class
NamespaceLockController
{
@Autowired
private
NamespaceLockService
namespaceLockService
;
@Autowired
private
NamespaceService
namespaceService
;
@Autowired
private
ApolloSwitcher
apolloSwitcher
;
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
NamespaceLockDTO
getNamespaceLockOwner
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
){
@PathVariable
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
){
if
(
namespace
==
null
)
{
throw
new
BadRequestException
(
"namespace not exist."
);
}
if
(
apolloSwitcher
.
isNamespaceLockSwitchOff
())
{
throw
new
NotFoundException
(
namespaceName
+
" is not locked"
);
}
NamespaceLock
lock
=
namespaceLockService
.
findLock
(
namespace
.
getId
());
if
(
lock
==
null
){
if
(
lock
==
null
)
{
throw
new
NotFoundException
(
namespaceName
+
" is not locked"
);
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ApolloSwitcher.java
0 → 100644
View file @
75199e3b
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
utils
;
import
com.ctrip.framework.apollo.biz.service.ServerConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ApolloSwitcher
{
private
static
final
String
NAMESPACE_LOCK_SWITCH_CONFIG_KEY
=
"namespace.lock.switch"
;
@Autowired
private
ServerConfigService
serverConfigService
;
public
boolean
isNamespaceLockSwitchOff
()
{
return
!
"true"
.
equals
(
serverConfigService
.
getValue
(
NAMESPACE_LOCK_SWITCH_CONFIG_KEY
,
"false"
));
}
}
apollo-portal/src/main/resources/static/config.html
View file @
75199e3b
...
...
@@ -617,8 +617,8 @@
<script
type=
"application/javascript"
src=
"scripts/directive.js"
></script>
<!--controller-->
<script
type=
"application/javascript"
src=
"scripts/controller/
app
/ConfigNamespaceController.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/
app
/ConfigBaseInfoController.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/
config
/ConfigNamespaceController.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/
config
/ConfigBaseInfoController.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/PageCommon.js"
></script>
...
...
apollo-portal/src/main/resources/static/config/sync.html
View file @
75199e3b
...
...
@@ -209,7 +209,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/ConfigService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/controller/
app
/SyncConfigController.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/controller/
config
/SyncConfigController.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/PageCommon.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/directive.js"
></script>
...
...
apollo-portal/src/main/resources/static/scripts/controller/
app
/ConfigBaseInfoController.js
→
apollo-portal/src/main/resources/static/scripts/controller/
config
/ConfigBaseInfoController.js
View file @
75199e3b
File moved
apollo-portal/src/main/resources/static/scripts/controller/
app
/ConfigNamespaceController.js
→
apollo-portal/src/main/resources/static/scripts/controller/
config
/ConfigNamespaceController.js
View file @
75199e3b
File moved
apollo-portal/src/main/resources/static/scripts/controller/
app
/SyncConfigController.js
→
apollo-portal/src/main/resources/static/scripts/controller/
config
/SyncConfigController.js
View file @
75199e3b
File moved
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