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
8463c359
Commit
8463c359
authored
Jun 12, 2016
by
Jason Song
Committed by
GitHub
Jun 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #259 from lepdou/0613_17
diff show deleted item & clogging
parents
76bd56d9
be9385c8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
164 additions
and
32 deletions
+164
-32
logback.xml
apollo-adminservice/src/main/resources/logback.xml
+1
-2
logback.xml
apollo-assembly/src/main/resources/logback.xml
+1
-2
BizLoggingCustomizer.java
.../framework/apollo/biz/customize/BizLoggingCustomizer.java
+38
-0
package-info.java
...om/ctrip/framework/apollo/biz/customize/package-info.java
+4
-0
LoggingCustomizer.java
.../framework/apollo/common/customize/LoggingCustomizer.java
+18
-23
TomcatContainerCustomizer.java
...rk/apollo/common/customize/TomcatContainerCustomizer.java
+1
-1
package-info.java
...ctrip/framework/apollo/common/customize/package-info.java
+4
-0
package-info.java
...trip/framework/apollo/common/datasource/package-info.java
+4
-0
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+2
-2
BizLoggingCustomizer.java
...amework/apollo/portal/cumsomize/BizLoggingCustomizer.java
+38
-0
package-info.java
...ctrip/framework/apollo/portal/cumsomize/package-info.java
+4
-0
PortalConfigService.java
.../framework/apollo/portal/service/PortalConfigService.java
+13
-2
PortalNamespaceService.java
...amework/apollo/portal/service/PortalNamespaceService.java
+32
-0
config.html
apollo-portal/src/main/resources/static/config.html
+0
-0
server_config.html
apollo-portal/src/main/resources/static/server_config.html
+1
-0
nav.html
...lo-portal/src/main/resources/static/views/common/nav.html
+3
-0
No files found.
apollo-adminservice/src/main/resources/logback.xml
View file @
8463c359
...
...
@@ -7,4 +7,4 @@
<root
level=
"INFO"
>
<appender-ref
ref=
"FILE"
/>
</root>
</configuration>
\ No newline at end of file
</configuration>
apollo-assembly/src/main/resources/logback.xml
View file @
8463c359
...
...
@@ -7,4 +7,4 @@
<root
level=
"INFO"
>
<appender-ref
ref=
"FILE"
/>
</root>
</configuration>
\ No newline at end of file
</configuration>
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/customize/BizLoggingCustomizer.java
0 → 100644
View file @
8463c359
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
customize
;
import
com.ctrip.framework.apollo.biz.repository.ServerConfigRepository
;
import
com.ctrip.framework.apollo.common.customize.LoggingCustomizer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.stereotype.Component
;
@Component
@Profile
(
"ctrip"
)
public
class
BizLoggingCustomizer
extends
LoggingCustomizer
{
private
static
final
String
CLOGGING_SERVER_URL_KEY
=
"clogging.server.url"
;
private
static
final
String
CLOGGING_SERVER_PORT_KEY
=
"clogging.server.port"
;
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
private
String
cloggingUrl
;
private
String
cloggingPort
;
@Override
protected
String
cloggingUrl
()
{
if
(
cloggingUrl
==
null
){
cloggingUrl
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_URL_KEY
).
getValue
();
}
return
cloggingUrl
;
}
@Override
protected
String
cloggingPort
()
{
if
(
cloggingPort
==
null
){
cloggingPort
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_PORT_KEY
).
getValue
();
}
return
cloggingPort
;
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/customize/package-info.java
0 → 100644
View file @
8463c359
/**
* 携程内部的日志系统,第三方公司可删除
*/
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
customize
;
apollo-
biz/src/main/java/com/ctrip/framework/apollo/biz
/customize/LoggingCustomizer.java
→
apollo-
common/src/main/java/com/ctrip/framework/apollo/common
/customize/LoggingCustomizer.java
View file @
8463c359
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
customize
;
package
com
.
ctrip
.
framework
.
apollo
.
common
.
customize
;
import
com.google.common.base.Strings
;
import
com.ctrip.framework.apollo.biz.entity.ServerConfig
;
import
com.ctrip.framework.apollo.biz.repository.ServerConfigRepository
;
import
com.ctrip.framework.foundation.Foundation
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
import
java.util.Objects
;
import
ch.qos.logback.classic.LoggerContext
;
import
ch.qos.logback.core.Appender
;
/**
* clogging config.only used in ctrip
* @author Jason Song(song_s@ctrip.com)
*/
@Component
public
class
LoggingCustomizer
implements
InitializingBean
{
public
abstract
class
LoggingCustomizer
implements
InitializingBean
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LoggingCustomizer
.
class
);
private
static
final
String
cLoggingAppenderClass
=
"com.ctrip.framework.clogging.agent.appender.CLoggingAppender"
;
private
static
boolean
cLoggingAppenderPresent
=
ClassUtils
.
isPresent
(
cLoggingAppenderClass
,
LoggingCustomizer
.
class
.
getClassLoader
());
private
static
final
String
CLOGGING_SERVER_URL_KEY
=
"clogging.server.url"
;
private
static
final
String
CLOGGING_SERVER_PORT_KEY
=
"clogging.server.port"
;
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
@Override
public
void
afterPropertiesSet
()
{
if
(!
cLoggingAppenderPresent
)
{
...
...
@@ -59,13 +48,6 @@ public class LoggingCustomizer implements InitializingBean {
return
;
}
ServerConfig
cloggingUrl
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_URL_KEY
);
ServerConfig
cloggingPort
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_PORT_KEY
);
if
(
Objects
.
isNull
(
cloggingUrl
)
||
Objects
.
isNull
(
cloggingPort
))
{
logger
.
warn
(
"CLogging config is not set!"
);
return
;
}
LoggerContext
loggerContext
=
(
LoggerContext
)
LoggerFactory
.
getILoggerFactory
();
Class
clazz
=
Class
.
forName
(
cLoggingAppenderClass
);
...
...
@@ -73,9 +55,9 @@ public class LoggingCustomizer implements InitializingBean {
ReflectionUtils
.
findMethod
(
clazz
,
"setAppId"
,
String
.
class
).
invoke
(
cLoggingAppender
,
appId
);
ReflectionUtils
.
findMethod
(
clazz
,
"setServerIp"
,
String
.
class
)
.
invoke
(
cLoggingAppender
,
cloggingUrl
.
getValue
());
.
invoke
(
cLoggingAppender
,
cloggingUrl
());
ReflectionUtils
.
findMethod
(
clazz
,
"setServerPort"
,
int
.
class
)
.
invoke
(
cLoggingAppender
,
Integer
.
parseInt
(
cloggingPort
.
getValue
()));
.
invoke
(
cLoggingAppender
,
Integer
.
parseInt
(
cloggingPort
()));
cLoggingAppender
.
setName
(
"CentralLogging"
);
cLoggingAppender
.
setContext
(
loggerContext
);
...
...
@@ -87,4 +69,17 @@ public class LoggingCustomizer implements InitializingBean {
}
/**
* clogging server url
* @return
*/
protected
abstract
String
cloggingUrl
();
/**
* clogging server port
* @return
*/
protected
abstract
String
cloggingPort
();
}
apollo-
biz/src/main/java/com/ctrip/framework/apollo/biz
/customize/TomcatContainerCustomizer.java
→
apollo-
common/src/main/java/com/ctrip/framework/apollo/common
/customize/TomcatContainerCustomizer.java
View file @
8463c359
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
customize
;
package
com
.
ctrip
.
framework
.
apollo
.
common
.
customize
;
import
org.apache.catalina.connector.Connector
;
import
org.apache.coyote.ProtocolHandler
;
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/customize/package-info.java
0 → 100644
View file @
8463c359
/**
* 携程内部的日志系统,第三方公司可删除
*/
package
com
.
ctrip
.
framework
.
apollo
.
common
.
customize
;
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/package-info.java
0 → 100644
View file @
8463c359
/**
* 携程内部的dal,第三方公司可替换实现
*/
package
com
.
ctrip
.
framework
.
apollo
.
common
.
datasource
;
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
8463c359
...
...
@@ -95,12 +95,12 @@ public class AdminServiceAPI {
@Service
public
static
class
ItemAPI
extends
API
{
public
List
<
ItemDTO
>
findItems
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
)
{
public
List
<
ItemDTO
>
findItems
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
Name
)
{
ItemDTO
[]
itemDTOs
=
restTemplate
.
getForObject
(
"{host}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
ItemDTO
[].
class
,
getAdminServiceHost
(
env
),
appId
,
clusterName
,
namespace
);
getAdminServiceHost
(
env
),
appId
,
clusterName
,
namespace
Name
);
return
Arrays
.
asList
(
itemDTOs
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/cumsomize/BizLoggingCustomizer.java
0 → 100644
View file @
8463c359
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
cumsomize
;
import
com.ctrip.framework.apollo.common.customize.LoggingCustomizer
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.stereotype.Component
;
@Component
@Profile
(
"ctrip"
)
public
class
BizLoggingCustomizer
extends
LoggingCustomizer
{
private
static
final
String
CLOGGING_SERVER_URL_KEY
=
"clogging.server.url"
;
private
static
final
String
CLOGGING_SERVER_PORT_KEY
=
"clogging.server.port"
;
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
private
String
cloggingUrl
;
private
String
cloggingPort
;
@Override
protected
String
cloggingUrl
()
{
if
(
cloggingUrl
==
null
){
cloggingUrl
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_URL_KEY
).
getValue
();
}
return
cloggingUrl
;
}
@Override
protected
String
cloggingPort
()
{
if
(
cloggingPort
==
null
){
cloggingPort
=
serverConfigRepository
.
findByKey
(
CLOGGING_SERVER_PORT_KEY
).
getValue
();
}
return
cloggingPort
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/cumsomize/package-info.java
0 → 100644
View file @
8463c359
/**
* 携程内部的日志系统,第三方公司可删除
*/
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
cumsomize
;
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java
View file @
8463c359
...
...
@@ -168,13 +168,14 @@ public class PortalConfigService {
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
());
long
namespaceId
=
getNamespaceId
(
namespace
);
if
(
CollectionUtils
.
isEmpty
(
targetItems
))
{
//all source items is added
int
lineNum
=
1
;
for
(
ItemDTO
sourceItem
:
sourceItems
)
{
changeSets
.
addCreateItem
(
buildItem
(
namespaceId
,
lineNum
++,
sourceItem
));
}
}
else
{
Map
<
String
,
ItemDTO
>
keyMapItem
=
BeanUtils
.
mapByKey
(
"key"
,
targetItems
);
Map
<
String
,
ItemDTO
>
targetItemMap
=
BeanUtils
.
mapByKey
(
"key"
,
targetItems
);
String
key
,
sourceValue
,
sourceComment
;
ItemDTO
targetItem
=
null
;
int
maxLineNum
=
targetItems
.
size
();
//append to last
...
...
@@ -182,7 +183,7 @@ public class PortalConfigService {
key
=
sourceItem
.
getKey
();
sourceValue
=
sourceItem
.
getValue
();
sourceComment
=
sourceItem
.
getComment
();
targetItem
=
keyMapItem
.
get
(
key
);
targetItem
=
targetItemMap
.
get
(
key
);
if
(
targetItem
==
null
)
{
//added items
...
...
@@ -196,6 +197,16 @@ public class PortalConfigService {
}
}
//parse deleted items
List
<
ItemDTO
>
deletedItems
=
new
LinkedList
<>();
Map
<
String
,
ItemDTO
>
sourceItemMap
=
BeanUtils
.
mapByKey
(
"key"
,
sourceItems
);
for
(
ItemDTO
targetItem:
targetItems
){
if
(
sourceItemMap
.
get
(
targetItem
.
getKey
())
==
null
){
deletedItems
.
add
(
targetItem
);
}
}
changeSets
.
setDeleteItems
(
deletedItems
);
return
changeSets
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalNamespaceService.java
View file @
8463c359
...
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.service;
import
com.google.gson.Gson
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.ExceptionUtils
;
import
com.ctrip.framework.apollo.core.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
...
...
@@ -139,17 +140,48 @@ public class PortalNamespaceService {
itemVos
.
add
(
itemVO
);
}
//deleted items
List
<
NamespaceVO
.
ItemVO
>
deletedItems
=
countDeletedItemNum
(
items
,
releaseItems
);
itemVos
.
addAll
(
deletedItems
);
modifiedItemCnt
+=
deletedItems
.
size
();
namespaceVO
.
setItemModifiedCnt
(
modifiedItemCnt
);
return
namespaceVO
;
}
private
List
<
NamespaceVO
.
ItemVO
>
countDeletedItemNum
(
List
<
ItemDTO
>
newItems
,
Map
<
String
,
String
>
releaseItems
)
{
Map
<
String
,
ItemDTO
>
newItemMap
=
BeanUtils
.
mapByKey
(
"key"
,
newItems
);
List
<
NamespaceVO
.
ItemVO
>
deletedItems
=
new
LinkedList
<>();
for
(
Map
.
Entry
<
String
,
String
>
entry:
releaseItems
.
entrySet
()){
String
key
=
entry
.
getKey
();
if
(
newItemMap
.
get
(
key
)
==
null
){
NamespaceVO
.
ItemVO
deletedItem
=
new
NamespaceVO
.
ItemVO
();
ItemDTO
deletedItemDto
=
new
ItemDTO
();
deletedItemDto
.
setKey
(
key
);
String
oldValue
=
entry
.
getValue
();
deletedItem
.
setItem
(
deletedItemDto
);
deletedItemDto
.
setValue
(
oldValue
);
deletedItem
.
setModified
(
true
);
deletedItem
.
setOldValue
(
oldValue
);
deletedItem
.
setNewValue
(
""
);
deletedItems
.
add
(
deletedItem
);
}
}
return
deletedItems
;
}
private
NamespaceVO
.
ItemVO
parseItemVO
(
ItemDTO
itemDTO
,
Map
<
String
,
String
>
releaseItems
)
{
String
key
=
itemDTO
.
getKey
();
NamespaceVO
.
ItemVO
itemVO
=
new
NamespaceVO
.
ItemVO
();
itemVO
.
setItem
(
itemDTO
);
String
newValue
=
itemDTO
.
getValue
();
String
oldValue
=
releaseItems
.
get
(
key
);
//new item or modified
if
(!
StringUtils
.
isEmpty
(
key
)
&&
(
oldValue
==
null
||
!
newValue
.
equals
(
oldValue
)))
{
itemVO
.
setModified
(
true
);
itemVO
.
setOldValue
(
oldValue
==
null
?
""
:
oldValue
);
...
...
apollo-portal/src/main/resources/static/config.html
View file @
8463c359
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/server_config.html
View file @
8463c359
...
...
@@ -83,6 +83,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/ServerConfigService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/ServerConfigController.js"
></script>
...
...
apollo-portal/src/main/resources/static/views/common/nav.html
View file @
8463c359
...
...
@@ -10,6 +10,9 @@
<div
class=
"collapse navbar-collapse"
id=
"bs-example-navbar-collapse-1"
>
<ul
class=
"nav navbar-nav navbar-right"
>
<li><a
href=
"http://conf.ctripcorp.com/pages/viewpage.action?pageId=98435462"
target=
"_blank"
>
help
</span>
</a></li>
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-haspopup=
"true"
aria-expanded=
"false"
>
{{userName}}
<span
class=
"caret"
></span></a>
...
...
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