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
9d2cf93e
Commit
9d2cf93e
authored
Apr 07, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #61 from yiming187/bug_fix
Fix AdminService bugs
parents
6b98de3d
e74556fe
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
348 additions
and
205 deletions
+348
-205
pom.xml
apollo-adminservice/pom.xml
+32
-42
AdminServiceApplication.java
...c/main/java/com/ctrip/apollo/AdminServiceApplication.java
+1
-1
AppController.java
...m/ctrip/apollo/adminservice/controller/AppController.java
+16
-8
ClusterController.java
...rip/apollo/adminservice/controller/ClusterController.java
+11
-0
NamespaceController.java
...p/apollo/adminservice/controller/NamespaceController.java
+17
-8
WebMvcConfig.java
...om/ctrip/apollo/adminservice/controller/WebMvcConfig.java
+24
-0
SampleAdminServiceApplication.java
.../java/com/ctrip/apollo/SampleAdminServiceApplication.java
+13
-0
application.properties
...lo-adminservice/src/test/resources/application.properties
+4
-0
import.sql
apollo-adminservice/src/test/resources/import.sql
+31
-0
pom.xml
apollo-biz/pom.xml
+0
-6
App.java
...lo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
+3
-3
AppNamespace.java
...c/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
+3
-3
Cluster.java
...iz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
+2
-2
Item.java
...o-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
+2
-2
Namespace.java
.../src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
+2
-2
Privilege.java
.../src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
+2
-2
Release.java
...iz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
+2
-2
AppService.java
...rc/main/java/com/ctrip/apollo/biz/service/AppService.java
+1
-1
ClusterService.java
...ain/java/com/ctrip/apollo/biz/service/ClusterService.java
+18
-0
NamespaceService.java
...n/java/com/ctrip/apollo/biz/service/NamespaceService.java
+8
-2
ConfigServiceApplication.java
.../main/java/com/ctrip/apollo/ConfigServiceApplication.java
+2
-4
ServletInitializer.java
...ce/src/main/java/com/ctrip/apollo/ServletInitializer.java
+1
-1
SampleConfigServiceApplication.java
...java/com/ctrip/apollo/SampleConfigServiceApplication.java
+13
-0
AbstractConfigServiceTest.java
...ctrip/apollo/configservice/AbstractConfigServiceTest.java
+2
-2
application.yml
apollo-configservice/src/test/resources/application.yml
+11
-8
bootstrap.yml
apollo-configservice/src/test/resources/bootstrap.yml
+6
-2
AppDTO.java
...-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
+10
-0
ItemDTO.java
...core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
+17
-37
NamespaceDTO.java
...src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
+17
-17
ReleaseDTO.java
...e/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
+41
-14
ConfigService.java
...n/java/com/ctrip/apollo/portal/service/ConfigService.java
+32
-32
ConfigServiceTest.java
...va/com/ctrip/apollo/portal/service/ConfigServiceTest.java
+4
-4
No files found.
apollo-adminservice/pom.xml
View file @
9d2cf93e
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-adminservice
</artifactId>
<name>
Apollo AdminService
</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<!-- end of apollo -->
<!-- redis -->
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<!-- end of redis -->
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-adminservice
</artifactId>
<name>
Apollo AdminService
</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<!-- end of apollo -->
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka
</artifactId>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
apollo-adminservice/src/main/java/com/ctrip/apollo/AdminServiceApplication.java
View file @
9d2cf93e
...
...
@@ -9,6 +9,6 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@EnableEurekaClient
public
class
AdminServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
AdminServiceApplication
.
class
).
web
(
true
).
run
(
args
);
new
SpringApplicationBuilder
(
AdminServiceApplication
.
class
).
run
(
args
);
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppController.java
View file @
9d2cf93e
...
...
@@ -3,6 +3,7 @@ package com.ctrip.apollo.adminservice.controller;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -12,22 +13,29 @@ import com.ctrip.apollo.biz.entity.App;
import
com.ctrip.apollo.biz.service.AppService
;
import
com.ctrip.apollo.biz.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.AppDTO
;
import
com.google.common.base.Strings
;
@RestController
public
class
AppController
{
@Autowired
private
AppService
appService
;
@RequestMapping
(
"/apps/{appId}"
)
public
AppDTO
findByAppId
(
@PathVariable
(
"appId"
)
String
appId
)
{
App
app
=
appService
.
findByAppId
(
appId
);
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
public
AppDTO
getApp
(
@PathVariable
(
"appId"
)
String
appId
)
{
App
app
=
appService
.
findOne
(
appId
);
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
}
@RequestMapping
(
"/apps"
)
public
List
<
AppDTO
>
findByName
(
@RequestParam
(
"name"
)
String
name
)
{
List
<
App
>
app
=
appService
.
findByName
(
name
);
return
BeanUtils
.
batchTransform
(
AppDTO
.
class
,
app
);
public
List
<
AppDTO
>
findApps
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
,
Pageable
pageable
)
{
List
<
App
>
app
=
null
;
if
(
Strings
.
isNullOrEmpty
(
name
))
{
app
=
appService
.
findAll
(
pageable
);
}
else
{
app
=
appService
.
findByName
(
name
);
}
return
BeanUtils
.
batchTransform
(
AppDTO
.
class
,
app
);
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ClusterController.java
View file @
9d2cf93e
...
...
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.service.ClusterService
;
import
com.ctrip.apollo.biz.service.ViewService
;
import
com.ctrip.apollo.biz.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.ClusterDTO
;
...
...
@@ -18,9 +19,19 @@ public class ClusterController {
@Autowired
private
ViewService
viewService
;
@Autowired
private
ClusterService
clusterService
;
@RequestMapping
(
"/apps/{appId}/clusters"
)
public
List
<
ClusterDTO
>
findClusters
(
@PathVariable
(
"appId"
)
String
appId
)
{
List
<
Cluster
>
clusters
=
viewService
.
findClusters
(
appId
);
return
BeanUtils
.
batchTransform
(
ClusterDTO
.
class
,
clusters
);
}
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}"
)
public
ClusterDTO
getCluster
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
Cluster
cluster
=
clusterService
.
findOne
(
appId
,
clusterName
);
return
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
cluster
);
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/
Group
Controller.java
→
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/
Namespace
Controller.java
View file @
9d2cf93e
...
...
@@ -14,24 +14,33 @@ import com.ctrip.apollo.biz.utils.BeanUtils;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
@RestController
public
class
Group
Controller
{
public
class
Namespace
Controller
{
@Autowired
private
ViewService
viewService
;
@Autowired
private
NamespaceService
group
Service
;
private
NamespaceService
namespace
Service
;
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}/
group
s"
)
public
List
<
NamespaceDTO
>
find
Group
s
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}/
namespace
s"
)
public
List
<
NamespaceDTO
>
find
Namespace
s
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
List
<
Namespace
>
groups
=
viewService
.
findNamespaces
(
appId
,
clusterName
);
return
BeanUtils
.
batchTransform
(
NamespaceDTO
.
class
,
groups
);
}
@RequestMapping
(
"/groups/{groupId}"
)
public
NamespaceDTO
findOne
(
@PathVariable
(
"groupId"
)
Long
groupId
)
{
Namespace
group
=
groupService
.
findOne
(
groupId
);
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
group
);
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}"
)
public
NamespaceDTO
getNamespace
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
}
@RequestMapping
(
"/namespaces/{namespaceId}"
)
public
NamespaceDTO
getNamespace
(
@PathVariable
(
"namespaceId"
)
Long
namespaceId
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
namespaceId
);
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/WebMvcConfig.java
0 → 100644
View file @
9d2cf93e
package
com
.
ctrip
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
@EnableWebMvc
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
PageableHandlerMethodArgumentResolver
resolver
=
new
PageableHandlerMethodArgumentResolver
();
resolver
.
setFallbackPageable
(
new
PageRequest
(
0
,
10
));
argumentResolvers
.
add
(
resolver
);
}
}
apollo-adminservice/src/test/java/com/ctrip/apollo/SampleAdminServiceApplication.java
0 → 100644
View file @
9d2cf93e
package
com
.
ctrip
.
apollo
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
@SpringBootApplication
@EnableEurekaClient
public
class
SampleAdminServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
SampleAdminServiceApplication
.
class
).
run
(
args
);
}
}
apollo-adminservice/src/test/resources/application.properties
0 → 100644
View file @
9d2cf93e
spring.datasource.url
=
jdbc:h2:mem:~/fxapolloconfigdb;mode=mysql
spring.jpa.hibernate.naming_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
apollo-adminservice/src/test/resources/import.sql
0 → 100644
View file @
9d2cf93e
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003171'
,
'apollo-config-service'
,
'刘一鸣'
,
'liuym@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003172'
,
'apollo-admin-service'
,
'宋顺'
,
'song_s@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003173'
,
'apollo-portal'
,
'张乐'
,
'zhanglea@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'fxhermesproducer'
,
'fx-hermes-producer'
,
'梁锦华'
,
'jhliang@ctrip.com'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'cluster1'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'cluster2'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'cluster3'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'fxhermesproducer'
,
'default'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'apollo-config-service'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'apollo-admin-service'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'apollo-portal-service'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'fx-hermes-producer'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'apollo-config-service'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'fx-hermes-producer'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'apollo-admin-service'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'apollo-portal'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'fx-hermes-producer'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k2'
,
'v2'
,
'comment2'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
2
,
'k3'
,
'v3'
,
'comment3'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
5
,
'k3'
,
'v4'
,
'comment4'
);
INSERT
INTO
`RELEASE`
(
Name
,
Comment
,
AppId
,
ClusterName
,
NamespaceName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'apollo-config-service'
,
'{"k1":"v1"}'
);
apollo-biz/pom.xml
View file @
9d2cf93e
...
...
@@ -19,12 +19,6 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
<exclusions>
<exclusion>
<artifactId>
logback-classic
</artifactId>
<groupId>
ch.qos.logback
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<profiles>
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
View file @
9d2cf93e
...
...
@@ -7,14 +7,14 @@ import org.hibernate.annotations.SQLDelete;
import
org.hibernate.annotations.Where
;
@Entity
@SQLDelete
(
sql
=
"Update App set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update App set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
App
extends
BaseEntity
{
@Column
(
nullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
)
@Column
(
nullable
=
false
,
unique
=
true
)
private
String
appId
;
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
View file @
9d2cf93e
...
...
@@ -7,11 +7,11 @@ import org.hibernate.annotations.SQLDelete;
import
org.hibernate.annotations.Where
;
@Entity
@SQLDelete
(
sql
=
"Update AppNamespace set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update AppNamespace set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
AppNamespace
extends
BaseEntity
{
@Column
(
nullable
=
false
)
@Column
(
nullable
=
false
,
unique
=
true
)
private
String
name
;
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
View file @
9d2cf93e
...
...
@@ -10,8 +10,8 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@SQLDelete
(
sql
=
"Update Cluster set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update Cluster set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
Cluster
extends
BaseEntity
{
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
View file @
9d2cf93e
...
...
@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import
org.hibernate.annotations.Where
;
@Entity
@SQLDelete
(
sql
=
"Update Item set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update Item set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
Item
extends
BaseEntity
{
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
View file @
9d2cf93e
...
...
@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import
org.hibernate.annotations.Where
;
@Entity
@SQLDelete
(
sql
=
"Update Namespace set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update Namespace set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
Namespace
extends
BaseEntity
{
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
View file @
9d2cf93e
...
...
@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import
org.hibernate.annotations.Where
;
@Entity
@SQLDelete
(
sql
=
"Update Privilege set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update Privilege set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
Privilege
extends
BaseEntity
{
@Column
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
View file @
9d2cf93e
...
...
@@ -11,8 +11,8 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@SQLDelete
(
sql
=
"Update Release set isDeleted =
1
where id = ?"
)
@Where
(
clause
=
"isDeleted =
0
"
)
@SQLDelete
(
sql
=
"Update Release set isDeleted =
'false'
where id = ?"
)
@Where
(
clause
=
"isDeleted =
'false'
"
)
public
class
Release
extends
BaseEntity
{
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppService.java
View file @
9d2cf93e
...
...
@@ -29,7 +29,7 @@ public class AppService {
return
appRepository
.
findByName
(
name
);
}
public
App
find
ByAppId
(
String
appId
){
public
App
find
One
(
String
appId
){
return
appRepository
.
findByAppId
(
appId
);
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ClusterService.java
0 → 100644
View file @
9d2cf93e
package
com
.
ctrip
.
apollo
.
biz
.
service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.repository.ClusterRepository
;
@Service
public
class
ClusterService
{
@Autowired
private
ClusterRepository
clusterRepository
;
public
Cluster
findOne
(
String
appId
,
String
name
)
{
return
clusterRepository
.
findByAppIdAndName
(
appId
,
name
);
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/NamespaceService.java
View file @
9d2cf93e
...
...
@@ -11,8 +11,14 @@ public class NamespaceService {
@Autowired
private
NamespaceRepository
namespaceRepository
;
public
Namespace
findOne
(
Long
namespaceId
){
public
Namespace
findOne
(
Long
namespaceId
)
{
return
namespaceRepository
.
findOne
(
namespaceId
);
}
public
Namespace
findOne
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
appId
,
clusterName
,
namespaceName
);
}
}
apollo-configservice/src/main/java/com/ctrip/apollo/
Server
Application.java
→
apollo-configservice/src/main/java/com/ctrip/apollo/
ConfigService
Application.java
View file @
9d2cf93e
...
...
@@ -3,7 +3,6 @@ package com.ctrip.apollo;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
* Spring boot application entry point
...
...
@@ -12,11 +11,10 @@ import org.springframework.context.ConfigurableApplicationContext;
*/
@SpringBootApplication
@EnableEurekaServer
public
class
Server
Application
{
public
class
ConfigService
Application
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
ServerApplication
.
class
).
web
(
true
).
run
(
args
);
new
SpringApplicationBuilder
(
ConfigServiceApplication
.
class
).
run
(
args
);
}
}
apollo-configservice/src/main/java/com/ctrip/apollo/ServletInitializer.java
View file @
9d2cf93e
...
...
@@ -12,7 +12,7 @@ public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
Server
Application
.
class
);
return
application
.
sources
(
ConfigService
Application
.
class
);
}
}
apollo-configservice/src/test/java/com/ctrip/apollo/SampleConfigServiceApplication.java
0 → 100644
View file @
9d2cf93e
package
com
.
ctrip
.
apollo
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
@SpringBootApplication
@EnableEurekaServer
public
class
SampleConfigServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
SampleConfigServiceApplication
.
class
).
run
(
args
);
}
}
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/AbstractConfigServiceTest.java
View file @
9d2cf93e
package
com
.
ctrip
.
apollo
.
configservice
;
import
com.ctrip.apollo.
Server
Application
;
import
com.ctrip.apollo.
ConfigService
Application
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Server
Application
.
class
)
@SpringApplicationConfiguration
(
classes
=
ConfigService
Application
.
class
)
public
abstract
class
AbstractConfigServiceTest
{
}
apollo-configservice/src/test/resources/application.yml
View file @
9d2cf93e
spring
:
application
:
name
:
apollo-configservice
datasource
:
url
:
jdbc:h2:mem:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE
server
:
port
:
8888
port
:
${port:8080}
logging
:
level
:
org.springframework.cloud
:
'
DEBUG'
file
:
/opt/logs/${ctrip.appid}/apollo-configservice.log
spring
:
application
:
name
:
apollo-configservice
datasource
:
url
:
jdbc:h2:file:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE
username
:
sa
password
:
ctrip
:
appid
:
100003171
\ No newline at end of file
apollo-configservice/src/test/resources/bootstrap.yml
View file @
9d2cf93e
eureka
:
instance
:
hostname
:
localhost
hostname
:
${hostname:localhost}
preferIpAddress
:
true
client
:
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:8761/eureka/
defaultZone
:
http://${eureka.instance.hostname}:8080/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
View file @
9d2cf93e
...
...
@@ -2,6 +2,8 @@ package com.ctrip.apollo.core.dto;
public
class
AppDTO
{
private
long
id
;
private
String
name
;
private
String
appId
;
...
...
@@ -14,6 +16,10 @@ public class AppDTO {
return
appId
;
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
...
...
@@ -30,6 +36,10 @@ public class AppDTO {
this
.
appId
=
appId
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
View file @
9d2cf93e
...
...
@@ -4,11 +4,7 @@ public class ItemDTO {
private
long
id
;
private
long
clusterId
;
private
String
clusterName
;
private
String
appId
;
private
long
namespaceId
;
private
String
key
;
...
...
@@ -25,59 +21,43 @@ public class ItemDTO {
this
.
value
=
value
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getClusterId
()
{
return
clusterId
;
public
String
getComment
()
{
return
comment
;
}
public
void
setClusterId
(
long
clusterId
)
{
this
.
clusterId
=
clusterI
d
;
public
long
getId
(
)
{
return
i
d
;
}
public
String
get
ClusterName
()
{
return
clusterName
;
public
String
get
Key
()
{
return
key
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
public
long
getNamespaceId
(
)
{
return
namespaceId
;
}
public
String
get
AppId
()
{
return
appId
;
public
String
get
Value
()
{
return
value
;
}
public
void
set
AppId
(
String
appId
)
{
this
.
appId
=
appId
;
public
void
set
Comment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
String
getKey
(
)
{
return
key
;
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
String
getValue
(
)
{
return
value
;
public
void
setNamespaceId
(
long
namespaceId
)
{
this
.
namespaceId
=
namespaceId
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
View file @
9d2cf93e
...
...
@@ -4,41 +4,41 @@ public class NamespaceDTO {
private
long
id
;
private
long
clusterId
;
private
String
appId
;
private
String
clusterName
;
private
long
namespaceId
;
private
String
namespaceName
;
private
String
name
;
public
String
getAppId
()
{
return
appId
;
}
public
lo
ng
getClusterId
()
{
return
cluster
Id
;
public
Stri
ng
getClusterId
()
{
return
cluster
Name
;
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
public
String
getName
spaceName
()
{
return
name
spaceName
;
}
public
long
getNamespaceId
(
)
{
return
namespace
Id
;
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
app
Id
;
}
public
void
setCluster
Id
(
long
clusterId
)
{
this
.
cluster
Id
=
clusterId
;
public
void
setCluster
Name
(
String
clusterName
)
{
this
.
cluster
Name
=
clusterName
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setNamespaceId
(
long
namespaceId
)
{
this
.
namespaceId
=
namespaceId
;
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
View file @
9d2cf93e
...
...
@@ -4,45 +4,72 @@ public class ReleaseDTO {
private
long
id
;
private
long
releaseId
;
private
String
name
;
private
String
appId
;
private
String
clusterName
;
private
String
namespaceName
;
private
String
configurations
;
public
ReleaseDTO
()
{
private
String
comment
;
public
String
getAppId
()
{
return
appId
;
}
public
long
getId
()
{
return
id
;
public
String
getClusterName
()
{
return
clusterName
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
public
String
getComment
(
)
{
return
comment
;
}
public
long
getReleaseId
()
{
return
releaseId
;
public
String
getConfigurations
()
{
return
configurations
;
}
public
void
setReleaseId
(
long
releaseId
)
{
this
.
releaseId
=
releaseI
d
;
public
long
getId
(
)
{
return
i
d
;
}
public
String
getClusterName
()
{
return
clusterName
;
public
String
getName
()
{
return
name
;
}
public
String
getNamespaceName
()
{
return
namespaceName
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
}
public
String
getConfigurations
(
)
{
return
configurations
;
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
void
setConfigurations
(
String
configurations
)
{
this
.
configurations
=
configurations
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
}
}
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
View file @
9d2cf93e
...
...
@@ -180,16 +180,16 @@ public class ConfigService {
private
Map
<
String
,
List
<
ItemDTO
>>
groupConfigByCluster
(
List
<
ItemDTO
>
configItems
)
{
Map
<
String
,
List
<
ItemDTO
>>
groupedClusterConfigs
=
new
HashMap
<>();
String
clusterName
;
for
(
ItemDTO
configItem
:
configItems
)
{
clusterName
=
configItem
.
getClusterName
();
List
<
ItemDTO
>
clusterConfigs
=
groupedClusterConfigs
.
get
(
clusterName
);
if
(
clusterConfigs
==
null
)
{
clusterConfigs
=
new
LinkedList
<>();
groupedClusterConfigs
.
put
(
clusterName
,
clusterConfigs
);
}
clusterConfigs
.
add
(
configItem
);
}
//
String clusterName;
//
for (ItemDTO configItem : configItems) {
//
clusterName = configItem.getClusterName();
//
List<ItemDTO> clusterConfigs = groupedClusterConfigs.get(clusterName);
//
if (clusterConfigs == null) {
//
clusterConfigs = new LinkedList<>();
//
groupedClusterConfigs.put(clusterName, clusterConfigs);
//
}
//
clusterConfigs.add(configItem);
//
}
return
groupedClusterConfigs
;
}
...
...
@@ -227,28 +227,28 @@ public class ConfigService {
Map
<
String
,
AppConfigVO
.
OverrideAppConfig
>
appIdMapOverrideAppConfig
=
null
;
for
(
ItemDTO
config
:
clusterConfigs
)
{
String
targetAppId
=
config
.
getAppId
();
if
(
appId
.
equals
(
targetAppId
))
{
// app self's configs
defaultClusterConfigs
.
add
(
config
);
}
else
{
// override other app configs
if
(
appIdMapOverrideAppConfig
==
null
)
{
appIdMapOverrideAppConfig
=
new
HashMap
<>();
}
AppConfigVO
.
OverrideAppConfig
overrideAppConfig
=
appIdMapOverrideAppConfig
.
get
(
targetAppId
);
if
(
overrideAppConfig
==
null
)
{
overrideAppConfig
=
new
AppConfigVO
.
OverrideAppConfig
();
appIdMapOverrideAppConfig
.
put
(
targetAppId
,
overrideAppConfig
);
overrideAppConfigs
.
add
(
overrideAppConfig
);
}
overrideAppConfig
.
setAppId
(
targetAppId
);
overrideAppConfig
.
addConfig
(
config
);
}
}
//
for (ItemDTO config : clusterConfigs) {
//
String targetAppId = config.getAppId();
//
if (appId.equals(targetAppId)) {// app self's configs
//
defaultClusterConfigs.add(config);
//
} else {// override other app configs
//
if (appIdMapOverrideAppConfig == null) {
//
appIdMapOverrideAppConfig = new HashMap<>();
//
}
//
//
AppConfigVO.OverrideAppConfig overrideAppConfig =
//
appIdMapOverrideAppConfig.get(targetAppId);
//
//
if (overrideAppConfig == null) {
//
overrideAppConfig = new AppConfigVO.OverrideAppConfig();
//
appIdMapOverrideAppConfig.put(targetAppId, overrideAppConfig);
//
overrideAppConfigs.add(overrideAppConfig);
//
}
//
//
overrideAppConfig.setAppId(targetAppId);
//
overrideAppConfig.addConfig(config);
//
}
//
}
}
private
void
collectSpecialClusterConfigs
(
String
clusterName
,
List
<
ItemDTO
>
clusterConfigs
,
...
...
apollo-portal/src/test/java/com/ctrip/apollo/portal/service/ConfigServiceTest.java
View file @
9d2cf93e
...
...
@@ -187,7 +187,7 @@ public class ConfigServiceTest {
private
ReleaseDTO
assembleReleaseSnapShot
(
long
releaseId
,
String
clusterName
,
String
configurations
)
{
ReleaseDTO
releaseSnapShot
=
new
ReleaseDTO
();
releaseSnapShot
.
setReleaseId
(
releaseId
);
//
releaseSnapShot.setReleaseId(releaseId);
releaseSnapShot
.
setClusterName
(
clusterName
);
releaseSnapShot
.
setConfigurations
(
configurations
);
return
releaseSnapShot
;
...
...
@@ -221,9 +221,9 @@ public class ConfigServiceTest {
private
ItemDTO
assembleConfigItem
(
long
clusterId
,
String
clusterName
,
String
appId
,
String
key
,
String
value
)
{
ItemDTO
configItem
=
new
ItemDTO
();
configItem
.
setClusterName
(
clusterName
);
configItem
.
setClusterId
(
clusterId
);
configItem
.
setAppId
(
appId
);
//
configItem.setClusterName(clusterName);
//
configItem.setClusterId(clusterId);
//
configItem.setAppId(appId);
configItem
.
setKey
(
key
);
configItem
.
setValue
(
value
);
return
configItem
;
...
...
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