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
2c20c9d8
Commit
2c20c9d8
authored
Jun 24, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cluster unique check
parent
22ac5b5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+18
-5
ClusterService.java
...ctrip/framework/apollo/portal/service/ClusterService.java
+4
-0
ClusterController.js
.../resources/static/scripts/controller/ClusterController.js
+17
-10
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
2c20c9d8
...
...
@@ -127,9 +127,21 @@ public class AdminServiceAPI {
return
Arrays
.
asList
(
clusterDTOs
);
}
public
ClusterDTO
createOrUpdate
(
Env
env
,
ClusterDTO
cluster
){
public
ClusterDTO
loadCluster
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
getForObject
(
"{host}/apps/{appId}/clusters/{clusterName}"
,
ClusterDTO
.
class
,
getAdminServiceHost
(
env
),
appId
,
clusterName
);
}
public
boolean
isClusterUnique
(
String
appId
,
Env
env
,
String
clusterName
)
{
return
restTemplate
.
getForObject
(
"{host}/apps/{appId}/cluster/{clusterName}/unique"
,
Boolean
.
class
,
getAdminServiceHost
(
env
),
appId
,
clusterName
);
}
public
ClusterDTO
createOrUpdate
(
Env
env
,
ClusterDTO
cluster
)
{
return
restTemplate
.
postForObject
(
"{host}/apps/{appId}/clusters"
,
cluster
,
ClusterDTO
.
class
,
getAdminServiceHost
(
env
),
cluster
.
getAppId
());
getAdminServiceHost
(
env
),
cluster
.
getAppId
());
}
}
...
...
@@ -172,9 +184,10 @@ public class AdminServiceAPI {
CommitDTO
[]
commitDTOs
=
restTemplate
.
getForObject
(
"{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}"
,
CommitDTO
[].
class
,
getAdminServiceHost
(
env
),
appId
,
clusterName
,
namespaceName
,
page
,
size
);
restTemplate
.
getForObject
(
"{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}"
,
CommitDTO
[].
class
,
getAdminServiceHost
(
env
),
appId
,
clusterName
,
namespaceName
,
page
,
size
);
return
Arrays
.
asList
(
commitDTOs
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java
View file @
2c20c9d8
...
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.service;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.core.exception.BadRequestException
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,6 +21,9 @@ public class ClusterService {
}
public
ClusterDTO
createCluster
(
Env
env
,
ClusterDTO
cluster
){
if
(!
clusterAPI
.
isClusterUnique
(
cluster
.
getAppId
(),
env
,
cluster
.
getName
())){
throw
new
BadRequestException
(
String
.
format
(
"cluster %s already exist."
,
cluster
.
getName
()));
}
return
clusterAPI
.
createOrUpdate
(
env
,
cluster
);
}
...
...
apollo-portal/src/main/resources/static/scripts/controller/ClusterController.js
View file @
2c20c9d8
...
...
@@ -24,19 +24,26 @@ cluster_module.controller('ClusterController',
};
$scope
.
create
=
function
()
{
var
noEnvChecked
=
true
;
$scope
.
envs
.
forEach
(
function
(
env
)
{
ClusterService
.
create_cluster
(
$scope
.
appId
,
env
.
name
,
{
name
:
$scope
.
clusterName
,
appId
:
$scope
.
appId
}).
then
(
function
(
result
)
{
toastr
.
success
(
env
.
name
,
"集群创建成功"
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"集群创建失败"
);
})
if
(
env
.
checked
)
{
noEnvChecked
=
false
;
ClusterService
.
create_cluster
(
$scope
.
appId
,
env
.
name
,
{
name
:
$scope
.
clusterName
,
appId
:
$scope
.
appId
}).
then
(
function
(
result
)
{
toastr
.
success
(
env
.
name
,
"集群创建成功"
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"集群创建失败"
);
})
}
})
if
(
noEnvChecked
){
toastr
.
warning
(
"请选择环境"
);
}
};
}]);
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