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
43db6322
Commit
43db6322
authored
Jun 27, 2016
by
Jason Song
Committed by
GitHub
Jun 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #297 from lepdou/0620_27
sync config
parents
d77de842
7c456751
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
15 deletions
+58
-15
ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+6
-1
ItemDiffs.java
...om/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java
+9
-0
ConfigService.java
.../ctrip/framework/apollo/portal/service/ConfigService.java
+13
-7
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+21
-6
directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+9
-1
No files found.
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
View file @
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
View file @
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
View file @
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
View file @
43db6322
...
...
@@ -44,10 +44,20 @@
<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
View file @
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
);
})
});
...
...
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