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
b9057d27
Commit
b9057d27
authored
Dec 26, 2016
by
Jason Song
Committed by
GitHub
Dec 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #499 from lepdou/1221
return default cluster's namespace when custom cluster's namespace ne…
parents
bae4505f
33ad4945
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
42 deletions
+80
-42
NamespaceController.java
...k/apollo/adminservice/controller/NamespaceController.java
+5
-4
NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+43
-9
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+3
-3
ConfigPublishEmailBuilder.java
...al/components/emailbuilder/ConfigPublishEmailBuilder.java
+1
-1
NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+4
-4
NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+13
-15
namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+4
-1
ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+5
-4
namespace-panel-master-tab.html
...es/static/views/component/namespace-panel-master-tab.html
+2
-1
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
View file @
b9057d27
...
...
@@ -79,10 +79,11 @@ public class NamespaceController {
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
}
@RequestMapping
(
"/clusters/{clusterName}/namespaces/{namespaceName}/public"
)
public
NamespaceDTO
findPublicNamespace
(
@PathVariable
String
clusterName
,
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
)
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findPublicNamespace
(
clusterName
,
namespaceName
);
Namespace
namespace
=
namespaceService
.
findPublicNamespace
ForAssociatedNamespace
(
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"public namespace not found. namespace:%s"
,
namespaceName
));
...
...
@@ -95,7 +96,7 @@ public class NamespaceController {
* cluster -> cluster has not published namespaces?
*/
@RequestMapping
(
"/apps/{appId}/namespaces/publish_info"
)
public
Map
<
String
,
Boolean
>
namespacePublishInfo
(
@PathVariable
String
appId
){
public
Map
<
String
,
Boolean
>
namespacePublishInfo
(
@PathVariable
String
appId
)
{
return
namespaceService
.
namespacePublishInfo
(
appId
);
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
b9057d27
...
...
@@ -59,7 +59,6 @@ public class NamespaceService {
private
InstanceService
instanceService
;
public
Namespace
findOne
(
Long
namespaceId
)
{
return
namespaceRepository
.
findOne
(
namespaceId
);
}
...
...
@@ -69,7 +68,7 @@ public class NamespaceService {
namespaceName
);
}
public
Namespace
findPublicNamespace
(
String
clusterName
,
String
namespaceName
)
{
public
Namespace
findPublicNamespace
ForAssociatedNamespace
(
String
clusterName
,
String
namespaceName
)
{
AppNamespace
appNamespace
=
appNamespaceService
.
findPublicNamespaceByName
(
namespaceName
);
if
(
appNamespace
==
null
)
{
throw
new
BadRequestException
(
"namespace not exist"
);
...
...
@@ -79,13 +78,48 @@ public class NamespaceService {
Namespace
namespace
=
findOne
(
appId
,
clusterName
,
namespaceName
);
//default cluster's namespace
if
(
Objects
.
equals
(
clusterName
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
))
{
return
namespace
;
}
//custom cluster's namespace not exist.
//return default cluster's namespace
if
(
namespace
==
null
)
{
namespace
=
findOne
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
namespaceName
);
return
findOne
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
namespaceName
);
}
//custom cluster's namespace exist and has published.
//return custom cluster's namespace
Release
latestActiveRelease
=
releaseService
.
findLatestActiveRelease
(
namespace
);
if
(
latestActiveRelease
!=
null
)
{
return
namespace
;
}
Namespace
defaultNamespace
=
findOne
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
namespaceName
);
//custom cluster's namespace exist but never published.
//and default cluster's namespace not exist.
//return custom cluster's namespace
if
(
defaultNamespace
==
null
)
{
return
namespace
;
}
//custom cluster's namespace exist but never published.
//and default cluster's namespace exist and has published.
//return default cluster's namespace
Release
defaultNamespaceLatestActiveRelease
=
releaseService
.
findLatestActiveRelease
(
defaultNamespace
);
if
(
defaultNamespaceLatestActiveRelease
!=
null
)
{
return
defaultNamespace
;
}
//custom cluster's namespace exist but never published.
//and default cluster's namespace exist but never published.
//return custom cluster's namespace
return
namespace
;
}
public
List
<
Namespace
>
findNamespaces
(
String
appId
,
String
clusterName
)
{
List
<
Namespace
>
namespaces
=
namespaceRepository
.
findByAppIdAndClusterNameOrderByIdAsc
(
appId
,
clusterName
);
if
(
namespaces
==
null
)
{
...
...
@@ -129,7 +163,7 @@ public class NamespaceService {
}
public
Namespace
findParentNamespace
(
String
appId
,
String
clusterName
,
String
namespaceName
){
public
Namespace
findParentNamespace
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
findParentNamespace
(
new
Namespace
(
appId
,
clusterName
,
namespaceName
));
}
...
...
@@ -146,7 +180,7 @@ public class NamespaceService {
return
null
;
}
public
boolean
isChildNamespace
(
String
appId
,
String
clusterName
,
String
namespaceName
){
public
boolean
isChildNamespace
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
isChildNamespace
(
new
Namespace
(
appId
,
clusterName
,
namespaceName
));
}
...
...
@@ -268,10 +302,10 @@ public class NamespaceService {
String
clusterName
=
cluster
.
getName
();
List
<
Namespace
>
namespaces
=
findNamespaces
(
appId
,
clusterName
);
for
(
Namespace
namespace:
namespaces
)
{
for
(
Namespace
namespace
:
namespaces
)
{
boolean
isNamespaceNotPublished
=
isNamespaceNotPublished
(
namespace
);
if
(
isNamespaceNotPublished
){
if
(
isNamespaceNotPublished
)
{
clusterHasNotPublishedItems
.
put
(
clusterName
,
true
);
break
;
}
...
...
@@ -301,8 +335,8 @@ public class NamespaceService {
}
Map
<
String
,
String
>
publishedConfiguration
=
gson
.
fromJson
(
latestRelease
.
getConfigurations
(),
GsonType
.
CONFIG
);
for
(
Item
item:
itemsModifiedAfterLastPublish
)
{
if
(!
Objects
.
equals
(
item
.
getValue
(),
publishedConfiguration
.
get
(
item
.
getKey
()))){
for
(
Item
item
:
itemsModifiedAfterLastPublish
)
{
if
(!
Objects
.
equals
(
item
.
getValue
(),
publishedConfiguration
.
get
(
item
.
getKey
())))
{
return
true
;
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
b9057d27
...
...
@@ -81,10 +81,10 @@ public class AdminServiceAPI {
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
loadPublicNamespace
(
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"
/clusters/{clusterName}/namespaces/{namespaceName}/public
"
,
NamespaceDTO
.
class
,
clusterName
,
namespaceName
);
restTemplate
.
get
(
env
,
"
apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace
"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
createNamespace
(
Env
env
,
NamespaceDTO
namespace
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/emailbuilder/ConfigPublishEmailBuilder.java
View file @
b9057d27
...
...
@@ -58,7 +58,7 @@ public abstract class ConfigPublishEmailBuilder {
//set config's value max length to protect email.
protected
static
final
int
VALUE_MAX_LENGTH
=
100
;
pr
ivate
FastDateFormat
dateFormat
=
FastDateFormat
.
getInstance
(
"yyyy-MM-dd hh
:mm:ss"
);
pr
otected
FastDateFormat
dateFormat
=
FastDateFormat
.
getInstance
(
"yyyy-MM-dd HH
:mm:ss"
);
@Autowired
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
b9057d27
...
...
@@ -81,12 +81,13 @@ public class NamespaceController {
return
namespaceService
.
loadNamespaceBO
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
@RequestMapping
(
"/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/public"
)
public
NamespaceBO
findPublicNamespace
(
@PathVariable
String
env
,
@RequestMapping
(
"/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
)
public
NamespaceBO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
env
,
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
)
{
return
namespaceService
.
loadPublicNamespaceBO
(
Env
.
valueOf
(
env
)
,
clusterName
,
namespaceName
);
return
namespaceService
.
findPublicNamespaceForAssociatedNamespace
(
Env
.
valueOf
(
env
),
appId
,
clusterName
,
namespaceName
);
}
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateNamespacePermission(#appId)"
)
...
...
@@ -176,7 +177,6 @@ public class NamespaceController {
* dev ->
* default -> true (default cluster has not published namespace)
* customCluster -> false (customCluster cluster's all namespaces had published)
*
*/
@RequestMapping
(
"/apps/{appId}/namespaces/publish_info"
)
public
Map
<
String
,
Map
<
String
,
Boolean
>>
getNamespacesPublishInfo
(
@PathVariable
String
appId
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
b9057d27
...
...
@@ -11,7 +11,6 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
...
...
@@ -26,10 +25,8 @@ import com.ctrip.framework.apollo.tracer.Tracer;
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.transaction.annotation.Transactional
;
import
org.springframework.web.client.HttpClientErrorException
;
import
java.util.*
;
...
...
@@ -104,9 +101,9 @@ public class NamespaceService {
List
<
NamespaceBO
>
namespaceBOs
=
new
LinkedList
<>();
for
(
NamespaceDTO
namespace
:
namespaces
)
{
NamespaceBO
namespaceBO
=
null
;
NamespaceBO
namespaceBO
;
try
{
namespaceBO
=
transformNamespace2BO
(
appId
,
env
,
clusterName
,
namespace
);
namespaceBO
=
transformNamespace2BO
(
env
,
namespace
);
namespaceBOs
.
add
(
namespaceBO
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}"
,
...
...
@@ -123,16 +120,15 @@ public class NamespaceService {
if
(
namespace
==
null
)
{
throw
new
BadRequestException
(
"namespaces not exist"
);
}
return
transformNamespace2BO
(
appId
,
env
,
clusterName
,
namespace
);
return
transformNamespace2BO
(
env
,
namespace
);
}
public
NamespaceBO
loadPublicNamespaceBO
(
Env
env
,
String
clusterName
,
String
namespaceName
)
{
NamespaceDTO
namespace
=
namespaceAPI
.
loadPublicNamespace
(
env
,
clusterName
,
namespaceName
);
public
NamespaceBO
findPublicNamespaceForAssociatedNamespace
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
)
{
NamespaceDTO
namespace
=
namespaceAPI
.
findPublicNamespaceForAssociatedNamespace
(
env
,
appId
,
clusterName
,
namespaceName
);
String
appId
=
namespace
.
getAppId
();
String
actualClusterName
=
namespace
.
getClusterName
();
return
transformNamespace2BO
(
appId
,
env
,
actualClusterName
,
namespace
);
return
transformNamespace2BO
(
env
,
namespace
);
}
public
Map
<
String
,
Map
<
String
,
Boolean
>>
getNamespacesPublishInfo
(
String
appId
)
{
...
...
@@ -148,19 +144,21 @@ public class NamespaceService {
return
result
;
}
private
NamespaceBO
transformNamespace2BO
(
String
appId
,
Env
env
,
String
clusterName
,
NamespaceDTO
namespace
)
{
private
NamespaceBO
transformNamespace2BO
(
Env
env
,
NamespaceDTO
namespace
)
{
NamespaceBO
namespaceBO
=
new
NamespaceBO
();
namespaceBO
.
setBaseInfo
(
namespace
);
String
appId
=
namespace
.
getAppId
();
String
clusterName
=
namespace
.
getClusterName
();
String
namespaceName
=
namespace
.
getNamespaceName
();
fillAppNamespaceProperties
(
namespaceBO
);
List
<
ItemBO
>
itemBOs
=
new
LinkedList
<>();
namespaceBO
.
setItems
(
itemBOs
);
String
namespaceName
=
namespace
.
getNamespaceName
();
//latest Release
ReleaseDTO
latestRelease
=
null
;
ReleaseDTO
latestRelease
;
Map
<
String
,
String
>
releaseItems
=
new
HashMap
<>();
latestRelease
=
releaseService
.
loadLatestRelease
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
latestRelease
!=
null
)
{
...
...
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
View file @
b9057d27
...
...
@@ -227,7 +227,8 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
return
;
}
//load public namespace
ConfigService
.
load_public_namespace
(
scope
.
env
,
scope
.
cluster
,
namespace
.
baseInfo
.
namespaceName
)
ConfigService
.
load_public_namespace_for_associated_namespace
(
scope
.
env
,
scope
.
appId
,
scope
.
cluster
,
namespace
.
baseInfo
.
namespaceName
)
.
then
(
function
(
result
)
{
var
publicNamespace
=
result
;
namespace
.
publicNamespace
=
publicNamespace
;
...
...
@@ -429,6 +430,8 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
namespace
.
latestReleaseInstances
=
result
;
namespace
.
latestReleaseInstancesPage
++
;
})
namespace
.
isLatestReleaseLoaded
=
true
;
});
}
else
{
InstanceService
.
findInstancesByRelease
(
scope
.
env
,
...
...
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
View file @
b9057d27
...
...
@@ -5,10 +5,10 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
isArray
:
false
,
url
:
'/apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName'
},
load_public_namespace
:
{
load_public_namespace
_for_associated_namespace
:
{
method
:
'GET'
,
isArray
:
false
,
url
:
'/envs/:env/
clusters/:clusterName/namespaces/:namespaceName/public
'
url
:
'/envs/:env/
apps/:appId/clusters/:clusterName/namespaces/:namespaceName/associated-public-namespace
'
},
load_all_namespaces
:
{
method
:
'GET'
,
...
...
@@ -63,10 +63,11 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
});
return
d
.
promise
;
},
load_public_namespace
:
function
(
env
,
clusterName
,
namespaceName
)
{
load_public_namespace
_for_associated_namespace
:
function
(
env
,
appId
,
clusterName
,
namespaceName
)
{
var
d
=
$q
.
defer
();
config_source
.
load_public_namespace
({
config_source
.
load_public_namespace
_for_associated_namespace
({
env
:
env
,
appId
:
appId
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
},
function
(
result
)
{
...
...
apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html
View file @
b9057d27
...
...
@@ -163,7 +163,8 @@
<!--table view-->
<div
class=
"namespace-view-table"
ng-show=
"namespace.viewType == 'table'"
>
<div
class=
"well well-sm no-radius text-center"
ng-show=
"!namespace.isLinkedNamespace && !namespace.latestRelease"
>
<div
class=
"J_namespace-release-tip well well-sm no-radius text-center"
ng-show=
"namespace.isLatestReleaseLoaded && !namespace.isLinkedNamespace && !namespace.latestRelease"
>
<span
style=
"color: red"
>
Tips: 此namespace从来没有发布过,Apollo客户端将获取不到配置并记录404日志信息,请及时发布。
</span>
</div>
<!--not link namespace-->
...
...
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