Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
43db6322
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,发现更多精彩内容 >>
提交
43db6322
编写于
6月 27, 2016
作者:
J
Jason Song
提交者:
GitHub
6月 27, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #297 from lepdou/0620_27
sync config
上级
d77de842
7c456751
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
15 deletion
+58
-15
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+6
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java
...om/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java
+9
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigService.java
.../ctrip/framework/apollo/portal/service/ConfigService.java
+13
-7
apollo-portal/src/main/resources/static/config/sync.html
apollo-portal/src/main/resources/static/config/sync.html
+21
-6
apollo-portal/src/main/resources/static/scripts/directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+9
-1
未找到文件。
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
浏览文件 @
43db6322
...
...
@@ -13,6 +13,7 @@ import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
@Service
...
...
@@ -71,7 +72,11 @@ public class ItemSetService {
auditService
.
audit
(
"ItemSet"
,
null
,
Audit
.
OP
.
DELETE
,
operator
);
}
createCommit
(
appId
,
clusterName
,
namespaceName
,
configChangeContentBuilder
.
build
(),
changeSet
.
getDataChangeLastModifiedBy
());
String
configChangeContent
=
configChangeContentBuilder
.
build
();
if
(!
StringUtils
.
isEmpty
(
configChangeContent
)){
createCommit
(
appId
,
clusterName
,
namespaceName
,
configChangeContentBuilder
.
build
(),
changeSet
.
getDataChangeLastModifiedBy
());
}
return
changeSet
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java
浏览文件 @
43db6322
...
...
@@ -5,6 +5,7 @@ import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
public
class
ItemDiffs
{
private
NamespaceIdentifer
namespace
;
private
ItemChangeSets
diffs
;
private
String
extInfo
;
public
ItemDiffs
(
NamespaceIdentifer
namespace
){
this
.
namespace
=
namespace
;
...
...
@@ -24,4 +25,12 @@ public class ItemDiffs {
public
void
setDiffs
(
ItemChangeSets
diffs
)
{
this
.
diffs
=
diffs
;
}
public
String
getExtInfo
()
{
return
extInfo
;
}
public
void
setExtInfo
(
String
extInfo
)
{
this
.
extInfo
=
extInfo
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigService.java
浏览文件 @
43db6322
...
...
@@ -4,6 +4,7 @@ package com.ctrip.framework.apollo.portal.service;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.HttpClientErrorException
;
...
...
@@ -135,7 +136,12 @@ public class ConfigService {
for
(
NamespaceIdentifer
namespace
:
comparedNamespaces
)
{
ItemDiffs
itemDiffs
=
new
ItemDiffs
(
namespace
);
itemDiffs
.
setDiffs
(
parseChangeSets
(
namespace
,
sourceItems
));
try
{
itemDiffs
.
setDiffs
(
parseChangeSets
(
namespace
,
sourceItems
));
}
catch
(
BadRequestException
e
)
{
itemDiffs
.
setDiffs
(
new
ItemChangeSets
());
itemDiffs
.
setExtInfo
(
"该集群下没有名为 "
+
namespace
.
getNamespaceName
()
+
" 的namespace"
);
}
result
.
add
(
itemDiffs
);
}
...
...
@@ -150,12 +156,12 @@ public class ConfigService {
NamespaceDTO
namespaceDTO
=
null
;
try
{
namespaceDTO
=
namespaceAPI
.
loadNamespace
(
appId
,
env
,
clusterName
,
namespaceName
);
}
catch
(
NotFound
Exception
e
)
{
logger
.
warn
(
"namespace not exist. appId:{}, env:{}, clusterName:{}, namespaceName:{}"
,
appId
,
env
,
clusterName
,
namespaceName
);
throw
new
BadRequestException
(
String
.
format
(
"namespace not exist. appId:%s, env:%s, clusterName:%s, namespaceName:%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
catch
(
HttpClientError
Exception
e
)
{
if
(
e
.
getStatusCode
()
==
HttpStatus
.
NOT_FOUND
)
{
throw
new
BadRequestException
(
String
.
format
(
"namespace not exist. appId:%s, env:%s, clusterName:%s, namespaceName:%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
}
return
namespaceDTO
.
getId
();
}
...
...
apollo-portal/src/main/resources/static/config/sync.html
浏览文件 @
43db6322
...
...
@@ -42,12 +42,22 @@
</header>
<div
class=
"panel-body"
>
<div
class=
"row"
ng-show=
"syncItemStep == 1"
>
<div
class=
"form-horizontal"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
同步的Namespace
</label>
<div
class=
"col-sm-6"
>
<h4
ng-bind=
"pageContext.namespaceName"
></h4>
</div>
</div>
</div>
<div
class=
"form-horizontal"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
同步到那个集群
</label>
<div
class=
"col-sm-6"
>
<apolloclusterselector
apollo-app-id=
"pageContext.appId"
apollo-default-all-checked=
"true"
apollo-select=
"collectSelectedClusters"
></apolloclusterselector>
apollo-select=
"collectSelectedClusters"
apollo-not-checked-env=
"pageContext.env"
apollo-not-checked-cluster=
"pageContext.clusterName"
></apolloclusterselector>
</div>
</div>
</div>
...
...
@@ -96,11 +106,16 @@
<!--step 2-->
<div
class=
"row"
ng-show=
"syncItemStep == 2"
ng-repeat=
"diff in diffs"
>
<h4
class=
"text-center"
>
环境:
<span
ng-bind=
"diff.namespace.env"
></span>
<h5
class=
"text-center"
>
环境:
<span
ng-bind=
"diff.namespace.env"
></span>
集群:
<span
ng-bind=
"diff.namespace.clusterName"
></span>
<em
ng-show=
"diff.diffs.createItems.length == 0 && diff.diffs.updateItems.length == 0"
>
没有更新的配置
</em>
</h4>
<hr>
<span
ng-show=
"!diff.extInfo"
>
Namespace:{{pageContext.namespaceName}}
</span>
</h5>
<div
class=
"text-center"
ng-show=
"diff.diffs.createItems.length + diff.diffs.updateItems.length == 0 || diff.extInfo"
>
<font
ng-show=
"diff.diffs.createItems.length + diff.diffs.updateItems.length == 0 && !diff.extInfo"
>
没有更新的配置
</font>
<font
ng-show=
"diff.extInfo"
ng-bind=
"diff.extInfo"
></font>
,忽略同步
</div>
<div
class=
"row"
style=
"margin-top: 10px;"
ng-show=
"diff.diffs.createItems.length > 0"
>
<div
class=
"form-horizontal"
>
...
...
@@ -150,6 +165,7 @@
</div>
</div>
</div>
<hr>
</div>
...
...
@@ -180,7 +196,6 @@
<script
src=
"../vendor/angular/loading-bar.min.js"
></script>
<!-- bootstrap.js -->
<script
src=
"../vendor/bootstrap/js/bootstrap.min.js"
type=
"text/javascript"
></script>
...
...
apollo-portal/src/main/resources/static/scripts/directive.js
浏览文件 @
43db6322
...
...
@@ -128,7 +128,9 @@ directive_module.directive('apolloclusterselector', function ($compile, $window,
defaultAllChecked
:
'
=apolloDefaultAllChecked
'
,
select
:
'
=apolloSelect
'
,
defaultCheckedEnv
:
'
=apolloDefaultCheckedEnv
'
,
defaultCheckedCluster
:
'
=apolloDefaultCheckedCluster
'
defaultCheckedCluster
:
'
=apolloDefaultCheckedCluster
'
,
notCheckedEnv
:
'
=apolloNotCheckedEnv
'
,
notCheckedCluster
:
'
=apolloNotCheckedCluster
'
},
link
:
function
(
scope
,
element
,
attrs
)
{
...
...
@@ -146,9 +148,15 @@ directive_module.directive('apolloclusterselector', function ($compile, $window,
var
env
=
node
.
env
;
node
.
clusters
.
forEach
(
function
(
cluster
)
{
cluster
.
env
=
env
;
//default checked
cluster
.
checked
=
scope
.
defaultAllChecked
||
(
cluster
.
env
==
scope
.
defaultCheckedEnv
&&
cluster
.
name
==
scope
.
defaultCheckedCluster
);
//not checked
if
(
cluster
.
env
==
scope
.
notCheckedEnv
&&
cluster
.
name
==
scope
.
notCheckedCluster
){
cluster
.
checked
=
false
;
}
scope
.
clusters
.
push
(
cluster
);
})
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录