Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
73ce069f
Commit
73ce069f
authored
Dec 05, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor trace related code to make CAT dependency optional
parent
804eb991
Changes
190
Show whitespace changes
Inline
Side-by-side
Showing
190 changed files
with
1371 additions
and
1108 deletions
+1371
-1108
apollo-adminservice/pom.xml
apollo-adminservice/pom.xml
+1
-11
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java
...work/apollo/adminservice/AdminServiceHealthIndicator.java
+2
-2
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
...amework/apollo/adminservice/controller/AppController.java
+10
-10
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
...pollo/adminservice/controller/AppNamespaceController.java
+8
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
...ork/apollo/adminservice/controller/ClusterController.java
+8
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
...work/apollo/adminservice/controller/CommitController.java
+1
-1
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+11
-11
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetController.java
...ork/apollo/adminservice/controller/ItemSetController.java
+4
-4
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
...k/apollo/adminservice/controller/NamespaceController.java
+8
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
...ollo/adminservice/controller/NamespaceLockController.java
+1
-1
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseController.java
...ork/apollo/adminservice/controller/ReleaseController.java
+1
-1
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/AdminServiceTestConfiguration.java
...ctrip/framework/apollo/AdminServiceTestConfiguration.java
+1
-2
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AbstractControllerTest.java
...pollo/adminservice/controller/AbstractControllerTest.java
+2
-2
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java
...ork/apollo/adminservice/controller/AppControllerTest.java
+5
-5
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceControllerTest.java
...o/adminservice/controller/AppNamespaceControllerTest.java
+1
-1
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java
...ollo/adminservice/controller/ControllerExceptionTest.java
+11
-11
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerIntegrationExceptionTest.java
...ervice/controller/ControllerIntegrationExceptionTest.java
+8
-8
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java
...apollo/adminservice/controller/ItemSetControllerTest.java
+8
-8
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseControllerTest.java
...apollo/adminservice/controller/ReleaseControllerTest.java
+1
-1
apollo-adminservice/src/test/resources/META-INF/plexus/plexus.xml
...dminservice/src/test/resources/META-INF/plexus/plexus.xml
+0
-42
apollo-assembly/pom.xml
apollo-assembly/pom.xml
+1
-6
apollo-assembly/src/main/java/com/ctrip/framework/apollo/assembly/ApolloApplication.java
...om/ctrip/framework/apollo/assembly/ApolloApplication.java
+4
-4
apollo-assembly/src/main/resources/META-INF/plexus/plexus.xml
...lo-assembly/src/main/resources/META-INF/plexus/plexus.xml
+0
-42
apollo-assembly/src/test/java/com/ctrip/framework/apollo/assembly/LocalApolloApplication.java
...rip/framework/apollo/assembly/LocalApolloApplication.java
+4
-4
apollo-biz/pom.xml
apollo-biz/pom.xml
+1
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java
...ain/java/com/ctrip/framework/apollo/biz/entity/Audit.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java
...n/java/com/ctrip/framework/apollo/biz/entity/Cluster.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java
...om/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java
+0
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java
...main/java/com/ctrip/framework/apollo/biz/entity/Item.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java
...java/com/ctrip/framework/apollo/biz/entity/Namespace.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java
...java/com/ctrip/framework/apollo/biz/entity/Privilege.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java
...rk/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java
+6
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java
...p/framework/apollo/biz/message/DatabaseMessageSender.java
+5
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java
...p/framework/apollo/biz/message/ReleaseMessageScanner.java
+6
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java
...amework/apollo/biz/repository/AppNamespaceRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java
.../ctrip/framework/apollo/biz/repository/AppRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java
...trip/framework/apollo/biz/repository/AuditRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java
...work/apollo/biz/repository/GrayReleaseRuleRepository.java
+1
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java
.../framework/apollo/biz/repository/NamespaceRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java
.../framework/apollo/biz/repository/PrivilegeRepository.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java
...ip/framework/apollo/biz/repository/ReleaseRepository.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java
.../com/ctrip/framework/apollo/biz/service/AdminService.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
...rip/framework/apollo/biz/service/AppNamespaceService.java
+1
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
...va/com/ctrip/framework/apollo/biz/service/AppService.java
+7
-7
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java
.../com/ctrip/framework/apollo/biz/service/AuditService.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+9
-9
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java
...m/ctrip/framework/apollo/biz/service/InstanceService.java
+0
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+5
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+6
-6
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+12
-12
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java
...p/framework/apollo/biz/service/ReleaseMessageService.java
+2
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java
...ramework/apollo/biz/utils/ConfigChangeContentBuilder.java
+0
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
...ip/framework/apollo/biz/repository/AppRepositoryTest.java
+3
-3
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java
.../ctrip/framework/apollo/biz/service/AdminServiceTest.java
+9
-9
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java
...ework/apollo/biz/service/AdminServiceTransactionTest.java
+7
-7
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java
...trip/framework/apollo/biz/service/ClusterServiceTest.java
+4
-4
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java
...mework/apollo/biz/service/NamespaceBranchServiceTest.java
+0
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/PrivilegeServiceTest.java
...ip/framework/apollo/biz/service/PrivilegeServiceTest.java
+7
-7
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
...rip/framework/apollo/biz/service/ReleaseCreationTest.java
+0
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java
...framework/apollo/biz/service/ServerConfigServiceTest.java
+2
-1
apollo-biz/src/test/resources/META-INF/plexus/plexus.xml
apollo-biz/src/test/resources/META-INF/plexus/plexus.xml
+0
-42
apollo-buildtools/pom.xml
apollo-buildtools/pom.xml
+1
-11
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullClientConfigManager.java
...m/ctrip/framework/apollo/cat/NullClientConfigManager.java
+0
-57
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullLoggerManager.java
...ava/com/ctrip/framework/apollo/cat/NullLoggerManager.java
+0
-8
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullMessageManager.java
...va/com/ctrip/framework/apollo/cat/NullMessageManager.java
+0
-111
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullTransportManager.java
.../com/ctrip/framework/apollo/cat/NullTransportManager.java
+0
-33
apollo-client/pom.xml
apollo-client/pom.xml
+20
-30
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
...c/main/java/com/ctrip/framework/apollo/ConfigService.java
+3
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
.../com/ctrip/framework/apollo/internals/AbstractConfig.java
+18
-19
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
.../ctrip/framework/apollo/internals/AbstractConfigFile.java
+3
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
.../framework/apollo/internals/AbstractConfigRepository.java
+3
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
...trip/framework/apollo/internals/ConfigServiceLocator.java
+7
-8
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
...a/com/ctrip/framework/apollo/internals/DefaultConfig.java
+4
-4
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
...framework/apollo/internals/LocalFileConfigRepository.java
+14
-15
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java
...trip/framework/apollo/internals/PropertiesConfigFile.java
+2
-2
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
...amework/apollo/internals/RemoteConfigLongPollService.java
+7
-8
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
...ip/framework/apollo/internals/RemoteConfigRepository.java
+13
-14
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
...va/com/ctrip/framework/apollo/internals/SimpleConfig.java
+3
-3
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
.../java/com/ctrip/framework/apollo/BaseIntegrationTest.java
+1
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
.../framework/apollo/internals/DefaultConfigManagerTest.java
+0
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java
...om/ctrip/framework/apollo/internals/SimpleConfigTest.java
+0
-4
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
...m/ctrip/framework/apollo/internals/XmlConfigFileTest.java
+4
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
...va/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
+1
-1
apollo-client/src/test/resources/META-INF/plexus/plexus.xml
apollo-client/src/test/resources/META-INF/plexus/plexus.xml
+0
-42
apollo-common/pom.xml
apollo-common/pom.xml
+1
-1
apollo-common/src/main/java/com/ctrip/framework/apollo/common/aop/RepositoryAspect.java
...m/ctrip/framework/apollo/common/aop/RepositoryAspect.java
+4
-5
apollo-common/src/main/java/com/ctrip/framework/apollo/common/constants/GsonType.java
...com/ctrip/framework/apollo/common/constants/GsonType.java
+0
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/ApolloInfoController.java
...mework/apollo/common/controller/ApolloInfoController.java
+3
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CatConfig.java
...m/ctrip/framework/apollo/common/controller/CatConfig.java
+0
-26
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CharacterEncodingFilterConfiguration.java
...mmon/controller/CharacterEncodingFilterConfiguration.java
+2
-2
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java
...ollo/common/controller/GlobalDefaultExceptionHandler.java
+2
-2
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java
...trip/framework/apollo/common/controller/WebMvcConfig.java
+2
-2
apollo-common/src/main/java/com/ctrip/framework/apollo/common/customize/LoggingCustomizer.java
.../framework/apollo/common/customize/LoggingCustomizer.java
+2
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanCondition.java
...ip/framework/apollo/common/datasource/TitanCondition.java
+2
-2
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanEntityManager.java
...ramework/apollo/common/datasource/TitanEntityManager.java
+5
-5
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanSettings.java
...rip/framework/apollo/common/datasource/TitanSettings.java
+3
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java
...p/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java
+0
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java
.../com/ctrip/framework/apollo/common/entity/BaseEntity.java
+3
-3
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java
...va/com/ctrip/framework/apollo/common/utils/BeanUtils.java
+4
-4
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/ExceptionUtils.java
...m/ctrip/framework/apollo/common/utils/ExceptionUtils.java
+5
-5
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java
...rip/framework/apollo/common/utils/UniqueKeyGenerator.java
+0
-1
apollo-common/src/test/java/com/ctrip/framework/apollo/common/utils/InputValidatorTest.java
...rip/framework/apollo/common/utils/InputValidatorTest.java
+2
-1
apollo-configservice/pom.xml
apollo-configservice/pom.xml
+1
-11
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigController.java
...ork/apollo/configservice/controller/ConfigController.java
+4
-4
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileController.java
...apollo/configservice/controller/ConfigFileController.java
+5
-5
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationController.java
...ollo/configservice/controller/NotificationController.java
+3
-3
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
...lo/configservice/controller/NotificationControllerV2.java
+5
-5
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/util/InstanceConfigAuditUtil.java
...rk/apollo/configservice/util/InstanceConfigAuditUtil.java
+2
-2
apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DiscoveryService.java
...ramework/apollo/metaservice/service/DiscoveryService.java
+4
-4
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/ConfigControllerTest.java
...apollo/configservice/controller/ConfigControllerTest.java
+2
-2
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileControllerTest.java
...lo/configservice/controller/ConfigFileControllerTest.java
+0
-1
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerTest.java
.../configservice/controller/NotificationControllerTest.java
+0
-2
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/util/NamespaceUtilTest.java
...ramework/apollo/configservice/util/NamespaceUtilTest.java
+1
-1
apollo-configservice/src/test/resources/META-INF/plexus/plexus.xml
...nfigservice/src/test/resources/META-INF/plexus/plexus.xml
+0
-42
apollo-core/pom.xml
apollo-core/pom.xml
+17
-5
apollo-core/src/main/java/com/ctrip/framework/apollo/core/MetaDomainConsts.java
...ava/com/ctrip/framework/apollo/core/MetaDomainConsts.java
+3
-3
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ClassLoaderUtil.java
...om/ctrip/framework/apollo/core/utils/ClassLoaderUtil.java
+9
-1
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ResourceUtils.java
.../com/ctrip/framework/apollo/core/utils/ResourceUtils.java
+3
-3
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ServiceBootstrap.java
...m/ctrip/framework/apollo/core/utils/ServiceBootstrap.java
+22
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/Tracer.java
...c/main/java/com/ctrip/framework/apollo/tracer/Tracer.java
+84
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/DefaultMessageProducerManager.java
...pollo/tracer/internals/DefaultMessageProducerManager.java
+27
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducer.java
...ramework/apollo/tracer/internals/NullMessageProducer.java
+32
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerManager.java
...k/apollo/tracer/internals/NullMessageProducerManager.java
+16
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullTransaction.java
...ip/framework/apollo/tracer/internals/NullTransaction.java
+24
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatMessageProducer.java
...ework/apollo/tracer/internals/cat/CatMessageProducer.java
+84
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatNames.java
...ctrip/framework/apollo/tracer/internals/cat/CatNames.java
+16
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatTransaction.java
...framework/apollo/tracer/internals/cat/CatTransaction.java
+76
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/MessageProducer.java
...om/ctrip/framework/apollo/tracer/spi/MessageProducer.java
+46
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/MessageProducerManager.java
...p/framework/apollo/tracer/spi/MessageProducerManager.java
+11
-0
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/Transaction.java
...va/com/ctrip/framework/apollo/tracer/spi/Transaction.java
+32
-0
apollo-core/src/main/resources/META-INF/services/com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
....ctrip.framework.apollo.tracer.spi.MessageProducerManager
+1
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java
...re/src/test/java/com/ctrip/framework/apollo/AllTests.java
+20
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/core/AllTests.java
...c/test/java/com/ctrip/framework/apollo/core/AllTests.java
+0
-11
apollo-core/src/test/java/com/ctrip/framework/apollo/core/utils/ServiceBootstrapTest.java
...rip/framework/apollo/core/utils/ServiceBootstrapTest.java
+56
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/TracerTest.java
...st/java/com/ctrip/framework/apollo/tracer/TracerTest.java
+144
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/DefaultMessageProducerManagerTest.java
...o/tracer/internals/DefaultMessageProducerManagerTest.java
+26
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/MockMessageProducerManager.java
...k/apollo/tracer/internals/MockMessageProducerManager.java
+20
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerManagerTest.java
...ollo/tracer/internals/NullMessageProducerManagerTest.java
+25
-0
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerTest.java
...work/apollo/tracer/internals/NullMessageProducerTest.java
+28
-0
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface1
...amework.apollo.core.utils.ServiceBootstrapTest$Interface1
+1
-0
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface3
...amework.apollo.core.utils.ServiceBootstrapTest$Interface3
+0
-0
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface4
...amework.apollo.core.utils.ServiceBootstrapTest$Interface4
+1
-0
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface5
...amework.apollo.core.utils.ServiceBootstrapTest$Interface5
+1
-0
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
....ctrip.framework.apollo.tracer.spi.MessageProducerManager
+1
-0
apollo-core/src/test/resources/log4j2.xml
apollo-core/src/test/resources/log4j2.xml
+19
-0
apollo-demo/pom.xml
apollo-demo/pom.xml
+1
-1
apollo-portal/pom.xml
apollo-portal/pom.xml
+1
-11
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java
...trip/framework/apollo/openapi/util/ConsumerAuditUtil.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+0
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/AdminServiceAddressLocator.java
.../apollo/portal/components/AdminServiceAddressLocator.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/PermissionValidator.java
...amework/apollo/portal/components/PermissionValidator.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/RetryableRestTemplate.java
...ework/apollo/portal/components/RetryableRestTemplate.java
+10
-11
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java
...framework/apollo/portal/controller/ClusterController.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
...ip/framework/apollo/portal/controller/ItemController.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+4
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java
...mework/apollo/portal/controller/PermissionController.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
...work/apollo/portal/controller/ServerConfigController.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
...ramework/apollo/portal/controller/UserInfoController.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java
...ip/framework/apollo/portal/listener/CreationListener.java
+4
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
.../framework/apollo/portal/service/AppNamespaceService.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
...com/ctrip/framework/apollo/portal/service/AppService.java
+3
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java
...ctrip/framework/apollo/portal/service/ClusterService.java
+3
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
...trip/framework/apollo/portal/service/FavoriteService.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java
...om/ctrip/framework/apollo/portal/service/ItemService.java
+7
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
...amework/apollo/portal/service/NamespaceBranchService.java
+7
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+3
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
...ctrip/framework/apollo/portal/service/ReleaseService.java
+3
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java
...work/apollo/portal/service/RoleInitializationService.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
...rk/apollo/portal/spi/configuration/AuthConfiguration.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripLogoutHandler.java
...framework/apollo/portal/spi/ctrip/CtripLogoutHandler.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserInfoHolder.java
...ramework/apollo/portal/spi/ctrip/CtripUserInfoHolder.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/WebContextConfiguration.java
...work/apollo/portal/spi/ctrip/WebContextConfiguration.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/filters/RecordAccessUserFilter.java
...ollo/portal/spi/ctrip/filters/RecordAccessUserFilter.java
+3
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java
.../apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionServiceTest.java
...lo/openapi/service/ConsumerRolePermissionServiceTest.java
+2
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerServiceTest.java
...framework/apollo/openapi/service/ConsumerServiceTest.java
+2
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtilTest.java
.../framework/apollo/openapi/util/ConsumerAuditUtilTest.java
+1
-3
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java
...test/java/com/ctrip/framework/apollo/portal/AllTests.java
+2
-2
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/RetryableRestTemplateTest.java
...ip/framework/apollo/portal/RetryableRestTemplateTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/ServiceExceptionTest.java
...m/ctrip/framework/apollo/portal/ServiceExceptionTest.java
+12
-12
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/components/txtresolver/FileTextResolverTest.java
...o/portal/components/txtresolver/FileTextResolverTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/controller/ConsumerControllerTest.java
...work/apollo/portal/controller/ConsumerControllerTest.java
+2
-2
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/AppNamespaceServiceTest.java
...mework/apollo/portal/service/AppNamespaceServiceTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigServiceTest.java
...ip/framework/apollo/portal/service/ConfigServiceTest.java
+4
-4
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/NamespaceServiceTest.java
...framework/apollo/portal/service/NamespaceServiceTest.java
+2
-2
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/RoleInitializationServiceTest.java
.../apollo/portal/service/RoleInitializationServiceTest.java
+1
-1
apollo-portal/src/test/resources/META-INF/plexus/plexus.xml
apollo-portal/src/test/resources/META-INF/plexus/plexus.xml
+0
-42
pom.xml
pom.xml
+23
-2
scripts/build.sh
scripts/build.sh
+2
-2
No files found.
apollo-adminservice/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -19,11 +19,6 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- end of apollo -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
@@ -108,11 +103,6 @@
<package.environment>
github
</package.environment>
</properties>
<dependencies>
<!-- disable cat for outside use -->
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.HealthIndicator
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Component
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
@Component
public
class
AdminServiceHealthIndicator
implements
HealthIndicator
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -11,15 +19,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
java.util.List
;
@RestController
public
class
AppController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.ctrip.framework.apollo.biz.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
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.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.biz.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
@RestController
public
class
AppNamespaceController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.service.ClusterService
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -10,13 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.service.ClusterService
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
java.util.List
;
@RestController
public
class
ClusterController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
View file @
73ce069f
...
...
@@ -2,8 +2,8 @@ package com.ctrip.framework.apollo.adminservice.controller;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
import
com.ctrip.framework.apollo.biz.service.CommitService
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.CommitDTO
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock
;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
...
...
@@ -18,10 +8,20 @@ import com.ctrip.framework.apollo.biz.service.CommitService;
import
com.ctrip.framework.apollo.biz.service.ItemService
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
public
class
ItemController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock
;
import
com.ctrip.framework.apollo.biz.service.ItemSetService
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -9,10 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock
;
import
com.ctrip.framework.apollo.biz.service.ItemSetService
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
@RestController
public
class
ItemSetController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -10,13 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
java.util.List
;
@RestController
public
class
NamespaceController
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
View file @
73ce069f
...
...
@@ -5,9 +5,9 @@ import com.ctrip.framework.apollo.biz.entity.NamespaceLock;
import
com.ctrip.framework.apollo.biz.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.biz.utils.ApolloSwitcher
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseController.java
View file @
73ce069f
...
...
@@ -13,9 +13,9 @@ import com.ctrip.framework.apollo.biz.service.ReleaseService;
import
com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator
;
import
com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/AdminServiceTestConfiguration.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
import
com.ctrip.framework.apollo.common.controller.HttpMessageConverterConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
...
...
@@ -8,8 +9,6 @@ import org.springframework.context.annotation.ComponentScan.Filter;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.FilterType
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
@Configuration
@ComponentScan
(
excludeFilters
=
{
@Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
value
=
{
LocalAdminServiceApplication
.
class
,
AdminServiceApplication
.
class
,
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AbstractControllerTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
javax.annotation.PostConstruct
;
import
com.ctrip.framework.apollo.AdminServiceTestConfiguration
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.framework.apollo.AdminServiceTestConfiguration
;
import
javax.annotation.PostConstruct
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
AdminServiceTestConfiguration
.
class
)
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -9,11 +14,6 @@ import org.springframework.test.context.jdbc.Sql;
import
org.springframework.test.context.jdbc.Sql.ExecutionPhase
;
import
org.springframework.web.client.HttpClientErrorException
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
public
class
AppControllerTest
extends
AbstractControllerTest
{
@Autowired
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceControllerTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
@@ -16,12 +17,11 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
ControllerExceptionTest
{
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerIntegrationExceptionTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.google.gson.Gson
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
@@ -16,12 +18,10 @@ import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.service.AdminService
;
import
com.ctrip.framework.apollo.biz.service.AppService
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
java.util.Map
;
import
com.google.gson.Gson
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
public
class
ControllerIntegrationExceptionTest
extends
AbstractControllerTest
{
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.repository.ItemRepository
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -12,13 +18,7 @@ import org.springframework.test.context.jdbc.Sql;
import
org.springframework.test.context.jdbc.Sql.ExecutionPhase
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.repository.ItemRepository
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
java.util.List
;
public
class
ItemSetControllerTest
extends
AbstractControllerTest
{
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseControllerTest.java
View file @
73ce069f
...
...
@@ -9,12 +9,12 @@ import com.ctrip.framework.apollo.biz.message.Topics;
import
com.ctrip.framework.apollo.biz.repository.ReleaseRepository
;
import
com.ctrip.framework.apollo.biz.service.NamespaceService
;
import
com.ctrip.framework.apollo.biz.service.ReleaseService
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
apollo-adminservice/src/test/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
apollo-assembly/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -27,11 +27,6 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-portal
</artifactId>
</dependency>
<!-- disable cat for assembly -->
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
...
...
apollo-assembly/src/main/java/com/ctrip/framework/apollo/assembly/ApolloApplication.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
assembly
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
import
com.ctrip.framework.apollo.configservice.ConfigServiceApplication
;
import
com.ctrip.framework.apollo.portal.PortalApplication
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.actuate.system.ApplicationPidFileWriter
;
...
...
@@ -10,10 +14,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
com.ctrip.framework.apollo.portal.PortalApplication
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
import
com.ctrip.framework.apollo.configservice.ConfigServiceApplication
;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
})
public
class
ApolloApplication
{
...
...
apollo-assembly/src/main/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
apollo-assembly/src/test/java/com/ctrip/framework/apollo/assembly/LocalApolloApplication.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
assembly
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
import
com.ctrip.framework.apollo.configservice.ConfigServiceApplication
;
import
com.ctrip.framework.apollo.portal.PortalApplication
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.actuate.system.ApplicationPidFileWriter
;
...
...
@@ -10,10 +14,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
com.ctrip.framework.apollo.adminservice.AdminServiceApplication
;
import
com.ctrip.framework.apollo.configservice.ConfigServiceApplication
;
import
com.ctrip.framework.apollo.portal.PortalApplication
;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
})
public
class
LocalApolloApplication
{
...
...
apollo-biz/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<artifactId>
apollo
</artifactId>
<groupId>
com.ctrip.framework.apollo
</groupId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-biz
</artifactId>
...
...
@@ -24,11 +24,6 @@
<artifactId>
spring-cloud-starter-eureka
</artifactId>
</dependency>
<!-- end of eureka -->
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java
View file @
73ce069f
...
...
@@ -2,13 +2,13 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Audit"
)
@SQLDelete
(
sql
=
"Update Audit set isDeleted = 1 where id = ?"
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java
View file @
73ce069f
...
...
@@ -2,13 +2,13 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java
View file @
73ce069f
...
...
@@ -2,7 +2,6 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java
View file @
73ce069f
...
...
@@ -2,14 +2,14 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Lob
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Item"
)
@SQLDelete
(
sql
=
"Update Item set isDeleted = 1 where id = ?"
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java
View file @
73ce069f
...
...
@@ -2,13 +2,13 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Namespace"
)
@SQLDelete
(
sql
=
"Update Namespace set isDeleted = 1 where id = ?"
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java
View file @
73ce069f
...
...
@@ -2,13 +2,13 @@ package com.ctrip.framework.apollo.biz.entity;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"Privilege"
)
@SQLDelete
(
sql
=
"Update Privilege set isDeleted = 1 where id = ?"
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java
View file @
73ce069f
...
...
@@ -20,9 +20,8 @@ import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO;
import
com.ctrip.framework.apollo.common.utils.GrayReleaseRuleItemTransformer
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -102,12 +101,12 @@ public class GrayReleaseRulesHolder implements ReleaseMessageListener, Initializ
}
private
void
periodicScanRules
()
{
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.GrayReleaseRulesScanner"
,
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.GrayReleaseRulesScanner"
,
"scanGrayReleaseRules"
);
try
{
loadVersion
.
incrementAndGet
();
scanGrayReleaseRules
();
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
transaction
.
setStatus
(
ex
);
logger
.
error
(
"Scan gray release rule failed"
,
ex
);
...
...
@@ -238,7 +237,7 @@ public class GrayReleaseRulesHolder implements ReleaseMessageListener, Initializ
ruleItems
=
GrayReleaseRuleItemTransformer
.
batchTransformFromJSON
(
grayReleaseRule
.
getRules
());
}
catch
(
Throwable
ex
)
{
ruleItems
=
Sets
.
newHashSet
();
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"parse rule for gray release rule {} failed"
,
grayReleaseRule
.
getId
(),
ex
);
}
...
...
@@ -257,7 +256,7 @@ public class GrayReleaseRulesHolder implements ReleaseMessageListener, Initializ
databaseScanInterval
=
Integer
.
parseInt
(
interval
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Load apollo gray release rule scan interval from server config failed"
,
ex
);
}
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java
View file @
73ce069f
...
...
@@ -2,9 +2,8 @@ package com.ctrip.framework.apollo.biz.message;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.repository.ReleaseMessageRepository
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -31,11 +30,11 @@ public class DatabaseMessageSender implements MessageSender {
return
;
}
Cat
.
logEvent
(
"Apollo.AdminService.ReleaseMessage"
,
message
);
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.AdminService"
,
"sendMessage"
);
Tracer
.
logEvent
(
"Apollo.AdminService.ReleaseMessage"
,
message
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.AdminService"
,
"sendMessage"
);
try
{
releaseMessageRepository
.
save
(
new
ReleaseMessage
(
message
));
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Sending message to database failed"
,
ex
);
transaction
.
setStatus
(
ex
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java
View file @
73ce069f
...
...
@@ -5,9 +5,8 @@ import com.google.common.collect.Lists;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.repository.ReleaseMessageRepository
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -48,10 +47,10 @@ public class ReleaseMessageScanner implements InitializingBean {
populateDataBaseInterval
();
maxIdScanned
=
loadLargestMessageId
();
executorService
.
scheduleWithFixedDelay
((
Runnable
)
()
->
{
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ReleaseMessageScanner"
,
"scanMessage"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ReleaseMessageScanner"
,
"scanMessage"
);
try
{
scanMessages
();
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
transaction
.
setStatus
(
ex
);
logger
.
error
(
"Scan and send message failed"
,
ex
);
...
...
@@ -119,7 +118,7 @@ public class ReleaseMessageScanner implements InitializingBean {
try
{
listener
.
handleMessage
(
message
,
Topics
.
APOLLO_RELEASE_TOPIC
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Failed to invoke message listener {}"
,
listener
.
getClass
(),
ex
);
}
}
...
...
@@ -134,7 +133,7 @@ public class ReleaseMessageScanner implements InitializingBean {
databaseScanInterval
=
Integer
.
parseInt
(
interval
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Load apollo message scan interval from system property failed"
,
ex
);
}
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
import
java.util.Set
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
java.util.List
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
java.util.List
;
public
interface
AppRepository
extends
PagingAndSortingRepository
<
App
,
Long
>
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
java.util.Lis
t
;
import
com.ctrip.framework.apollo.biz.entity.Audi
t
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
import
com.ctrip.framework.apollo.biz.entity.Audi
t
;
import
java.util.Lis
t
;
public
interface
AuditRepository
extends
PagingAndSortingRepository
<
Audit
,
Long
>
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
com.ctrip.framework.apollo.biz.entity.GrayReleaseRule
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
java.util.List
;
public
interface
ItemRepository
extends
PagingAndSortingRepository
<
Item
,
Long
>
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
java.util.List
;
public
interface
NamespaceRepository
extends
PagingAndSortingRepository
<
Namespace
,
Long
>
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
com.ctrip.framework.apollo.biz.entity.Privilege
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
public
interface
PrivilegeRepository
extends
PagingAndSortingRepository
<
Privilege
,
Long
>
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
java.util.List
;
import
java.util.Set
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.Modifying
;
...
...
@@ -9,7 +8,8 @@ import org.springframework.data.jpa.repository.Query;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
@Service
public
class
AdminService
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
View file @
73ce069f
...
...
@@ -8,10 +8,10 @@ import com.ctrip.framework.apollo.biz.entity.Cluster;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
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.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.List
;
import
java.util.Objects
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
...
...
@@ -9,11 +12,8 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
java.util.List
;
import
java.util.Objects
;
@Service
public
class
AppService
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.repository.AuditRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.repository.AuditRepository
;
import
java.util.List
;
@Service
public
class
AuditService
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.google.common.base.Strings
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.repository.ClusterRepository
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.google.common.base.Strings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
@Service
public
class
ClusterService
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.Interner
;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.biz.entity.Instance
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
View file @
73ce069f
...
...
@@ -8,14 +8,13 @@ import com.ctrip.framework.apollo.biz.entity.Audit;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.repository.ItemRepository
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -74,10 +73,10 @@ public class ItemService implements InitializingBean {
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
executorService
.
scheduleWithFixedDelay
(()
->
{
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ItemServiceLimitUpdater"
,
"updateLimit"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ItemServiceLimitUpdater"
,
"updateLimit"
);
try
{
updateLimits
();
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
transaction
.
setStatus
(
ex
);
}
finally
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
@Service
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.repository.NamespaceRepository
;
import
com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
public
class
NamespaceService
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@ import com.google.common.collect.Lists;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.repository.ReleaseMessageRepository
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -13,7 +13,6 @@ import org.springframework.util.CollectionUtils;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
@@ -43,7 +42,7 @@ public class ReleaseMessageService {
releaseMessage
.
setId
((
Long
)
o
[
1
]);
releaseMessages
.
add
(
releaseMessage
);
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"Parsing LatestReleaseMessagesGroupByMessages failed"
,
ex
);
Tracer
.
logError
(
"Parsing LatestReleaseMessagesGroupByMessages failed"
,
ex
);
}
}
return
releaseMessages
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java
View file @
73ce069f
...
...
@@ -6,7 +6,6 @@ import com.google.gson.GsonBuilder;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.LinkedList
;
import
java.util.List
;
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
repository
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
public
class
AppRepositoryTest
extends
AbstractIntegrationTest
{
@Autowired
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Date
;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.co
re.ConfigConsts
;
import
com.ctrip.framework.apollo.co
mmon.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Date
;
import
java.util.List
;
public
class
AdminServiceTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Date
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.biz.repository.ClusterRepository
;
import
com.ctrip.framework.apollo.biz.repository.NamespaceRepository
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.junit.After
;
import
org.junit.Assert
;
...
...
@@ -11,12 +16,7 @@ import org.springframework.test.annotation.Rollback;
import
org.springframework.test.context.transaction.AfterTransaction
;
import
org.springframework.test.context.transaction.BeforeTransaction
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.biz.repository.AppRepository
;
import
com.ctrip.framework.apollo.biz.repository.ClusterRepository
;
import
com.ctrip.framework.apollo.biz.repository.NamespaceRepository
;
import
java.util.Date
;
public
class
AdminServiceTransactionTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Date
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
java.util.Date
;
public
class
ClusterServiceTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java
View file @
73ce069f
...
...
@@ -14,7 +14,6 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.test.context.jdbc.Sql
;
import
org.springframework.test.util.AssertionErrors
;
public
class
NamespaceBranchServiceTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/PrivilegeServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
biz
.
service
;
import
java.util.Date
;
import
java.util.List
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Privilege
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.framework.apollo.biz.AbstractIntegrationTest
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.biz.entity.Cluster
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Privilege
;
import
java.util.Date
;
import
java.util.List
;
public
class
PrivilegeServiceTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
View file @
73ce069f
...
...
@@ -19,7 +19,6 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.test.context.jdbc.Sql
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
public
class
ReleaseCreationTest
extends
AbstractIntegrationTest
{
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java
View file @
73ce069f
...
...
@@ -11,7 +11,8 @@ import org.junit.Test;
import
org.mockito.Mock
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
apollo-biz/src/test/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
apollo-buildtools/pom.xml
View file @
73ce069f
...
...
@@ -4,22 +4,12 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-buildtools
</artifactId>
<name>
Apollo BuildTools
</name>
<properties>
<java.version>
1.7
</java.version>
<github.path>
${project.artifactId}
</github.path>
</properties>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
...
...
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullClientConfigManager.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
cat
;
import
java.io.File
;
import
java.util.List
;
import
com.dianping.cat.configuration.ClientConfigManager
;
import
com.dianping.cat.configuration.client.entity.Domain
;
import
com.dianping.cat.configuration.client.entity.Server
;
public
class
NullClientConfigManager
implements
ClientConfigManager
{
@Override
public
Domain
getDomain
()
{
return
null
;
}
@Override
public
int
getMaxMessageLength
()
{
return
0
;
}
@Override
public
String
getServerConfigUrl
()
{
return
null
;
}
@Override
public
List
<
Server
>
getServers
()
{
return
null
;
}
@Override
public
int
getTaggedTransactionCacheSize
()
{
return
0
;
}
@Override
public
void
initialize
(
File
configFile
)
throws
Exception
{
}
@Override
public
boolean
isCatEnabled
()
{
return
false
;
}
@Override
public
boolean
isDumpLocked
()
{
return
false
;
}
@Override
public
int
getQueueSize
()
{
return
0
;
}
}
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullLoggerManager.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
cat
;
import
org.codehaus.plexus.logging.console.ConsoleLoggerManager
;
public
class
NullLoggerManager
extends
ConsoleLoggerManager
{
}
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullMessageManager.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
cat
;
import
java.io.IOException
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.lookup.ContainerHolder
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.MessageIdFactory
;
import
com.dianping.cat.message.spi.MessageManager
;
import
com.dianping.cat.message.spi.MessageTree
;
public
class
NullMessageManager
extends
ContainerHolder
implements
MessageManager
,
Initializable
,
LogEnabled
{
@Inject
private
MessageIdFactory
m_factory
;
@Override
public
void
enableLogging
(
Logger
logger
)
{
}
@Override
public
void
initialize
()
throws
InitializationException
{
try
{
m_factory
.
initialize
(
"localhost"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
add
(
Message
message
)
{
}
@Override
public
void
end
(
Transaction
transaction
)
{
}
@Override
public
Transaction
getPeekTransaction
()
{
return
null
;
}
@Override
public
MessageTree
getThreadLocalMessageTree
()
{
return
null
;
}
@Override
public
boolean
hasContext
()
{
return
false
;
}
@Override
public
boolean
isMessageEnabled
()
{
return
false
;
}
@Override
public
boolean
isCatEnabled
()
{
return
false
;
}
@Override
public
boolean
isTraceMode
()
{
return
false
;
}
@Override
public
void
reset
()
{
}
@Override
public
void
setTraceMode
(
boolean
traceMode
)
{
}
@Override
public
void
setup
()
{
}
@Override
public
void
start
(
Transaction
transaction
,
boolean
forked
)
{
}
@Override
public
void
bind
(
String
tag
,
String
title
)
{
}
@Override
public
String
getDomain
()
{
return
null
;
}
}
apollo-buildtools/src/main/java/com/ctrip/framework/apollo/cat/NullTransportManager.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
cat
;
import
com.dianping.cat.message.io.MessageSender
;
import
com.dianping.cat.message.io.TransportManager
;
import
com.dianping.cat.message.spi.MessageTree
;
public
class
NullTransportManager
implements
TransportManager
{
private
static
final
MessageSender
nullMessageSender
=
new
MessageSender
()
{
@Override
public
void
initialize
()
{
}
@Override
public
void
send
(
MessageTree
tree
)
{
}
@Override
public
void
shutdown
()
{
}
};
@Override
public
MessageSender
getSender
()
{
return
nullMessageSender
;
}
}
apollo-client/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -20,16 +20,11 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- end of apollo -->
<!-- foundation service -->
<dependency>
<groupId>
com.ctrip
.framework
</groupId>
<artifactId>
f
ramework-foundation
</artifactId>
<groupId>
org.unidal
.framework
</groupId>
<artifactId>
f
oundation-service
</artifactId>
</dependency>
<!-- end of foundation service -->
<!-- log -->
...
...
@@ -37,27 +32,6 @@
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-slf4j-impl
</artifactId>
<exclusions>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-api
</artifactId>
</exclusion>
</exclusions>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<scope>
provided
</scope>
</dependency>
<!-- end of log -->
<!-- test -->
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
...
...
@@ -69,13 +43,29 @@
<artifactId>
commons-logging
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-slf4j-impl
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- end of test -->
<!-- dal-jdbc -->
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
<version>
2.4.0
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
<exclusions>
<exclusion>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end of dal-jdbc -->
</dependencies>
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
View file @
73ce069f
...
...
@@ -6,7 +6,7 @@ import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import
com.ctrip.framework.apollo.internals.ConfigManager
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigRegistry
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
...
...
@@ -51,7 +51,7 @@ public class ConfigService {
return
s_instance
.
m_container
.
lookup
(
ConfigManager
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to load ConfigManager!"
,
ex
);
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
}
...
...
@@ -61,7 +61,7 @@ public class ConfigService {
return
s_instance
.
m_container
.
lookup
(
ConfigRegistry
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to load ConfigRegistry!"
,
ex
);
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
View file @
73ce069f
...
...
@@ -11,10 +11,9 @@ import com.ctrip.framework.apollo.enums.PropertyChangeType;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.parser.Parsers
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -63,7 +62,7 @@ public abstract class AbstractConfig implements Config {
return
Integer
.
parseInt
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getIntProperty for %s failed, return default value %d"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -79,7 +78,7 @@ public abstract class AbstractConfig implements Config {
return
Long
.
parseLong
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getLongProperty for %s failed, return default value %d"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -95,7 +94,7 @@ public abstract class AbstractConfig implements Config {
return
Short
.
parseShort
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getShortProperty for %s failed, return default value %d"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -111,7 +110,7 @@ public abstract class AbstractConfig implements Config {
return
Float
.
parseFloat
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getFloatProperty for %s failed, return default value %f"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -127,7 +126,7 @@ public abstract class AbstractConfig implements Config {
return
Double
.
parseDouble
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getDoubleProperty for %s failed, return default value %f"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -143,7 +142,7 @@ public abstract class AbstractConfig implements Config {
return
Byte
.
parseByte
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getByteProperty for %s failed, return default value %d"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -159,7 +158,7 @@ public abstract class AbstractConfig implements Config {
return
Boolean
.
parseBoolean
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getBooleanProperty for %s failed, return default value %b"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -175,7 +174,7 @@ public abstract class AbstractConfig implements Config {
return
value
.
split
(
delimiter
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getArrayProperty for %s failed, return default value"
,
key
),
ex
));
}
return
defaultValue
;
...
...
@@ -190,7 +189,7 @@ public abstract class AbstractConfig implements Config {
return
Enum
.
valueOf
(
enumType
,
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getEnumProperty for %s failed, return default value %s"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -207,7 +206,7 @@ public abstract class AbstractConfig implements Config {
return
Parsers
.
forDate
().
parse
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getDateProperty for %s failed, return default value %s"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -224,7 +223,7 @@ public abstract class AbstractConfig implements Config {
return
Parsers
.
forDate
().
parse
(
value
,
format
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getDateProperty for %s failed, return default value %s"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -241,7 +240,7 @@ public abstract class AbstractConfig implements Config {
return
Parsers
.
forDate
().
parse
(
value
,
format
,
locale
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getDateProperty for %s failed, return default value %s"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -258,7 +257,7 @@ public abstract class AbstractConfig implements Config {
return
Parsers
.
forDuration
().
parseToMillis
(
value
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
new
ApolloConfigException
(
Tracer
.
logError
(
new
ApolloConfigException
(
String
.
format
(
"getDurationProperty for %s failed, return default value %d"
,
key
,
defaultValue
),
ex
));
}
...
...
@@ -272,13 +271,13 @@ public abstract class AbstractConfig implements Config {
@Override
public
void
run
()
{
String
listenerName
=
listener
.
getClass
().
getName
();
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigChangeListener"
,
listenerName
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigChangeListener"
,
listenerName
);
try
{
listener
.
onChange
(
changeEvent
);
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
transaction
.
setStatus
(
ex
);
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Failed to invoke config change listener {}"
,
listenerName
,
ex
);
}
finally
{
transaction
.
complete
();
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
internals
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -30,7 +30,7 @@ public abstract class AbstractConfigFile implements ConfigFile, RepositoryChange
try
{
m_configProperties
.
set
(
m_configRepository
.
getConfig
());
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
warn
(
"Init Apollo Config File failed - namespace: {}, reason: {}."
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
));
}
finally
{
...
...
@@ -55,7 +55,7 @@ public abstract class AbstractConfigFile implements ConfigFile, RepositoryChange
m_configProperties
.
set
(
newConfigProperties
);
Cat
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
Tracer
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
View file @
73ce069f
...
...
@@ -2,8 +2,8 @@ package com.ctrip.framework.apollo.internals;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -23,7 +23,7 @@ public abstract class AbstractConfigRepository implements ConfigRepository {
sync
();
return
true
;
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
warn
(
"Sync config failed, will retry. Repository {}, reason: {}"
,
this
.
getClass
(),
ExceptionUtil
.
getDetailMessage
(
ex
));
...
...
@@ -50,7 +50,7 @@ public abstract class AbstractConfigRepository implements ConfigRepository {
try
{
listener
.
onRepositoryChange
(
namespace
,
newProperties
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Failed to invoke repository change listener {}"
,
listener
.
getClass
(),
ex
);
}
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
View file @
73ce069f
...
...
@@ -11,13 +11,12 @@ import com.google.gson.reflect.TypeToken;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
...
...
@@ -94,7 +93,7 @@ public class ConfigServiceLocator implements Initializable {
@Override
public
void
run
()
{
logger
.
debug
(
"refresh config services"
);
Cat
.
logEvent
(
"Apollo.MetaService"
,
"periodicRefresh"
);
Tracer
.
logEvent
(
"Apollo.MetaService"
,
"periodicRefresh"
);
tryUpdateConfigServices
();
}
},
m_configUtil
.
getRefreshInterval
(),
m_configUtil
.
getRefreshInterval
(),
...
...
@@ -109,11 +108,11 @@ public class ConfigServiceLocator implements Initializable {
Throwable
exception
=
null
;
for
(
int
i
=
0
;
i
<
maxRetries
;
i
++)
{
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.MetaService"
,
"getConfigService"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.MetaService"
,
"getConfigService"
);
transaction
.
addData
(
"Url"
,
url
);
try
{
HttpResponse
<
List
<
ServiceDTO
>>
response
=
m_httpUtil
.
doGet
(
request
,
m_responseType
);
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
List
<
ServiceDTO
>
services
=
response
.
getBody
();
if
(
services
==
null
||
services
.
isEmpty
())
{
logConfigServiceToCat
(
"Empty response!"
);
...
...
@@ -123,7 +122,7 @@ public class ConfigServiceLocator implements Initializable {
logConfigServicesToCat
(
services
);
return
;
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
transaction
.
setStatus
(
ex
);
exception
=
ex
;
}
finally
{
...
...
@@ -162,6 +161,6 @@ public class ConfigServiceLocator implements Initializable {
}
private
void
logConfigServiceToCat
(
String
serviceUrl
)
{
Cat
.
logEvent
(
"Apollo.Config.Services"
,
serviceUrl
);
Tracer
.
logEvent
(
"Apollo.Config.Services"
,
serviceUrl
);
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
View file @
73ce069f
...
...
@@ -6,8 +6,8 @@ import com.ctrip.framework.apollo.core.utils.ClassLoaderUtil;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -51,7 +51,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
try
{
m_configProperties
.
set
(
m_configRepository
.
getConfig
());
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
warn
(
"Init Apollo Local Config failed - namespace: {}, reason: {}."
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
));
}
finally
{
...
...
@@ -119,7 +119,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
this
.
fireConfigChange
(
new
ConfigChangeEvent
(
m_namespace
,
actualChanges
));
Cat
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
Tracer
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
}
private
Map
<
String
,
ConfigChange
>
updateAndCalcConfigChanges
(
Properties
newConfigProperties
)
{
...
...
@@ -185,7 +185,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
try
{
properties
.
load
(
in
);
}
catch
(
IOException
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
error
(
"Load resource config for namespace {} failed"
,
namespace
,
ex
);
}
finally
{
try
{
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
View file @
73ce069f
...
...
@@ -6,11 +6,10 @@ import com.google.common.base.Preconditions;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
...
...
@@ -58,7 +57,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
try
{
m_configUtil
=
m_container
.
lookup
(
ConfigUtil
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
"Unable to load component!"
,
ex
);
}
this
.
setLocalCacheDir
(
findLocalCacheDir
(),
false
);
...
...
@@ -135,14 +134,14 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
return
;
}
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"syncLocalConfig"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"syncLocalConfig"
);
Throwable
exception
=
null
;
try
{
transaction
.
addData
(
"Basedir"
,
m_baseDir
.
getAbsolutePath
());
m_fileProperties
=
this
.
loadFromLocalCacheFile
(
m_baseDir
,
m_namespace
);
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
transaction
.
setStatus
(
ex
);
exception
=
ex
;
//ignore
...
...
@@ -165,7 +164,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
updateFileProperties
(
properties
);
return
true
;
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
warn
(
"Sync config from upstream repository {} failed, reason: {}"
,
m_upstream
.
getClass
(),
ExceptionUtil
.
getDetailMessage
(
ex
));
...
...
@@ -197,7 +196,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
properties
.
load
(
in
);
logger
.
debug
(
"Loading local config file {} successfully!"
,
file
.
getAbsolutePath
());
}
catch
(
IOException
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
String
.
format
(
"Loading config from local cache file %s failed"
,
file
.
getAbsolutePath
()),
ex
);
}
finally
{
...
...
@@ -225,17 +224,17 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
OutputStream
out
=
null
;
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"persistLocalConfigFile"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"persistLocalConfigFile"
);
transaction
.
addData
(
"LocalConfigFile"
,
file
.
getAbsolutePath
());
try
{
out
=
new
FileOutputStream
(
file
);
m_fileProperties
.
store
(
out
,
"Persisted by DefaultConfig"
);
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
IOException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
String
.
format
(
"Persist local cache file %s failed"
,
file
.
getAbsolutePath
()),
ex
);
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
transaction
.
setStatus
(
exception
);
logger
.
warn
(
"Persist local cache file {} failed, reason: {}."
,
file
.
getAbsolutePath
(),
ExceptionUtil
.
getDetailMessage
(
ex
));
...
...
@@ -255,17 +254,17 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
if
(
baseDir
.
exists
())
{
return
;
}
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"createLocalConfigDir"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"createLocalConfigDir"
);
transaction
.
addData
(
"BaseDir"
,
baseDir
.
getAbsolutePath
());
try
{
Files
.
createDirectory
(
baseDir
.
toPath
());
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
IOException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
String
.
format
(
"Create local config directory %s failed"
,
baseDir
.
getAbsolutePath
()),
ex
);
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
transaction
.
setStatus
(
exception
);
logger
.
warn
(
"Unable to create local config cache directory {}, reason: {}. Will not able to cache config file."
,
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java
View file @
73ce069f
...
...
@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.internals;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.utils.PropertiesUtil
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -45,7 +45,7 @@ public class PropertiesConfigFile extends AbstractConfigFile {
new
ApolloConfigException
(
String
.
format
(
"Parse properties file content failed for namespace: %s, cause: %s"
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
)));
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
View file @
73ce069f
...
...
@@ -21,14 +21,13 @@ import com.ctrip.framework.apollo.core.schedule.ExponentialSchedulePolicy;
import
com.ctrip.framework.apollo.core.schedule.SchedulePolicy
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
...
...
@@ -123,7 +122,7 @@ public class RemoteConfigLongPollService implements Initializable {
m_longPollStarted
.
set
(
false
);
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Schedule long polling refresh failed"
,
ex
);
Cat
.
logError
(
exception
);
Tracer
.
logError
(
exception
);
logger
.
warn
(
ExceptionUtil
.
getDetailMessage
(
exception
));
}
}
...
...
@@ -143,7 +142,7 @@ public class RemoteConfigLongPollService implements Initializable {
}
catch
(
InterruptedException
e
)
{
}
}
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"pollNotification"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"pollNotification"
);
try
{
if
(
lastServiceDto
==
null
)
{
List
<
ServiceDTO
>
configServices
=
getConfigServices
();
...
...
@@ -178,10 +177,10 @@ public class RemoteConfigLongPollService implements Initializable {
m_longPollFailSchedulePolicyInSecond
.
success
();
transaction
.
addData
(
"StatusCode"
,
response
.
getStatusCode
());
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
lastServiceDto
=
null
;
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
transaction
.
setStatus
(
ex
);
long
sleepTimeInSecond
=
m_longPollFailSchedulePolicyInSecond
.
fail
();
logger
.
warn
(
...
...
@@ -215,7 +214,7 @@ public class RemoteConfigLongPollService implements Initializable {
try
{
remoteConfigRepository
.
onLongPollNotified
(
lastServiceDto
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
}
}
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
View file @
73ce069f
...
...
@@ -15,13 +15,12 @@ import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
...
...
@@ -78,7 +77,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
m_serviceLocator
=
m_container
.
lookup
(
ConfigServiceLocator
.
class
);
remoteConfigLongPollService
=
m_container
.
lookup
(
RemoteConfigLongPollService
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
"Unable to load component!"
,
ex
);
}
m_longPollServiceDto
=
new
AtomicReference
<>();
...
...
@@ -108,10 +107,10 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
new
Runnable
()
{
@Override
public
void
run
()
{
Cat
.
logEvent
(
"Apollo.ConfigService"
,
String
.
format
(
"periodicRefresh: %s"
,
m_namespace
));
Tracer
.
logEvent
(
"Apollo.ConfigService"
,
String
.
format
(
"periodicRefresh: %s"
,
m_namespace
));
logger
.
debug
(
"refresh config for namespace: {}"
,
m_namespace
);
trySync
();
Cat
.
logEvent
(
"Apollo.Client.Version"
,
Apollo
.
VERSION
);
Tracer
.
logEvent
(
"Apollo.Client.Version"
,
Apollo
.
VERSION
);
}
},
m_configUtil
.
getRefreshInterval
(),
m_configUtil
.
getRefreshInterval
(),
m_configUtil
.
getRefreshIntervalTimeUnit
());
...
...
@@ -119,7 +118,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
@Override
protected
synchronized
void
sync
()
{
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"syncRemoteConfig"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"syncRemoteConfig"
);
try
{
ApolloConfig
previous
=
m_configCache
.
get
();
...
...
@@ -133,11 +132,11 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
}
if
(
current
!=
null
)
{
Cat
.
logEvent
(
String
.
format
(
"Apollo.Client.Configs.%s"
,
current
.
getNamespaceName
()),
Tracer
.
logEvent
(
String
.
format
(
"Apollo.Client.Configs.%s"
,
current
.
getNamespaceName
()),
current
.
getReleaseKey
());
}
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
ex
)
{
transaction
.
setStatus
(
ex
);
throw
ex
;
...
...
@@ -163,7 +162,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
String
appId
=
m_configUtil
.
getAppId
();
String
cluster
=
m_configUtil
.
getCluster
();
String
dataCenter
=
m_configUtil
.
getDataCenter
();
Cat
.
logEvent
(
"Apollo.Client.ConfigMeta"
,
STRING_JOINER
.
join
(
appId
,
cluster
,
m_namespace
));
Tracer
.
logEvent
(
"Apollo.Client.ConfigMeta"
,
STRING_JOINER
.
join
(
appId
,
cluster
,
m_namespace
));
int
maxRetries
=
2
;
Throwable
exception
=
null
;
...
...
@@ -184,14 +183,14 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
logger
.
debug
(
"Loading config from {}"
,
url
);
HttpRequest
request
=
new
HttpRequest
(
url
);
Transaction
transaction
=
Cat
.
newTransaction
(
"Apollo.ConfigService"
,
"queryConfig"
);
Transaction
transaction
=
Tracer
.
newTransaction
(
"Apollo.ConfigService"
,
"queryConfig"
);
transaction
.
addData
(
"Url"
,
url
);
try
{
HttpResponse
<
ApolloConfig
>
response
=
m_httpUtil
.
doGet
(
request
,
ApolloConfig
.
class
);
transaction
.
addData
(
"StatusCode"
,
response
.
getStatusCode
());
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStatus
(
Transaction
.
SUCCESS
);
if
(
response
.
getStatusCode
()
==
304
)
{
logger
.
debug
(
"Config server responds with 304 HTTP status code."
);
...
...
@@ -214,11 +213,11 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
statusCodeException
=
new
ApolloConfigStatusCodeException
(
ex
.
getStatusCode
(),
message
);
}
Cat
.
logError
(
statusCodeException
);
Tracer
.
logError
(
statusCodeException
);
transaction
.
setStatus
(
statusCodeException
);
exception
=
statusCodeException
;
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
transaction
.
setStatus
(
ex
);
exception
=
ex
;
}
finally
{
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
View file @
73ce069f
...
...
@@ -5,8 +5,8 @@ import com.google.common.collect.Maps;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -42,7 +42,7 @@ public class SimpleConfig extends AbstractConfig implements RepositoryChangeList
try
{
m_configProperties
=
m_configRepository
.
getConfig
();
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
logger
.
warn
(
"Init Apollo Simple Config failed - namespace: {}, reason: {}"
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
));
}
finally
{
...
...
@@ -93,6 +93,6 @@ public class SimpleConfig extends AbstractConfig implements RepositoryChangeList
this
.
fireConfigChange
(
new
ConfigChangeEvent
(
m_namespace
,
changeMap
));
Cat
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
Tracer
.
logEvent
(
"Apollo.Client.ConfigChanges"
,
m_namespace
);
}
}
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
View file @
73ce069f
...
...
@@ -5,8 +5,8 @@ import com.google.common.collect.Lists;
import
com.google.common.io.Files
;
import
com.google.gson.Gson
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
View file @
73ce069f
...
...
@@ -5,7 +5,6 @@ import com.ctrip.framework.apollo.ConfigFile;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigFactoryManager
;
import
com.ctrip.framework.apollo.spi.ConfigRegistry
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java
View file @
73ce069f
...
...
@@ -12,7 +12,6 @@ import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
...
...
@@ -20,9 +19,6 @@ import java.util.Properties;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
View file @
73ce069f
...
...
@@ -11,7 +11,10 @@ import org.mockito.runners.MockitoJUnitRunner;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
View file @
73ce069f
...
...
@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.util;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
apollo-common/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/aop/RepositoryAspect.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
aop
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
...
...
@@ -23,10 +22,10 @@ public class RepositoryAspect {
String
name
=
joinPoint
.
getSignature
().
getDeclaringType
().
getSimpleName
()
+
"."
+
joinPoint
.
getSignature
()
.
getName
();
Transaction
catTransaction
=
Cat
.
newTransaction
(
"SQL"
,
name
);
Transaction
catTransaction
=
Tracer
.
newTransaction
(
"SQL"
,
name
);
try
{
Object
result
=
joinPoint
.
proceed
();
catTransaction
.
setStatus
(
Message
.
SUCCESS
);
catTransaction
.
setStatus
(
Transaction
.
SUCCESS
);
return
result
;
}
catch
(
Throwable
ex
)
{
catTransaction
.
setStatus
(
ex
);
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/constants/GsonType.java
View file @
73ce069f
...
...
@@ -2,11 +2,8 @@ package com.ctrip.framework.apollo.common.constants;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO
;
import
java.lang.reflect.Type
;
import
java.util.Map
;
import
java.util.Set
;
public
interface
GsonType
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/ApolloInfoController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.Apollo
;
import
com.ctrip.framework.foundation.Foundation
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
path
=
"/apollo"
)
public
class
ApolloInfoController
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CatConfig.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
javax.servlet.DispatcherType
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.Ordered
;
import
com.dianping.cat.servlet.CatFilter
;
@Configuration
public
class
CatConfig
{
@Bean
public
FilterRegistrationBean
catFilter
()
{
FilterRegistrationBean
bean
=
new
FilterRegistrationBean
();
bean
.
setFilter
(
new
CatFilter
());
bean
.
setName
(
"cat-filter"
);
bean
.
addUrlPatterns
(
"/*"
);
bean
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
FORWARD
);
bean
.
setOrder
(
Ordered
.
HIGHEST_PRECEDENCE
);
return
bean
;
}
}
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CharacterEncodingFilterConfiguration.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
javax.servlet.DispatcherType
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.filter.CharacterEncodingFilter
;
import
javax.servlet.DispatcherType
;
@Configuration
public
class
CharacterEncodingFilterConfiguration
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@ import com.google.gson.Gson;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.common.exception.AbstractApolloHttpException
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -82,7 +82,7 @@ public class GlobalDefaultExceptionHandler {
String
message
=
ex
.
getMessage
();
logger
.
error
(
message
,
ex
);
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
Map
<
String
,
Object
>
errorAttributes
=
new
HashMap
<>();
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
java.util.List
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
...
...
@@ -10,6 +8,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
java.util.List
;
@Configuration
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/customize/LoggingCustomizer.java
View file @
73ce069f
...
...
@@ -2,8 +2,8 @@ package com.ctrip.framework.apollo.common.customize;
import
com.google.common.base.Strings
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.foundation.Foundation
;
import
com.dianping.cat.Cat
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -11,7 +11,6 @@ import org.springframework.beans.factory.InitializingBean;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
import
ch.qos.logback.classic.LoggerContext
;
import
ch.qos.logback.core.Appender
;
...
...
@@ -36,7 +35,7 @@ public abstract class LoggingCustomizer implements InitializingBean {
tryConfigCLogging
();
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Config CLogging failed"
,
ex
);
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
}
}
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanCondition.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
datasource
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.context.annotation.Condition
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
public
class
TitanCondition
implements
Condition
{
@Override
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanEntityManager.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
datasource
;
import
java.lang.reflect.Method
;
import
javax.sql.DataSource
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.stereotype.Component
;
import
com.dianping.cat.Cat
;
import
java.lang.reflect.Method
;
import
javax.sql.DataSource
;
@Component
@Conditional
(
TitanCondition
.
class
)
...
...
@@ -26,7 +26,7 @@ public class TitanEntityManager {
Method
method
=
clazz
.
getMethod
(
"createDataSource"
,
new
Class
[]
{
String
.
class
,
String
.
class
});
DataSource
ds
=
((
DataSource
)
method
.
invoke
(
obj
,
new
Object
[]
{
settings
.
getTitanDbname
(),
settings
.
getTitanUrl
()}));
Cat
.
logEvent
(
"Apollo.Datasource.Titan"
,
settings
.
getTitanDbname
());
Tracer
.
logEvent
(
"Apollo.Datasource.Titan"
,
settings
.
getTitanDbname
());
return
ds
;
}
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/TitanSettings.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
datasource
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.EnvUtils
;
import
com.ctrip.framework.foundation.Foundation
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
@Component
public
class
TitanSettings
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
dto
;
import
com.google.common.collect.Sets
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
java.lang.reflect.Type
;
import
java.util.Set
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
entity
;
import
com.google.common.base.MoreObjects
;
import
com.google.common.base.MoreObjects.ToStringHelper
;
import
java.util.Date
;
import
javax.persistence.Column
;
...
...
@@ -12,9 +15,6 @@ import javax.persistence.PrePersist;
import
javax.persistence.PreRemove
;
import
javax.persistence.PreUpdate
;
import
com.google.common.base.MoreObjects
;
import
com.google.common.base.MoreObjects.ToStringHelper
;
@MappedSuperclass
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
abstract
class
BaseEntity
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java
View file @
73ce069f
...
...
@@ -2,6 +2,10 @@ package com.ctrip.framework.apollo.common.utils;
import
com.ctrip.framework.apollo.common.exception.BeanUtilsException
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.util.CollectionUtils
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
...
...
@@ -12,10 +16,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.util.CollectionUtils
;
public
class
BeanUtils
{
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/ExceptionUtils.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
common
.
utils
;
import
java.lang.reflect.Type
;
import
java.util.Map
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
com.google.common.base.MoreObjects
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
java.lang.reflect.Type
;
import
java.util.Map
;
public
final
class
ExceptionUtils
{
private
static
Gson
gson
=
new
Gson
();
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java
View file @
73ce069f
...
...
@@ -2,7 +2,6 @@ package com.ctrip.framework.apollo.common.utils;
import
com.google.common.base.Joiner
;
import
com.ctrip.framework.apollo.common.dto.ClusterDTO
;
import
com.ctrip.framework.apollo.core.utils.ByteUtil
;
import
com.ctrip.framework.apollo.core.utils.MachineUtil
;
...
...
apollo-common/src/test/java/com/ctrip/framework/apollo/common/utils/InputValidatorTest.java
View file @
73ce069f
...
...
@@ -2,7 +2,8 @@ package com.ctrip.framework.apollo.common.utils;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-configservice/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -19,11 +19,6 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- end of apollo -->
<!-- eureka -->
<dependency>
...
...
@@ -109,11 +104,6 @@
<package.environment>
github
</package.environment>
</properties>
<dependencies>
<!-- disable cat for outside use -->
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigController.java
View file @
73ce069f
...
...
@@ -18,7 +18,7 @@ import com.ctrip.framework.apollo.configservice.util.InstanceConfigAuditUtil;
import
com.ctrip.framework.apollo.configservice.util.NamespaceUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -107,7 +107,7 @@ public class ConfigController {
String
.
format
(
"Could not load configurations with appId: %s, clusterName: %s, namespace: %s"
,
appId
,
clusterName
,
originalNamespace
));
Cat
.
logEvent
(
"Apollo.Config.NotFound"
,
Tracer
.
logEvent
(
"Apollo.Config.NotFound"
,
assembleKey
(
appId
,
clusterName
,
originalNamespace
,
dataCenter
));
return
null
;
}
...
...
@@ -120,7 +120,7 @@ public class ConfigController {
if
(
mergedReleaseKey
.
equals
(
clientSideReleaseKey
))
{
// Client side configuration is the same with server side, return 304
response
.
setStatus
(
HttpServletResponse
.
SC_NOT_MODIFIED
);
Cat
.
logEvent
(
"Apollo.Config.NotModified"
,
Tracer
.
logEvent
(
"Apollo.Config.NotModified"
,
assembleKey
(
appId
,
appClusterNameLoaded
,
originalNamespace
,
dataCenter
));
return
null
;
}
...
...
@@ -129,7 +129,7 @@ public class ConfigController {
mergedReleaseKey
);
apolloConfig
.
setConfigurations
(
mergeReleaseConfigurations
(
releases
));
Cat
.
logEvent
(
"Apollo.Config.Found"
,
assembleKey
(
appId
,
appClusterNameLoaded
,
Tracer
.
logEvent
(
"Apollo.Config.Found"
,
assembleKey
(
appId
,
appClusterNameLoaded
,
originalNamespace
,
dataCenter
));
return
apolloConfig
;
}
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileController.java
View file @
73ce069f
...
...
@@ -23,7 +23,7 @@ import com.ctrip.framework.apollo.configservice.util.WatchKeysUtil;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.utils.PropertiesUtil
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -176,7 +176,7 @@ public class ConfigFileController implements ReleaseMessageListener {
//2. try to load gray release and return
if
(
hasGrayReleaseRule
)
{
Cat
.
logEvent
(
"ConfigFile.Cache.GrayRelease"
,
cacheKey
);
Tracer
.
logEvent
(
"ConfigFile.Cache.GrayRelease"
,
cacheKey
);
return
loadConfig
(
outputFormat
,
appId
,
clusterName
,
namespace
,
dataCenter
,
clientIp
,
request
,
response
);
}
...
...
@@ -186,7 +186,7 @@ public class ConfigFileController implements ReleaseMessageListener {
//4. if not exists, load from ConfigController
if
(
Strings
.
isNullOrEmpty
(
result
))
{
Cat
.
logEvent
(
"ConfigFile.Cache.Miss"
,
cacheKey
);
Tracer
.
logEvent
(
"ConfigFile.Cache.Miss"
,
cacheKey
);
result
=
loadConfig
(
outputFormat
,
appId
,
clusterName
,
namespace
,
dataCenter
,
clientIp
,
request
,
response
);
...
...
@@ -196,7 +196,7 @@ public class ConfigFileController implements ReleaseMessageListener {
//5. Double check if this client needs to load gray release, if yes, load from db again
//This step is mainly to avoid cache pollution
if
(
grayReleaseRulesHolder
.
hasGrayReleaseRule
(
appId
,
clientIp
,
namespace
))
{
Cat
.
logEvent
(
"ConfigFile.Cache.GrayReleaseConflict"
,
cacheKey
);
Tracer
.
logEvent
(
"ConfigFile.Cache.GrayReleaseConflict"
,
cacheKey
);
return
loadConfig
(
outputFormat
,
appId
,
clusterName
,
namespace
,
dataCenter
,
clientIp
,
request
,
response
);
}
...
...
@@ -214,7 +214,7 @@ public class ConfigFileController implements ReleaseMessageListener {
cacheKey2WatchedKeys
.
putAll
(
cacheKey
,
watchedKeys
);
logger
.
debug
(
"added cache for key: {}"
,
cacheKey
);
}
else
{
Cat
.
logEvent
(
"ConfigFile.Cache.Hit"
,
cacheKey
);
Tracer
.
logEvent
(
"ConfigFile.Cache.Hit"
,
cacheKey
);
}
return
result
;
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationController.java
View file @
73ce069f
...
...
@@ -16,7 +16,7 @@ import com.ctrip.framework.apollo.configservice.util.NamespaceUtil;
import
com.ctrip.framework.apollo.configservice.util.WatchKeysUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -130,7 +130,7 @@ public class NotificationController implements ReleaseMessageListener {
logger
.
info
(
"message received - channel: {}, message: {}"
,
channel
,
message
);
String
content
=
message
.
getMessage
();
Cat
.
logEvent
(
"Apollo.LongPoll.Messages"
,
content
);
Tracer
.
logEvent
(
"Apollo.LongPoll.Messages"
,
content
);
if
(!
Topics
.
APOLLO_RELEASE_TOPIC
.
equals
(
channel
)
||
Strings
.
isNullOrEmpty
(
content
))
{
return
;
}
...
...
@@ -161,7 +161,7 @@ public class NotificationController implements ReleaseMessageListener {
private
void
logWatchedKeysToCat
(
Set
<
String
>
watchedKeys
,
String
eventName
)
{
for
(
String
watchedKey
:
watchedKeys
)
{
Cat
.
logEvent
(
eventName
,
watchedKey
);
Tracer
.
logEvent
(
eventName
,
watchedKey
);
}
}
}
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
View file @
73ce069f
...
...
@@ -17,12 +17,12 @@ import com.ctrip.framework.apollo.biz.message.ReleaseMessageListener;
import
com.ctrip.framework.apollo.biz.message.Topics
;
import
com.ctrip.framework.apollo.biz.service.ReleaseMessageService
;
import
com.ctrip.framework.apollo.biz.utils.EntityManagerUtil
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.configservice.util.NamespaceUtil
;
import
com.ctrip.framework.apollo.configservice.util.WatchKeysUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -89,7 +89,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
notifications
=
gson
.
fromJson
(
notificationsAsString
,
notificationsTypeReference
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
}
if
(
CollectionUtils
.
isEmpty
(
notifications
))
{
...
...
@@ -197,7 +197,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
logger
.
info
(
"message received - channel: {}, message: {}"
,
channel
,
message
);
String
content
=
message
.
getMessage
();
Cat
.
logEvent
(
"Apollo.LongPoll.Messages"
,
content
);
Tracer
.
logEvent
(
"Apollo.LongPoll.Messages"
,
content
);
if
(!
Topics
.
APOLLO_RELEASE_TOPIC
.
equals
(
channel
)
||
Strings
.
isNullOrEmpty
(
content
))
{
return
;
}
...
...
@@ -244,7 +244,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
private
void
logWatchedKeysToCat
(
Set
<
String
>
watchedKeys
,
String
eventName
)
{
for
(
String
watchedKey
:
watchedKeys
)
{
Cat
.
logEvent
(
eventName
,
watchedKey
);
Tracer
.
logEvent
(
eventName
,
watchedKey
);
}
}
}
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/util/InstanceConfigAuditUtil.java
View file @
73ce069f
...
...
@@ -12,7 +12,7 @@ import com.ctrip.framework.apollo.biz.entity.InstanceConfig;
import
com.ctrip.framework.apollo.biz.service.InstanceService
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -151,7 +151,7 @@ public class InstanceConfigAuditUtil implements InitializingBean {
}
doAudit
(
model
);
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
}
}
});
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DiscoveryService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
metaservice
.
service
;
import
com.ctrip.framework.apollo.core.ServiceNameConsts
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.EurekaClient
;
import
com.netflix.discovery.shared.Application
;
...
...
@@ -21,7 +21,7 @@ public class DiscoveryService {
public
List
<
InstanceInfo
>
getConfigServiceInstances
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceNameConsts
.
APOLLO_CONFIGSERVICE
);
if
(
application
==
null
)
{
Cat
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_CONFIGSERVICE
);
Tracer
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_CONFIGSERVICE
);
}
return
application
!=
null
?
application
.
getInstances
()
:
new
ArrayList
<>();
}
...
...
@@ -29,7 +29,7 @@ public class DiscoveryService {
public
List
<
InstanceInfo
>
getMetaServiceInstances
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceNameConsts
.
APOLLO_METASERVICE
);
if
(
application
==
null
)
{
Cat
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_METASERVICE
);
Tracer
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_METASERVICE
);
}
return
application
!=
null
?
application
.
getInstances
()
:
new
ArrayList
<>();
}
...
...
@@ -37,7 +37,7 @@ public class DiscoveryService {
public
List
<
InstanceInfo
>
getAdminServiceInstances
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceNameConsts
.
APOLLO_ADMINSERVICE
);
if
(
application
==
null
)
{
Cat
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_ADMINSERVICE
);
Tracer
.
logEvent
(
"Apollo.EurekaDiscovery.NotFound"
,
ServiceNameConsts
.
APOLLO_ADMINSERVICE
);
}
return
application
!=
null
?
application
.
getInstances
()
:
new
ArrayList
<>();
}
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/ConfigControllerTest.java
View file @
73ce069f
...
...
@@ -6,11 +6,11 @@ import com.google.common.collect.Lists;
import
com.google.gson.Gson
;
import
com.google.gson.JsonSyntaxException
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolder
;
import
com.ctrip.framework.apollo.biz.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.biz.service.ReleaseService
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.configservice.util.InstanceConfigAuditUtil
;
import
com.ctrip.framework.apollo.configservice.util.NamespaceUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileControllerTest.java
View file @
73ce069f
...
...
@@ -32,7 +32,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerTest.java
View file @
73ce069f
...
...
@@ -28,8 +28,6 @@ import java.util.Set;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/util/NamespaceUtilTest.java
View file @
73ce069f
...
...
@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.configservice.util;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-configservice/src/test/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
apollo-core/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -16,12 +16,12 @@
<github.path>
${project.artifactId}
</github.path>
</properties>
<dependencies>
<!--
cat
-->
<!--
framework foundation
-->
<dependency>
<groupId>
com.
dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
<groupId>
com.
ctrip.framework
</groupId>
<artifactId>
framework-foundation
</artifactId>
</dependency>
<!-- end of
cat
-->
<!-- end of
framework foundation
-->
<!-- json -->
<dependency>
<groupId>
com.google.code.gson
</groupId>
...
...
@@ -40,5 +40,17 @@
<artifactId>
slf4j-api
</artifactId>
</dependency>
<!-- end of log -->
<!-- test -->
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-slf4j-impl
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- end of test -->
</dependencies>
</project>
apollo-core/src/main/java/com/ctrip/framework/apollo/core/MetaDomainConsts.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
core
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ResourceUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ResourceUtils
;
/**
* The meta domain will load the meta server from System environment first, if not exist, will load
* from apollo-env.properties. If neither exists, will load the default meta url.
...
...
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ClassLoaderUtil.java
View file @
73ce069f
...
...
@@ -5,7 +5,6 @@ import com.google.common.base.Strings;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URLDecoder
;
...
...
@@ -50,4 +49,13 @@ public class ClassLoaderUtil {
public
static
String
getClassPath
()
{
return
classPath
;
}
public
static
boolean
isClassPresent
(
String
className
)
{
try
{
Class
.
forName
(
className
);
return
true
;
}
catch
(
ClassNotFoundException
ex
)
{
return
false
;
}
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ResourceUtils.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
core
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
...
...
@@ -9,9 +12,6 @@ import java.nio.file.Path;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
ResourceUtils
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResourceUtils
.
class
);
...
...
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/ServiceBootstrap.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
core
.
utils
;
import
java.util.Iterator
;
import
java.util.ServiceLoader
;
public
class
ServiceBootstrap
{
public
static
<
S
>
S
loadFirst
(
Class
<
S
>
clazz
)
{
Iterator
<
S
>
iterator
=
loadAll
(
clazz
);
if
(!
iterator
.
hasNext
())
{
throw
new
IllegalStateException
(
String
.
format
(
"No implementation defined in /META-INF/services/%s, please check whether the file exists and has the right implementation class!"
,
clazz
.
getName
()));
}
return
iterator
.
next
();
}
private
static
<
S
>
Iterator
<
S
>
loadAll
(
Class
<
S
>
clazz
)
{
ServiceLoader
<
S
>
loader
=
ServiceLoader
.
load
(
clazz
);
return
loader
.
iterator
();
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/Tracer.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
;
import
com.ctrip.framework.apollo.core.utils.ServiceBootstrap
;
import
com.ctrip.framework.apollo.tracer.internals.NullMessageProducerManager
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
abstract
class
Tracer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Tracer
.
class
);
private
static
final
MessageProducerManager
NULL_MESSAGE_PRODUCER_MANAGER
=
new
NullMessageProducerManager
();
private
static
MessageProducerManager
producerManager
;
private
static
Object
lock
=
new
Object
();
static
{
getProducer
();
}
private
static
MessageProducer
getProducer
()
{
try
{
if
(
producerManager
==
null
)
{
synchronized
(
lock
)
{
if
(
producerManager
==
null
)
{
producerManager
=
ServiceBootstrap
.
loadFirst
(
MessageProducerManager
.
class
);
}
}
}
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Failed to initialize message producer manager, use null message producer manager."
,
ex
);
producerManager
=
NULL_MESSAGE_PRODUCER_MANAGER
;
}
return
producerManager
.
getProducer
();
}
public
static
void
logError
(
String
message
,
Throwable
cause
)
{
try
{
getProducer
().
logError
(
message
,
cause
);
}
catch
(
Throwable
ex
)
{
logger
.
warn
(
"Failed to log error for message: {}, cause: {}"
,
message
,
cause
,
ex
);
}
}
public
static
void
logError
(
Throwable
cause
)
{
try
{
getProducer
().
logError
(
cause
);
}
catch
(
Throwable
ex
)
{
logger
.
warn
(
"Failed to log error for cause: {}"
,
cause
,
ex
);
}
}
public
static
void
logEvent
(
String
type
,
String
name
)
{
try
{
getProducer
().
logEvent
(
type
,
name
);
}
catch
(
Throwable
ex
)
{
logger
.
warn
(
"Failed to log event for type: {}, name: {}"
,
type
,
name
,
ex
);
}
}
public
static
void
logEvent
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
)
{
try
{
getProducer
().
logEvent
(
type
,
name
,
status
,
nameValuePairs
);
}
catch
(
Throwable
ex
)
{
logger
.
warn
(
"Failed to log event for type: {}, name: {}, status: {}, nameValuePairs: {}"
,
type
,
name
,
status
,
nameValuePairs
,
ex
);
}
}
public
static
Transaction
newTransaction
(
String
type
,
String
name
)
{
try
{
return
getProducer
().
newTransaction
(
type
,
name
);
}
catch
(
Throwable
ex
)
{
logger
.
warn
(
"Failed to create transaction for type: {}, name: {}"
,
type
,
name
,
ex
);
return
NULL_MESSAGE_PRODUCER_MANAGER
.
getProducer
().
newTransaction
(
type
,
name
);
}
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/DefaultMessageProducerManager.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.tracer.internals.cat.CatMessageProducer
;
import
com.ctrip.framework.apollo.tracer.internals.cat.CatNames
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultMessageProducerManager
implements
MessageProducerManager
{
private
static
MessageProducer
producer
;
public
DefaultMessageProducerManager
()
{
if
(
ClassLoaderUtil
.
isClassPresent
(
CatNames
.
CAT_CLASS
))
{
producer
=
new
CatMessageProducer
();
}
else
{
producer
=
new
NullMessageProducerManager
().
getProducer
();
}
}
@Override
public
MessageProducer
getProducer
()
{
return
producer
;
}
}
apollo-
buildtools/src/main/java/com/ctrip/framework/apollo/cat
/NullMessageProducer.java
→
apollo-
core/src/main/java/com/ctrip/framework/apollo/tracer/internals
/NullMessageProducer.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
cat
;
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.dianping.cat.message.internal.DefaultMessageProducer
;
public
class
NullMessageProducer
extends
DefaultMessageProducer
{
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
NullMessageProducer
implements
MessageProducer
{
private
static
final
Transaction
NULL_TRANSACTION
=
new
NullTransaction
();
@Override
public
void
logError
(
Throwable
cause
)
{
}
@Override
public
void
logError
(
String
message
,
Throwable
cause
)
{
}
@Override
public
void
logEvent
(
String
type
,
String
name
)
{
}
@Override
public
void
logTrace
(
String
type
,
String
name
)
{
}
@Override
public
void
logEvent
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
)
{
}
@Override
public
void
logTags
(
String
scenario
,
Map
<
String
,
String
>
indexedTags
,
Map
<
String
,
String
>
storedTags
)
{
public
Transaction
newTransaction
(
String
type
,
String
name
)
{
return
NULL_TRANSACTION
;
}
@Override
public
void
logTrace
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
)
{
}
@Override
public
void
logHeartbeat
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
)
{
}
@Override
public
void
logMetric
(
String
name
,
String
status
,
String
nameValuePairs
)
{
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerManager.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
NullMessageProducerManager
implements
MessageProducerManager
{
private
static
final
MessageProducer
producer
=
new
NullMessageProducer
();
@Override
public
MessageProducer
getProducer
()
{
return
producer
;
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullTransaction.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
NullTransaction
implements
Transaction
{
@Override
public
void
setStatus
(
String
status
)
{
}
@Override
public
void
setStatus
(
Throwable
e
)
{
}
@Override
public
void
addData
(
String
key
,
Object
value
)
{
}
@Override
public
void
complete
()
{
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatMessageProducer.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
.
cat
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
java.lang.reflect.Method
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
CatMessageProducer
implements
MessageProducer
{
private
static
Class
CAT_CLASS
;
private
static
Method
LOG_ERROR_WITH_CAUSE
;
private
static
Method
LOG_ERROR_WITH_MESSAGE_AND_CAUSE
;
private
static
Method
LOG_EVENT_WITH_TYPE_AND_NAME
;
private
static
Method
LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS
;
private
static
Method
NEW_TRANSACTION_WITH_TYPE_AND_NAME
;
static
{
try
{
CAT_CLASS
=
Class
.
forName
(
CatNames
.
CAT_CLASS
);
LOG_ERROR_WITH_CAUSE
=
CAT_CLASS
.
getMethod
(
CatNames
.
LOG_ERROR_METHOD
,
Throwable
.
class
);
LOG_ERROR_WITH_MESSAGE_AND_CAUSE
=
CAT_CLASS
.
getMethod
(
CatNames
.
LOG_ERROR_METHOD
,
String
.
class
,
Throwable
.
class
);
LOG_EVENT_WITH_TYPE_AND_NAME
=
CAT_CLASS
.
getMethod
(
CatNames
.
LOG_EVENT_METHOD
,
String
.
class
,
String
.
class
);
LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS
=
CAT_CLASS
.
getMethod
(
CatNames
.
LOG_EVENT_METHOD
,
String
.
class
,
String
.
class
,
String
.
class
,
String
.
class
);
NEW_TRANSACTION_WITH_TYPE_AND_NAME
=
CAT_CLASS
.
getMethod
(
CatNames
.
NEW_TRANSACTION_METHOD
,
String
.
class
,
String
.
class
);
//eager init CatTransaction
CatTransaction
.
init
();
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
"Initialize Cat message producer failed"
,
ex
);
}
}
@Override
public
void
logError
(
Throwable
cause
)
{
try
{
LOG_ERROR_WITH_CAUSE
.
invoke
(
null
,
cause
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
logError
(
String
message
,
Throwable
cause
)
{
try
{
LOG_ERROR_WITH_MESSAGE_AND_CAUSE
.
invoke
(
null
,
message
,
cause
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
logEvent
(
String
type
,
String
name
)
{
try
{
LOG_EVENT_WITH_TYPE_AND_NAME
.
invoke
(
null
,
type
,
name
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
logEvent
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
)
{
try
{
LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS
.
invoke
(
null
,
type
,
name
,
status
,
nameValuePairs
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
Transaction
newTransaction
(
String
type
,
String
name
)
{
try
{
return
new
CatTransaction
(
NEW_TRANSACTION_WITH_TYPE_AND_NAME
.
invoke
(
null
,
type
,
name
));
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatNames.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
.
cat
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
CatNames
{
String
CAT_CLASS
=
"com.dianping.cat.Cat"
;
String
LOG_ERROR_METHOD
=
"logError"
;
String
LOG_EVENT_METHOD
=
"logEvent"
;
String
NEW_TRANSACTION_METHOD
=
"newTransaction"
;
String
CAT_TRANSACTION_CLASS
=
"com.dianping.cat.message.Transaction"
;
String
SET_STATUS_METHOD
=
"setStatus"
;
String
ADD_DATA_METHOD
=
"addData"
;
String
COMPLETE_METHOD
=
"complete"
;
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatTransaction.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
.
cat
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
java.lang.reflect.Method
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
CatTransaction
implements
Transaction
{
private
static
Class
CAT_TRANSACTION_CLASS
;
private
static
Method
SET_STATUS_WITH_STRING
;
private
static
Method
SET_STATUS_WITH_THROWABLE
;
private
static
Method
ADD_DATA_WITH_KEY_AND_VALUE
;
private
static
Method
COMPLETE
;
private
Object
catTransaction
;
static
{
try
{
CAT_TRANSACTION_CLASS
=
Class
.
forName
(
CatNames
.
CAT_TRANSACTION_CLASS
);
SET_STATUS_WITH_STRING
=
CAT_TRANSACTION_CLASS
.
getMethod
(
CatNames
.
SET_STATUS_METHOD
,
String
.
class
);
SET_STATUS_WITH_THROWABLE
=
CAT_TRANSACTION_CLASS
.
getMethod
(
CatNames
.
SET_STATUS_METHOD
,
Throwable
.
class
);
ADD_DATA_WITH_KEY_AND_VALUE
=
CAT_TRANSACTION_CLASS
.
getMethod
(
CatNames
.
ADD_DATA_METHOD
,
String
.
class
,
Object
.
class
);
COMPLETE
=
CAT_TRANSACTION_CLASS
.
getMethod
(
CatNames
.
COMPLETE_METHOD
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
"Initialize Cat transaction failed"
,
ex
);
}
}
static
void
init
()
{
//do nothing, just to initialize the static variables
}
public
CatTransaction
(
Object
catTransaction
)
{
this
.
catTransaction
=
catTransaction
;
}
@Override
public
void
setStatus
(
String
status
)
{
try
{
SET_STATUS_WITH_STRING
.
invoke
(
catTransaction
,
status
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
setStatus
(
Throwable
status
)
{
try
{
SET_STATUS_WITH_THROWABLE
.
invoke
(
catTransaction
,
status
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
addData
(
String
key
,
Object
value
)
{
try
{
ADD_DATA_WITH_KEY_AND_VALUE
.
invoke
(
catTransaction
,
key
,
value
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
@Override
public
void
complete
()
{
try
{
COMPLETE
.
invoke
(
catTransaction
);
}
catch
(
Throwable
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/MessageProducer.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
spi
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
MessageProducer
{
/**
* Log an error.
*
* @param cause root cause exception
*/
public
void
logError
(
Throwable
cause
);
/**
* Log an error.
*
* @param cause root cause exception
*/
public
void
logError
(
String
message
,
Throwable
cause
);
/**
* Log an event in one shot with SUCCESS status.
*
* @param type event type
* @param name event name
*/
public
void
logEvent
(
String
type
,
String
name
);
/**
* Log an event in one shot.
*
* @param type event type
* @param name event name
* @param status "0" means success, otherwise means error code
* @param nameValuePairs name value pairs in the format of "a=1&b=2&..."
*/
public
void
logEvent
(
String
type
,
String
name
,
String
status
,
String
nameValuePairs
);
/**
* Create a new transaction with given type and name.
*
* @param type transaction type
* @param name transaction name
*/
public
Transaction
newTransaction
(
String
type
,
String
name
);
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/MessageProducerManager.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
spi
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
MessageProducerManager
{
/**
* @return the message producer
*/
MessageProducer
getProducer
();
}
apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/spi/Transaction.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
spi
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
Transaction
{
String
SUCCESS
=
"0"
;
/**
* Set the message status.
*
* @param status message status. "0" means success, otherwise error code.
*/
public
void
setStatus
(
String
status
);
/**
* Set the message status with exception class name.
*
* @param e exception.
*/
public
void
setStatus
(
Throwable
e
);
/**
* add one key-value pair to the message.
*/
public
void
addData
(
String
key
,
Object
value
);
/**
* Complete the message construction.
*/
public
void
complete
();
}
apollo-core/src/main/resources/META-INF/services/com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
0 → 100644
View file @
73ce069f
com.ctrip.framework.apollo.tracer.internals.DefaultMessageProducerManager
\ No newline at end of file
apollo-core/src/test/java/com/ctrip/framework/apollo/AllTests.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
;
import
com.ctrip.framework.apollo.core.MetaDomainTest
;
import
com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest
;
import
com.ctrip.framework.apollo.tracer.TracerTest
;
import
com.ctrip.framework.apollo.tracer.internals.DefaultMessageProducerManagerTest
;
import
com.ctrip.framework.apollo.tracer.internals.NullMessageProducerManagerTest
;
import
com.ctrip.framework.apollo.tracer.internals.NullMessageProducerTest
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
MetaDomainTest
.
class
,
ServiceBootstrapTest
.
class
,
NullMessageProducerManagerTest
.
class
,
NullMessageProducerTest
.
class
,
DefaultMessageProducerManagerTest
.
class
,
TracerTest
.
class
})
public
class
AllTests
{
}
apollo-core/src/test/java/com/ctrip/framework/apollo/core/AllTests.java
deleted
100644 → 0
View file @
804eb991
package
com
.
ctrip
.
framework
.
apollo
.
core
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
MetaDomainTest
.
class
})
public
class
AllTests
{
}
apollo-core/src/test/java/com/ctrip/framework/apollo/core/utils/ServiceBootstrapTest.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
core
.
utils
;
import
org.junit.Test
;
import
java.util.ServiceConfigurationError
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
ServiceBootstrapTest
{
@Test
public
void
loadFirstSuccessfully
()
throws
Exception
{
Interface1
service
=
ServiceBootstrap
.
loadFirst
(
Interface1
.
class
);
assertTrue
(
service
instanceof
Interface1Impl
);
}
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
loadFirstWithNoServiceFileDefined
()
throws
Exception
{
ServiceBootstrap
.
loadFirst
(
Interface2
.
class
);
}
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
loadFirstWithServiceFileButNoServiceImpl
()
throws
Exception
{
ServiceBootstrap
.
loadFirst
(
Interface3
.
class
);
}
@Test
(
expected
=
ServiceConfigurationError
.
class
)
public
void
loadFirstWithWrongServiceImpl
()
throws
Exception
{
ServiceBootstrap
.
loadFirst
(
Interface4
.
class
);
}
@Test
(
expected
=
ServiceConfigurationError
.
class
)
public
void
loadFirstWithServiceImplNotExists
()
throws
Exception
{
ServiceBootstrap
.
loadFirst
(
Interface5
.
class
);
}
private
interface
Interface1
{
}
public
static
class
Interface1Impl
implements
Interface1
{
}
private
interface
Interface2
{
}
private
interface
Interface3
{
}
private
interface
Interface4
{
}
private
interface
Interface5
{
}
}
\ No newline at end of file
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/TracerTest.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
;
import
com.ctrip.framework.apollo.tracer.internals.MockMessageProducerManager
;
import
com.ctrip.framework.apollo.tracer.internals.NullTransaction
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
TracerTest
{
private
MessageProducer
someProducer
;
@Before
public
void
setUp
()
throws
Exception
{
someProducer
=
mock
(
MessageProducer
.
class
);
MockMessageProducerManager
.
setProducer
(
someProducer
);
}
@Test
public
void
testLogError
()
throws
Exception
{
String
someMessage
=
"someMessage"
;
Throwable
someCause
=
mock
(
Throwable
.
class
);
Tracer
.
logError
(
someMessage
,
someCause
);
verify
(
someProducer
,
times
(
1
)).
logError
(
someMessage
,
someCause
);
}
@Test
public
void
testLogErrorWithException
()
throws
Exception
{
String
someMessage
=
"someMessage"
;
Throwable
someCause
=
mock
(
Throwable
.
class
);
doThrow
(
RuntimeException
.
class
).
when
(
someProducer
).
logError
(
someMessage
,
someCause
);
Tracer
.
logError
(
someMessage
,
someCause
);
verify
(
someProducer
,
times
(
1
)).
logError
(
someMessage
,
someCause
);
}
@Test
public
void
testLogErrorWithOnlyCause
()
throws
Exception
{
Throwable
someCause
=
mock
(
Throwable
.
class
);
Tracer
.
logError
(
someCause
);
verify
(
someProducer
,
times
(
1
)).
logError
(
someCause
);
}
@Test
public
void
testLogErrorWithOnlyCauseWithException
()
throws
Exception
{
Throwable
someCause
=
mock
(
Throwable
.
class
);
doThrow
(
RuntimeException
.
class
).
when
(
someProducer
).
logError
(
someCause
);
Tracer
.
logError
(
someCause
);
verify
(
someProducer
,
times
(
1
)).
logError
(
someCause
);
}
@Test
public
void
testLogEvent
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
Tracer
.
logEvent
(
someType
,
someName
);
verify
(
someProducer
,
times
(
1
)).
logEvent
(
someType
,
someName
);
}
@Test
public
void
testLogEventWithException
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
doThrow
(
RuntimeException
.
class
).
when
(
someProducer
).
logEvent
(
someType
,
someName
);
Tracer
.
logEvent
(
someType
,
someName
);
verify
(
someProducer
,
times
(
1
)).
logEvent
(
someType
,
someName
);
}
@Test
public
void
testLogEventWithStatusAndNameValuePairs
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
String
someStatus
=
"someStatus"
;
String
someNameValuePairs
=
"someNameValuePairs"
;
Tracer
.
logEvent
(
someType
,
someName
,
someStatus
,
someNameValuePairs
);
verify
(
someProducer
,
times
(
1
)).
logEvent
(
someType
,
someName
,
someStatus
,
someNameValuePairs
);
}
@Test
public
void
testLogEventWithStatusAndNameValuePairsWithException
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
String
someStatus
=
"someStatus"
;
String
someNameValuePairs
=
"someNameValuePairs"
;
doThrow
(
RuntimeException
.
class
).
when
(
someProducer
).
logEvent
(
someType
,
someName
,
someStatus
,
someNameValuePairs
);
Tracer
.
logEvent
(
someType
,
someName
,
someStatus
,
someNameValuePairs
);
verify
(
someProducer
,
times
(
1
)).
logEvent
(
someType
,
someName
,
someStatus
,
someNameValuePairs
);
}
@Test
public
void
testNewTransaction
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
Transaction
someTransaction
=
mock
(
Transaction
.
class
);
when
(
someProducer
.
newTransaction
(
someType
,
someName
)).
thenReturn
(
someTransaction
);
Transaction
result
=
Tracer
.
newTransaction
(
someType
,
someName
);
verify
(
someProducer
,
times
(
1
)).
newTransaction
(
someType
,
someName
);
assertEquals
(
someTransaction
,
result
);
}
@Test
public
void
testNewTransactionWithException
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
when
(
someProducer
.
newTransaction
(
someType
,
someName
)).
thenThrow
(
RuntimeException
.
class
);
Transaction
result
=
Tracer
.
newTransaction
(
someType
,
someName
);
verify
(
someProducer
,
times
(
1
)).
newTransaction
(
someType
,
someName
);
assertTrue
(
result
instanceof
NullTransaction
);
}
}
\ No newline at end of file
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/DefaultMessageProducerManagerTest.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultMessageProducerManagerTest
{
private
MessageProducerManager
messageProducerManager
;
@Before
public
void
setUp
()
throws
Exception
{
messageProducerManager
=
new
DefaultMessageProducerManager
();
}
@Test
public
void
testGetProducer
()
throws
Exception
{
assertTrue
(
messageProducerManager
.
getProducer
()
instanceof
NullMessageProducer
);
}
}
\ No newline at end of file
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/MockMessageProducerManager.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
MockMessageProducerManager
implements
MessageProducerManager
{
private
static
MessageProducer
s_producer
;
@Override
public
MessageProducer
getProducer
()
{
return
s_producer
;
}
public
static
void
setProducer
(
MessageProducer
producer
)
{
s_producer
=
producer
;
}
}
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerManagerTest.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
NullMessageProducerManagerTest
{
private
MessageProducerManager
messageProducerManager
;
@Before
public
void
setUp
()
throws
Exception
{
messageProducerManager
=
new
NullMessageProducerManager
();
}
@Test
public
void
testGetProducer
()
throws
Exception
{
assertTrue
(
messageProducerManager
.
getProducer
()
instanceof
NullMessageProducer
);
}
}
\ No newline at end of file
apollo-core/src/test/java/com/ctrip/framework/apollo/tracer/internals/NullMessageProducerTest.java
0 → 100644
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
tracer
.
internals
;
import
com.ctrip.framework.apollo.tracer.spi.MessageProducer
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
NullMessageProducerTest
{
private
MessageProducer
messageProducer
;
@Before
public
void
setUp
()
throws
Exception
{
messageProducer
=
new
NullMessageProducer
();
}
@Test
public
void
testNewTransaction
()
throws
Exception
{
String
someType
=
"someType"
;
String
someName
=
"someName"
;
assertTrue
(
messageProducer
.
newTransaction
(
someType
,
someName
)
instanceof
NullTransaction
);
}
}
\ No newline at end of file
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface1
0 → 100644
View file @
73ce069f
com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface1Impl
\ No newline at end of file
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface3
0 → 100644
View file @
73ce069f
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface4
0 → 100644
View file @
73ce069f
com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface1Impl
\ No newline at end of file
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$Interface5
0 → 100644
View file @
73ce069f
com.ctrip.framework.apollo.core.utils.ServiceBootstrapTest$SomeImplNotExists
\ No newline at end of file
apollo-core/src/test/resources/META-INF/services/com.ctrip.framework.apollo.tracer.spi.MessageProducerManager
0 → 100644
View file @
73ce069f
com.ctrip.framework.apollo.tracer.internals.MockMessageProducerManager
\ No newline at end of file
apollo-core/src/test/resources/log4j2.xml
0 → 100644
View file @
73ce069f
<?xml version="1.0" encoding="UTF-8"?>
<configuration
monitorInterval=
"60"
>
<appenders>
<Console
name=
"Console"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"[apollo-client][%t]%d %-5p [%c] %m%n"
/>
</Console>
<Async
name=
"Async"
includeLocation=
"true"
>
<AppenderRef
ref=
"Console"
/>
</Async>
</appenders>
<loggers>
<logger
name=
"com.ctrip.framework.apollo"
additivity=
"false"
level=
"trace"
>
<AppenderRef
ref=
"Async"
level=
"DEBUG"
/>
</logger>
<root
level=
"INFO"
>
<AppenderRef
ref=
"Async"
/>
</root>
</loggers>
</configuration>
apollo-demo/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<artifactId>
apollo
</artifactId>
<groupId>
com.ctrip.framework.apollo
</groupId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-demo
</artifactId>
...
...
apollo-portal/pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -18,11 +18,6 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-common
</artifactId>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
...
...
@@ -77,11 +72,6 @@
<package.environment>
github
</package.environment>
</properties>
<dependencies>
<!-- disable cat for outside use -->
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-buildtools
</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java
View file @
73ce069f
...
...
@@ -7,7 +7,7 @@ import com.google.common.collect.Queues;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerAudit
;
import
com.ctrip.framework.apollo.openapi.service.ConsumerService
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -74,7 +74,7 @@ public class ConsumerAuditUtil implements InitializingBean {
consumerService
.
createConsumerAudits
(
toAudit
);
}
}
catch
(
Throwable
ex
)
{
Cat
.
logError
(
ex
);
Tracer
.
logError
(
ex
);
}
}
});
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
73ce069f
...
...
@@ -2,7 +2,6 @@ package com.ctrip.framework.apollo.portal.api;
import
com.google.common.base.Joiner
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.common.dto.AppDTO
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
...
...
@@ -21,7 +20,6 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
...
...
@@ -31,11 +29,9 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.lang.reflect.Type
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/AdminServiceAddressLocator.java
View file @
73ce069f
...
...
@@ -5,7 +5,7 @@ import com.google.common.collect.Lists;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -117,7 +117,7 @@ public class AdminServiceAddressLocator {
}
catch
(
Throwable
e
)
{
logger
.
error
(
String
.
format
(
"Get admin server address from meta server failed. env: %s, meta server address:%s"
,
env
,
MetaDomainConsts
.
getDomain
(
env
)),
e
);
Cat
.
logError
(
String
.
format
(
"Get admin server address from meta server failed. env: %s, meta server address:%s"
,
Tracer
.
logError
(
String
.
format
(
"Get admin server address from meta server failed. env: %s, meta server address:%s"
,
env
,
MetaDomainConsts
.
getDomain
(
env
)),
e
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/PermissionValidator.java
View file @
73ce069f
...
...
@@ -2,8 +2,8 @@ package com.ctrip.framework.apollo.portal.components;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.portal.constant.PermissionType
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/RetryableRestTemplate.java
View file @
73ce069f
...
...
@@ -4,9 +4,8 @@ import com.ctrip.framework.apollo.common.exception.ServiceException;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
org.apache.http.conn.ConnectTimeoutException
;
import
org.apache.http.conn.HttpHostConnectException
;
...
...
@@ -84,7 +83,7 @@ public class RetryableRestTemplate {
}
String
uri
=
uriTemplateHandler
.
expand
(
path
,
uriVariables
).
getPath
();
Transaction
ct
=
Cat
.
newTransaction
(
"AdminAPI"
,
uri
);
Transaction
ct
=
Tracer
.
newTransaction
(
"AdminAPI"
,
uri
);
List
<
ServiceDTO
>
services
=
getAdminServices
(
env
,
ct
);
...
...
@@ -93,14 +92,14 @@ public class RetryableRestTemplate {
T
result
=
doExecute
(
method
,
serviceDTO
,
path
,
request
,
responseType
,
uriVariables
);
ct
.
setStatus
(
Message
.
SUCCESS
);
ct
.
setStatus
(
Transaction
.
SUCCESS
);
ct
.
complete
();
return
result
;
}
catch
(
Throwable
t
)
{
logger
.
error
(
"Http request failed, uri: {}, method: {}"
,
uri
,
method
,
t
);
Cat
.
logError
(
t
);
Tracer
.
logError
(
t
);
if
(
canRetry
(
t
,
method
))
{
Cat
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
Tracer
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
}
else
{
//biz exception rethrow
ct
.
setStatus
(
t
);
ct
.
complete
();
...
...
@@ -123,7 +122,7 @@ public class RetryableRestTemplate {
}
String
uri
=
uriTemplateHandler
.
expand
(
path
,
uriVariables
).
getPath
();
Transaction
ct
=
Cat
.
newTransaction
(
"AdminAPI"
,
uri
);
Transaction
ct
=
Tracer
.
newTransaction
(
"AdminAPI"
,
uri
);
List
<
ServiceDTO
>
services
=
getAdminServices
(
env
,
ct
);
...
...
@@ -133,14 +132,14 @@ public class RetryableRestTemplate {
ResponseEntity
<
T
>
result
=
restTemplate
.
exchange
(
parseHost
(
serviceDTO
)
+
path
,
HttpMethod
.
GET
,
null
,
reference
,
uriVariables
);
ct
.
setStatus
(
Message
.
SUCCESS
);
ct
.
setStatus
(
Transaction
.
SUCCESS
);
ct
.
complete
();
return
result
;
}
catch
(
Throwable
t
)
{
logger
.
error
(
"Http request failed, uri: {}, method: {}"
,
uri
,
HttpMethod
.
GET
,
t
);
Cat
.
logError
(
t
);
Tracer
.
logError
(
t
);
if
(
canRetry
(
t
,
HttpMethod
.
GET
)){
Cat
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
Tracer
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
}
else
{
// biz exception rethrow
ct
.
setStatus
(
t
);
ct
.
complete
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java
View file @
73ce069f
...
...
@@ -5,8 +5,8 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.service.ClusterService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
View file @
73ce069f
...
...
@@ -4,11 +4,11 @@ import com.ctrip.framework.apollo.common.dto.ItemDTO;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceSyncModel
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs
;
import
com.ctrip.framework.apollo.portal.service.ItemService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
73ce069f
...
...
@@ -11,9 +11,8 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceService
;
...
...
@@ -21,8 +20,9 @@ import com.ctrip.framework.apollo.portal.service.AppService;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.
dianping.cat.Cat
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -101,7 +101,7 @@ public class NamespaceController {
namespaceService
.
createNamespace
(
Env
.
valueOf
(
model
.
getEnv
()),
namespace
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"create namespace fail."
,
e
);
Cat
.
logError
(
Tracer
.
logError
(
String
.
format
(
"create namespace fail. (env=%s namespace=%s)"
,
model
.
getEnv
(),
namespace
.
getNamespaceName
()),
e
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java
View file @
73ce069f
...
...
@@ -4,13 +4,13 @@ import com.google.common.collect.Sets;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.AppRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.PermissionCondition
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
View file @
73ce069f
...
...
@@ -3,9 +3,9 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.LogoutHandler
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java
View file @
73ce069f
...
...
@@ -4,9 +4,9 @@ import com.ctrip.framework.apollo.common.dto.AppDTO;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.components.PortalSettings
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.components.PortalSettings
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -37,7 +37,7 @@ public class CreationListener {
appAPI
.
createApp
(
env
,
appDTO
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
"call appAPI.createApp error.(appId={appId}, env={env})"
,
appDTO
.
getAppId
(),
env
,
e
);
Cat
.
logError
(
String
.
format
(
"call appAPI.createApp error. (appId=%s, env=%s)"
,
appDTO
.
getAppId
(),
env
),
e
);
Tracer
.
logError
(
String
.
format
(
"call appAPI.createApp error. (appId=%s, env=%s)"
,
appDTO
.
getAppId
(),
env
),
e
);
}
}
}
...
...
@@ -51,7 +51,7 @@ public class CreationListener {
namespaceAPI
.
createAppNamespace
(
env
,
appNamespace
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
"call appAPI.createApp error.(appId={appId}, env={env})"
,
appNamespace
.
getAppId
(),
env
,
e
);
Cat
.
logError
(
String
.
format
(
"call appAPI.createApp error. (appId=%s, env=%s)"
,
appNamespace
.
getAppId
(),
env
),
e
);
Tracer
.
logError
(
String
.
format
(
"call appAPI.createApp error. (appId=%s, env=%s)"
,
appNamespace
.
getAppId
(),
env
),
e
);
}
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
View file @
73ce069f
...
...
@@ -5,8 +5,8 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
View file @
73ce069f
...
...
@@ -9,11 +9,11 @@ import com.ctrip.framework.apollo.common.utils.BeanUtils;
import
com.ctrip.framework.apollo.common.utils.ExceptionUtils
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.repository.AppRepository
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -107,7 +107,7 @@ public class AppService {
//role
roleInitializationService
.
initAppRoles
(
createdApp
);
Cat
.
logEvent
(
CatEventType
.
CREATE_APP
,
appId
);
Tracer
.
logEvent
(
CatEventType
.
CREATE_APP
,
appId
);
return
createdApp
;
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java
View file @
73ce069f
...
...
@@ -4,9 +4,9 @@ import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -31,7 +31,7 @@ public class ClusterService {
}
ClusterDTO
clusterDTO
=
clusterAPI
.
create
(
env
,
cluster
);
Cat
.
logEvent
(
CatEventType
.
CREATE_CLUSTER
,
cluster
.
getAppId
(),
"0"
,
cluster
.
getName
());
Tracer
.
logEvent
(
CatEventType
.
CREATE_CLUSTER
,
cluster
.
getAppId
(),
"0"
,
cluster
.
getName
());
return
clusterDTO
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.Favorite
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.repository.FavoriteRepository
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java
View file @
73ce069f
...
...
@@ -10,13 +10,13 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.
spi.UserInfoHold
er
;
import
com.ctrip.framework.apollo.portal.
components.txtresolver.ConfigTextResolv
er
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier
;
import
com.ctrip.framework.apollo.portal.
components.txtresolver.ConfigTextResolv
er
;
import
com.
dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.
spi.UserInfoHold
er
;
import
com.
ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
...
@@ -73,9 +73,9 @@ public class ItemService {
changeSets
.
setDataChangeLastModifiedBy
(
userInfoHolder
.
getUser
().
getUserId
());
updateItems
(
appId
,
env
,
clusterName
,
namespaceName
,
changeSets
);
Cat
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE_BY_TEXT
,
Tracer
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE_BY_TEXT
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Cat
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Tracer
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
public
void
updateItems
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
ItemChangeSets
changeSets
){
...
...
@@ -92,7 +92,7 @@ public class ItemService {
item
.
setNamespaceId
(
namespace
.
getId
());
ItemDTO
itemDTO
=
itemAPI
.
createItem
(
appId
,
env
,
clusterName
,
namespaceName
,
item
);
Cat
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Tracer
.
logEvent
(
CatEventType
.
MODIFY_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
return
itemDTO
;
}
...
...
@@ -126,7 +126,7 @@ public class ItemService {
itemAPI
.
updateItemsByChangeSet
(
appId
,
env
,
clusterName
,
namespaceName
,
changeSets
);
Cat
.
logEvent
(
CatEventType
.
SYNC_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Tracer
.
logEvent
(
CatEventType
.
SYNC_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
View file @
73ce069f
...
...
@@ -8,12 +8,12 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.components.ItemsComparator
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -46,7 +46,7 @@ public class NamespaceBranchService {
NamespaceDTO
createdBranch
=
namespaceBranchAPI
.
createBranch
(
appId
,
env
,
parentClusterName
,
namespaceName
,
userInfoHolder
.
getUser
().
getUserId
());
Cat
.
logEvent
(
CatEventType
.
CREATE_GRAY_RELEASE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
parentClusterName
,
Tracer
.
logEvent
(
CatEventType
.
CREATE_GRAY_RELEASE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
parentClusterName
,
namespaceName
));
return
createdBranch
;
...
...
@@ -67,7 +67,7 @@ public class NamespaceBranchService {
namespaceBranchAPI
.
updateBranchGrayRules
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
rules
);
Cat
.
logEvent
(
CatEventType
.
UPDATE_GRAY_RELEASE_RULE
,
Tracer
.
logEvent
(
CatEventType
.
UPDATE_GRAY_RELEASE_RULE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
...
...
@@ -78,7 +78,7 @@ public class NamespaceBranchService {
namespaceBranchAPI
.
deleteBranch
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
operator
);
Cat
.
logEvent
(
CatEventType
.
DELETE_GRAY_RELEASE
,
Tracer
.
logEvent
(
CatEventType
.
DELETE_GRAY_RELEASE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
}
...
...
@@ -92,7 +92,7 @@ public class NamespaceBranchService {
mergedResult
=
releaseService
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
title
,
comment
,
branchName
,
deleteBranch
,
changeSets
);
Cat
.
logEvent
(
CatEventType
.
MERGE_GRAY_RELEASE
,
Tracer
.
logEvent
(
CatEventType
.
MERGE_GRAY_RELEASE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
return
mergedResult
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
73ce069f
...
...
@@ -13,10 +13,10 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -57,7 +57,7 @@ public class NamespaceService {
namespace
.
setDataChangeLastModifiedBy
(
userInfoHolder
.
getUser
().
getUserId
());
NamespaceDTO
createdNamespace
=
namespaceAPI
.
createNamespace
(
env
,
namespace
);
Cat
.
logEvent
(
CatEventType
.
CREATE_NAMESPACE
,
Tracer
.
logEvent
(
CatEventType
.
CREATE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
namespace
.
getAppId
(),
env
,
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
()));
return
createdNamespace
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
View file @
73ce069f
...
...
@@ -9,14 +9,14 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.KVEntity
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseVO
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -55,7 +55,7 @@ public class ReleaseService {
.
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
()
,
releaseBy
);
Cat
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Tracer
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
return
releaseDTO
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java
View file @
73ce069f
...
...
@@ -6,11 +6,11 @@ import com.google.common.collect.Sets;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.PermissionType
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.po.Permission
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
View file @
73ce069f
...
...
@@ -5,9 +5,11 @@ import com.google.common.collect.Maps;
import
com.ctrip.framework.apollo.openapi.filter.ConsumerAuthenticationFilter
;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtil
;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil
;
import
com.ctrip.framework.apollo.portal.service.ServerConfigService
;
import
com.ctrip.framework.apollo.portal.spi.LogoutHandler
;
import
com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.ctrip.CtripLogoutHandler
;
import
com.ctrip.framework.apollo.portal.spi.ctrip.CtripSsoHeartbeatHandler
;
import
com.ctrip.framework.apollo.portal.spi.ctrip.CtripUserInfoHolder
;
...
...
@@ -16,8 +18,6 @@ import com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultLogoutHandler;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultSsoHeartbeatHandler
;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultUserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultUserService
;
import
com.ctrip.framework.apollo.portal.service.ServerConfigService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripLogoutHandler.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
;
import
com.ctrip.framework.apollo.portal.spi.LogoutHandler
;
import
com.ctrip.framework.apollo.portal.service.ServerConfigService
;
import
com.ctrip.framework.apollo.portal.spi.LogoutHandler
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserInfoHolder.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
java.lang.reflect.Method
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/WebContextConfiguration.java
View file @
73ce069f
...
...
@@ -2,9 +2,9 @@ package com.ctrip.framework.apollo.portal.spi.ctrip;
import
com.google.common.base.Strings
;
import
com.ctrip.framework.apollo.portal.service.ServerConfigService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.ctrip.filters.RecordAccessUserFilter
;
import
com.ctrip.framework.apollo.portal.service.ServerConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/filters/RecordAccessUserFilter.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
.
filters
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.dianping.cat.Cat
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
java.io.IOException
;
...
...
@@ -32,7 +32,7 @@ public class RecordAccessUserFilter implements Filter {
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
Cat
.
logEvent
(
CatEventType
.
USER_ACCESS
,
userInfoHolder
.
getUser
().
getUserId
());
Tracer
.
logEvent
(
CatEventType
.
USER_ACCESS
,
userInfoHolder
.
getUser
().
getUserId
());
chain
.
doFilter
(
request
,
response
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
defaultimpl
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
/**
* 不是ctrip的公司默认提供一个假用户
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionServiceTest.java
View file @
73ce069f
...
...
@@ -7,7 +7,8 @@ import org.junit.Test;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.jdbc.Sql
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerServiceTest.java
View file @
73ce069f
...
...
@@ -17,7 +17,8 @@ import java.util.Calendar;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
eq
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtilTest.java
View file @
73ce069f
...
...
@@ -9,7 +9,6 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.runners.MockitoJUnitRunner
;
...
...
@@ -17,12 +16,11 @@ import org.mockito.stubbing.Answer;
import
org.springframework.test.util.ReflectionTestUtils
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
anyCollectionOf
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AllTests.java
View file @
73ce069f
...
...
@@ -6,14 +6,14 @@ import com.ctrip.framework.apollo.openapi.service.ConsumerRolePermissionServiceT
import
com.ctrip.framework.apollo.openapi.service.ConsumerServiceTest
;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtilTest
;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtilTest
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.FileTextResolverTest
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolverTest
;
import
com.ctrip.framework.apollo.portal.controller.ConsumerControllerTest
;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceServiceTest
;
import
com.ctrip.framework.apollo.portal.service.ConfigServiceTest
;
import
com.ctrip.framework.apollo.portal.service.NamespaceServiceTest
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationServiceTest
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionServiceTest
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.FileTextResolverTest
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolverTest
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/RetryableRestTemplateTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.portal.components.AdminServiceAddressLocator
;
import
com.ctrip.framework.apollo.portal.components.RetryableRestTemplate
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/ServiceExceptionTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.google.gson.Gson
;
import
java.nio.charset.Charset
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.portal.controller.AppController
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -18,12 +16,14 @@ import org.springframework.http.HttpStatus;
import
org.springframework.web.client.HttpServerErrorException
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.portal.controller.AppController
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
java.nio.charset.Charset
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
com.google.gson.Gson
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
public
class
ServiceExceptionTest
extends
AbstractUnitTest
{
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/components/txtresolver/FileTextResolverTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
components
.
txtresolver
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.portal.AbstractUnitTest
;
import
org.junit.Assert
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/controller/ConsumerControllerTest.java
View file @
73ce069f
...
...
@@ -2,8 +2,8 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerToken
;
import
com.ctrip.framework.apollo.openapi.service.ConsumerService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -14,7 +14,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import
java.util.Date
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/AppNamespaceServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.portal.AbstractIntegrationTest
;
import
org.junit.Assert
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
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.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/NamespaceServiceTest.java
View file @
73ce069f
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/RoleInitializationServiceTest.java
View file @
73ce069f
...
...
@@ -4,11 +4,11 @@ import com.google.common.collect.Sets;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.portal.AbstractUnitTest
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.constant.PermissionType
;
import
com.ctrip.framework.apollo.portal.entity.po.Permission
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.entity.po.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
org.junit.Test
;
...
...
apollo-portal/src/test/resources/META-INF/plexus/plexus.xml
deleted
100644 → 0
View file @
804eb991
<plexus>
<components>
<component>
<role>
com.dianping.cat.configuration.ClientConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullClientConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.io.TransportManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullTransportManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.message.MessageProducer
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullMessageProducer
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.message.spi.MessageManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.internal.MessageIdFactory
</role>
</requirement>
</requirements>
</component>
<component>
<role>
org.codehaus.plexus.logging.LoggerManager
</role>
<implementation>
com.ctrip.framework.apollo.cat.NullLoggerManager
</implementation>
</component>
</components>
</plexus>
pom.xml
View file @
73ce069f
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
3.0
</version>
<version>
0.
4.0-SNAPSHOT
</version>
<name>
Apollo
</name>
<packaging>
pom
</packaging>
<description>
Ctrip Configuration Center
</description>
...
...
@@ -144,7 +144,12 @@
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
<version>
1.5.0
</version>
<version>
2.1.2
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-service
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
com.ctrip.platform
</groupId>
...
...
@@ -433,6 +438,18 @@
<activeByDefault>
true
</activeByDefault>
</activation>
</profile>
<profile>
<id>
ctrip-dev
</id>
<properties>
<package.environment>
dev
</package.environment>
</properties>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>
ctrip
</id>
<properties>
...
...
@@ -447,6 +464,10 @@
<groupId>
com.ctrip.framework.clogging
</groupId>
<artifactId>
clogging-agent
</artifactId>
</dependency>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
...
scripts/build.sh
View file @
73ce069f
...
...
@@ -24,13 +24,13 @@ cd ..
# package config-service and admin-service
echo
"==== starting to build config-service and admin-service ===="
mvn clean package
-DskipTests
-pl
apollo-configservice,apollo-adminservice
-am
-
Pgithub
-
Dapollo_profile
=
dev
-Dspring_datasource_url
=
$apollo_config_db_url
-Dspring_datasource_username
=
$apollo_config_db_username
-Dspring_datasource_password
=
$apollo_config_db_password
mvn clean package
-DskipTests
-pl
apollo-configservice,apollo-adminservice
-am
-Dapollo_profile
=
dev
-Dspring_datasource_url
=
$apollo_config_db_url
-Dspring_datasource_username
=
$apollo_config_db_username
-Dspring_datasource_password
=
$apollo_config_db_password
echo
"==== building config-service and admin-service finished ===="
echo
"==== starting to build portal ===="
mvn clean package
-DskipTests
-pl
apollo-portal
-am
-
Pgithub
-
Dapollo_profile
=
dev
-Dspring_datasource_url
=
$apollo_portal_db_url
-Dspring_datasource_username
=
$apollo_portal_db_username
-Dspring_datasource_password
=
$apollo_portal_db_password
$META_SERVERS_OPTS
mvn clean package
-DskipTests
-pl
apollo-portal
-am
-Dapollo_profile
=
dev
-Dspring_datasource_url
=
$apollo_portal_db_url
-Dspring_datasource_username
=
$apollo_portal_db_username
-Dspring_datasource_password
=
$apollo_portal_db_password
$META_SERVERS_OPTS
echo
"==== building portal finished ===="
...
...
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