Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
75199e3b
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
75199e3b
编写于
6月 30, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix when namespace.lock.switch off
上级
41bfee44
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
40 addition
and
15 deletion
+40
-15
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceLockAspect.java
...ramework/apollo/adminservice/aop/NamespaceLockAspect.java
+5
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
...ollo/adminservice/controller/NamespaceLockController.java
+11
-4
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ApolloSwitcher.java
.../com/ctrip/framework/apollo/biz/utils/ApolloSwitcher.java
+21
-0
apollo-portal/src/main/resources/static/config.html
apollo-portal/src/main/resources/static/config.html
+2
-2
apollo-portal/src/main/resources/static/config/sync.html
apollo-portal/src/main/resources/static/config/sync.html
+1
-1
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js
...tic/scripts/controller/config/ConfigBaseInfoController.js
+0
-0
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+0
-0
apollo-portal/src/main/resources/static/scripts/controller/config/SyncConfigController.js
.../static/scripts/controller/config/SyncConfigController.js
+0
-0
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceLockAspect.java
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
75199e3b
文件已移动
apollo-portal/src/main/resources/static/scripts/controller/
app
/ConfigNamespaceController.js
→
apollo-portal/src/main/resources/static/scripts/controller/
config
/ConfigNamespaceController.js
浏览文件 @
75199e3b
文件已移动
apollo-portal/src/main/resources/static/scripts/controller/
app
/SyncConfigController.js
→
apollo-portal/src/main/resources/static/scripts/controller/
config
/SyncConfigController.js
浏览文件 @
75199e3b
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录