repo_name
stringclasses
5 values
pr_number
int64
1.52k
15.5k
pr_title
stringlengths
8
143
pr_description
stringlengths
0
10.2k
author
stringlengths
3
18
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
11
10.2k
filepath
stringlengths
6
220
before_content
stringlengths
0
597M
after_content
stringlengths
0
597M
label
int64
-1
1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spi; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.internals.PropertiesCompatibleFileConfigRepository; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.test.util.ReflectionTestUtils; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigFile; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.internals.DefaultConfig; import com.ctrip.framework.apollo.internals.JsonConfigFile; import com.ctrip.framework.apollo.internals.LocalFileConfigRepository; import com.ctrip.framework.apollo.internals.PropertiesConfigFile; import com.ctrip.framework.apollo.internals.XmlConfigFile; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.internals.YmlConfigFile; import com.ctrip.framework.apollo.util.ConfigUtil; /** * @author Jason Song(song_s@ctrip.com) */ public class DefaultConfigFactoryTest { private DefaultConfigFactory defaultConfigFactory; private static String someAppId; private static Env someEnv; @Before public void setUp() throws Exception { someAppId = "someId"; someEnv = Env.DEV; MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil()); defaultConfigFactory = spy(new DefaultConfigFactory()); } @After public void tearDown() throws Exception { MockInjector.reset(); } @Test public void testCreate() throws Exception { String someNamespace = "someName"; Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); LocalFileConfigRepository someLocalConfigRepo = mock(LocalFileConfigRepository.class); when(someLocalConfigRepo.getConfig()).thenReturn(someProperties); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(someNamespace); Config result = defaultConfigFactory.create(someNamespace); assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class))); assertEquals(someValue, result.getProperty(someKey, null)); } @Test public void testCreateLocalConfigRepositoryInLocalDev() throws Exception { String someNamespace = "someName"; someEnv = Env.LOCAL; LocalFileConfigRepository localFileConfigRepository = defaultConfigFactory.createLocalConfigRepository(someNamespace); assertNull(ReflectionTestUtils.getField(localFileConfigRepository, "m_upstream")); } @Test public void testCreatePropertiesCompatibleFileConfigRepository() throws Exception { ConfigFileFormat somePropertiesCompatibleFormat = ConfigFileFormat.YML; String someNamespace = "someName" + "." + somePropertiesCompatibleFormat; Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); PropertiesCompatibleFileConfigRepository someRepository = mock(PropertiesCompatibleFileConfigRepository.class); when(someRepository.getConfig()).thenReturn(someProperties); doReturn(someRepository).when(defaultConfigFactory) .createPropertiesCompatibleFileConfigRepository(someNamespace, somePropertiesCompatibleFormat); Config result = defaultConfigFactory.create(someNamespace); assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class))); assertEquals(someValue, result.getProperty(someKey, null)); } @Test public void testCreateConfigFile() throws Exception { String someNamespace = "someName"; String anotherNamespace = "anotherName"; String yetAnotherNamespace = "yetAnotherNamespace"; Properties someProperties = new Properties(); LocalFileConfigRepository someLocalConfigRepo = mock(LocalFileConfigRepository.class); when(someLocalConfigRepo.getConfig()).thenReturn(someProperties); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(someNamespace); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(anotherNamespace); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(yetAnotherNamespace); ConfigFile propertyConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.Properties); ConfigFile xmlConfigFile = defaultConfigFactory.createConfigFile(anotherNamespace, ConfigFileFormat.XML); ConfigFile jsonConfigFile = defaultConfigFactory.createConfigFile(yetAnotherNamespace, ConfigFileFormat.JSON); ConfigFile ymlConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.YML); ConfigFile yamlConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.YAML); assertThat("Should create PropertiesConfigFile for properties format", propertyConfigFile, is(instanceOf( PropertiesConfigFile.class))); assertEquals(someNamespace, propertyConfigFile.getNamespace()); assertThat("Should create XmlConfigFile for xml format", xmlConfigFile, is(instanceOf( XmlConfigFile.class))); assertEquals(anotherNamespace, xmlConfigFile.getNamespace()); assertThat("Should create JsonConfigFile for json format", jsonConfigFile, is(instanceOf( JsonConfigFile.class))); assertEquals(yetAnotherNamespace, jsonConfigFile.getNamespace()); assertThat("Should create YmlConfigFile for yml format", ymlConfigFile, is(instanceOf( YmlConfigFile.class))); assertEquals(someNamespace, ymlConfigFile.getNamespace()); assertThat("Should create YamlConfigFile for yaml format", yamlConfigFile, is(instanceOf( YamlConfigFile.class))); assertEquals(someNamespace, yamlConfigFile.getNamespace()); } @Test public void testDetermineFileFormat() throws Exception { checkFileFormat("abc", ConfigFileFormat.Properties); checkFileFormat("abc.properties", ConfigFileFormat.Properties); checkFileFormat("abc.pRopErties", ConfigFileFormat.Properties); checkFileFormat("abc.xml", ConfigFileFormat.XML); checkFileFormat("abc.xmL", ConfigFileFormat.XML); checkFileFormat("abc.json", ConfigFileFormat.JSON); checkFileFormat("abc.jsOn", ConfigFileFormat.JSON); checkFileFormat("abc.yaml", ConfigFileFormat.YAML); checkFileFormat("abc.yAml", ConfigFileFormat.YAML); checkFileFormat("abc.yml", ConfigFileFormat.YML); checkFileFormat("abc.yMl", ConfigFileFormat.YML); checkFileFormat("abc.properties.yml", ConfigFileFormat.YML); } @Test public void testTrimNamespaceFormat() throws Exception { checkNamespaceName("abc", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abc.properties", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abcproperties", ConfigFileFormat.Properties, "abcproperties"); checkNamespaceName("abc.pRopErties", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abc.xml", ConfigFileFormat.XML, "abc"); checkNamespaceName("abc.xmL", ConfigFileFormat.XML, "abc"); checkNamespaceName("abc.json", ConfigFileFormat.JSON, "abc"); checkNamespaceName("abc.jsOn", ConfigFileFormat.JSON, "abc"); checkNamespaceName("abc.yaml", ConfigFileFormat.YAML, "abc"); checkNamespaceName("abc.yAml", ConfigFileFormat.YAML, "abc"); checkNamespaceName("abc.yml", ConfigFileFormat.YML, "abc"); checkNamespaceName("abc.yMl", ConfigFileFormat.YML, "abc"); checkNamespaceName("abc.proPerties.yml", ConfigFileFormat.YML, "abc.proPerties"); } private void checkFileFormat(String namespaceName, ConfigFileFormat expectedFormat) { assertEquals(expectedFormat, defaultConfigFactory.determineFileFormat(namespaceName)); } private void checkNamespaceName(String namespaceName, ConfigFileFormat format, String expectedNamespaceName) { assertEquals(expectedNamespaceName, defaultConfigFactory.trimNamespaceFormat(namespaceName, format)); } public static class MockConfigUtil extends ConfigUtil { @Override public String getAppId() { return someAppId; } @Override public Env getApolloEnv() { return someEnv; } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spi; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.internals.PropertiesCompatibleFileConfigRepository; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.test.util.ReflectionTestUtils; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigFile; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.internals.DefaultConfig; import com.ctrip.framework.apollo.internals.JsonConfigFile; import com.ctrip.framework.apollo.internals.LocalFileConfigRepository; import com.ctrip.framework.apollo.internals.PropertiesConfigFile; import com.ctrip.framework.apollo.internals.XmlConfigFile; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.internals.YmlConfigFile; import com.ctrip.framework.apollo.util.ConfigUtil; /** * @author Jason Song(song_s@ctrip.com) */ public class DefaultConfigFactoryTest { private DefaultConfigFactory defaultConfigFactory; private static String someAppId; private static Env someEnv; @Before public void setUp() throws Exception { someAppId = "someId"; someEnv = Env.DEV; MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil()); defaultConfigFactory = spy(new DefaultConfigFactory()); } @After public void tearDown() throws Exception { MockInjector.reset(); } @Test public void testCreate() throws Exception { String someNamespace = "someName"; Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); LocalFileConfigRepository someLocalConfigRepo = mock(LocalFileConfigRepository.class); when(someLocalConfigRepo.getConfig()).thenReturn(someProperties); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(someNamespace); Config result = defaultConfigFactory.create(someNamespace); assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class))); assertEquals(someValue, result.getProperty(someKey, null)); } @Test public void testCreateLocalConfigRepositoryInLocalDev() throws Exception { String someNamespace = "someName"; someEnv = Env.LOCAL; LocalFileConfigRepository localFileConfigRepository = defaultConfigFactory.createLocalConfigRepository(someNamespace); assertNull(ReflectionTestUtils.getField(localFileConfigRepository, "m_upstream")); } @Test public void testCreatePropertiesCompatibleFileConfigRepository() throws Exception { ConfigFileFormat somePropertiesCompatibleFormat = ConfigFileFormat.YML; String someNamespace = "someName" + "." + somePropertiesCompatibleFormat; Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); PropertiesCompatibleFileConfigRepository someRepository = mock(PropertiesCompatibleFileConfigRepository.class); when(someRepository.getConfig()).thenReturn(someProperties); doReturn(someRepository).when(defaultConfigFactory) .createPropertiesCompatibleFileConfigRepository(someNamespace, somePropertiesCompatibleFormat); Config result = defaultConfigFactory.create(someNamespace); assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class))); assertEquals(someValue, result.getProperty(someKey, null)); } @Test public void testCreateConfigFile() throws Exception { String someNamespace = "someName"; String anotherNamespace = "anotherName"; String yetAnotherNamespace = "yetAnotherNamespace"; Properties someProperties = new Properties(); LocalFileConfigRepository someLocalConfigRepo = mock(LocalFileConfigRepository.class); when(someLocalConfigRepo.getConfig()).thenReturn(someProperties); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(someNamespace); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(anotherNamespace); doReturn(someLocalConfigRepo).when(defaultConfigFactory).createLocalConfigRepository(yetAnotherNamespace); ConfigFile propertyConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.Properties); ConfigFile xmlConfigFile = defaultConfigFactory.createConfigFile(anotherNamespace, ConfigFileFormat.XML); ConfigFile jsonConfigFile = defaultConfigFactory.createConfigFile(yetAnotherNamespace, ConfigFileFormat.JSON); ConfigFile ymlConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.YML); ConfigFile yamlConfigFile = defaultConfigFactory.createConfigFile(someNamespace, ConfigFileFormat.YAML); assertThat("Should create PropertiesConfigFile for properties format", propertyConfigFile, is(instanceOf( PropertiesConfigFile.class))); assertEquals(someNamespace, propertyConfigFile.getNamespace()); assertThat("Should create XmlConfigFile for xml format", xmlConfigFile, is(instanceOf( XmlConfigFile.class))); assertEquals(anotherNamespace, xmlConfigFile.getNamespace()); assertThat("Should create JsonConfigFile for json format", jsonConfigFile, is(instanceOf( JsonConfigFile.class))); assertEquals(yetAnotherNamespace, jsonConfigFile.getNamespace()); assertThat("Should create YmlConfigFile for yml format", ymlConfigFile, is(instanceOf( YmlConfigFile.class))); assertEquals(someNamespace, ymlConfigFile.getNamespace()); assertThat("Should create YamlConfigFile for yaml format", yamlConfigFile, is(instanceOf( YamlConfigFile.class))); assertEquals(someNamespace, yamlConfigFile.getNamespace()); } @Test public void testDetermineFileFormat() throws Exception { checkFileFormat("abc", ConfigFileFormat.Properties); checkFileFormat("abc.properties", ConfigFileFormat.Properties); checkFileFormat("abc.pRopErties", ConfigFileFormat.Properties); checkFileFormat("abc.xml", ConfigFileFormat.XML); checkFileFormat("abc.xmL", ConfigFileFormat.XML); checkFileFormat("abc.json", ConfigFileFormat.JSON); checkFileFormat("abc.jsOn", ConfigFileFormat.JSON); checkFileFormat("abc.yaml", ConfigFileFormat.YAML); checkFileFormat("abc.yAml", ConfigFileFormat.YAML); checkFileFormat("abc.yml", ConfigFileFormat.YML); checkFileFormat("abc.yMl", ConfigFileFormat.YML); checkFileFormat("abc.properties.yml", ConfigFileFormat.YML); } @Test public void testTrimNamespaceFormat() throws Exception { checkNamespaceName("abc", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abc.properties", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abcproperties", ConfigFileFormat.Properties, "abcproperties"); checkNamespaceName("abc.pRopErties", ConfigFileFormat.Properties, "abc"); checkNamespaceName("abc.xml", ConfigFileFormat.XML, "abc"); checkNamespaceName("abc.xmL", ConfigFileFormat.XML, "abc"); checkNamespaceName("abc.json", ConfigFileFormat.JSON, "abc"); checkNamespaceName("abc.jsOn", ConfigFileFormat.JSON, "abc"); checkNamespaceName("abc.yaml", ConfigFileFormat.YAML, "abc"); checkNamespaceName("abc.yAml", ConfigFileFormat.YAML, "abc"); checkNamespaceName("abc.yml", ConfigFileFormat.YML, "abc"); checkNamespaceName("abc.yMl", ConfigFileFormat.YML, "abc"); checkNamespaceName("abc.proPerties.yml", ConfigFileFormat.YML, "abc.proPerties"); } private void checkFileFormat(String namespaceName, ConfigFileFormat expectedFormat) { assertEquals(expectedFormat, defaultConfigFactory.determineFileFormat(namespaceName)); } private void checkNamespaceName(String namespaceName, ConfigFileFormat format, String expectedNamespaceName) { assertEquals(expectedNamespaceName, defaultConfigFactory.trimNamespaceFormat(namespaceName, format)); } public static class MockConfigUtil extends ConfigUtil { @Override public String getAppId() { return someAppId; } @Override public Env getApolloEnv() { return someEnv; } } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/InstanceService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.InstanceDTO; import com.ctrip.framework.apollo.common.dto.PageDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import org.springframework.stereotype.Service; import java.util.List; import java.util.Set; @Service public class InstanceService { private final AdminServiceAPI.InstanceAPI instanceAPI; public InstanceService(final AdminServiceAPI.InstanceAPI instanceAPI) { this.instanceAPI = instanceAPI; } public PageDTO<InstanceDTO> getByRelease(Env env, long releaseId, int page, int size){ return instanceAPI.getByRelease(env, releaseId, page, size); } public PageDTO<InstanceDTO> getByNamespace(Env env, String appId, String clusterName, String namespaceName, String instanceAppId, int page, int size){ return instanceAPI.getByNamespace(appId, env, clusterName, namespaceName, instanceAppId, page, size); } public int getInstanceCountByNamepsace(String appId, Env env, String clusterName, String namespaceName){ return instanceAPI.getInstanceCountByNamespace(appId, env, clusterName, namespaceName); } public List<InstanceDTO> getByReleasesNotIn(Env env, String appId, String clusterName, String namespaceName, Set<Long> releaseIds){ return instanceAPI.getByReleasesNotIn(appId, env, clusterName, namespaceName, releaseIds); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.InstanceDTO; import com.ctrip.framework.apollo.common.dto.PageDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import org.springframework.stereotype.Service; import java.util.List; import java.util.Set; @Service public class InstanceService { private final AdminServiceAPI.InstanceAPI instanceAPI; public InstanceService(final AdminServiceAPI.InstanceAPI instanceAPI) { this.instanceAPI = instanceAPI; } public PageDTO<InstanceDTO> getByRelease(Env env, long releaseId, int page, int size){ return instanceAPI.getByRelease(env, releaseId, page, size); } public PageDTO<InstanceDTO> getByNamespace(Env env, String appId, String clusterName, String namespaceName, String instanceAppId, int page, int size){ return instanceAPI.getByNamespace(appId, env, clusterName, namespaceName, instanceAppId, page, size); } public int getInstanceCountByNamepsace(String appId, Env env, String clusterName, String namespaceName){ return instanceAPI.getInstanceCountByNamespace(appId, env, clusterName, namespaceName); } public List<InstanceDTO> getByReleasesNotIn(Env env, String appId, String clusterName, String namespaceName, Set<Long> releaseIds){ return instanceAPI.getByReleasesNotIn(appId, env, clusterName, namespaceName, releaseIds); } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/v1/controller/AppControllerTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.v1.controller; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.openapi.entity.ConsumerRole; import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository; import com.ctrip.framework.apollo.openapi.service.ConsumerService; import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.po.Role; import com.ctrip.framework.apollo.portal.repository.PermissionRepository; import com.ctrip.framework.apollo.portal.repository.RolePermissionRepository; import com.ctrip.framework.apollo.portal.repository.RoleRepository; import com.ctrip.framework.apollo.portal.service.AppService; import com.ctrip.framework.apollo.portal.service.ClusterService; 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.google.common.collect.Sets; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; /** * @author wxq */ @RunWith(SpringRunner.class) @WebMvcTest(controllers = AppController.class) @Import(ConsumerService.class) public class AppControllerTest { @Autowired private MockMvc mockMvc; @MockBean private PortalSettings portalSettings; @MockBean private AppService appService; @MockBean private ClusterService clusterService; @MockBean private ConsumerAuthUtil consumerAuthUtil; @MockBean private PermissionRepository permissionRepository; @MockBean private RolePermissionRepository rolePermissionRepository; @MockBean private UserInfoHolder userInfoHolder; @MockBean private ConsumerTokenRepository consumerTokenRepository; @MockBean private ConsumerRepository consumerRepository; @MockBean private ConsumerAuditRepository consumerAuditRepository; @MockBean private ConsumerRoleRepository consumerRoleRepository; @MockBean private PortalConfig portalConfig; @MockBean private RolePermissionService rolePermissionService; @MockBean private UserService userService; @MockBean private RoleRepository roleRepository; @Test public void testFindAppsAuthorized() throws Exception { final long consumerId = 123456; Mockito.when(this.consumerAuthUtil.retrieveConsumerId(Mockito.any())).thenReturn(consumerId); final List<ConsumerRole> consumerRoles = Arrays.asList( generateConsumerRoleByRoleId(6), generateConsumerRoleByRoleId(7), generateConsumerRoleByRoleId(8) ); Mockito.when(this.consumerRoleRepository.findByConsumerId(consumerId)) .thenReturn(consumerRoles); Mockito.when(this.roleRepository.findAllById(Mockito.any())).thenAnswer(invocation -> { Set<Role> roles = new HashSet<>(); Iterable<Long> roleIds = invocation.getArgument(0); for (Long roleId : roleIds) { if (roleId == 6) { roles.add(generateRoleByIdAndRoleName(6, "ModifyNamespace+app1+application+DEV")); } if (roleId == 7) { roles.add(generateRoleByIdAndRoleName(7, "ReleaseNamespace+app1+application+DEV")); } if (roleId == 8) { roles.add(generateRoleByIdAndRoleName(8, "Master+app2")); } } assertEquals(3, roles.size()); return roles; }); this.mockMvc.perform(MockMvcRequestBuilders.get("/openapi/v1/apps/authorized")) .andDo(MockMvcResultHandlers.print()) .andExpect(MockMvcResultMatchers.status().is2xxSuccessful()); Mockito.verify(this.consumerRoleRepository, Mockito.times(1)).findByConsumerId(consumerId); Mockito.verify(this.roleRepository, Mockito.times(1)).findAllById(Mockito.any()); ArgumentCaptor<Set<String>> appIdsCaptor = ArgumentCaptor.forClass(Set.class); Mockito.verify(this.appService).findByAppIds(appIdsCaptor.capture()); Set<String> appIds = appIdsCaptor.getValue(); assertEquals(Sets.newHashSet("app1", "app2"), appIds); } private static ConsumerRole generateConsumerRoleByRoleId(long roleId) { ConsumerRole consumerRole = new ConsumerRole(); consumerRole.setRoleId(roleId); return consumerRole; } private static Role generateRoleByIdAndRoleName(long id, String roleName) { Role role = new Role(); role.setId(id); role.setRoleName(roleName); return role; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.v1.controller; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.openapi.entity.ConsumerRole; import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository; import com.ctrip.framework.apollo.openapi.service.ConsumerService; import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.po.Role; import com.ctrip.framework.apollo.portal.repository.PermissionRepository; import com.ctrip.framework.apollo.portal.repository.RolePermissionRepository; import com.ctrip.framework.apollo.portal.repository.RoleRepository; import com.ctrip.framework.apollo.portal.service.AppService; import com.ctrip.framework.apollo.portal.service.ClusterService; 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.google.common.collect.Sets; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; /** * @author wxq */ @RunWith(SpringRunner.class) @WebMvcTest(controllers = AppController.class) @Import(ConsumerService.class) public class AppControllerTest { @Autowired private MockMvc mockMvc; @MockBean private PortalSettings portalSettings; @MockBean private AppService appService; @MockBean private ClusterService clusterService; @MockBean private ConsumerAuthUtil consumerAuthUtil; @MockBean private PermissionRepository permissionRepository; @MockBean private RolePermissionRepository rolePermissionRepository; @MockBean private UserInfoHolder userInfoHolder; @MockBean private ConsumerTokenRepository consumerTokenRepository; @MockBean private ConsumerRepository consumerRepository; @MockBean private ConsumerAuditRepository consumerAuditRepository; @MockBean private ConsumerRoleRepository consumerRoleRepository; @MockBean private PortalConfig portalConfig; @MockBean private RolePermissionService rolePermissionService; @MockBean private UserService userService; @MockBean private RoleRepository roleRepository; @Test public void testFindAppsAuthorized() throws Exception { final long consumerId = 123456; Mockito.when(this.consumerAuthUtil.retrieveConsumerId(Mockito.any())).thenReturn(consumerId); final List<ConsumerRole> consumerRoles = Arrays.asList( generateConsumerRoleByRoleId(6), generateConsumerRoleByRoleId(7), generateConsumerRoleByRoleId(8) ); Mockito.when(this.consumerRoleRepository.findByConsumerId(consumerId)) .thenReturn(consumerRoles); Mockito.when(this.roleRepository.findAllById(Mockito.any())).thenAnswer(invocation -> { Set<Role> roles = new HashSet<>(); Iterable<Long> roleIds = invocation.getArgument(0); for (Long roleId : roleIds) { if (roleId == 6) { roles.add(generateRoleByIdAndRoleName(6, "ModifyNamespace+app1+application+DEV")); } if (roleId == 7) { roles.add(generateRoleByIdAndRoleName(7, "ReleaseNamespace+app1+application+DEV")); } if (roleId == 8) { roles.add(generateRoleByIdAndRoleName(8, "Master+app2")); } } assertEquals(3, roles.size()); return roles; }); this.mockMvc.perform(MockMvcRequestBuilders.get("/openapi/v1/apps/authorized")) .andDo(MockMvcResultHandlers.print()) .andExpect(MockMvcResultMatchers.status().is2xxSuccessful()); Mockito.verify(this.consumerRoleRepository, Mockito.times(1)).findByConsumerId(consumerId); Mockito.verify(this.roleRepository, Mockito.times(1)).findAllById(Mockito.any()); ArgumentCaptor<Set<String>> appIdsCaptor = ArgumentCaptor.forClass(Set.class); Mockito.verify(this.appService).findByAppIds(appIdsCaptor.capture()); Set<String> appIds = appIdsCaptor.getValue(); assertEquals(Sets.newHashSet("app1", "app2"), appIds); } private static ConsumerRole generateConsumerRoleByRoleId(long roleId) { ConsumerRole consumerRole = new ConsumerRole(); consumerRole.setRoleId(roleId); return consumerRole; } private static Role generateRoleByIdAndRoleName(long id, String roleName) { Role role = new Role(); role.setId(id); role.setRoleName(roleName); return role; } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/FilterLdapByGroupUserSearch.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ldap; import static org.springframework.ldap.query.LdapQueryBuilder.query; import javax.naming.Name; import javax.naming.directory.SearchControls; import javax.naming.ldap.LdapName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.support.BaseLdapPathContextSource; import org.springframework.ldap.support.LdapUtils; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.ldap.SpringSecurityLdapTemplate; import org.springframework.security.ldap.search.FilterBasedLdapUserSearch; /** * the FilterLdapByGroupUserSearch description. * * @author wuzishu */ public class FilterLdapByGroupUserSearch extends FilterBasedLdapUserSearch { private static final Logger logger = LoggerFactory.getLogger(FilterLdapByGroupUserSearch.class); private static final String MEMBER_UID_ATTR_NAME = "memberUid"; private String searchBase; private String groupBase; private String groupSearch; private String rdnKey; private String groupMembershipAttrName; private String loginIdAttrName; private final SearchControls searchControls = new SearchControls(); private BaseLdapPathContextSource contextSource; public FilterLdapByGroupUserSearch(String searchBase, String searchFilter, String groupBase, BaseLdapPathContextSource contextSource, String groupSearch, String rdnKey, String groupMembershipAttrName, String loginIdAttrName) { super(searchBase, searchFilter, contextSource); this.searchBase = searchBase; this.groupBase = groupBase; this.groupSearch = groupSearch; this.contextSource = contextSource; this.rdnKey = rdnKey; this.groupMembershipAttrName = groupMembershipAttrName; this.loginIdAttrName = loginIdAttrName; } private Name searchUserById(String userId) { SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(this.contextSource); template.setSearchControls(searchControls); return template.searchForObject(query().where(this.loginIdAttrName).is(userId), ctx -> ((DirContextAdapter) ctx).getDn()); } @Override public DirContextOperations searchForUser(String username) { if (logger.isDebugEnabled()) { logger.debug("Searching for user '" + username + "', with user search " + this); } SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(this.contextSource); template.setSearchControls(searchControls); return template .searchForObject(groupBase, groupSearch, ctx -> { if (!MEMBER_UID_ATTR_NAME.equals(groupMembershipAttrName)) { String[] members = ((DirContextAdapter) ctx) .getStringAttributes(groupMembershipAttrName); for (String item : members) { LdapName memberDn = LdapUtils.newLdapName(item); LdapName memberRdn = LdapUtils .removeFirst(memberDn, LdapUtils.newLdapName(searchBase)); String rdnValue = LdapUtils.getValue(memberRdn, rdnKey).toString(); if (rdnValue.equalsIgnoreCase(username)) { return new DirContextAdapter(memberRdn.toString()); } } throw new UsernameNotFoundException("User " + username + " not found in directory."); } String[] memberUids = ((DirContextAdapter) ctx) .getStringAttributes(groupMembershipAttrName); for (String memberUid : memberUids) { if (memberUid.equalsIgnoreCase(username)) { Name name = searchUserById(memberUid); LdapName ldapName = LdapUtils.newLdapName(name); LdapName ldapRdn = LdapUtils .removeFirst(ldapName, LdapUtils.newLdapName(searchBase)); return new DirContextAdapter(ldapRdn); } } throw new UsernameNotFoundException("User " + username + " not found in directory."); }); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ldap; import static org.springframework.ldap.query.LdapQueryBuilder.query; import javax.naming.Name; import javax.naming.directory.SearchControls; import javax.naming.ldap.LdapName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.support.BaseLdapPathContextSource; import org.springframework.ldap.support.LdapUtils; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.ldap.SpringSecurityLdapTemplate; import org.springframework.security.ldap.search.FilterBasedLdapUserSearch; /** * the FilterLdapByGroupUserSearch description. * * @author wuzishu */ public class FilterLdapByGroupUserSearch extends FilterBasedLdapUserSearch { private static final Logger logger = LoggerFactory.getLogger(FilterLdapByGroupUserSearch.class); private static final String MEMBER_UID_ATTR_NAME = "memberUid"; private String searchBase; private String groupBase; private String groupSearch; private String rdnKey; private String groupMembershipAttrName; private String loginIdAttrName; private final SearchControls searchControls = new SearchControls(); private BaseLdapPathContextSource contextSource; public FilterLdapByGroupUserSearch(String searchBase, String searchFilter, String groupBase, BaseLdapPathContextSource contextSource, String groupSearch, String rdnKey, String groupMembershipAttrName, String loginIdAttrName) { super(searchBase, searchFilter, contextSource); this.searchBase = searchBase; this.groupBase = groupBase; this.groupSearch = groupSearch; this.contextSource = contextSource; this.rdnKey = rdnKey; this.groupMembershipAttrName = groupMembershipAttrName; this.loginIdAttrName = loginIdAttrName; } private Name searchUserById(String userId) { SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(this.contextSource); template.setSearchControls(searchControls); return template.searchForObject(query().where(this.loginIdAttrName).is(userId), ctx -> ((DirContextAdapter) ctx).getDn()); } @Override public DirContextOperations searchForUser(String username) { if (logger.isDebugEnabled()) { logger.debug("Searching for user '" + username + "', with user search " + this); } SpringSecurityLdapTemplate template = new SpringSecurityLdapTemplate(this.contextSource); template.setSearchControls(searchControls); return template .searchForObject(groupBase, groupSearch, ctx -> { if (!MEMBER_UID_ATTR_NAME.equals(groupMembershipAttrName)) { String[] members = ((DirContextAdapter) ctx) .getStringAttributes(groupMembershipAttrName); for (String item : members) { LdapName memberDn = LdapUtils.newLdapName(item); LdapName memberRdn = LdapUtils .removeFirst(memberDn, LdapUtils.newLdapName(searchBase)); String rdnValue = LdapUtils.getValue(memberRdn, rdnKey).toString(); if (rdnValue.equalsIgnoreCase(username)) { return new DirContextAdapter(memberRdn.toString()); } } throw new UsernameNotFoundException("User " + username + " not found in directory."); } String[] memberUids = ((DirContextAdapter) ctx) .getStringAttributes(groupMembershipAttrName); for (String memberUid : memberUids) { if (memberUid.equalsIgnoreCase(username)) { Name name = searchUserById(memberUid); LdapName ldapName = LdapUtils.newLdapName(name); LdapName ldapRdn = LdapUtils .removeFirst(ldapName, LdapUtils.newLdapName(searchBase)); return new DirContextAdapter(ldapRdn); } } throw new UsernameNotFoundException("User " + username + " not found in directory."); }); } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/test/java/com/ctrip/framework/apollo/LocalPortalApplication.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class LocalPortalApplication { public static void main(String[] args) { new SpringApplicationBuilder(LocalPortalApplication.class).run(args); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class LocalPortalApplication { public static void main(String[] args) { new SpringApplicationBuilder(LocalPortalApplication.class).run(args); } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/controller/CommitControllerTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.portal.AbstractIntegrationTest; import java.util.List; import org.junit.Test; import org.springframework.web.client.HttpClientErrorException; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; /** * Created by kezhenxu at 2019/1/14 12:49. * * @author kezhenxu (kezhenxu at lizhi dot fm) */ public class CommitControllerTest extends AbstractIntegrationTest { @Test public void shouldFailWhenPageOrSiseIsNegative() { try { restTemplate.getForEntity( url("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits?page=-1"), List.class, "1", "env", "cl", "ns" ); fail("should throw"); } catch (final HttpClientErrorException e) { assertThat( new String(e.getResponseBodyAsByteArray()), containsString("page should be positive or 0") ); } try { restTemplate.getForEntity( url("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits?size=0"), List.class, "1", "env", "cl", "ns" ); fail("should throw"); } catch (final HttpClientErrorException e) { assertThat( new String(e.getResponseBodyAsByteArray()), containsString("size should be positive number") ); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.portal.AbstractIntegrationTest; import java.util.List; import org.junit.Test; import org.springframework.web.client.HttpClientErrorException; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; /** * Created by kezhenxu at 2019/1/14 12:49. * * @author kezhenxu (kezhenxu at lizhi dot fm) */ public class CommitControllerTest extends AbstractIntegrationTest { @Test public void shouldFailWhenPageOrSiseIsNegative() { try { restTemplate.getForEntity( url("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits?page=-1"), List.class, "1", "env", "cl", "ns" ); fail("should throw"); } catch (final HttpClientErrorException e) { assertThat( new String(e.getResponseBodyAsByteArray()), containsString("page should be positive or 0") ); } try { restTemplate.getForEntity( url("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits?size=0"), List.class, "1", "env", "cl", "ns" ); fail("should throw"); } catch (final HttpClientErrorException e) { assertThat( new String(e.getResponseBodyAsByteArray()), containsString("size should be positive number") ); } } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserInfoHolder.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ctrip; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import java.lang.reflect.Method; /** * ctrip内部实现的获取用户信息 */ public class CtripUserInfoHolder implements UserInfoHolder { private Object assertionHolder; private Method getAssertion; public CtripUserInfoHolder() { Class clazz = null; try { clazz = Class.forName("org.jasig.cas.client.util.AssertionHolder"); assertionHolder = clazz.newInstance(); getAssertion = assertionHolder.getClass().getMethod("getAssertion"); } catch (Exception e) { throw new RuntimeException("init AssertionHolder fail", e); } } @Override public UserInfo getUser() { try { Object assertion = getAssertion.invoke(assertionHolder); Method getPrincipal = assertion.getClass().getMethod("getPrincipal"); Object principal = getPrincipal.invoke(assertion); Method getName = principal.getClass().getMethod("getName"); String name = (String) getName.invoke(principal); UserInfo userInfo = new UserInfo(); userInfo.setUserId(name); return userInfo; } catch (Exception e) { throw new RuntimeException("get user info from assertion holder error", e); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ctrip; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import java.lang.reflect.Method; /** * ctrip内部实现的获取用户信息 */ public class CtripUserInfoHolder implements UserInfoHolder { private Object assertionHolder; private Method getAssertion; public CtripUserInfoHolder() { Class clazz = null; try { clazz = Class.forName("org.jasig.cas.client.util.AssertionHolder"); assertionHolder = clazz.newInstance(); getAssertion = assertionHolder.getClass().getMethod("getAssertion"); } catch (Exception e) { throw new RuntimeException("init AssertionHolder fail", e); } } @Override public UserInfo getUser() { try { Object assertion = getAssertion.invoke(assertionHolder); Method getPrincipal = assertion.getClass().getMethod("getPrincipal"); Object principal = getPrincipal.invoke(assertion); Method getName = principal.getClass().getMethod("getName"); String name = (String) getName.invoke(principal); UserInfo userInfo = new UserInfo(); userInfo.setUserId(name); return userInfo; } catch (Exception e) { throw new RuntimeException("get user info from assertion holder error", e); } } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/en/_sidebar.md
- [**Home**](en/README.md) - Design Document - [Apollo Config Center Design](en/design/apollo-design.md) - [Apollo Config Center Introduction](en/design/apollo-introduction.md) - [Apollo Core Concept Namespace](en/design/apollo-core-concept-namespace.md) - [Apollo Source Code Analysis](http://www.iocoder.cn/categories/Apollo/) - Deployment Document - [Quick Start](en/deployment/quick-start.md) - [Deployment Quick Start By Docker](en/deployment/quick-start-docker.md) - [Distributed Deployment Guide](en/deployment/distributed-deployment-guide.md) - Development Document - [Apollo Development Guide](en/development/apollo-development-guide.md) - Code Styles - [Eclipse Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) - [Intellij Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) - [Portal Implement User Login Function](en/development/portal-how-to-implement-user-login-function.md) - [Portal Enable Email Service](en/development/portal-how-to-enable-email-service.md) - [Portal Enable Session Store](en/development/portal-how-to-enable-session-store.md) - [Portal Enable Webhook Notification](en/development/portal-how-to-enable-webhook-notification.md) - Usage Document - [Apollo Usage Guide](en/usage/apollo-user-guide.md) - [Java Client Usage Guide](en/usage/java-sdk-user-guide.md) - [.Net Client Usage Guide](en/usage/dotnet-sdk-user-guide.md) - [Go、Python、NodeJS、PHP etc. Client Usage Guide](en/usage/third-party-sdks-user-guide.md) - [Other Language Client User Guide](en/usage/other-language-client-user-guide.md) - [Apollo Openapi Guide](en/usage/apollo-open-api-platform.md) - [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) - [Apollo User Practices](en/usage/apollo-user-practices.md) - [Apollo Security Best Practices](en/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) - FAQ - [Frequently Asked Question](en/faq/faq.md) - [Common Issues In Deployment & Development Phase](en/faq/common-issues-in-deployment-and-development-phase.md) - Other - [Release History](https://github.com/ctripcorp/apollo/releases) - [Apollo Benchmark](en/misc/apollo-benchmark.md) - Community - [Team](en/community/team.md) - [Community Governance](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md) - [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) - [Acknowledgements](en/community/thank-you.md)
- [**Home**](en/README.md) - Design Document - [Apollo Config Center Design](en/design/apollo-design.md) - [Apollo Config Center Introduction](en/design/apollo-introduction.md) - [Apollo Core Concept Namespace](en/design/apollo-core-concept-namespace.md) - [Apollo Source Code Analysis](http://www.iocoder.cn/categories/Apollo/) - Deployment Document - [Quick Start](en/deployment/quick-start.md) - [Deployment Quick Start By Docker](en/deployment/quick-start-docker.md) - [Distributed Deployment Guide](en/deployment/distributed-deployment-guide.md) - Development Document - [Apollo Development Guide](en/development/apollo-development-guide.md) - Code Styles - [Eclipse Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) - [Intellij Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) - [Portal Implement User Login Function](en/development/portal-how-to-implement-user-login-function.md) - [Portal Enable Email Service](en/development/portal-how-to-enable-email-service.md) - [Portal Enable Session Store](en/development/portal-how-to-enable-session-store.md) - [Portal Enable Webhook Notification](en/development/portal-how-to-enable-webhook-notification.md) - Usage Document - [Apollo Usage Guide](en/usage/apollo-user-guide.md) - [Java Client Usage Guide](en/usage/java-sdk-user-guide.md) - [.Net Client Usage Guide](en/usage/dotnet-sdk-user-guide.md) - [Go、Python、NodeJS、PHP etc. Client Usage Guide](en/usage/third-party-sdks-user-guide.md) - [Other Language Client User Guide](en/usage/other-language-client-user-guide.md) - [Apollo Openapi Guide](en/usage/apollo-open-api-platform.md) - [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) - [Apollo User Practices](en/usage/apollo-user-practices.md) - [Apollo Security Best Practices](en/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) - FAQ - [Frequently Asked Question](en/faq/faq.md) - [Common Issues In Deployment & Development Phase](en/faq/common-issues-in-deployment-and-development-phase.md) - Other - [Release History](https://github.com/ctripcorp/apollo/releases) - [Apollo Benchmark](en/misc/apollo-benchmark.md) - Community - [Team](en/community/team.md) - [Community Governance](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md) - [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) - [Acknowledgements](en/community/thank-you.md)
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.util; import com.ctrip.framework.apollo.openapi.service.ConsumerService; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; /** * @author Jason Song(song_s@ctrip.com) */ @Service public class ConsumerAuthUtil { static final String CONSUMER_ID = "ApolloConsumerId"; private final ConsumerService consumerService; public ConsumerAuthUtil(final ConsumerService consumerService) { this.consumerService = consumerService; } public Long getConsumerId(String token) { return consumerService.getConsumerIdByToken(token); } public void storeConsumerId(HttpServletRequest request, Long consumerId) { request.setAttribute(CONSUMER_ID, consumerId); } public long retrieveConsumerId(HttpServletRequest request) { Object value = request.getAttribute(CONSUMER_ID); try { return Long.parseLong(value.toString()); } catch (Throwable ex) { throw new IllegalStateException("No consumer id!", ex); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.util; import com.ctrip.framework.apollo.openapi.service.ConsumerService; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; /** * @author Jason Song(song_s@ctrip.com) */ @Service public class ConsumerAuthUtil { static final String CONSUMER_ID = "ApolloConsumerId"; private final ConsumerService consumerService; public ConsumerAuthUtil(final ConsumerService consumerService) { this.consumerService = consumerService; } public Long getConsumerId(String token) { return consumerService.getConsumerIdByToken(token); } public void storeConsumerId(HttpServletRequest request, Long consumerId) { request.setAttribute(CONSUMER_ID, consumerId); } public long retrieveConsumerId(HttpServletRequest request) { Object value = request.getAttribute(CONSUMER_ID); try { return Long.parseLong(value.toString()); } catch (Throwable ex) { throw new IllegalStateException("No consumer id!", ex); } } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactory.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.config.data.extension.initialize; import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties; import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties; import org.springframework.boot.context.properties.bind.BindHandler; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; /** * @author vdisk <vdisk@foxmail.com> */ public class ApolloClientPropertiesFactory { public static final String PROPERTIES_PREFIX = "apollo.client"; public ApolloClientProperties createApolloClientProperties( Binder binder, BindHandler bindHandler) { return binder.bind(PROPERTIES_PREFIX, Bindable.of(ApolloClientProperties.class), bindHandler).orElse(null); } public OAuth2ClientProperties createOauth2ClientProperties(Binder binder, BindHandler bindHandler) { return binder.bind("spring.security.oauth2.client", Bindable.of(OAuth2ClientProperties.class), bindHandler).orElse(null); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.config.data.extension.initialize; import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties; import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties; import org.springframework.boot.context.properties.bind.BindHandler; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; /** * @author vdisk <vdisk@foxmail.com> */ public class ApolloClientPropertiesFactory { public static final String PROPERTIES_PREFIX = "apollo.client"; public ApolloClientProperties createApolloClientProperties( Binder binder, BindHandler bindHandler) { return binder.bind(PROPERTIES_PREFIX, Bindable.of(ApolloClientProperties.class), bindHandler).orElse(null); } public OAuth2ClientProperties createOauth2ClientProperties(Binder binder, BindHandler bindHandler) { return binder.bind("spring.security.oauth2.client", Bindable.of(OAuth2ClientProperties.class), bindHandler).orElse(null); } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerTokenRepository.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.repository; import com.ctrip.framework.apollo.openapi.entity.ConsumerToken; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.Date; /** * @author Jason Song(song_s@ctrip.com) */ public interface ConsumerTokenRepository extends PagingAndSortingRepository<ConsumerToken, Long> { /** * find consumer token by token * * @param token the token * @param validDate the date when the token is valid */ ConsumerToken findTopByTokenAndExpiresAfter(String token, Date validDate); ConsumerToken findByConsumerId(Long consumerId); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.repository; import com.ctrip.framework.apollo.openapi.entity.ConsumerToken; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.Date; /** * @author Jason Song(song_s@ctrip.com) */ public interface ConsumerTokenRepository extends PagingAndSortingRepository<ConsumerToken, Long> { /** * find consumer token by token * * @param token the token * @param validDate the date when the token is valid */ ConsumerToken findTopByTokenAndExpiresAfter(String token, Date validDate); ConsumerToken findByConsumerId(Long consumerId); }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DefaultDiscoveryService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.metaservice.service; import com.ctrip.framework.apollo.common.condition.ConditionalOnMissingProfile; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import com.ctrip.framework.apollo.tracer.Tracer; import com.netflix.appinfo.InstanceInfo; import com.netflix.discovery.EurekaClient; import com.netflix.discovery.shared.Application; import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; /** * Default discovery service for Eureka */ @Service @ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery"}) public class DefaultDiscoveryService implements DiscoveryService { private final EurekaClient eurekaClient; public DefaultDiscoveryService(final EurekaClient eurekaClient) { this.eurekaClient = eurekaClient; } @Override public List<ServiceDTO> getServiceInstances(String serviceId) { Application application = eurekaClient.getApplication(serviceId); if (application == null || CollectionUtils.isEmpty(application.getInstances())) { Tracer.logEvent("Apollo.Discovery.NotFound", serviceId); return Collections.emptyList(); } return application.getInstances().stream().map(instanceInfoToServiceDTOFunc) .collect(Collectors.toList()); } private static final Function<InstanceInfo, ServiceDTO> instanceInfoToServiceDTOFunc = instance -> { ServiceDTO service = new ServiceDTO(); service.setAppName(instance.getAppName()); service.setInstanceId(instance.getInstanceId()); service.setHomepageUrl(instance.getHomePageUrl()); return service; }; }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.metaservice.service; import com.ctrip.framework.apollo.common.condition.ConditionalOnMissingProfile; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import com.ctrip.framework.apollo.tracer.Tracer; import com.netflix.appinfo.InstanceInfo; import com.netflix.discovery.EurekaClient; import com.netflix.discovery.shared.Application; import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; /** * Default discovery service for Eureka */ @Service @ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery"}) public class DefaultDiscoveryService implements DiscoveryService { private final EurekaClient eurekaClient; public DefaultDiscoveryService(final EurekaClient eurekaClient) { this.eurekaClient = eurekaClient; } @Override public List<ServiceDTO> getServiceInstances(String serviceId) { Application application = eurekaClient.getApplication(serviceId); if (application == null || CollectionUtils.isEmpty(application.getInstances())) { Tracer.logEvent("Apollo.Discovery.NotFound", serviceId); return Collections.emptyList(); } return application.getInstances().stream().map(instanceInfoToServiceDTOFunc) .collect(Collectors.toList()); } private static final Function<InstanceInfo, ServiceDTO> instanceInfoToServiceDTOFunc = instance -> { ServiceDTO service = new ServiceDTO(); service.setAppName(instance.getAppName()); service.setInstanceId(instance.getInstanceId()); service.setHomepageUrl(instance.getHomePageUrl()); return service; }; }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.Commit; import com.ctrip.framework.apollo.biz.repository.CommitRepository; import java.util.Date; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class CommitService { private final CommitRepository commitRepository; public CommitService(final CommitRepository commitRepository) { this.commitRepository = commitRepository; } @Transactional public Commit save(Commit commit){ commit.setId(0);//protection return commitRepository.save(commit); } public List<Commit> find(String appId, String clusterName, String namespaceName, Pageable page){ return commitRepository.findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(appId, clusterName, namespaceName, page); } public List<Commit> find(String appId, String clusterName, String namespaceName, Date lastModifiedTime, Pageable page) { return commitRepository .findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedTimeGreaterThanEqualOrderByIdDesc( appId, clusterName, namespaceName, lastModifiedTime, page); } @Transactional public int batchDelete(String appId, String clusterName, String namespaceName, String operator){ return commitRepository.batchDelete(appId, clusterName, namespaceName, operator); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.Commit; import com.ctrip.framework.apollo.biz.repository.CommitRepository; import java.util.Date; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class CommitService { private final CommitRepository commitRepository; public CommitService(final CommitRepository commitRepository) { this.commitRepository = commitRepository; } @Transactional public Commit save(Commit commit){ commit.setId(0);//protection return commitRepository.save(commit); } public List<Commit> find(String appId, String clusterName, String namespaceName, Pageable page){ return commitRepository.findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(appId, clusterName, namespaceName, page); } public List<Commit> find(String appId, String clusterName, String namespaceName, Date lastModifiedTime, Pageable page) { return commitRepository .findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedTimeGreaterThanEqualOrderByIdDesc( appId, clusterName, namespaceName, lastModifiedTime, page); } @Transactional public int batchDelete(String appId, String clusterName, String namespaceName, String operator){ return commitRepository.batchDelete(appId, clusterName, namespaceName, operator); } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapGroupProperties description. * * @author wuzishu */ public class LdapGroupProperties { /** * group search base */ private String groupBase; /** * group search filter */ private String groupSearch; /** * group membership prop */ private String groupMembership; public String getGroupBase() { return groupBase; } public void setGroupBase(String groupBase) { this.groupBase = groupBase; } public String getGroupSearch() { return groupSearch; } public void setGroupSearch(String groupSearch) { this.groupSearch = groupSearch; } public String getGroupMembership() { return groupMembership; } public void setGroupMembership(String groupMembership) { this.groupMembership = groupMembership; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapGroupProperties description. * * @author wuzishu */ public class LdapGroupProperties { /** * group search base */ private String groupBase; /** * group search filter */ private String groupSearch; /** * group membership prop */ private String groupMembership; public String getGroupBase() { return groupBase; } public void setGroupBase(String groupBase) { this.groupBase = groupBase; } public String getGroupSearch() { return groupSearch; } public void setGroupSearch(String groupSearch) { this.groupSearch = groupSearch; } public String getGroupMembership() { return groupMembership; } public void setGroupMembership(String groupMembership) { this.groupMembership = groupMembership; } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/views/component/merge-and-publish-modal.html
<div class="modal fade" id="mergeAndPublishModal" tabindex="-1" role="dialog"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header panel-primary"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">{{'Component.MergePublish.Title' | translate }}</h4> </div> <div class="modal-body"> {{'Component.MergePublish.Tips' | translate }} <br> <h5>{{'Component.MergePublish.NextStep' | translate }}</h5> <div class="radio"> <label ng-click="toReleaseNamespace.mergeAfterDeleteBranch = 'true'"> <input type="radio" name="deleteBranch" ng-checked="!toReleaseNamespace.mergeAfterDeleteBranch || toReleaseNamespace.mergeAfterDeleteBranch == 'true'"> {{'Component.MergePublish.DeleteGrayscale' | translate }} </label> </div> <div class="radio"> <label ng-click="toReleaseNamespace.mergeAfterDeleteBranch = 'false'"> <input type="radio" name="deleteBranch" ng-checked="toReleaseNamespace.mergeAfterDeleteBranch == 'false'"> {{'Component.MergePublish.ReservedGrayscale' | translate }} </label> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">{{'Common.Cancel' | translate }}</button> <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="showReleaseModal()"> {{'Common.Ok' | translate }} </button> </div> </div> </div> </div>
<div class="modal fade" id="mergeAndPublishModal" tabindex="-1" role="dialog"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header panel-primary"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">{{'Component.MergePublish.Title' | translate }}</h4> </div> <div class="modal-body"> {{'Component.MergePublish.Tips' | translate }} <br> <h5>{{'Component.MergePublish.NextStep' | translate }}</h5> <div class="radio"> <label ng-click="toReleaseNamespace.mergeAfterDeleteBranch = 'true'"> <input type="radio" name="deleteBranch" ng-checked="!toReleaseNamespace.mergeAfterDeleteBranch || toReleaseNamespace.mergeAfterDeleteBranch == 'true'"> {{'Component.MergePublish.DeleteGrayscale' | translate }} </label> </div> <div class="radio"> <label ng-click="toReleaseNamespace.mergeAfterDeleteBranch = 'false'"> <input type="radio" name="deleteBranch" ng-checked="toReleaseNamespace.mergeAfterDeleteBranch == 'false'"> {{'Component.MergePublish.ReservedGrayscale' | translate }} </label> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">{{'Common.Cancel' | translate }}</button> <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="showReleaseModal()"> {{'Common.Ok' | translate }} </button> </div> </div> </div> </div>
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/HttpMessageConverterConfiguration.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.controller; import com.google.common.collect.Lists; import com.google.gson.GsonBuilder; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; import java.util.List; /** * Created by Jason on 5/11/16. */ @Configuration public class HttpMessageConverterConfiguration { @Bean public HttpMessageConverters messageConverters() { GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(); gsonHttpMessageConverter.setGson( new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create()); final List<HttpMessageConverter<?>> converters = Lists.newArrayList( new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(), new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter); return new HttpMessageConverters() { @Override public List<HttpMessageConverter<?>> getConverters() { return converters; } }; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.controller; import com.google.common.collect.Lists; import com.google.gson.GsonBuilder; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; import java.util.List; /** * Created by Jason on 5/11/16. */ @Configuration public class HttpMessageConverterConfiguration { @Bean public HttpMessageConverters messageConverters() { GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(); gsonHttpMessageConverter.setGson( new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create()); final List<HttpMessageConverter<?>> converters = Lists.newArrayList( new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(), new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter); return new HttpMessageConverters() { @Override public List<HttpMessageConverter<?>> getConverters() { return converters; } }; } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/resources/yaml/case3.yaml
# # Copyright 2021 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # root: key1: "someValue" key2: 100
# # Copyright 2021 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # root: key1: "someValue" key2: 100
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseMessageRepository.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import java.util.Collection; import java.util.List; /** * @author Jason Song(song_s@ctrip.com) */ public interface ReleaseMessageRepository extends PagingAndSortingRepository<ReleaseMessage, Long> { List<ReleaseMessage> findFirst500ByIdGreaterThanOrderByIdAsc(Long id); ReleaseMessage findTopByOrderByIdDesc(); ReleaseMessage findTopByMessageInOrderByIdDesc(Collection<String> messages); List<ReleaseMessage> findFirst100ByMessageAndIdLessThanOrderByIdAsc(String message, Long id); @Query("select message, max(id) as id from ReleaseMessage where message in :messages group by message") List<Object[]> findLatestReleaseMessagesGroupByMessages(@Param("messages") Collection<String> messages); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import java.util.Collection; import java.util.List; /** * @author Jason Song(song_s@ctrip.com) */ public interface ReleaseMessageRepository extends PagingAndSortingRepository<ReleaseMessage, Long> { List<ReleaseMessage> findFirst500ByIdGreaterThanOrderByIdAsc(Long id); ReleaseMessage findTopByOrderByIdDesc(); ReleaseMessage findTopByMessageInOrderByIdDesc(Collection<String> messages); List<ReleaseMessage> findFirst100ByMessageAndIdLessThanOrderByIdAsc(String message, Long id); @Query("select message, max(id) as id from ReleaseMessage where message in :messages group by message") List<Object[]> findLatestReleaseMessagesGroupByMessages(@Param("messages") Collection<String> messages); }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/impl/UserDisplayNameEnricher.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.enricher.impl; import com.ctrip.framework.apollo.portal.enricher.AdditionalUserInfoEnricher; import com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import java.util.Map; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; /** * @author vdisk <vdisk@foxmail.com> */ @Component public class UserDisplayNameEnricher implements AdditionalUserInfoEnricher { @Override public void enrichAdditionalUserInfo(UserInfoEnrichedAdapter adapter, Map<String, UserInfo> userInfoMap) { if (StringUtils.hasText(adapter.getFirstUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getFirstUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setFirstUserDisplayName(userInfo.getName()); } } if (StringUtils.hasText(adapter.getSecondUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getSecondUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setSecondUserDisplayName(userInfo.getName()); } } if (StringUtils.hasText(adapter.getThirdUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getThirdUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setThirdUserDisplayName(userInfo.getName()); } } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.enricher.impl; import com.ctrip.framework.apollo.portal.enricher.AdditionalUserInfoEnricher; import com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import java.util.Map; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; /** * @author vdisk <vdisk@foxmail.com> */ @Component public class UserDisplayNameEnricher implements AdditionalUserInfoEnricher { @Override public void enrichAdditionalUserInfo(UserInfoEnrichedAdapter adapter, Map<String, UserInfo> userInfoMap) { if (StringUtils.hasText(adapter.getFirstUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getFirstUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setFirstUserDisplayName(userInfo.getName()); } } if (StringUtils.hasText(adapter.getSecondUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getSecondUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setSecondUserDisplayName(userInfo.getName()); } } if (StringUtils.hasText(adapter.getThirdUserId())) { UserInfo userInfo = userInfoMap.get(adapter.getThirdUserId()); if (userInfo != null && StringUtils.hasText(userInfo.getName())) { adapter.setThirdUserDisplayName(userInfo.getName()); } } } }
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/views/component/entrance.html
<a class="list-group-item hover" href="{{href}}"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <div class="row icon-text icon-{{imgSrc}}"> <p class="btn-title">{{title}}</p> </div> </a>
<a class="list-group-item hover" href="{{href}}"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <div class="row icon-text icon-{{imgSrc}}"> <p class="btn-title">{{title}}</p> </div> </a>
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/scripts/services/SystemInfoService.js
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ appService.service('SystemInfoService', ['$resource', '$q', 'AppUtil', function ($resource, $q, AppUtil) { var system_info_resource = $resource('', {}, { load_system_info: { method: 'GET', url: AppUtil.prefixPath() + '/system-info' }, check_health: { method: 'GET', url: AppUtil.prefixPath() + '/system-info/health' } }); return { load_system_info: function () { var d = $q.defer(); system_info_resource.load_system_info({}, function (result) { d.resolve(result); }, function (result) { d.reject(result); }); return d.promise; }, check_health: function (instanceId, host) { var d = $q.defer(); system_info_resource.check_health({ instanceId: instanceId }, function (result) { d.resolve(result); }, function (result) { d.reject(result); }); return d.promise; } } }]);
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ appService.service('SystemInfoService', ['$resource', '$q', 'AppUtil', function ($resource, $q, AppUtil) { var system_info_resource = $resource('', {}, { load_system_info: { method: 'GET', url: AppUtil.prefixPath() + '/system-info' }, check_health: { method: 'GET', url: AppUtil.prefixPath() + '/system-info/health' } }); return { load_system_info: function () { var d = $q.defer(); system_info_resource.load_system_info({}, function (result) { d.resolve(result); }, function (result) { d.reject(result); }); return d.promise; }, check_health: function (instanceId, host) { var d = $q.defer(); system_info_resource.check_health({ instanceId: instanceId }, function (result) { d.resolve(result); }, function (result) { d.reject(result); }); return d.promise; } } }]);
-1
apolloconfig/apollo
3,819
fix the issue that release messages might be missed in certain scenarios
## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
nobodyiam
2021-07-11T08:32:34Z
2021-07-22T00:09:32Z
9bd47037886468040dacb693db370e6417b31aad
f9c69dbb181e9cb6c5cb0ee08ae915a52430c23a
fix the issue that release messages might be missed in certain scenarios. ## What's the purpose of this PR fix the issue that release messages might be missed in certain scenarios ## Which issue(s) this PR fixes: Fixes #3806 ## Brief changelog 1. record the missing release messages when scanning 2. try to reload and notify the missing release messages for certain amount of times Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./doc/images/local-development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lʉMIn%>ͶdPՊ:F='@y }z@7F`x~U*c4uv:~:W& kե!ZzҒzǦ$%j5^o\[myTҌԐՖuiJe@= Rh  &կ{bs?B-`nE[DM1uX@ zfVpD7>r[:F.tjjNŇuSq)J \,?E V?׉FxčX lUX^k/7⥶A?|tVV N>qS0~KCQ2ӧ%;.@$rsa#36Y{{>y~X@@ON@'gK  0{?ղE H2g)9FP⩗j[!M7YU_ӣb{J -E8N +0?n_ >9  |qsH}5bMZkA6bQq(Hjecч $q4  0>Wd9KRYtR "xiW -'ŝ3Ӈ; "*ne  +pS]A4{weC싒"|G@`ǭu?@\ѱX @"'Ssf@@@@ \@Ek    A    .@"܃5@@@sj@@@ P   DP@E95    ` @@@"(@"@@@T{    PA|N   BKIENDB`
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./CHANGES.md
Changes by Version ================== Release Notes. Apollo 1.9.0 ------------------ * [extend DataChange_CreatedBy, DataChange_LastModifiedBy from 32 to 64.](https://github.com/ctripcorp/apollo/pull/3552) * [add spring configuration metadata](https://github.com/ctripcorp/apollo/pull/3553) * [fix #3551 and optimize ldap samples ](https://github.com/ctripcorp/apollo/pull/3561) * [update wiki url and refine documentation](https://github.com/ctripcorp/apollo/pull/3563) * [slim docker images](https://github.com/ctripcorp/apollo/pull/3572) * [add network strategy guideline to docker quick start](https://github.com/ctripcorp/apollo/pull/3574) * [Added support for consul service discovery](https://github.com/ctripcorp/apollo/pull/3575) * [disable consul in apollo-assembly by default ](https://github.com/ctripcorp/apollo/pull/3585) * [ServiceBootstrap unit test fix](https://github.com/ctripcorp/apollo/pull/3593) * [replace http client implementation with interface ](https://github.com/ctripcorp/apollo/pull/3594) * [Allow users to inject customized instance via ApolloInjectorCustomizer](https://github.com/ctripcorp/apollo/pull/3602) * [Fixes #3606](https://github.com/ctripcorp/apollo/pull/3609) * [Bump xstream from 1.4.15 to 1.4.16](https://github.com/ctripcorp/apollo/pull/3611) * [docs: user practices. Alibaba Sentinel Dashboard Push Rules to apollo](https://github.com/ctripcorp/apollo/pull/3617) * [update known users](https://github.com/ctripcorp/apollo/pull/3619) * [add maven deploy action](https://github.com/ctripcorp/apollo/pull/3620) * [fix the issue that access key doesn't work if appid passed is in different case](https://github.com/ctripcorp/apollo/pull/3627) * [fix oidc logout](https://github.com/ctripcorp/apollo/pull/3628) * [docs: third party sdk nodejs client](https://github.com/ctripcorp/apollo/pull/3632) * [update known users](https://github.com/ctripcorp/apollo/pull/3633) * [docs: use docsify pagination plugin](https://github.com/ctripcorp/apollo/pull/3634) * [apollo client to support jdk16](https://github.com/ctripcorp/apollo/pull/3646) * [add English version of readme](https://github.com/ctripcorp/apollo/pull/3656) * [update known users](https://github.com/ctripcorp/apollo/pull/3657) * [update apolloconfig.com domain](https://github.com/ctripcorp/apollo/pull/3658) * [localize css to speed up the loading of google fonts](https://github.com/ctripcorp/apollo/pull/3660) * [test(apollo-client): use assertEquals instead of assertThat](https://github.com/ctripcorp/apollo/pull/3667) * [test(apollo-client): make timeout more longer when long poll](https://github.com/ctripcorp/apollo/pull/3668) * [fix unit test](https://github.com/ctripcorp/apollo/pull/3669) * [解决日志系统未初始化完成时,apollo 的加载日志没法输出问题](https://github.com/ctripcorp/apollo/pull/3677) * [fix[apollo-configService]: Solve configService startup exception](https://github.com/ctripcorp/apollo/pull/3679) * [Community Governance Proposal](https://github.com/ctripcorp/apollo/pull/3670) * [增加阿波罗client的php库](https://github.com/ctripcorp/apollo/pull/3682) * [Bump xstream from 1.4.16 to 1.4.17](https://github.com/ctripcorp/apollo/pull/3692) * [Improve the nacos registry configuration document](https://github.com/ctripcorp/apollo/pull/3695) * [Remove redundant invoke of trySyncFromUpstream](https://github.com/ctripcorp/apollo/pull/3699) * [add apollo team introduction and community releated contents](https://github.com/ctripcorp/apollo/pull/3713) * [fix oidc sql](https://github.com/ctripcorp/apollo/pull/3720) * [feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent](https://github.com/ctripcorp/apollo/pull/3666) * [add More... link for known users](https://github.com/ctripcorp/apollo/pull/3757) * [update OIDC documentation](https://github.com/ctripcorp/apollo/pull/3766) * [Improve the item-value length limit configuration document](https://github.com/ctripcorp/apollo/pull/3789) * [Use queue#take instead of poll](https://github.com/ctripcorp/apollo/pull/3765) * [feature: add Spring Boot 2.4 config data loader support](https://github.com/ctripcorp/apollo/pull/3754) * [feat(open-api): get authorized apps](https://github.com/ctripcorp/apollo/pull/3647) * [feature: shared session for multi apollo portal](https://github.com/ctripcorp/apollo/pull/3786) * [feature: add email for select user on apollo portal](https://github.com/ctripcorp/apollo/pull/3797) * [feature: modify item comment valid size](https://github.com/ctripcorp/apollo/pull/3803) * [set default session store-type](https://github.com/ctripcorp/apollo/pull/3812) * [speed up the stale issue mark and close phase](https://github.com/ctripcorp/apollo/pull/3808) * [feature: add the delegating password encoder for apollo-portal simple auth](https://github.com/ctripcorp/apollo/pull/3804) * [support release apollo-client-config-data](https://github.com/ctripcorp/apollo/pull/3822) ------------------ All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/6?closed=1)
Changes by Version ================== Release Notes. Apollo 1.9.0 ------------------ * [extend DataChange_CreatedBy, DataChange_LastModifiedBy from 32 to 64.](https://github.com/ctripcorp/apollo/pull/3552) * [add spring configuration metadata](https://github.com/ctripcorp/apollo/pull/3553) * [fix #3551 and optimize ldap samples ](https://github.com/ctripcorp/apollo/pull/3561) * [update wiki url and refine documentation](https://github.com/ctripcorp/apollo/pull/3563) * [slim docker images](https://github.com/ctripcorp/apollo/pull/3572) * [add network strategy guideline to docker quick start](https://github.com/ctripcorp/apollo/pull/3574) * [Added support for consul service discovery](https://github.com/ctripcorp/apollo/pull/3575) * [disable consul in apollo-assembly by default ](https://github.com/ctripcorp/apollo/pull/3585) * [ServiceBootstrap unit test fix](https://github.com/ctripcorp/apollo/pull/3593) * [replace http client implementation with interface ](https://github.com/ctripcorp/apollo/pull/3594) * [Allow users to inject customized instance via ApolloInjectorCustomizer](https://github.com/ctripcorp/apollo/pull/3602) * [Fixes #3606](https://github.com/ctripcorp/apollo/pull/3609) * [Bump xstream from 1.4.15 to 1.4.16](https://github.com/ctripcorp/apollo/pull/3611) * [docs: user practices. Alibaba Sentinel Dashboard Push Rules to apollo](https://github.com/ctripcorp/apollo/pull/3617) * [update known users](https://github.com/ctripcorp/apollo/pull/3619) * [add maven deploy action](https://github.com/ctripcorp/apollo/pull/3620) * [fix the issue that access key doesn't work if appid passed is in different case](https://github.com/ctripcorp/apollo/pull/3627) * [fix oidc logout](https://github.com/ctripcorp/apollo/pull/3628) * [docs: third party sdk nodejs client](https://github.com/ctripcorp/apollo/pull/3632) * [update known users](https://github.com/ctripcorp/apollo/pull/3633) * [docs: use docsify pagination plugin](https://github.com/ctripcorp/apollo/pull/3634) * [apollo client to support jdk16](https://github.com/ctripcorp/apollo/pull/3646) * [add English version of readme](https://github.com/ctripcorp/apollo/pull/3656) * [update known users](https://github.com/ctripcorp/apollo/pull/3657) * [update apolloconfig.com domain](https://github.com/ctripcorp/apollo/pull/3658) * [localize css to speed up the loading of google fonts](https://github.com/ctripcorp/apollo/pull/3660) * [test(apollo-client): use assertEquals instead of assertThat](https://github.com/ctripcorp/apollo/pull/3667) * [test(apollo-client): make timeout more longer when long poll](https://github.com/ctripcorp/apollo/pull/3668) * [fix unit test](https://github.com/ctripcorp/apollo/pull/3669) * [解决日志系统未初始化完成时,apollo 的加载日志没法输出问题](https://github.com/ctripcorp/apollo/pull/3677) * [fix[apollo-configService]: Solve configService startup exception](https://github.com/ctripcorp/apollo/pull/3679) * [Community Governance Proposal](https://github.com/ctripcorp/apollo/pull/3670) * [增加阿波罗client的php库](https://github.com/ctripcorp/apollo/pull/3682) * [Bump xstream from 1.4.16 to 1.4.17](https://github.com/ctripcorp/apollo/pull/3692) * [Improve the nacos registry configuration document](https://github.com/ctripcorp/apollo/pull/3695) * [Remove redundant invoke of trySyncFromUpstream](https://github.com/ctripcorp/apollo/pull/3699) * [add apollo team introduction and community releated contents](https://github.com/ctripcorp/apollo/pull/3713) * [fix oidc sql](https://github.com/ctripcorp/apollo/pull/3720) * [feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent](https://github.com/ctripcorp/apollo/pull/3666) * [add More... link for known users](https://github.com/ctripcorp/apollo/pull/3757) * [update OIDC documentation](https://github.com/ctripcorp/apollo/pull/3766) * [Improve the item-value length limit configuration document](https://github.com/ctripcorp/apollo/pull/3789) * [Use queue#take instead of poll](https://github.com/ctripcorp/apollo/pull/3765) * [feature: add Spring Boot 2.4 config data loader support](https://github.com/ctripcorp/apollo/pull/3754) * [feat(open-api): get authorized apps](https://github.com/ctripcorp/apollo/pull/3647) * [feature: shared session for multi apollo portal](https://github.com/ctripcorp/apollo/pull/3786) * [feature: add email for select user on apollo portal](https://github.com/ctripcorp/apollo/pull/3797) * [feature: modify item comment valid size](https://github.com/ctripcorp/apollo/pull/3803) * [set default session store-type](https://github.com/ctripcorp/apollo/pull/3812) * [speed up the stale issue mark and close phase](https://github.com/ctripcorp/apollo/pull/3808) * [feature: add the delegating password encoder for apollo-portal simple auth](https://github.com/ctripcorp/apollo/pull/3804) * [support release apollo-client-config-data](https://github.com/ctripcorp/apollo/pull/3822) * [Reduce bootstrap time in the situation with large properties](https://github.com/ctripcorp/apollo/pull/3816) ------------------ All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/6?closed=1)
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.boot; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.utils.DeferredLogger; import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory; import com.ctrip.framework.apollo.spring.config.PropertySourcesConstants; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.google.common.base.Splitter; import com.google.common.base.Strings; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.Ordered; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; /** * Initialize apollo system properties and inject the Apollo config in Spring Boot bootstrap phase * * <p>Configuration example:</p> * <pre class="code"> * # set app.id * app.id = 100004458 * # enable apollo bootstrap config and inject 'application' namespace in bootstrap phase * apollo.bootstrap.enabled = true * </pre> * * or * * <pre class="code"> * # set app.id * app.id = 100004458 * # enable apollo bootstrap config * apollo.bootstrap.enabled = true * # will inject 'application' and 'FX.apollo' namespaces in bootstrap phase * apollo.bootstrap.namespaces = application,FX.apollo * </pre> * * * If you want to load Apollo configurations even before Logging System Initialization Phase, * add * <pre class="code"> * # set apollo.bootstrap.eagerLoad.enabled * apollo.bootstrap.eagerLoad.enabled = true * </pre> * * This would be very helpful when your logging configurations is set by Apollo. * * for example, you have defined logback-spring.xml in your project, and you want to inject some attributes into logback-spring.xml. * */ public class ApolloApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> , EnvironmentPostProcessor, Ordered { public static final int DEFAULT_ORDER = 0; private static final Logger logger = LoggerFactory.getLogger(ApolloApplicationContextInitializer.class); private static final Splitter NAMESPACE_SPLITTER = Splitter.on(",").omitEmptyStrings() .trimResults(); public static final String[] APOLLO_SYSTEM_PROPERTIES = {ApolloClientSystemConsts.APP_ID, ApolloClientSystemConsts.APOLLO_CLUSTER, ApolloClientSystemConsts.APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_ACCESS_KEY_SECRET, ApolloClientSystemConsts.APOLLO_META, ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE, ApolloClientSystemConsts.APOLLO_PROPERTY_ORDER_ENABLE}; private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector .getInstance(ConfigPropertySourceFactory.class); private int order = DEFAULT_ORDER; @Override public void initialize(ConfigurableApplicationContext context) { ConfigurableEnvironment environment = context.getEnvironment(); if (!environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, Boolean.class, false)) { logger.debug("Apollo bootstrap config is not enabled for context {}, see property: ${{}}", context, PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED); return; } logger.debug("Apollo bootstrap config is enabled for context {}", context); initialize(environment); } /** * Initialize Apollo Configurations Just after environment is ready. * * @param environment */ protected void initialize(ConfigurableEnvironment environment) { if (environment.getPropertySources().contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)) { //already initialized, replay the logs that were printed before the logging system was initialized DeferredLogger.replayTo(); return; } String namespaces = environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES, ConfigConsts.NAMESPACE_APPLICATION); logger.debug("Apollo bootstrap namespaces: {}", namespaces); List<String> namespaceList = NAMESPACE_SPLITTER.splitToList(namespaces); CompositePropertySource composite = new CompositePropertySource(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); for (String namespace : namespaceList) { Config config = ConfigService.getConfig(namespace); composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource(namespace, config)); } environment.getPropertySources().addFirst(composite); } /** * To fill system properties from environment config */ void initializeSystemProperty(ConfigurableEnvironment environment) { for (String propertyName : APOLLO_SYSTEM_PROPERTIES) { fillSystemPropertyFromEnvironment(environment, propertyName); } } private void fillSystemPropertyFromEnvironment(ConfigurableEnvironment environment, String propertyName) { if (System.getProperty(propertyName) != null) { return; } String propertyValue = environment.getProperty(propertyName); if (Strings.isNullOrEmpty(propertyValue)) { return; } System.setProperty(propertyName, propertyValue); } /** * * In order to load Apollo configurations as early as even before Spring loading logging system phase, * this EnvironmentPostProcessor can be called Just After ConfigFileApplicationListener has succeeded. * * <br /> * The processing sequence would be like this: <br /> * Load Bootstrap properties and application properties -----> load Apollo configuration properties ----> Initialize Logging systems * * @param configurableEnvironment * @param springApplication */ @Override public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) { // should always initialize system properties like app.id in the first place initializeSystemProperty(configurableEnvironment); Boolean eagerLoadEnabled = configurableEnvironment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED, Boolean.class, false); //EnvironmentPostProcessor should not be triggered if you don't want Apollo Loading before Logging System Initialization if (!eagerLoadEnabled) { return; } Boolean bootstrapEnabled = configurableEnvironment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, Boolean.class, false); if (bootstrapEnabled) { DeferredLogger.enable(); initialize(configurableEnvironment); } } /** * @since 1.3.0 */ @Override public int getOrder() { return order; } /** * @since 1.3.0 */ public void setOrder(int order) { this.order = order; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.boot; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.build.ApolloInjector; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.utils.DeferredLogger; import com.ctrip.framework.apollo.spring.config.CachedCompositePropertySource; import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory; import com.ctrip.framework.apollo.spring.config.PropertySourcesConstants; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.base.Splitter; import com.google.common.base.Strings; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.Ordered; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; /** * Initialize apollo system properties and inject the Apollo config in Spring Boot bootstrap phase * * <p>Configuration example:</p> * <pre class="code"> * # set app.id * app.id = 100004458 * # enable apollo bootstrap config and inject 'application' namespace in bootstrap phase * apollo.bootstrap.enabled = true * </pre> * * or * * <pre class="code"> * # set app.id * app.id = 100004458 * # enable apollo bootstrap config * apollo.bootstrap.enabled = true * # will inject 'application' and 'FX.apollo' namespaces in bootstrap phase * apollo.bootstrap.namespaces = application,FX.apollo * </pre> * * * If you want to load Apollo configurations even before Logging System Initialization Phase, * add * <pre class="code"> * # set apollo.bootstrap.eagerLoad.enabled * apollo.bootstrap.eagerLoad.enabled = true * </pre> * * This would be very helpful when your logging configurations is set by Apollo. * * for example, you have defined logback-spring.xml in your project, and you want to inject some attributes into logback-spring.xml. * */ public class ApolloApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> , EnvironmentPostProcessor, Ordered { public static final int DEFAULT_ORDER = 0; private static final Logger logger = LoggerFactory.getLogger(ApolloApplicationContextInitializer.class); private static final Splitter NAMESPACE_SPLITTER = Splitter.on(",").omitEmptyStrings() .trimResults(); public static final String[] APOLLO_SYSTEM_PROPERTIES = {ApolloClientSystemConsts.APP_ID, ApolloClientSystemConsts.APOLLO_CLUSTER, ApolloClientSystemConsts.APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_ACCESS_KEY_SECRET, ApolloClientSystemConsts.APOLLO_META, ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE, ApolloClientSystemConsts.APOLLO_PROPERTY_ORDER_ENABLE, ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE}; private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector .getInstance(ConfigPropertySourceFactory.class); private final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class); private int order = DEFAULT_ORDER; @Override public void initialize(ConfigurableApplicationContext context) { ConfigurableEnvironment environment = context.getEnvironment(); if (!environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, Boolean.class, false)) { logger.debug("Apollo bootstrap config is not enabled for context {}, see property: ${{}}", context, PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED); return; } logger.debug("Apollo bootstrap config is enabled for context {}", context); initialize(environment); } /** * Initialize Apollo Configurations Just after environment is ready. * * @param environment */ protected void initialize(ConfigurableEnvironment environment) { if (environment.getPropertySources().contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)) { //already initialized, replay the logs that were printed before the logging system was initialized DeferredLogger.replayTo(); return; } String namespaces = environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES, ConfigConsts.NAMESPACE_APPLICATION); logger.debug("Apollo bootstrap namespaces: {}", namespaces); List<String> namespaceList = NAMESPACE_SPLITTER.splitToList(namespaces); CompositePropertySource composite; if (configUtil.isPropertyNamesCacheEnabled()) { composite = new CachedCompositePropertySource(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); } else { composite = new CompositePropertySource(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); } for (String namespace : namespaceList) { Config config = ConfigService.getConfig(namespace); composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource(namespace, config)); } environment.getPropertySources().addFirst(composite); } /** * To fill system properties from environment config */ void initializeSystemProperty(ConfigurableEnvironment environment) { for (String propertyName : APOLLO_SYSTEM_PROPERTIES) { fillSystemPropertyFromEnvironment(environment, propertyName); } } private void fillSystemPropertyFromEnvironment(ConfigurableEnvironment environment, String propertyName) { if (System.getProperty(propertyName) != null) { return; } String propertyValue = environment.getProperty(propertyName); if (Strings.isNullOrEmpty(propertyValue)) { return; } System.setProperty(propertyName, propertyValue); } /** * * In order to load Apollo configurations as early as even before Spring loading logging system phase, * this EnvironmentPostProcessor can be called Just After ConfigFileApplicationListener has succeeded. * * <br /> * The processing sequence would be like this: <br /> * Load Bootstrap properties and application properties -----> load Apollo configuration properties ----> Initialize Logging systems * * @param configurableEnvironment * @param springApplication */ @Override public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) { // should always initialize system properties like app.id in the first place initializeSystemProperty(configurableEnvironment); Boolean eagerLoadEnabled = configurableEnvironment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED, Boolean.class, false); //EnvironmentPostProcessor should not be triggered if you don't want Apollo Loading before Logging System Initialization if (!eagerLoadEnabled) { return; } Boolean bootstrapEnabled = configurableEnvironment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, Boolean.class, false); if (bootstrapEnabled) { DeferredLogger.enable(); initialize(configurableEnvironment); } } /** * @since 1.3.0 */ @Override public int getOrder() { return order; } /** * @since 1.3.0 */ public void setOrder(int order) { this.order = order; } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySource.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.config; import com.ctrip.framework.apollo.ConfigChangeListener; import java.util.Set; import org.springframework.core.env.EnumerablePropertySource; import com.ctrip.framework.apollo.Config; /** * Property source wrapper for Config * * @author Jason Song(song_s@ctrip.com) */ public class ConfigPropertySource extends EnumerablePropertySource<Config> { private static final String[] EMPTY_ARRAY = new String[0]; ConfigPropertySource(String name, Config source) { super(name, source); } @Override public String[] getPropertyNames() { Set<String> propertyNames = this.source.getPropertyNames(); if (propertyNames.isEmpty()) { return EMPTY_ARRAY; } return propertyNames.toArray(new String[propertyNames.size()]); } @Override public Object getProperty(String name) { return this.source.getProperty(name, null); } public void addChangeListener(ConfigChangeListener listener) { this.source.addChangeListener(listener); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.config; import com.ctrip.framework.apollo.ConfigChangeListener; import java.util.Set; import org.springframework.core.env.EnumerablePropertySource; import com.ctrip.framework.apollo.Config; /** * Property source wrapper for Config * * @author Jason Song(song_s@ctrip.com) */ public class ConfigPropertySource extends EnumerablePropertySource<Config> { private static final String[] EMPTY_ARRAY = new String[0]; ConfigPropertySource(String name, Config source) { super(name, source); } @Override public boolean containsProperty(String name) { return this.source.getProperty(name, null) != null; } @Override public String[] getPropertyNames() { Set<String> propertyNames = this.source.getPropertyNames(); if (propertyNames.isEmpty()) { return EMPTY_ARRAY; } return propertyNames.toArray(new String[propertyNames.size()]); } @Override public Object getProperty(String name) { return this.source.getProperty(name, null); } public void addChangeListener(ConfigChangeListener listener) { this.source.addChangeListener(listener); } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.config; import com.ctrip.framework.apollo.build.ApolloInjector; import com.ctrip.framework.apollo.spring.property.AutoUpdateConfigChangeListener; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigService; import com.google.common.collect.Sets; import java.util.List; import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.EnvironmentAware; import org.springframework.core.Ordered; import org.springframework.core.PriorityOrdered; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import java.util.Collection; import java.util.Iterator; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; /** * Apollo Property Sources processor for Spring Annotation Based Application. <br /> <br /> * * The reason why PropertySourcesProcessor implements {@link BeanFactoryPostProcessor} instead of * {@link org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor} is that lower versions of * Spring (e.g. 3.1.1) doesn't support registering BeanDefinitionRegistryPostProcessor in ImportBeanDefinitionRegistrar * - {@link com.ctrip.framework.apollo.spring.annotation.ApolloConfigRegistrar} * * @author Jason Song(song_s@ctrip.com) */ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, EnvironmentAware, PriorityOrdered { private static final Multimap<Integer, String> NAMESPACE_NAMES = LinkedHashMultimap.create(); private static final Set<BeanFactory> AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES = Sets.newConcurrentHashSet(); private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector .getInstance(ConfigPropertySourceFactory.class); private final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class); private ConfigurableEnvironment environment; public static boolean addNamespaces(Collection<String> namespaces, int order) { return NAMESPACE_NAMES.putAll(order, namespaces); } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { initializePropertySources(); initializeAutoUpdatePropertiesFeature(beanFactory); } private void initializePropertySources() { if (environment.getPropertySources().contains(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME)) { //already initialized return; } CompositePropertySource composite = new CompositePropertySource(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME); //sort by order asc ImmutableSortedSet<Integer> orders = ImmutableSortedSet.copyOf(NAMESPACE_NAMES.keySet()); Iterator<Integer> iterator = orders.iterator(); while (iterator.hasNext()) { int order = iterator.next(); for (String namespace : NAMESPACE_NAMES.get(order)) { Config config = ConfigService.getConfig(namespace); composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource(namespace, config)); } } // clean up NAMESPACE_NAMES.clear(); // add after the bootstrap property source or to the first if (environment.getPropertySources() .contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)) { // ensure ApolloBootstrapPropertySources is still the first ensureBootstrapPropertyPrecedence(environment); environment.getPropertySources() .addAfter(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME, composite); } else { environment.getPropertySources().addFirst(composite); } } private void ensureBootstrapPropertyPrecedence(ConfigurableEnvironment environment) { MutablePropertySources propertySources = environment.getPropertySources(); PropertySource<?> bootstrapPropertySource = propertySources .get(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); // not exists or already in the first place if (bootstrapPropertySource == null || propertySources.precedenceOf(bootstrapPropertySource) == 0) { return; } propertySources.remove(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); propertySources.addFirst(bootstrapPropertySource); } private void initializeAutoUpdatePropertiesFeature(ConfigurableListableBeanFactory beanFactory) { if (!configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() || !AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES.add(beanFactory)) { return; } AutoUpdateConfigChangeListener autoUpdateConfigChangeListener = new AutoUpdateConfigChangeListener( environment, beanFactory); List<ConfigPropertySource> configPropertySources = configPropertySourceFactory.getAllConfigPropertySources(); for (ConfigPropertySource configPropertySource : configPropertySources) { configPropertySource.addChangeListener(autoUpdateConfigChangeListener); } } @Override public void setEnvironment(Environment environment) { //it is safe enough to cast as all known environment is derived from ConfigurableEnvironment this.environment = (ConfigurableEnvironment) environment; } @Override public int getOrder() { //make it as early as possible return Ordered.HIGHEST_PRECEDENCE; } // for test only static void reset() { NAMESPACE_NAMES.clear(); AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES.clear(); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.config; import com.ctrip.framework.apollo.build.ApolloInjector; import com.ctrip.framework.apollo.spring.property.AutoUpdateConfigChangeListener; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigService; import com.google.common.collect.Sets; import java.util.List; import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.EnvironmentAware; import org.springframework.core.Ordered; import org.springframework.core.PriorityOrdered; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import java.util.Collection; import java.util.Iterator; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; /** * Apollo Property Sources processor for Spring Annotation Based Application. <br /> <br /> * * The reason why PropertySourcesProcessor implements {@link BeanFactoryPostProcessor} instead of * {@link org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor} is that lower versions of * Spring (e.g. 3.1.1) doesn't support registering BeanDefinitionRegistryPostProcessor in ImportBeanDefinitionRegistrar * - {@link com.ctrip.framework.apollo.spring.annotation.ApolloConfigRegistrar} * * @author Jason Song(song_s@ctrip.com) */ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, EnvironmentAware, PriorityOrdered { private static final Multimap<Integer, String> NAMESPACE_NAMES = LinkedHashMultimap.create(); private static final Set<BeanFactory> AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES = Sets.newConcurrentHashSet(); private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector .getInstance(ConfigPropertySourceFactory.class); private final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class); private ConfigurableEnvironment environment; public static boolean addNamespaces(Collection<String> namespaces, int order) { return NAMESPACE_NAMES.putAll(order, namespaces); } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { initializePropertySources(); initializeAutoUpdatePropertiesFeature(beanFactory); } private void initializePropertySources() { if (environment.getPropertySources().contains(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME)) { //already initialized return; } CompositePropertySource composite; if (configUtil.isPropertyNamesCacheEnabled()) { composite = new CachedCompositePropertySource(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME); } else { composite = new CompositePropertySource(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME); } //sort by order asc ImmutableSortedSet<Integer> orders = ImmutableSortedSet.copyOf(NAMESPACE_NAMES.keySet()); Iterator<Integer> iterator = orders.iterator(); while (iterator.hasNext()) { int order = iterator.next(); for (String namespace : NAMESPACE_NAMES.get(order)) { Config config = ConfigService.getConfig(namespace); composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource(namespace, config)); } } // clean up NAMESPACE_NAMES.clear(); // add after the bootstrap property source or to the first if (environment.getPropertySources() .contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)) { // ensure ApolloBootstrapPropertySources is still the first ensureBootstrapPropertyPrecedence(environment); environment.getPropertySources() .addAfter(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME, composite); } else { environment.getPropertySources().addFirst(composite); } } private void ensureBootstrapPropertyPrecedence(ConfigurableEnvironment environment) { MutablePropertySources propertySources = environment.getPropertySources(); PropertySource<?> bootstrapPropertySource = propertySources .get(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); // not exists or already in the first place if (bootstrapPropertySource == null || propertySources.precedenceOf(bootstrapPropertySource) == 0) { return; } propertySources.remove(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); propertySources.addFirst(bootstrapPropertySource); } private void initializeAutoUpdatePropertiesFeature(ConfigurableListableBeanFactory beanFactory) { if (!configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() || !AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES.add(beanFactory)) { return; } AutoUpdateConfigChangeListener autoUpdateConfigChangeListener = new AutoUpdateConfigChangeListener( environment, beanFactory); List<ConfigPropertySource> configPropertySources = configPropertySourceFactory.getAllConfigPropertySources(); for (ConfigPropertySource configPropertySource : configPropertySources) { configPropertySource.addChangeListener(autoUpdateConfigChangeListener); } } @Override public void setEnvironment(Environment environment) { //it is safe enough to cast as all known environment is derived from ConfigurableEnvironment this.environment = (ConfigurableEnvironment) environment; } @Override public int getOrder() { //make it as early as possible return Ordered.HIGHEST_PRECEDENCE; } // for test only static void reset() { NAMESPACE_NAMES.clear(); AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES.clear(); } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util; import static com.ctrip.framework.apollo.util.factory.PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.MetaDomainConsts; import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.EnvUtils; import com.ctrip.framework.apollo.core.utils.DeprecatedPropertyNotifyUtil; import com.ctrip.framework.foundation.Foundation; import com.google.common.base.Strings; import com.google.common.util.concurrent.RateLimiter; import java.io.File; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigUtil { private static final Logger logger = LoggerFactory.getLogger(ConfigUtil.class); private int refreshInterval = 5; private TimeUnit refreshIntervalTimeUnit = TimeUnit.MINUTES; private int connectTimeout = 1000; //1 second private int readTimeout = 5000; //5 seconds private String cluster; private int loadConfigQPS = 2; //2 times per second private int longPollQPS = 2; //2 times per second //for on error retry private long onErrorRetryInterval = 1;//1 second private TimeUnit onErrorRetryIntervalTimeUnit = TimeUnit.SECONDS;//1 second //for typed config cache of parser result, e.g. integer, double, long, etc. private long maxConfigCacheSize = 500;//500 cache key private long configCacheExpireTime = 1;//1 minute private TimeUnit configCacheExpireTimeUnit = TimeUnit.MINUTES;//1 minute private long longPollingInitialDelayInMills = 2000;//2 seconds private boolean autoUpdateInjectedSpringProperties = true; private final RateLimiter warnLogRateLimiter; private boolean propertiesOrdered = false; public ConfigUtil() { warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute initRefreshInterval(); initConnectTimeout(); initReadTimeout(); initCluster(); initQPS(); initMaxConfigCacheSize(); initLongPollingInitialDelayInMills(); initAutoUpdateInjectedSpringProperties(); initPropertiesOrdered(); } /** * Get the app id for the current application. * * @return the app id or ConfigConsts.NO_APPID_PLACEHOLDER if app id is not available */ public String getAppId() { String appId = Foundation.app().getAppId(); if (Strings.isNullOrEmpty(appId)) { appId = ConfigConsts.NO_APPID_PLACEHOLDER; if (warnLogRateLimiter.tryAcquire()) { logger.warn( "app.id is not set, please make sure it is set in classpath:/META-INF/app.properties, now apollo will only load public namespace configurations!"); } } return appId; } /** * Get the access key secret for the current application. * * @return the current access key secret, null if there is no such secret. */ public String getAccessKeySecret() { return Foundation.app().getAccessKeySecret(); } /** * Get the data center info for the current application. * * @return the current data center, null if there is no such info. */ public String getDataCenter() { return Foundation.server().getDataCenter(); } private void initCluster() { //Load data center from system property cluster = System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY); //Use data center as cluster if (Strings.isNullOrEmpty(cluster)) { cluster = getDataCenter(); } //Use default cluster if (Strings.isNullOrEmpty(cluster)) { cluster = ConfigConsts.CLUSTER_NAME_DEFAULT; } } /** * Get the cluster name for the current application. * * @return the cluster name, or "default" if not specified */ public String getCluster() { return cluster; } /** * Get the current environment. * * @return the env, UNKNOWN if env is not set or invalid */ public Env getApolloEnv() { return EnvUtils.transformEnv(Foundation.server().getEnvType()); } public String getLocalIp() { return Foundation.net().getHostAddress(); } public String getMetaServerDomainName() { return MetaDomainConsts.getDomain(getApolloEnv()); } private void initConnectTimeout() { String customizedConnectTimeout = System.getProperty("apollo.connectTimeout"); if (!Strings.isNullOrEmpty(customizedConnectTimeout)) { try { connectTimeout = Integer.parseInt(customizedConnectTimeout); } catch (Throwable ex) { logger.error("Config for apollo.connectTimeout is invalid: {}", customizedConnectTimeout); } } } public int getConnectTimeout() { return connectTimeout; } private void initReadTimeout() { String customizedReadTimeout = System.getProperty("apollo.readTimeout"); if (!Strings.isNullOrEmpty(customizedReadTimeout)) { try { readTimeout = Integer.parseInt(customizedReadTimeout); } catch (Throwable ex) { logger.error("Config for apollo.readTimeout is invalid: {}", customizedReadTimeout); } } } public int getReadTimeout() { return readTimeout; } private void initRefreshInterval() { String customizedRefreshInterval = System.getProperty("apollo.refreshInterval"); if (!Strings.isNullOrEmpty(customizedRefreshInterval)) { try { refreshInterval = Integer.parseInt(customizedRefreshInterval); } catch (Throwable ex) { logger.error("Config for apollo.refreshInterval is invalid: {}", customizedRefreshInterval); } } } public int getRefreshInterval() { return refreshInterval; } public TimeUnit getRefreshIntervalTimeUnit() { return refreshIntervalTimeUnit; } private void initQPS() { String customizedLoadConfigQPS = System.getProperty("apollo.loadConfigQPS"); if (!Strings.isNullOrEmpty(customizedLoadConfigQPS)) { try { loadConfigQPS = Integer.parseInt(customizedLoadConfigQPS); } catch (Throwable ex) { logger.error("Config for apollo.loadConfigQPS is invalid: {}", customizedLoadConfigQPS); } } String customizedLongPollQPS = System.getProperty("apollo.longPollQPS"); if (!Strings.isNullOrEmpty(customizedLongPollQPS)) { try { longPollQPS = Integer.parseInt(customizedLongPollQPS); } catch (Throwable ex) { logger.error("Config for apollo.longPollQPS is invalid: {}", customizedLongPollQPS); } } } public int getLoadConfigQPS() { return loadConfigQPS; } public int getLongPollQPS() { return longPollQPS; } public long getOnErrorRetryInterval() { return onErrorRetryInterval; } public TimeUnit getOnErrorRetryIntervalTimeUnit() { return onErrorRetryIntervalTimeUnit; } public String getDefaultLocalCacheDir() { String cacheRoot = getCustomizedCacheRoot(); if (!Strings.isNullOrEmpty(cacheRoot)) { return cacheRoot + File.separator + getAppId(); } cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s"; return String.format(cacheRoot, getAppId()); } private String getCustomizedCacheRoot() { // 1. Get from System Property String cacheRoot = System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); if (Strings.isNullOrEmpty(cacheRoot)) { // 2. Get from OS environment variable cacheRoot = System.getenv(ApolloClientSystemConsts.APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); } if (Strings.isNullOrEmpty(cacheRoot)) { // 3. Get from server.properties cacheRoot = Foundation.server().getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, null); } if (Strings.isNullOrEmpty(cacheRoot)) { // 4. Get from app.properties cacheRoot = Foundation.app().getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, null); } if (Strings.isNullOrEmpty(cacheRoot)) { // 5. Get from deprecated config cacheRoot = getDeprecatedCustomizedCacheRoot(); } return cacheRoot; } @SuppressWarnings("deprecation") private String getDeprecatedCustomizedCacheRoot() { // 1. Get from System Property String cacheRoot = System.getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } if (Strings.isNullOrEmpty(cacheRoot)) { // 2. Get from OS environment variable cacheRoot = System.getenv(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil .warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES, ApolloClientSystemConsts.APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); } } if (Strings.isNullOrEmpty(cacheRoot)) { // 3. Get from server.properties cacheRoot = Foundation.server().getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, null); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } } if (Strings.isNullOrEmpty(cacheRoot)) { // 4. Get from app.properties cacheRoot = Foundation.app().getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, null); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } } return cacheRoot; } public boolean isInLocalMode() { try { return Env.LOCAL == getApolloEnv(); } catch (Throwable ex) { //ignore } return false; } public boolean isOSWindows() { String osName = System.getProperty("os.name"); if (Strings.isNullOrEmpty(osName)) { return false; } return osName.startsWith("Windows"); } private void initMaxConfigCacheSize() { String customizedConfigCacheSize = System.getProperty("apollo.configCacheSize"); if (!Strings.isNullOrEmpty(customizedConfigCacheSize)) { try { maxConfigCacheSize = Long.parseLong(customizedConfigCacheSize); } catch (Throwable ex) { logger.error("Config for apollo.configCacheSize is invalid: {}", customizedConfigCacheSize); } } } public long getMaxConfigCacheSize() { return maxConfigCacheSize; } public long getConfigCacheExpireTime() { return configCacheExpireTime; } public TimeUnit getConfigCacheExpireTimeUnit() { return configCacheExpireTimeUnit; } private void initLongPollingInitialDelayInMills() { String customizedLongPollingInitialDelay = System .getProperty("apollo.longPollingInitialDelayInMills"); if (!Strings.isNullOrEmpty(customizedLongPollingInitialDelay)) { try { longPollingInitialDelayInMills = Long.parseLong(customizedLongPollingInitialDelay); } catch (Throwable ex) { logger.error("Config for apollo.longPollingInitialDelayInMills is invalid: {}", customizedLongPollingInitialDelay); } } } public long getLongPollingInitialDelayInMills() { return longPollingInitialDelayInMills; } private void initAutoUpdateInjectedSpringProperties() { // 1. Get from System Property String enableAutoUpdate = System.getProperty("apollo.autoUpdateInjectedSpringProperties"); if (Strings.isNullOrEmpty(enableAutoUpdate)) { // 2. Get from app.properties enableAutoUpdate = Foundation.app() .getProperty("apollo.autoUpdateInjectedSpringProperties", null); } if (!Strings.isNullOrEmpty(enableAutoUpdate)) { autoUpdateInjectedSpringProperties = Boolean.parseBoolean(enableAutoUpdate.trim()); } } public boolean isAutoUpdateInjectedSpringPropertiesEnabled() { return autoUpdateInjectedSpringProperties; } private void initPropertiesOrdered() { String enablePropertiesOrdered = System.getProperty(APOLLO_PROPERTY_ORDER_ENABLE); if (Strings.isNullOrEmpty(enablePropertiesOrdered)) { enablePropertiesOrdered = Foundation.app().getProperty(APOLLO_PROPERTY_ORDER_ENABLE, "false"); } if (!Strings.isNullOrEmpty(enablePropertiesOrdered)) { try { propertiesOrdered = Boolean.parseBoolean(enablePropertiesOrdered); } catch (Throwable ex) { logger.warn("Config for {} is invalid: {}, set default value: false", APOLLO_PROPERTY_ORDER_ENABLE, enablePropertiesOrdered); } } } public boolean isPropertiesOrderEnabled() { return propertiesOrdered; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util; import static com.ctrip.framework.apollo.util.factory.PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.MetaDomainConsts; import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.EnvUtils; import com.ctrip.framework.apollo.core.utils.DeprecatedPropertyNotifyUtil; import com.ctrip.framework.foundation.Foundation; import com.google.common.base.Strings; import com.google.common.util.concurrent.RateLimiter; import java.io.File; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigUtil { private static final Logger logger = LoggerFactory.getLogger(ConfigUtil.class); private int refreshInterval = 5; private TimeUnit refreshIntervalTimeUnit = TimeUnit.MINUTES; private int connectTimeout = 1000; //1 second private int readTimeout = 5000; //5 seconds private String cluster; private int loadConfigQPS = 2; //2 times per second private int longPollQPS = 2; //2 times per second //for on error retry private long onErrorRetryInterval = 1;//1 second private TimeUnit onErrorRetryIntervalTimeUnit = TimeUnit.SECONDS;//1 second //for typed config cache of parser result, e.g. integer, double, long, etc. private long maxConfigCacheSize = 500;//500 cache key private long configCacheExpireTime = 1;//1 minute private TimeUnit configCacheExpireTimeUnit = TimeUnit.MINUTES;//1 minute private long longPollingInitialDelayInMills = 2000;//2 seconds private boolean autoUpdateInjectedSpringProperties = true; private final RateLimiter warnLogRateLimiter; private boolean propertiesOrdered = false; private boolean propertyNamesCacheEnabled = false; public ConfigUtil() { warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute initRefreshInterval(); initConnectTimeout(); initReadTimeout(); initCluster(); initQPS(); initMaxConfigCacheSize(); initLongPollingInitialDelayInMills(); initAutoUpdateInjectedSpringProperties(); initPropertiesOrdered(); initPropertyNamesCacheEnabled(); } /** * Get the app id for the current application. * * @return the app id or ConfigConsts.NO_APPID_PLACEHOLDER if app id is not available */ public String getAppId() { String appId = Foundation.app().getAppId(); if (Strings.isNullOrEmpty(appId)) { appId = ConfigConsts.NO_APPID_PLACEHOLDER; if (warnLogRateLimiter.tryAcquire()) { logger.warn( "app.id is not set, please make sure it is set in classpath:/META-INF/app.properties, now apollo will only load public namespace configurations!"); } } return appId; } /** * Get the access key secret for the current application. * * @return the current access key secret, null if there is no such secret. */ public String getAccessKeySecret() { return Foundation.app().getAccessKeySecret(); } /** * Get the data center info for the current application. * * @return the current data center, null if there is no such info. */ public String getDataCenter() { return Foundation.server().getDataCenter(); } private void initCluster() { //Load data center from system property cluster = System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY); //Use data center as cluster if (Strings.isNullOrEmpty(cluster)) { cluster = getDataCenter(); } //Use default cluster if (Strings.isNullOrEmpty(cluster)) { cluster = ConfigConsts.CLUSTER_NAME_DEFAULT; } } /** * Get the cluster name for the current application. * * @return the cluster name, or "default" if not specified */ public String getCluster() { return cluster; } /** * Get the current environment. * * @return the env, UNKNOWN if env is not set or invalid */ public Env getApolloEnv() { return EnvUtils.transformEnv(Foundation.server().getEnvType()); } public String getLocalIp() { return Foundation.net().getHostAddress(); } public String getMetaServerDomainName() { return MetaDomainConsts.getDomain(getApolloEnv()); } private void initConnectTimeout() { String customizedConnectTimeout = System.getProperty("apollo.connectTimeout"); if (!Strings.isNullOrEmpty(customizedConnectTimeout)) { try { connectTimeout = Integer.parseInt(customizedConnectTimeout); } catch (Throwable ex) { logger.error("Config for apollo.connectTimeout is invalid: {}", customizedConnectTimeout); } } } public int getConnectTimeout() { return connectTimeout; } private void initReadTimeout() { String customizedReadTimeout = System.getProperty("apollo.readTimeout"); if (!Strings.isNullOrEmpty(customizedReadTimeout)) { try { readTimeout = Integer.parseInt(customizedReadTimeout); } catch (Throwable ex) { logger.error("Config for apollo.readTimeout is invalid: {}", customizedReadTimeout); } } } public int getReadTimeout() { return readTimeout; } private void initRefreshInterval() { String customizedRefreshInterval = System.getProperty("apollo.refreshInterval"); if (!Strings.isNullOrEmpty(customizedRefreshInterval)) { try { refreshInterval = Integer.parseInt(customizedRefreshInterval); } catch (Throwable ex) { logger.error("Config for apollo.refreshInterval is invalid: {}", customizedRefreshInterval); } } } public int getRefreshInterval() { return refreshInterval; } public TimeUnit getRefreshIntervalTimeUnit() { return refreshIntervalTimeUnit; } private void initQPS() { String customizedLoadConfigQPS = System.getProperty("apollo.loadConfigQPS"); if (!Strings.isNullOrEmpty(customizedLoadConfigQPS)) { try { loadConfigQPS = Integer.parseInt(customizedLoadConfigQPS); } catch (Throwable ex) { logger.error("Config for apollo.loadConfigQPS is invalid: {}", customizedLoadConfigQPS); } } String customizedLongPollQPS = System.getProperty("apollo.longPollQPS"); if (!Strings.isNullOrEmpty(customizedLongPollQPS)) { try { longPollQPS = Integer.parseInt(customizedLongPollQPS); } catch (Throwable ex) { logger.error("Config for apollo.longPollQPS is invalid: {}", customizedLongPollQPS); } } } public int getLoadConfigQPS() { return loadConfigQPS; } public int getLongPollQPS() { return longPollQPS; } public long getOnErrorRetryInterval() { return onErrorRetryInterval; } public TimeUnit getOnErrorRetryIntervalTimeUnit() { return onErrorRetryIntervalTimeUnit; } public String getDefaultLocalCacheDir() { String cacheRoot = getCustomizedCacheRoot(); if (!Strings.isNullOrEmpty(cacheRoot)) { return cacheRoot + File.separator + getAppId(); } cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s"; return String.format(cacheRoot, getAppId()); } private String getCustomizedCacheRoot() { // 1. Get from System Property String cacheRoot = System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); if (Strings.isNullOrEmpty(cacheRoot)) { // 2. Get from OS environment variable cacheRoot = System.getenv(ApolloClientSystemConsts.APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); } if (Strings.isNullOrEmpty(cacheRoot)) { // 3. Get from server.properties cacheRoot = Foundation.server().getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, null); } if (Strings.isNullOrEmpty(cacheRoot)) { // 4. Get from app.properties cacheRoot = Foundation.app().getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, null); } if (Strings.isNullOrEmpty(cacheRoot)) { // 5. Get from deprecated config cacheRoot = getDeprecatedCustomizedCacheRoot(); } return cacheRoot; } @SuppressWarnings("deprecation") private String getDeprecatedCustomizedCacheRoot() { // 1. Get from System Property String cacheRoot = System.getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } if (Strings.isNullOrEmpty(cacheRoot)) { // 2. Get from OS environment variable cacheRoot = System.getenv(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil .warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES, ApolloClientSystemConsts.APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES); } } if (Strings.isNullOrEmpty(cacheRoot)) { // 3. Get from server.properties cacheRoot = Foundation.server().getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, null); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } } if (Strings.isNullOrEmpty(cacheRoot)) { // 4. Get from app.properties cacheRoot = Foundation.app().getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, null); if (!Strings.isNullOrEmpty(cacheRoot)) { DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, ApolloClientSystemConsts.APOLLO_CACHE_DIR); } } return cacheRoot; } public boolean isInLocalMode() { try { return Env.LOCAL == getApolloEnv(); } catch (Throwable ex) { //ignore } return false; } public boolean isOSWindows() { String osName = System.getProperty("os.name"); if (Strings.isNullOrEmpty(osName)) { return false; } return osName.startsWith("Windows"); } private void initMaxConfigCacheSize() { String customizedConfigCacheSize = System.getProperty("apollo.configCacheSize"); if (!Strings.isNullOrEmpty(customizedConfigCacheSize)) { try { maxConfigCacheSize = Long.parseLong(customizedConfigCacheSize); } catch (Throwable ex) { logger.error("Config for apollo.configCacheSize is invalid: {}", customizedConfigCacheSize); } } } public long getMaxConfigCacheSize() { return maxConfigCacheSize; } public long getConfigCacheExpireTime() { return configCacheExpireTime; } public TimeUnit getConfigCacheExpireTimeUnit() { return configCacheExpireTimeUnit; } private void initLongPollingInitialDelayInMills() { String customizedLongPollingInitialDelay = System .getProperty("apollo.longPollingInitialDelayInMills"); if (!Strings.isNullOrEmpty(customizedLongPollingInitialDelay)) { try { longPollingInitialDelayInMills = Long.parseLong(customizedLongPollingInitialDelay); } catch (Throwable ex) { logger.error("Config for apollo.longPollingInitialDelayInMills is invalid: {}", customizedLongPollingInitialDelay); } } } public long getLongPollingInitialDelayInMills() { return longPollingInitialDelayInMills; } private void initAutoUpdateInjectedSpringProperties() { // 1. Get from System Property String enableAutoUpdate = System.getProperty("apollo.autoUpdateInjectedSpringProperties"); if (Strings.isNullOrEmpty(enableAutoUpdate)) { // 2. Get from app.properties enableAutoUpdate = Foundation.app() .getProperty("apollo.autoUpdateInjectedSpringProperties", null); } if (!Strings.isNullOrEmpty(enableAutoUpdate)) { autoUpdateInjectedSpringProperties = Boolean.parseBoolean(enableAutoUpdate.trim()); } } public boolean isAutoUpdateInjectedSpringPropertiesEnabled() { return autoUpdateInjectedSpringProperties; } private void initPropertiesOrdered() { String enablePropertiesOrdered = System.getProperty(APOLLO_PROPERTY_ORDER_ENABLE); if (Strings.isNullOrEmpty(enablePropertiesOrdered)) { enablePropertiesOrdered = Foundation.app().getProperty(APOLLO_PROPERTY_ORDER_ENABLE, "false"); } if (!Strings.isNullOrEmpty(enablePropertiesOrdered)) { try { propertiesOrdered = Boolean.parseBoolean(enablePropertiesOrdered); } catch (Throwable ex) { logger.warn("Config for {} is invalid: {}, set default value: false", APOLLO_PROPERTY_ORDER_ENABLE, enablePropertiesOrdered); } } } public boolean isPropertiesOrderEnabled() { return propertiesOrdered; } public boolean isPropertyNamesCacheEnabled() { return propertyNamesCacheEnabled; } private void initPropertyNamesCacheEnabled() { String propertyName = ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE; String propertyEnvName = ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE_ENVIRONMENT_VARIABLES; String enablePropertyNamesCache = System.getProperty(propertyName); if (Strings.isNullOrEmpty(enablePropertyNamesCache)) { enablePropertyNamesCache = System.getenv(propertyEnvName); } if (Strings.isNullOrEmpty(enablePropertyNamesCache)) { enablePropertyNamesCache = Foundation.app().getProperty(propertyName, "false"); } if (!Strings.isNullOrEmpty(enablePropertyNamesCache)) { try { propertyNamesCacheEnabled = Boolean.parseBoolean(enablePropertyNamesCache); } catch (Throwable ex) { logger.warn("Config for {} is invalid: {}, set default value: false", propertyName, enablePropertyNamesCache); } } } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.ConfigFileChangeListener; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.model.ConfigChange; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.annotation.ApolloConfig; import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.util.concurrent.SettableFuture; import java.io.IOException; import java.util.Collections; import java.util.Properties; import java.util.UUID; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anySetOf; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ public class JavaConfigAnnotationTest extends AbstractSpringIntegrationTest { private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; private static final String APPLICATION_YAML_NAMESPACE = "application.yaml"; private static <T> T getBean(Class<T> beanClass, Class<?>... annotatedClasses) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(annotatedClasses); return context.getBean(beanClass); } private static <T> T getSimpleBean(Class<? extends T> clazz) { return getBean(clazz, clazz); } @Override @After public void tearDown() throws Exception { // clear the system properties System.clearProperty(SystemPropertyKeyConstants.SIMPLE_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.REDIS_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_SYSTEM_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_SYSTEM_YAML_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY); System.clearProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY_YAML); super.tearDown(); } @Test public void testApolloConfig() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); String someKey = "someKey"; String someValue = "someValue"; mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloConfigBean1 bean = getBean(TestApolloConfigBean1.class, AppConfig1.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); Config yamlConfig = bean.getYamlConfig(); assertEquals(someValue, yamlConfig.getProperty(someKey, null)); } @Test(expected = BeanCreationException.class) public void testApolloConfigWithWrongFieldType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigBean2.class, AppConfig2.class); } @Test public void testApolloConfigWithInheritance() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloChildConfigBean bean = getBean(TestApolloChildConfigBean.class, AppConfig6.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); assertEquals(applicationConfig, bean.getSomeConfig()); } @Test public void testEnableApolloConfigResolveExpressionSimple() { String someKey = "someKey-2020-11-14-1750"; String someValue = UUID.randomUUID().toString(); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); Config xxxConfig = mock(Config.class); when(xxxConfig.getProperty(eq(someKey), anyString())).thenReturn(someValue); mockConfig("xxx", xxxConfig); TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration configuration = getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); // check assertEquals(someValue, configuration.getSomeKey()); verify(xxxConfig, times(1)).getProperty(eq(someKey), anyString()); } @Test public void testEnableApolloConfigResolveExpressionFromSystemProperty() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String someKey = "someKey-2020-11-14-1750"; final String someValue = UUID.randomUUID().toString(); final String resolvedNamespaceName = "yyy"; System.setProperty(SystemPropertyKeyConstants.SIMPLE_NAMESPACE, resolvedNamespaceName); Config yyyConfig = mock(Config.class); when(yyyConfig.getProperty(eq(someKey), anyString())).thenReturn(someValue); mockConfig(resolvedNamespaceName, yyyConfig); TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration configuration = getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); // check assertEquals(someValue, configuration.getSomeKey()); verify(yyyConfig, times(1)).getProperty(eq(someKey), anyString()); } @Test(expected = BeanCreationException.class) public void testEnableApolloConfigUnresolvedValueInField() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); mockConfig("xxx", mock(Config.class)); getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); } @Test(expected = IllegalArgumentException.class) public void testEnableApolloConfigUnresolvable() { getSimpleBean(TestEnableApolloConfigUnresolvableConfiguration.class); } @Test public void testApolloConfigChangeListener() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloConfigChangeListenerBean1 bean = getBean(TestApolloConfigChangeListenerBean1.class, AppConfig3.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(4, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigChangeListenerBean2.class, AppConfig4.class); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamCount() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigChangeListenerBean3.class, AppConfig5.class); } @Test public void testApolloConfigChangeListenerWithInheritance() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloChildConfigChangeListener bean = getBean(TestApolloChildConfigChangeListener.class, AppConfig7.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(5, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); assertEquals(someEvent, bean.getSomeChangeEvent()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); assertEquals(someEvent, bean.getSomeChangeEvent()); } @Test public void testApolloConfigChangeListenerWithInterestedKeys() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigChangeListenerWithInterestedKeysBean bean = getBean( TestApolloConfigChangeListenerWithInterestedKeysBean.class, AppConfig8.class); final ArgumentCaptor<Set> applicationConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); final ArgumentCaptor<Set> fxApolloConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); verify(applicationConfig, times(2)) .addChangeListener(any(ConfigChangeListener.class), applicationConfigInterestedKeys.capture(), anySetOf(String.class)); verify(fxApolloConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), fxApolloConfigInterestedKeys.capture(), anySetOf(String.class)); assertEquals(2, applicationConfigInterestedKeys.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set interestedKeys : applicationConfigInterestedKeys.getAllValues()) { result.addAll(interestedKeys); } assertEquals(Sets.newHashSet("someKey", "anotherKey"), result); assertEquals(1, fxApolloConfigInterestedKeys.getAllValues().size()); assertEquals(Collections.singletonList(Sets.newHashSet("anotherKey")), fxApolloConfigInterestedKeys.getAllValues()); } @Test public void testApolloConfigChangeListenerWithInterestedKeyPrefixes() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean bean = getBean( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean.class, AppConfig10.class); final ArgumentCaptor<Set> interestedKeyPrefixesArgumentCaptor = ArgumentCaptor .forClass(Set.class); verify(applicationConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), anySetOf(String.class), interestedKeyPrefixesArgumentCaptor.capture()); assertEquals(1, interestedKeyPrefixesArgumentCaptor.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set<String> interestedKeyPrefixes : interestedKeyPrefixesArgumentCaptor.getAllValues()) { result.addAll(interestedKeyPrefixes); } assertEquals(Sets.newHashSet("logging.level", "number"), result); } @Test public void testApolloConfigChangeListenerWithInterestedKeyPrefixes_fire() throws InterruptedException { // default mock, useless here // just for speed up test without waiting mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); SimpleConfig simpleConfig = spy( this.prepareConfig( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, new Properties())); mockConfig(TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, simpleConfig); TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 bean = getBean( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.class, AppConfig11.class); verify(simpleConfig, atLeastOnce()) .addChangeListener(any(ConfigChangeListener.class), anySetOf(String.class), anySetOf(String.class)); Properties properties = new Properties(); properties.put("logging.level.com", "debug"); properties.put("logging.level.root", "warn"); properties.put("number.value", "333"); // publish config change simpleConfig.onRepositoryChange( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, properties); // get event from bean ConfigChangeEvent configChangeEvent = bean.getConfigChangeEvent(); Set<String> interestedChangedKeys = configChangeEvent.interestedChangedKeys(); assertEquals(Sets.newHashSet("logging.level.com", "logging.level.root", "number.value"), interestedChangedKeys); } @Test public void testApolloConfigChangeListenerWithYamlFile() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String anotherValue = "anotherValue"; YamlConfigFile configFile = prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloConfigChangeListenerWithYamlFile bean = getBean(TestApolloConfigChangeListenerWithYamlFile.class, AppConfig9.class); Config yamlConfig = bean.getYamlConfig(); SettableFuture<ConfigChangeEvent> future = bean.getConfigChangeEventFuture(); assertEquals(someValue, yamlConfig.getProperty(someKey, null)); assertFalse(future.isDone()); configFile.onRepositoryChange(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9-new.yml")); ConfigChangeEvent configChangeEvent = future.get(100, TimeUnit.MILLISECONDS); ConfigChange change = configChangeEvent.getChange(someKey); assertEquals(someValue, change.getOldValue()); assertEquals(anotherValue, change.getNewValue()); assertEquals(anotherValue, yamlConfig.getProperty(someKey, null)); } @Test public void testApolloConfigChangeListenerResolveExpressionSimple() { // for ignore, no listener use it Config ignoreConfig = mock(Config.class); mockConfig("ignore.for.listener", ignoreConfig); Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getSimpleBean(TestApolloConfigChangeListenerResolveExpressionSimpleConfiguration.class); // no using verify(ignoreConfig, never()).addChangeListener(any(ConfigChangeListener.class)); // one invocation for spring value auto update and another for the @ApolloConfigChangeListener annotation verify(applicationConfig, times(2)).addChangeListener(any(ConfigChangeListener.class)); } /** * resolve namespace's name from system property. */ @Test public void testApolloConfigChangeListenerResolveExpressionFromSystemProperty() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); final String namespaceName = "magicRedis"; System.setProperty(SystemPropertyKeyConstants.REDIS_NAMESPACE, namespaceName); Config redisConfig = mock(Config.class); mockConfig(namespaceName, redisConfig); getSimpleBean( TestApolloConfigChangeListenerResolveExpressionFromSystemPropertyConfiguration.class); // if config was used, it must be invoked on method addChangeListener 1 time verify(redisConfig, times(1)).addChangeListener(any(ConfigChangeListener.class)); } /** * resolve namespace from config. ${mysql.namespace} will be resolved by config from namespace * application. */ @Test public void testApolloConfigChangeListenerResolveExpressionFromApplicationNamespace() { final String namespaceKey = "mysql.namespace"; final String namespaceName = "magicMysqlNamespaceApplication"; Properties properties = new Properties(); properties.setProperty(namespaceKey, namespaceName); this.prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); Config mysqlConfig = mock(Config.class); mockConfig(namespaceName, mysqlConfig); getSimpleBean( TestApolloConfigChangeListenerResolveExpressionFromApplicationNamespaceConfiguration.class); // if config was used, it must be invoked on method addChangeListener 1 time verify(mysqlConfig, times(1)).addChangeListener(any(ConfigChangeListener.class)); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerUnresolvedPlaceholder() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getSimpleBean(TestApolloConfigChangeListenerUnresolvedPlaceholderConfiguration.class); } @Test public void testApolloConfigChangeListenerResolveExpressionFromSelfYaml() throws IOException { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String resolvedValue = "resolve.from.self.yml"; YamlConfigFile yamlConfigFile = prepareYamlConfigFile(resolvedValue, readYamlContentAsConfigFileProperties(resolvedValue)); getSimpleBean(TestApolloConfigChangeListenerResolveExpressionFromSelfYamlConfiguration.class); verify(yamlConfigFile, times(1)).addChangeListener(any(ConfigFileChangeListener.class)); } @Test public void testApolloConfigResolveExpressionDefault() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); Config defaultConfig = mock(Config.class); Config yamlConfig = mock(Config.class); mockConfig("default-2020-11-14-1733", defaultConfig); mockConfig(APPLICATION_YAML_NAMESPACE, yamlConfig); TestApolloConfigResolveExpressionDefaultConfiguration configuration = getSimpleBean( TestApolloConfigResolveExpressionDefaultConfiguration.class); assertSame(defaultConfig, configuration.getDefaultConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } @Test public void testApolloConfigResolveExpressionFromSystemProperty() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String namespaceName = "xxx6"; final String yamlNamespaceName = "yyy8.yml"; System.setProperty(SystemPropertyKeyConstants.FROM_SYSTEM_NAMESPACE, namespaceName); System.setProperty(SystemPropertyKeyConstants.FROM_SYSTEM_YAML_NAMESPACE, yamlNamespaceName); Config config = mock(Config.class); Config yamlConfig = mock(Config.class); mockConfig(namespaceName, config); mockConfig(yamlNamespaceName, yamlConfig); TestApolloConfigResolveExpressionFromSystemPropertyConfiguration configuration = getSimpleBean( TestApolloConfigResolveExpressionFromSystemPropertyConfiguration.class); assertSame(config, configuration.getConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } @Test(expected = BeanCreationException.class) public void testApolloConfigUnresolvedExpression() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); getSimpleBean(TestApolloConfigUnresolvedExpressionConfiguration.class); } @Test public void testApolloConfigResolveExpressionFromApolloConfigNamespaceApplication() { final String namespaceName = "xxx6"; final String yamlNamespaceName = "yyy8.yml"; { // hide variable scope Properties properties = new Properties(); properties.setProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY, namespaceName); properties.setProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY_YAML, yamlNamespaceName); this.prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); } final Config config = mock(Config.class); final Config yamlConfig = mock(Config.class); mockConfig(namespaceName, config); mockConfig(yamlNamespaceName, yamlConfig); TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication configuration = getSimpleBean( TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication.class); assertSame(config, configuration.getConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } private static class SystemPropertyKeyConstants { static final String SIMPLE_NAMESPACE = "simple.namespace"; static final String REDIS_NAMESPACE = "redis.namespace"; static final String FROM_SYSTEM_NAMESPACE = "from.system.namespace"; static final String FROM_SYSTEM_YAML_NAMESPACE = "from.system.yaml.namespace"; static final String FROM_NAMESPACE_APPLICATION_KEY = "from.namespace.application.key"; static final String FROM_NAMESPACE_APPLICATION_KEY_YAML = "from.namespace.application.key.yaml"; } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionDefaultConfiguration { @ApolloConfig(value = "${simple.namespace:default-2020-11-14-1733}") private Config defaultConfig; @ApolloConfig(value = "${simple.yaml.namespace:" + APPLICATION_YAML_NAMESPACE + "}") private Config yamlConfig; public Config getDefaultConfig() { return defaultConfig; } public Config getYamlConfig() { return yamlConfig; } } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionFromSystemPropertyConfiguration { @ApolloConfig(value = "${from.system.namespace}") private Config config; @ApolloConfig(value = "${from.system.yaml.namespace}") private Config yamlConfig; public Config getConfig() { return config; } public Config getYamlConfig() { return yamlConfig; } } @EnableApolloConfig protected static class TestApolloConfigUnresolvedExpressionConfiguration { @ApolloConfig(value = "${so.complex.to.resolve}") private Config config; } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication { @ApolloConfig(value = "${from.namespace.application.key}") private Config config; @ApolloConfig(value = "${from.namespace.application.key.yaml}") private Config yamlConfig; public Config getConfig() { return config; } public Config getYamlConfig() { return yamlConfig; } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionSimpleConfiguration { @ApolloConfigChangeListener("${simple.application:application}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionFromSystemPropertyConfiguration { @ApolloConfigChangeListener("${redis.namespace}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionFromApplicationNamespaceConfiguration { @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, "${mysql.namespace}"}) private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerUnresolvedPlaceholderConfiguration { @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, "${i.can.not.be.resolved}"}) private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig("resolve.from.self.yml") static class TestApolloConfigChangeListenerResolveExpressionFromSelfYamlConfiguration { /** * value in file src/test/resources/spring/yaml/resolve.from.self.yml */ @ApolloConfigChangeListener("${i.can.resolve.from.self}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig(value = {ConfigConsts.NAMESPACE_APPLICATION, "${simple.namespace:xxx}"}) static class TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration { @Value("${someKey-2020-11-14-1750}") private String someKey; public String getSomeKey() { return this.someKey; } } @Configuration @EnableApolloConfig(value = "${unresolvable.property}") static class TestEnableApolloConfigUnresolvableConfiguration { } @Configuration @EnableApolloConfig static class AppConfig1 { @Bean public TestApolloConfigBean1 bean() { return new TestApolloConfigBean1(); } } @Configuration @EnableApolloConfig static class AppConfig2 { @Bean public TestApolloConfigBean2 bean() { return new TestApolloConfigBean2(); } } @Configuration @EnableApolloConfig static class AppConfig3 { @Bean public TestApolloConfigChangeListenerBean1 bean() { return new TestApolloConfigChangeListenerBean1(); } } @Configuration @EnableApolloConfig static class AppConfig4 { @Bean public TestApolloConfigChangeListenerBean2 bean() { return new TestApolloConfigChangeListenerBean2(); } } @Configuration @EnableApolloConfig static class AppConfig5 { @Bean public TestApolloConfigChangeListenerBean3 bean() { return new TestApolloConfigChangeListenerBean3(); } } @Configuration @EnableApolloConfig static class AppConfig6 { @Bean public TestApolloChildConfigBean bean() { return new TestApolloChildConfigBean(); } } @Configuration @EnableApolloConfig static class AppConfig7 { @Bean public TestApolloChildConfigChangeListener bean() { return new TestApolloChildConfigChangeListener(); } } @Configuration @EnableApolloConfig static class AppConfig8 { @Bean public TestApolloConfigChangeListenerWithInterestedKeysBean bean() { return new TestApolloConfigChangeListenerWithInterestedKeysBean(); } } @Configuration @EnableApolloConfig(APPLICATION_YAML_NAMESPACE) static class AppConfig9 { @Bean public TestApolloConfigChangeListenerWithYamlFile bean() { return new TestApolloConfigChangeListenerWithYamlFile(); } } @Configuration @EnableApolloConfig static class AppConfig10 { @Bean public TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean bean() { return new TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean(); } } @Configuration @EnableApolloConfig static class AppConfig11 { @Bean public TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 bean() { return spy(new TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1()); } } static class TestApolloConfigBean1 { @ApolloConfig private Config config; @ApolloConfig(ConfigConsts.NAMESPACE_APPLICATION) private Config anotherConfig; @ApolloConfig(FX_APOLLO_NAMESPACE) private Config yetAnotherConfig; @ApolloConfig(APPLICATION_YAML_NAMESPACE) private Config yamlConfig; public Config getConfig() { return config; } public Config getAnotherConfig() { return anotherConfig; } public Config getYetAnotherConfig() { return yetAnotherConfig; } public Config getYamlConfig() { return yamlConfig; } } static class TestApolloConfigBean2 { @ApolloConfig private String config; } static class TestApolloChildConfigBean extends TestApolloConfigBean1 { @ApolloConfig private Config someConfig; public Config getSomeConfig() { return someConfig; } } static class TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent changeEvent1; private ConfigChangeEvent changeEvent2; private ConfigChangeEvent changeEvent3; @ApolloConfigChangeListener private void onChange1(ConfigChangeEvent changeEvent) { this.changeEvent1 = changeEvent; } @ApolloConfigChangeListener(ConfigConsts.NAMESPACE_APPLICATION) private void onChange2(ConfigChangeEvent changeEvent) { this.changeEvent2 = changeEvent; } @ApolloConfigChangeListener({ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}) private void onChange3(ConfigChangeEvent changeEvent) { this.changeEvent3 = changeEvent; } public ConfigChangeEvent getChangeEvent1() { return changeEvent1; } public ConfigChangeEvent getChangeEvent2() { return changeEvent2; } public ConfigChangeEvent getChangeEvent3() { return changeEvent3; } } static class TestApolloConfigChangeListenerBean2 { @ApolloConfigChangeListener private void onChange(String event) { } } static class TestApolloConfigChangeListenerBean3 { @ApolloConfigChangeListener private void onChange(ConfigChangeEvent event, String someParam) { } } static class TestApolloChildConfigChangeListener extends TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent someChangeEvent; @ApolloConfigChangeListener private void someOnChange(ConfigChangeEvent changeEvent) { this.someChangeEvent = changeEvent; } public ConfigChangeEvent getSomeChangeEvent() { return someChangeEvent; } } static class TestApolloConfigChangeListenerWithInterestedKeysBean { @ApolloConfigChangeListener(interestedKeys = {"someKey"}) private void someOnChange(ConfigChangeEvent changeEvent) {} @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}, interestedKeys = {"anotherKey"}) private void anotherOnChange(ConfigChangeEvent changeEvent) { } } private static class TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean { @ApolloConfigChangeListener(interestedKeyPrefixes = {"number", "logging.level"}) private void onChange(ConfigChangeEvent changeEvent) { } } private static class TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 { static final String SPECIAL_NAMESPACE = "special-namespace-2021"; private final BlockingQueue<ConfigChangeEvent> configChangeEventQueue = new ArrayBlockingQueue<>(100); @ApolloConfigChangeListener(value = SPECIAL_NAMESPACE, interestedKeyPrefixes = {"number", "logging.level"}) private void onChange(ConfigChangeEvent changeEvent) { this.configChangeEventQueue.add(changeEvent); } public ConfigChangeEvent getConfigChangeEvent() throws InterruptedException { return this.configChangeEventQueue.poll(5, TimeUnit.SECONDS); } } static class TestApolloConfigChangeListenerWithYamlFile { private SettableFuture<ConfigChangeEvent> configChangeEventFuture = SettableFuture.create(); @ApolloConfig(APPLICATION_YAML_NAMESPACE) private Config yamlConfig; @ApolloConfigChangeListener(APPLICATION_YAML_NAMESPACE) private void onChange(ConfigChangeEvent event) { configChangeEventFuture.set(event); } public SettableFuture<ConfigChangeEvent> getConfigChangeEventFuture() { return configChangeEventFuture; } public Config getYamlConfig() { return yamlConfig; } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.ConfigFileChangeListener; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.model.ConfigChange; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.annotation.ApolloConfig; import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.util.concurrent.SettableFuture; import java.io.IOException; import java.util.Collections; import java.util.Properties; import java.util.UUID; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anySetOf; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ public class JavaConfigAnnotationTest extends AbstractSpringIntegrationTest { private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; private static final String APPLICATION_YAML_NAMESPACE = "application.yaml"; private static <T> T getBean(Class<T> beanClass, Class<?>... annotatedClasses) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(annotatedClasses); return context.getBean(beanClass); } private static <T> T getSimpleBean(Class<? extends T> clazz) { return getBean(clazz, clazz); } @Override @After public void tearDown() throws Exception { // clear the system properties System.clearProperty(SystemPropertyKeyConstants.SIMPLE_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.REDIS_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_SYSTEM_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_SYSTEM_YAML_NAMESPACE); System.clearProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY); System.clearProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY_YAML); System.clearProperty(ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE); super.tearDown(); } @Test public void testApolloConfig() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); String someKey = "someKey"; String someValue = "someValue"; mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloConfigBean1 bean = getBean(TestApolloConfigBean1.class, AppConfig1.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); Config yamlConfig = bean.getYamlConfig(); assertEquals(someValue, yamlConfig.getProperty(someKey, null)); } @Test(expected = BeanCreationException.class) public void testApolloConfigWithWrongFieldType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigBean2.class, AppConfig2.class); } @Test public void testApolloConfigWithInheritance() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloChildConfigBean bean = getBean(TestApolloChildConfigBean.class, AppConfig6.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); assertEquals(applicationConfig, bean.getSomeConfig()); } @Test public void testEnableApolloConfigResolveExpressionSimple() { String someKey = "someKey-2020-11-14-1750"; String someValue = UUID.randomUUID().toString(); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); Config xxxConfig = mock(Config.class); when(xxxConfig.getProperty(eq(someKey), anyString())).thenReturn(someValue); mockConfig("xxx", xxxConfig); TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration configuration = getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); // check assertEquals(someValue, configuration.getSomeKey()); verify(xxxConfig, times(1)).getProperty(eq(someKey), anyString()); } @Test public void testEnableApolloConfigResolveExpressionFromSystemProperty() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String someKey = "someKey-2020-11-14-1750"; final String someValue = UUID.randomUUID().toString(); final String resolvedNamespaceName = "yyy"; System.setProperty(SystemPropertyKeyConstants.SIMPLE_NAMESPACE, resolvedNamespaceName); Config yyyConfig = mock(Config.class); when(yyyConfig.getProperty(eq(someKey), anyString())).thenReturn(someValue); mockConfig(resolvedNamespaceName, yyyConfig); TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration configuration = getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); // check assertEquals(someValue, configuration.getSomeKey()); verify(yyyConfig, times(1)).getProperty(eq(someKey), anyString()); } @Test(expected = BeanCreationException.class) public void testEnableApolloConfigUnresolvedValueInField() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); mockConfig("xxx", mock(Config.class)); getSimpleBean(TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration.class); } @Test(expected = IllegalArgumentException.class) public void testEnableApolloConfigUnresolvable() { getSimpleBean(TestEnableApolloConfigUnresolvableConfiguration.class); } @Test public void testApolloConfigChangeListener() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloConfigChangeListenerBean1 bean = getBean(TestApolloConfigChangeListenerBean1.class, AppConfig3.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(4, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigChangeListenerBean2.class, AppConfig4.class); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamCount() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean(TestApolloConfigChangeListenerBean3.class, AppConfig5.class); } @Test public void testApolloConfigChangeListenerWithInheritance() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloChildConfigChangeListener bean = getBean(TestApolloChildConfigChangeListener.class, AppConfig7.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(5, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); assertEquals(someEvent, bean.getSomeChangeEvent()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); assertEquals(someEvent, bean.getSomeChangeEvent()); } @Test public void testApolloConfigChangeListenerWithInterestedKeys() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigChangeListenerWithInterestedKeysBean bean = getBean( TestApolloConfigChangeListenerWithInterestedKeysBean.class, AppConfig8.class); final ArgumentCaptor<Set> applicationConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); final ArgumentCaptor<Set> fxApolloConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); verify(applicationConfig, times(2)) .addChangeListener(any(ConfigChangeListener.class), applicationConfigInterestedKeys.capture(), anySetOf(String.class)); verify(fxApolloConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), fxApolloConfigInterestedKeys.capture(), anySetOf(String.class)); assertEquals(2, applicationConfigInterestedKeys.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set interestedKeys : applicationConfigInterestedKeys.getAllValues()) { result.addAll(interestedKeys); } assertEquals(Sets.newHashSet("someKey", "anotherKey"), result); assertEquals(1, fxApolloConfigInterestedKeys.getAllValues().size()); assertEquals(Collections.singletonList(Sets.newHashSet("anotherKey")), fxApolloConfigInterestedKeys.getAllValues()); } @Test public void testApolloConfigChangeListenerWithInterestedKeyPrefixes() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean bean = getBean( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean.class, AppConfig10.class); final ArgumentCaptor<Set> interestedKeyPrefixesArgumentCaptor = ArgumentCaptor .forClass(Set.class); verify(applicationConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), anySetOf(String.class), interestedKeyPrefixesArgumentCaptor.capture()); assertEquals(1, interestedKeyPrefixesArgumentCaptor.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set<String> interestedKeyPrefixes : interestedKeyPrefixesArgumentCaptor.getAllValues()) { result.addAll(interestedKeyPrefixes); } assertEquals(Sets.newHashSet("logging.level", "number"), result); } @Test public void testApolloConfigChangeListenerWithInterestedKeyPrefixes_fire() throws InterruptedException { // default mock, useless here // just for speed up test without waiting mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); SimpleConfig simpleConfig = spy( this.prepareConfig( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, new Properties())); mockConfig(TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, simpleConfig); TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 bean = getBean( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.class, AppConfig11.class); verify(simpleConfig, atLeastOnce()) .addChangeListener(any(ConfigChangeListener.class), anySetOf(String.class), anySetOf(String.class)); Properties properties = new Properties(); properties.put("logging.level.com", "debug"); properties.put("logging.level.root", "warn"); properties.put("number.value", "333"); // publish config change simpleConfig.onRepositoryChange( TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, properties); // get event from bean ConfigChangeEvent configChangeEvent = bean.getConfigChangeEvent(); Set<String> interestedChangedKeys = configChangeEvent.interestedChangedKeys(); assertEquals(Sets.newHashSet("logging.level.com", "logging.level.root", "number.value"), interestedChangedKeys); } @Test public void testApolloConfigChangeListenerWithYamlFile() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String anotherValue = "anotherValue"; YamlConfigFile configFile = prepareYamlConfigFile(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9.yml")); TestApolloConfigChangeListenerWithYamlFile bean = getBean(TestApolloConfigChangeListenerWithYamlFile.class, AppConfig9.class); Config yamlConfig = bean.getYamlConfig(); SettableFuture<ConfigChangeEvent> future = bean.getConfigChangeEventFuture(); assertEquals(someValue, yamlConfig.getProperty(someKey, null)); assertFalse(future.isDone()); configFile.onRepositoryChange(APPLICATION_YAML_NAMESPACE, readYamlContentAsConfigFileProperties("case9-new.yml")); ConfigChangeEvent configChangeEvent = future.get(100, TimeUnit.MILLISECONDS); ConfigChange change = configChangeEvent.getChange(someKey); assertEquals(someValue, change.getOldValue()); assertEquals(anotherValue, change.getNewValue()); assertEquals(anotherValue, yamlConfig.getProperty(someKey, null)); } @Test public void testApolloConfigChangeListenerResolveExpressionSimple() { // for ignore, no listener use it Config ignoreConfig = mock(Config.class); mockConfig("ignore.for.listener", ignoreConfig); Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); System.setProperty(ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE, "true"); getSimpleBean(TestApolloConfigChangeListenerResolveExpressionSimpleConfiguration.class); // no using verify(ignoreConfig, never()).addChangeListener(any(ConfigChangeListener.class)); // one invocation for spring value auto update // one invocation for the @ApolloConfigChangeListener annotation // one invocation for CachedCompositePropertySource clear cache listener verify(applicationConfig, times(3)).addChangeListener(any(ConfigChangeListener.class)); } /** * resolve namespace's name from system property. */ @Test public void testApolloConfigChangeListenerResolveExpressionFromSystemProperty() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); final String namespaceName = "magicRedis"; System.setProperty(SystemPropertyKeyConstants.REDIS_NAMESPACE, namespaceName); Config redisConfig = mock(Config.class); mockConfig(namespaceName, redisConfig); getSimpleBean( TestApolloConfigChangeListenerResolveExpressionFromSystemPropertyConfiguration.class); // if config was used, it must be invoked on method addChangeListener 1 time verify(redisConfig, times(1)).addChangeListener(any(ConfigChangeListener.class)); } /** * resolve namespace from config. ${mysql.namespace} will be resolved by config from namespace * application. */ @Test public void testApolloConfigChangeListenerResolveExpressionFromApplicationNamespace() { final String namespaceKey = "mysql.namespace"; final String namespaceName = "magicMysqlNamespaceApplication"; Properties properties = new Properties(); properties.setProperty(namespaceKey, namespaceName); this.prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); Config mysqlConfig = mock(Config.class); mockConfig(namespaceName, mysqlConfig); getSimpleBean( TestApolloConfigChangeListenerResolveExpressionFromApplicationNamespaceConfiguration.class); // if config was used, it must be invoked on method addChangeListener 1 time verify(mysqlConfig, times(1)).addChangeListener(any(ConfigChangeListener.class)); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerUnresolvedPlaceholder() { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getSimpleBean(TestApolloConfigChangeListenerUnresolvedPlaceholderConfiguration.class); } @Test public void testApolloConfigChangeListenerResolveExpressionFromSelfYaml() throws IOException { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String resolvedValue = "resolve.from.self.yml"; YamlConfigFile yamlConfigFile = prepareYamlConfigFile(resolvedValue, readYamlContentAsConfigFileProperties(resolvedValue)); getSimpleBean(TestApolloConfigChangeListenerResolveExpressionFromSelfYamlConfiguration.class); verify(yamlConfigFile, times(1)).addChangeListener(any(ConfigFileChangeListener.class)); } @Test public void testApolloConfigResolveExpressionDefault() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); Config defaultConfig = mock(Config.class); Config yamlConfig = mock(Config.class); mockConfig("default-2020-11-14-1733", defaultConfig); mockConfig(APPLICATION_YAML_NAMESPACE, yamlConfig); TestApolloConfigResolveExpressionDefaultConfiguration configuration = getSimpleBean( TestApolloConfigResolveExpressionDefaultConfiguration.class); assertSame(defaultConfig, configuration.getDefaultConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } @Test public void testApolloConfigResolveExpressionFromSystemProperty() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); final String namespaceName = "xxx6"; final String yamlNamespaceName = "yyy8.yml"; System.setProperty(SystemPropertyKeyConstants.FROM_SYSTEM_NAMESPACE, namespaceName); System.setProperty(SystemPropertyKeyConstants.FROM_SYSTEM_YAML_NAMESPACE, yamlNamespaceName); Config config = mock(Config.class); Config yamlConfig = mock(Config.class); mockConfig(namespaceName, config); mockConfig(yamlNamespaceName, yamlConfig); TestApolloConfigResolveExpressionFromSystemPropertyConfiguration configuration = getSimpleBean( TestApolloConfigResolveExpressionFromSystemPropertyConfiguration.class); assertSame(config, configuration.getConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } @Test(expected = BeanCreationException.class) public void testApolloConfigUnresolvedExpression() { mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class)); getSimpleBean(TestApolloConfigUnresolvedExpressionConfiguration.class); } @Test public void testApolloConfigResolveExpressionFromApolloConfigNamespaceApplication() { final String namespaceName = "xxx6"; final String yamlNamespaceName = "yyy8.yml"; { // hide variable scope Properties properties = new Properties(); properties.setProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY, namespaceName); properties.setProperty(SystemPropertyKeyConstants.FROM_NAMESPACE_APPLICATION_KEY_YAML, yamlNamespaceName); this.prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); } final Config config = mock(Config.class); final Config yamlConfig = mock(Config.class); mockConfig(namespaceName, config); mockConfig(yamlNamespaceName, yamlConfig); TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication configuration = getSimpleBean( TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication.class); assertSame(config, configuration.getConfig()); assertSame(yamlConfig, configuration.getYamlConfig()); } private static class SystemPropertyKeyConstants { static final String SIMPLE_NAMESPACE = "simple.namespace"; static final String REDIS_NAMESPACE = "redis.namespace"; static final String FROM_SYSTEM_NAMESPACE = "from.system.namespace"; static final String FROM_SYSTEM_YAML_NAMESPACE = "from.system.yaml.namespace"; static final String FROM_NAMESPACE_APPLICATION_KEY = "from.namespace.application.key"; static final String FROM_NAMESPACE_APPLICATION_KEY_YAML = "from.namespace.application.key.yaml"; } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionDefaultConfiguration { @ApolloConfig(value = "${simple.namespace:default-2020-11-14-1733}") private Config defaultConfig; @ApolloConfig(value = "${simple.yaml.namespace:" + APPLICATION_YAML_NAMESPACE + "}") private Config yamlConfig; public Config getDefaultConfig() { return defaultConfig; } public Config getYamlConfig() { return yamlConfig; } } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionFromSystemPropertyConfiguration { @ApolloConfig(value = "${from.system.namespace}") private Config config; @ApolloConfig(value = "${from.system.yaml.namespace}") private Config yamlConfig; public Config getConfig() { return config; } public Config getYamlConfig() { return yamlConfig; } } @EnableApolloConfig protected static class TestApolloConfigUnresolvedExpressionConfiguration { @ApolloConfig(value = "${so.complex.to.resolve}") private Config config; } @EnableApolloConfig protected static class TestApolloConfigResolveExpressionFromApolloConfigNamespaceApplication { @ApolloConfig(value = "${from.namespace.application.key}") private Config config; @ApolloConfig(value = "${from.namespace.application.key.yaml}") private Config yamlConfig; public Config getConfig() { return config; } public Config getYamlConfig() { return yamlConfig; } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionSimpleConfiguration { @ApolloConfigChangeListener("${simple.application:application}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionFromSystemPropertyConfiguration { @ApolloConfigChangeListener("${redis.namespace}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerResolveExpressionFromApplicationNamespaceConfiguration { @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, "${mysql.namespace}"}) private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig static class TestApolloConfigChangeListenerUnresolvedPlaceholderConfiguration { @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, "${i.can.not.be.resolved}"}) private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig("resolve.from.self.yml") static class TestApolloConfigChangeListenerResolveExpressionFromSelfYamlConfiguration { /** * value in file src/test/resources/spring/yaml/resolve.from.self.yml */ @ApolloConfigChangeListener("${i.can.resolve.from.self}") private void onChange(ConfigChangeEvent event) { } } @Configuration @EnableApolloConfig(value = {ConfigConsts.NAMESPACE_APPLICATION, "${simple.namespace:xxx}"}) static class TestEnableApolloConfigResolveExpressionWithDefaultValueConfiguration { @Value("${someKey-2020-11-14-1750}") private String someKey; public String getSomeKey() { return this.someKey; } } @Configuration @EnableApolloConfig(value = "${unresolvable.property}") static class TestEnableApolloConfigUnresolvableConfiguration { } @Configuration @EnableApolloConfig static class AppConfig1 { @Bean public TestApolloConfigBean1 bean() { return new TestApolloConfigBean1(); } } @Configuration @EnableApolloConfig static class AppConfig2 { @Bean public TestApolloConfigBean2 bean() { return new TestApolloConfigBean2(); } } @Configuration @EnableApolloConfig static class AppConfig3 { @Bean public TestApolloConfigChangeListenerBean1 bean() { return new TestApolloConfigChangeListenerBean1(); } } @Configuration @EnableApolloConfig static class AppConfig4 { @Bean public TestApolloConfigChangeListenerBean2 bean() { return new TestApolloConfigChangeListenerBean2(); } } @Configuration @EnableApolloConfig static class AppConfig5 { @Bean public TestApolloConfigChangeListenerBean3 bean() { return new TestApolloConfigChangeListenerBean3(); } } @Configuration @EnableApolloConfig static class AppConfig6 { @Bean public TestApolloChildConfigBean bean() { return new TestApolloChildConfigBean(); } } @Configuration @EnableApolloConfig static class AppConfig7 { @Bean public TestApolloChildConfigChangeListener bean() { return new TestApolloChildConfigChangeListener(); } } @Configuration @EnableApolloConfig static class AppConfig8 { @Bean public TestApolloConfigChangeListenerWithInterestedKeysBean bean() { return new TestApolloConfigChangeListenerWithInterestedKeysBean(); } } @Configuration @EnableApolloConfig(APPLICATION_YAML_NAMESPACE) static class AppConfig9 { @Bean public TestApolloConfigChangeListenerWithYamlFile bean() { return new TestApolloConfigChangeListenerWithYamlFile(); } } @Configuration @EnableApolloConfig static class AppConfig10 { @Bean public TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean bean() { return new TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean(); } } @Configuration @EnableApolloConfig static class AppConfig11 { @Bean public TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 bean() { return spy(new TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1()); } } static class TestApolloConfigBean1 { @ApolloConfig private Config config; @ApolloConfig(ConfigConsts.NAMESPACE_APPLICATION) private Config anotherConfig; @ApolloConfig(FX_APOLLO_NAMESPACE) private Config yetAnotherConfig; @ApolloConfig(APPLICATION_YAML_NAMESPACE) private Config yamlConfig; public Config getConfig() { return config; } public Config getAnotherConfig() { return anotherConfig; } public Config getYetAnotherConfig() { return yetAnotherConfig; } public Config getYamlConfig() { return yamlConfig; } } static class TestApolloConfigBean2 { @ApolloConfig private String config; } static class TestApolloChildConfigBean extends TestApolloConfigBean1 { @ApolloConfig private Config someConfig; public Config getSomeConfig() { return someConfig; } } static class TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent changeEvent1; private ConfigChangeEvent changeEvent2; private ConfigChangeEvent changeEvent3; @ApolloConfigChangeListener private void onChange1(ConfigChangeEvent changeEvent) { this.changeEvent1 = changeEvent; } @ApolloConfigChangeListener(ConfigConsts.NAMESPACE_APPLICATION) private void onChange2(ConfigChangeEvent changeEvent) { this.changeEvent2 = changeEvent; } @ApolloConfigChangeListener({ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}) private void onChange3(ConfigChangeEvent changeEvent) { this.changeEvent3 = changeEvent; } public ConfigChangeEvent getChangeEvent1() { return changeEvent1; } public ConfigChangeEvent getChangeEvent2() { return changeEvent2; } public ConfigChangeEvent getChangeEvent3() { return changeEvent3; } } static class TestApolloConfigChangeListenerBean2 { @ApolloConfigChangeListener private void onChange(String event) { } } static class TestApolloConfigChangeListenerBean3 { @ApolloConfigChangeListener private void onChange(ConfigChangeEvent event, String someParam) { } } static class TestApolloChildConfigChangeListener extends TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent someChangeEvent; @ApolloConfigChangeListener private void someOnChange(ConfigChangeEvent changeEvent) { this.someChangeEvent = changeEvent; } public ConfigChangeEvent getSomeChangeEvent() { return someChangeEvent; } } static class TestApolloConfigChangeListenerWithInterestedKeysBean { @ApolloConfigChangeListener(interestedKeys = {"someKey"}) private void someOnChange(ConfigChangeEvent changeEvent) {} @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}, interestedKeys = {"anotherKey"}) private void anotherOnChange(ConfigChangeEvent changeEvent) { } } private static class TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean { @ApolloConfigChangeListener(interestedKeyPrefixes = {"number", "logging.level"}) private void onChange(ConfigChangeEvent changeEvent) { } } private static class TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1 { static final String SPECIAL_NAMESPACE = "special-namespace-2021"; private final BlockingQueue<ConfigChangeEvent> configChangeEventQueue = new ArrayBlockingQueue<>(100); @ApolloConfigChangeListener(value = SPECIAL_NAMESPACE, interestedKeyPrefixes = {"number", "logging.level"}) private void onChange(ConfigChangeEvent changeEvent) { this.configChangeEventQueue.add(changeEvent); } public ConfigChangeEvent getConfigChangeEvent() throws InterruptedException { return this.configChangeEventQueue.poll(5, TimeUnit.SECONDS); } } static class TestApolloConfigChangeListenerWithYamlFile { private SettableFuture<ConfigChangeEvent> configChangeEventFuture = SettableFuture.create(); @ApolloConfig(APPLICATION_YAML_NAMESPACE) private Config yamlConfig; @ApolloConfigChangeListener(APPLICATION_YAML_NAMESPACE) private void onChange(ConfigChangeEvent event) { configChangeEventFuture.set(event); } public SettableFuture<ConfigChangeEvent> getConfigChangeEventFuture() { return configChangeEventFuture; } public Config getYamlConfig() { return yamlConfig; } } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/spring/boot/ApolloApplicationContextInitializerTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.boot; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.core.env.ConfigurableEnvironment; public class ApolloApplicationContextInitializerTest { private ApolloApplicationContextInitializer apolloApplicationContextInitializer; @Before public void setUp() throws Exception { apolloApplicationContextInitializer = new ApolloApplicationContextInitializer(); } @After public void tearDown() throws Exception { System.clearProperty(ApolloClientSystemConsts.APP_ID); System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY); System.clearProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); System.clearProperty(ConfigConsts.APOLLO_META_KEY); } @Test public void testFillFromEnvironment() throws Exception { String someAppId = "someAppId"; String someCluster = "someCluster"; String someCacheDir = "someCacheDir"; String someApolloMeta = "someApolloMeta"; ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); when(environment.getProperty(ApolloClientSystemConsts.APP_ID)).thenReturn(someAppId); when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(someCluster); when(environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)).thenReturn(someCacheDir); when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(someApolloMeta); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertEquals(someAppId, System.getProperty(ApolloClientSystemConsts.APP_ID)); assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertEquals(someCacheDir, System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY)); } @Test public void testFillFromEnvironmentWithSystemPropertyAlreadyFilled() throws Exception { String someAppId = "someAppId"; String someCluster = "someCluster"; String someCacheDir = "someCacheDir"; String someApolloMeta = "someApolloMeta"; System.setProperty(ApolloClientSystemConsts.APP_ID, someAppId); System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster); System.setProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, someCacheDir); System.setProperty(ConfigConsts.APOLLO_META_KEY, someApolloMeta); String anotherAppId = "anotherAppId"; String anotherCluster = "anotherCluster"; String anotherCacheDir = "anotherCacheDir"; String anotherApolloMeta = "anotherApolloMeta"; ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); when(environment.getProperty(ApolloClientSystemConsts.APP_ID)).thenReturn(anotherAppId); when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(anotherCluster); when(environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)).thenReturn(anotherCacheDir); when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(anotherApolloMeta); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertEquals(someAppId, System.getProperty(ApolloClientSystemConsts.APP_ID)); assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertEquals(someCacheDir, System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY)); } @Test public void testFillFromEnvironmentWithNoPropertyFromEnvironment() throws Exception { ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertNull(System.getProperty(ApolloClientSystemConsts.APP_ID)); assertNull(System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertNull(System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertNull(System.getProperty(ConfigConsts.APOLLO_META_KEY)); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.boot; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.spring.config.CachedCompositePropertySource; import com.ctrip.framework.apollo.spring.config.PropertySourcesConstants; import com.ctrip.framework.apollo.util.ConfigUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MutablePropertySources; public class ApolloApplicationContextInitializerTest { private ApolloApplicationContextInitializer apolloApplicationContextInitializer; @Before public void setUp() throws Exception { apolloApplicationContextInitializer = new ApolloApplicationContextInitializer(); } @After public void tearDown() throws Exception { System.clearProperty(ApolloClientSystemConsts.APP_ID); System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY); System.clearProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); System.clearProperty(ConfigConsts.APOLLO_META_KEY); MockInjector.reset(); } @Test public void testFillFromEnvironment() throws Exception { String someAppId = "someAppId"; String someCluster = "someCluster"; String someCacheDir = "someCacheDir"; String someApolloMeta = "someApolloMeta"; ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); when(environment.getProperty(ApolloClientSystemConsts.APP_ID)).thenReturn(someAppId); when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(someCluster); when(environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)).thenReturn(someCacheDir); when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(someApolloMeta); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertEquals(someAppId, System.getProperty(ApolloClientSystemConsts.APP_ID)); assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertEquals(someCacheDir, System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY)); } @Test public void testFillFromEnvironmentWithSystemPropertyAlreadyFilled() throws Exception { String someAppId = "someAppId"; String someCluster = "someCluster"; String someCacheDir = "someCacheDir"; String someApolloMeta = "someApolloMeta"; System.setProperty(ApolloClientSystemConsts.APP_ID, someAppId); System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster); System.setProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, someCacheDir); System.setProperty(ConfigConsts.APOLLO_META_KEY, someApolloMeta); String anotherAppId = "anotherAppId"; String anotherCluster = "anotherCluster"; String anotherCacheDir = "anotherCacheDir"; String anotherApolloMeta = "anotherApolloMeta"; ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); when(environment.getProperty(ApolloClientSystemConsts.APP_ID)).thenReturn(anotherAppId); when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(anotherCluster); when(environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)).thenReturn(anotherCacheDir); when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(anotherApolloMeta); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertEquals(someAppId, System.getProperty(ApolloClientSystemConsts.APP_ID)); assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertEquals(someCacheDir, System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY)); } @Test public void testFillFromEnvironmentWithNoPropertyFromEnvironment() throws Exception { ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); apolloApplicationContextInitializer.initializeSystemProperty(environment); assertNull(System.getProperty(ApolloClientSystemConsts.APP_ID)); assertNull(System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)); assertNull(System.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR)); assertNull(System.getProperty(ConfigConsts.APOLLO_META_KEY)); } @Test public void testPropertyNamesCacheEnabled() { ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class); MutablePropertySources propertySources = new MutablePropertySources(); when(environment.getPropertySources()).thenReturn(propertySources); when(environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES, ConfigConsts.NAMESPACE_APPLICATION)).thenReturn(""); apolloApplicationContextInitializer.initialize(environment); assertTrue(propertySources.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)); assertFalse(propertySources.iterator().next() instanceof CachedCompositePropertySource); ConfigUtil configUtil = new ConfigUtil(); configUtil = spy(configUtil); when(configUtil.isPropertyNamesCacheEnabled()).thenReturn(true); MockInjector.setInstance(ConfigUtil.class, configUtil); apolloApplicationContextInitializer = new ApolloApplicationContextInitializer(); propertySources.remove(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME); apolloApplicationContextInitializer.initialize(environment); assertTrue(propertySources.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)); assertTrue(propertySources.iterator().next() instanceof CachedCompositePropertySource); } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import java.io.File; import org.junit.After; import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigUtilTest { @After public void tearDown() throws Exception { System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY); System.clearProperty("apollo.connectTimeout"); System.clearProperty("apollo.readTimeout"); System.clearProperty("apollo.refreshInterval"); System.clearProperty("apollo.loadConfigQPS"); System.clearProperty("apollo.longPollQPS"); System.clearProperty("apollo.configCacheSize"); System.clearProperty("apollo.longPollingInitialDelayInMills"); System.clearProperty("apollo.autoUpdateInjectedSpringProperties"); System.clearProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); System.clearProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE); } @Test public void testApolloCluster() throws Exception { String someCluster = "someCluster"; System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someCluster, configUtil.getCluster()); } @Test public void testCustomizeConnectTimeout() throws Exception { int someConnectTimeout = 1; System.setProperty("apollo.connectTimeout", String.valueOf(someConnectTimeout)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someConnectTimeout, configUtil.getConnectTimeout()); } @Test public void testCustomizeInvalidConnectTimeout() throws Exception { String someInvalidConnectTimeout = "a"; System.setProperty("apollo.connectTimeout", someInvalidConnectTimeout); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getConnectTimeout() > 0); } @Test public void testCustomizeReadTimeout() throws Exception { int someReadTimeout = 1; System.setProperty("apollo.readTimeout", String.valueOf(someReadTimeout)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someReadTimeout, configUtil.getReadTimeout()); } @Test public void testCustomizeInvalidReadTimeout() throws Exception { String someInvalidReadTimeout = "a"; System.setProperty("apollo.readTimeout", someInvalidReadTimeout); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getReadTimeout() > 0); } @Test public void testCustomizeRefreshInterval() throws Exception { int someRefreshInterval = 1; System.setProperty("apollo.refreshInterval", String.valueOf(someRefreshInterval)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someRefreshInterval, configUtil.getRefreshInterval()); } @Test public void testCustomizeInvalidRefreshInterval() throws Exception { String someInvalidRefreshInterval = "a"; System.setProperty("apollo.refreshInterval", someInvalidRefreshInterval); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getRefreshInterval() > 0); } @Test public void testCustomizeLoadConfigQPS() throws Exception { int someQPS = 1; System.setProperty("apollo.loadConfigQPS", String.valueOf(someQPS)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someQPS, configUtil.getLoadConfigQPS()); } @Test public void testCustomizeInvalidLoadConfigQPS() throws Exception { String someInvalidQPS = "a"; System.setProperty("apollo.loadConfigQPS", someInvalidQPS); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLoadConfigQPS() > 0); } @Test public void testCustomizeLongPollQPS() throws Exception { int someQPS = 1; System.setProperty("apollo.longPollQPS", String.valueOf(someQPS)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someQPS, configUtil.getLongPollQPS()); } @Test public void testCustomizeInvalidLongPollQPS() throws Exception { String someInvalidQPS = "a"; System.setProperty("apollo.longPollQPS", someInvalidQPS); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLongPollQPS() > 0); } @Test public void testCustomizeMaxConfigCacheSize() throws Exception { long someCacheSize = 1; System.setProperty("apollo.configCacheSize", String.valueOf(someCacheSize)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someCacheSize, configUtil.getMaxConfigCacheSize()); } @Test public void testCustomizeInvalidMaxConfigCacheSize() throws Exception { String someInvalidCacheSize = "a"; System.setProperty("apollo.configCacheSize", someInvalidCacheSize); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getMaxConfigCacheSize() > 0); } @Test public void testCustomizeLongPollingInitialDelayInMills() throws Exception { long someLongPollingDelayInMills = 1; System.setProperty("apollo.longPollingInitialDelayInMills", String.valueOf(someLongPollingDelayInMills)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someLongPollingDelayInMills, configUtil.getLongPollingInitialDelayInMills()); } @Test public void testCustomizeInvalidLongPollingInitialDelayInMills() throws Exception { String someInvalidLongPollingDelayInMills = "a"; System.setProperty("apollo.longPollingInitialDelayInMills", someInvalidLongPollingDelayInMills); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLongPollingInitialDelayInMills() > 0); } @Test public void testCustomizeAutoUpdateInjectedSpringProperties() throws Exception { boolean someAutoUpdateInjectedSpringProperties = false; System.setProperty("apollo.autoUpdateInjectedSpringProperties", String.valueOf(someAutoUpdateInjectedSpringProperties)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someAutoUpdateInjectedSpringProperties, configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()); } @Test public void testLocalCacheDirWithSystemProperty() throws Exception { String someCacheDir = "someCacheDir"; String someAppId = "someAppId"; System.setProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, someCacheDir); ConfigUtil configUtil = spy(new ConfigUtil()); doReturn(someAppId).when(configUtil).getAppId(); assertEquals(someCacheDir + File.separator + someAppId, configUtil.getDefaultLocalCacheDir()); } @Test public void testDefaultLocalCacheDir() throws Exception { String someAppId = "someAppId"; ConfigUtil configUtil = spy(new ConfigUtil()); doReturn(someAppId).when(configUtil).getAppId(); doReturn(true).when(configUtil).isOSWindows(); assertEquals("C:\\opt\\data\\" + someAppId, configUtil.getDefaultLocalCacheDir()); doReturn(false).when(configUtil).isOSWindows(); assertEquals("/opt/data/" + someAppId, configUtil.getDefaultLocalCacheDir()); } @Test public void testCustomizePropertiesOrdered() { boolean propertiesOrdered = true; System.setProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE, String.valueOf(propertiesOrdered)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(propertiesOrdered, configUtil.isPropertiesOrderEnabled()); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import java.io.File; import org.junit.After; import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigUtilTest { @After public void tearDown() throws Exception { System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY); System.clearProperty("apollo.connectTimeout"); System.clearProperty("apollo.readTimeout"); System.clearProperty("apollo.refreshInterval"); System.clearProperty("apollo.loadConfigQPS"); System.clearProperty("apollo.longPollQPS"); System.clearProperty("apollo.configCacheSize"); System.clearProperty("apollo.longPollingInitialDelayInMills"); System.clearProperty("apollo.autoUpdateInjectedSpringProperties"); System.clearProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR); System.clearProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE); System.clearProperty(ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE); } @Test public void testApolloCluster() throws Exception { String someCluster = "someCluster"; System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someCluster, configUtil.getCluster()); } @Test public void testCustomizeConnectTimeout() throws Exception { int someConnectTimeout = 1; System.setProperty("apollo.connectTimeout", String.valueOf(someConnectTimeout)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someConnectTimeout, configUtil.getConnectTimeout()); } @Test public void testCustomizeInvalidConnectTimeout() throws Exception { String someInvalidConnectTimeout = "a"; System.setProperty("apollo.connectTimeout", someInvalidConnectTimeout); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getConnectTimeout() > 0); } @Test public void testCustomizeReadTimeout() throws Exception { int someReadTimeout = 1; System.setProperty("apollo.readTimeout", String.valueOf(someReadTimeout)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someReadTimeout, configUtil.getReadTimeout()); } @Test public void testCustomizeInvalidReadTimeout() throws Exception { String someInvalidReadTimeout = "a"; System.setProperty("apollo.readTimeout", someInvalidReadTimeout); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getReadTimeout() > 0); } @Test public void testCustomizeRefreshInterval() throws Exception { int someRefreshInterval = 1; System.setProperty("apollo.refreshInterval", String.valueOf(someRefreshInterval)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someRefreshInterval, configUtil.getRefreshInterval()); } @Test public void testCustomizeInvalidRefreshInterval() throws Exception { String someInvalidRefreshInterval = "a"; System.setProperty("apollo.refreshInterval", someInvalidRefreshInterval); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getRefreshInterval() > 0); } @Test public void testCustomizeLoadConfigQPS() throws Exception { int someQPS = 1; System.setProperty("apollo.loadConfigQPS", String.valueOf(someQPS)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someQPS, configUtil.getLoadConfigQPS()); } @Test public void testCustomizeInvalidLoadConfigQPS() throws Exception { String someInvalidQPS = "a"; System.setProperty("apollo.loadConfigQPS", someInvalidQPS); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLoadConfigQPS() > 0); } @Test public void testCustomizeLongPollQPS() throws Exception { int someQPS = 1; System.setProperty("apollo.longPollQPS", String.valueOf(someQPS)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someQPS, configUtil.getLongPollQPS()); } @Test public void testCustomizeInvalidLongPollQPS() throws Exception { String someInvalidQPS = "a"; System.setProperty("apollo.longPollQPS", someInvalidQPS); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLongPollQPS() > 0); } @Test public void testCustomizeMaxConfigCacheSize() throws Exception { long someCacheSize = 1; System.setProperty("apollo.configCacheSize", String.valueOf(someCacheSize)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someCacheSize, configUtil.getMaxConfigCacheSize()); } @Test public void testCustomizeInvalidMaxConfigCacheSize() throws Exception { String someInvalidCacheSize = "a"; System.setProperty("apollo.configCacheSize", someInvalidCacheSize); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getMaxConfigCacheSize() > 0); } @Test public void testCustomizeLongPollingInitialDelayInMills() throws Exception { long someLongPollingDelayInMills = 1; System.setProperty("apollo.longPollingInitialDelayInMills", String.valueOf(someLongPollingDelayInMills)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someLongPollingDelayInMills, configUtil.getLongPollingInitialDelayInMills()); } @Test public void testCustomizeInvalidLongPollingInitialDelayInMills() throws Exception { String someInvalidLongPollingDelayInMills = "a"; System.setProperty("apollo.longPollingInitialDelayInMills", someInvalidLongPollingDelayInMills); ConfigUtil configUtil = new ConfigUtil(); assertTrue(configUtil.getLongPollingInitialDelayInMills() > 0); } @Test public void testCustomizeAutoUpdateInjectedSpringProperties() throws Exception { boolean someAutoUpdateInjectedSpringProperties = false; System.setProperty("apollo.autoUpdateInjectedSpringProperties", String.valueOf(someAutoUpdateInjectedSpringProperties)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(someAutoUpdateInjectedSpringProperties, configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()); } @Test public void testLocalCacheDirWithSystemProperty() throws Exception { String someCacheDir = "someCacheDir"; String someAppId = "someAppId"; System.setProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR, someCacheDir); ConfigUtil configUtil = spy(new ConfigUtil()); doReturn(someAppId).when(configUtil).getAppId(); assertEquals(someCacheDir + File.separator + someAppId, configUtil.getDefaultLocalCacheDir()); } @Test public void testDefaultLocalCacheDir() throws Exception { String someAppId = "someAppId"; ConfigUtil configUtil = spy(new ConfigUtil()); doReturn(someAppId).when(configUtil).getAppId(); doReturn(true).when(configUtil).isOSWindows(); assertEquals("C:\\opt\\data\\" + someAppId, configUtil.getDefaultLocalCacheDir()); doReturn(false).when(configUtil).isOSWindows(); assertEquals("/opt/data/" + someAppId, configUtil.getDefaultLocalCacheDir()); } @Test public void testCustomizePropertiesOrdered() { boolean propertiesOrdered = true; System.setProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE, String.valueOf(propertiesOrdered)); ConfigUtil configUtil = new ConfigUtil(); assertEquals(propertiesOrdered, configUtil.isPropertiesOrderEnabled()); } @Test public void test() { ConfigUtil configUtil = new ConfigUtil(); assertFalse(configUtil.isPropertyNamesCacheEnabled()); System.setProperty(ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE, "true"); configUtil = new ConfigUtil(); assertTrue(configUtil.isPropertyNamesCacheEnabled()); } }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/main/java/com/ctrip/framework/apollo/core/ApolloClientSystemConsts.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.core; /** * @author vdisk <vdisk@foxmail.com> */ public class ApolloClientSystemConsts { /** * apollo client app id */ public static final String APP_ID = "app.id"; /** * apollo client app id environment variables */ public static final String APP_ID_ENVIRONMENT_VARIABLES = "APP_ID"; /** * cluster name */ public static final String APOLLO_CLUSTER = ConfigConsts.APOLLO_CLUSTER_KEY; /** * cluster name environment variables */ public static final String APOLLO_CLUSTER_ENVIRONMENT_VARIABLES = "APOLLO_CLUSTER"; /** * local cache directory */ public static final String APOLLO_CACHE_DIR = "apollo.cache-dir"; /** * local cache directory */ @Deprecated public static final String DEPRECATED_APOLLO_CACHE_DIR = "apollo.cacheDir"; /** * local cache directory environment variables */ public static final String APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES = "APOLLO_CACHE_DIR"; /** * local cache directory environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES = "APOLLO_CACHEDIR"; /** * apollo client access key */ public static final String APOLLO_ACCESS_KEY_SECRET = "apollo.access-key.secret"; /** * apollo client access key */ @Deprecated public static final String DEPRECATED_APOLLO_ACCESS_KEY_SECRET = "apollo.accesskey.secret"; /** * apollo client access key environment variables */ public static final String APOLLO_ACCESS_KEY_SECRET_ENVIRONMENT_VARIABLES = "APOLLO_ACCESS_KEY_SECRET"; /** * apollo client access key environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_ACCESS_KEY_SECRET_ENVIRONMENT_VARIABLES = "APOLLO_ACCESSKEY_SECRET"; /** * apollo meta server address */ public static final String APOLLO_META = ConfigConsts.APOLLO_META_KEY; /** * apollo meta server address environment variables */ public static final String APOLLO_META_ENVIRONMENT_VARIABLES = "APOLLO_META"; /** * apollo config service address */ public static final String APOLLO_CONFIG_SERVICE = "apollo.config-service"; /** * apollo config service address */ @Deprecated public static final String DEPRECATED_APOLLO_CONFIG_SERVICE = "apollo.configService"; /** * apollo config service address environment variables */ public static final String APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES = "APOLLO_CONFIG_SERVICE"; /** * apollo config service address environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES = "APOLLO_CONFIGSERVICE"; /** * enable property order */ public static final String APOLLO_PROPERTY_ORDER_ENABLE = "apollo.property.order.enable"; /** * enable property order environment variables */ public static final String APOLLO_PROPERTY_ORDER_ENABLE_ENVIRONMENT_VARIABLES = "APOLLO_PROPERTY_ORDER_ENABLE"; }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.core; /** * @author vdisk <vdisk@foxmail.com> */ public class ApolloClientSystemConsts { /** * apollo client app id */ public static final String APP_ID = "app.id"; /** * apollo client app id environment variables */ public static final String APP_ID_ENVIRONMENT_VARIABLES = "APP_ID"; /** * cluster name */ public static final String APOLLO_CLUSTER = ConfigConsts.APOLLO_CLUSTER_KEY; /** * cluster name environment variables */ public static final String APOLLO_CLUSTER_ENVIRONMENT_VARIABLES = "APOLLO_CLUSTER"; /** * local cache directory */ public static final String APOLLO_CACHE_DIR = "apollo.cache-dir"; /** * local cache directory */ @Deprecated public static final String DEPRECATED_APOLLO_CACHE_DIR = "apollo.cacheDir"; /** * local cache directory environment variables */ public static final String APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES = "APOLLO_CACHE_DIR"; /** * local cache directory environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES = "APOLLO_CACHEDIR"; /** * apollo client access key */ public static final String APOLLO_ACCESS_KEY_SECRET = "apollo.access-key.secret"; /** * apollo client access key */ @Deprecated public static final String DEPRECATED_APOLLO_ACCESS_KEY_SECRET = "apollo.accesskey.secret"; /** * apollo client access key environment variables */ public static final String APOLLO_ACCESS_KEY_SECRET_ENVIRONMENT_VARIABLES = "APOLLO_ACCESS_KEY_SECRET"; /** * apollo client access key environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_ACCESS_KEY_SECRET_ENVIRONMENT_VARIABLES = "APOLLO_ACCESSKEY_SECRET"; /** * apollo meta server address */ public static final String APOLLO_META = ConfigConsts.APOLLO_META_KEY; /** * apollo meta server address environment variables */ public static final String APOLLO_META_ENVIRONMENT_VARIABLES = "APOLLO_META"; /** * apollo config service address */ public static final String APOLLO_CONFIG_SERVICE = "apollo.config-service"; /** * apollo config service address */ @Deprecated public static final String DEPRECATED_APOLLO_CONFIG_SERVICE = "apollo.configService"; /** * apollo config service address environment variables */ public static final String APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES = "APOLLO_CONFIG_SERVICE"; /** * apollo config service address environment variables */ @Deprecated public static final String DEPRECATED_APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES = "APOLLO_CONFIGSERVICE"; /** * enable property order */ public static final String APOLLO_PROPERTY_ORDER_ENABLE = "apollo.property.order.enable"; /** * enable property order environment variables */ public static final String APOLLO_PROPERTY_ORDER_ENABLE_ENVIRONMENT_VARIABLES = "APOLLO_PROPERTY_ORDER_ENABLE"; /** * enable property names cache */ public static final String APOLLO_PROPERTY_NAMES_CACHE_ENABLE = "apollo.property.names.cache.enable"; /** * enable property names cache environment variables */ public static final String APOLLO_PROPERTY_NAMES_CACHE_ENABLE_ENVIRONMENT_VARIABLES = "APOLLO_PROPERTY_NAMES_CACHE_ENABLE"; }
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/zh/usage/java-sdk-user-guide.md
>注意:本文档适用对象是Apollo系统的使用者,如果你是公司内Apollo系统的开发者/维护人员,建议先参考[Apollo开发指南](zh/development/apollo-development-guide)。 # &nbsp; # 一、准备工作 ## 1.1 环境要求 * Java: 1.7+ * Guava: 15.0+ * Apollo客户端默认会引用Guava 19,如果你的项目引用了其它版本,请确保版本号大于等于15.0 >注:对于Apollo客户端,如果有需要的话,可以做少量代码修改来降级到Java 1.6,详细信息可以参考[Issue 483](https://github.com/ctripcorp/apollo/issues/483) ## 1.2 必选设置 Apollo客户端依赖于`AppId`,`Apollo Meta Server`等环境信息来工作,所以请确保阅读下面的说明并且做正确的配置: ### 1.2.1 AppId AppId是应用的身份信息,是从服务端获取配置的一个重要信息。 有以下几种方式设置,按照优先级从高到低分别为: 1. System Property Apollo 0.7.0+支持通过System Property传入app.id信息,如 ```bash -Dapp.id=YOUR-APP-ID ``` 2. 操作系统的System Environment Apollo 1.4.0+支持通过操作系统的System Environment `APP_ID`来传入app.id信息,如 ```bash APP_ID=YOUR-APP-ID ``` 3. Spring Boot application.properties Apollo 1.0.0+支持通过Spring Boot的application.properties文件配置,如 ```properties app.id=YOUR-APP-ID ``` > 该配置方式不适用于多个war包部署在同一个tomcat的使用场景 4. app.properties 确保classpath:/META-INF/app.properties文件存在,并且其中内容形如: >app.id=YOUR-APP-ID 文件位置参考如下: ![app-id-location](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/app-id-location.png) > 注:app.id是用来标识应用身份的唯一id,格式为string。 ### 1.2.2 Apollo Meta Server Apollo支持应用在不同的环境有不同的配置,所以需要在运行提供给Apollo客户端当前环境的[Apollo Meta Server](zh/design/apollo-design?id=_133-meta-server)信息。默认情况下,meta server和config service是部署在同一个JVM进程,所以meta server的地址就是config service的地址。 为了实现meta server的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡。Meta server地址也可以填入IP,如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 1.0.0版本开始支持以下方式配置apollo meta server信息,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.meta` * 可以通过Java的System Property `apollo.meta`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.meta=http://config-service-url` * 如果是运行jar文件,需要注意格式是`java -Dapollo.meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.meta", "http://config-service-url");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.meta=http://config-service-url` > 该配置方式不适用于多个war包部署在同一个tomcat的使用场景 3. 通过操作系统的System Environment`APOLLO_META` * 可以通过操作系统的System Environment `APOLLO_META`来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.meta=http://config-service-url` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` 5. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.meta=http://config-service-url` 6. 通过Java system property `${env}_meta` * 如果当前[env](#_1241-environment)是`dev`,那么用户可以配置`-Ddev_meta=http://config-service-url` * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) 7. 通过操作系统的System Environment `${ENV}_META` (1.2.0版本开始支持) * 如果当前[env](#_1241-environment)是`dev`,那么用户可以配置操作系统的System Environment `DEV_META=http://config-service-url` * 注意key为全大写 * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) 8. 通过`apollo-env.properties`文件 * 用户也可以创建一个`apollo-env.properties`,放在程序的classpath下,或者放在spring boot应用的config目录下 * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) * 文件内容形如: ```properties dev.meta=http://1.1.1.1:8080 fat.meta=http://apollo.fat.xxx.com uat.meta=http://apollo.uat.xxx.com pro.meta=http://apollo.xxx.com ``` > 如果通过以上各种手段都无法获取到Meta Server地址,Apollo最终会fallback到`http://apollo.meta`作为Meta Server地址 #### 1.2.2.1 自定义Apollo Meta Server地址定位逻辑 在1.0.0版本中,Apollo提供了[MetaServerProvider SPI](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/spi/MetaServerProvider.java),用户可以注入自己的MetaServerProvider来自定义Meta Server地址定位逻辑。 由于我们使用典型的[Java Service Loader模式](https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html),所以实现起来还是比较简单的。 有一点需要注意的是,apollo会在运行时按照顺序遍历所有的MetaServerProvider,直到某一个MetaServerProvider提供了一个非空的Meta Server地址,因此用户需要格外注意自定义MetaServerProvider的Order。规则是较小的Order具有较高的优先级,因此Order=0的MetaServerProvider会排在Order=1的MetaServerProvider的前面。 **如果你的公司有很多应用需要接入Apollo,建议封装一个jar包,然后提供自定义的Apollo Meta Server定位逻辑,从而可以让接入Apollo的应用零配置使用。比如自己写一个`xx-company-apollo-client`,该jar包依赖`apollo-client`,在该jar包中通过spi方式定义自定义的MetaServerProvider实现,然后应用直接依赖`xx-company-apollo-client`即可。** MetaServerProvider的实现可以参考[LegacyMetaServerProvider](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/internals/LegacyMetaServerProvider.java)和[DefaultMetaServerProvider](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultMetaServerProvider.java)。 #### 1.2.2.2 跳过Apollo Meta Server服务发现 > 适用于apollo-client 0.11.0及以上版本 一般情况下都建议使用Apollo的Meta Server机制来实现Config Service的服务发现,从而可以实现Config Service的高可用。不过apollo-client也支持跳过Meta Server服务发现,主要用于以下场景: 1. Config Service部署在公有云上,注册到Meta Server的是内网地址,本地开发环境无法直接连接 * 如果通过公网 SLB 对外暴露 Config Service的话,记得要设置 IP 白名单,避免数据泄露 2. Config Service部署在docker环境中,注册到Meta Server的是docker内网地址,本地开发环境无法直接连接 3. Config Service部署在kubernetes中,希望使用kubernetes自带的服务发现能力(Service) 针对以上场景,可以通过直接指定Config Service地址的方式来跳过Meta Server服务发现,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.config-service`(1.9.0+) 或者 `apollo.configService`(1.9.0之前) * 可以通过Java的System Property `apollo.config-service`(1.9.0+) 或者 `apollo.configService`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.config-service=http://config-service-url:port` * 如果是运行jar文件,需要注意格式是`java -Dapollo.configService=http://config-service-url:port -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.config-service", "http://config-service-url:port");` 2. 通过操作系统的System Environment `APOLLO_CONFIG_SERVICE`(1.9.0+) 或者 `APOLLO_CONFIGSERVICE`(1.9.0之前) * 可以通过操作系统的System Environment `APOLLO_CONFIG_SERVICE`(1.9.0+) 或者 `APOLLO_CONFIGSERVICE`(1.9.0之前)来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.config-service=http://config-service-url:port`(1.9.0+) 或者 `apollo.configService=http://config-service-url:port`(1.9.0之前) * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` ### 1.2.3 本地缓存路径 Apollo客户端会把从服务端获取到的配置在本地文件系统缓存一份,用于在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置,不影响应用正常运行。 本地缓存路径默认位于以下路径,所以请确保`/opt/data`或`C:\opt\data\`目录存在,且应用有读写权限。 * **Mac/Linux**: /opt/data/{_appId_}/config-cache * **Windows**: C:\opt\data\\{_appId_}\config-cache 本地配置文件会以下面的文件名格式放置于本地缓存路径下: **_{appId}+{cluster}+{namespace}.properties_** * appId就是应用自己的appId,如100004458 * cluster就是应用使用的集群,一般在本地模式下没有做过配置的话,就是default * namespace就是应用使用的配置namespace,一般是application ![client-local-cache](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/client-local-cache.png) 文件内容以properties格式存储,比如如果有两个key,一个是request.timeout,另一个是batch,那么文件内容就是如下格式: ```properties request.timeout=2000 batch=2000 ``` #### 1.2.3.1 自定义缓存路径 1.0.0版本开始支持以下方式自定义缓存路径,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.cache-dir`(1.9.0+) 或者 `apollo.cacheDir`(1.9.0之前) * 可以通过Java的System Property `apollo.cache-dir`(1.9.0+) 或者 `apollo.cacheDir`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) * 如果是运行jar文件,需要注意格式是`java -Dapollo.cache-dir=/opt/data/some-cache-dir -jar xxx.jar`(1.9.0+) 或者 `java -Dapollo.cacheDir=/opt/data/some-cache-dir -jar xxx.jar`(1.9.0之前) * 也可以通过程序指定,如`System.setProperty("apollo.cache-dir", "/opt/data/some-cache-dir");`(1.9.0+) 或者 `System.setProperty("apollo.cacheDir", "/opt/data/some-cache-dir");`(1.9.0之前) 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) 3. 通过操作系统的System Environment`APOLLO_CACHE_DIR`(1.9.0+) 或者 `APOLLO_CACHEDIR`(1.9.0之前) * 可以通过操作系统的System Environment `APOLLO_CACHE_DIR`(1.9.0+) 或者 `APOLLO_CACHEDIR`(1.9.0之前)来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` > 注:本地缓存路径也可用于容灾目录,如果应用在所有config service都挂掉的情况下需要扩容,那么也可以先把配置从已有机器上的缓存路径复制到新机器上的相同缓存路径 ### 1.2.4 可选设置 #### 1.2.4.1 Environment Environment可以通过以下3种方式的任意一个配置: 1. 通过Java System Property * 可以通过Java的System Property `env`来指定环境 * 在Java程序启动脚本中,可以指定`-Denv=YOUR-ENVIRONMENT` * 如果是运行jar文件,需要注意格式是`java -Denv=YOUR-ENVIRONMENT -jar xxx.jar` * 注意key为全小写 2. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `ENV`来指定 * 注意key为全大写 3. 通过配置文件 * 最后一个推荐的方式是通过配置文件来指定`env=YOUR-ENVIRONMENT` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` 文件内容形如: ```properties env=DEV ``` 目前,`env`支持以下几个值(大小写不敏感): * DEV * Development environment * FAT * Feature Acceptance Test environment * UAT * User Acceptance Test environment * PRO * Production environment 更多环境定义,可以参考[Env.java](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/enums/Env.java) #### 1.2.4.2 Cluster(集群) Apollo支持配置按照集群划分,也就是说对于一个appId和一个环境,对不同的集群可以有不同的配置。 1.0.0版本开始支持以下方式集群,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.cluster` * 可以通过Java的System Property `apollo.cluster`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.cluster=SomeCluster` * 如果是运行jar文件,需要注意格式是`java -Dapollo.cluster=SomeCluster -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.cluster", "SomeCluster");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.cluster=SomeCluster` 3. 通过Java System Property * 可以通过Java的System Property `idc`来指定环境 * 在Java程序启动脚本中,可以指定`-Didc=xxx` * 如果是运行jar文件,需要注意格式是`java -Didc=xxx -jar xxx.jar` * 注意key为全小写 4. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `IDC`来指定 * 注意key为全大写 5. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`idc=xxx` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` **Cluster Precedence**(集群顺序) 1. 如果`apollo.cluster`和`idc`同时指定: * 我们会首先尝试从`apollo.cluster`指定的集群加载配置 * 如果没找到任何配置,会尝试从`idc`指定的集群加载配置 * 如果还是没找到,会从默认的集群(`default`)加载 2. 如果只指定了`apollo.cluster`: * 我们会首先尝试从`apollo.cluster`指定的集群加载配置 * 如果没找到,会从默认的集群(`default`)加载 3. 如果只指定了`idc`: * 我们会首先尝试从`idc`指定的集群加载配置 * 如果没找到,会从默认的集群(`default`)加载 4. 如果`apollo.cluster`和`idc`都没有指定: * 我们会从默认的集群(`default`)加载配置 #### 1.2.4.3 设置内存中的配置项是否保持和页面上的顺序一致 > 适用于1.6.0及以上版本 默认情况下,apollo client内存中的配置存放在Properties中(底下是Hashtable),不会刻意保持和页面上看到的顺序一致,对绝大部分的场景是没有影响的。不过有些场景会强依赖配置项的顺序(如spring cloud zuul的路由规则),针对这种情况,可以开启OrderedProperties特性来使得内存中的配置顺序和页面上看到的一致。 配置方式按照优先级从高到低分别为: 1. 通过Java System Property `apollo.property.order.enable` * 可以通过Java的System Property `apollo.property.order.enable`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.property.order.enable=true` * 如果是运行jar文件,需要注意格式是`java -Dapollo.property.order.enable=true -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.property.order.enable", "true");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.property.order.enable=true` 3. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.property.order.enable=true` #### 1.2.4.4 配置访问密钥 > 适用于1.6.0及以上版本 Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端需要配置密钥,否则无法获取配置。 配置方式按照优先级从高到低分别为: 1. 通过Java System Property `apollo.access-key.secret`(1.9.0+) 或者 `apollo.accesskey.secret`(1.9.0之前) * 可以通过Java的System Property `apollo.access-key.secret`(1.9.0+) 或者 `apollo.accesskey.secret`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `-Dapollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) * 如果是运行jar文件,需要注意格式是`java -Dapollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719 -jar xxx.jar`(1.9.0+) 或者 `java -Dapollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719 -jar xxx.jar`(1.9.0之前) * 也可以通过程序指定,如`System.setProperty("apollo.access-key.secret", "1cf998c4e2ad4704b45a98a509d15719");`(1.9.0+) 或者 `System.setProperty("apollo.accesskey.secret", "1cf998c4e2ad4704b45a98a509d15719");`(1.9.0之前) 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `apollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) 3. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `APOLLO_ACCESS_KEY_SECRET`(1.9.0+) 或者 `APOLLO_ACCESSKEY_SECRET`(1.9.0之前)来指定 * 注意key为全大写 4. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `apollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) #### 1.2.4.5 自定义server.properties路径 > 适用于1.8.0及以上版本 1.8.0版本开始支持以下方式自定义server.properties路径,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.path.server.properties` * 可以通过Java的System Property `apollo.path.server.properties`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.path.server.properties=/some-dir/some-file.properties` * 如果是运行jar文件,需要注意格式是`java -Dapollo.path.server.properties=/some-dir/some-file.properties -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.path.server.properties", "/some-dir/some-file.properties");` 2. 通过操作系统的System Environment`APOLLO_PATH_SERVER_PROPERTIES` * 可以通过操作系统的System Environment `APOLLO_PATH_SERVER_PROPERTIES`来指定 * 注意key为全大写,且中间是`_`分隔 # 二、Maven Dependency Apollo的客户端jar包已经上传到中央仓库,应用在实际使用时只需要按照如下方式引入即可。 ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client</artifactId> <version>1.7.0</version> </dependency> ``` # 三、客户端用法 Apollo支持API方式和Spring整合方式,该怎么选择用哪一种方式? * API方式灵活,功能完备,配置值实时更新(热发布),支持所有Java环境。 * Spring方式接入简单,结合Spring有N种酷炫的玩法,如 * Placeholder方式: * 代码中直接使用,如:`@Value("${someKeyFromApollo:someDefaultValue}")` * 配置文件中使用替换placeholder,如:`spring.datasource.url: ${someKeyFromApollo:someDefaultValue}` * 直接托管spring的配置,如在apollo中直接配置`spring.datasource.url=jdbc:mysql://localhost:3306/somedb?characterEncoding=utf8` * Spring boot的[@ConfigurationProperties](http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/context/properties/ConfigurationProperties.html)方式 * 从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见[PR #972](https://github.com/ctripcorp/apollo/pull/972)。(v0.10.0之前的版本在配置变化后不会重新注入,需要重启才会更新,如果需要配置值实时更新,可以参考后续[3.2.2 Spring Placeholder的使用](#_322-spring-placeholder的使用)的说明) * Spring方式也可以结合API方式使用,如注入Apollo的Config对象,就可以照常通过API方式获取配置了: ```java @ApolloConfig private Config config; //inject config for namespace application ``` * 更多有意思的实际使用场景和示例代码,请参考[apollo-use-cases](https://github.com/ctripcorp/apollo-use-cases) ## 3.1 API使用方式 API方式是最简单、高效使用Apollo配置的方式,不依赖Spring框架即可使用。 ### 3.1.1 获取默认namespace的配置(application) ```java Config config = ConfigService.getAppConfig(); //config instance is singleton for each namespace and is never null String someKey = "someKeyFromDefaultNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` 通过上述的**config.getProperty**可以获取到someKey对应的实时最新的配置值。 另外,配置值从内存中获取,所以不需要应用自己做缓存。 ### 3.1.2 监听配置变化事件 监听配置变化事件只在应用真的关心配置变化,需要在配置变化时得到通知时使用,比如:数据库连接串变化后需要重建连接等。 如果只是希望每次都取到最新的配置的话,只需要按照上面的例子,调用**config.getProperty**即可。 ```java Config config = ConfigService.getAppConfig(); //config instance is singleton for each namespace and is never null config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { System.out.println("Changes for namespace " + changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format("Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ### 3.1.3 获取公共Namespace的配置 ```java String somePublicNamespace = "CAT"; Config config = ConfigService.getConfig(somePublicNamespace); //config instance is singleton for each namespace and is never null String someKey = "someKeyFromPublicNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` ### 3.1.4 获取非properties格式namespace的配置 #### 3.1.4.1 yaml/yml格式的namespace apollo-client 1.3.0版本开始对yaml/yml做了更好的支持,使用起来和properties格式一致。 ```java Config config = ConfigService.getConfig("application.yml"); String someKey = "someKeyFromYmlNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` #### 3.1.4.2 非yaml/yml格式的namespace 获取时需要使用`ConfigService.getConfigFile`接口并指定Format,如`ConfigFileFormat.XML`。 ```java String someNamespace = "test"; ConfigFile configFile = ConfigService.getConfigFile("test", ConfigFileFormat.XML); String content = configFile.getContent(); ``` ## 3.2 Spring整合方式 ### 3.2.1 配置 Apollo也支持和Spring整合(Spring 3.1.1+),只需要做一些简单的配置就可以了。 Apollo目前既支持比较传统的`基于XML`的配置,也支持目前比较流行的`基于Java(推荐)`的配置。 如果是Spring Boot环境,建议参照[3.2.1.3 Spring Boot集成方式(推荐)](#_3213-spring-boot集成方式(推荐))配置。 需要注意的是,如果之前有使用`org.springframework.beans.factory.config.PropertyPlaceholderConfigurer`的,请替换成`org.springframework.context.support.PropertySourcesPlaceholderConfigurer`。Spring 3.1以后就不建议使用PropertyPlaceholderConfigurer了,要改用PropertySourcesPlaceholderConfigurer。 如果之前有使用`<context:property-placeholder>`,请注意xml中引入的`spring-context.xsd`版本需要是3.1以上(一般只要没有指定版本会自动升级的),建议使用不带版本号的形式引入,如:`http://www.springframework.org/schema/context/spring-context.xsd` > 注1:yaml/yml格式的namespace从1.3.0版本开始支持和Spring整合,注入时需要填写带后缀的完整名字,比如application.yml > 注2:非properties、非yaml/yml格式(如xml,json等)的namespace暂不支持和Spring整合。 #### 3.2.1.1 基于XML的配置 >注:需要把apollo相关的xml namespace加到配置文件头上,不然会报xml语法错误。 1.注入默认namespace的配置到Spring中 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <!-- 这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 --> <apollo:config/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` 2.注入多个namespace的配置到Spring中 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <!-- 这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 --> <apollo:config/> <!-- 这个是稍微复杂一些的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中 --> <apollo:config namespaces="FX.apollo,application.yml"/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` 3.注入多个namespace,并且指定顺序 Spring的配置是有顺序的,如果多个property source都有同一个key,那么最终是顺序在前的配置生效。 <apollo:config>如果不指定order,那么默认是最低优先级。 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <apollo:config order="2"/> <!-- 这个是最复杂的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中,并且顺序在application前面 --> <apollo:config namespaces="FX.apollo,application.yml" order="1"/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` #### 3.2.1.2 基于Java的配置(推荐) 相对于基于XML的配置,基于Java的配置是目前比较流行的方式。 注意`@EnableApolloConfig`要和`@Configuration`一起使用,不然不会生效。 1.注入默认namespace的配置到Spring中 ```java //这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } ``` 2.注入多个namespace的配置到Spring中 ```java @Configuration @EnableApolloConfig public class SomeAppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } //这个是稍微复杂一些的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中 @Configuration @EnableApolloConfig({"FX.apollo", "application.yml"}) public class AnotherAppConfig {} ``` 3.注入多个namespace,并且指定顺序 ```java //这个是最复杂的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中,并且顺序在application前面 @Configuration @EnableApolloConfig(order = 2) public class SomeAppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } @Configuration @EnableApolloConfig(value = {"FX.apollo", "application.yml"}, order = 1) public class AnotherAppConfig {} ``` #### 3.2.1.3 Spring Boot集成方式(推荐) Spring Boot除了支持上述两种集成方式以外,还支持通过application.properties/bootstrap.properties来配置,该方式能使配置在更早的阶段注入,比如使用`@ConditionalOnProperty`的场景或者是有一些spring-boot-starter在启动阶段就需要读取配置做一些事情(如[dubbo-spring-boot-project](https://github.com/apache/incubator-dubbo-spring-boot-project)),所以对于Spring Boot环境建议通过以下方式来接入Apollo(需要0.10.0及以上版本)。 使用方式很简单,只需要在application.properties/bootstrap.properties中按照如下样例配置即可。 1. 注入默认`application` namespace的配置示例 ```properties # will inject 'application' namespace in bootstrap phase apollo.bootstrap.enabled = true ``` 2. 注入非默认`application` namespace或多个namespace的配置示例 ```properties apollo.bootstrap.enabled = true # will inject 'application', 'FX.apollo' and 'application.yml' namespaces in bootstrap phase apollo.bootstrap.namespaces = application,FX.apollo,application.yml ``` 3. 将Apollo配置加载提到初始化日志系统之前(1.2.0+) 从1.2.0版本开始,如果希望把日志相关的配置(如`logging.level.root=info`或`logback-spring.xml`中的参数)也放在Apollo管理,那么可以额外配置`apollo.bootstrap.eagerLoad.enabled=true`来使Apollo的加载顺序放到日志系统加载之前,更多信息可以参考[PR 1614](https://github.com/ctripcorp/apollo/pull/1614)。参考配置示例如下: ```properties # will inject 'application' namespace in bootstrap phase apollo.bootstrap.enabled = true # put apollo initialization before logging system initialization apollo.bootstrap.eagerLoad.enabled=true ``` #### 3.2.1.4 Spring Boot Config Data Loader (Spring Boot 2.4+, Apollo Client 1.9.0+ 推荐) 对于 Spring Boot 2.4 以上版本还支持通过 Config Data Loader 模式来加载配置 ##### 3.2.1.4.1 添加 maven 依赖 apollo-client-config-data 已经依赖了 apollo-client, 所以只需要添加这一个依赖即可, 无需再添加 apollo-client 的依赖 ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> </dependencies> ``` ##### 3.2.1.4.2 参照前述的方式配置 `app.id`, `env`, `apollo.meta`(或者 `apollo.config-service`), `apollo.cluster` ##### 3.2.1.4.3 配置 `application.properties` 或 `application.yml` 使用默认的 namespace `application` ```properties # old way # apollo.bootstrap.enabled=true # 不配置 apollo.bootstrap.namespaces # new way spring.config.import=apollo:// ``` 或者 ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=application # new way spring.config.import=apollo://application ``` 使用自定义 namespace ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=your-namespace # new way spring.config.import=apollo://your-namespace ``` 使用多个 namespaces 注: `spring.config.import` 是从后往前加载配置的, 而 `apollo.bootstrap.namespaces` 是从前往后加载的, 刚好相反。为了保证和原有逻辑一致, 请颠倒 namespaces 的顺序 ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=namespace1,namespace2,namespace3 # new way spring.config.import=apollo://namespace3, apollo://namespace2, apollo://namespace1 ``` #### 3.2.1.5 Spring Boot Config Data Loader (Spring Boot 2.4+, Apollo Client 1.9.0+ 推荐) + webClient 扩展 对于 Spring Boot 2.4 以上版本还支持通过 Config Data Loader 模式来加载配置 Apollo 的 Config Data Loader 还提供了基于 webClient 的 http 客户端来替换原有的 http 客户端, 从而方便的对 http 客户端进行扩展 ##### 3.2.1.5.1 添加 maven 依赖 webClient 可以基于多种实现 (reactor netty httpclient, jetty reactive httpclient, apache httpclient5), 所需添加的依赖如下 ###### reactor netty httpclient ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- reactor netty httpclient --> <dependency> <groupId>io.projectreactor.netty</groupId> <artifactId>reactor-netty-http</artifactId> </dependency> </dependencies> ``` ###### jetty reactive httpclient ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- jetty reactive httpclient --> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-reactive-httpclient</artifactId> </dependency> </dependencies> ``` ###### apache httpclient5 spring boot 没有指定 apache httpclient5 的版本, 所以这里需要手动指定一下版本 ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- apache httpclient5 --> <dependency> <groupId>org.apache.httpcomponents.client5</groupId> <artifactId>httpclient5</artifactId> <version>5.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents.core5</groupId> <artifactId>httpcore5-reactive</artifactId> <version>5.1</version> </dependency> </dependencies> ``` ##### 3.2.1.5.2 参照前述的方式配置 `app.id`, `env`, `apollo.meta`(或者 `apollo.config-service`), `apollo.cluster` ##### 3.2.1.5.3 配置 `application.properties` 或 `application.yml` 这里以默认 namespace 为例, namespace 的配置详见 3.2.1.4.3 ```properties spring.config.import=apollo://application apollo.client.extension.enabled=true ``` ##### 3.2.1.5.4 提供 spi 的实现 提供接口 `com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi.ApolloClientWebClientCustomizerFactory` 的 spi 实现 在配置了 `apollo.client.extension.enabled=true` 之后, Apollo 的 Config Data Loader 会尝试去加载该 spi 的实现类来定制 webClient ### 3.2.2 Spring Placeholder的使用 Spring应用通常会使用Placeholder来注入配置,使用的格式形如${someKey:someDefaultValue},如${timeout:100}。冒号前面的是key,冒号后面的是默认值。 建议在实际使用时尽量给出默认值,以免由于key没有定义导致运行时错误。 从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见[PR #972](https://github.com/ctripcorp/apollo/pull/972)。 如果需要关闭placeholder在运行时自动更新功能,可以通过以下两种方式关闭: 1. 通过设置System Property `apollo.autoUpdateInjectedSpringProperties`,如启动时传入`-Dapollo.autoUpdateInjectedSpringProperties=false` 2. 通过设置META-INF/app.properties中的`apollo.autoUpdateInjectedSpringProperties`属性,如 ```properties app.id=SampleApp apollo.autoUpdateInjectedSpringProperties=false ``` #### 3.2.2.1 XML使用方式 假设我有一个TestXmlBean,它有两个配置项需要注入: ```java public class TestXmlBean { private int timeout; private int batch; public void setTimeout(int timeout) { this.timeout = timeout; } public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } ``` 那么,我在XML中会使用如下方式来定义(假设应用默认的application namespace中有timeout和batch的配置项): ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <apollo:config/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` #### 3.2.2.2 Java Config使用方式 假设我有一个TestJavaConfigBean,通过Java Config的方式还可以使用@Value的方式注入: ```java public class TestJavaConfigBean { @Value("${timeout:100}") private int timeout; private int batch; @Value("${batch:200}") public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } ``` 在Configuration类中按照下面的方式使用(假设应用默认的application namespace中有`timeout`和`batch`的配置项): ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } ``` #### 3.2.2.3 ConfigurationProperties使用方式 Spring Boot提供了[@ConfigurationProperties](http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/context/properties/ConfigurationProperties.html)把配置注入到bean对象中。 Apollo也支持这种方式,下面的例子会把`redis.cache.expireSeconds`和`redis.cache.commandTimeout`分别注入到SampleRedisConfig的`expireSeconds`和`commandTimeout`字段中。 ```java @ConfigurationProperties(prefix = "redis.cache") public class SampleRedisConfig { private int expireSeconds; private int commandTimeout; public void setExpireSeconds(int expireSeconds) { this.expireSeconds = expireSeconds; } public void setCommandTimeout(int commandTimeout) { this.commandTimeout = commandTimeout; } } ``` 在Configuration类中按照下面的方式使用(假设应用默认的application namespace中有`redis.cache.expireSeconds`和`redis.cache.commandTimeout`的配置项): ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public SampleRedisConfig sampleRedisConfig() { return new SampleRedisConfig(); } } ``` 需要注意的是,`@ConfigurationProperties`如果需要在Apollo配置变化时自动更新注入的值,需要配合使用[EnvironmentChangeEvent](https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_environment_changes)或[RefreshScope](https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_refresh_scope)。相关代码实现,可以参考apollo-use-cases项目中的[ZuulPropertiesRefresher.java](https://github.com/ctripcorp/apollo-use-cases/blob/master/spring-cloud-zuul/src/main/java/com/ctrip/framework/apollo/use/cases/spring/cloud/zuul/ZuulPropertiesRefresher.java#L48)和apollo-demo项目中的[SampleRedisConfig.java](https://github.com/ctripcorp/apollo/blob/master/apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/config/SampleRedisConfig.java)以及[SpringBootApolloRefreshConfig.java](https://github.com/ctripcorp/apollo/blob/master/apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/refresh/SpringBootApolloRefreshConfig.java) ### 3.2.3 Spring Annotation支持 Apollo同时还增加了几个新的Annotation来简化在Spring环境中的使用。 1. @ApolloConfig * 用来自动注入Config对象 2. @ApolloConfigChangeListener * 用来自动注册ConfigChangeListener 3. @ApolloJsonValue * 用来把配置的json字符串自动注入为对象 使用样例如下: ```java public class TestApolloAnnotationBean { @ApolloConfig private Config config; //inject config for namespace application @ApolloConfig("application") private Config anotherConfig; //inject config for namespace application @ApolloConfig("FX.apollo") private Config yetAnotherConfig; //inject config for namespace FX.apollo @ApolloConfig("application.yml") private Config ymlConfig; //inject config for namespace application.yml /** * ApolloJsonValue annotated on fields example, the default value is specified as empty list - [] * <br /> * jsonBeanProperty=[{"someString":"hello","someInt":100},{"someString":"world!","someInt":200}] */ @ApolloJsonValue("${jsonBeanProperty:[]}") private List<JsonBean> anotherJsonBeans; @Value("${batch:100}") private int batch; //config change listener for namespace application @ApolloConfigChangeListener private void someOnChange(ConfigChangeEvent changeEvent) { //update injected value of batch if it is changed in Apollo if (changeEvent.isChanged("batch")) { batch = config.getIntProperty("batch", 100); } } //config change listener for namespace application @ApolloConfigChangeListener("application") private void anotherOnChange(ConfigChangeEvent changeEvent) { //do something } //config change listener for namespaces application, FX.apollo and application.yml @ApolloConfigChangeListener({"application", "FX.apollo", "application.yml"}) private void yetAnotherOnChange(ConfigChangeEvent changeEvent) { //do something } //example of getting config from Apollo directly //this will always return the latest value of timeout public int getTimeout() { return config.getIntProperty("timeout", 200); } //example of getting config from injected value //the program needs to update the injected value when batch is changed in Apollo using @ApolloConfigChangeListener shown above public int getBatch() { return this.batch; } private static class JsonBean{ private String someString; private int someInt; } } ``` 在Configuration类中按照下面的方式使用: ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestApolloAnnotationBean testApolloAnnotationBean() { return new TestApolloAnnotationBean(); } } ``` ### 3.2.4 已有配置迁移 很多情况下,应用可能已经有不少配置了,比如Spring Boot的应用,就会有bootstrap.properties/yml, application.properties/yml等配置。 在应用接入Apollo之后,这些配置是可以非常方便的迁移到Apollo的,具体步骤如下: 1. 在Apollo为应用新建项目 2. 在应用中配置好META-INF/app.properties 3. 建议把原先配置先转为properties格式,然后通过Apollo提供的文本编辑模式全部粘帖到应用的application namespace,发布配置 * 如果原来格式是yml,可以使用[YamlPropertiesFactoryBean.getObject](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.html#getObject--)转成properties格式 4. 如果原来是yml,想继续使用yml来编辑配置,那么可以创建私有的application.yml namespace,把原来的配置全部粘贴进去,发布配置 * 需要apollo-client是1.3.0及以上版本 5. 把原先的配置文件如bootstrap.properties/yml, application.properties/yml从项目中删除 * 如果需要保留本地配置文件,需要注意部分配置如`server.port`必须确保本地文件已经删除该配置项 如: ```properties spring.application.name = reservation-service server.port = 8080 logging.level = ERROR eureka.client.serviceUrl.defaultZone = http://127.0.0.1:8761/eureka/ eureka.client.healthcheck.enabled = true eureka.client.registerWithEureka = true eureka.client.fetchRegistry = true eureka.client.eurekaServiceUrlPollIntervalSeconds = 60 eureka.instance.preferIpAddress = true ``` ![text-mode-spring-boot-config-sample](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/text-mode-spring-boot-config-sample.png) ## 3.3 Demo 项目中有一个样例客户端的项目:`apollo-demo`,具体信息可以参考[Apollo开发指南](zh/development/apollo-development-guide)中的[2.3 Java样例客户端启动](zh/development/apollo-development-guide?id=_23-java样例客户端启动)部分。 更多使用案例Demo可以参考[Apollo使用场景和示例代码](https://github.com/ctripcorp/apollo-use-cases)。 # 四、客户端设计 ![client-architecture](https://github.com/ctripcorp/apollo/raw/master/doc/images/client-architecture.png) 上图简要描述了Apollo客户端的实现原理: 1. 客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。(通过Http Long Polling实现) 2. 客户端还会定时从Apollo配置中心服务端拉取应用的最新配置。 * 这是一个fallback机制,为了防止推送机制失效导致配置不更新 * 客户端定时拉取会上报本地版本,所以一般情况下,对于定时拉取的操作,服务端都会返回304 - Not Modified * 定时频率默认为每5分钟拉取一次,客户端也可以通过在运行时指定System Property: `apollo.refreshInterval`来覆盖,单位为分钟。 3. 客户端从Apollo配置中心服务端获取到应用的最新配置后,会保存在内存中 4. 客户端会把从服务端获取到的配置在本地文件系统缓存一份 * 在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置 5. 应用程序可以从Apollo客户端获取最新的配置、订阅配置更新通知 # 五、本地开发模式 Apollo客户端还支持本地开发模式,这个主要用于当开发环境无法连接Apollo服务器的时候,比如在邮轮、飞机上做相关功能开发。 在本地开发模式下,Apollo只会从本地文件读取配置信息,不会从Apollo服务器读取配置。 可以通过下面的步骤开启Apollo本地开发模式。 ## 5.1 修改环境 修改/opt/settings/server.properties(Mac/Linux)或C:\opt\settings\server.properties(Windows)文件,设置env为Local: ```properties env=Local ``` 更多配置环境的方式请参考[1.2.4.1 Environment](#_1241-environment) ## 5.2 准备本地配置文件 在本地开发模式下,Apollo客户端会从本地读取文件,所以我们需要事先准备好配置文件。 ### 5.2.1 本地配置目录 本地配置目录位于: * **Mac/Linux**: /opt/data/{_appId_}/config-cache * **Windows**: C:\opt\data\\{_appId_}\config-cache appId就是应用的appId,如100004458。 请确保该目录存在,且应用程序对该目录有读权限。 **【小技巧】** 推荐的方式是先在普通模式下使用Apollo,这样Apollo会自动创建该目录并在目录下生成配置文件。 ### 5.2.2 本地配置文件 本地配置文件需要按照一定的文件名格式放置于本地配置目录下,文件名格式如下: **_{appId}+{cluster}+{namespace}.properties_** * appId就是应用自己的appId,如100004458 * cluster就是应用使用的集群,一般在本地模式下没有做过配置的话,就是default * namespace就是应用使用的配置namespace,一般是application ![client-local-cache](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/client-local-cache.png) 文件内容以properties格式存储,比如如果有两个key,一个是request.timeout,另一个是batch,那么文件内容就是如下格式: ```properties request.timeout=2000 batch=2000 ``` ## 5.3 修改配置 在本地开发模式下,Apollo不会实时监测文件内容是否有变化,所以如果修改了配置,需要重启应用生效。 # 六、测试模式 1.1.0版本开始增加了`apollo-mockserver`,从而可以很好地支持单元测试时需要mock配置的场景,使用方法如下: ## 6.1 引入pom依赖 ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-mockserver</artifactId> <version>1.7.0</version> </dependency> ``` ## 6.2 在test的resources下放置mock的数据 文件名格式约定为`mockdata-{namespace}.properties` ![image](https://user-images.githubusercontent.com/17842829/44515526-5e0e6480-a6f5-11e8-9c3c-4ff2ec737c8d.png) ## 6.3 写测试类 更多使用demo可以参考[ApolloMockServerApiTest.java](https://github.com/ctripcorp/apollo/blob/master/apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiTest.java)和[ApolloMockServerSpringIntegrationTest.java](https://github.com/ctripcorp/apollo/blob/master/apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerSpringIntegrationTest.java)。 ```java @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = TestConfiguration.class) public class SpringIntegrationTest { // 启动apollo的mockserver @ClassRule public static EmbeddedApollo embeddedApollo = new EmbeddedApollo(); @Test @DirtiesContext // 这个注解很有必要,因为配置注入会弄脏应用上下文 public void testPropertyInject(){ assertEquals("value1", testBean.key1); assertEquals("value2", testBean.key2); } @Test @DirtiesContext public void testListenerTriggeredByAdd() throws InterruptedException, ExecutionException, TimeoutException { String otherNamespace = "othernamespace"; embeddedApollo.addOrModifyPropery(otherNamespace,"someKey","someValue"); ConfigChangeEvent changeEvent = testBean.futureData.get(5000, TimeUnit.MILLISECONDS); assertEquals(otherNamespace, changeEvent.getNamespace()); assertEquals("someValue", changeEvent.getChange("someKey").getNewValue()); } @EnableApolloConfig("application") @Configuration static class TestConfiguration{ @Bean public TestBean testBean(){ return new TestBean(); } } static class TestBean{ @Value("${key1:default}") String key1; @Value("${key2:default}") String key2; SettableFuture<ConfigChangeEvent> futureData = SettableFuture.create(); @ApolloConfigChangeListener("othernamespace") private void onChange(ConfigChangeEvent changeEvent) { futureData.set(changeEvent); } } } ```
>注意:本文档适用对象是Apollo系统的使用者,如果你是公司内Apollo系统的开发者/维护人员,建议先参考[Apollo开发指南](zh/development/apollo-development-guide)。 # &nbsp; # 一、准备工作 ## 1.1 环境要求 * Java: 1.7+ * Guava: 15.0+ * Apollo客户端默认会引用Guava 19,如果你的项目引用了其它版本,请确保版本号大于等于15.0 >注:对于Apollo客户端,如果有需要的话,可以做少量代码修改来降级到Java 1.6,详细信息可以参考[Issue 483](https://github.com/ctripcorp/apollo/issues/483) ## 1.2 必选设置 Apollo客户端依赖于`AppId`,`Apollo Meta Server`等环境信息来工作,所以请确保阅读下面的说明并且做正确的配置: ### 1.2.1 AppId AppId是应用的身份信息,是从服务端获取配置的一个重要信息。 有以下几种方式设置,按照优先级从高到低分别为: 1. System Property Apollo 0.7.0+支持通过System Property传入app.id信息,如 ```bash -Dapp.id=YOUR-APP-ID ``` 2. 操作系统的System Environment Apollo 1.4.0+支持通过操作系统的System Environment `APP_ID`来传入app.id信息,如 ```bash APP_ID=YOUR-APP-ID ``` 3. Spring Boot application.properties Apollo 1.0.0+支持通过Spring Boot的application.properties文件配置,如 ```properties app.id=YOUR-APP-ID ``` > 该配置方式不适用于多个war包部署在同一个tomcat的使用场景 4. app.properties 确保classpath:/META-INF/app.properties文件存在,并且其中内容形如: >app.id=YOUR-APP-ID 文件位置参考如下: ![app-id-location](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/app-id-location.png) > 注:app.id是用来标识应用身份的唯一id,格式为string。 ### 1.2.2 Apollo Meta Server Apollo支持应用在不同的环境有不同的配置,所以需要在运行提供给Apollo客户端当前环境的[Apollo Meta Server](zh/design/apollo-design?id=_133-meta-server)信息。默认情况下,meta server和config service是部署在同一个JVM进程,所以meta server的地址就是config service的地址。 为了实现meta server的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡。Meta server地址也可以填入IP,如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 1.0.0版本开始支持以下方式配置apollo meta server信息,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.meta` * 可以通过Java的System Property `apollo.meta`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.meta=http://config-service-url` * 如果是运行jar文件,需要注意格式是`java -Dapollo.meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.meta", "http://config-service-url");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.meta=http://config-service-url` > 该配置方式不适用于多个war包部署在同一个tomcat的使用场景 3. 通过操作系统的System Environment`APOLLO_META` * 可以通过操作系统的System Environment `APOLLO_META`来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.meta=http://config-service-url` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` 5. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.meta=http://config-service-url` 6. 通过Java system property `${env}_meta` * 如果当前[env](#_1241-environment)是`dev`,那么用户可以配置`-Ddev_meta=http://config-service-url` * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) 7. 通过操作系统的System Environment `${ENV}_META` (1.2.0版本开始支持) * 如果当前[env](#_1241-environment)是`dev`,那么用户可以配置操作系统的System Environment `DEV_META=http://config-service-url` * 注意key为全大写 * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) 8. 通过`apollo-env.properties`文件 * 用户也可以创建一个`apollo-env.properties`,放在程序的classpath下,或者放在spring boot应用的config目录下 * 使用该配置方式,那么就必须要正确配置Environment,详见[1.2.4.1 Environment](#_1241-environment) * 文件内容形如: ```properties dev.meta=http://1.1.1.1:8080 fat.meta=http://apollo.fat.xxx.com uat.meta=http://apollo.uat.xxx.com pro.meta=http://apollo.xxx.com ``` > 如果通过以上各种手段都无法获取到Meta Server地址,Apollo最终会fallback到`http://apollo.meta`作为Meta Server地址 #### 1.2.2.1 自定义Apollo Meta Server地址定位逻辑 在1.0.0版本中,Apollo提供了[MetaServerProvider SPI](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/spi/MetaServerProvider.java),用户可以注入自己的MetaServerProvider来自定义Meta Server地址定位逻辑。 由于我们使用典型的[Java Service Loader模式](https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html),所以实现起来还是比较简单的。 有一点需要注意的是,apollo会在运行时按照顺序遍历所有的MetaServerProvider,直到某一个MetaServerProvider提供了一个非空的Meta Server地址,因此用户需要格外注意自定义MetaServerProvider的Order。规则是较小的Order具有较高的优先级,因此Order=0的MetaServerProvider会排在Order=1的MetaServerProvider的前面。 **如果你的公司有很多应用需要接入Apollo,建议封装一个jar包,然后提供自定义的Apollo Meta Server定位逻辑,从而可以让接入Apollo的应用零配置使用。比如自己写一个`xx-company-apollo-client`,该jar包依赖`apollo-client`,在该jar包中通过spi方式定义自定义的MetaServerProvider实现,然后应用直接依赖`xx-company-apollo-client`即可。** MetaServerProvider的实现可以参考[LegacyMetaServerProvider](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/internals/LegacyMetaServerProvider.java)和[DefaultMetaServerProvider](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultMetaServerProvider.java)。 #### 1.2.2.2 跳过Apollo Meta Server服务发现 > 适用于apollo-client 0.11.0及以上版本 一般情况下都建议使用Apollo的Meta Server机制来实现Config Service的服务发现,从而可以实现Config Service的高可用。不过apollo-client也支持跳过Meta Server服务发现,主要用于以下场景: 1. Config Service部署在公有云上,注册到Meta Server的是内网地址,本地开发环境无法直接连接 * 如果通过公网 SLB 对外暴露 Config Service的话,记得要设置 IP 白名单,避免数据泄露 2. Config Service部署在docker环境中,注册到Meta Server的是docker内网地址,本地开发环境无法直接连接 3. Config Service部署在kubernetes中,希望使用kubernetes自带的服务发现能力(Service) 针对以上场景,可以通过直接指定Config Service地址的方式来跳过Meta Server服务发现,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.config-service`(1.9.0+) 或者 `apollo.configService`(1.9.0之前) * 可以通过Java的System Property `apollo.config-service`(1.9.0+) 或者 `apollo.configService`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.config-service=http://config-service-url:port` * 如果是运行jar文件,需要注意格式是`java -Dapollo.configService=http://config-service-url:port -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.config-service", "http://config-service-url:port");` 2. 通过操作系统的System Environment `APOLLO_CONFIG_SERVICE`(1.9.0+) 或者 `APOLLO_CONFIGSERVICE`(1.9.0之前) * 可以通过操作系统的System Environment `APOLLO_CONFIG_SERVICE`(1.9.0+) 或者 `APOLLO_CONFIGSERVICE`(1.9.0之前)来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.config-service=http://config-service-url:port`(1.9.0+) 或者 `apollo.configService=http://config-service-url:port`(1.9.0之前) * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` ### 1.2.3 本地缓存路径 Apollo客户端会把从服务端获取到的配置在本地文件系统缓存一份,用于在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置,不影响应用正常运行。 本地缓存路径默认位于以下路径,所以请确保`/opt/data`或`C:\opt\data\`目录存在,且应用有读写权限。 * **Mac/Linux**: /opt/data/{_appId_}/config-cache * **Windows**: C:\opt\data\\{_appId_}\config-cache 本地配置文件会以下面的文件名格式放置于本地缓存路径下: **_{appId}+{cluster}+{namespace}.properties_** * appId就是应用自己的appId,如100004458 * cluster就是应用使用的集群,一般在本地模式下没有做过配置的话,就是default * namespace就是应用使用的配置namespace,一般是application ![client-local-cache](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/client-local-cache.png) 文件内容以properties格式存储,比如如果有两个key,一个是request.timeout,另一个是batch,那么文件内容就是如下格式: ```properties request.timeout=2000 batch=2000 ``` #### 1.2.3.1 自定义缓存路径 1.0.0版本开始支持以下方式自定义缓存路径,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.cache-dir`(1.9.0+) 或者 `apollo.cacheDir`(1.9.0之前) * 可以通过Java的System Property `apollo.cache-dir`(1.9.0+) 或者 `apollo.cacheDir`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) * 如果是运行jar文件,需要注意格式是`java -Dapollo.cache-dir=/opt/data/some-cache-dir -jar xxx.jar`(1.9.0+) 或者 `java -Dapollo.cacheDir=/opt/data/some-cache-dir -jar xxx.jar`(1.9.0之前) * 也可以通过程序指定,如`System.setProperty("apollo.cache-dir", "/opt/data/some-cache-dir");`(1.9.0+) 或者 `System.setProperty("apollo.cacheDir", "/opt/data/some-cache-dir");`(1.9.0之前) 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) 3. 通过操作系统的System Environment`APOLLO_CACHE_DIR`(1.9.0+) 或者 `APOLLO_CACHEDIR`(1.9.0之前) * 可以通过操作系统的System Environment `APOLLO_CACHE_DIR`(1.9.0+) 或者 `APOLLO_CACHEDIR`(1.9.0之前)来指定 * 注意key为全大写,且中间是`_`分隔 4. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`apollo.cache-dir=/opt/data/some-cache-dir`(1.9.0+) 或者 `apollo.cacheDir=/opt/data/some-cache-dir`(1.9.0之前) * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` > 注:本地缓存路径也可用于容灾目录,如果应用在所有config service都挂掉的情况下需要扩容,那么也可以先把配置从已有机器上的缓存路径复制到新机器上的相同缓存路径 ### 1.2.4 可选设置 #### 1.2.4.1 Environment Environment可以通过以下3种方式的任意一个配置: 1. 通过Java System Property * 可以通过Java的System Property `env`来指定环境 * 在Java程序启动脚本中,可以指定`-Denv=YOUR-ENVIRONMENT` * 如果是运行jar文件,需要注意格式是`java -Denv=YOUR-ENVIRONMENT -jar xxx.jar` * 注意key为全小写 2. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `ENV`来指定 * 注意key为全大写 3. 通过配置文件 * 最后一个推荐的方式是通过配置文件来指定`env=YOUR-ENVIRONMENT` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` 文件内容形如: ```properties env=DEV ``` 目前,`env`支持以下几个值(大小写不敏感): * DEV * Development environment * FAT * Feature Acceptance Test environment * UAT * User Acceptance Test environment * PRO * Production environment 更多环境定义,可以参考[Env.java](https://github.com/ctripcorp/apollo/blob/master/apollo-core/src/main/java/com/ctrip/framework/apollo/core/enums/Env.java) #### 1.2.4.2 Cluster(集群) Apollo支持配置按照集群划分,也就是说对于一个appId和一个环境,对不同的集群可以有不同的配置。 1.0.0版本开始支持以下方式集群,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.cluster` * 可以通过Java的System Property `apollo.cluster`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.cluster=SomeCluster` * 如果是运行jar文件,需要注意格式是`java -Dapollo.cluster=SomeCluster -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.cluster", "SomeCluster");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.cluster=SomeCluster` 3. 通过Java System Property * 可以通过Java的System Property `idc`来指定环境 * 在Java程序启动脚本中,可以指定`-Didc=xxx` * 如果是运行jar文件,需要注意格式是`java -Didc=xxx -jar xxx.jar` * 注意key为全小写 4. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `IDC`来指定 * 注意key为全大写 5. 通过`server.properties`配置文件 * 可以在`server.properties`配置文件中指定`idc=xxx` * 对于Mac/Linux,默认文件位置为`/opt/settings/server.properties` * 对于Windows,默认文件位置为`C:\opt\settings\server.properties` **Cluster Precedence**(集群顺序) 1. 如果`apollo.cluster`和`idc`同时指定: * 我们会首先尝试从`apollo.cluster`指定的集群加载配置 * 如果没找到任何配置,会尝试从`idc`指定的集群加载配置 * 如果还是没找到,会从默认的集群(`default`)加载 2. 如果只指定了`apollo.cluster`: * 我们会首先尝试从`apollo.cluster`指定的集群加载配置 * 如果没找到,会从默认的集群(`default`)加载 3. 如果只指定了`idc`: * 我们会首先尝试从`idc`指定的集群加载配置 * 如果没找到,会从默认的集群(`default`)加载 4. 如果`apollo.cluster`和`idc`都没有指定: * 我们会从默认的集群(`default`)加载配置 #### 1.2.4.3 设置内存中的配置项是否保持和页面上的顺序一致 > 适用于1.6.0及以上版本 默认情况下,apollo client内存中的配置存放在Properties中(底下是Hashtable),不会刻意保持和页面上看到的顺序一致,对绝大部分的场景是没有影响的。不过有些场景会强依赖配置项的顺序(如spring cloud zuul的路由规则),针对这种情况,可以开启OrderedProperties特性来使得内存中的配置顺序和页面上看到的一致。 配置方式按照优先级从高到低分别为: 1. 通过Java System Property `apollo.property.order.enable` * 可以通过Java的System Property `apollo.property.order.enable`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.property.order.enable=true` * 如果是运行jar文件,需要注意格式是`java -Dapollo.property.order.enable=true -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.property.order.enable", "true");` 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.property.order.enable=true` 3. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.property.order.enable=true` #### 1.2.4.4 配置访问密钥 > 适用于1.6.0及以上版本 Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端需要配置密钥,否则无法获取配置。 配置方式按照优先级从高到低分别为: 1. 通过Java System Property `apollo.access-key.secret`(1.9.0+) 或者 `apollo.accesskey.secret`(1.9.0之前) * 可以通过Java的System Property `apollo.access-key.secret`(1.9.0+) 或者 `apollo.accesskey.secret`(1.9.0之前)来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `-Dapollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) * 如果是运行jar文件,需要注意格式是`java -Dapollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719 -jar xxx.jar`(1.9.0+) 或者 `java -Dapollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719 -jar xxx.jar`(1.9.0之前) * 也可以通过程序指定,如`System.setProperty("apollo.access-key.secret", "1cf998c4e2ad4704b45a98a509d15719");`(1.9.0+) 或者 `System.setProperty("apollo.accesskey.secret", "1cf998c4e2ad4704b45a98a509d15719");`(1.9.0之前) 2. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `apollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) 3. 通过操作系统的System Environment * 还可以通过操作系统的System Environment `APOLLO_ACCESS_KEY_SECRET`(1.9.0+) 或者 `APOLLO_ACCESSKEY_SECRET`(1.9.0之前)来指定 * 注意key为全大写 4. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.access-key.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0+) 或者 `apollo.accesskey.secret=1cf998c4e2ad4704b45a98a509d15719`(1.9.0之前) #### 1.2.4.5 自定义server.properties路径 > 适用于1.8.0及以上版本 1.8.0版本开始支持以下方式自定义server.properties路径,按照优先级从高到低分别为: 1. 通过Java System Property `apollo.path.server.properties` * 可以通过Java的System Property `apollo.path.server.properties`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.path.server.properties=/some-dir/some-file.properties` * 如果是运行jar文件,需要注意格式是`java -Dapollo.path.server.properties=/some-dir/some-file.properties -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.path.server.properties", "/some-dir/some-file.properties");` 2. 通过操作系统的System Environment`APOLLO_PATH_SERVER_PROPERTIES` * 可以通过操作系统的System Environment `APOLLO_PATH_SERVER_PROPERTIES`来指定 * 注意key为全大写,且中间是`_`分隔 #### 1.2.4.6 开启`propertyNames`缓存,在大量配置场景下可以显著改善启动速度 > 适用于1.9.0及以上版本 在使用`@ConfigurationProperties`和存在大量配置项场景下,Spring容器的启动速度会变慢。通过开启该配置可以显著提升启动速度,当配置发生变化时缓存会自动清理,默认为`false`。详见:[issue 3800](https://github.com/ctripcorp/apollo/issues/3800) 配置方式按照优先级从高到低依次为: 1. 通过Java System Property `apollo.property.names.cache.enable` * 可以通过Java的System Property `apollo.property.names.cache.enable`来指定 * 在Java程序启动脚本中,可以指定`-Dapollo.property.names.cache.enable=true` * 如果是运行jar文件,需要注意格式是`java -Dapollo.property.names.cache.enable=true -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("apollo.property.names.cache.enable", "true");` 2. 通过系统环境变量 * 在启动程序前配置环境变量`APOLLO_PROPERTY_NAMES_CACHE_ENABLE=true`来指定 * 注意key为全大写,且中间是`_`分隔 3. 通过Spring Boot的配置文件 * 可以在Spring Boot的`application.properties`或`bootstrap.properties`中指定`apollo.property.names.cache.enable=true` 4. 通过`app.properties`配置文件 * 可以在`classpath:/META-INF/app.properties`指定`apollo.property.names.cache.enable=true` # 二、Maven Dependency Apollo的客户端jar包已经上传到中央仓库,应用在实际使用时只需要按照如下方式引入即可。 ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client</artifactId> <version>1.7.0</version> </dependency> ``` # 三、客户端用法 Apollo支持API方式和Spring整合方式,该怎么选择用哪一种方式? * API方式灵活,功能完备,配置值实时更新(热发布),支持所有Java环境。 * Spring方式接入简单,结合Spring有N种酷炫的玩法,如 * Placeholder方式: * 代码中直接使用,如:`@Value("${someKeyFromApollo:someDefaultValue}")` * 配置文件中使用替换placeholder,如:`spring.datasource.url: ${someKeyFromApollo:someDefaultValue}` * 直接托管spring的配置,如在apollo中直接配置`spring.datasource.url=jdbc:mysql://localhost:3306/somedb?characterEncoding=utf8` * Spring boot的[@ConfigurationProperties](http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/context/properties/ConfigurationProperties.html)方式 * 从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见[PR #972](https://github.com/ctripcorp/apollo/pull/972)。(v0.10.0之前的版本在配置变化后不会重新注入,需要重启才会更新,如果需要配置值实时更新,可以参考后续[3.2.2 Spring Placeholder的使用](#_322-spring-placeholder的使用)的说明) * Spring方式也可以结合API方式使用,如注入Apollo的Config对象,就可以照常通过API方式获取配置了: ```java @ApolloConfig private Config config; //inject config for namespace application ``` * 更多有意思的实际使用场景和示例代码,请参考[apollo-use-cases](https://github.com/ctripcorp/apollo-use-cases) ## 3.1 API使用方式 API方式是最简单、高效使用Apollo配置的方式,不依赖Spring框架即可使用。 ### 3.1.1 获取默认namespace的配置(application) ```java Config config = ConfigService.getAppConfig(); //config instance is singleton for each namespace and is never null String someKey = "someKeyFromDefaultNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` 通过上述的**config.getProperty**可以获取到someKey对应的实时最新的配置值。 另外,配置值从内存中获取,所以不需要应用自己做缓存。 ### 3.1.2 监听配置变化事件 监听配置变化事件只在应用真的关心配置变化,需要在配置变化时得到通知时使用,比如:数据库连接串变化后需要重建连接等。 如果只是希望每次都取到最新的配置的话,只需要按照上面的例子,调用**config.getProperty**即可。 ```java Config config = ConfigService.getAppConfig(); //config instance is singleton for each namespace and is never null config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { System.out.println("Changes for namespace " + changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format("Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ### 3.1.3 获取公共Namespace的配置 ```java String somePublicNamespace = "CAT"; Config config = ConfigService.getConfig(somePublicNamespace); //config instance is singleton for each namespace and is never null String someKey = "someKeyFromPublicNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` ### 3.1.4 获取非properties格式namespace的配置 #### 3.1.4.1 yaml/yml格式的namespace apollo-client 1.3.0版本开始对yaml/yml做了更好的支持,使用起来和properties格式一致。 ```java Config config = ConfigService.getConfig("application.yml"); String someKey = "someKeyFromYmlNamespace"; String someDefaultValue = "someDefaultValueForTheKey"; String value = config.getProperty(someKey, someDefaultValue); ``` #### 3.1.4.2 非yaml/yml格式的namespace 获取时需要使用`ConfigService.getConfigFile`接口并指定Format,如`ConfigFileFormat.XML`。 ```java String someNamespace = "test"; ConfigFile configFile = ConfigService.getConfigFile("test", ConfigFileFormat.XML); String content = configFile.getContent(); ``` ## 3.2 Spring整合方式 ### 3.2.1 配置 Apollo也支持和Spring整合(Spring 3.1.1+),只需要做一些简单的配置就可以了。 Apollo目前既支持比较传统的`基于XML`的配置,也支持目前比较流行的`基于Java(推荐)`的配置。 如果是Spring Boot环境,建议参照[3.2.1.3 Spring Boot集成方式(推荐)](#_3213-spring-boot集成方式(推荐))配置。 需要注意的是,如果之前有使用`org.springframework.beans.factory.config.PropertyPlaceholderConfigurer`的,请替换成`org.springframework.context.support.PropertySourcesPlaceholderConfigurer`。Spring 3.1以后就不建议使用PropertyPlaceholderConfigurer了,要改用PropertySourcesPlaceholderConfigurer。 如果之前有使用`<context:property-placeholder>`,请注意xml中引入的`spring-context.xsd`版本需要是3.1以上(一般只要没有指定版本会自动升级的),建议使用不带版本号的形式引入,如:`http://www.springframework.org/schema/context/spring-context.xsd` > 注1:yaml/yml格式的namespace从1.3.0版本开始支持和Spring整合,注入时需要填写带后缀的完整名字,比如application.yml > 注2:非properties、非yaml/yml格式(如xml,json等)的namespace暂不支持和Spring整合。 #### 3.2.1.1 基于XML的配置 >注:需要把apollo相关的xml namespace加到配置文件头上,不然会报xml语法错误。 1.注入默认namespace的配置到Spring中 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <!-- 这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 --> <apollo:config/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` 2.注入多个namespace的配置到Spring中 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <!-- 这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 --> <apollo:config/> <!-- 这个是稍微复杂一些的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中 --> <apollo:config namespaces="FX.apollo,application.yml"/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` 3.注入多个namespace,并且指定顺序 Spring的配置是有顺序的,如果多个property source都有同一个key,那么最终是顺序在前的配置生效。 <apollo:config>如果不指定order,那么默认是最低优先级。 ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <apollo:config order="2"/> <!-- 这个是最复杂的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中,并且顺序在application前面 --> <apollo:config namespaces="FX.apollo,application.yml" order="1"/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` #### 3.2.1.2 基于Java的配置(推荐) 相对于基于XML的配置,基于Java的配置是目前比较流行的方式。 注意`@EnableApolloConfig`要和`@Configuration`一起使用,不然不会生效。 1.注入默认namespace的配置到Spring中 ```java //这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } ``` 2.注入多个namespace的配置到Spring中 ```java @Configuration @EnableApolloConfig public class SomeAppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } //这个是稍微复杂一些的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中 @Configuration @EnableApolloConfig({"FX.apollo", "application.yml"}) public class AnotherAppConfig {} ``` 3.注入多个namespace,并且指定顺序 ```java //这个是最复杂的配置形式,指示Apollo注入FX.apollo和application.yml namespace的配置到Spring环境中,并且顺序在application前面 @Configuration @EnableApolloConfig(order = 2) public class SomeAppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } @Configuration @EnableApolloConfig(value = {"FX.apollo", "application.yml"}, order = 1) public class AnotherAppConfig {} ``` #### 3.2.1.3 Spring Boot集成方式(推荐) Spring Boot除了支持上述两种集成方式以外,还支持通过application.properties/bootstrap.properties来配置,该方式能使配置在更早的阶段注入,比如使用`@ConditionalOnProperty`的场景或者是有一些spring-boot-starter在启动阶段就需要读取配置做一些事情(如[dubbo-spring-boot-project](https://github.com/apache/incubator-dubbo-spring-boot-project)),所以对于Spring Boot环境建议通过以下方式来接入Apollo(需要0.10.0及以上版本)。 使用方式很简单,只需要在application.properties/bootstrap.properties中按照如下样例配置即可。 1. 注入默认`application` namespace的配置示例 ```properties # will inject 'application' namespace in bootstrap phase apollo.bootstrap.enabled = true ``` 2. 注入非默认`application` namespace或多个namespace的配置示例 ```properties apollo.bootstrap.enabled = true # will inject 'application', 'FX.apollo' and 'application.yml' namespaces in bootstrap phase apollo.bootstrap.namespaces = application,FX.apollo,application.yml ``` 3. 将Apollo配置加载提到初始化日志系统之前(1.2.0+) 从1.2.0版本开始,如果希望把日志相关的配置(如`logging.level.root=info`或`logback-spring.xml`中的参数)也放在Apollo管理,那么可以额外配置`apollo.bootstrap.eagerLoad.enabled=true`来使Apollo的加载顺序放到日志系统加载之前,更多信息可以参考[PR 1614](https://github.com/ctripcorp/apollo/pull/1614)。参考配置示例如下: ```properties # will inject 'application' namespace in bootstrap phase apollo.bootstrap.enabled = true # put apollo initialization before logging system initialization apollo.bootstrap.eagerLoad.enabled=true ``` #### 3.2.1.4 Spring Boot Config Data Loader (Spring Boot 2.4+, Apollo Client 1.9.0+ 推荐) 对于 Spring Boot 2.4 以上版本还支持通过 Config Data Loader 模式来加载配置 ##### 3.2.1.4.1 添加 maven 依赖 apollo-client-config-data 已经依赖了 apollo-client, 所以只需要添加这一个依赖即可, 无需再添加 apollo-client 的依赖 ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> </dependencies> ``` ##### 3.2.1.4.2 参照前述的方式配置 `app.id`, `env`, `apollo.meta`(或者 `apollo.config-service`), `apollo.cluster` ##### 3.2.1.4.3 配置 `application.properties` 或 `application.yml` 使用默认的 namespace `application` ```properties # old way # apollo.bootstrap.enabled=true # 不配置 apollo.bootstrap.namespaces # new way spring.config.import=apollo:// ``` 或者 ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=application # new way spring.config.import=apollo://application ``` 使用自定义 namespace ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=your-namespace # new way spring.config.import=apollo://your-namespace ``` 使用多个 namespaces 注: `spring.config.import` 是从后往前加载配置的, 而 `apollo.bootstrap.namespaces` 是从前往后加载的, 刚好相反。为了保证和原有逻辑一致, 请颠倒 namespaces 的顺序 ```properties # old way # apollo.bootstrap.enabled=true # apollo.bootstrap.namespaces=namespace1,namespace2,namespace3 # new way spring.config.import=apollo://namespace3, apollo://namespace2, apollo://namespace1 ``` #### 3.2.1.5 Spring Boot Config Data Loader (Spring Boot 2.4+, Apollo Client 1.9.0+ 推荐) + webClient 扩展 对于 Spring Boot 2.4 以上版本还支持通过 Config Data Loader 模式来加载配置 Apollo 的 Config Data Loader 还提供了基于 webClient 的 http 客户端来替换原有的 http 客户端, 从而方便的对 http 客户端进行扩展 ##### 3.2.1.5.1 添加 maven 依赖 webClient 可以基于多种实现 (reactor netty httpclient, jetty reactive httpclient, apache httpclient5), 所需添加的依赖如下 ###### reactor netty httpclient ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- reactor netty httpclient --> <dependency> <groupId>io.projectreactor.netty</groupId> <artifactId>reactor-netty-http</artifactId> </dependency> </dependencies> ``` ###### jetty reactive httpclient ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- jetty reactive httpclient --> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-reactive-httpclient</artifactId> </dependency> </dependencies> ``` ###### apache httpclient5 spring boot 没有指定 apache httpclient5 的版本, 所以这里需要手动指定一下版本 ```xml <dependencies> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client-config-data</artifactId> <version>1.9.0</version> </dependency> <!-- webclient --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <!-- apache httpclient5 --> <dependency> <groupId>org.apache.httpcomponents.client5</groupId> <artifactId>httpclient5</artifactId> <version>5.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents.core5</groupId> <artifactId>httpcore5-reactive</artifactId> <version>5.1</version> </dependency> </dependencies> ``` ##### 3.2.1.5.2 参照前述的方式配置 `app.id`, `env`, `apollo.meta`(或者 `apollo.config-service`), `apollo.cluster` ##### 3.2.1.5.3 配置 `application.properties` 或 `application.yml` 这里以默认 namespace 为例, namespace 的配置详见 3.2.1.4.3 ```properties spring.config.import=apollo://application apollo.client.extension.enabled=true ``` ##### 3.2.1.5.4 提供 spi 的实现 提供接口 `com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi.ApolloClientWebClientCustomizerFactory` 的 spi 实现 在配置了 `apollo.client.extension.enabled=true` 之后, Apollo 的 Config Data Loader 会尝试去加载该 spi 的实现类来定制 webClient ### 3.2.2 Spring Placeholder的使用 Spring应用通常会使用Placeholder来注入配置,使用的格式形如${someKey:someDefaultValue},如${timeout:100}。冒号前面的是key,冒号后面的是默认值。 建议在实际使用时尽量给出默认值,以免由于key没有定义导致运行时错误。 从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见[PR #972](https://github.com/ctripcorp/apollo/pull/972)。 如果需要关闭placeholder在运行时自动更新功能,可以通过以下两种方式关闭: 1. 通过设置System Property `apollo.autoUpdateInjectedSpringProperties`,如启动时传入`-Dapollo.autoUpdateInjectedSpringProperties=false` 2. 通过设置META-INF/app.properties中的`apollo.autoUpdateInjectedSpringProperties`属性,如 ```properties app.id=SampleApp apollo.autoUpdateInjectedSpringProperties=false ``` #### 3.2.2.1 XML使用方式 假设我有一个TestXmlBean,它有两个配置项需要注入: ```java public class TestXmlBean { private int timeout; private int batch; public void setTimeout(int timeout) { this.timeout = timeout; } public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } ``` 那么,我在XML中会使用如下方式来定义(假设应用默认的application namespace中有timeout和batch的配置项): ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:apollo="http://www.ctrip.com/schema/apollo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"> <apollo:config/> <bean class="com.ctrip.framework.apollo.spring.TestXmlBean"> <property name="timeout" value="${timeout:100}"/> <property name="batch" value="${batch:200}"/> </bean> </beans> ``` #### 3.2.2.2 Java Config使用方式 假设我有一个TestJavaConfigBean,通过Java Config的方式还可以使用@Value的方式注入: ```java public class TestJavaConfigBean { @Value("${timeout:100}") private int timeout; private int batch; @Value("${batch:200}") public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } ``` 在Configuration类中按照下面的方式使用(假设应用默认的application namespace中有`timeout`和`batch`的配置项): ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestJavaConfigBean javaConfigBean() { return new TestJavaConfigBean(); } } ``` #### 3.2.2.3 ConfigurationProperties使用方式 Spring Boot提供了[@ConfigurationProperties](http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/context/properties/ConfigurationProperties.html)把配置注入到bean对象中。 Apollo也支持这种方式,下面的例子会把`redis.cache.expireSeconds`和`redis.cache.commandTimeout`分别注入到SampleRedisConfig的`expireSeconds`和`commandTimeout`字段中。 ```java @ConfigurationProperties(prefix = "redis.cache") public class SampleRedisConfig { private int expireSeconds; private int commandTimeout; public void setExpireSeconds(int expireSeconds) { this.expireSeconds = expireSeconds; } public void setCommandTimeout(int commandTimeout) { this.commandTimeout = commandTimeout; } } ``` 在Configuration类中按照下面的方式使用(假设应用默认的application namespace中有`redis.cache.expireSeconds`和`redis.cache.commandTimeout`的配置项): ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public SampleRedisConfig sampleRedisConfig() { return new SampleRedisConfig(); } } ``` 需要注意的是,`@ConfigurationProperties`如果需要在Apollo配置变化时自动更新注入的值,需要配合使用[EnvironmentChangeEvent](https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_environment_changes)或[RefreshScope](https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_refresh_scope)。相关代码实现,可以参考apollo-use-cases项目中的[ZuulPropertiesRefresher.java](https://github.com/ctripcorp/apollo-use-cases/blob/master/spring-cloud-zuul/src/main/java/com/ctrip/framework/apollo/use/cases/spring/cloud/zuul/ZuulPropertiesRefresher.java#L48)和apollo-demo项目中的[SampleRedisConfig.java](https://github.com/ctripcorp/apollo/blob/master/apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/config/SampleRedisConfig.java)以及[SpringBootApolloRefreshConfig.java](https://github.com/ctripcorp/apollo/blob/master/apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/refresh/SpringBootApolloRefreshConfig.java) ### 3.2.3 Spring Annotation支持 Apollo同时还增加了几个新的Annotation来简化在Spring环境中的使用。 1. @ApolloConfig * 用来自动注入Config对象 2. @ApolloConfigChangeListener * 用来自动注册ConfigChangeListener 3. @ApolloJsonValue * 用来把配置的json字符串自动注入为对象 使用样例如下: ```java public class TestApolloAnnotationBean { @ApolloConfig private Config config; //inject config for namespace application @ApolloConfig("application") private Config anotherConfig; //inject config for namespace application @ApolloConfig("FX.apollo") private Config yetAnotherConfig; //inject config for namespace FX.apollo @ApolloConfig("application.yml") private Config ymlConfig; //inject config for namespace application.yml /** * ApolloJsonValue annotated on fields example, the default value is specified as empty list - [] * <br /> * jsonBeanProperty=[{"someString":"hello","someInt":100},{"someString":"world!","someInt":200}] */ @ApolloJsonValue("${jsonBeanProperty:[]}") private List<JsonBean> anotherJsonBeans; @Value("${batch:100}") private int batch; //config change listener for namespace application @ApolloConfigChangeListener private void someOnChange(ConfigChangeEvent changeEvent) { //update injected value of batch if it is changed in Apollo if (changeEvent.isChanged("batch")) { batch = config.getIntProperty("batch", 100); } } //config change listener for namespace application @ApolloConfigChangeListener("application") private void anotherOnChange(ConfigChangeEvent changeEvent) { //do something } //config change listener for namespaces application, FX.apollo and application.yml @ApolloConfigChangeListener({"application", "FX.apollo", "application.yml"}) private void yetAnotherOnChange(ConfigChangeEvent changeEvent) { //do something } //example of getting config from Apollo directly //this will always return the latest value of timeout public int getTimeout() { return config.getIntProperty("timeout", 200); } //example of getting config from injected value //the program needs to update the injected value when batch is changed in Apollo using @ApolloConfigChangeListener shown above public int getBatch() { return this.batch; } private static class JsonBean{ private String someString; private int someInt; } } ``` 在Configuration类中按照下面的方式使用: ```java @Configuration @EnableApolloConfig public class AppConfig { @Bean public TestApolloAnnotationBean testApolloAnnotationBean() { return new TestApolloAnnotationBean(); } } ``` ### 3.2.4 已有配置迁移 很多情况下,应用可能已经有不少配置了,比如Spring Boot的应用,就会有bootstrap.properties/yml, application.properties/yml等配置。 在应用接入Apollo之后,这些配置是可以非常方便的迁移到Apollo的,具体步骤如下: 1. 在Apollo为应用新建项目 2. 在应用中配置好META-INF/app.properties 3. 建议把原先配置先转为properties格式,然后通过Apollo提供的文本编辑模式全部粘帖到应用的application namespace,发布配置 * 如果原来格式是yml,可以使用[YamlPropertiesFactoryBean.getObject](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.html#getObject--)转成properties格式 4. 如果原来是yml,想继续使用yml来编辑配置,那么可以创建私有的application.yml namespace,把原来的配置全部粘贴进去,发布配置 * 需要apollo-client是1.3.0及以上版本 5. 把原先的配置文件如bootstrap.properties/yml, application.properties/yml从项目中删除 * 如果需要保留本地配置文件,需要注意部分配置如`server.port`必须确保本地文件已经删除该配置项 如: ```properties spring.application.name = reservation-service server.port = 8080 logging.level = ERROR eureka.client.serviceUrl.defaultZone = http://127.0.0.1:8761/eureka/ eureka.client.healthcheck.enabled = true eureka.client.registerWithEureka = true eureka.client.fetchRegistry = true eureka.client.eurekaServiceUrlPollIntervalSeconds = 60 eureka.instance.preferIpAddress = true ``` ![text-mode-spring-boot-config-sample](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/text-mode-spring-boot-config-sample.png) ## 3.3 Demo 项目中有一个样例客户端的项目:`apollo-demo`,具体信息可以参考[Apollo开发指南](zh/development/apollo-development-guide)中的[2.3 Java样例客户端启动](zh/development/apollo-development-guide?id=_23-java样例客户端启动)部分。 更多使用案例Demo可以参考[Apollo使用场景和示例代码](https://github.com/ctripcorp/apollo-use-cases)。 # 四、客户端设计 ![client-architecture](https://github.com/ctripcorp/apollo/raw/master/doc/images/client-architecture.png) 上图简要描述了Apollo客户端的实现原理: 1. 客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。(通过Http Long Polling实现) 2. 客户端还会定时从Apollo配置中心服务端拉取应用的最新配置。 * 这是一个fallback机制,为了防止推送机制失效导致配置不更新 * 客户端定时拉取会上报本地版本,所以一般情况下,对于定时拉取的操作,服务端都会返回304 - Not Modified * 定时频率默认为每5分钟拉取一次,客户端也可以通过在运行时指定System Property: `apollo.refreshInterval`来覆盖,单位为分钟。 3. 客户端从Apollo配置中心服务端获取到应用的最新配置后,会保存在内存中 4. 客户端会把从服务端获取到的配置在本地文件系统缓存一份 * 在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置 5. 应用程序可以从Apollo客户端获取最新的配置、订阅配置更新通知 # 五、本地开发模式 Apollo客户端还支持本地开发模式,这个主要用于当开发环境无法连接Apollo服务器的时候,比如在邮轮、飞机上做相关功能开发。 在本地开发模式下,Apollo只会从本地文件读取配置信息,不会从Apollo服务器读取配置。 可以通过下面的步骤开启Apollo本地开发模式。 ## 5.1 修改环境 修改/opt/settings/server.properties(Mac/Linux)或C:\opt\settings\server.properties(Windows)文件,设置env为Local: ```properties env=Local ``` 更多配置环境的方式请参考[1.2.4.1 Environment](#_1241-environment) ## 5.2 准备本地配置文件 在本地开发模式下,Apollo客户端会从本地读取文件,所以我们需要事先准备好配置文件。 ### 5.2.1 本地配置目录 本地配置目录位于: * **Mac/Linux**: /opt/data/{_appId_}/config-cache * **Windows**: C:\opt\data\\{_appId_}\config-cache appId就是应用的appId,如100004458。 请确保该目录存在,且应用程序对该目录有读权限。 **【小技巧】** 推荐的方式是先在普通模式下使用Apollo,这样Apollo会自动创建该目录并在目录下生成配置文件。 ### 5.2.2 本地配置文件 本地配置文件需要按照一定的文件名格式放置于本地配置目录下,文件名格式如下: **_{appId}+{cluster}+{namespace}.properties_** * appId就是应用自己的appId,如100004458 * cluster就是应用使用的集群,一般在本地模式下没有做过配置的话,就是default * namespace就是应用使用的配置namespace,一般是application ![client-local-cache](https://raw.githubusercontent.com/ctripcorp/apollo/master/apollo-client/doc/pic/client-local-cache.png) 文件内容以properties格式存储,比如如果有两个key,一个是request.timeout,另一个是batch,那么文件内容就是如下格式: ```properties request.timeout=2000 batch=2000 ``` ## 5.3 修改配置 在本地开发模式下,Apollo不会实时监测文件内容是否有变化,所以如果修改了配置,需要重启应用生效。 # 六、测试模式 1.1.0版本开始增加了`apollo-mockserver`,从而可以很好地支持单元测试时需要mock配置的场景,使用方法如下: ## 6.1 引入pom依赖 ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-mockserver</artifactId> <version>1.7.0</version> </dependency> ``` ## 6.2 在test的resources下放置mock的数据 文件名格式约定为`mockdata-{namespace}.properties` ![image](https://user-images.githubusercontent.com/17842829/44515526-5e0e6480-a6f5-11e8-9c3c-4ff2ec737c8d.png) ## 6.3 写测试类 更多使用demo可以参考[ApolloMockServerApiTest.java](https://github.com/ctripcorp/apollo/blob/master/apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiTest.java)和[ApolloMockServerSpringIntegrationTest.java](https://github.com/ctripcorp/apollo/blob/master/apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerSpringIntegrationTest.java)。 ```java @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = TestConfiguration.class) public class SpringIntegrationTest { // 启动apollo的mockserver @ClassRule public static EmbeddedApollo embeddedApollo = new EmbeddedApollo(); @Test @DirtiesContext // 这个注解很有必要,因为配置注入会弄脏应用上下文 public void testPropertyInject(){ assertEquals("value1", testBean.key1); assertEquals("value2", testBean.key2); } @Test @DirtiesContext public void testListenerTriggeredByAdd() throws InterruptedException, ExecutionException, TimeoutException { String otherNamespace = "othernamespace"; embeddedApollo.addOrModifyPropery(otherNamespace,"someKey","someValue"); ConfigChangeEvent changeEvent = testBean.futureData.get(5000, TimeUnit.MILLISECONDS); assertEquals(otherNamespace, changeEvent.getNamespace()); assertEquals("someValue", changeEvent.getChange("someKey").getNewValue()); } @EnableApolloConfig("application") @Configuration static class TestConfiguration{ @Bean public TestBean testBean(){ return new TestBean(); } } static class TestBean{ @Value("${key1:default}") String key1; @Value("${key2:default}") String key2; SettableFuture<ConfigChangeEvent> futureData = SettableFuture.create(); @ApolloConfigChangeListener("othernamespace") private void onChange(ConfigChangeEvent changeEvent) { futureData.set(changeEvent); } } } ```
1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultNetworkProvider.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.internals.provider; import com.ctrip.framework.foundation.internals.NetworkInterfaceManager; import com.ctrip.framework.foundation.spi.provider.NetworkProvider; import com.ctrip.framework.foundation.spi.provider.Provider; public class DefaultNetworkProvider implements NetworkProvider { @Override public String getProperty(String name, String defaultValue) { if ("host.address".equalsIgnoreCase(name)) { String val = getHostAddress(); return val == null ? defaultValue : val; } if ("host.name".equalsIgnoreCase(name)) { String val = getHostName(); return val == null ? defaultValue : val; } return defaultValue; } @Override public void initialize() { } @Override public String getHostAddress() { return NetworkInterfaceManager.INSTANCE.getLocalHostAddress(); } @Override public String getHostName() { return NetworkInterfaceManager.INSTANCE.getLocalHostName(); } @Override public Class<? extends Provider> getType() { return NetworkProvider.class; } @Override public String toString() { return "hostName [" + getHostName() + "] hostIP [" + getHostAddress() + "] (DefaultNetworkProvider)"; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.internals.provider; import com.ctrip.framework.foundation.internals.NetworkInterfaceManager; import com.ctrip.framework.foundation.spi.provider.NetworkProvider; import com.ctrip.framework.foundation.spi.provider.Provider; public class DefaultNetworkProvider implements NetworkProvider { @Override public String getProperty(String name, String defaultValue) { if ("host.address".equalsIgnoreCase(name)) { String val = getHostAddress(); return val == null ? defaultValue : val; } if ("host.name".equalsIgnoreCase(name)) { String val = getHostName(); return val == null ? defaultValue : val; } return defaultValue; } @Override public void initialize() { } @Override public String getHostAddress() { return NetworkInterfaceManager.INSTANCE.getLocalHostAddress(); } @Override public String getHostName() { return NetworkInterfaceManager.INSTANCE.getLocalHostName(); } @Override public Class<? extends Provider> getType() { return NetworkProvider.class; } @Override public String toString() { return "hostName [" + getHostName() + "] hostIP [" + getHostAddress() + "] (DefaultNetworkProvider)"; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/test/java/com/ctrip/framework/test/tools/AloneRunner.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.test.tools; import org.junit.runner.Description; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.JUnit4; import org.junit.runners.model.InitializationError; /** * @author kl (http://kailing.pub) * @since 2021/5/21 */ public class AloneRunner extends Runner { private static final String CONSTRUCTOR_ERROR_FORMAT = "Custom runner class %s should have a public constructor with signature %s(Class testClass)"; private final Runner realRunner; private final ClassLoader testCaseClassloader; public AloneRunner(Class<?> clazz) throws InitializationError { AloneWith annotation = clazz.getAnnotation( AloneWith.class); Class<? extends Runner> realClassRunnerClass = annotation == null ? JUnit4.class : annotation.value(); if (AloneRunner.class.isAssignableFrom(realClassRunnerClass)) { throw new InitializationError("Dead-loop code"); } testCaseClassloader = new AloneClassLoader(); ClassLoader backupClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(testCaseClassloader); try { Class<?> newTestCaseClass = testCaseClassloader.loadClass(clazz.getName()); Class<? extends Runner> realRunnerClass = (Class<? extends Runner>) testCaseClassloader .loadClass(realClassRunnerClass.getName()); realRunner = buildRunner(realRunnerClass, newTestCaseClass); } catch (ReflectiveOperationException e) { throw new InitializationError(e); } finally { Thread.currentThread().setContextClassLoader(backupClassLoader); } } public Description getDescription() { return realRunner.getDescription(); } public void run(RunNotifier runNotifier) { ClassLoader backupClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(testCaseClassloader); realRunner.run(runNotifier); Thread.currentThread().setContextClassLoader(backupClassLoader); } protected Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws ReflectiveOperationException, InitializationError { try { return runnerClass.getConstructor(Class.class).newInstance(testClass); } catch (NoSuchMethodException e) { String simpleName = runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.test.tools; import org.junit.runner.Description; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.JUnit4; import org.junit.runners.model.InitializationError; /** * @author kl (http://kailing.pub) * @since 2021/5/21 */ public class AloneRunner extends Runner { private static final String CONSTRUCTOR_ERROR_FORMAT = "Custom runner class %s should have a public constructor with signature %s(Class testClass)"; private final Runner realRunner; private final ClassLoader testCaseClassloader; public AloneRunner(Class<?> clazz) throws InitializationError { AloneWith annotation = clazz.getAnnotation( AloneWith.class); Class<? extends Runner> realClassRunnerClass = annotation == null ? JUnit4.class : annotation.value(); if (AloneRunner.class.isAssignableFrom(realClassRunnerClass)) { throw new InitializationError("Dead-loop code"); } testCaseClassloader = new AloneClassLoader(); ClassLoader backupClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(testCaseClassloader); try { Class<?> newTestCaseClass = testCaseClassloader.loadClass(clazz.getName()); Class<? extends Runner> realRunnerClass = (Class<? extends Runner>) testCaseClassloader .loadClass(realClassRunnerClass.getName()); realRunner = buildRunner(realRunnerClass, newTestCaseClass); } catch (ReflectiveOperationException e) { throw new InitializationError(e); } finally { Thread.currentThread().setContextClassLoader(backupClassLoader); } } public Description getDescription() { return realRunner.getDescription(); } public void run(RunNotifier runNotifier) { ClassLoader backupClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(testCaseClassloader); realRunner.run(runNotifier); Thread.currentThread().setContextClassLoader(backupClassLoader); } protected Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws ReflectiveOperationException, InitializationError { try { return runnerClass.getConstructor(Class.class).newInstance(testClass); } catch (NoSuchMethodException e) { String simpleName = runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.model; import com.ctrip.framework.apollo.enums.PropertyChangeType; /** * Holds the information for a config change. * @author Jason Song(song_s@ctrip.com) */ public class ConfigChange { private final String namespace; private final String propertyName; private String oldValue; private String newValue; private PropertyChangeType changeType; /** * Constructor. * @param namespace the namespace of the key * @param propertyName the key whose value is changed * @param oldValue the value before change * @param newValue the value after change * @param changeType the change type */ public ConfigChange(String namespace, String propertyName, String oldValue, String newValue, PropertyChangeType changeType) { this.namespace = namespace; this.propertyName = propertyName; this.oldValue = oldValue; this.newValue = newValue; this.changeType = changeType; } public String getPropertyName() { return propertyName; } public String getOldValue() { return oldValue; } public String getNewValue() { return newValue; } public PropertyChangeType getChangeType() { return changeType; } public void setOldValue(String oldValue) { this.oldValue = oldValue; } public void setNewValue(String newValue) { this.newValue = newValue; } public void setChangeType(PropertyChangeType changeType) { this.changeType = changeType; } public String getNamespace() { return namespace; } @Override public String toString() { final StringBuilder sb = new StringBuilder("ConfigChange{"); sb.append("namespace='").append(namespace).append('\''); sb.append(", propertyName='").append(propertyName).append('\''); sb.append(", oldValue='").append(oldValue).append('\''); sb.append(", newValue='").append(newValue).append('\''); sb.append(", changeType=").append(changeType); sb.append('}'); return sb.toString(); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.model; import com.ctrip.framework.apollo.enums.PropertyChangeType; /** * Holds the information for a config change. * @author Jason Song(song_s@ctrip.com) */ public class ConfigChange { private final String namespace; private final String propertyName; private String oldValue; private String newValue; private PropertyChangeType changeType; /** * Constructor. * @param namespace the namespace of the key * @param propertyName the key whose value is changed * @param oldValue the value before change * @param newValue the value after change * @param changeType the change type */ public ConfigChange(String namespace, String propertyName, String oldValue, String newValue, PropertyChangeType changeType) { this.namespace = namespace; this.propertyName = propertyName; this.oldValue = oldValue; this.newValue = newValue; this.changeType = changeType; } public String getPropertyName() { return propertyName; } public String getOldValue() { return oldValue; } public String getNewValue() { return newValue; } public PropertyChangeType getChangeType() { return changeType; } public void setOldValue(String oldValue) { this.oldValue = oldValue; } public void setNewValue(String newValue) { this.newValue = newValue; } public void setChangeType(PropertyChangeType changeType) { this.changeType = changeType; } public String getNamespace() { return namespace; } @Override public String toString() { final StringBuilder sb = new StringBuilder("ConfigChange{"); sb.append("namespace='").append(namespace).append('\''); sb.append(", propertyName='").append(propertyName).append('\''); sb.append(", oldValue='").append(oldValue).append('\''); sb.append(", newValue='").append(newValue).append('\''); sb.append(", changeType=").append(changeType); sb.append('}'); return sb.toString(); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.utils.BeanUtils; 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 java.util.Objects; import javax.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; /** * 配置中心本身需要一些配置,这些配置放在数据库里面 */ @RestController public class ServerConfigController { private final ServerConfigRepository serverConfigRepository; private final UserInfoHolder userInfoHolder; public ServerConfigController(final ServerConfigRepository serverConfigRepository, final UserInfoHolder userInfoHolder) { this.serverConfigRepository = serverConfigRepository; this.userInfoHolder = userInfoHolder; } @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/server/config") public ServerConfig createOrUpdate(@Valid @RequestBody ServerConfig serverConfig) { String modifiedBy = userInfoHolder.getUser().getUserId(); ServerConfig storedConfig = serverConfigRepository.findByKey(serverConfig.getKey()); if (Objects.isNull(storedConfig)) {//create serverConfig.setDataChangeCreatedBy(modifiedBy); serverConfig.setDataChangeLastModifiedBy(modifiedBy); serverConfig.setId(0L);//为空,设置ID 为0,jpa执行新增操作 return serverConfigRepository.save(serverConfig); } //update BeanUtils.copyEntityProperties(serverConfig, storedConfig); storedConfig.setDataChangeLastModifiedBy(modifiedBy); return serverConfigRepository.save(storedConfig); } @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @GetMapping("/server/config/{key:.+}") public ServerConfig loadServerConfig(@PathVariable String key) { return serverConfigRepository.findByKey(key); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.utils.BeanUtils; 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 java.util.Objects; import javax.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; /** * 配置中心本身需要一些配置,这些配置放在数据库里面 */ @RestController public class ServerConfigController { private final ServerConfigRepository serverConfigRepository; private final UserInfoHolder userInfoHolder; public ServerConfigController(final ServerConfigRepository serverConfigRepository, final UserInfoHolder userInfoHolder) { this.serverConfigRepository = serverConfigRepository; this.userInfoHolder = userInfoHolder; } @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/server/config") public ServerConfig createOrUpdate(@Valid @RequestBody ServerConfig serverConfig) { String modifiedBy = userInfoHolder.getUser().getUserId(); ServerConfig storedConfig = serverConfigRepository.findByKey(serverConfig.getKey()); if (Objects.isNull(storedConfig)) {//create serverConfig.setDataChangeCreatedBy(modifiedBy); serverConfig.setDataChangeLastModifiedBy(modifiedBy); serverConfig.setId(0L);//为空,设置ID 为0,jpa执行新增操作 return serverConfigRepository.save(serverConfig); } //update BeanUtils.copyEntityProperties(serverConfig, storedConfig); storedConfig.setDataChangeLastModifiedBy(modifiedBy); return serverConfigRepository.save(storedConfig); } @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @GetMapping("/server/config/{key:.+}") public ServerConfig loadServerConfig(@PathVariable String key) { return serverConfigRepository.findByKey(key); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/customize/package-info.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * 携程内部的日志系统,第三方公司可删除 */ package com.ctrip.framework.apollo.biz.customize;
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * 携程内部的日志系统,第三方公司可删除 */ package com.ctrip.framework.apollo.biz.customize;
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/zh/usage/apollo-open-api-platform.md
### 一、 什么是开放平台? Apollo提供了一套的Http REST接口,使第三方应用能够自己管理配置。虽然Apollo系统本身提供了Portal来管理配置,但是在有些情景下,应用需要通过程序去管理配置。 ### 二、 第三方应用接入Apollo开放平台 #### 2.1 注册第三方应用 第三方应用负责人需要向Apollo管理员提供一些第三方应用基本信息。 基本信息如下: * 第三方应用的AppId、应用名、部门 * 第三方应用负责人 Apollo管理员在 http://{portal_address}/open/manage.html 创建第三方应用,创建之前最好先查询此AppId是否已经创建。创建成功之后会生成一个token,如下图所示: ![开放平台管理](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-open-manage.png) #### 2.2 给已注册的第三方应用授权 第三方应用不应该能操作任何Namespace的配置,所以需要给token绑定可以操作的Namespace。Apollo管理员在 http://{portal_address}/open/manage.html 页面给token赋权。赋权之后,第三方应用就可以通过Apollo提供的Http REST接口来管理已授权的Namespace的配置了。 #### 2.3 第三方应用调用Apollo Open API ##### 2.3.1 调用Http REST接口 任何语言的第三方应用都可以调用Apollo的Open API,在调用接口时,需要设置注意以下两点: * Http Header中增加一个Authorization字段,字段值为申请的token * Http Header的Content-Type字段需要设置成application/json;charset=UTF-8 ##### 2.3.2 Java应用通过apollo-openapi调用Apollo Open API 从1.1.0版本开始,Apollo提供了[apollo-openapi](https://github.com/ctripcorp/apollo/tree/master/apollo-openapi)客户端,所以Java语言的第三方应用可以更方便地调用Apollo Open API。 首先引入`apollo-openapi`依赖: ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-openapi</artifactId> <version>1.7.0</version> </dependency> ``` 在程序中构造`ApolloOpenApiClient`: ```java String portalUrl = "http://localhost:8070"; // portal url String token = "e16e5cd903fd0c97a116c873b448544b9d086de9"; // 申请的token ApolloOpenApiClient client = ApolloOpenApiClient.newBuilder() .withPortalUrl(portalUrl) .withToken(token) .build(); ``` 后续就可以通过`ApolloOpenApiClient`的接口直接操作Apollo Open API了,接口说明参见下面的Rest接口文档。 ##### 2.3.3 .Net core应用调用Apollo Open API .Net core也提供了open api的客户端,详见https://github.com/ctripcorp/apollo.net/pull/77 ### 三、 接口文档 #### 3.1 URL路径参数说明 参数名 | 参数说明 --- | --- env | 所管理的配置环境 appId | 所管理的配置AppId clusterName | 所管理的配置集群名, 一般情况下传入 default 即可。如果是特殊集群,传入相应集群的名称即可 namespaceName | 所管理的Namespace的名称,如果是非properties格式,需要加上后缀名,如`sample.yml` #### 3.2 API接口列表 ##### 3.2.1 获取App的环境,集群信息 * **URL** : http://{portal_address}/openapi/v1/apps/{appId}/envclusters * **Method** : GET * **Request Params** : 无 * **返回值Sample**: ``` json [ { "env":"FAT", "clusters":[ //集群列表 "default", "FAT381" ] }, { "env":"UAT", "clusters":[ "default" ] }, { "env":"PRO", "clusters":[ "default", "SHAOY", "SHAJQ" ] } ] ``` ##### 3.2.2 获取App信息 * **URL** : http://{portal_address}/openapi/v1/apps * **Method** : GET * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- appIds | false | String | appId列表,以逗号分隔,如果为空则返回所有App信息 * **返回值Sample**: ``` json [ { "name":"first_app", "appId":"100003171", "orgId":"development", "orgName":"研发部", "ownerName":"apollo", "ownerEmail":"test@test.com", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2019-05-08T09:13:31.000+0800", "dataChangeLastModifiedTime":"2019-05-08T09:13:31.000+0800" }, { "name":"apollo-demo", "appId":"100004458", "orgId":"development", "orgName":"产品研发部", "ownerName":"apollo", "ownerEmail":"apollo@cmcm.com", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2019-04-08T13:58:36.000+0800" } ] ``` ##### 3.2.3 获取集群接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName} * **Method** : GET * **Request Params** :无 * **返回值Sample**: ``` json { "name":"default", "appId":"100004458", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2018-12-23T12:35:16.000+0800" } ``` ##### 3.2.4 创建集群接口 可以通过此接口创建集群,调用此接口需要授予第三方APP对目标APP的管理权限。 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- name | true | String | Cluster的名字 appId | true | String | Cluster所属的AppId dataChangeCreatedBy | true | String | namespace的创建人,格式为域账号,也就是sso系统的User ID * **返回值 Sample** : ``` json { "name":"someClusterName", "appId":"100004458", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2018-12-23T12:35:16.000+0800" } ``` ##### 3.2.5 获取集群下所有Namespace信息接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces * **Method**: GET * **Request Params**: 无 * **返回值Sample**: ``` json [ { "appId": "100003171", "clusterName": "default", "namespaceName": "application", "comment": "default app namespace", "format": "properties", //Namespace格式可能取值为:properties、xml、json、yml、yaml "isPublic": false, //是否为公共的Namespace "items": [ // Namespace下所有的配置集合 { "key": "batch", "value": "100", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-21T16:03:43.000+0800", "dataChangeLastModifiedTime": "2016-07-21T16:03:43.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:05:58.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:05:58.000+0800" }, { "appId": "100003171", "clusterName": "default", "namespaceName": "FX.apollo", "comment": "apollo public namespace", "format": "properties", "isPublic": true, "items": [ { "key": "request.timeout", "value": "3000", "comment": "", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:08:30.000+0800", "dataChangeLastModifiedTime": "2016-08-01T13:56:25.000+0800" }, { "id": 1116, "key": "batch", "value": "3000", "comment": "", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-28T15:13:42.000+0800", "dataChangeLastModifiedTime": "2016-08-01T13:51:00.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:08:13.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:08:13.000+0800" } ] ``` ##### 3.2.6 获取某个Namespace信息接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName} * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "appId": "100003171", "clusterName": "default", "namespaceName": "application", "comment": "default app namespace", "format": "properties", //Namespace格式可能取值为:properties、xml、json、yml、yaml "isPublic": false, //是否为公共的Namespace "items": [ // Namespace下所有的配置集合 { "key": "batch", "value": "100", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-21T16:03:43.000+0800", "dataChangeLastModifiedTime": "2016-07-21T16:03:43.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:05:58.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:05:58.000+0800" } ``` ##### 3.2.7 创建Namespace 可以通过此接口创建Namespace,调用此接口需要授予第三方APP对目标APP的管理权限。 * **URL** : http://{portal_address}/openapi/v1/apps/{appId}/appnamespaces * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- name | true | String | Namespace的名字 appId | true | String | Namespace所属的AppId format |true | String | Namespace的格式,**只能是以下类型: properties、xml、json、yml、yaml** isPublic |true | boolean | 是否是公共文件 comment |false | String | Namespace说明 dataChangeCreatedBy | true | String | namespace的创建人,格式为域账号,也就是sso系统的User ID * **返回值 Sample** : ``` json { "name": "FX.public-0420-11", "appId": "100003173", "format": "properties", "isPublic": true, "comment": "test", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2017-04-20T18:25:49.033+0800", "dataChangeLastModifiedTime": "2017-04-20T18:25:49.033+0800" } ``` * **返回值说明** : > 如果是properties文件,name = ${appId所属的部门}.${传入的name值} ,例如调用接口传入的name=xy-z, format=properties,应用的部门为框架(FX),那么name=FX.xy-z > 如果不是properties文件 name = ${appId所属的部门}.${传入的name值}.${format},例如调用接口传入的name=xy-z, format=json,应用的部门为框架(FX),那么name=FX.xy-z.json ##### 3.2.8 获取某个Namespace当前编辑人接口 Apollo在生产环境(PRO)有限制规则:每次发布只能有一个人编辑配置,且该次发布的人不能是该次发布的编辑人。 也就是说如果一个用户A修改了某个namespace的配置,那么在这个namespace发布前,只能由A修改,其它用户无法修改。同时,该用户A无法发布自己修改的配置,必须找另一个有发布权限的人操作。 这个接口就是用来获取当前namespace是否有人锁定的接口。在非生产环境(FAT、UAT),该接口始终返回没有人锁定。 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock * **Method** : GET * **Request Params** :无 * **返回值 Sample(未锁定)** : ``` json { "namespaceName": "application", "isLocked": false } ``` * **返回值Sample(被锁定)** : ``` json { "namespaceName": "application", "isLocked": true, "lockedBy": "song_s" //锁owner } ``` ##### 3.2.9 读取配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key} * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "key": "timeout", "value": "3000", "comment": "超时时间", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T12:06:41.818+0800", "dataChangeLastModifiedTime": "2016-08-11T12:06:41.818+0800" } ``` ##### 3.2.10 新增配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- key | true | String | 配置的key,长度不能超过128个字符。非properties格式,key固定为`content` value | true | String | 配置的value,长度不能超过20000个字符,非properties格式,value为文件全部内容 comment | false | String | 配置的备注,长度不能超过256个字符 dataChangeCreatedBy | true | String | item的创建人,格式为域账号,也就是sso系统的User ID * **Request body sample** : ``` json { "key":"timeout", "value":"3000", "comment":"超时时间", "dataChangeCreatedBy":"zhanglea" } ``` * **返回值Sample** : ``` json { "key": "timeout", "value": "3000", "comment": "超时时间", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T12:06:41.818+0800", "dataChangeLastModifiedTime": "2016-08-11T12:06:41.818+0800" } ``` ##### 3.2.11 修改配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key} * **Method** : PUT * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- createIfNotExists | false | Boolean | 当配置不存在时是否自动创建 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- key | true | String | 配置的key,需和url中的key值一致。非properties格式,key固定为`content` value | true | String | 配置的value,长度不能超过20000个字符,非properties格式,value为文件全部内容 comment | false | String | 配置的备注,长度不能超过256个字符 dataChangeLastModifiedBy | true | String | item的修改人,格式为域账号,也就是sso系统的User ID dataChangeCreatedBy | false | String | 当createIfNotExists为true时必选。item的创建人,格式为域账号,也就是sso系统的User ID * **Request body sample** : ```json { "key":"timeout", "value":"3000", "comment":"超时时间", "dataChangeLastModifiedBy":"zhanglea" } ``` * **返回值** :无 ##### 3.2.12 删除配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}?operator={operator} * **Method** : DELETE * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- key | true | String | 配置的key。非properties格式,key固定为`content` operator | true | String | 删除配置的操作者,域账号 * **返回值** : 无 ##### 3.2.13 发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases * **Method** : POST * **Request Params** :无 * **Request Body** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- releaseTitle | true | String | 此次发布的标题,长度不能超过64个字符 releaseComment | false | String | 发布的备注,长度不能超过256个字符 releasedBy | true | String | 发布人,域账号,注意:如果`ApolloConfigDB.ServerConfig`中的`namespace.lock.switch`设置为true的话(默认是false),那么该环境不允许发布人和编辑人为同一人。所以如果编辑人是zhanglea,发布人就不能再是zhanglea。 * **Request Body example** : ```json { "releaseTitle":"2016-08-11", "releaseComment":"修改timeout值", "releasedBy":"zhanglea" } ``` * **返回值Sample** : ``` json { "appId": "test-0620-01", "clusterName": "test", "namespaceName": "application", "name": "2016-08-11", "configurations": { "timeout": "3000", }, "comment": "修改timeout值", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T14:03:46.232+0800", "dataChangeLastModifiedTime": "2016-08-11T14:03:46.235+0800" } ``` ##### 3.2.14 获取某个Namespace当前生效的已发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "appId": "test-0620-01", "clusterName": "test", "namespaceName": "application", "name": "2016-08-11", "configurations": { "timeout": "3000", }, "comment": "修改timeout值", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T14:03:46.232+0800", "dataChangeLastModifiedTime": "2016-08-11T14:03:46.235+0800" } ``` ##### 3.2.15 回滚已发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/releases/{releaseId}/rollback * **Method** : PUT * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- operator | true | String | 删除配置的操作者,域账号 * **返回值** : 无 ### 四、错误码说明 正常情况下,接口返回的Http状态码是200,下面列举了Apollo会返回的非200错误码说明。 #### 4.1 400 - Bad Request 客户端传入参数的错误,如操作人不存在,namespace不存在等等,客户端需要根据提示信息检查对应的参数是否正确。 #### 4.2 401 - Unauthorized 接口传入的token非法或者已过期,客户端需要检查token是否传入正确。 #### 4.3 403 - Forbidden 接口要访问的资源未得到授权,比如只授权了对A应用下Namespace的管理权限,但是却尝试管理B应用下的配置。 #### 4.4 404 - Not Found 接口要访问的资源不存在,一般是URL或URL的参数错误。 #### 4.5 405 - Method Not Allowed 接口访问的Method不正确,比如应该使用POST的接口使用了GET访问等,客户端需要检查接口访问方式是否正确。 #### 4.6 500 - Internal Server Error 其它类型的错误默认都会返回500,对这类错误如果应用无法根据提示信息找到原因的话,可以找Apollo研发团队一起排查问题。
### 一、 什么是开放平台? Apollo提供了一套的Http REST接口,使第三方应用能够自己管理配置。虽然Apollo系统本身提供了Portal来管理配置,但是在有些情景下,应用需要通过程序去管理配置。 ### 二、 第三方应用接入Apollo开放平台 #### 2.1 注册第三方应用 第三方应用负责人需要向Apollo管理员提供一些第三方应用基本信息。 基本信息如下: * 第三方应用的AppId、应用名、部门 * 第三方应用负责人 Apollo管理员在 http://{portal_address}/open/manage.html 创建第三方应用,创建之前最好先查询此AppId是否已经创建。创建成功之后会生成一个token,如下图所示: ![开放平台管理](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-open-manage.png) #### 2.2 给已注册的第三方应用授权 第三方应用不应该能操作任何Namespace的配置,所以需要给token绑定可以操作的Namespace。Apollo管理员在 http://{portal_address}/open/manage.html 页面给token赋权。赋权之后,第三方应用就可以通过Apollo提供的Http REST接口来管理已授权的Namespace的配置了。 #### 2.3 第三方应用调用Apollo Open API ##### 2.3.1 调用Http REST接口 任何语言的第三方应用都可以调用Apollo的Open API,在调用接口时,需要设置注意以下两点: * Http Header中增加一个Authorization字段,字段值为申请的token * Http Header的Content-Type字段需要设置成application/json;charset=UTF-8 ##### 2.3.2 Java应用通过apollo-openapi调用Apollo Open API 从1.1.0版本开始,Apollo提供了[apollo-openapi](https://github.com/ctripcorp/apollo/tree/master/apollo-openapi)客户端,所以Java语言的第三方应用可以更方便地调用Apollo Open API。 首先引入`apollo-openapi`依赖: ```xml <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-openapi</artifactId> <version>1.7.0</version> </dependency> ``` 在程序中构造`ApolloOpenApiClient`: ```java String portalUrl = "http://localhost:8070"; // portal url String token = "e16e5cd903fd0c97a116c873b448544b9d086de9"; // 申请的token ApolloOpenApiClient client = ApolloOpenApiClient.newBuilder() .withPortalUrl(portalUrl) .withToken(token) .build(); ``` 后续就可以通过`ApolloOpenApiClient`的接口直接操作Apollo Open API了,接口说明参见下面的Rest接口文档。 ##### 2.3.3 .Net core应用调用Apollo Open API .Net core也提供了open api的客户端,详见https://github.com/ctripcorp/apollo.net/pull/77 ### 三、 接口文档 #### 3.1 URL路径参数说明 参数名 | 参数说明 --- | --- env | 所管理的配置环境 appId | 所管理的配置AppId clusterName | 所管理的配置集群名, 一般情况下传入 default 即可。如果是特殊集群,传入相应集群的名称即可 namespaceName | 所管理的Namespace的名称,如果是非properties格式,需要加上后缀名,如`sample.yml` #### 3.2 API接口列表 ##### 3.2.1 获取App的环境,集群信息 * **URL** : http://{portal_address}/openapi/v1/apps/{appId}/envclusters * **Method** : GET * **Request Params** : 无 * **返回值Sample**: ``` json [ { "env":"FAT", "clusters":[ //集群列表 "default", "FAT381" ] }, { "env":"UAT", "clusters":[ "default" ] }, { "env":"PRO", "clusters":[ "default", "SHAOY", "SHAJQ" ] } ] ``` ##### 3.2.2 获取App信息 * **URL** : http://{portal_address}/openapi/v1/apps * **Method** : GET * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- appIds | false | String | appId列表,以逗号分隔,如果为空则返回所有App信息 * **返回值Sample**: ``` json [ { "name":"first_app", "appId":"100003171", "orgId":"development", "orgName":"研发部", "ownerName":"apollo", "ownerEmail":"test@test.com", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2019-05-08T09:13:31.000+0800", "dataChangeLastModifiedTime":"2019-05-08T09:13:31.000+0800" }, { "name":"apollo-demo", "appId":"100004458", "orgId":"development", "orgName":"产品研发部", "ownerName":"apollo", "ownerEmail":"apollo@cmcm.com", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2019-04-08T13:58:36.000+0800" } ] ``` ##### 3.2.3 获取集群接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName} * **Method** : GET * **Request Params** :无 * **返回值Sample**: ``` json { "name":"default", "appId":"100004458", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2018-12-23T12:35:16.000+0800" } ``` ##### 3.2.4 创建集群接口 可以通过此接口创建集群,调用此接口需要授予第三方APP对目标APP的管理权限。 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- name | true | String | Cluster的名字 appId | true | String | Cluster所属的AppId dataChangeCreatedBy | true | String | namespace的创建人,格式为域账号,也就是sso系统的User ID * **返回值 Sample** : ``` json { "name":"someClusterName", "appId":"100004458", "dataChangeCreatedBy":"apollo", "dataChangeLastModifiedBy":"apollo", "dataChangeCreatedTime":"2018-12-23T12:35:16.000+0800", "dataChangeLastModifiedTime":"2018-12-23T12:35:16.000+0800" } ``` ##### 3.2.5 获取集群下所有Namespace信息接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces * **Method**: GET * **Request Params**: 无 * **返回值Sample**: ``` json [ { "appId": "100003171", "clusterName": "default", "namespaceName": "application", "comment": "default app namespace", "format": "properties", //Namespace格式可能取值为:properties、xml、json、yml、yaml "isPublic": false, //是否为公共的Namespace "items": [ // Namespace下所有的配置集合 { "key": "batch", "value": "100", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-21T16:03:43.000+0800", "dataChangeLastModifiedTime": "2016-07-21T16:03:43.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:05:58.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:05:58.000+0800" }, { "appId": "100003171", "clusterName": "default", "namespaceName": "FX.apollo", "comment": "apollo public namespace", "format": "properties", "isPublic": true, "items": [ { "key": "request.timeout", "value": "3000", "comment": "", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:08:30.000+0800", "dataChangeLastModifiedTime": "2016-08-01T13:56:25.000+0800" }, { "id": 1116, "key": "batch", "value": "3000", "comment": "", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-28T15:13:42.000+0800", "dataChangeLastModifiedTime": "2016-08-01T13:51:00.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:08:13.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:08:13.000+0800" } ] ``` ##### 3.2.6 获取某个Namespace信息接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName} * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "appId": "100003171", "clusterName": "default", "namespaceName": "application", "comment": "default app namespace", "format": "properties", //Namespace格式可能取值为:properties、xml、json、yml、yaml "isPublic": false, //是否为公共的Namespace "items": [ // Namespace下所有的配置集合 { "key": "batch", "value": "100", "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-21T16:03:43.000+0800", "dataChangeLastModifiedTime": "2016-07-21T16:03:43.000+0800" } ], "dataChangeCreatedBy": "song_s", "dataChangeLastModifiedBy": "song_s", "dataChangeCreatedTime": "2016-07-20T14:05:58.000+0800", "dataChangeLastModifiedTime": "2016-07-20T14:05:58.000+0800" } ``` ##### 3.2.7 创建Namespace 可以通过此接口创建Namespace,调用此接口需要授予第三方APP对目标APP的管理权限。 * **URL** : http://{portal_address}/openapi/v1/apps/{appId}/appnamespaces * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- name | true | String | Namespace的名字 appId | true | String | Namespace所属的AppId format |true | String | Namespace的格式,**只能是以下类型: properties、xml、json、yml、yaml** isPublic |true | boolean | 是否是公共文件 comment |false | String | Namespace说明 dataChangeCreatedBy | true | String | namespace的创建人,格式为域账号,也就是sso系统的User ID * **返回值 Sample** : ``` json { "name": "FX.public-0420-11", "appId": "100003173", "format": "properties", "isPublic": true, "comment": "test", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2017-04-20T18:25:49.033+0800", "dataChangeLastModifiedTime": "2017-04-20T18:25:49.033+0800" } ``` * **返回值说明** : > 如果是properties文件,name = ${appId所属的部门}.${传入的name值} ,例如调用接口传入的name=xy-z, format=properties,应用的部门为框架(FX),那么name=FX.xy-z > 如果不是properties文件 name = ${appId所属的部门}.${传入的name值}.${format},例如调用接口传入的name=xy-z, format=json,应用的部门为框架(FX),那么name=FX.xy-z.json ##### 3.2.8 获取某个Namespace当前编辑人接口 Apollo在生产环境(PRO)有限制规则:每次发布只能有一个人编辑配置,且该次发布的人不能是该次发布的编辑人。 也就是说如果一个用户A修改了某个namespace的配置,那么在这个namespace发布前,只能由A修改,其它用户无法修改。同时,该用户A无法发布自己修改的配置,必须找另一个有发布权限的人操作。 这个接口就是用来获取当前namespace是否有人锁定的接口。在非生产环境(FAT、UAT),该接口始终返回没有人锁定。 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock * **Method** : GET * **Request Params** :无 * **返回值 Sample(未锁定)** : ``` json { "namespaceName": "application", "isLocked": false } ``` * **返回值Sample(被锁定)** : ``` json { "namespaceName": "application", "isLocked": true, "lockedBy": "song_s" //锁owner } ``` ##### 3.2.9 读取配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key} * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "key": "timeout", "value": "3000", "comment": "超时时间", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T12:06:41.818+0800", "dataChangeLastModifiedTime": "2016-08-11T12:06:41.818+0800" } ``` ##### 3.2.10 新增配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items * **Method** : POST * **Request Params** :无 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- key | true | String | 配置的key,长度不能超过128个字符。非properties格式,key固定为`content` value | true | String | 配置的value,长度不能超过20000个字符,非properties格式,value为文件全部内容 comment | false | String | 配置的备注,长度不能超过256个字符 dataChangeCreatedBy | true | String | item的创建人,格式为域账号,也就是sso系统的User ID * **Request body sample** : ``` json { "key":"timeout", "value":"3000", "comment":"超时时间", "dataChangeCreatedBy":"zhanglea" } ``` * **返回值Sample** : ``` json { "key": "timeout", "value": "3000", "comment": "超时时间", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T12:06:41.818+0800", "dataChangeLastModifiedTime": "2016-08-11T12:06:41.818+0800" } ``` ##### 3.2.11 修改配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key} * **Method** : PUT * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- createIfNotExists | false | Boolean | 当配置不存在时是否自动创建 * **请求内容(Request Body, JSON格式)** : 参数名 | 必选 | 类型 | 说明 ---- | --- | --- | --- key | true | String | 配置的key,需和url中的key值一致。非properties格式,key固定为`content` value | true | String | 配置的value,长度不能超过20000个字符,非properties格式,value为文件全部内容 comment | false | String | 配置的备注,长度不能超过256个字符 dataChangeLastModifiedBy | true | String | item的修改人,格式为域账号,也就是sso系统的User ID dataChangeCreatedBy | false | String | 当createIfNotExists为true时必选。item的创建人,格式为域账号,也就是sso系统的User ID * **Request body sample** : ```json { "key":"timeout", "value":"3000", "comment":"超时时间", "dataChangeLastModifiedBy":"zhanglea" } ``` * **返回值** :无 ##### 3.2.12 删除配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}?operator={operator} * **Method** : DELETE * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- key | true | String | 配置的key。非properties格式,key固定为`content` operator | true | String | 删除配置的操作者,域账号 * **返回值** : 无 ##### 3.2.13 发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases * **Method** : POST * **Request Params** :无 * **Request Body** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- releaseTitle | true | String | 此次发布的标题,长度不能超过64个字符 releaseComment | false | String | 发布的备注,长度不能超过256个字符 releasedBy | true | String | 发布人,域账号,注意:如果`ApolloConfigDB.ServerConfig`中的`namespace.lock.switch`设置为true的话(默认是false),那么该环境不允许发布人和编辑人为同一人。所以如果编辑人是zhanglea,发布人就不能再是zhanglea。 * **Request Body example** : ```json { "releaseTitle":"2016-08-11", "releaseComment":"修改timeout值", "releasedBy":"zhanglea" } ``` * **返回值Sample** : ``` json { "appId": "test-0620-01", "clusterName": "test", "namespaceName": "application", "name": "2016-08-11", "configurations": { "timeout": "3000", }, "comment": "修改timeout值", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T14:03:46.232+0800", "dataChangeLastModifiedTime": "2016-08-11T14:03:46.235+0800" } ``` ##### 3.2.14 获取某个Namespace当前生效的已发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest * **Method** : GET * **Request Params** :无 * **返回值Sample** : ``` json { "appId": "test-0620-01", "clusterName": "test", "namespaceName": "application", "name": "2016-08-11", "configurations": { "timeout": "3000", }, "comment": "修改timeout值", "dataChangeCreatedBy": "zhanglea", "dataChangeLastModifiedBy": "zhanglea", "dataChangeCreatedTime": "2016-08-11T14:03:46.232+0800", "dataChangeLastModifiedTime": "2016-08-11T14:03:46.235+0800" } ``` ##### 3.2.15 回滚已发布配置接口 * **URL** : http://{portal_address}/openapi/v1/envs/{env}/releases/{releaseId}/rollback * **Method** : PUT * **Request Params** : 参数名 | 必选 | 类型 | 说明 --- | --- | --- | --- operator | true | String | 删除配置的操作者,域账号 * **返回值** : 无 ### 四、错误码说明 正常情况下,接口返回的Http状态码是200,下面列举了Apollo会返回的非200错误码说明。 #### 4.1 400 - Bad Request 客户端传入参数的错误,如操作人不存在,namespace不存在等等,客户端需要根据提示信息检查对应的参数是否正确。 #### 4.2 401 - Unauthorized 接口传入的token非法或者已过期,客户端需要检查token是否传入正确。 #### 4.3 403 - Forbidden 接口要访问的资源未得到授权,比如只授权了对A应用下Namespace的管理权限,但是却尝试管理B应用下的配置。 #### 4.4 404 - Not Found 接口要访问的资源不存在,一般是URL或URL的参数错误。 #### 4.5 405 - Method Not Allowed 接口访问的Method不正确,比如应该使用POST的接口使用了GET访问等,客户端需要检查接口访问方式是否正确。 #### 4.6 500 - Internal Server Error 其它类型的错误默认都会返回500,对这类错误如果应用无法根据提示信息找到原因的话,可以找Apollo研发团队一起排查问题。
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.portal.component.PermissionValidator; import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.util.ConfigFileUtils; import com.ctrip.framework.apollo.portal.util.ConfigToFileUtils; import java.io.IOException; import java.io.InputStream; import java.security.AccessControlException; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; /** * @author wxq */ @Service public class ConfigsImportService { private final ItemService itemService; private final NamespaceService namespaceService; private final PermissionValidator permissionValidator; public ConfigsImportService( final ItemService itemService, final @Lazy NamespaceService namespaceService, PermissionValidator permissionValidator) { this.itemService = itemService; this.namespaceService = namespaceService; this.permissionValidator = permissionValidator; } /** * move from {@link com.ctrip.framework.apollo.portal.controller.ConfigsImportController} */ private void importConfig( final String appId, final String env, final String clusterName, final String namespaceName, final long namespaceId, final String format, final String configText ) { final NamespaceTextModel model = new NamespaceTextModel(); model.setAppId(appId); model.setEnv(env); model.setClusterName(clusterName); model.setNamespaceName(namespaceName); model.setNamespaceId(namespaceId); model.setFormat(format); model.setConfigText(configText); itemService.updateConfigItemByText(model); } /** * import one config from file */ private void importOneConfigFromFile( final String appId, final String env, final String clusterName, final String namespaceName, final String configText, final String format ) { final NamespaceDTO namespaceDTO = namespaceService .loadNamespaceBaseInfo(appId, Env.valueOf(env), clusterName, namespaceName); this.importConfig(appId, env, clusterName, namespaceName, namespaceDTO.getId(), format, configText); } /** * import a config file. * the name of config file must be special like * appId+cluster+namespace.format * Example: * <pre> * 123456+default+application.properties (appId is 123456, cluster is default, namespace is application, format is properties) * 654321+north+password.yml (appId is 654321, cluster is north, namespace is password, format is yml) * </pre> * so we can get the information of appId, cluster, namespace, format from the file name. * @param env environment * @param standardFilename appId+cluster+namespace.format * @param configText config content */ private void importOneConfigFromText( final String env, final String standardFilename, final String configText ) { final String appId = ConfigFileUtils.getAppId(standardFilename); final String clusterName = ConfigFileUtils.getClusterName(standardFilename); final String namespace = ConfigFileUtils.getNamespace(standardFilename); final String format = ConfigFileUtils.getFormat(standardFilename); this.importOneConfigFromFile(appId, env, clusterName, namespace, configText, format); } /** * @see ConfigsImportService#importOneConfigFromText(java.lang.String, java.lang.String, java.lang.String) * @throws AccessControlException if has no modify namespace permission */ public void importOneConfigFromFile( final String env, final String standardFilename, final InputStream inputStream ) { final String configText; try(InputStream in = inputStream) { configText = ConfigToFileUtils.fileToString(in); } catch (IOException e) { throw new ServiceException("Read config file errors:{}", e); } this.importOneConfigFromText(env, standardFilename, configText); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.portal.component.PermissionValidator; import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.util.ConfigFileUtils; import com.ctrip.framework.apollo.portal.util.ConfigToFileUtils; import java.io.IOException; import java.io.InputStream; import java.security.AccessControlException; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; /** * @author wxq */ @Service public class ConfigsImportService { private final ItemService itemService; private final NamespaceService namespaceService; private final PermissionValidator permissionValidator; public ConfigsImportService( final ItemService itemService, final @Lazy NamespaceService namespaceService, PermissionValidator permissionValidator) { this.itemService = itemService; this.namespaceService = namespaceService; this.permissionValidator = permissionValidator; } /** * move from {@link com.ctrip.framework.apollo.portal.controller.ConfigsImportController} */ private void importConfig( final String appId, final String env, final String clusterName, final String namespaceName, final long namespaceId, final String format, final String configText ) { final NamespaceTextModel model = new NamespaceTextModel(); model.setAppId(appId); model.setEnv(env); model.setClusterName(clusterName); model.setNamespaceName(namespaceName); model.setNamespaceId(namespaceId); model.setFormat(format); model.setConfigText(configText); itemService.updateConfigItemByText(model); } /** * import one config from file */ private void importOneConfigFromFile( final String appId, final String env, final String clusterName, final String namespaceName, final String configText, final String format ) { final NamespaceDTO namespaceDTO = namespaceService .loadNamespaceBaseInfo(appId, Env.valueOf(env), clusterName, namespaceName); this.importConfig(appId, env, clusterName, namespaceName, namespaceDTO.getId(), format, configText); } /** * import a config file. * the name of config file must be special like * appId+cluster+namespace.format * Example: * <pre> * 123456+default+application.properties (appId is 123456, cluster is default, namespace is application, format is properties) * 654321+north+password.yml (appId is 654321, cluster is north, namespace is password, format is yml) * </pre> * so we can get the information of appId, cluster, namespace, format from the file name. * @param env environment * @param standardFilename appId+cluster+namespace.format * @param configText config content */ private void importOneConfigFromText( final String env, final String standardFilename, final String configText ) { final String appId = ConfigFileUtils.getAppId(standardFilename); final String clusterName = ConfigFileUtils.getClusterName(standardFilename); final String namespace = ConfigFileUtils.getNamespace(standardFilename); final String format = ConfigFileUtils.getFormat(standardFilename); this.importOneConfigFromFile(appId, env, clusterName, namespace, configText, format); } /** * @see ConfigsImportService#importOneConfigFromText(java.lang.String, java.lang.String, java.lang.String) * @throws AccessControlException if has no modify namespace permission */ public void importOneConfigFromFile( final String env, final String standardFilename, final InputStream inputStream ) { final String configText; try(InputStream in = inputStream) { configText = ConfigToFileUtils.fileToString(in); } catch (IOException e) { throw new ServiceException("Read config file errors:{}", e); } this.importOneConfigFromText(env, standardFilename, configText); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.AbstractIntegrationTest; import com.ctrip.framework.apollo.biz.entity.Instance; import com.ctrip.framework.apollo.biz.entity.InstanceConfig; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.test.annotation.Rollback; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; /** * @author Jason Song(song_s@ctrip.com) */ public class InstanceServiceTest extends AbstractIntegrationTest { @Autowired private InstanceService instanceService; @Test @Rollback public void testCreateAndFindInstance() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; Instance instance = instanceService.findInstance(someAppId, someClusterName, someDataCenter, someIp); assertNull(instance); instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); instance = instanceService.findInstance(someAppId, someClusterName, someDataCenter, someIp); assertNotEquals(0, instance.getId()); } @Test @Rollback public void testFindInstancesByIds() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; String anotherIp = "anotherIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, anotherIp)); List<Instance> instances = instanceService.findInstancesByIds(Sets.newHashSet(someInstance .getId(), anotherInstance.getId())); Set<String> ips = instances.stream().map(Instance::getIp).collect(Collectors.toSet()); assertEquals(2, instances.size()); assertEquals(Sets.newHashSet(someIp, anotherIp), ips); } @Test @Rollback public void testCreateAndFindInstanceConfig() throws Exception { long someInstanceId = 1; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; String anotherReleaseKey = "anotherReleaseKey"; InstanceConfig instanceConfig = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertNull(instanceConfig); instanceService.createInstanceConfig(assembleInstanceConfig(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey)); instanceConfig = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertNotEquals(0, instanceConfig.getId()); assertEquals(someReleaseKey, instanceConfig.getReleaseKey()); instanceConfig.setReleaseKey(anotherReleaseKey); instanceService.updateInstanceConfig(instanceConfig); InstanceConfig updated = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertEquals(instanceConfig.getId(), updated.getId()); assertEquals(anotherReleaseKey, updated.getReleaseKey()); } @Test @Rollback public void testFindActiveInstanceConfigs() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); Pageable pageable = PageRequest.of(0, 10); String someReleaseKey = "someReleaseKey"; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -2); Date someInvalidDate = calendar.getTime(); prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someInvalidDate); Page<InstanceConfig> validInstanceConfigs = instanceService .findActiveInstanceConfigsByReleaseKey(someReleaseKey, pageable); assertEquals(1, validInstanceConfigs.getContent().size()); assertEquals(someInstanceId, validInstanceConfigs.getContent().get(0).getInstanceId()); } @Test @Rollback public void testFindInstancesByNamespace() throws Exception { String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; Date someValidDate = new Date(); String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; String anotherIp = "anotherIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, anotherIp)); prepareInstanceConfigForInstance(someInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); Page<Instance> result = instanceService.findInstancesByNamespace(someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); assertEquals(Lists.newArrayList(someInstance, anotherInstance), result.getContent()); } @Test @Rollback public void testFindInstancesByNamespaceAndInstanceAppId() throws Exception { String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; Date someValidDate = new Date(); String someAppId = "someAppId"; String anotherAppId = "anotherAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(anotherAppId, someClusterName, someDataCenter, someIp)); prepareInstanceConfigForInstance(someInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); Page<Instance> result = instanceService.findInstancesByNamespaceAndInstanceAppId(someAppId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); Page<Instance> anotherResult = instanceService.findInstancesByNamespaceAndInstanceAppId(anotherAppId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); assertEquals(Lists.newArrayList(someInstance), result.getContent()); assertEquals(Lists.newArrayList(anotherInstance), anotherResult.getContent()); } @Test @Rollback public void testFindInstanceConfigsByNamespaceWithReleaseKeysNotIn() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; long yetAnotherInstanceId = 3; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); String someReleaseKey = "someReleaseKey"; String anotherReleaseKey = "anotherReleaseKey"; String yetAnotherReleaseKey = "yetAnotherReleaseKey"; InstanceConfig someInstanceConfig = prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); InstanceConfig anotherInstanceConfig = prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(yetAnotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, anotherReleaseKey, someValidDate); List<InstanceConfig> instanceConfigs = instanceService .findInstanceConfigsByNamespaceWithReleaseKeysNotIn(someConfigAppId, someConfigClusterName, someConfigNamespaceName, Sets.newHashSet(anotherReleaseKey, yetAnotherReleaseKey)); assertEquals(Lists.newArrayList(someInstanceConfig, anotherInstanceConfig), instanceConfigs); } private InstanceConfig prepareInstanceConfigForInstance(long instanceId, String configAppId, String configClusterName, String configNamespace, String releaseKey, Date lastModifiedTime) { InstanceConfig someConfig = assembleInstanceConfig(instanceId, configAppId, configClusterName, configNamespace, releaseKey); someConfig.setDataChangeCreatedTime(lastModifiedTime); someConfig.setDataChangeLastModifiedTime(lastModifiedTime); return instanceService.createInstanceConfig(someConfig); } private Instance assembleInstance(String appId, String clusterName, String dataCenter, String ip) { Instance instance = new Instance(); instance.setAppId(appId); instance.setIp(ip); instance.setClusterName(clusterName); instance.setDataCenter(dataCenter); return instance; } private InstanceConfig assembleInstanceConfig(long instanceId, String configAppId, String configClusterName, String configNamespaceName, String releaseKey) { InstanceConfig instanceConfig = new InstanceConfig(); instanceConfig.setInstanceId(instanceId); instanceConfig.setConfigAppId(configAppId); instanceConfig.setConfigClusterName(configClusterName); instanceConfig.setConfigNamespaceName(configNamespaceName); instanceConfig.setReleaseKey(releaseKey); return instanceConfig; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.AbstractIntegrationTest; import com.ctrip.framework.apollo.biz.entity.Instance; import com.ctrip.framework.apollo.biz.entity.InstanceConfig; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.test.annotation.Rollback; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; /** * @author Jason Song(song_s@ctrip.com) */ public class InstanceServiceTest extends AbstractIntegrationTest { @Autowired private InstanceService instanceService; @Test @Rollback public void testCreateAndFindInstance() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; Instance instance = instanceService.findInstance(someAppId, someClusterName, someDataCenter, someIp); assertNull(instance); instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); instance = instanceService.findInstance(someAppId, someClusterName, someDataCenter, someIp); assertNotEquals(0, instance.getId()); } @Test @Rollback public void testFindInstancesByIds() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; String anotherIp = "anotherIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, anotherIp)); List<Instance> instances = instanceService.findInstancesByIds(Sets.newHashSet(someInstance .getId(), anotherInstance.getId())); Set<String> ips = instances.stream().map(Instance::getIp).collect(Collectors.toSet()); assertEquals(2, instances.size()); assertEquals(Sets.newHashSet(someIp, anotherIp), ips); } @Test @Rollback public void testCreateAndFindInstanceConfig() throws Exception { long someInstanceId = 1; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; String anotherReleaseKey = "anotherReleaseKey"; InstanceConfig instanceConfig = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertNull(instanceConfig); instanceService.createInstanceConfig(assembleInstanceConfig(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey)); instanceConfig = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertNotEquals(0, instanceConfig.getId()); assertEquals(someReleaseKey, instanceConfig.getReleaseKey()); instanceConfig.setReleaseKey(anotherReleaseKey); instanceService.updateInstanceConfig(instanceConfig); InstanceConfig updated = instanceService.findInstanceConfig(someInstanceId, someConfigAppId, someConfigNamespaceName); assertEquals(instanceConfig.getId(), updated.getId()); assertEquals(anotherReleaseKey, updated.getReleaseKey()); } @Test @Rollback public void testFindActiveInstanceConfigs() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); Pageable pageable = PageRequest.of(0, 10); String someReleaseKey = "someReleaseKey"; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -2); Date someInvalidDate = calendar.getTime(); prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someInvalidDate); Page<InstanceConfig> validInstanceConfigs = instanceService .findActiveInstanceConfigsByReleaseKey(someReleaseKey, pageable); assertEquals(1, validInstanceConfigs.getContent().size()); assertEquals(someInstanceId, validInstanceConfigs.getContent().get(0).getInstanceId()); } @Test @Rollback public void testFindInstancesByNamespace() throws Exception { String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; Date someValidDate = new Date(); String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; String anotherIp = "anotherIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, anotherIp)); prepareInstanceConfigForInstance(someInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); Page<Instance> result = instanceService.findInstancesByNamespace(someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); assertEquals(Lists.newArrayList(someInstance, anotherInstance), result.getContent()); } @Test @Rollback public void testFindInstancesByNamespaceAndInstanceAppId() throws Exception { String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; String someReleaseKey = "someReleaseKey"; Date someValidDate = new Date(); String someAppId = "someAppId"; String anotherAppId = "anotherAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(anotherAppId, someClusterName, someDataCenter, someIp)); prepareInstanceConfigForInstance(someInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstance.getId(), someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); Page<Instance> result = instanceService.findInstancesByNamespaceAndInstanceAppId(someAppId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); Page<Instance> anotherResult = instanceService.findInstancesByNamespaceAndInstanceAppId(anotherAppId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, PageRequest.of(0, 10)); assertEquals(Lists.newArrayList(someInstance), result.getContent()); assertEquals(Lists.newArrayList(anotherInstance), anotherResult.getContent()); } @Test @Rollback public void testFindInstanceConfigsByNamespaceWithReleaseKeysNotIn() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; long yetAnotherInstanceId = 3; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); String someReleaseKey = "someReleaseKey"; String anotherReleaseKey = "anotherReleaseKey"; String yetAnotherReleaseKey = "yetAnotherReleaseKey"; InstanceConfig someInstanceConfig = prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); InstanceConfig anotherInstanceConfig = prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(yetAnotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, anotherReleaseKey, someValidDate); List<InstanceConfig> instanceConfigs = instanceService .findInstanceConfigsByNamespaceWithReleaseKeysNotIn(someConfigAppId, someConfigClusterName, someConfigNamespaceName, Sets.newHashSet(anotherReleaseKey, yetAnotherReleaseKey)); assertEquals(Lists.newArrayList(someInstanceConfig, anotherInstanceConfig), instanceConfigs); } private InstanceConfig prepareInstanceConfigForInstance(long instanceId, String configAppId, String configClusterName, String configNamespace, String releaseKey, Date lastModifiedTime) { InstanceConfig someConfig = assembleInstanceConfig(instanceId, configAppId, configClusterName, configNamespace, releaseKey); someConfig.setDataChangeCreatedTime(lastModifiedTime); someConfig.setDataChangeLastModifiedTime(lastModifiedTime); return instanceService.createInstanceConfig(someConfig); } private Instance assembleInstance(String appId, String clusterName, String dataCenter, String ip) { Instance instance = new Instance(); instance.setAppId(appId); instance.setIp(ip); instance.setClusterName(clusterName); instance.setDataCenter(dataCenter); return instance; } private InstanceConfig assembleInstanceConfig(long instanceId, String configAppId, String configClusterName, String configNamespaceName, String releaseKey) { InstanceConfig instanceConfig = new InstanceConfig(); instanceConfig.setInstanceId(instanceId); instanceConfig.setConfigAppId(configAppId); instanceConfig.setConfigClusterName(configClusterName); instanceConfig.setConfigNamespaceName(configNamespaceName); instanceConfig.setReleaseKey(releaseKey); return instanceConfig; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/zh/design/apollo-core-concept-namespace.md
### 1. 什么是Namespace? Namespace是配置项的集合,类似于一个配置文件的概念。 ### 2. 什么是“application”的Namespace? Apollo在创建项目的时候,都会默认创建一个“application”的Namespace。顾名思义,“application”是给应用自身使用的,熟悉Spring Boot的同学都知道,Spring Boot项目都有一个默认配置文件application.yml。在这里application.yml就等同于“application”的Namespace。对于90%的应用来说,“application”的Namespace已经满足日常配置使用场景了。 #### 客户端获取“application” Namespace的代码如下: ``` java Config config = ConfigService.getAppConfig(); ``` #### 客户端获取非“application” Namespace的代码如下: ``` java Config config = ConfigService.getConfig(namespaceName); ``` ### 3. Namespace的格式有哪些? 配置文件有多种格式,例如:properties、xml、yml、yaml、json等。同样Namespace也具有这些格式。在Portal UI中可以看到“application”的Namespace上有一个“properties”标签,表明“application”是properties格式的。 >注1:非properties格式的namespace,在客户端使用时需要调用`ConfigService.getConfigFile(String namespace, ConfigFileFormat configFileFormat)`来获取,如果使用[Http接口直接调用](zh/usage/other-language-client-user-guide#_12-通过带缓存的http接口从apollo读取配置)时,对应的namespace参数需要传入namespace的名字加上后缀名,如datasources.json。 >注2:apollo-client 1.3.0版本开始对yaml/yml做了更好的支持,使用起来和properties格式一致:`Config config = ConfigService.getConfig("application.yml");`,Spring的注入方式也和properties一致。 ### 4. Namespace的获取权限分类 Namespace的获取权限分为两种: * private (私有的) * public (公共的) 这里的获取权限是相对于Apollo客户端来说的。 #### 4.1 private权限 private权限的Namespace,只能被所属的应用获取到。一个应用尝试获取其它应用private的Namespace,Apollo会报“404”异常。 #### 4.2 public权限 public权限的Namespace,能被任何应用获取。 ### 5. Namespace的类型 Namespace类型有三种: * 私有类型 * 公共类型 * 关联类型(继承类型) #### 5.1 私有类型 私有类型的Namespace具有private权限。例如上文提到的“application” Namespace就是私有类型。 #### 5.2 公共类型 ##### 5.2.1 含义 公共类型的Namespace具有public权限。公共类型的Namespace相当于游离于应用之外的配置,且通过Namespace的名称去标识公共Namespace,所以公共的Namespace的名称必须全局唯一。 ##### 5.2.2 使用场景 * 部门级别共享的配置 * 小组级别共享的配置 * 几个项目之间共享的配置 * 中间件客户端的配置 #### 5.3 关联类型 ##### 5.3.1 含义 关联类型又可称为继承类型,关联类型具有private权限。关联类型的Namespace继承于公共类型的Namespace,用于覆盖公共Namespace的某些配置。例如公共的Namespace有两个配置项 ``` k1 = v1 k2 = v2 ``` 然后应用A有一个关联类型的Namespace关联了此公共Namespace,且覆盖了配置项k1,新值为v3。那么在应用A实际运行时,获取到的公共Namespace的配置为: ``` k1 = v3 k2 = v2 ``` ##### 5.3.2 使用场景 举一个实际使用的场景。假设RPC框架的配置(如:timeout)有以下要求: * 提供一份全公司默认的配置且可动态调整 * RPC客户端项目可以自定义某些配置项且可动态调整 1. 如果把以上两点要求去掉“动态调整”,那么做法很简单。在rpc-client.jar包里有一份配置文件,每次修改配置文件然后重新发一个版本的jar包即可。同理,客户端项目修改配置也是如此。 2. 如果只支持客户端项目可动态调整配置。客户端项目可以在Apollo “application” Namespace上配置一些配置项。在初始化service的时候,从Apollo上读取配置即可。这样做的坏处就是,每个项目都要自定义一些key,不统一。 3. 那么如何完美支持以上需求呢?答案就是结合使用Apollo的公共类型的Namespace和关联类型的Namespace。RPC团队在Apollo上维护一个叫“rpc-client”的公共Namespace,在“rpc-client” Namespace上配置默认的参数值。rpc-client.jar里的代码读取“rpc-client”Namespace的配置即可。如果需要调整默认的配置,只需要修改公共类型“rpc-client” Namespace的配置。如果客户端项目想要自定义或动态修改某些配置项,只需要在Apollo 自己项目下关联“rpc-client”,就能创建关联类型“rpc-client”的Namespace。然后在关联类型“rpc-client”的Namespace下修改配置项即可。这里有一点需要指出的,那就是rpc-client.jar是在应用容器里运行的,所以rpc-client获取到的“rpc-client” Namespace的配置是应用的关联类型的Namespace加上公共类型的Namespace。 #### 5.4 例子 如下图所示,有三个应用:应用A、应用B、应用C。 * 应用A有两个私有类型的Namespace:application和NS-Private,以及一个关联类型的Namespace:NS-Public。 * 应用B有一个私有类型的Namespace:application,以及一个公共类型的Namespace:NS-Public。 * 应用C只有一个私有类型的Namespace:application ![Namespace例子](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/namespace-model-example.png) ##### 5.4.1 应用A获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v11 appConfig.getProperty("k2", null); // k2 = v21 //NS-Private Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", null); // k1 = v3 privateConfig.getProperty("k3", null); // k3 = v4 //NS-Public,覆盖公共类型配置的情况,k4被覆盖 Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v6 cover publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.2 应用B获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v12 appConfig.getProperty("k2", null); // k2 = null appConfig.getProperty("k3", null); // k3 = v32 //NS-Private,由于没有NS-Private Namespace 所以获取到default value Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", "default value"); //NS-Public Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v5 publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.3 应用C获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v12 appConfig.getProperty("k2", null); // k2 = null appConfig.getProperty("k3", null); // k3 = v33 //NS-Private,由于没有NS-Private Namespace 所以获取到default value Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", "default value"); //NS-Public,公共类型的Namespace,任何项目都可以获取到 Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v5 publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.4 ChangeListener 以上代码例子中可以看到,在客户端Namespace映射成一个Config对象。Namespace配置变更的监听器是注册在Config对象上。 所以在应用A中监听application的Namespace代码如下: ```java Config appConfig = ConfigService.getAppConfig(); appConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ``` 在应用A中监听NS-Private的Namespace代码如下: ```java Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ``` 在应用A、应用B、应用C中监听NS-Public的Namespace代码如下: ```java Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ```
### 1. 什么是Namespace? Namespace是配置项的集合,类似于一个配置文件的概念。 ### 2. 什么是“application”的Namespace? Apollo在创建项目的时候,都会默认创建一个“application”的Namespace。顾名思义,“application”是给应用自身使用的,熟悉Spring Boot的同学都知道,Spring Boot项目都有一个默认配置文件application.yml。在这里application.yml就等同于“application”的Namespace。对于90%的应用来说,“application”的Namespace已经满足日常配置使用场景了。 #### 客户端获取“application” Namespace的代码如下: ``` java Config config = ConfigService.getAppConfig(); ``` #### 客户端获取非“application” Namespace的代码如下: ``` java Config config = ConfigService.getConfig(namespaceName); ``` ### 3. Namespace的格式有哪些? 配置文件有多种格式,例如:properties、xml、yml、yaml、json等。同样Namespace也具有这些格式。在Portal UI中可以看到“application”的Namespace上有一个“properties”标签,表明“application”是properties格式的。 >注1:非properties格式的namespace,在客户端使用时需要调用`ConfigService.getConfigFile(String namespace, ConfigFileFormat configFileFormat)`来获取,如果使用[Http接口直接调用](zh/usage/other-language-client-user-guide#_12-通过带缓存的http接口从apollo读取配置)时,对应的namespace参数需要传入namespace的名字加上后缀名,如datasources.json。 >注2:apollo-client 1.3.0版本开始对yaml/yml做了更好的支持,使用起来和properties格式一致:`Config config = ConfigService.getConfig("application.yml");`,Spring的注入方式也和properties一致。 ### 4. Namespace的获取权限分类 Namespace的获取权限分为两种: * private (私有的) * public (公共的) 这里的获取权限是相对于Apollo客户端来说的。 #### 4.1 private权限 private权限的Namespace,只能被所属的应用获取到。一个应用尝试获取其它应用private的Namespace,Apollo会报“404”异常。 #### 4.2 public权限 public权限的Namespace,能被任何应用获取。 ### 5. Namespace的类型 Namespace类型有三种: * 私有类型 * 公共类型 * 关联类型(继承类型) #### 5.1 私有类型 私有类型的Namespace具有private权限。例如上文提到的“application” Namespace就是私有类型。 #### 5.2 公共类型 ##### 5.2.1 含义 公共类型的Namespace具有public权限。公共类型的Namespace相当于游离于应用之外的配置,且通过Namespace的名称去标识公共Namespace,所以公共的Namespace的名称必须全局唯一。 ##### 5.2.2 使用场景 * 部门级别共享的配置 * 小组级别共享的配置 * 几个项目之间共享的配置 * 中间件客户端的配置 #### 5.3 关联类型 ##### 5.3.1 含义 关联类型又可称为继承类型,关联类型具有private权限。关联类型的Namespace继承于公共类型的Namespace,用于覆盖公共Namespace的某些配置。例如公共的Namespace有两个配置项 ``` k1 = v1 k2 = v2 ``` 然后应用A有一个关联类型的Namespace关联了此公共Namespace,且覆盖了配置项k1,新值为v3。那么在应用A实际运行时,获取到的公共Namespace的配置为: ``` k1 = v3 k2 = v2 ``` ##### 5.3.2 使用场景 举一个实际使用的场景。假设RPC框架的配置(如:timeout)有以下要求: * 提供一份全公司默认的配置且可动态调整 * RPC客户端项目可以自定义某些配置项且可动态调整 1. 如果把以上两点要求去掉“动态调整”,那么做法很简单。在rpc-client.jar包里有一份配置文件,每次修改配置文件然后重新发一个版本的jar包即可。同理,客户端项目修改配置也是如此。 2. 如果只支持客户端项目可动态调整配置。客户端项目可以在Apollo “application” Namespace上配置一些配置项。在初始化service的时候,从Apollo上读取配置即可。这样做的坏处就是,每个项目都要自定义一些key,不统一。 3. 那么如何完美支持以上需求呢?答案就是结合使用Apollo的公共类型的Namespace和关联类型的Namespace。RPC团队在Apollo上维护一个叫“rpc-client”的公共Namespace,在“rpc-client” Namespace上配置默认的参数值。rpc-client.jar里的代码读取“rpc-client”Namespace的配置即可。如果需要调整默认的配置,只需要修改公共类型“rpc-client” Namespace的配置。如果客户端项目想要自定义或动态修改某些配置项,只需要在Apollo 自己项目下关联“rpc-client”,就能创建关联类型“rpc-client”的Namespace。然后在关联类型“rpc-client”的Namespace下修改配置项即可。这里有一点需要指出的,那就是rpc-client.jar是在应用容器里运行的,所以rpc-client获取到的“rpc-client” Namespace的配置是应用的关联类型的Namespace加上公共类型的Namespace。 #### 5.4 例子 如下图所示,有三个应用:应用A、应用B、应用C。 * 应用A有两个私有类型的Namespace:application和NS-Private,以及一个关联类型的Namespace:NS-Public。 * 应用B有一个私有类型的Namespace:application,以及一个公共类型的Namespace:NS-Public。 * 应用C只有一个私有类型的Namespace:application ![Namespace例子](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/namespace-model-example.png) ##### 5.4.1 应用A获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v11 appConfig.getProperty("k2", null); // k2 = v21 //NS-Private Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", null); // k1 = v3 privateConfig.getProperty("k3", null); // k3 = v4 //NS-Public,覆盖公共类型配置的情况,k4被覆盖 Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v6 cover publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.2 应用B获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v12 appConfig.getProperty("k2", null); // k2 = null appConfig.getProperty("k3", null); // k3 = v32 //NS-Private,由于没有NS-Private Namespace 所以获取到default value Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", "default value"); //NS-Public Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v5 publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.3 应用C获取Apollo配置 ```java //application Config appConfig = ConfigService.getAppConfig(); appConfig.getProperty("k1", null); // k1 = v12 appConfig.getProperty("k2", null); // k2 = null appConfig.getProperty("k3", null); // k3 = v33 //NS-Private,由于没有NS-Private Namespace 所以获取到default value Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.getProperty("k1", "default value"); //NS-Public,公共类型的Namespace,任何项目都可以获取到 Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.getProperty("k4", null); // k4 = v5 publicConfig.getProperty("k6", null); // k6 = v6 publicConfig.getProperty("k7", null); // k7 = v7 ``` ##### 5.4.4 ChangeListener 以上代码例子中可以看到,在客户端Namespace映射成一个Config对象。Namespace配置变更的监听器是注册在Config对象上。 所以在应用A中监听application的Namespace代码如下: ```java Config appConfig = ConfigService.getAppConfig(); appConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ``` 在应用A中监听NS-Private的Namespace代码如下: ```java Config privateConfig = ConfigService.getConfig("NS-Private"); privateConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ``` 在应用A、应用B、应用C中监听NS-Public的Namespace代码如下: ```java Config publicConfig = ConfigService.getConfig("NS-Public"); publicConfig.addChangeListener(new ConfigChangeListener() { public void onChange(ConfigChangeEvent changeEvent) { //do something } }) ```
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapGroupProperties description. * * @author wuzishu */ public class LdapGroupProperties { /** * group search base */ private String groupBase; /** * group search filter */ private String groupSearch; /** * group membership prop */ private String groupMembership; public String getGroupBase() { return groupBase; } public void setGroupBase(String groupBase) { this.groupBase = groupBase; } public String getGroupSearch() { return groupSearch; } public void setGroupSearch(String groupSearch) { this.groupSearch = groupSearch; } public String getGroupMembership() { return groupMembership; } public void setGroupMembership(String groupMembership) { this.groupMembership = groupMembership; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapGroupProperties description. * * @author wuzishu */ public class LdapGroupProperties { /** * group search base */ private String groupBase; /** * group search filter */ private String groupSearch; /** * group membership prop */ private String groupMembership; public String getGroupBase() { return groupBase; } public void setGroupBase(String groupBase) { this.groupBase = groupBase; } public String getGroupSearch() { return groupSearch; } public void setGroupSearch(String groupSearch) { this.groupSearch = groupSearch; } public String getGroupMembership() { return groupMembership; } public void setGroupMembership(String groupMembership) { this.groupMembership = groupMembership; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.service.ItemService; import com.ctrip.framework.apollo.portal.spi.UserService; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpStatusCodeException; import javax.servlet.http.HttpServletRequest; @RestController("openapiItemController") @RequestMapping("/openapi/v1/envs/{env}") public class ItemController { private final ItemService itemService; private final UserService userService; public ItemController(final ItemService itemService, final UserService userService) { this.itemService = itemService; this.userService = userService; } @GetMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public OpenItemDTO getItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key) { ItemDTO itemDTO = itemService.loadItem(Env.valueOf(env), appId, clusterName, namespaceName, key); return itemDTO == null ? null : OpenApiBeanUtils.transformFromItemDTO(itemDTO); } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items") public OpenItemDTO createItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @RequestBody OpenItemDTO item, HttpServletRequest request) { RequestPrecondition.checkArguments( !StringUtils.isContainEmpty(item.getKey(), item.getDataChangeCreatedBy()), "key and dataChangeCreatedBy should not be null or empty"); if (userService.findByUserId(item.getDataChangeCreatedBy()) == null) { throw new BadRequestException("User " + item.getDataChangeCreatedBy() + " doesn't exist!"); } if(!StringUtils.isEmpty(item.getComment()) && item.getComment().length() > 256){ throw new BadRequestException("Comment length should not exceed 256 characters"); } ItemDTO toCreate = OpenApiBeanUtils.transformToItemDTO(item); //protect toCreate.setLineNum(0); toCreate.setId(0); toCreate.setDataChangeLastModifiedBy(toCreate.getDataChangeCreatedBy()); toCreate.setDataChangeLastModifiedTime(null); toCreate.setDataChangeCreatedTime(null); ItemDTO createdItem = itemService.createItem(appId, Env.valueOf(env), clusterName, namespaceName, toCreate); return OpenApiBeanUtils.transformFromItemDTO(createdItem); } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @PutMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public void updateItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key, @RequestBody OpenItemDTO item, @RequestParam(defaultValue = "false") boolean createIfNotExists, HttpServletRequest request) { RequestPrecondition.checkArguments(item != null, "item payload can not be empty"); RequestPrecondition.checkArguments( !StringUtils.isContainEmpty(item.getKey(), item.getDataChangeLastModifiedBy()), "key and dataChangeLastModifiedBy can not be empty"); RequestPrecondition.checkArguments(item.getKey().equals(key), "Key in path and payload is not consistent"); if (userService.findByUserId(item.getDataChangeLastModifiedBy()) == null) { throw new BadRequestException("user(dataChangeLastModifiedBy) not exists"); } if(!StringUtils.isEmpty(item.getComment()) && item.getComment().length() > 256){ throw new BadRequestException("Comment length should not exceed 256 characters"); } try { ItemDTO toUpdateItem = itemService .loadItem(Env.valueOf(env), appId, clusterName, namespaceName, item.getKey()); //protect. only value,comment,lastModifiedBy can be modified toUpdateItem.setComment(item.getComment()); toUpdateItem.setValue(item.getValue()); toUpdateItem.setDataChangeLastModifiedBy(item.getDataChangeLastModifiedBy()); itemService.updateItem(appId, Env.valueOf(env), clusterName, namespaceName, toUpdateItem); } catch (Throwable ex) { if (ex instanceof HttpStatusCodeException) { // check createIfNotExists if (((HttpStatusCodeException) ex).getStatusCode().equals(HttpStatus.NOT_FOUND) && createIfNotExists) { createItem(appId, env, clusterName, namespaceName, item, request); return; } } throw ex; } } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @DeleteMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public void deleteItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key, @RequestParam String operator, HttpServletRequest request) { if (userService.findByUserId(operator) == null) { throw new BadRequestException("user(operator) not exists"); } ItemDTO toDeleteItem = itemService.loadItem(Env.valueOf(env), appId, clusterName, namespaceName, key); if (toDeleteItem == null){ throw new BadRequestException("item not exists"); } itemService.deleteItem(Env.valueOf(env), toDeleteItem.getId(), operator); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.service.ItemService; import com.ctrip.framework.apollo.portal.spi.UserService; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpStatusCodeException; import javax.servlet.http.HttpServletRequest; @RestController("openapiItemController") @RequestMapping("/openapi/v1/envs/{env}") public class ItemController { private final ItemService itemService; private final UserService userService; public ItemController(final ItemService itemService, final UserService userService) { this.itemService = itemService; this.userService = userService; } @GetMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public OpenItemDTO getItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key) { ItemDTO itemDTO = itemService.loadItem(Env.valueOf(env), appId, clusterName, namespaceName, key); return itemDTO == null ? null : OpenApiBeanUtils.transformFromItemDTO(itemDTO); } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items") public OpenItemDTO createItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @RequestBody OpenItemDTO item, HttpServletRequest request) { RequestPrecondition.checkArguments( !StringUtils.isContainEmpty(item.getKey(), item.getDataChangeCreatedBy()), "key and dataChangeCreatedBy should not be null or empty"); if (userService.findByUserId(item.getDataChangeCreatedBy()) == null) { throw new BadRequestException("User " + item.getDataChangeCreatedBy() + " doesn't exist!"); } if(!StringUtils.isEmpty(item.getComment()) && item.getComment().length() > 256){ throw new BadRequestException("Comment length should not exceed 256 characters"); } ItemDTO toCreate = OpenApiBeanUtils.transformToItemDTO(item); //protect toCreate.setLineNum(0); toCreate.setId(0); toCreate.setDataChangeLastModifiedBy(toCreate.getDataChangeCreatedBy()); toCreate.setDataChangeLastModifiedTime(null); toCreate.setDataChangeCreatedTime(null); ItemDTO createdItem = itemService.createItem(appId, Env.valueOf(env), clusterName, namespaceName, toCreate); return OpenApiBeanUtils.transformFromItemDTO(createdItem); } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @PutMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public void updateItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key, @RequestBody OpenItemDTO item, @RequestParam(defaultValue = "false") boolean createIfNotExists, HttpServletRequest request) { RequestPrecondition.checkArguments(item != null, "item payload can not be empty"); RequestPrecondition.checkArguments( !StringUtils.isContainEmpty(item.getKey(), item.getDataChangeLastModifiedBy()), "key and dataChangeLastModifiedBy can not be empty"); RequestPrecondition.checkArguments(item.getKey().equals(key), "Key in path and payload is not consistent"); if (userService.findByUserId(item.getDataChangeLastModifiedBy()) == null) { throw new BadRequestException("user(dataChangeLastModifiedBy) not exists"); } if(!StringUtils.isEmpty(item.getComment()) && item.getComment().length() > 256){ throw new BadRequestException("Comment length should not exceed 256 characters"); } try { ItemDTO toUpdateItem = itemService .loadItem(Env.valueOf(env), appId, clusterName, namespaceName, item.getKey()); //protect. only value,comment,lastModifiedBy can be modified toUpdateItem.setComment(item.getComment()); toUpdateItem.setValue(item.getValue()); toUpdateItem.setDataChangeLastModifiedBy(item.getDataChangeLastModifiedBy()); itemService.updateItem(appId, Env.valueOf(env), clusterName, namespaceName, toUpdateItem); } catch (Throwable ex) { if (ex instanceof HttpStatusCodeException) { // check createIfNotExists if (((HttpStatusCodeException) ex).getStatusCode().equals(HttpStatus.NOT_FOUND) && createIfNotExists) { createItem(appId, env, clusterName, namespaceName, item, request); return; } } throw ex; } } @PreAuthorize(value = "@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)") @DeleteMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}") public void deleteItem(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String key, @RequestParam String operator, HttpServletRequest request) { if (userService.findByUserId(operator) == null) { throw new BadRequestException("user(operator) not exists"); } ItemDTO toDeleteItem = itemService.loadItem(Env.valueOf(env), appId, clusterName, namespaceName, key); if (toDeleteItem == null){ throw new BadRequestException("item not exists"); } itemService.deleteItem(Env.valueOf(env), toDeleteItem.getId(), operator); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.AbstractUnitTest; import com.ctrip.framework.apollo.biz.MockBeanFactory; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.common.exception.BadRequestException; import java.util.ArrayList; import java.util.Optional; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.data.domain.PageRequest; import java.util.Arrays; import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class ReleaseServiceTest extends AbstractUnitTest { @Mock private ReleaseRepository releaseRepository; @Mock private NamespaceService namespaceService; @Mock private ReleaseHistoryService releaseHistoryService; @Mock private ItemSetService itemSetService; @InjectMocks private ReleaseService releaseService; private String appId = "appId-test"; private String clusterName = "cluster-test"; private String namespaceName = "namespace-test"; private String user = "user-test"; private long releaseId = 1; private Release firstRelease; private Release secondRelease; private PageRequest pageRequest; @Before public void init() { firstRelease = new Release(); firstRelease.setId(releaseId); firstRelease.setAppId(appId); firstRelease.setClusterName(clusterName); firstRelease.setNamespaceName(namespaceName); firstRelease.setAbandoned(false); secondRelease = new Release(); secondRelease.setAppId(appId); secondRelease.setClusterName(clusterName); secondRelease.setNamespaceName(namespaceName); secondRelease.setAbandoned(false); pageRequest = PageRequest.of(0, 2); } @Test(expected = BadRequestException.class) public void testNamespaceNotExist() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); releaseService.rollback(releaseId, user); } @Test(expected = BadRequestException.class) public void testHasNoRelease() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, clusterName, namespaceName, pageRequest)) .thenReturn(null); releaseService.rollback(releaseId, user); } @Test public void testRollback() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, clusterName, namespaceName, pageRequest)) .thenReturn( Arrays.asList(firstRelease, secondRelease)); releaseService.rollback(releaseId, user); verify(releaseRepository).save(firstRelease); Assert.assertEquals(true, firstRelease.isAbandoned()); Assert.assertEquals(user, firstRelease.getDataChangeLastModifiedBy()); } @Test public void testRollbackTo() { List<Release> releaseList = new ArrayList<>(); for (int i = 0; i < 3; i++) { Release release = new Release(); release.setId(3 - i); release.setAppId(appId); release.setClusterName(clusterName); release.setNamespaceName(namespaceName); release.setAbandoned(false); releaseList.add(release); } long releaseId1 = 1; long releaseId3 = 3; when(releaseRepository.findById(releaseId1)).thenReturn(Optional.of(releaseList.get(2))); when(releaseRepository.findById(releaseId3)).thenReturn(Optional.of(releaseList.get(0))); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseAndIdBetweenOrderByIdDesc(appId, clusterName, namespaceName, releaseId1, releaseId3)) .thenReturn(releaseList); releaseService.rollbackTo(releaseId3, releaseId1, user); verify(releaseRepository).saveAll(releaseList); Assert.assertTrue(releaseList.get(0).isAbandoned()); Assert.assertTrue(releaseList.get(1).isAbandoned()); Assert.assertFalse(releaseList.get(2).isAbandoned()); Assert.assertEquals(user, releaseList.get(0).getDataChangeLastModifiedBy()); Assert.assertEquals(user, releaseList.get(1).getDataChangeLastModifiedBy()); } @Test public void testFindRelease() throws Exception { String someAppId = "1"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; long someReleaseId = 1; String someReleaseKey = "someKey"; String someValidConfiguration = "{\"apollo.bar\": \"foo\"}"; Release someRelease = MockBeanFactory.mockRelease(someReleaseId, someReleaseKey, someAppId, someClusterName, someNamespaceName, someValidConfiguration); when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)) .thenReturn(someRelease); Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName); verify(releaseRepository, times(1)) .findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName); assertEquals(someAppId, result.getAppId()); assertEquals(someClusterName, result.getClusterName()); assertEquals(someReleaseId, result.getId()); assertEquals(someReleaseKey, result.getReleaseKey()); assertEquals(someValidConfiguration, result.getConfigurations()); } @Test public void testLoadConfigWithConfigNotFound() throws Exception { String someAppId = "1"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)) .thenReturn(null); Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName); assertNull(result); verify(releaseRepository, times(1)).findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc( someAppId, someClusterName, someNamespaceName); } @Test public void testFindByReleaseIds() throws Exception { Release someRelease = mock(Release.class); Release anotherRelease = mock(Release.class); long someReleaseId = 1; long anotherReleaseId = 2; List<Release> someReleases = Lists.newArrayList(someRelease, anotherRelease); Set<Long> someReleaseIds = Sets.newHashSet(someReleaseId, anotherReleaseId); when(releaseRepository.findAllById(someReleaseIds)).thenReturn(someReleases); List<Release> result = releaseService.findByReleaseIds(someReleaseIds); assertEquals(someReleases, result); } @Test public void testFindByReleaseKeys() throws Exception { Release someRelease = mock(Release.class); Release anotherRelease = mock(Release.class); String someReleaseKey = "key1"; String anotherReleaseKey = "key2"; List<Release> someReleases = Lists.newArrayList(someRelease, anotherRelease); Set<String> someReleaseKeys = Sets.newHashSet(someReleaseKey, anotherReleaseKey); when(releaseRepository.findByReleaseKeyIn(someReleaseKeys)).thenReturn(someReleases); List<Release> result = releaseService.findByReleaseKeys(someReleaseKeys); assertEquals(someReleases, result); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.AbstractUnitTest; import com.ctrip.framework.apollo.biz.MockBeanFactory; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.common.exception.BadRequestException; import java.util.ArrayList; import java.util.Optional; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.data.domain.PageRequest; import java.util.Arrays; import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class ReleaseServiceTest extends AbstractUnitTest { @Mock private ReleaseRepository releaseRepository; @Mock private NamespaceService namespaceService; @Mock private ReleaseHistoryService releaseHistoryService; @Mock private ItemSetService itemSetService; @InjectMocks private ReleaseService releaseService; private String appId = "appId-test"; private String clusterName = "cluster-test"; private String namespaceName = "namespace-test"; private String user = "user-test"; private long releaseId = 1; private Release firstRelease; private Release secondRelease; private PageRequest pageRequest; @Before public void init() { firstRelease = new Release(); firstRelease.setId(releaseId); firstRelease.setAppId(appId); firstRelease.setClusterName(clusterName); firstRelease.setNamespaceName(namespaceName); firstRelease.setAbandoned(false); secondRelease = new Release(); secondRelease.setAppId(appId); secondRelease.setClusterName(clusterName); secondRelease.setNamespaceName(namespaceName); secondRelease.setAbandoned(false); pageRequest = PageRequest.of(0, 2); } @Test(expected = BadRequestException.class) public void testNamespaceNotExist() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); releaseService.rollback(releaseId, user); } @Test(expected = BadRequestException.class) public void testHasNoRelease() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, clusterName, namespaceName, pageRequest)) .thenReturn(null); releaseService.rollback(releaseId, user); } @Test public void testRollback() { when(releaseRepository.findById(releaseId)).thenReturn(Optional.of(firstRelease)); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, clusterName, namespaceName, pageRequest)) .thenReturn( Arrays.asList(firstRelease, secondRelease)); releaseService.rollback(releaseId, user); verify(releaseRepository).save(firstRelease); Assert.assertEquals(true, firstRelease.isAbandoned()); Assert.assertEquals(user, firstRelease.getDataChangeLastModifiedBy()); } @Test public void testRollbackTo() { List<Release> releaseList = new ArrayList<>(); for (int i = 0; i < 3; i++) { Release release = new Release(); release.setId(3 - i); release.setAppId(appId); release.setClusterName(clusterName); release.setNamespaceName(namespaceName); release.setAbandoned(false); releaseList.add(release); } long releaseId1 = 1; long releaseId3 = 3; when(releaseRepository.findById(releaseId1)).thenReturn(Optional.of(releaseList.get(2))); when(releaseRepository.findById(releaseId3)).thenReturn(Optional.of(releaseList.get(0))); when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseAndIdBetweenOrderByIdDesc(appId, clusterName, namespaceName, releaseId1, releaseId3)) .thenReturn(releaseList); releaseService.rollbackTo(releaseId3, releaseId1, user); verify(releaseRepository).saveAll(releaseList); Assert.assertTrue(releaseList.get(0).isAbandoned()); Assert.assertTrue(releaseList.get(1).isAbandoned()); Assert.assertFalse(releaseList.get(2).isAbandoned()); Assert.assertEquals(user, releaseList.get(0).getDataChangeLastModifiedBy()); Assert.assertEquals(user, releaseList.get(1).getDataChangeLastModifiedBy()); } @Test public void testFindRelease() throws Exception { String someAppId = "1"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; long someReleaseId = 1; String someReleaseKey = "someKey"; String someValidConfiguration = "{\"apollo.bar\": \"foo\"}"; Release someRelease = MockBeanFactory.mockRelease(someReleaseId, someReleaseKey, someAppId, someClusterName, someNamespaceName, someValidConfiguration); when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)) .thenReturn(someRelease); Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName); verify(releaseRepository, times(1)) .findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName); assertEquals(someAppId, result.getAppId()); assertEquals(someClusterName, result.getClusterName()); assertEquals(someReleaseId, result.getId()); assertEquals(someReleaseKey, result.getReleaseKey()); assertEquals(someValidConfiguration, result.getConfigurations()); } @Test public void testLoadConfigWithConfigNotFound() throws Exception { String someAppId = "1"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)) .thenReturn(null); Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName); assertNull(result); verify(releaseRepository, times(1)).findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc( someAppId, someClusterName, someNamespaceName); } @Test public void testFindByReleaseIds() throws Exception { Release someRelease = mock(Release.class); Release anotherRelease = mock(Release.class); long someReleaseId = 1; long anotherReleaseId = 2; List<Release> someReleases = Lists.newArrayList(someRelease, anotherRelease); Set<Long> someReleaseIds = Sets.newHashSet(someReleaseId, anotherReleaseId); when(releaseRepository.findAllById(someReleaseIds)).thenReturn(someReleases); List<Release> result = releaseService.findByReleaseIds(someReleaseIds); assertEquals(someReleases, result); } @Test public void testFindByReleaseKeys() throws Exception { Release someRelease = mock(Release.class); Release anotherRelease = mock(Release.class); String someReleaseKey = "key1"; String anotherReleaseKey = "key2"; List<Release> someReleases = Lists.newArrayList(someRelease, anotherRelease); Set<String> someReleaseKeys = Sets.newHashSet(someReleaseKey, anotherReleaseKey); when(releaseRepository.findByReleaseKeyIn(someReleaseKeys)).thenReturn(someReleases); List<Release> result = releaseService.findByReleaseKeys(someReleaseKeys); assertEquals(someReleases, result); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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.dto.CommitDTO; import com.ctrip.framework.apollo.common.utils.BeanUtils; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController public class CommitController { private final CommitService commitService; public CommitController(final CommitService commitService) { this.commitService = commitService; } @GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit") public List<CommitDTO> find(@PathVariable String appId, @PathVariable String clusterName, @PathVariable String namespaceName, Pageable pageable){ List<Commit> commits = commitService.find(appId, clusterName, namespaceName, pageable); return BeanUtils.batchTransform(CommitDTO.class, commits); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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.dto.CommitDTO; import com.ctrip.framework.apollo.common.utils.BeanUtils; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController public class CommitController { private final CommitService commitService; public CommitController(final CommitService commitService) { this.commitService = commitService; } @GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit") public List<CommitDTO> find(@PathVariable String appId, @PathVariable String clusterName, @PathVariable String namespaceName, Pageable pageable){ List<Commit> commits = commitService.find(appId, clusterName, namespaceName, pageable); return BeanUtils.batchTransform(CommitDTO.class, commits); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ItemsComparator.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.component; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.utils.StringUtils; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @Component public class ItemsComparator { public ItemChangeSets compareIgnoreBlankAndCommentItem(long baseNamespaceId, List<ItemDTO> baseItems, List<ItemDTO> targetItems){ List<ItemDTO> filteredSourceItems = filterBlankAndCommentItem(baseItems); List<ItemDTO> filteredTargetItems = filterBlankAndCommentItem(targetItems); Map<String, ItemDTO> sourceItemMap = BeanUtils.mapByKey("key", filteredSourceItems); Map<String, ItemDTO> targetItemMap = BeanUtils.mapByKey("key", filteredTargetItems); ItemChangeSets changeSets = new ItemChangeSets(); for (ItemDTO item: targetItems){ String key = item.getKey(); ItemDTO sourceItem = sourceItemMap.get(key); if (sourceItem == null){//add ItemDTO copiedItem = copyItem(item); copiedItem.setNamespaceId(baseNamespaceId); changeSets.addCreateItem(copiedItem); }else if (!Objects.equals(sourceItem.getValue(), item.getValue())){//update //only value & comment can be update sourceItem.setValue(item.getValue()); sourceItem.setComment(item.getComment()); changeSets.addUpdateItem(sourceItem); } } for (ItemDTO item: baseItems){ String key = item.getKey(); ItemDTO targetItem = targetItemMap.get(key); if(targetItem == null){//delete changeSets.addDeleteItem(item); } } return changeSets; } private List<ItemDTO> filterBlankAndCommentItem(List<ItemDTO> items){ List<ItemDTO> result = new LinkedList<>(); if (CollectionUtils.isEmpty(items)){ return result; } for (ItemDTO item: items){ if (!StringUtils.isEmpty(item.getKey())){ result.add(item); } } return result; } private ItemDTO copyItem(ItemDTO sourceItem){ ItemDTO copiedItem = new ItemDTO(); copiedItem.setKey(sourceItem.getKey()); copiedItem.setValue(sourceItem.getValue()); copiedItem.setComment(sourceItem.getComment()); return copiedItem; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.component; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.utils.StringUtils; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @Component public class ItemsComparator { public ItemChangeSets compareIgnoreBlankAndCommentItem(long baseNamespaceId, List<ItemDTO> baseItems, List<ItemDTO> targetItems){ List<ItemDTO> filteredSourceItems = filterBlankAndCommentItem(baseItems); List<ItemDTO> filteredTargetItems = filterBlankAndCommentItem(targetItems); Map<String, ItemDTO> sourceItemMap = BeanUtils.mapByKey("key", filteredSourceItems); Map<String, ItemDTO> targetItemMap = BeanUtils.mapByKey("key", filteredTargetItems); ItemChangeSets changeSets = new ItemChangeSets(); for (ItemDTO item: targetItems){ String key = item.getKey(); ItemDTO sourceItem = sourceItemMap.get(key); if (sourceItem == null){//add ItemDTO copiedItem = copyItem(item); copiedItem.setNamespaceId(baseNamespaceId); changeSets.addCreateItem(copiedItem); }else if (!Objects.equals(sourceItem.getValue(), item.getValue())){//update //only value & comment can be update sourceItem.setValue(item.getValue()); sourceItem.setComment(item.getComment()); changeSets.addUpdateItem(sourceItem); } } for (ItemDTO item: baseItems){ String key = item.getKey(); ItemDTO targetItem = targetItemMap.get(key); if(targetItem == null){//delete changeSets.addDeleteItem(item); } } return changeSets; } private List<ItemDTO> filterBlankAndCommentItem(List<ItemDTO> items){ List<ItemDTO> result = new LinkedList<>(); if (CollectionUtils.isEmpty(items)){ return result; } for (ItemDTO item: items){ if (!StringUtils.isEmpty(item.getKey())){ result.add(item); } } return result; } private ItemDTO copyItem(ItemDTO sourceItem){ ItemDTO copiedItem = new ItemDTO(); copiedItem.setKey(sourceItem.getKey()); copiedItem.setValue(sourceItem.getValue()); copiedItem.setComment(sourceItem.getComment()); return copiedItem; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO; 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.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.ItemsComparator; import com.ctrip.framework.apollo.portal.constant.TracerEventType; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.tracer.Tracer; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; @Service public class NamespaceBranchService { private final ItemsComparator itemsComparator; private final UserInfoHolder userInfoHolder; private final NamespaceService namespaceService; private final ItemService itemService; private final AdminServiceAPI.NamespaceBranchAPI namespaceBranchAPI; private final ReleaseService releaseService; public NamespaceBranchService( final ItemsComparator itemsComparator, final UserInfoHolder userInfoHolder, final NamespaceService namespaceService, final ItemService itemService, final AdminServiceAPI.NamespaceBranchAPI namespaceBranchAPI, final ReleaseService releaseService) { this.itemsComparator = itemsComparator; this.userInfoHolder = userInfoHolder; this.namespaceService = namespaceService; this.itemService = itemService; this.namespaceBranchAPI = namespaceBranchAPI; this.releaseService = releaseService; } @Transactional public NamespaceDTO createBranch(String appId, Env env, String parentClusterName, String namespaceName) { String operator = userInfoHolder.getUser().getUserId(); return createBranch(appId, env, parentClusterName, namespaceName, operator); } @Transactional public NamespaceDTO createBranch(String appId, Env env, String parentClusterName, String namespaceName, String operator) { NamespaceDTO createdBranch = namespaceBranchAPI.createBranch(appId, env, parentClusterName, namespaceName, operator); Tracer.logEvent(TracerEventType.CREATE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, parentClusterName, namespaceName)); return createdBranch; } public GrayReleaseRuleDTO findBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName) { return namespaceBranchAPI.findBranchGrayRules(appId, env, clusterName, namespaceName, branchName); } public void updateBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName, GrayReleaseRuleDTO rules) { String operator = userInfoHolder.getUser().getUserId(); updateBranchGrayRules(appId, env, clusterName, namespaceName, branchName, rules, operator); } public void updateBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName, GrayReleaseRuleDTO rules, String operator) { rules.setDataChangeCreatedBy(operator); rules.setDataChangeLastModifiedBy(operator); namespaceBranchAPI.updateBranchGrayRules(appId, env, clusterName, namespaceName, branchName, rules); Tracer.logEvent(TracerEventType.UPDATE_GRAY_RELEASE_RULE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); } public void deleteBranch(String appId, Env env, String clusterName, String namespaceName, String branchName) { String operator = userInfoHolder.getUser().getUserId(); deleteBranch(appId, env, clusterName, namespaceName, branchName, operator); } public void deleteBranch(String appId, Env env, String clusterName, String namespaceName, String branchName, String operator) { namespaceBranchAPI.deleteBranch(appId, env, clusterName, namespaceName, branchName, operator); Tracer.logEvent(TracerEventType.DELETE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); } public ReleaseDTO merge(String appId, Env env, String clusterName, String namespaceName, String branchName, String title, String comment, boolean isEmergencyPublish, boolean deleteBranch) { String operator = userInfoHolder.getUser().getUserId(); return merge(appId, env, clusterName, namespaceName, branchName, title, comment, isEmergencyPublish, deleteBranch, operator); } public ReleaseDTO merge(String appId, Env env, String clusterName, String namespaceName, String branchName, String title, String comment, boolean isEmergencyPublish, boolean deleteBranch, String operator) { ItemChangeSets changeSets = calculateBranchChangeSet(appId, env, clusterName, namespaceName, branchName, operator); ReleaseDTO mergedResult = releaseService.updateAndPublish(appId, env, clusterName, namespaceName, title, comment, branchName, isEmergencyPublish, deleteBranch, changeSets); Tracer.logEvent(TracerEventType.MERGE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); return mergedResult; } private ItemChangeSets calculateBranchChangeSet(String appId, Env env, String clusterName, String namespaceName, String branchName, String operator) { NamespaceBO parentNamespace = namespaceService.loadNamespaceBO(appId, env, clusterName, namespaceName); if (parentNamespace == null) { throw new BadRequestException("base namespace not existed"); } if (parentNamespace.getItemModifiedCnt() > 0) { throw new BadRequestException("Merge operation failed. Because master has modified items"); } List<ItemDTO> masterItems = itemService.findItems(appId, env, clusterName, namespaceName); List<ItemDTO> branchItems = itemService.findItems(appId, env, branchName, namespaceName); ItemChangeSets changeSets = itemsComparator.compareIgnoreBlankAndCommentItem(parentNamespace.getBaseInfo().getId(), masterItems, branchItems); changeSets.setDeleteItems(Collections.emptyList()); changeSets.setDataChangeLastModifiedBy(operator); return changeSets; } public NamespaceDTO findBranchBaseInfo(String appId, Env env, String clusterName, String namespaceName) { return namespaceBranchAPI.findBranch(appId, env, clusterName, namespaceName); } public NamespaceBO findBranch(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespaceDTO = findBranchBaseInfo(appId, env, clusterName, namespaceName); if (namespaceDTO == null) { return null; } return namespaceService.loadNamespaceBO(appId, env, namespaceDTO.getClusterName(), namespaceName); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO; 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.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.ItemsComparator; import com.ctrip.framework.apollo.portal.constant.TracerEventType; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.tracer.Tracer; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; @Service public class NamespaceBranchService { private final ItemsComparator itemsComparator; private final UserInfoHolder userInfoHolder; private final NamespaceService namespaceService; private final ItemService itemService; private final AdminServiceAPI.NamespaceBranchAPI namespaceBranchAPI; private final ReleaseService releaseService; public NamespaceBranchService( final ItemsComparator itemsComparator, final UserInfoHolder userInfoHolder, final NamespaceService namespaceService, final ItemService itemService, final AdminServiceAPI.NamespaceBranchAPI namespaceBranchAPI, final ReleaseService releaseService) { this.itemsComparator = itemsComparator; this.userInfoHolder = userInfoHolder; this.namespaceService = namespaceService; this.itemService = itemService; this.namespaceBranchAPI = namespaceBranchAPI; this.releaseService = releaseService; } @Transactional public NamespaceDTO createBranch(String appId, Env env, String parentClusterName, String namespaceName) { String operator = userInfoHolder.getUser().getUserId(); return createBranch(appId, env, parentClusterName, namespaceName, operator); } @Transactional public NamespaceDTO createBranch(String appId, Env env, String parentClusterName, String namespaceName, String operator) { NamespaceDTO createdBranch = namespaceBranchAPI.createBranch(appId, env, parentClusterName, namespaceName, operator); Tracer.logEvent(TracerEventType.CREATE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, parentClusterName, namespaceName)); return createdBranch; } public GrayReleaseRuleDTO findBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName) { return namespaceBranchAPI.findBranchGrayRules(appId, env, clusterName, namespaceName, branchName); } public void updateBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName, GrayReleaseRuleDTO rules) { String operator = userInfoHolder.getUser().getUserId(); updateBranchGrayRules(appId, env, clusterName, namespaceName, branchName, rules, operator); } public void updateBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName, GrayReleaseRuleDTO rules, String operator) { rules.setDataChangeCreatedBy(operator); rules.setDataChangeLastModifiedBy(operator); namespaceBranchAPI.updateBranchGrayRules(appId, env, clusterName, namespaceName, branchName, rules); Tracer.logEvent(TracerEventType.UPDATE_GRAY_RELEASE_RULE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); } public void deleteBranch(String appId, Env env, String clusterName, String namespaceName, String branchName) { String operator = userInfoHolder.getUser().getUserId(); deleteBranch(appId, env, clusterName, namespaceName, branchName, operator); } public void deleteBranch(String appId, Env env, String clusterName, String namespaceName, String branchName, String operator) { namespaceBranchAPI.deleteBranch(appId, env, clusterName, namespaceName, branchName, operator); Tracer.logEvent(TracerEventType.DELETE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); } public ReleaseDTO merge(String appId, Env env, String clusterName, String namespaceName, String branchName, String title, String comment, boolean isEmergencyPublish, boolean deleteBranch) { String operator = userInfoHolder.getUser().getUserId(); return merge(appId, env, clusterName, namespaceName, branchName, title, comment, isEmergencyPublish, deleteBranch, operator); } public ReleaseDTO merge(String appId, Env env, String clusterName, String namespaceName, String branchName, String title, String comment, boolean isEmergencyPublish, boolean deleteBranch, String operator) { ItemChangeSets changeSets = calculateBranchChangeSet(appId, env, clusterName, namespaceName, branchName, operator); ReleaseDTO mergedResult = releaseService.updateAndPublish(appId, env, clusterName, namespaceName, title, comment, branchName, isEmergencyPublish, deleteBranch, changeSets); Tracer.logEvent(TracerEventType.MERGE_GRAY_RELEASE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); return mergedResult; } private ItemChangeSets calculateBranchChangeSet(String appId, Env env, String clusterName, String namespaceName, String branchName, String operator) { NamespaceBO parentNamespace = namespaceService.loadNamespaceBO(appId, env, clusterName, namespaceName); if (parentNamespace == null) { throw new BadRequestException("base namespace not existed"); } if (parentNamespace.getItemModifiedCnt() > 0) { throw new BadRequestException("Merge operation failed. Because master has modified items"); } List<ItemDTO> masterItems = itemService.findItems(appId, env, clusterName, namespaceName); List<ItemDTO> branchItems = itemService.findItems(appId, env, branchName, namespaceName); ItemChangeSets changeSets = itemsComparator.compareIgnoreBlankAndCommentItem(parentNamespace.getBaseInfo().getId(), masterItems, branchItems); changeSets.setDeleteItems(Collections.emptyList()); changeSets.setDataChangeLastModifiedBy(operator); return changeSets; } public NamespaceDTO findBranchBaseInfo(String appId, Env env, String clusterName, String namespaceName) { return namespaceBranchAPI.findBranch(appId, env, clusterName, namespaceName); } public NamespaceBO findBranch(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespaceDTO = findBranchBaseInfo(appId, env, clusterName, namespaceName); if (namespaceDTO == null) { return null; } return namespaceService.loadNamespaceBO(appId, env, namespaceDTO.getClusterName(), namespaceName); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.vo; /** * @author Jason Song(song_s@ctrip.com) */ public class Organization { private String orgId; private String orgName; public String getOrgId() { return orgId; } public void setOrgId(String orgId) { this.orgId = orgId; } public String getOrgName() { return orgName; } public void setOrgName(String orgName) { this.orgName = orgName; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.vo; /** * @author Jason Song(song_s@ctrip.com) */ public class Organization { private String orgId; private String orgName; public String getOrgId() { return orgId; } public void setOrgId(String orgId) { this.orgId = orgId; } public String getOrgName() { return orgName; } public void setOrgName(String orgName) { this.orgName = orgName; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.grayReleaseRule; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gson.Gson; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.GrayReleaseRuleRepository; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO; import com.ctrip.framework.apollo.core.ConfigConsts; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; 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.spy; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ @RunWith(MockitoJUnitRunner.class) public class GrayReleaseRulesHolderTest { private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); private GrayReleaseRulesHolder grayReleaseRulesHolder; @Mock private BizConfig bizConfig; @Mock private GrayReleaseRuleRepository grayReleaseRuleRepository; private static final Gson GSON = new Gson(); private AtomicLong idCounter; @Before public void setUp() throws Exception { grayReleaseRulesHolder = spy(new GrayReleaseRulesHolder()); ReflectionTestUtils.setField(grayReleaseRulesHolder, "bizConfig", bizConfig); ReflectionTestUtils.setField(grayReleaseRulesHolder, "grayReleaseRuleRepository", grayReleaseRuleRepository); idCounter = new AtomicLong(); } @Test public void testScanGrayReleaseRules() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; String anotherNamespaceName = "anotherNamespaceName"; Long someReleaseId = 1L; int activeBranchStatus = NamespaceBranchStatus.ACTIVE; String someClientAppId = "clientAppId1"; String someClientIp = "1.1.1.1"; String anotherClientAppId = "clientAppId2"; String anotherClientIp = "2.2.2.2"; GrayReleaseRule someRule = assembleGrayReleaseRule(someAppId, someClusterName, someNamespaceName, Lists.newArrayList(assembleRuleItem(someClientAppId, Sets.newHashSet (someClientIp))), someReleaseId, activeBranchStatus); when(bizConfig.grayReleaseRuleScanInterval()).thenReturn(30); when(grayReleaseRuleRepository.findFirst500ByIdGreaterThanOrderByIdAsc(0L)).thenReturn(Lists .newArrayList(someRule)); //scan rules grayReleaseRulesHolder.afterPropertiesSet(); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId.toUpperCase(), someClientIp, someAppId.toUpperCase(), someClusterName, someNamespaceName.toUpperCase())); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(someClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(anotherClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(anotherClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, someNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId.toUpperCase(), someClientIp, someNamespaceName.toUpperCase())); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, anotherNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, anotherNamespaceName)); GrayReleaseRule anotherRule = assembleGrayReleaseRule(someAppId, someClusterName, someNamespaceName, Lists.newArrayList(assembleRuleItem(anotherClientAppId, Sets.newHashSet (anotherClientIp))), someReleaseId, activeBranchStatus); when(grayReleaseRuleRepository.findByAppIdAndClusterNameAndNamespaceName(someAppId, someClusterName, someNamespaceName)).thenReturn(Lists.newArrayList(anotherRule)); //send message grayReleaseRulesHolder.handleMessage(assembleReleaseMessage(someAppId, someClusterName, someNamespaceName), Topics.APOLLO_RELEASE_TOPIC); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (anotherClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, anotherNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, someClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, anotherNamespaceName)); } private GrayReleaseRule assembleGrayReleaseRule(String appId, String clusterName, String namespaceName, List<GrayReleaseRuleItemDTO> ruleItems, long releaseId, int branchStatus) { GrayReleaseRule rule = new GrayReleaseRule(); rule.setId(idCounter.incrementAndGet()); rule.setAppId(appId); rule.setClusterName(clusterName); rule.setNamespaceName(namespaceName); rule.setBranchName("someBranch"); rule.setRules(GSON.toJson(ruleItems)); rule.setReleaseId(releaseId); rule.setBranchStatus(branchStatus); return rule; } private GrayReleaseRuleItemDTO assembleRuleItem(String clientAppId, Set<String> clientIpList) { return new GrayReleaseRuleItemDTO(clientAppId, clientIpList); } private ReleaseMessage assembleReleaseMessage(String appId, String clusterName, String namespaceName) { String message = STRING_JOINER.join(appId, clusterName, namespaceName); ReleaseMessage releaseMessage = new ReleaseMessage(message); return releaseMessage; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.grayReleaseRule; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gson.Gson; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.GrayReleaseRuleRepository; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO; import com.ctrip.framework.apollo.core.ConfigConsts; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; 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.spy; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ @RunWith(MockitoJUnitRunner.class) public class GrayReleaseRulesHolderTest { private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); private GrayReleaseRulesHolder grayReleaseRulesHolder; @Mock private BizConfig bizConfig; @Mock private GrayReleaseRuleRepository grayReleaseRuleRepository; private static final Gson GSON = new Gson(); private AtomicLong idCounter; @Before public void setUp() throws Exception { grayReleaseRulesHolder = spy(new GrayReleaseRulesHolder()); ReflectionTestUtils.setField(grayReleaseRulesHolder, "bizConfig", bizConfig); ReflectionTestUtils.setField(grayReleaseRulesHolder, "grayReleaseRuleRepository", grayReleaseRuleRepository); idCounter = new AtomicLong(); } @Test public void testScanGrayReleaseRules() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; String anotherNamespaceName = "anotherNamespaceName"; Long someReleaseId = 1L; int activeBranchStatus = NamespaceBranchStatus.ACTIVE; String someClientAppId = "clientAppId1"; String someClientIp = "1.1.1.1"; String anotherClientAppId = "clientAppId2"; String anotherClientIp = "2.2.2.2"; GrayReleaseRule someRule = assembleGrayReleaseRule(someAppId, someClusterName, someNamespaceName, Lists.newArrayList(assembleRuleItem(someClientAppId, Sets.newHashSet (someClientIp))), someReleaseId, activeBranchStatus); when(bizConfig.grayReleaseRuleScanInterval()).thenReturn(30); when(grayReleaseRuleRepository.findFirst500ByIdGreaterThanOrderByIdAsc(0L)).thenReturn(Lists .newArrayList(someRule)); //scan rules grayReleaseRulesHolder.afterPropertiesSet(); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId.toUpperCase(), someClientIp, someAppId.toUpperCase(), someClusterName, someNamespaceName.toUpperCase())); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(someClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(anotherClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(anotherClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, someNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId.toUpperCase(), someClientIp, someNamespaceName.toUpperCase())); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, anotherNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, anotherNamespaceName)); GrayReleaseRule anotherRule = assembleGrayReleaseRule(someAppId, someClusterName, someNamespaceName, Lists.newArrayList(assembleRuleItem(anotherClientAppId, Sets.newHashSet (anotherClientIp))), someReleaseId, activeBranchStatus); when(grayReleaseRuleRepository.findByAppIdAndClusterNameAndNamespaceName(someAppId, someClusterName, someNamespaceName)).thenReturn(Lists.newArrayList(anotherRule)); //send message grayReleaseRulesHolder.handleMessage(assembleReleaseMessage(someAppId, someClusterName, someNamespaceName), Topics.APOLLO_RELEASE_TOPIC); assertNull(grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (someClientAppId, someClientIp, someAppId, someClusterName, someNamespaceName)); assertEquals(someReleaseId, grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule (anotherClientAppId, anotherClientIp, someAppId, someClusterName, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(someClientAppId, someClientIp, anotherNamespaceName)); assertTrue(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, someClientIp, someNamespaceName)); assertFalse(grayReleaseRulesHolder.hasGrayReleaseRule(anotherClientAppId, anotherClientIp, anotherNamespaceName)); } private GrayReleaseRule assembleGrayReleaseRule(String appId, String clusterName, String namespaceName, List<GrayReleaseRuleItemDTO> ruleItems, long releaseId, int branchStatus) { GrayReleaseRule rule = new GrayReleaseRule(); rule.setId(idCounter.incrementAndGet()); rule.setAppId(appId); rule.setClusterName(clusterName); rule.setNamespaceName(namespaceName); rule.setBranchName("someBranch"); rule.setRules(GSON.toJson(ruleItems)); rule.setReleaseId(releaseId); rule.setBranchStatus(branchStatus); return rule; } private GrayReleaseRuleItemDTO assembleRuleItem(String clientAppId, Set<String> clientIpList) { return new GrayReleaseRuleItemDTO(clientAppId, clientIpList); } private ReleaseMessage assembleReleaseMessage(String appId, String clusterName, String namespaceName) { String message = STRING_JOINER.join(appId, clusterName, namespaceName); ReleaseMessage releaseMessage = new ReleaseMessage(message); return releaseMessage; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.adminservice.controller; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.Namespace; 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.common.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController public class NamespaceLockController { private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final BizConfig bizConfig; public NamespaceLockController( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final BizConfig bizConfig) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.bizConfig = bizConfig; } @GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock") public NamespaceLockDTO getNamespaceLockOwner(@PathVariable String appId, @PathVariable String clusterName, @PathVariable String namespaceName) { Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException("namespace not exist."); } if (bizConfig.isNamespaceLockSwitchOff()) { return null; } NamespaceLock lock = namespaceLockService.findLock(namespace.getId()); if (lock == null) { return null; } return BeanUtils.transform(NamespaceLockDTO.class, lock); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.adminservice.controller; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.Namespace; 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.common.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController public class NamespaceLockController { private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final BizConfig bizConfig; public NamespaceLockController( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final BizConfig bizConfig) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.bizConfig = bizConfig; } @GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock") public NamespaceLockDTO getNamespaceLockOwner(@PathVariable String appId, @PathVariable String clusterName, @PathVariable String namespaceName) { Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException("namespace not exist."); } if (bizConfig.isNamespaceLockSwitchOff()) { return null; } NamespaceLock lock = namespaceLockService.findLock(namespace.getId()); if (lock == null) { return null; } return BeanUtils.transform(NamespaceLockDTO.class, lock); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/main/java/com/ctrip/framework/foundation/internals/DefaultProviderManager.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.internals; import java.util.LinkedHashMap; import java.util.Map; import com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider; import com.ctrip.framework.foundation.internals.provider.DefaultNetworkProvider; import com.ctrip.framework.foundation.internals.provider.DefaultServerProvider; import com.ctrip.framework.foundation.spi.ProviderManager; import com.ctrip.framework.foundation.spi.provider.Provider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DefaultProviderManager implements ProviderManager { private static final Logger logger = LoggerFactory.getLogger(DefaultProviderManager.class); private Map<Class<? extends Provider>, Provider> m_providers = new LinkedHashMap<>(); public DefaultProviderManager() { // Load per-application configuration, like app id, from classpath://META-INF/app.properties Provider applicationProvider = new DefaultApplicationProvider(); applicationProvider.initialize(); register(applicationProvider); // Load network parameters Provider networkProvider = new DefaultNetworkProvider(); networkProvider.initialize(); register(networkProvider); // Load environment (fat, fws, uat, prod ...) and dc, from /opt/settings/server.properties, JVM property and/or OS // environment variables. Provider serverProvider = new DefaultServerProvider(); serverProvider.initialize(); register(serverProvider); } public synchronized void register(Provider provider) { m_providers.put(provider.getType(), provider); } @Override @SuppressWarnings("unchecked") public <T extends Provider> T provider(Class<T> clazz) { Provider provider = m_providers.get(clazz); if (provider != null) { return (T) provider; } logger.error("No provider [{}] found in DefaultProviderManager, please make sure it is registered in DefaultProviderManager ", clazz.getName()); return (T) NullProviderManager.provider; } @Override public String getProperty(String name, String defaultValue) { for (Provider provider : m_providers.values()) { String value = provider.getProperty(name, null); if (value != null) { return value; } } return defaultValue; } @Override public String toString() { StringBuilder sb = new StringBuilder(512); if (null != m_providers) { for (Map.Entry<Class<? extends Provider>, Provider> entry : m_providers.entrySet()) { sb.append(entry.getValue()).append("\n"); } } sb.append("(DefaultProviderManager)").append("\n"); return sb.toString(); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.internals; import java.util.LinkedHashMap; import java.util.Map; import com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider; import com.ctrip.framework.foundation.internals.provider.DefaultNetworkProvider; import com.ctrip.framework.foundation.internals.provider.DefaultServerProvider; import com.ctrip.framework.foundation.spi.ProviderManager; import com.ctrip.framework.foundation.spi.provider.Provider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DefaultProviderManager implements ProviderManager { private static final Logger logger = LoggerFactory.getLogger(DefaultProviderManager.class); private Map<Class<? extends Provider>, Provider> m_providers = new LinkedHashMap<>(); public DefaultProviderManager() { // Load per-application configuration, like app id, from classpath://META-INF/app.properties Provider applicationProvider = new DefaultApplicationProvider(); applicationProvider.initialize(); register(applicationProvider); // Load network parameters Provider networkProvider = new DefaultNetworkProvider(); networkProvider.initialize(); register(networkProvider); // Load environment (fat, fws, uat, prod ...) and dc, from /opt/settings/server.properties, JVM property and/or OS // environment variables. Provider serverProvider = new DefaultServerProvider(); serverProvider.initialize(); register(serverProvider); } public synchronized void register(Provider provider) { m_providers.put(provider.getType(), provider); } @Override @SuppressWarnings("unchecked") public <T extends Provider> T provider(Class<T> clazz) { Provider provider = m_providers.get(clazz); if (provider != null) { return (T) provider; } logger.error("No provider [{}] found in DefaultProviderManager, please make sure it is registered in DefaultProviderManager ", clazz.getName()); return (T) NullProviderManager.provider; } @Override public String getProperty(String name, String defaultValue) { for (Provider provider : m_providers.values()) { String value = provider.getProperty(name, null); if (value != null) { return value; } } return defaultValue; } @Override public String toString() { StringBuilder sb = new StringBuilder(512); if (null != m_providers) { for (Map.Entry<Class<? extends Provider>, Provider> entry : m_providers.entrySet()) { sb.append(entry.getValue()).append("\n"); } } sb.append("(DefaultProviderManager)").append("\n"); return sb.toString(); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceEnvRolesAssignedUsers.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.portal.environment.Env; public class NamespaceEnvRolesAssignedUsers extends NamespaceRolesAssignedUsers { private String env; public Env getEnv() { return Env.valueOf(env); } public void setEnv(Env env) { this.env = env.toString(); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.portal.environment.Env; public class NamespaceEnvRolesAssignedUsers extends NamespaceRolesAssignedUsers { private String env; public Env getEnv() { return Env.valueOf(env); } public void setEnv(Env env) { this.env = env.toString(); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceLockService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.NamespaceLock; import com.ctrip.framework.apollo.biz.repository.NamespaceLockRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service public class NamespaceLockService { private final NamespaceLockRepository namespaceLockRepository; public NamespaceLockService(final NamespaceLockRepository namespaceLockRepository) { this.namespaceLockRepository = namespaceLockRepository; } public NamespaceLock findLock(Long namespaceId){ return namespaceLockRepository.findByNamespaceId(namespaceId); } @Transactional public NamespaceLock tryLock(NamespaceLock lock){ return namespaceLockRepository.save(lock); } @Transactional public void unlock(Long namespaceId){ namespaceLockRepository.deleteByNamespaceId(namespaceId); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.NamespaceLock; import com.ctrip.framework.apollo.biz.repository.NamespaceLockRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service public class NamespaceLockService { private final NamespaceLockRepository namespaceLockRepository; public NamespaceLockService(final NamespaceLockRepository namespaceLockRepository) { this.namespaceLockRepository = namespaceLockRepository; } public NamespaceLock findLock(Long namespaceId){ return namespaceLockRepository.findByNamespaceId(namespaceId); } @Transactional public NamespaceLock tryLock(NamespaceLock lock){ return namespaceLockRepository.save(lock); } @Transactional public void unlock(Long namespaceId){ namespaceLockRepository.deleteByNamespaceId(namespaceId); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/AccessKeyDTO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.dto; public class AccessKeyDTO extends BaseDTO { private Long id; private String secret; private String appId; private Boolean enabled; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getSecret() { return secret; } public void setSecret(String secret) { this.secret = secret; } public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.dto; public class AccessKeyDTO extends BaseDTO { private Long id; private String secret; private String appId; private Boolean enabled; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getSecret() { return secret; } public void setSecret(String secret) { this.secret = secret; } public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AccessKeyService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.AccessKey; import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.repository.AccessKeyRepository; import com.ctrip.framework.apollo.common.exception.BadRequestException; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** * @author nisiyong */ @Service public class AccessKeyService { private static final int ACCESSKEY_COUNT_LIMIT = 5; private final AccessKeyRepository accessKeyRepository; private final AuditService auditService; public AccessKeyService( AccessKeyRepository accessKeyRepository, AuditService auditService) { this.accessKeyRepository = accessKeyRepository; this.auditService = auditService; } public List<AccessKey> findByAppId(String appId) { return accessKeyRepository.findByAppId(appId); } @Transactional public AccessKey create(String appId, AccessKey entity) { long count = accessKeyRepository.countByAppId(appId); if (count >= ACCESSKEY_COUNT_LIMIT) { throw new BadRequestException("AccessKeys count limit exceeded"); } entity.setId(0L); entity.setAppId(appId); entity.setDataChangeLastModifiedBy(entity.getDataChangeCreatedBy()); AccessKey accessKey = accessKeyRepository.save(entity); auditService.audit(AccessKey.class.getSimpleName(), accessKey.getId(), Audit.OP.INSERT, accessKey.getDataChangeCreatedBy()); return accessKey; } @Transactional public AccessKey update(String appId, AccessKey entity) { long id = entity.getId(); String operator = entity.getDataChangeLastModifiedBy(); AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id); if (accessKey == null) { throw new BadRequestException("AccessKey not exist"); } accessKey.setEnabled(entity.isEnabled()); accessKey.setDataChangeLastModifiedBy(operator); accessKeyRepository.save(accessKey); auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.UPDATE, operator); return accessKey; } @Transactional public void delete(String appId, long id, String operator) { AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id); if (accessKey == null) { throw new BadRequestException("AccessKey not exist"); } if (accessKey.isEnabled()) { throw new BadRequestException("AccessKey should disable first"); } accessKey.setDeleted(Boolean.TRUE); accessKey.setDataChangeLastModifiedBy(operator); accessKeyRepository.save(accessKey); auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.DELETE, operator); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; import com.ctrip.framework.apollo.biz.entity.AccessKey; import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.repository.AccessKeyRepository; import com.ctrip.framework.apollo.common.exception.BadRequestException; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** * @author nisiyong */ @Service public class AccessKeyService { private static final int ACCESSKEY_COUNT_LIMIT = 5; private final AccessKeyRepository accessKeyRepository; private final AuditService auditService; public AccessKeyService( AccessKeyRepository accessKeyRepository, AuditService auditService) { this.accessKeyRepository = accessKeyRepository; this.auditService = auditService; } public List<AccessKey> findByAppId(String appId) { return accessKeyRepository.findByAppId(appId); } @Transactional public AccessKey create(String appId, AccessKey entity) { long count = accessKeyRepository.countByAppId(appId); if (count >= ACCESSKEY_COUNT_LIMIT) { throw new BadRequestException("AccessKeys count limit exceeded"); } entity.setId(0L); entity.setAppId(appId); entity.setDataChangeLastModifiedBy(entity.getDataChangeCreatedBy()); AccessKey accessKey = accessKeyRepository.save(entity); auditService.audit(AccessKey.class.getSimpleName(), accessKey.getId(), Audit.OP.INSERT, accessKey.getDataChangeCreatedBy()); return accessKey; } @Transactional public AccessKey update(String appId, AccessKey entity) { long id = entity.getId(); String operator = entity.getDataChangeLastModifiedBy(); AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id); if (accessKey == null) { throw new BadRequestException("AccessKey not exist"); } accessKey.setEnabled(entity.isEnabled()); accessKey.setDataChangeLastModifiedBy(operator); accessKeyRepository.save(accessKey); auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.UPDATE, operator); return accessKey; } @Transactional public void delete(String appId, long id, String operator) { AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id); if (accessKey == null) { throw new BadRequestException("AccessKey not exist"); } if (accessKey.isEnabled()) { throw new BadRequestException("AccessKey should disable first"); } accessKey.setDeleted(Boolean.TRUE); accessKey.setDataChangeLastModifiedBy(operator); accessKeyRepository.save(accessKey); auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.DELETE, operator); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/condition/OnProfileCondition.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.condition; import com.google.common.collect.Sets; import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.ConditionContext; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.util.MultiValueMap; import java.util.Collections; import java.util.List; import java.util.Set; /** * @author Jason Song(song_s@ctrip.com) */ public class OnProfileCondition implements Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { Set<String> activeProfiles = Sets.newHashSet(context.getEnvironment().getActiveProfiles()); Set<String> requiredActiveProfiles = retrieveAnnotatedProfiles(metadata, ConditionalOnProfile.class.getName()); Set<String> requiredInactiveProfiles = retrieveAnnotatedProfiles(metadata, ConditionalOnMissingProfile.class .getName()); return Sets.difference(requiredActiveProfiles, activeProfiles).isEmpty() && Sets.intersection(requiredInactiveProfiles, activeProfiles).isEmpty(); } private Set<String> retrieveAnnotatedProfiles(AnnotatedTypeMetadata metadata, String annotationType) { if (!metadata.isAnnotated(annotationType)) { return Collections.emptySet(); } MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationType); if (attributes == null) { return Collections.emptySet(); } Set<String> profiles = Sets.newHashSet(); List<?> values = attributes.get("value"); if (values != null) { for (Object value : values) { if (value instanceof String[]) { Collections.addAll(profiles, (String[]) value); } else { profiles.add((String) value); } } } return profiles; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.condition; import com.google.common.collect.Sets; import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.ConditionContext; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.util.MultiValueMap; import java.util.Collections; import java.util.List; import java.util.Set; /** * @author Jason Song(song_s@ctrip.com) */ public class OnProfileCondition implements Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { Set<String> activeProfiles = Sets.newHashSet(context.getEnvironment().getActiveProfiles()); Set<String> requiredActiveProfiles = retrieveAnnotatedProfiles(metadata, ConditionalOnProfile.class.getName()); Set<String> requiredInactiveProfiles = retrieveAnnotatedProfiles(metadata, ConditionalOnMissingProfile.class .getName()); return Sets.difference(requiredActiveProfiles, activeProfiles).isEmpty() && Sets.intersection(requiredInactiveProfiles, activeProfiles).isEmpty(); } private Set<String> retrieveAnnotatedProfiles(AnnotatedTypeMetadata metadata, String annotationType) { if (!metadata.isAnnotated(annotationType)) { return Collections.emptySet(); } MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationType); if (attributes == null) { return Collections.emptySet(); } Set<String> profiles = Sets.newHashSet(); List<?> values = attributes.get("value"); if (values != null) { for (Object value : values) { if (value instanceof String[]) { Collections.addAll(profiles, (String[]) value); } else { profiles.add((String) value); } } } return profiles; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-openapi/src/main/java/com/ctrip/framework/apollo/openapi/dto/NamespaceReleaseDTO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class NamespaceReleaseDTO { private String releaseTitle; private String releaseComment; private String releasedBy; private boolean isEmergencyPublish; public String getReleaseTitle() { return releaseTitle; } public void setReleaseTitle(String releaseTitle) { this.releaseTitle = releaseTitle; } public String getReleaseComment() { return releaseComment; } public void setReleaseComment(String releaseComment) { this.releaseComment = releaseComment; } public String getReleasedBy() { return releasedBy; } public void setReleasedBy(String releasedBy) { this.releasedBy = releasedBy; } public boolean isEmergencyPublish() { return isEmergencyPublish; } public void setEmergencyPublish(boolean emergencyPublish) { isEmergencyPublish = emergencyPublish; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class NamespaceReleaseDTO { private String releaseTitle; private String releaseComment; private String releasedBy; private boolean isEmergencyPublish; public String getReleaseTitle() { return releaseTitle; } public void setReleaseTitle(String releaseTitle) { this.releaseTitle = releaseTitle; } public String getReleaseComment() { return releaseComment; } public void setReleaseComment(String releaseComment) { this.releaseComment = releaseComment; } public String getReleasedBy() { return releasedBy; } public void setReleasedBy(String releasedBy) { this.releasedBy = releasedBy; } public boolean isEmergencyPublish() { return isEmergencyPublish; } public void setEmergencyPublish(boolean emergencyPublish) { isEmergencyPublish = emergencyPublish; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/datasource/package-info.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * 携程内部的dal,第三方公司可替换实现 */ package com.ctrip.framework.apollo.common.datasource;
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * 携程内部的dal,第三方公司可替换实现 */ package com.ctrip.framework.apollo.common.datasource;
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserService; import java.security.Principal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.core.oidc.StandardClaimNames; import org.springframework.security.oauth2.core.oidc.user.OidcUser; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.util.StringUtils; /** * @author vdisk <vdisk@foxmail.com> */ public class OidcUserInfoHolder implements UserInfoHolder { private static final Logger log = LoggerFactory.getLogger(OidcUserInfoHolder.class); private final UserService userService; public OidcUserInfoHolder(UserService userService) { this.userService = userService; } @Override public UserInfo getUser() { UserInfo userInfo = this.getUserInternal(); if (StringUtils.hasText(userInfo.getName())) { return userInfo; } UserInfo userInfoFound = this.userService.findByUserId(userInfo.getUserId()); if (userInfoFound != null) { return userInfoFound; } return userInfo; } private UserInfo getUserInternal() { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof OidcUser) { UserInfo userInfo = new UserInfo(); OidcUser oidcUser = (OidcUser) principal; userInfo.setUserId(oidcUser.getSubject()); userInfo.setName(oidcUser.getPreferredUsername()); userInfo.setEmail(oidcUser.getEmail()); return userInfo; } if (principal instanceof Jwt) { Jwt jwt = (Jwt) principal; UserInfo userInfo = new UserInfo(); userInfo.setUserId(jwt.getSubject()); return userInfo; } log.debug("principal is neither oidcUser nor jwt, principal=[{}]", principal); if (principal instanceof OAuth2User) { UserInfo userInfo = new UserInfo(); OAuth2User oAuth2User = (OAuth2User) principal; userInfo.setUserId(oAuth2User.getName()); userInfo.setName(oAuth2User.getAttribute(StandardClaimNames.PREFERRED_USERNAME)); userInfo.setEmail(oAuth2User.getAttribute(StandardClaimNames.EMAIL)); return userInfo; } if (principal instanceof Principal) { UserInfo userInfo = new UserInfo(); Principal userPrincipal = (Principal) principal; userInfo.setUserId(userPrincipal.getName()); return userInfo; } UserInfo userInfo = new UserInfo(); userInfo.setUserId(String.valueOf(principal)); return userInfo; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserService; import java.security.Principal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.core.oidc.StandardClaimNames; import org.springframework.security.oauth2.core.oidc.user.OidcUser; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.util.StringUtils; /** * @author vdisk <vdisk@foxmail.com> */ public class OidcUserInfoHolder implements UserInfoHolder { private static final Logger log = LoggerFactory.getLogger(OidcUserInfoHolder.class); private final UserService userService; public OidcUserInfoHolder(UserService userService) { this.userService = userService; } @Override public UserInfo getUser() { UserInfo userInfo = this.getUserInternal(); if (StringUtils.hasText(userInfo.getName())) { return userInfo; } UserInfo userInfoFound = this.userService.findByUserId(userInfo.getUserId()); if (userInfoFound != null) { return userInfoFound; } return userInfo; } private UserInfo getUserInternal() { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof OidcUser) { UserInfo userInfo = new UserInfo(); OidcUser oidcUser = (OidcUser) principal; userInfo.setUserId(oidcUser.getSubject()); userInfo.setName(oidcUser.getPreferredUsername()); userInfo.setEmail(oidcUser.getEmail()); return userInfo; } if (principal instanceof Jwt) { Jwt jwt = (Jwt) principal; UserInfo userInfo = new UserInfo(); userInfo.setUserId(jwt.getSubject()); return userInfo; } log.debug("principal is neither oidcUser nor jwt, principal=[{}]", principal); if (principal instanceof OAuth2User) { UserInfo userInfo = new UserInfo(); OAuth2User oAuth2User = (OAuth2User) principal; userInfo.setUserId(oAuth2User.getName()); userInfo.setName(oAuth2User.getAttribute(StandardClaimNames.PREFERRED_USERNAME)); userInfo.setEmail(oAuth2User.getAttribute(StandardClaimNames.EMAIL)); return userInfo; } if (principal instanceof Principal) { UserInfo userInfo = new UserInfo(); Principal userPrincipal = (Principal) principal; userInfo.setUserId(userPrincipal.getName()); return userInfo; } UserInfo userInfo = new UserInfo(); userInfo.setUserId(String.valueOf(principal)); return userInfo; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/util/AccessKeyUtil.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.configservice.util; import com.ctrip.framework.apollo.configservice.service.AccessKeyServiceWithCache; import com.ctrip.framework.apollo.core.signature.Signature; import com.google.common.base.Strings; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Component; /** * @author nisiyong */ @Component public class AccessKeyUtil { private static final String URL_SEPARATOR = "/"; private static final String URL_CONFIGS_PREFIX = "/configs/"; private static final String URL_CONFIGFILES_JSON_PREFIX = "/configfiles/json/"; private static final String URL_CONFIGFILES_PREFIX = "/configfiles/"; private static final String URL_NOTIFICATIONS_PREFIX = "/notifications/v2"; private final AccessKeyServiceWithCache accessKeyServiceWithCache; public AccessKeyUtil(AccessKeyServiceWithCache accessKeyServiceWithCache) { this.accessKeyServiceWithCache = accessKeyServiceWithCache; } public List<String> findAvailableSecret(String appId) { return accessKeyServiceWithCache.getAvailableSecrets(appId); } public String extractAppIdFromRequest(HttpServletRequest request) { String appId = null; String servletPath = request.getServletPath(); if (StringUtils.startsWith(servletPath, URL_CONFIGS_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGS_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_CONFIGFILES_JSON_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGFILES_JSON_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_CONFIGFILES_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGFILES_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_NOTIFICATIONS_PREFIX)) { appId = request.getParameter("appId"); } return appId; } public String buildSignature(String path, String query, String timestampString, String secret) { String pathWithQuery = path; if (!Strings.isNullOrEmpty(query)) { pathWithQuery += "?" + query; } return Signature.signature(timestampString, pathWithQuery, secret); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.configservice.util; import com.ctrip.framework.apollo.configservice.service.AccessKeyServiceWithCache; import com.ctrip.framework.apollo.core.signature.Signature; import com.google.common.base.Strings; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Component; /** * @author nisiyong */ @Component public class AccessKeyUtil { private static final String URL_SEPARATOR = "/"; private static final String URL_CONFIGS_PREFIX = "/configs/"; private static final String URL_CONFIGFILES_JSON_PREFIX = "/configfiles/json/"; private static final String URL_CONFIGFILES_PREFIX = "/configfiles/"; private static final String URL_NOTIFICATIONS_PREFIX = "/notifications/v2"; private final AccessKeyServiceWithCache accessKeyServiceWithCache; public AccessKeyUtil(AccessKeyServiceWithCache accessKeyServiceWithCache) { this.accessKeyServiceWithCache = accessKeyServiceWithCache; } public List<String> findAvailableSecret(String appId) { return accessKeyServiceWithCache.getAvailableSecrets(appId); } public String extractAppIdFromRequest(HttpServletRequest request) { String appId = null; String servletPath = request.getServletPath(); if (StringUtils.startsWith(servletPath, URL_CONFIGS_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGS_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_CONFIGFILES_JSON_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGFILES_JSON_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_CONFIGFILES_PREFIX)) { appId = StringUtils.substringBetween(servletPath, URL_CONFIGFILES_PREFIX, URL_SEPARATOR); } else if (StringUtils.startsWith(servletPath, URL_NOTIFICATIONS_PREFIX)) { appId = request.getParameter("appId"); } return appId; } public String buildSignature(String path, String query, String timestampString, String secret) { String pathWithQuery = path; if (!Strings.isNullOrEmpty(query)) { pathWithQuery += "?" + query; } return Signature.signature(timestampString, pathWithQuery, secret); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.po.UserPO; import com.ctrip.framework.apollo.portal.repository.UserRepository; import java.util.ArrayList; import java.util.Base64; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.crypto.password.DelegatingPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.JdbcUserDetailsManager; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; /** * @author vdisk <vdisk@foxmail.com> */ public class OidcLocalUserServiceImpl implements OidcLocalUserService { private final Collection<? extends GrantedAuthority> authorities = Collections .singletonList(new SimpleGrantedAuthority("ROLE_USER")); private final PasswordEncoder placeholderDelegatingPasswordEncoder = new DelegatingPasswordEncoder( PlaceholderPasswordEncoder.ENCODING_ID, Collections .singletonMap(PlaceholderPasswordEncoder.ENCODING_ID, new PlaceholderPasswordEncoder())); private final JdbcUserDetailsManager userDetailsManager; private final UserRepository userRepository; public OidcLocalUserServiceImpl( JdbcUserDetailsManager userDetailsManager, UserRepository userRepository) { this.userDetailsManager = userDetailsManager; this.userRepository = userRepository; } @Transactional(rollbackFor = Exception.class) @Override public void createLocalUser(UserInfo newUserInfo) { UserDetails user = new User(newUserInfo.getUserId(), this.placeholderDelegatingPasswordEncoder.encode(""), authorities); userDetailsManager.createUser(user); this.updateUserInfoInternal(newUserInfo); } private void updateUserInfoInternal(UserInfo newUserInfo) { UserPO managedUser = userRepository.findByUsername(newUserInfo.getUserId()); if (!StringUtils.isBlank(newUserInfo.getEmail())) { managedUser.setEmail(newUserInfo.getEmail()); } if (!StringUtils.isBlank(newUserInfo.getName())) { managedUser.setUserDisplayName(newUserInfo.getName()); } userRepository.save(managedUser); } @Transactional(rollbackFor = Exception.class) @Override public void updateUserInfo(UserInfo newUserInfo) { this.updateUserInfoInternal(newUserInfo); } @Override public List<UserInfo> searchUsers(String keyword, int offset, int limit) { List<UserPO> users = this.findUsers(keyword); if (CollectionUtils.isEmpty(users)) { return Collections.emptyList(); } return users.stream().map(UserPO::toUserInfo) .collect(Collectors.toList()); } private List<UserPO> findUsers(String keyword) { if (StringUtils.isEmpty(keyword)) { return userRepository.findFirst20ByEnabled(1); } List<UserPO> users = new ArrayList<>(); List<UserPO> byUsername = userRepository .findByUsernameLikeAndEnabled("%" + keyword + "%", 1); List<UserPO> byUserDisplayName = userRepository .findByUserDisplayNameLikeAndEnabled("%" + keyword + "%", 1); if (!CollectionUtils.isEmpty(byUsername)) { users.addAll(byUsername); } if (!CollectionUtils.isEmpty(byUserDisplayName)) { users.addAll(byUserDisplayName); } return users; } @Override public UserInfo findByUserId(String userId) { UserPO userPO = userRepository.findByUsername(userId); return userPO == null ? null : userPO.toUserInfo(); } @Override public List<UserInfo> findByUserIds(List<String> userIds) { List<UserPO> users = userRepository.findByUsernameIn(userIds); if (CollectionUtils.isEmpty(users)) { return Collections.emptyList(); } return users.stream().map(UserPO::toUserInfo) .collect(Collectors.toList()); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.po.UserPO; import com.ctrip.framework.apollo.portal.repository.UserRepository; import java.util.ArrayList; import java.util.Base64; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.crypto.password.DelegatingPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.JdbcUserDetailsManager; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; /** * @author vdisk <vdisk@foxmail.com> */ public class OidcLocalUserServiceImpl implements OidcLocalUserService { private final Collection<? extends GrantedAuthority> authorities = Collections .singletonList(new SimpleGrantedAuthority("ROLE_USER")); private final PasswordEncoder placeholderDelegatingPasswordEncoder = new DelegatingPasswordEncoder( PlaceholderPasswordEncoder.ENCODING_ID, Collections .singletonMap(PlaceholderPasswordEncoder.ENCODING_ID, new PlaceholderPasswordEncoder())); private final JdbcUserDetailsManager userDetailsManager; private final UserRepository userRepository; public OidcLocalUserServiceImpl( JdbcUserDetailsManager userDetailsManager, UserRepository userRepository) { this.userDetailsManager = userDetailsManager; this.userRepository = userRepository; } @Transactional(rollbackFor = Exception.class) @Override public void createLocalUser(UserInfo newUserInfo) { UserDetails user = new User(newUserInfo.getUserId(), this.placeholderDelegatingPasswordEncoder.encode(""), authorities); userDetailsManager.createUser(user); this.updateUserInfoInternal(newUserInfo); } private void updateUserInfoInternal(UserInfo newUserInfo) { UserPO managedUser = userRepository.findByUsername(newUserInfo.getUserId()); if (!StringUtils.isBlank(newUserInfo.getEmail())) { managedUser.setEmail(newUserInfo.getEmail()); } if (!StringUtils.isBlank(newUserInfo.getName())) { managedUser.setUserDisplayName(newUserInfo.getName()); } userRepository.save(managedUser); } @Transactional(rollbackFor = Exception.class) @Override public void updateUserInfo(UserInfo newUserInfo) { this.updateUserInfoInternal(newUserInfo); } @Override public List<UserInfo> searchUsers(String keyword, int offset, int limit) { List<UserPO> users = this.findUsers(keyword); if (CollectionUtils.isEmpty(users)) { return Collections.emptyList(); } return users.stream().map(UserPO::toUserInfo) .collect(Collectors.toList()); } private List<UserPO> findUsers(String keyword) { if (StringUtils.isEmpty(keyword)) { return userRepository.findFirst20ByEnabled(1); } List<UserPO> users = new ArrayList<>(); List<UserPO> byUsername = userRepository .findByUsernameLikeAndEnabled("%" + keyword + "%", 1); List<UserPO> byUserDisplayName = userRepository .findByUserDisplayNameLikeAndEnabled("%" + keyword + "%", 1); if (!CollectionUtils.isEmpty(byUsername)) { users.addAll(byUsername); } if (!CollectionUtils.isEmpty(byUserDisplayName)) { users.addAll(byUserDisplayName); } return users; } @Override public UserInfo findByUserId(String userId) { UserPO userPO = userRepository.findByUsername(userId); return userPO == null ? null : userPO.toUserInfo(); } @Override public List<UserInfo> findByUserIds(List<String> userIds) { List<UserPO> users = userRepository.findByUsernameIn(userIds); if (CollectionUtils.isEmpty(users)) { return Collections.emptyList(); } return users.stream().map(UserPO::toUserInfo) .collect(Collectors.toList()); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/test/java/com/ctrip/framework/apollo/LocalPortalApplication.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class LocalPortalApplication { public static void main(String[] args) { new SpringApplicationBuilder(LocalPortalApplication.class).run(args); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication public class LocalPortalApplication { public static void main(String[] args) { new SpringApplicationBuilder(LocalPortalApplication.class).run(args); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.listener; 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.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.tracer.Tracer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import java.util.List; @Component public class CreationListener { private static Logger logger = LoggerFactory.getLogger(CreationListener.class); private final PortalSettings portalSettings; private final AdminServiceAPI.AppAPI appAPI; private final AdminServiceAPI.NamespaceAPI namespaceAPI; public CreationListener( final PortalSettings portalSettings, final AdminServiceAPI.AppAPI appAPI, final AdminServiceAPI.NamespaceAPI namespaceAPI) { this.portalSettings = portalSettings; this.appAPI = appAPI; this.namespaceAPI = namespaceAPI; } @EventListener public void onAppCreationEvent(AppCreationEvent event) { AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp()); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { appAPI.createApp(env, appDTO); } catch (Throwable e) { logger.error("Create app failed. appId = {}, env = {})", appDTO.getAppId(), env, e); Tracer.logError(String.format("Create app failed. appId = %s, env = %s", appDTO.getAppId(), env), e); } } } @EventListener public void onAppNamespaceCreationEvent(AppNamespaceCreationEvent event) { AppNamespaceDTO appNamespace = BeanUtils.transform(AppNamespaceDTO.class, event.getAppNamespace()); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { namespaceAPI.createAppNamespace(env, appNamespace); } catch (Throwable e) { logger.error("Create appNamespace failed. appId = {}, env = {}", appNamespace.getAppId(), env, e); Tracer.logError(String.format("Create appNamespace failed. appId = %s, env = %s", appNamespace.getAppId(), env), e); } } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.listener; 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.portal.environment.Env; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.tracer.Tracer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import java.util.List; @Component public class CreationListener { private static Logger logger = LoggerFactory.getLogger(CreationListener.class); private final PortalSettings portalSettings; private final AdminServiceAPI.AppAPI appAPI; private final AdminServiceAPI.NamespaceAPI namespaceAPI; public CreationListener( final PortalSettings portalSettings, final AdminServiceAPI.AppAPI appAPI, final AdminServiceAPI.NamespaceAPI namespaceAPI) { this.portalSettings = portalSettings; this.appAPI = appAPI; this.namespaceAPI = namespaceAPI; } @EventListener public void onAppCreationEvent(AppCreationEvent event) { AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp()); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { appAPI.createApp(env, appDTO); } catch (Throwable e) { logger.error("Create app failed. appId = {}, env = {})", appDTO.getAppId(), env, e); Tracer.logError(String.format("Create app failed. appId = %s, env = %s", appDTO.getAppId(), env), e); } } } @EventListener public void onAppNamespaceCreationEvent(AppNamespaceCreationEvent event) { AppNamespaceDTO appNamespace = BeanUtils.transform(AppNamespaceDTO.class, event.getAppNamespace()); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { namespaceAPI.createAppNamespace(env, appNamespace); } catch (Throwable e) { logger.error("Create appNamespace failed. appId = {}, env = {}", appNamespace.getAppId(), env, e); Tracer.logError(String.format("Create appNamespace failed. appId = %s, env = %s", appNamespace.getAppId(), env), e); } } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.repository; import com.ctrip.framework.apollo.portal.entity.po.RolePermission; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.Collection; import java.util.List; /** * @author Jason Song(song_s@ctrip.com) */ public interface RolePermissionRepository extends PagingAndSortingRepository<RolePermission, Long> { /** * find role permissions by role ids */ List<RolePermission> findByRoleIdIn(Collection<Long> roleId); @Modifying @Query("UPDATE RolePermission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") Integer batchDeleteByPermissionIds(List<Long> permissionIds, String operator); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.repository; import com.ctrip.framework.apollo.portal.entity.po.RolePermission; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.Collection; import java.util.List; /** * @author Jason Song(song_s@ctrip.com) */ public interface RolePermissionRepository extends PagingAndSortingRepository<RolePermission, Long> { /** * find role permissions by role ids */ List<RolePermission> findByRoleIdIn(Collection<Long> roleId); @Modifying @Query("UPDATE RolePermission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") Integer batchDeleteByPermissionIds(List<Long> permissionIds, String operator); }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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; public class AppRepositoryTest extends AbstractIntegrationTest{ @Autowired private AppRepository appRepository; @Test public void testCreate() { String appId = "someAppId"; String appName = "someAppName"; String ownerName = "someOwnerName"; String ownerEmail = "someOwnerName@ctrip.com"; App app = new App(); app.setAppId(appId); app.setName(appName); app.setOwnerName(ownerName); app.setOwnerEmail(ownerEmail); Assert.assertEquals(0, appRepository.count()); appRepository.save(app); Assert.assertEquals(1, appRepository.count()); } @Test public void testRemove() { String appId = "someAppId"; String appName = "someAppName"; String ownerName = "someOwnerName"; String ownerEmail = "someOwnerName@ctrip.com"; App app = new App(); app.setAppId(appId); app.setName(appName); app.setOwnerName(ownerName); app.setOwnerEmail(ownerEmail); Assert.assertEquals(0, appRepository.count()); appRepository.save(app); Assert.assertEquals(1, appRepository.count()); appRepository.deleteById(app.getId()); Assert.assertEquals(0, appRepository.count()); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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; public class AppRepositoryTest extends AbstractIntegrationTest{ @Autowired private AppRepository appRepository; @Test public void testCreate() { String appId = "someAppId"; String appName = "someAppName"; String ownerName = "someOwnerName"; String ownerEmail = "someOwnerName@ctrip.com"; App app = new App(); app.setAppId(appId); app.setName(appName); app.setOwnerName(ownerName); app.setOwnerEmail(ownerEmail); Assert.assertEquals(0, appRepository.count()); appRepository.save(app); Assert.assertEquals(1, appRepository.count()); } @Test public void testRemove() { String appId = "someAppId"; String appName = "someAppName"; String ownerName = "someOwnerName"; String ownerEmail = "someOwnerName@ctrip.com"; App app = new App(); app.setAppId(appId); app.setName(appName); app.setOwnerName(ownerName); app.setOwnerEmail(ownerEmail); Assert.assertEquals(0, appRepository.count()); appRepository.save(app); Assert.assertEquals(1, appRepository.count()); appRepository.deleteById(app.getId()); Assert.assertEquals(0, appRepository.count()); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatTransaction.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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); } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.enums.ConfigSourceType; import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.internals.AbstractConfig; import com.ctrip.framework.apollo.spi.ConfigFactory; import com.ctrip.framework.apollo.util.ConfigUtil; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigServiceTest { private static String someAppId; @Before public void setUp() throws Exception { someAppId = "someAppId"; MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil()); } @After public void tearDown() throws Exception { //as ConfigService is singleton, so we must manually clear its container ConfigService.reset(); MockInjector.reset(); } @Test public void testHackConfig() { String someNamespace = "hack"; String someKey = "first"; ConfigService.setConfig(new MockConfig(someNamespace)); Config config = ConfigService.getAppConfig(); assertEquals(someNamespace + ":" + someKey, config.getProperty(someKey, null)); assertEquals(null, config.getProperty("unknown", null)); } @Test public void testHackConfigFactory() throws Exception { String someKey = "someKey"; ConfigService.setConfigFactory(new MockConfigFactory()); Config config = ConfigService.getAppConfig(); assertEquals(ConfigConsts.NAMESPACE_APPLICATION + ":" + someKey, config.getProperty(someKey, null)); } @Test public void testMockConfigFactory() throws Exception { String someNamespace = "mock"; String someKey = "someKey"; MockInjector.setInstance(ConfigFactory.class, someNamespace, new MockConfigFactory()); Config config = ConfigService.getConfig(someNamespace); assertEquals(someNamespace + ":" + someKey, config.getProperty(someKey, null)); assertEquals(null, config.getProperty("unknown", null)); } @Test public void testMockConfigFactoryForConfigFile() throws Exception { String someNamespace = "mock"; ConfigFileFormat someConfigFileFormat = ConfigFileFormat.Properties; String someNamespaceFileName = String.format("%s.%s", someNamespace, someConfigFileFormat.getValue()); MockInjector.setInstance(ConfigFactory.class, someNamespaceFileName, new MockConfigFactory()); ConfigFile configFile = ConfigService.getConfigFile(someNamespace, someConfigFileFormat); assertEquals(someNamespaceFileName, configFile.getNamespace()); assertEquals(someNamespaceFileName + ":" + someConfigFileFormat.getValue(), configFile.getContent()); } private static class MockConfig extends AbstractConfig { private final String m_namespace; public MockConfig(String namespace) { m_namespace = namespace; } @Override public String getProperty(String key, String defaultValue) { if (key.equals("unknown")) { return null; } return m_namespace + ":" + key; } @Override public Set<String> getPropertyNames() { return null; } @Override public ConfigSourceType getSourceType() { return null; } } private static class MockConfigFile implements ConfigFile { private ConfigFileFormat m_configFileFormat; private String m_namespace; public MockConfigFile(String namespace, ConfigFileFormat configFileFormat) { m_namespace = namespace; m_configFileFormat = configFileFormat; } @Override public String getContent() { return m_namespace + ":" + m_configFileFormat.getValue(); } @Override public boolean hasContent() { return true; } @Override public String getNamespace() { return m_namespace; } @Override public ConfigFileFormat getConfigFileFormat() { return m_configFileFormat; } @Override public void addChangeListener(ConfigFileChangeListener listener) { } @Override public boolean removeChangeListener(ConfigFileChangeListener listener) { return false; } @Override public ConfigSourceType getSourceType() { return null; } } public static class MockConfigFactory implements ConfigFactory { @Override public Config create(String namespace) { return new MockConfig(namespace); } @Override public ConfigFile createConfigFile(String namespace, ConfigFileFormat configFileFormat) { return new MockConfigFile(namespace, configFileFormat); } } public static class MockConfigUtil extends ConfigUtil { @Override public String getAppId() { return someAppId; } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.enums.ConfigSourceType; import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.internals.AbstractConfig; import com.ctrip.framework.apollo.spi.ConfigFactory; import com.ctrip.framework.apollo.util.ConfigUtil; /** * @author Jason Song(song_s@ctrip.com) */ public class ConfigServiceTest { private static String someAppId; @Before public void setUp() throws Exception { someAppId = "someAppId"; MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil()); } @After public void tearDown() throws Exception { //as ConfigService is singleton, so we must manually clear its container ConfigService.reset(); MockInjector.reset(); } @Test public void testHackConfig() { String someNamespace = "hack"; String someKey = "first"; ConfigService.setConfig(new MockConfig(someNamespace)); Config config = ConfigService.getAppConfig(); assertEquals(someNamespace + ":" + someKey, config.getProperty(someKey, null)); assertEquals(null, config.getProperty("unknown", null)); } @Test public void testHackConfigFactory() throws Exception { String someKey = "someKey"; ConfigService.setConfigFactory(new MockConfigFactory()); Config config = ConfigService.getAppConfig(); assertEquals(ConfigConsts.NAMESPACE_APPLICATION + ":" + someKey, config.getProperty(someKey, null)); } @Test public void testMockConfigFactory() throws Exception { String someNamespace = "mock"; String someKey = "someKey"; MockInjector.setInstance(ConfigFactory.class, someNamespace, new MockConfigFactory()); Config config = ConfigService.getConfig(someNamespace); assertEquals(someNamespace + ":" + someKey, config.getProperty(someKey, null)); assertEquals(null, config.getProperty("unknown", null)); } @Test public void testMockConfigFactoryForConfigFile() throws Exception { String someNamespace = "mock"; ConfigFileFormat someConfigFileFormat = ConfigFileFormat.Properties; String someNamespaceFileName = String.format("%s.%s", someNamespace, someConfigFileFormat.getValue()); MockInjector.setInstance(ConfigFactory.class, someNamespaceFileName, new MockConfigFactory()); ConfigFile configFile = ConfigService.getConfigFile(someNamespace, someConfigFileFormat); assertEquals(someNamespaceFileName, configFile.getNamespace()); assertEquals(someNamespaceFileName + ":" + someConfigFileFormat.getValue(), configFile.getContent()); } private static class MockConfig extends AbstractConfig { private final String m_namespace; public MockConfig(String namespace) { m_namespace = namespace; } @Override public String getProperty(String key, String defaultValue) { if (key.equals("unknown")) { return null; } return m_namespace + ":" + key; } @Override public Set<String> getPropertyNames() { return null; } @Override public ConfigSourceType getSourceType() { return null; } } private static class MockConfigFile implements ConfigFile { private ConfigFileFormat m_configFileFormat; private String m_namespace; public MockConfigFile(String namespace, ConfigFileFormat configFileFormat) { m_namespace = namespace; m_configFileFormat = configFileFormat; } @Override public String getContent() { return m_namespace + ":" + m_configFileFormat.getValue(); } @Override public boolean hasContent() { return true; } @Override public String getNamespace() { return m_namespace; } @Override public ConfigFileFormat getConfigFileFormat() { return m_configFileFormat; } @Override public void addChangeListener(ConfigFileChangeListener listener) { } @Override public boolean removeChangeListener(ConfigFileChangeListener listener) { return false; } @Override public ConfigSourceType getSourceType() { return null; } } public static class MockConfigFactory implements ConfigFactory { @Override public Config create(String namespace) { return new MockConfig(namespace); } @Override public ConfigFile createConfigFile(String namespace, ConfigFileFormat configFileFormat) { return new MockConfigFile(namespace, configFileFormat); } } public static class MockConfigUtil extends ConfigUtil { @Override public String getAppId() { return someAppId; } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.config; import com.ctrip.framework.apollo.biz.service.BizDBPropertySource; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.util.ReflectionTestUtils; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ @RunWith(MockitoJUnitRunner.class) public class BizConfigTest { @Mock private ConfigurableEnvironment environment; private BizConfig bizConfig; @Before public void setUp() throws Exception { bizConfig = new BizConfig(new BizDBPropertySource()); ReflectionTestUtils.setField(bizConfig, "environment", environment); } @Test public void testReleaseMessageNotificationBatch() throws Exception { int someBatch = 20; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(String.valueOf(someBatch)); assertEquals(someBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithDefaultValue() throws Exception { int defaultBatch = 100; assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithInvalidNumber() throws Exception { int someBatch = -20; int defaultBatch = 100; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(String.valueOf(someBatch)); assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithNAN() throws Exception { String someNAN = "someNAN"; int defaultBatch = 100; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(someNAN); assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testCheckInt() throws Exception { int someInvalidValue = 1; int anotherInvalidValue = 2; int someValidValue = 3; int someDefaultValue = 10; int someMin = someInvalidValue + 1; int someMax = anotherInvalidValue - 1; assertEquals(someDefaultValue, bizConfig.checkInt(someInvalidValue, someMin, Integer.MAX_VALUE, someDefaultValue)); assertEquals(someDefaultValue, bizConfig.checkInt(anotherInvalidValue, Integer.MIN_VALUE, someMax, someDefaultValue)); assertEquals(someValidValue, bizConfig.checkInt(someValidValue, Integer.MIN_VALUE, Integer.MAX_VALUE, someDefaultValue)); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.config; import com.ctrip.framework.apollo.biz.service.BizDBPropertySource; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.util.ReflectionTestUtils; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; /** * @author Jason Song(song_s@ctrip.com) */ @RunWith(MockitoJUnitRunner.class) public class BizConfigTest { @Mock private ConfigurableEnvironment environment; private BizConfig bizConfig; @Before public void setUp() throws Exception { bizConfig = new BizConfig(new BizDBPropertySource()); ReflectionTestUtils.setField(bizConfig, "environment", environment); } @Test public void testReleaseMessageNotificationBatch() throws Exception { int someBatch = 20; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(String.valueOf(someBatch)); assertEquals(someBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithDefaultValue() throws Exception { int defaultBatch = 100; assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithInvalidNumber() throws Exception { int someBatch = -20; int defaultBatch = 100; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(String.valueOf(someBatch)); assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testReleaseMessageNotificationBatchWithNAN() throws Exception { String someNAN = "someNAN"; int defaultBatch = 100; when(environment.getProperty("apollo.release-message.notification.batch")).thenReturn(someNAN); assertEquals(defaultBatch, bizConfig.releaseMessageNotificationBatch()); } @Test public void testCheckInt() throws Exception { int someInvalidValue = 1; int anotherInvalidValue = 2; int someValidValue = 3; int someDefaultValue = 10; int someMin = someInvalidValue + 1; int someMax = anotherInvalidValue - 1; assertEquals(someDefaultValue, bizConfig.checkInt(someInvalidValue, someMin, Integer.MAX_VALUE, someDefaultValue)); assertEquals(someDefaultValue, bizConfig.checkInt(anotherInvalidValue, Integer.MIN_VALUE, someMax, someDefaultValue)); assertEquals(someValidValue, bizConfig.checkInt(someValidValue, Integer.MIN_VALUE, Integer.MAX_VALUE, someDefaultValue)); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/util/yaml/YamlParserTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util.yaml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.util.OrderedProperties; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import com.google.common.base.Charsets; import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; import org.springframework.core.io.ByteArrayResource; import org.yaml.snakeyaml.constructor.ConstructorException; import org.yaml.snakeyaml.parser.ParserException; public class YamlParserTest { private YamlParser parser; @Before public void setUp() throws Exception { parser = new YamlParser(); } @After public void tearDown() throws Exception { MockInjector.reset(); } @Test public void testValidCases() throws Exception { test("case1.yaml"); test("case3.yaml"); test("case4.yaml"); test("case5.yaml"); test("case6.yaml"); test("case7.yaml"); } @Test(expected = ParserException.class) public void testcase2() throws Exception { testInvalid("case2.yaml"); } @Test(expected = ParserException.class) public void testcase8() throws Exception { testInvalid("case8.yaml"); } @Test(expected = ConstructorException.class) public void testcase9() throws Exception { testInvalid("case9.yaml"); } @Test public void testOrderProperties() throws IOException { String yamlContent = loadYaml("orderedcase.yaml"); Properties nonOrderedProperties = parser.yamlToProperties(yamlContent); PropertiesFactory propertiesFactory = mock(PropertiesFactory.class); when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() { @Override public Properties answer(InvocationOnMock invocation) { return new OrderedProperties(); } }); MockInjector.setInstance(PropertiesFactory.class, propertiesFactory); parser = new YamlParser(); Properties orderedProperties = parser.yamlToProperties(yamlContent); assertTrue(orderedProperties instanceof OrderedProperties); checkPropertiesEquals(nonOrderedProperties, orderedProperties); String[] propertyNames = orderedProperties.stringPropertyNames().toArray(new String[0]); assertEquals("k2", propertyNames[0]); assertEquals("k4", propertyNames[1]); assertEquals("k1", propertyNames[2]); } private void test(String caseName) throws Exception { String yamlContent = loadYaml(caseName); check(yamlContent); } private String loadYaml(String caseName) throws IOException { File file = new File("src/test/resources/yaml/" + caseName); return Files.toString(file, Charsets.UTF_8); } private void testInvalid(String caseName) throws Exception { File file = new File("src/test/resources/yaml/" + caseName); String yamlContent = Files.toString(file, Charsets.UTF_8); parser.yamlToProperties(yamlContent); } private void check(String yamlContent) { YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); yamlPropertiesFactoryBean.setResources(new ByteArrayResource(yamlContent.getBytes())); Properties expected = yamlPropertiesFactoryBean.getObject(); Properties actual = parser.yamlToProperties(yamlContent); assertTrue("expected: " + expected + " actual: " + actual, checkPropertiesEquals(expected, actual)); } private boolean checkPropertiesEquals(Properties expected, Properties actual) { if (expected == actual) return true; if (expected.size() != actual.size()) return false; for (Object key : expected.keySet()) { if (!expected.getProperty((String) key).equals(actual.getProperty((String) key))) { return false; } } return true; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util.yaml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.util.OrderedProperties; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import com.google.common.base.Charsets; import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; import org.springframework.core.io.ByteArrayResource; import org.yaml.snakeyaml.constructor.ConstructorException; import org.yaml.snakeyaml.parser.ParserException; public class YamlParserTest { private YamlParser parser; @Before public void setUp() throws Exception { parser = new YamlParser(); } @After public void tearDown() throws Exception { MockInjector.reset(); } @Test public void testValidCases() throws Exception { test("case1.yaml"); test("case3.yaml"); test("case4.yaml"); test("case5.yaml"); test("case6.yaml"); test("case7.yaml"); } @Test(expected = ParserException.class) public void testcase2() throws Exception { testInvalid("case2.yaml"); } @Test(expected = ParserException.class) public void testcase8() throws Exception { testInvalid("case8.yaml"); } @Test(expected = ConstructorException.class) public void testcase9() throws Exception { testInvalid("case9.yaml"); } @Test public void testOrderProperties() throws IOException { String yamlContent = loadYaml("orderedcase.yaml"); Properties nonOrderedProperties = parser.yamlToProperties(yamlContent); PropertiesFactory propertiesFactory = mock(PropertiesFactory.class); when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() { @Override public Properties answer(InvocationOnMock invocation) { return new OrderedProperties(); } }); MockInjector.setInstance(PropertiesFactory.class, propertiesFactory); parser = new YamlParser(); Properties orderedProperties = parser.yamlToProperties(yamlContent); assertTrue(orderedProperties instanceof OrderedProperties); checkPropertiesEquals(nonOrderedProperties, orderedProperties); String[] propertyNames = orderedProperties.stringPropertyNames().toArray(new String[0]); assertEquals("k2", propertyNames[0]); assertEquals("k4", propertyNames[1]); assertEquals("k1", propertyNames[2]); } private void test(String caseName) throws Exception { String yamlContent = loadYaml(caseName); check(yamlContent); } private String loadYaml(String caseName) throws IOException { File file = new File("src/test/resources/yaml/" + caseName); return Files.toString(file, Charsets.UTF_8); } private void testInvalid(String caseName) throws Exception { File file = new File("src/test/resources/yaml/" + caseName); String yamlContent = Files.toString(file, Charsets.UTF_8); parser.yamlToProperties(yamlContent); } private void check(String yamlContent) { YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); yamlPropertiesFactoryBean.setResources(new ByteArrayResource(yamlContent.getBytes())); Properties expected = yamlPropertiesFactoryBean.getObject(); Properties actual = parser.yamlToProperties(yamlContent); assertTrue("expected: " + expected + " actual: " + actual, checkPropertiesEquals(expected, actual)); } private boolean checkPropertiesEquals(Properties expected, Properties actual) { if (expected == actual) return true; if (expected.size() != actual.size()) return false; for (Object key : expected.keySet()) { if (!expected.getProperty((String) key).equals(actual.getProperty((String) key))) { return false; } } return true; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/zh/community/team.md
# Apollo 团队 Apollo 团队由 Member 和 Contributor 组成。Member 可以直接访问 Apollo 项目的源代码并基于代码库积极演进。Contributor 通过向 Member 提交补丁和建议来改善项目,项目的贡献者数量是没有限制的。无论是进行小规模的清理,提交新的功能或其它形式的贡献,都将受到极大的赞赏。 有关社区治理模型的更多信息,请参考[GOVERNANCE.md](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md)。 ## Member Member 包括 PMC 成员和 Committer,该列表按字母顺序排列。 ### Project Management Committee(PMC) | Github ID | Name | Organization | | ---------- | ---------- | ------------ | | JaredTan95 | Jared Tan | DaoCloud | | kezhenxu94 | Zhenxu Ke | Tetrate | | nobodyiam | Jason Song | Ant Group | | zouyx | Joe Zou | Shein | ### Committer | Github ID | Name | Organization | | ----------- | ------------- | ------------ | | Anilople | Xiaoquan Wang | Some Bank | | klboke | Kailing Chen | TapTap | | lepdou | Le Zhang | Ant Group | | nisiyong | Stephen Ni | Qihoo 360 | | pengweiqhca | Wei Peng | Tuhu | | vdisk-group | Lvqiu Ye | Hundsun | ## Contributor ### Apollo 主仓库 <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> ### apollo.net <a href="https://github.com/ctripcorp/apollo.net/graphs/contributors"><img src="https://opencollective.com/apollonet/contributors.svg?width=880&button=false" /></a> ## **如何成为提交者** 请参考 [How to become a Committer](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md#how-to-become-a-committer).
# Apollo 团队 Apollo 团队由 Member 和 Contributor 组成。Member 可以直接访问 Apollo 项目的源代码并基于代码库积极演进。Contributor 通过向 Member 提交补丁和建议来改善项目,项目的贡献者数量是没有限制的。无论是进行小规模的清理,提交新的功能或其它形式的贡献,都将受到极大的赞赏。 有关社区治理模型的更多信息,请参考[GOVERNANCE.md](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md)。 ## Member Member 包括 PMC 成员和 Committer,该列表按字母顺序排列。 ### Project Management Committee(PMC) | Github ID | Name | Organization | | ---------- | ---------- | ------------ | | JaredTan95 | Jared Tan | DaoCloud | | kezhenxu94 | Zhenxu Ke | Tetrate | | nobodyiam | Jason Song | Ant Group | | zouyx | Joe Zou | Shein | ### Committer | Github ID | Name | Organization | | ----------- | ------------- | ------------ | | Anilople | Xiaoquan Wang | Some Bank | | klboke | Kailing Chen | TapTap | | lepdou | Le Zhang | Ant Group | | nisiyong | Stephen Ni | Qihoo 360 | | pengweiqhca | Wei Peng | Tuhu | | vdisk-group | Lvqiu Ye | Hundsun | ## Contributor ### Apollo 主仓库 <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> ### apollo.net <a href="https://github.com/ctripcorp/apollo.net/graphs/contributors"><img src="https://opencollective.com/apollonet/contributors.svg?width=880&button=false" /></a> ## **如何成为提交者** 请参考 [How to become a Committer](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md#how-to-become-a-committer).
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ServerProvider.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.spi.provider; import java.io.IOException; import java.io.InputStream; /** * Provider for server related properties */ public interface ServerProvider extends Provider { /** * @return current environment or {@code null} if not set */ String getEnvType(); /** * @return whether current environment is set or not */ boolean isEnvTypeSet(); /** * @return current data center or {@code null} if not set */ String getDataCenter(); /** * @return whether data center is set or not */ boolean isDataCenterSet(); /** * Initialize server provider with the specified input stream * * @throws IOException */ void initialize(InputStream in) throws IOException; }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.foundation.spi.provider; import java.io.IOException; import java.io.InputStream; /** * Provider for server related properties */ public interface ServerProvider extends Provider { /** * @return current environment or {@code null} if not set */ String getEnvType(); /** * @return whether current environment is set or not */ boolean isEnvTypeSet(); /** * @return current data center or {@code null} if not set */ String getDataCenter(); /** * @return whether data center is set or not */ boolean isDataCenterSet(); /** * Initialize server provider with the specified input stream * * @throws IOException */ void initialize(InputStream in) throws IOException; }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.environment; import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory; import com.ctrip.framework.apollo.core.utils.NetUtil; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; /** * Only use in apollo-portal * Provider an available meta server url. * If there is no available meta server url for the given environment, * the default meta server url will be used(http://apollo.meta). * @see com.ctrip.framework.apollo.core.MetaDomainConsts * @author wxq */ @Service public class PortalMetaDomainService { private static final Logger logger = LoggerFactory.getLogger(PortalMetaDomainService.class); private static final long REFRESH_INTERVAL_IN_SECOND = 60;// 1 min static final String DEFAULT_META_URL = "http://apollo.meta"; private final Map<Env, String> metaServerAddressCache = Maps.newConcurrentMap(); /** * initialize meta server provider without cache. * Multiple {@link PortalMetaServerProvider} */ private final List<PortalMetaServerProvider> portalMetaServerProviders = new ArrayList<>(); // env -> meta server address cache // comma separated meta server address -> selected single meta server address cache private final Map<String, String> selectedMetaServerAddressCache = Maps.newConcurrentMap(); private final AtomicBoolean periodicRefreshStarted = new AtomicBoolean(false); PortalMetaDomainService(final PortalConfig portalConfig) { // high priority with data in database portalMetaServerProviders.add(new DatabasePortalMetaServerProvider(portalConfig)); // System properties, OS environment, configuration file portalMetaServerProviders.add(new DefaultPortalMetaServerProvider()); } /** * Return one meta server address. If multiple meta server addresses are configured, will select one. */ public String getDomain(Env env) { String metaServerAddress = getMetaServerAddress(env); // if there is more than one address, need to select one if (metaServerAddress.contains(",")) { return selectMetaServerAddress(metaServerAddress); } return metaServerAddress; } /** * Return meta server address. If multiple meta server addresses are configured, will return the comma separated string. */ public String getMetaServerAddress(Env env) { // in cache? if (!metaServerAddressCache.containsKey(env)) { // put it to cache metaServerAddressCache .put(env, getMetaServerAddressCacheValue(portalMetaServerProviders, env) ); } // get from cache return metaServerAddressCache.get(env); } /** * Get the meta server from provider by given environment. * If there is no available meta server url for the given environment, * the default meta server url will be used(http://apollo.meta). * @param providers provide environment's meta server address * @param env environment * @return meta server address */ private String getMetaServerAddressCacheValue( Collection<PortalMetaServerProvider> providers, Env env) { // null value String metaAddress = null; for(PortalMetaServerProvider portalMetaServerProvider : providers) { if(portalMetaServerProvider.exists(env)) { metaAddress = portalMetaServerProvider.getMetaServerAddress(env); logger.info("Located meta server address [{}] for env [{}]", metaAddress, env); break; } } // check find it or not if (Strings.isNullOrEmpty(metaAddress)) { // Fallback to default meta address metaAddress = DEFAULT_META_URL; logger.warn( "Meta server address fallback to [{}] for env [{}], because it is not available in MetaServerProvider", metaAddress, env); } return metaAddress.trim(); } /** * reload all {@link PortalMetaServerProvider}. * clear cache {@link this#metaServerAddressCache} */ public void reload() { for(PortalMetaServerProvider portalMetaServerProvider : portalMetaServerProviders) { portalMetaServerProvider.reload(); } metaServerAddressCache.clear(); } /** * Select one available meta server from the comma separated meta server addresses, e.g. * http://1.2.3.4:8080,http://2.3.4.5:8080 * * <br /> * * In production environment, we still suggest using one single domain like http://config.xxx.com(backed by software * load balancers like nginx) instead of multiple ip addresses */ private String selectMetaServerAddress(String metaServerAddresses) { String metaAddressSelected = selectedMetaServerAddressCache.get(metaServerAddresses); if (metaAddressSelected == null) { // initialize if (periodicRefreshStarted.compareAndSet(false, true)) { schedulePeriodicRefresh(); } updateMetaServerAddresses(metaServerAddresses); metaAddressSelected = selectedMetaServerAddressCache.get(metaServerAddresses); } return metaAddressSelected; } private void updateMetaServerAddresses(String metaServerAddresses) { logger.debug("Selecting meta server address for: {}", metaServerAddresses); Transaction transaction = Tracer.newTransaction("Apollo.MetaService", "refreshMetaServerAddress"); transaction.addData("Url", metaServerAddresses); try { List<String> metaServers = Lists.newArrayList(metaServerAddresses.split(",")); // random load balancing Collections.shuffle(metaServers); boolean serverAvailable = false; for (String address : metaServers) { address = address.trim(); //check whether /services/config is accessible if (NetUtil.pingUrl(address + "/services/config")) { // select the first available meta server selectedMetaServerAddressCache.put(metaServerAddresses, address); serverAvailable = true; logger.debug("Selected meta server address {} for {}", address, metaServerAddresses); break; } } // we need to make sure the map is not empty, e.g. the first update might be failed if (!selectedMetaServerAddressCache.containsKey(metaServerAddresses)) { selectedMetaServerAddressCache.put(metaServerAddresses, metaServers.get(0).trim()); } if (!serverAvailable) { logger.warn("Could not find available meta server for configured meta server addresses: {}, fallback to: {}", metaServerAddresses, selectedMetaServerAddressCache.get(metaServerAddresses)); } transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { transaction.setStatus(ex); throw ex; } finally { transaction.complete(); } } private void schedulePeriodicRefresh() { ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory.create("MetaServiceLocator", true)); scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { try { for (String metaServerAddresses : selectedMetaServerAddressCache.keySet()) { updateMetaServerAddresses(metaServerAddresses); } } catch (Throwable ex) { logger.warn(String.format("Refreshing meta server address failed, will retry in %d seconds", REFRESH_INTERVAL_IN_SECOND), ex); } } }, REFRESH_INTERVAL_IN_SECOND, REFRESH_INTERVAL_IN_SECOND, TimeUnit.SECONDS); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.environment; import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory; import com.ctrip.framework.apollo.core.utils.NetUtil; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; /** * Only use in apollo-portal * Provider an available meta server url. * If there is no available meta server url for the given environment, * the default meta server url will be used(http://apollo.meta). * @see com.ctrip.framework.apollo.core.MetaDomainConsts * @author wxq */ @Service public class PortalMetaDomainService { private static final Logger logger = LoggerFactory.getLogger(PortalMetaDomainService.class); private static final long REFRESH_INTERVAL_IN_SECOND = 60;// 1 min static final String DEFAULT_META_URL = "http://apollo.meta"; private final Map<Env, String> metaServerAddressCache = Maps.newConcurrentMap(); /** * initialize meta server provider without cache. * Multiple {@link PortalMetaServerProvider} */ private final List<PortalMetaServerProvider> portalMetaServerProviders = new ArrayList<>(); // env -> meta server address cache // comma separated meta server address -> selected single meta server address cache private final Map<String, String> selectedMetaServerAddressCache = Maps.newConcurrentMap(); private final AtomicBoolean periodicRefreshStarted = new AtomicBoolean(false); PortalMetaDomainService(final PortalConfig portalConfig) { // high priority with data in database portalMetaServerProviders.add(new DatabasePortalMetaServerProvider(portalConfig)); // System properties, OS environment, configuration file portalMetaServerProviders.add(new DefaultPortalMetaServerProvider()); } /** * Return one meta server address. If multiple meta server addresses are configured, will select one. */ public String getDomain(Env env) { String metaServerAddress = getMetaServerAddress(env); // if there is more than one address, need to select one if (metaServerAddress.contains(",")) { return selectMetaServerAddress(metaServerAddress); } return metaServerAddress; } /** * Return meta server address. If multiple meta server addresses are configured, will return the comma separated string. */ public String getMetaServerAddress(Env env) { // in cache? if (!metaServerAddressCache.containsKey(env)) { // put it to cache metaServerAddressCache .put(env, getMetaServerAddressCacheValue(portalMetaServerProviders, env) ); } // get from cache return metaServerAddressCache.get(env); } /** * Get the meta server from provider by given environment. * If there is no available meta server url for the given environment, * the default meta server url will be used(http://apollo.meta). * @param providers provide environment's meta server address * @param env environment * @return meta server address */ private String getMetaServerAddressCacheValue( Collection<PortalMetaServerProvider> providers, Env env) { // null value String metaAddress = null; for(PortalMetaServerProvider portalMetaServerProvider : providers) { if(portalMetaServerProvider.exists(env)) { metaAddress = portalMetaServerProvider.getMetaServerAddress(env); logger.info("Located meta server address [{}] for env [{}]", metaAddress, env); break; } } // check find it or not if (Strings.isNullOrEmpty(metaAddress)) { // Fallback to default meta address metaAddress = DEFAULT_META_URL; logger.warn( "Meta server address fallback to [{}] for env [{}], because it is not available in MetaServerProvider", metaAddress, env); } return metaAddress.trim(); } /** * reload all {@link PortalMetaServerProvider}. * clear cache {@link this#metaServerAddressCache} */ public void reload() { for(PortalMetaServerProvider portalMetaServerProvider : portalMetaServerProviders) { portalMetaServerProvider.reload(); } metaServerAddressCache.clear(); } /** * Select one available meta server from the comma separated meta server addresses, e.g. * http://1.2.3.4:8080,http://2.3.4.5:8080 * * <br /> * * In production environment, we still suggest using one single domain like http://config.xxx.com(backed by software * load balancers like nginx) instead of multiple ip addresses */ private String selectMetaServerAddress(String metaServerAddresses) { String metaAddressSelected = selectedMetaServerAddressCache.get(metaServerAddresses); if (metaAddressSelected == null) { // initialize if (periodicRefreshStarted.compareAndSet(false, true)) { schedulePeriodicRefresh(); } updateMetaServerAddresses(metaServerAddresses); metaAddressSelected = selectedMetaServerAddressCache.get(metaServerAddresses); } return metaAddressSelected; } private void updateMetaServerAddresses(String metaServerAddresses) { logger.debug("Selecting meta server address for: {}", metaServerAddresses); Transaction transaction = Tracer.newTransaction("Apollo.MetaService", "refreshMetaServerAddress"); transaction.addData("Url", metaServerAddresses); try { List<String> metaServers = Lists.newArrayList(metaServerAddresses.split(",")); // random load balancing Collections.shuffle(metaServers); boolean serverAvailable = false; for (String address : metaServers) { address = address.trim(); //check whether /services/config is accessible if (NetUtil.pingUrl(address + "/services/config")) { // select the first available meta server selectedMetaServerAddressCache.put(metaServerAddresses, address); serverAvailable = true; logger.debug("Selected meta server address {} for {}", address, metaServerAddresses); break; } } // we need to make sure the map is not empty, e.g. the first update might be failed if (!selectedMetaServerAddressCache.containsKey(metaServerAddresses)) { selectedMetaServerAddressCache.put(metaServerAddresses, metaServers.get(0).trim()); } if (!serverAvailable) { logger.warn("Could not find available meta server for configured meta server addresses: {}, fallback to: {}", metaServerAddresses, selectedMetaServerAddressCache.get(metaServerAddresses)); } transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { transaction.setStatus(ex); throw ex; } finally { transaction.complete(); } } private void schedulePeriodicRefresh() { ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory.create("MetaServiceLocator", true)); scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { try { for (String metaServerAddresses : selectedMetaServerAddressCache.keySet()) { updateMetaServerAddresses(metaServerAddresses); } } catch (Throwable ex) { logger.warn(String.format("Refreshing meta server address failed, will retry in %d seconds", REFRESH_INTERVAL_IN_SECOND), ex); } } }, REFRESH_INTERVAL_IN_SECOND, REFRESH_INTERVAL_IN_SECOND, TimeUnit.SECONDS); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./README.md
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Apollo - A reliable configuration management system [![Build Status](https://github.com/ctripcorp/apollo/workflows/build/badge.svg)](https://github.com/ctripcorp/apollo/actions) [![GitHub Release](https://img.shields.io/github/release/ctripcorp/apollo.svg)](https://github.com/ctripcorp/apollo/releases) [![Maven Central Repo](https://img.shields.io/maven-central/v/com.ctrip.framework.apollo/apollo.svg)](https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client) [![codecov.io](https://codecov.io/github/ctripcorp/apollo/coverage.svg?branch=master)](https://codecov.io/github/ctripcorp/apollo?branch=master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) Apollo is a reliable configuration management system. It can centrally manage the configurations of different applications and different clusters. It is suitable for microservice configuration management scenarios. The server side is developed based on Spring Boot and Spring Cloud, which can simply run without the need to install additional application containers such as Tomcat. The Java SDK does not rely on any framework and can run in all Java runtime environments. It also has good support for Spring/Spring Boot environments. The .Net SDK does not rely on any framework and can run in all .Net runtime environments. For more details of the product introduction, please refer [Introduction to Apollo Configuration Center](https://www.apolloconfig.com/#/zh/design/apollo-introduction). For local demo purpose, please refer [Quick Start](https://www.apolloconfig.com/#/zh/deployment/quick-start). Demo Environment: - [http://106.54.227.205](http://106.54.227.205/) - User/Password: apollo/admin # Screenshots ![Screenshot](https://raw.githubusercontent.com/ctripcorp/apollo/master/docs/en/images/apollo-home-screenshot.jpg) # Features * **Unified management of the configurations of different environments and different clusters** * Apollo provides a unified interface to centrally manage the configurations of different environments, different clusters, and different namespaces * The same codebase could have different configurations when deployed in different clusters * With the namespace concept, it is easy to support multiple applications to share the same configurations, while also allowing them to customize the configurations * Multiple languages is provided in user interface(currently Chinese and English) * **Configuration changes takes effect in real time (hot release)** * After the user modified the configuration and released it in Apollo, the sdk will receive the latest configurations in real time (1 second) and notify the application * **Release version management** * Every configuration releases are versioned, which is friendly to support configuration rollback * **Grayscale release** * Support grayscale configuration release, for example, after clicking release, it will only take effect for some application instances. After a period of observation, we could push the configurations to all application instances if there is no problem * **Authorization management, release approval and operation audit** * Great authorization mechanism is designed for applications and configurations management, and the management of configurations is divided into two operations: editing and publishing, therefore greatly reducing human errors * All operations have audit logs for easy tracking of problems * **Client side configuration information monitoring** * It's very easy to see which instances are using the configurations and what versions they are using * **Rich SDKs available** * Provides native sdks of Java and .Net to facilitate application integration * Support Spring Placeholder, Annotation and Spring Boot ConfigurationProperties for easy application use (requires Spring 3.1.1+) * Http APIs are provided, so non-Java and .Net applications can integrate conveniently * Rich third party sdks are also available, e.g. Golang, Python, NodeJS, PHP, C, etc * **Open platform API** * Apollo itself provides a unified configuration management interface, which supports features such as multi-environment, multi-data center configuration management, permissions, and process governance * However, for the sake of versatility, Apollo will not put too many restrictions on the modification of the configuration, as long as it conforms to the basic format, it can be saved. * In our research, we found that for some users, their configurations may have more complicated formats, such as xml, json, and the format needs to be verified * There are also some users such as DAL, which not only have a specific format, but also need to verify the entered value before saving, such as checking whether the database, username and password match * For this type of application, Apollo allows the application to modify and release configurations through open APIs, which has great authorization and permission control mechanism built in * **Simple deployment** * As an infrastructure service, the configuration center has very high availability requirements, which forces Apollo to rely on external dependencies as little as possible * Currently, the only external dependency is MySQL, so the deployment is very simple. Apollo can run as long as Java and MySQL are installed * Apollo also provides a packaging script, which can generate all required installation packages with just one click, and supports customization of runtime parameters # Usage 1. [Apollo User Guide](https://www.apolloconfig.com/#/zh/usage/apollo-user-guide) 2. [Java SDK User Guide](https://www.apolloconfig.com/#/zh/usage/java-sdk-user-guide) 3. [.Net SDK user Guide](https://www.apolloconfig.com/#/zh/usage/dotnet-sdk-user-guide) 4. [Third Party SDK User Guide](https://www.apolloconfig.com/#/zh/usage/third-party-sdks-user-guide) 5. [Other Language Client User Guide](https://www.apolloconfig.com/#/zh/usage/other-language-client-user-guide) 6. [Apollo Open APIs](https://www.apolloconfig.com/#/zh/usage/apollo-open-api-platform) 7. [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo User Practices](https://www.apolloconfig.com/#/zh/usage/apollo-user-practices) 9. [Apollo Security Best Practices](https://www.apolloconfig.com/#/zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design * [Apollo Design](https://www.apolloconfig.com/#/zh/design/apollo-design) * [Apollo Core Concept - Namespace](https://www.apolloconfig.com/#/zh/design/apollo-core-concept-namespace) * [Apollo Architecture Analysis](https://mp.weixin.qq.com/s/-hUaQPzfsl9Lm3IqQW3VDQ) * [Apollo Source Code Explanation](http://www.iocoder.cn/categories/Apollo/) # Development * [Apollo Development Guide](https://www.apolloconfig.com/#/zh/development/apollo-development-guide) * Code Styles * [Eclipse Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) * [Intellij Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) # Deployment * [Quick Start](https://www.apolloconfig.com/#/zh/deployment/quick-start) * [Distributed Deployment Guide](https://www.apolloconfig.com/#/zh/deployment/distributed-deployment-guide) # Release Notes * [Releases](https://github.com/ctripcorp/apollo/releases) # FAQ * [FAQ](https://www.apolloconfig.com/#/zh/faq/faq) * [Common Issues in Deployment & Development Phase](https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase) # Presentation * [Design and Implementation Details of Apollo](http://www.itdks.com/dakalive/detail/3420) * [Slides](https://myslide.cn/slides/10168) * [Configuration Center Makes Microservices Smart](https://2018.qconshanghai.com/presentation/799) * [Slides](https://myslide.cn/slides/10035) # Publication * [Design and Implementation Details of Apollo](https://www.infoq.cn/article/open-source-configuration-center-apollo) * [Configuration Center Makes Microservices Smart](https://mp.weixin.qq.com/s/iDmYJre_ULEIxuliu1EbIQ) # Community * [Apollo Team](https://www.apolloconfig.com/#/en/community/team) * [Community Governance](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md) * [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE). # Known Users > Sorted by registration order,users are welcome to register in [https://github.com/ctripcorp/apollo/issues/451](https://github.com/ctripcorp/apollo/issues/451) (reference purpose only for the community) <table> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ctrip.png" alt="携程"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bluestone.png" alt="青石证券"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sagreen.png" alt="沙绿"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/umetrip.jpg" alt="航旅纵横"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhuanzhuan.png" alt="58转转"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/phone580.png" alt="蜂助手"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hainan-airlines.png" alt="海南航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cvte.png" alt="CVTE"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mainbo.jpg" alt="明博教育"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/madailicai.png" alt="麻袋理财"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mxnavi.jpg" alt="美行科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fshows.jpg" alt="首展科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/feezu.png" alt="易微行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rencaijia.png" alt="人才加"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/keking.png" alt="凯京集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/leoao.png" alt="乐刻运动"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dji.png" alt="大疆"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kkmh.png" alt="快看漫画"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wolaidai.png" alt="我来贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xsrj.png" alt="虚实软件"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yanxuan.png" alt="网易严选"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sjzg.png" alt="视觉中国"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zc360.png" alt="资产360"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ecarx.png" alt="亿咖通"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/5173.png" alt="5173"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hujiang.png" alt="沪江"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/163yun.png" alt="网易云基础服务"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cash-bus.png" alt="现金巴士"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/smartisan.png" alt="锤子科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/toodc.png" alt="头等仓"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/juneyaoair.png" alt="吉祥航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/263mobile.png" alt="263移动通信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/toutoujinrong.png" alt="投投金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mytijian.png" alt="每天健康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maiyabank.png" alt="麦芽金服"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fengunion.png" alt="蜂向科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/geex-logo.png" alt="即科金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beike.png" alt="贝壳网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/youzan.png" alt="有赞"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunjihuitong.png" alt="云集汇通"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rhinotech.png" alt="犀牛瀚海科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/nxin.png" alt="农信互联"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mgzf.png" alt="蘑菇租房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/huli-logo.png" alt="狐狸金服"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mandao.png" alt="漫道集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enmonster.png" alt="怪兽充电"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/nanguazufang.png" alt="南瓜租房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shitoujinrong.png" alt="石投金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tubatu.png" alt="土巴兔"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/payh_logo.png" alt="平安银行"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xinxindai.png" alt="新新贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chrtc.png" alt="中国华戎科技集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tuya_logo.png" alt="涂鸦智能"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/szlcsc.jpg" alt="立创商城"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hairongyi.png" alt="乐赚金服"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kxqc.png" alt="开心汽车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ppcredit.png" alt="乐赚金服"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/primeton.png" alt="普元信息"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hoskeeper.png" alt="医帮管家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fula.png" alt="付啦信用卡管家"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uzai.png" alt="悠哉网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/91wutong.png" alt="梧桐诚选"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ppdai.png" alt="拍拍贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xinyongfei.png" alt="信用飞"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dxy.png" alt="丁香园"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ghtech.png" alt="国槐科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/qbb.png" alt="亲宝宝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/huawei_logo.png" alt="华为视频直播"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/weiboyi.png" alt="微播易"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ofpay.png" alt="欧飞"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mishuo.png" alt="迷说"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yixia.png" alt="一下科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daocloud.png" alt="DaoCloud"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cnvex.png" alt="汽摩交易所"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/100tal.png" alt="好未来教育集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ainirobot.png" alt="猎户星空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhuojian.png" alt="卓健科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enjoyor.png" alt="银江股份"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tuhu.png" alt="途虎养车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/homedo.png" alt="河姆渡"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xwbank.png" alt="新网银行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ctspcl.png" alt="中旅安信云贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meiyou.png" alt="美柚"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zkh-logo.png" alt="震坤行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wgss.png" alt="万谷盛世"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/plateno.png" alt="铂涛旅行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lifesense.png" alt="乐心"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/reachmedia.png" alt="亿投传媒"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/guxiansheng.png" alt="股先生"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caixuetang.png" alt="财学堂"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/4399.png" alt="4399"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/autohome.png" alt="汽车之家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mbcaijing.png" alt="面包财经"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hoopchina.png" alt="虎扑"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sohu-auto.png" alt="搜狐汽车"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/liangfuzhengxin.png" alt="量富征信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maihaoche.png" alt="卖好车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zyiot.jpg" alt="中移物联网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/biauto.png" alt="易车网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maiyaole.png" alt="一药网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaoying.png" alt="小影"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caibeike.png" alt="彩贝壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yeelight.png" alt="YEELIGHT"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/itsgmu.png" alt="积目"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/acmedcare.png" alt="极致医疗"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinhui365.png" alt="金汇金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/900etrip.png" alt="久柏易游"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/24xiaomai.png" alt="小麦铺"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/vvic.png" alt="搜款网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mizlicai.png" alt="米庄理财"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bjt.png" alt="贝吉塔网络科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/weimob.png" alt="微盟"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kada.png" alt="网易卡搭"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kapbook.png" alt="股书"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jumore.png" alt="聚贸"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bimface.png" alt="广联达bimface"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/globalgrow.png" alt="环球易购"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jollychic.png" alt="浙江执御"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/2dfire.jpg" alt="二维火"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shopin.png" alt="上品"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/inspur.png" alt="浪潮集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ngarihealth.png" alt="纳里健康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/oraro.png" alt="橙红科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dragonpass.png" alt="龙腾出行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lizhi.fm.png" alt="荔枝"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/htd.png" alt="汇通达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunrong.png" alt="云融金科"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tszg360.png" alt="天生掌柜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rongplus.png" alt="容联光辉"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/intellif.png" alt="云天励飞"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jiayundata.png" alt="嘉云数据"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zts.png" alt="中泰证券网络金融部"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/163dun.png" alt="网易易盾"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiangwushuo.png" alt="享物说"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sto.png" alt="申通"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinhe.png" alt="金和网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/2345.png" alt="二三四五"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chtwm.jpg" alt="恒天财富"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uweixin.png" alt="沐雪微信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wzeye.png" alt="温州医科大学附属眼视光医院"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/10010pay.png" alt="联通支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shanshu.png" alt="杉数科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fenlibao.png" alt="分利宝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hetao101.png" alt="核桃编程"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaohongshu.png" alt="小红书"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/blissmall.png" alt="幸福西饼"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ky-express.png" alt="跨越速运"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/oyohotels.png" alt="OYO"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/100-me.png" alt="叮咚买菜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhidaohulian.jpg" alt="智道网联"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xueqiu.jpg" alt="雪球"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/autocloudpro.png" alt="车通云"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dadaabc.png" alt="哒哒英语"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xedaojia.jpg" alt="小E微店"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daling.png" alt="达令家"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/renliwo.png" alt="人力窝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mocire.jpg" alt="嘉美在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uepay.png" alt="极易付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wdom.png" alt="智慧开源"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cheshiku.png" alt="车仕库"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/taimeitech.png" alt="太美医疗科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yilianbaihui.png" alt="亿联百汇"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhoupu123.png" alt="舟谱数据"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/frxs.png" alt="芙蓉兴盛"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beastshop.png" alt="野兽派"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kaishustory.png" alt="凯叔讲故事"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/haodf.png" alt="好大夫在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/insyunmi.png" alt="云幂信息技术"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/duiba.png" alt="兑吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/9ji.png" alt="九机网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sui.png" alt="随手科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aixiangdao.png" alt="万谷盛世"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunzhangfang.png" alt="云账房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yuantutech.png" alt="浙江远图互联"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/qk365.png" alt="青客公寓"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/eastmoney.png" alt="东方财富"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jikexiu.png" alt="极客修"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meix.png" alt="美市科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zto.png" alt="中通快递"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/e6yun.png" alt="易流科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaoyuanzhao.png" alt="实习僧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dalingjia.png" alt="达令家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/secoo.png" alt="寺库"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lianlianpay.png" alt="连连支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhongan.png" alt="众安保险"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/360jinrong.png" alt="360金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caschina.png" alt="中航服商旅"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ke.png" alt="贝壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yeahmobi.png" alt="Yeahmobi易点天下"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/idengyun.png" alt="北京登云美业网络科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinher.png" alt="金和网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/komect.png" alt="中移(杭州)信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beisen.png" alt="北森"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/log56.png" alt="合肥维天运通"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meboth.png" alt="北京蜜步科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/postop.png" alt="术康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rfchina.png" alt="富力集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tfxing.png" alt="天府行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/8travelpay.png" alt="八商山"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/centaline.png" alt="中原地产"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zkyda.png" alt="智科云达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/house730.png" alt="中原730"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/pagoda.png" alt="百果园"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bolome.png" alt="波罗蜜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xignite.png" alt="Xignite"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aduer.png" alt="杭州有云科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jojoreading.png" alt="成都书声科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sweetome.png" alt="斯维登集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/vipthink.png" alt="广东快乐种子科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tongxuecool.png" alt="上海盈翼文化传播有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sccfc.png" alt="上海尚诚消费金融股份有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ziroom.png" alt="自如网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jd.png" alt="京东"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rabbitpre.png" alt="兔展智能"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhubei.png" alt="竹贝"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/imile.png" alt="iMile(中东)"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/helloglobal.png" alt="哈罗出行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhaopin.png" alt="智联招聘"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/acadsoc.png" alt="阿卡索"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mojory.png" alt="妙知旅"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chengduoduo.png" alt="程多多"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/baojunev.png" alt="上汽通用五菱"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/leyan.png" alt="乐言科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dushu.png" alt="樊登读书"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zyiz.png" alt="找一找教程网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bppc.png" alt="中油碧辟石油有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shanglv51.png" alt="四川商旅无忧科技服务有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/waijiao365.png" alt="懿鸢网络科技(上海)有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gaoding.jpg" alt="稿定科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ricacorp.png" alt="搵樓 - 利嘉閣"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/t3go.png" alt="南京领行科技股份有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mokahr.jpg" alt="北京希瑞亚斯科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/printrainbow.png" alt="印彩虹印刷公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/milliontech.png" alt="Million Tech"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/guoguokeji.jpg" alt="果果科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/airkunming.png" alt="昆明航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/5i5j.png" alt="我爱我家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gjzq.png" alt="国金证券"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enjoymusic.jpg" alt="不亦乐乎"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cnhnb.png" alt="惠农网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daoklab.jpg" alt="成都道壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ausnutria.jpg" alt="澳优乳业"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/deiyoudian.png" alt="河南有态度信息科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ezhiyang.png" alt="智阳第一人力"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shie.png" alt="上海保险交易所"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wsecar.png" alt="万顺叫车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shouqinba.jpg" alt="收钱吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/baozun.png" alt="宝尊电商"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xbnwl.png" alt="喜百年供应链"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gwwisdom.png" alt="南京观为智慧软件科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ztrip.png" alt="在途商旅"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hualala.png" alt="哗啦啦"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xin.png" alt="优信二手车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maycur.png" alt="每刻科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bullyun.png" alt="杭州蛮牛"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bestpay.png" alt="翼支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mockuai.png" alt="魔筷科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ct108.png" alt="畅唐网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jusdaglobal.jpg" alt="准时达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/izaodao.png" alt="早道网校"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ovopark.jpg" alt="万店掌"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/funstory.jpg" alt="推文科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lemonbox.png" alt="Lemonbox"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/polyt.png" alt="保利票务"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chipwing.png" alt="芯翼科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/czbank.png" alt="浙商银行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/czbyqy.png" alt="易企银科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yundun.jpg" alt="上海云盾"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gaiaworks.jpg" alt="苏州盖雅信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mengxiang.png" alt="爱库存"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jidouauto.png" alt="极豆车联网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ipalfish.png" alt="伴鱼少儿英语"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/iqboard.png" alt="锐达科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/koolearn.png" alt="新东方在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kingcome.png" alt="金康高科"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/soulapp.png" alt="soul"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ezrpro.png" alt="驿氪"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hc360.png" alt="慧聪"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/21cp.png" alt="中塑在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/goinglink.jpg" alt="甄云科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aitrace.jpg" alt="追溯科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/moqipobing.png" alt="玩吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cassan.png" alt="广州卡桑信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shuidichou.png" alt="水滴"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kuwo.png" alt="酷我音乐"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mi.png" alt="小米"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mvmyun.png" alt="今典"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/visabao.jpg" alt="签宝科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/inrice.png" alt="广州趣米网络科技有限公司"></td> <td><a target="_blank" href="https://github.com/ctripcorp/apollo/issues/451">More...</a></td> </tr> </table> # Awards <img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/awards/oschina-2018-award.jpg" width="240px" alt="The most popular Chinese open source software in 2018"> # Stargazers over time [![Stargazers over time](https://starcharts.herokuapp.com/ctripcorp/apollo.svg)](https://starcharts.herokuapp.com/ctripcorp/apollo)
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Apollo - A reliable configuration management system [![Build Status](https://github.com/ctripcorp/apollo/workflows/build/badge.svg)](https://github.com/ctripcorp/apollo/actions) [![GitHub Release](https://img.shields.io/github/release/ctripcorp/apollo.svg)](https://github.com/ctripcorp/apollo/releases) [![Maven Central Repo](https://img.shields.io/maven-central/v/com.ctrip.framework.apollo/apollo.svg)](https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client) [![codecov.io](https://codecov.io/github/ctripcorp/apollo/coverage.svg?branch=master)](https://codecov.io/github/ctripcorp/apollo?branch=master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) Apollo is a reliable configuration management system. It can centrally manage the configurations of different applications and different clusters. It is suitable for microservice configuration management scenarios. The server side is developed based on Spring Boot and Spring Cloud, which can simply run without the need to install additional application containers such as Tomcat. The Java SDK does not rely on any framework and can run in all Java runtime environments. It also has good support for Spring/Spring Boot environments. The .Net SDK does not rely on any framework and can run in all .Net runtime environments. For more details of the product introduction, please refer [Introduction to Apollo Configuration Center](https://www.apolloconfig.com/#/zh/design/apollo-introduction). For local demo purpose, please refer [Quick Start](https://www.apolloconfig.com/#/zh/deployment/quick-start). Demo Environment: - [http://106.54.227.205](http://106.54.227.205/) - User/Password: apollo/admin # Screenshots ![Screenshot](https://raw.githubusercontent.com/ctripcorp/apollo/master/docs/en/images/apollo-home-screenshot.jpg) # Features * **Unified management of the configurations of different environments and different clusters** * Apollo provides a unified interface to centrally manage the configurations of different environments, different clusters, and different namespaces * The same codebase could have different configurations when deployed in different clusters * With the namespace concept, it is easy to support multiple applications to share the same configurations, while also allowing them to customize the configurations * Multiple languages is provided in user interface(currently Chinese and English) * **Configuration changes takes effect in real time (hot release)** * After the user modified the configuration and released it in Apollo, the sdk will receive the latest configurations in real time (1 second) and notify the application * **Release version management** * Every configuration releases are versioned, which is friendly to support configuration rollback * **Grayscale release** * Support grayscale configuration release, for example, after clicking release, it will only take effect for some application instances. After a period of observation, we could push the configurations to all application instances if there is no problem * **Authorization management, release approval and operation audit** * Great authorization mechanism is designed for applications and configurations management, and the management of configurations is divided into two operations: editing and publishing, therefore greatly reducing human errors * All operations have audit logs for easy tracking of problems * **Client side configuration information monitoring** * It's very easy to see which instances are using the configurations and what versions they are using * **Rich SDKs available** * Provides native sdks of Java and .Net to facilitate application integration * Support Spring Placeholder, Annotation and Spring Boot ConfigurationProperties for easy application use (requires Spring 3.1.1+) * Http APIs are provided, so non-Java and .Net applications can integrate conveniently * Rich third party sdks are also available, e.g. Golang, Python, NodeJS, PHP, C, etc * **Open platform API** * Apollo itself provides a unified configuration management interface, which supports features such as multi-environment, multi-data center configuration management, permissions, and process governance * However, for the sake of versatility, Apollo will not put too many restrictions on the modification of the configuration, as long as it conforms to the basic format, it can be saved. * In our research, we found that for some users, their configurations may have more complicated formats, such as xml, json, and the format needs to be verified * There are also some users such as DAL, which not only have a specific format, but also need to verify the entered value before saving, such as checking whether the database, username and password match * For this type of application, Apollo allows the application to modify and release configurations through open APIs, which has great authorization and permission control mechanism built in * **Simple deployment** * As an infrastructure service, the configuration center has very high availability requirements, which forces Apollo to rely on external dependencies as little as possible * Currently, the only external dependency is MySQL, so the deployment is very simple. Apollo can run as long as Java and MySQL are installed * Apollo also provides a packaging script, which can generate all required installation packages with just one click, and supports customization of runtime parameters # Usage 1. [Apollo User Guide](https://www.apolloconfig.com/#/zh/usage/apollo-user-guide) 2. [Java SDK User Guide](https://www.apolloconfig.com/#/zh/usage/java-sdk-user-guide) 3. [.Net SDK user Guide](https://www.apolloconfig.com/#/zh/usage/dotnet-sdk-user-guide) 4. [Third Party SDK User Guide](https://www.apolloconfig.com/#/zh/usage/third-party-sdks-user-guide) 5. [Other Language Client User Guide](https://www.apolloconfig.com/#/zh/usage/other-language-client-user-guide) 6. [Apollo Open APIs](https://www.apolloconfig.com/#/zh/usage/apollo-open-api-platform) 7. [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo User Practices](https://www.apolloconfig.com/#/zh/usage/apollo-user-practices) 9. [Apollo Security Best Practices](https://www.apolloconfig.com/#/zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design * [Apollo Design](https://www.apolloconfig.com/#/zh/design/apollo-design) * [Apollo Core Concept - Namespace](https://www.apolloconfig.com/#/zh/design/apollo-core-concept-namespace) * [Apollo Architecture Analysis](https://mp.weixin.qq.com/s/-hUaQPzfsl9Lm3IqQW3VDQ) * [Apollo Source Code Explanation](http://www.iocoder.cn/categories/Apollo/) # Development * [Apollo Development Guide](https://www.apolloconfig.com/#/zh/development/apollo-development-guide) * Code Styles * [Eclipse Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) * [Intellij Code Style](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) # Deployment * [Quick Start](https://www.apolloconfig.com/#/zh/deployment/quick-start) * [Distributed Deployment Guide](https://www.apolloconfig.com/#/zh/deployment/distributed-deployment-guide) # Release Notes * [Releases](https://github.com/ctripcorp/apollo/releases) # FAQ * [FAQ](https://www.apolloconfig.com/#/zh/faq/faq) * [Common Issues in Deployment & Development Phase](https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase) # Presentation * [Design and Implementation Details of Apollo](http://www.itdks.com/dakalive/detail/3420) * [Slides](https://myslide.cn/slides/10168) * [Configuration Center Makes Microservices Smart](https://2018.qconshanghai.com/presentation/799) * [Slides](https://myslide.cn/slides/10035) # Publication * [Design and Implementation Details of Apollo](https://www.infoq.cn/article/open-source-configuration-center-apollo) * [Configuration Center Makes Microservices Smart](https://mp.weixin.qq.com/s/iDmYJre_ULEIxuliu1EbIQ) # Community * [Apollo Team](https://www.apolloconfig.com/#/en/community/team) * [Community Governance](https://github.com/ctripcorp/apollo/blob/master/GOVERNANCE.md) * [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE). # Known Users > Sorted by registration order,users are welcome to register in [https://github.com/ctripcorp/apollo/issues/451](https://github.com/ctripcorp/apollo/issues/451) (reference purpose only for the community) <table> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ctrip.png" alt="携程"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bluestone.png" alt="青石证券"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sagreen.png" alt="沙绿"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/umetrip.jpg" alt="航旅纵横"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhuanzhuan.png" alt="58转转"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/phone580.png" alt="蜂助手"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hainan-airlines.png" alt="海南航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cvte.png" alt="CVTE"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mainbo.jpg" alt="明博教育"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/madailicai.png" alt="麻袋理财"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mxnavi.jpg" alt="美行科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fshows.jpg" alt="首展科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/feezu.png" alt="易微行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rencaijia.png" alt="人才加"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/keking.png" alt="凯京集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/leoao.png" alt="乐刻运动"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dji.png" alt="大疆"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kkmh.png" alt="快看漫画"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wolaidai.png" alt="我来贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xsrj.png" alt="虚实软件"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yanxuan.png" alt="网易严选"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sjzg.png" alt="视觉中国"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zc360.png" alt="资产360"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ecarx.png" alt="亿咖通"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/5173.png" alt="5173"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hujiang.png" alt="沪江"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/163yun.png" alt="网易云基础服务"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cash-bus.png" alt="现金巴士"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/smartisan.png" alt="锤子科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/toodc.png" alt="头等仓"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/juneyaoair.png" alt="吉祥航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/263mobile.png" alt="263移动通信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/toutoujinrong.png" alt="投投金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mytijian.png" alt="每天健康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maiyabank.png" alt="麦芽金服"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fengunion.png" alt="蜂向科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/geex-logo.png" alt="即科金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beike.png" alt="贝壳网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/youzan.png" alt="有赞"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunjihuitong.png" alt="云集汇通"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rhinotech.png" alt="犀牛瀚海科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/nxin.png" alt="农信互联"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mgzf.png" alt="蘑菇租房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/huli-logo.png" alt="狐狸金服"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mandao.png" alt="漫道集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enmonster.png" alt="怪兽充电"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/nanguazufang.png" alt="南瓜租房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shitoujinrong.png" alt="石投金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tubatu.png" alt="土巴兔"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/payh_logo.png" alt="平安银行"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xinxindai.png" alt="新新贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chrtc.png" alt="中国华戎科技集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tuya_logo.png" alt="涂鸦智能"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/szlcsc.jpg" alt="立创商城"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hairongyi.png" alt="乐赚金服"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kxqc.png" alt="开心汽车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ppcredit.png" alt="乐赚金服"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/primeton.png" alt="普元信息"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hoskeeper.png" alt="医帮管家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fula.png" alt="付啦信用卡管家"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uzai.png" alt="悠哉网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/91wutong.png" alt="梧桐诚选"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ppdai.png" alt="拍拍贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xinyongfei.png" alt="信用飞"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dxy.png" alt="丁香园"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ghtech.png" alt="国槐科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/qbb.png" alt="亲宝宝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/huawei_logo.png" alt="华为视频直播"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/weiboyi.png" alt="微播易"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ofpay.png" alt="欧飞"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mishuo.png" alt="迷说"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yixia.png" alt="一下科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daocloud.png" alt="DaoCloud"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cnvex.png" alt="汽摩交易所"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/100tal.png" alt="好未来教育集团"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ainirobot.png" alt="猎户星空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhuojian.png" alt="卓健科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enjoyor.png" alt="银江股份"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tuhu.png" alt="途虎养车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/homedo.png" alt="河姆渡"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xwbank.png" alt="新网银行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ctspcl.png" alt="中旅安信云贷"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meiyou.png" alt="美柚"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zkh-logo.png" alt="震坤行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wgss.png" alt="万谷盛世"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/plateno.png" alt="铂涛旅行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lifesense.png" alt="乐心"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/reachmedia.png" alt="亿投传媒"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/guxiansheng.png" alt="股先生"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caixuetang.png" alt="财学堂"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/4399.png" alt="4399"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/autohome.png" alt="汽车之家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mbcaijing.png" alt="面包财经"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hoopchina.png" alt="虎扑"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sohu-auto.png" alt="搜狐汽车"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/liangfuzhengxin.png" alt="量富征信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maihaoche.png" alt="卖好车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zyiot.jpg" alt="中移物联网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/biauto.png" alt="易车网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maiyaole.png" alt="一药网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaoying.png" alt="小影"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caibeike.png" alt="彩贝壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yeelight.png" alt="YEELIGHT"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/itsgmu.png" alt="积目"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/acmedcare.png" alt="极致医疗"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinhui365.png" alt="金汇金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/900etrip.png" alt="久柏易游"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/24xiaomai.png" alt="小麦铺"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/vvic.png" alt="搜款网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mizlicai.png" alt="米庄理财"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bjt.png" alt="贝吉塔网络科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/weimob.png" alt="微盟"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kada.png" alt="网易卡搭"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kapbook.png" alt="股书"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jumore.png" alt="聚贸"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bimface.png" alt="广联达bimface"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/globalgrow.png" alt="环球易购"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jollychic.png" alt="浙江执御"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/2dfire.jpg" alt="二维火"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shopin.png" alt="上品"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/inspur.png" alt="浪潮集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ngarihealth.png" alt="纳里健康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/oraro.png" alt="橙红科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dragonpass.png" alt="龙腾出行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lizhi.fm.png" alt="荔枝"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/htd.png" alt="汇通达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunrong.png" alt="云融金科"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tszg360.png" alt="天生掌柜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rongplus.png" alt="容联光辉"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/intellif.png" alt="云天励飞"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jiayundata.png" alt="嘉云数据"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zts.png" alt="中泰证券网络金融部"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/163dun.png" alt="网易易盾"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiangwushuo.png" alt="享物说"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sto.png" alt="申通"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinhe.png" alt="金和网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/2345.png" alt="二三四五"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chtwm.jpg" alt="恒天财富"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uweixin.png" alt="沐雪微信"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wzeye.png" alt="温州医科大学附属眼视光医院"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/10010pay.png" alt="联通支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shanshu.png" alt="杉数科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/fenlibao.png" alt="分利宝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hetao101.png" alt="核桃编程"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaohongshu.png" alt="小红书"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/blissmall.png" alt="幸福西饼"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ky-express.png" alt="跨越速运"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/oyohotels.png" alt="OYO"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/100-me.png" alt="叮咚买菜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhidaohulian.jpg" alt="智道网联"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xueqiu.jpg" alt="雪球"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/autocloudpro.png" alt="车通云"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dadaabc.png" alt="哒哒英语"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xedaojia.jpg" alt="小E微店"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daling.png" alt="达令家"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/renliwo.png" alt="人力窝"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mocire.jpg" alt="嘉美在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/uepay.png" alt="极易付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wdom.png" alt="智慧开源"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cheshiku.png" alt="车仕库"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/taimeitech.png" alt="太美医疗科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yilianbaihui.png" alt="亿联百汇"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhoupu123.png" alt="舟谱数据"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/frxs.png" alt="芙蓉兴盛"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beastshop.png" alt="野兽派"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kaishustory.png" alt="凯叔讲故事"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/haodf.png" alt="好大夫在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/insyunmi.png" alt="云幂信息技术"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/duiba.png" alt="兑吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/9ji.png" alt="九机网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sui.png" alt="随手科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aixiangdao.png" alt="万谷盛世"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yunzhangfang.png" alt="云账房"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yuantutech.png" alt="浙江远图互联"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/qk365.png" alt="青客公寓"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/eastmoney.png" alt="东方财富"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jikexiu.png" alt="极客修"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meix.png" alt="美市科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zto.png" alt="中通快递"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/e6yun.png" alt="易流科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xiaoyuanzhao.png" alt="实习僧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dalingjia.png" alt="达令家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/secoo.png" alt="寺库"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lianlianpay.png" alt="连连支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhongan.png" alt="众安保险"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/360jinrong.png" alt="360金融"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/caschina.png" alt="中航服商旅"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ke.png" alt="贝壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yeahmobi.png" alt="Yeahmobi易点天下"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/idengyun.png" alt="北京登云美业网络科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jinher.png" alt="金和网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/komect.png" alt="中移(杭州)信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/beisen.png" alt="北森"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/log56.png" alt="合肥维天运通"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/meboth.png" alt="北京蜜步科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/postop.png" alt="术康"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rfchina.png" alt="富力集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tfxing.png" alt="天府行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/8travelpay.png" alt="八商山"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/centaline.png" alt="中原地产"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zkyda.png" alt="智科云达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/house730.png" alt="中原730"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/pagoda.png" alt="百果园"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bolome.png" alt="波罗蜜"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xignite.png" alt="Xignite"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aduer.png" alt="杭州有云科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jojoreading.png" alt="成都书声科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sweetome.png" alt="斯维登集团"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/vipthink.png" alt="广东快乐种子科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/tongxuecool.png" alt="上海盈翼文化传播有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/sccfc.png" alt="上海尚诚消费金融股份有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ziroom.png" alt="自如网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jd.png" alt="京东"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/rabbitpre.png" alt="兔展智能"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhubei.png" alt="竹贝"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/imile.png" alt="iMile(中东)"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/helloglobal.png" alt="哈罗出行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zhaopin.png" alt="智联招聘"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/acadsoc.png" alt="阿卡索"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mojory.png" alt="妙知旅"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chengduoduo.png" alt="程多多"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/baojunev.png" alt="上汽通用五菱"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/leyan.png" alt="乐言科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/dushu.png" alt="樊登读书"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/zyiz.png" alt="找一找教程网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bppc.png" alt="中油碧辟石油有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shanglv51.png" alt="四川商旅无忧科技服务有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/waijiao365.png" alt="懿鸢网络科技(上海)有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gaoding.jpg" alt="稿定科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ricacorp.png" alt="搵樓 - 利嘉閣"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/t3go.png" alt="南京领行科技股份有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mokahr.jpg" alt="北京希瑞亚斯科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/printrainbow.png" alt="印彩虹印刷公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/milliontech.png" alt="Million Tech"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/guoguokeji.jpg" alt="果果科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/airkunming.png" alt="昆明航空"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/5i5j.png" alt="我爱我家"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gjzq.png" alt="国金证券"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/enjoymusic.jpg" alt="不亦乐乎"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cnhnb.png" alt="惠农网"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/daoklab.jpg" alt="成都道壳"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ausnutria.jpg" alt="澳优乳业"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/deiyoudian.png" alt="河南有态度信息科技有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ezhiyang.png" alt="智阳第一人力"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shie.png" alt="上海保险交易所"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/wsecar.png" alt="万顺叫车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shouqinba.jpg" alt="收钱吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/baozun.png" alt="宝尊电商"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xbnwl.png" alt="喜百年供应链"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gwwisdom.png" alt="南京观为智慧软件科技有限公司"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ztrip.png" alt="在途商旅"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hualala.png" alt="哗啦啦"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/xin.png" alt="优信二手车"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/maycur.png" alt="每刻科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bullyun.png" alt="杭州蛮牛"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/bestpay.png" alt="翼支付"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mockuai.png" alt="魔筷科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ct108.png" alt="畅唐网络"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jusdaglobal.jpg" alt="准时达"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/izaodao.png" alt="早道网校"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ovopark.jpg" alt="万店掌"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/funstory.jpg" alt="推文科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/lemonbox.png" alt="Lemonbox"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/polyt.png" alt="保利票务"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/chipwing.png" alt="芯翼科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/czbank.png" alt="浙商银行"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/czbyqy.png" alt="易企银科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/yundun.jpg" alt="上海云盾"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/gaiaworks.jpg" alt="苏州盖雅信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mengxiang.png" alt="爱库存"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/jidouauto.png" alt="极豆车联网"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ipalfish.png" alt="伴鱼少儿英语"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/iqboard.png" alt="锐达科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/koolearn.png" alt="新东方在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kingcome.png" alt="金康高科"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/soulapp.png" alt="soul"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/ezrpro.png" alt="驿氪"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/hc360.png" alt="慧聪"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/21cp.png" alt="中塑在线"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/goinglink.jpg" alt="甄云科技"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/aitrace.jpg" alt="追溯科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/moqipobing.png" alt="玩吧"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/cassan.png" alt="广州卡桑信息技术有限公司"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/shuidichou.png" alt="水滴"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/kuwo.png" alt="酷我音乐"></td> </tr> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mi.png" alt="小米"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/mvmyun.png" alt="今典"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/visabao.jpg" alt="签宝科技"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/known-users/inrice.png" alt="广州趣米网络科技有限公司"></td> <td><a target="_blank" href="https://github.com/ctripcorp/apollo/issues/451">More...</a></td> </tr> </table> # Awards <img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/awards/oschina-2018-award.jpg" width="240px" alt="The most popular Chinese open source software in 2018"> # Stargazers over time [![Stargazers over time](https://starcharts.herokuapp.com/ctripcorp/apollo.svg)](https://starcharts.herokuapp.com/ctripcorp/apollo)
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.MappedSuperclass; import javax.persistence.PrePersist; import javax.persistence.PreRemove; import javax.persistence.PreUpdate; @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "Id") private long id; @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected boolean isDeleted = false; @Column(name = "DataChange_CreatedBy", nullable = false) private String dataChangeCreatedBy; @Column(name = "DataChange_CreatedTime", nullable = false) private Date dataChangeCreatedTime; @Column(name = "DataChange_LastModifiedBy") private String dataChangeLastModifiedBy; @Column(name = "DataChange_LastTime") private Date dataChangeLastModifiedTime; public String getDataChangeCreatedBy() { return dataChangeCreatedBy; } public Date getDataChangeCreatedTime() { return dataChangeCreatedTime; } public String getDataChangeLastModifiedBy() { return dataChangeLastModifiedBy; } public Date getDataChangeLastModifiedTime() { return dataChangeLastModifiedTime; } public long getId() { return id; } public boolean isDeleted() { return isDeleted; } public void setDataChangeCreatedBy(String dataChangeCreatedBy) { this.dataChangeCreatedBy = dataChangeCreatedBy; } public void setDataChangeCreatedTime(Date dataChangeCreatedTime) { this.dataChangeCreatedTime = dataChangeCreatedTime; } public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; } public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; } public void setDeleted(boolean deleted) { isDeleted = deleted; } public void setId(long id) { this.id = id; } @PrePersist protected void prePersist() { if (this.dataChangeCreatedTime == null) { dataChangeCreatedTime = new Date(); } if (this.dataChangeLastModifiedTime == null) { dataChangeLastModifiedTime = new Date(); } } @PreUpdate protected void preUpdate() { this.dataChangeLastModifiedTime = new Date(); } @PreRemove protected void preRemove() { this.dataChangeLastModifiedTime = new Date(); } protected ToStringHelper toStringHelper() { return MoreObjects.toStringHelper(this).omitNullValues().add("id", id) .add("dataChangeCreatedBy", dataChangeCreatedBy) .add("dataChangeCreatedTime", dataChangeCreatedTime) .add("dataChangeLastModifiedBy", dataChangeLastModifiedBy) .add("dataChangeLastModifiedTime", dataChangeLastModifiedTime); } public String toString(){ return toStringHelper().toString(); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ 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; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.MappedSuperclass; import javax.persistence.PrePersist; import javax.persistence.PreRemove; import javax.persistence.PreUpdate; @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "Id") private long id; @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected boolean isDeleted = false; @Column(name = "DataChange_CreatedBy", nullable = false) private String dataChangeCreatedBy; @Column(name = "DataChange_CreatedTime", nullable = false) private Date dataChangeCreatedTime; @Column(name = "DataChange_LastModifiedBy") private String dataChangeLastModifiedBy; @Column(name = "DataChange_LastTime") private Date dataChangeLastModifiedTime; public String getDataChangeCreatedBy() { return dataChangeCreatedBy; } public Date getDataChangeCreatedTime() { return dataChangeCreatedTime; } public String getDataChangeLastModifiedBy() { return dataChangeLastModifiedBy; } public Date getDataChangeLastModifiedTime() { return dataChangeLastModifiedTime; } public long getId() { return id; } public boolean isDeleted() { return isDeleted; } public void setDataChangeCreatedBy(String dataChangeCreatedBy) { this.dataChangeCreatedBy = dataChangeCreatedBy; } public void setDataChangeCreatedTime(Date dataChangeCreatedTime) { this.dataChangeCreatedTime = dataChangeCreatedTime; } public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; } public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; } public void setDeleted(boolean deleted) { isDeleted = deleted; } public void setId(long id) { this.id = id; } @PrePersist protected void prePersist() { if (this.dataChangeCreatedTime == null) { dataChangeCreatedTime = new Date(); } if (this.dataChangeLastModifiedTime == null) { dataChangeLastModifiedTime = new Date(); } } @PreUpdate protected void preUpdate() { this.dataChangeLastModifiedTime = new Date(); } @PreRemove protected void preRemove() { this.dataChangeLastModifiedTime = new Date(); } protected ToStringHelper toStringHelper() { return MoreObjects.toStringHelper(this).omitNullValues().add("id", id) .add("dataChangeCreatedBy", dataChangeCreatedBy) .add("dataChangeCreatedTime", dataChangeCreatedTime) .add("dataChangeLastModifiedBy", dataChangeLastModifiedBy) .add("dataChangeLastModifiedTime", dataChangeLastModifiedTime); } public String toString(){ return toStringHelper().toString(); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anySetOf; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import com.google.common.collect.Sets; import java.util.Collections; import java.util.List; import java.util.Set; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.annotation.ApolloConfig; import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener; import com.google.common.collect.Lists; /** * @author Jason Song(song_s@ctrip.com) */ public class XMLConfigAnnotationTest extends AbstractSpringIntegrationTest { private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; @Test public void testApolloConfig() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigBean1 bean = getBean("spring/XmlConfigAnnotationTest1.xml", TestApolloConfigBean1.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); } @Test(expected = BeanCreationException.class) public void testApolloConfigWithWrongFieldType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest2.xml", TestApolloConfigBean2.class); } @Test public void testApolloConfigChangeListener() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloConfigChangeListenerBean1 bean = getBean("spring/XmlConfigAnnotationTest3.xml", TestApolloConfigChangeListenerBean1.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(4, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest4.xml", TestApolloConfigChangeListenerBean2.class); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamCount() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest5.xml", TestApolloConfigChangeListenerBean3.class); } @Test public void testApolloConfigChangeListenerWithInterestedKeys() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigChangeListenerWithInterestedKeysBean bean = getBean( "spring/XmlConfigAnnotationTest6.xml", TestApolloConfigChangeListenerWithInterestedKeysBean.class); final ArgumentCaptor<Set> applicationConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); final ArgumentCaptor<Set> fxApolloConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); verify(applicationConfig, times(2)) .addChangeListener(any(ConfigChangeListener.class), applicationConfigInterestedKeys.capture(), anySetOf(String.class)); verify(fxApolloConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), fxApolloConfigInterestedKeys.capture(), anySetOf(String.class)); assertEquals(2, applicationConfigInterestedKeys.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set interestedKeys : applicationConfigInterestedKeys.getAllValues()) { result.addAll(interestedKeys); } assertEquals(Sets.newHashSet("someKey", "anotherKey"), result); assertEquals(1, fxApolloConfigInterestedKeys.getAllValues().size()); assertEquals(Collections.singletonList(Sets.newHashSet("anotherKey")), fxApolloConfigInterestedKeys.getAllValues()); } private <T> T getBean(String xmlLocation, Class<T> beanClass) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(xmlLocation); return context.getBean(beanClass); } public static class TestApolloConfigBean1 { @ApolloConfig private Config config; @ApolloConfig(ConfigConsts.NAMESPACE_APPLICATION) private Config anotherConfig; @ApolloConfig(FX_APOLLO_NAMESPACE) private Config yetAnotherConfig; public Config getConfig() { return config; } public Config getAnotherConfig() { return anotherConfig; } public Config getYetAnotherConfig() { return yetAnotherConfig; } } public static class TestApolloConfigBean2 { @ApolloConfig private String config; } public static class TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent changeEvent1; private ConfigChangeEvent changeEvent2; private ConfigChangeEvent changeEvent3; @ApolloConfigChangeListener private void onChange1(ConfigChangeEvent changeEvent) { this.changeEvent1 = changeEvent; } @ApolloConfigChangeListener(ConfigConsts.NAMESPACE_APPLICATION) private void onChange2(ConfigChangeEvent changeEvent) { this.changeEvent2 = changeEvent; } @ApolloConfigChangeListener({ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}) private void onChange3(ConfigChangeEvent changeEvent) { this.changeEvent3 = changeEvent; } public ConfigChangeEvent getChangeEvent1() { return changeEvent1; } public ConfigChangeEvent getChangeEvent2() { return changeEvent2; } public ConfigChangeEvent getChangeEvent3() { return changeEvent3; } } public static class TestApolloConfigChangeListenerBean2 { @ApolloConfigChangeListener private void onChange(String event) { } } public static class TestApolloConfigChangeListenerBean3 { @ApolloConfigChangeListener private void onChange(ConfigChangeEvent event, String someParam) { } } static class TestApolloConfigChangeListenerWithInterestedKeysBean { @ApolloConfigChangeListener(interestedKeys = {"someKey"}) private void someOnChange(ConfigChangeEvent changeEvent) {} @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}, interestedKeys = {"anotherKey"}) private void anotherOnChange(ConfigChangeEvent changeEvent) { } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anySetOf; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import com.google.common.collect.Sets; import java.util.Collections; import java.util.List; import java.util.Set; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.annotation.ApolloConfig; import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener; import com.google.common.collect.Lists; /** * @author Jason Song(song_s@ctrip.com) */ public class XMLConfigAnnotationTest extends AbstractSpringIntegrationTest { private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; @Test public void testApolloConfig() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigBean1 bean = getBean("spring/XmlConfigAnnotationTest1.xml", TestApolloConfigBean1.class); assertEquals(applicationConfig, bean.getConfig()); assertEquals(applicationConfig, bean.getAnotherConfig()); assertEquals(fxApolloConfig, bean.getYetAnotherConfig()); } @Test(expected = BeanCreationException.class) public void testApolloConfigWithWrongFieldType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest2.xml", TestApolloConfigBean2.class); } @Test public void testApolloConfigChangeListener() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); final List<ConfigChangeListener> applicationListeners = Lists.newArrayList(); final List<ConfigChangeListener> fxApolloListeners = Lists.newArrayList(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { applicationListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(applicationConfig).addChangeListener(any(ConfigChangeListener.class)); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { fxApolloListeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class)); return Void.class; } }).when(fxApolloConfig).addChangeListener(any(ConfigChangeListener.class)); ConfigChangeEvent someEvent = mock(ConfigChangeEvent.class); ConfigChangeEvent anotherEvent = mock(ConfigChangeEvent.class); TestApolloConfigChangeListenerBean1 bean = getBean("spring/XmlConfigAnnotationTest3.xml", TestApolloConfigChangeListenerBean1.class); //PropertySourcesProcessor add listeners to listen config changed of all namespace assertEquals(4, applicationListeners.size()); assertEquals(1, fxApolloListeners.size()); for (ConfigChangeListener listener : applicationListeners) { listener.onChange(someEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(someEvent, bean.getChangeEvent3()); for (ConfigChangeListener listener : fxApolloListeners) { listener.onChange(anotherEvent); } assertEquals(someEvent, bean.getChangeEvent1()); assertEquals(someEvent, bean.getChangeEvent2()); assertEquals(anotherEvent, bean.getChangeEvent3()); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamType() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest4.xml", TestApolloConfigChangeListenerBean2.class); } @Test(expected = BeanCreationException.class) public void testApolloConfigChangeListenerWithWrongParamCount() throws Exception { Config applicationConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); getBean("spring/XmlConfigAnnotationTest5.xml", TestApolloConfigChangeListenerBean3.class); } @Test public void testApolloConfigChangeListenerWithInterestedKeys() throws Exception { Config applicationConfig = mock(Config.class); Config fxApolloConfig = mock(Config.class); mockConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationConfig); mockConfig(FX_APOLLO_NAMESPACE, fxApolloConfig); TestApolloConfigChangeListenerWithInterestedKeysBean bean = getBean( "spring/XmlConfigAnnotationTest6.xml", TestApolloConfigChangeListenerWithInterestedKeysBean.class); final ArgumentCaptor<Set> applicationConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); final ArgumentCaptor<Set> fxApolloConfigInterestedKeys = ArgumentCaptor.forClass(Set.class); verify(applicationConfig, times(2)) .addChangeListener(any(ConfigChangeListener.class), applicationConfigInterestedKeys.capture(), anySetOf(String.class)); verify(fxApolloConfig, times(1)) .addChangeListener(any(ConfigChangeListener.class), fxApolloConfigInterestedKeys.capture(), anySetOf(String.class)); assertEquals(2, applicationConfigInterestedKeys.getAllValues().size()); Set<String> result = Sets.newHashSet(); for (Set interestedKeys : applicationConfigInterestedKeys.getAllValues()) { result.addAll(interestedKeys); } assertEquals(Sets.newHashSet("someKey", "anotherKey"), result); assertEquals(1, fxApolloConfigInterestedKeys.getAllValues().size()); assertEquals(Collections.singletonList(Sets.newHashSet("anotherKey")), fxApolloConfigInterestedKeys.getAllValues()); } private <T> T getBean(String xmlLocation, Class<T> beanClass) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(xmlLocation); return context.getBean(beanClass); } public static class TestApolloConfigBean1 { @ApolloConfig private Config config; @ApolloConfig(ConfigConsts.NAMESPACE_APPLICATION) private Config anotherConfig; @ApolloConfig(FX_APOLLO_NAMESPACE) private Config yetAnotherConfig; public Config getConfig() { return config; } public Config getAnotherConfig() { return anotherConfig; } public Config getYetAnotherConfig() { return yetAnotherConfig; } } public static class TestApolloConfigBean2 { @ApolloConfig private String config; } public static class TestApolloConfigChangeListenerBean1 { private ConfigChangeEvent changeEvent1; private ConfigChangeEvent changeEvent2; private ConfigChangeEvent changeEvent3; @ApolloConfigChangeListener private void onChange1(ConfigChangeEvent changeEvent) { this.changeEvent1 = changeEvent; } @ApolloConfigChangeListener(ConfigConsts.NAMESPACE_APPLICATION) private void onChange2(ConfigChangeEvent changeEvent) { this.changeEvent2 = changeEvent; } @ApolloConfigChangeListener({ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}) private void onChange3(ConfigChangeEvent changeEvent) { this.changeEvent3 = changeEvent; } public ConfigChangeEvent getChangeEvent1() { return changeEvent1; } public ConfigChangeEvent getChangeEvent2() { return changeEvent2; } public ConfigChangeEvent getChangeEvent3() { return changeEvent3; } } public static class TestApolloConfigChangeListenerBean2 { @ApolloConfigChangeListener private void onChange(String event) { } } public static class TestApolloConfigChangeListenerBean3 { @ApolloConfigChangeListener private void onChange(ConfigChangeEvent event, String someParam) { } } static class TestApolloConfigChangeListenerWithInterestedKeysBean { @ApolloConfigChangeListener(interestedKeys = {"someKey"}) private void someOnChange(ConfigChangeEvent changeEvent) {} @ApolloConfigChangeListener(value = {ConfigConsts.NAMESPACE_APPLICATION, FX_APOLLO_NAMESPACE}, interestedKeys = {"anotherKey"}) private void anotherOnChange(ConfigChangeEvent changeEvent) { } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.bo; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.portal.entity.bo.KVEntity; import java.util.Set; public class ReleaseBO { private ReleaseDTO baseInfo; private Set<KVEntity> items; public ReleaseDTO getBaseInfo() { return baseInfo; } public void setBaseInfo(ReleaseDTO baseInfo) { this.baseInfo = baseInfo; } public Set<KVEntity> getItems() { return items; } public void setItems(Set<KVEntity> items) { this.items = items; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.entity.bo; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.portal.entity.bo.KVEntity; import java.util.Set; public class ReleaseBO { private ReleaseDTO baseInfo; private Set<KVEntity> items; public ReleaseDTO getBaseInfo() { return baseInfo; } public void setBaseInfo(ReleaseDTO baseInfo) { this.baseInfo = baseInfo; } public Set<KVEntity> getItems() { return items; } public void setItems(Set<KVEntity> items) { this.items = items; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DefaultPortalMetaServerProvider.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.environment; import static com.ctrip.framework.apollo.portal.environment.Env.transformToEnvMap; import com.ctrip.framework.apollo.core.utils.ResourceUtils; import com.ctrip.framework.apollo.portal.util.KeyValueUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; /** * Only use in apollo-portal * load all meta server address from * - System Property [key ends with "_meta" (case insensitive)] * - OS environment variable [key ends with "_meta" (case insensitive)] * - user's configuration file [key ends with ".meta" (case insensitive)] * when apollo-portal start up. * @see com.ctrip.framework.apollo.core.internals.LegacyMetaServerProvider * @author wxq */ class DefaultPortalMetaServerProvider implements PortalMetaServerProvider { private static final Logger logger = LoggerFactory.getLogger(DefaultPortalMetaServerProvider.class); /** * environments and their meta server address * properties file path */ private static final String APOLLO_ENV_PROPERTIES_FILE_PATH = "apollo-env.properties"; private volatile Map<Env, String> domains; DefaultPortalMetaServerProvider() { reload(); } @Override public String getMetaServerAddress(Env targetEnv) { String metaServerAddress = domains.get(targetEnv); return metaServerAddress == null ? null : metaServerAddress.trim(); } @Override public boolean exists(Env targetEnv) { return domains.containsKey(targetEnv); } @Override public void reload() { domains = initializeDomains(); logger.info("Loaded meta server addresses from system property, os environment and properties file: {}", domains); } /** * load all environment's meta address dynamically when this class loaded by JVM */ private Map<Env, String> initializeDomains() { // add to domain Map<Env, String> map = new ConcurrentHashMap<>(); // lower priority add first map.putAll(getDomainsFromPropertiesFile()); map.putAll(getDomainsFromOSEnvironment()); map.putAll(getDomainsFromSystemProperty()); // log all return map; } private Map<Env, String> getDomainsFromSystemProperty() { // find key-value from System Property which key ends with "_meta" (case insensitive) Map<String, String> metaServerAddressesFromSystemProperty = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getProperties(), "_meta"); // remove key's suffix "_meta" (case insensitive) metaServerAddressesFromSystemProperty = KeyValueUtils.removeKeySuffix(metaServerAddressesFromSystemProperty, "_meta".length()); return transformToEnvMap(metaServerAddressesFromSystemProperty); } private Map<Env, String> getDomainsFromOSEnvironment() { // find key-value from OS environment variable which key ends with "_meta" (case insensitive) Map<String, String> metaServerAddressesFromOSEnvironment = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getenv(), "_meta"); // remove key's suffix "_meta" (case insensitive) metaServerAddressesFromOSEnvironment = KeyValueUtils.removeKeySuffix(metaServerAddressesFromOSEnvironment, "_meta".length()); return transformToEnvMap(metaServerAddressesFromOSEnvironment); } private Map<Env, String> getDomainsFromPropertiesFile() { // find key-value from properties file which key ends with ".meta" (case insensitive) Properties properties = new Properties(); properties = ResourceUtils.readConfigFile(APOLLO_ENV_PROPERTIES_FILE_PATH, properties); Map<String, String> metaServerAddressesFromPropertiesFile = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(properties, ".meta"); // remove key's suffix ".meta" (case insensitive) metaServerAddressesFromPropertiesFile = KeyValueUtils.removeKeySuffix(metaServerAddressesFromPropertiesFile, ".meta".length()); return transformToEnvMap(metaServerAddressesFromPropertiesFile); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.environment; import static com.ctrip.framework.apollo.portal.environment.Env.transformToEnvMap; import com.ctrip.framework.apollo.core.utils.ResourceUtils; import com.ctrip.framework.apollo.portal.util.KeyValueUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; /** * Only use in apollo-portal * load all meta server address from * - System Property [key ends with "_meta" (case insensitive)] * - OS environment variable [key ends with "_meta" (case insensitive)] * - user's configuration file [key ends with ".meta" (case insensitive)] * when apollo-portal start up. * @see com.ctrip.framework.apollo.core.internals.LegacyMetaServerProvider * @author wxq */ class DefaultPortalMetaServerProvider implements PortalMetaServerProvider { private static final Logger logger = LoggerFactory.getLogger(DefaultPortalMetaServerProvider.class); /** * environments and their meta server address * properties file path */ private static final String APOLLO_ENV_PROPERTIES_FILE_PATH = "apollo-env.properties"; private volatile Map<Env, String> domains; DefaultPortalMetaServerProvider() { reload(); } @Override public String getMetaServerAddress(Env targetEnv) { String metaServerAddress = domains.get(targetEnv); return metaServerAddress == null ? null : metaServerAddress.trim(); } @Override public boolean exists(Env targetEnv) { return domains.containsKey(targetEnv); } @Override public void reload() { domains = initializeDomains(); logger.info("Loaded meta server addresses from system property, os environment and properties file: {}", domains); } /** * load all environment's meta address dynamically when this class loaded by JVM */ private Map<Env, String> initializeDomains() { // add to domain Map<Env, String> map = new ConcurrentHashMap<>(); // lower priority add first map.putAll(getDomainsFromPropertiesFile()); map.putAll(getDomainsFromOSEnvironment()); map.putAll(getDomainsFromSystemProperty()); // log all return map; } private Map<Env, String> getDomainsFromSystemProperty() { // find key-value from System Property which key ends with "_meta" (case insensitive) Map<String, String> metaServerAddressesFromSystemProperty = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getProperties(), "_meta"); // remove key's suffix "_meta" (case insensitive) metaServerAddressesFromSystemProperty = KeyValueUtils.removeKeySuffix(metaServerAddressesFromSystemProperty, "_meta".length()); return transformToEnvMap(metaServerAddressesFromSystemProperty); } private Map<Env, String> getDomainsFromOSEnvironment() { // find key-value from OS environment variable which key ends with "_meta" (case insensitive) Map<String, String> metaServerAddressesFromOSEnvironment = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getenv(), "_meta"); // remove key's suffix "_meta" (case insensitive) metaServerAddressesFromOSEnvironment = KeyValueUtils.removeKeySuffix(metaServerAddressesFromOSEnvironment, "_meta".length()); return transformToEnvMap(metaServerAddressesFromOSEnvironment); } private Map<Env, String> getDomainsFromPropertiesFile() { // find key-value from properties file which key ends with ".meta" (case insensitive) Properties properties = new Properties(); properties = ResourceUtils.readConfigFile(APOLLO_ENV_PROPERTIES_FILE_PATH, properties); Map<String, String> metaServerAddressesFromPropertiesFile = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(properties, ".meta"); // remove key's suffix ".meta" (case insensitive) metaServerAddressesFromPropertiesFile = KeyValueUtils.removeKeySuffix(metaServerAddressesFromPropertiesFile, ".meta".length()); return transformToEnvMap(metaServerAddressesFromPropertiesFile); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.ConfigRepository; import com.ctrip.framework.apollo.internals.DefaultInjector; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.io.CharStreams; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.Date; import java.util.Map; import java.util.Objects; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.springframework.util.ReflectionUtils; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigFile; import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.internals.ConfigManager; import com.google.common.collect.Maps; import org.springframework.util.ReflectionUtils.FieldCallback; import org.springframework.util.ReflectionUtils.FieldFilter; /** * @author Jason Song(song_s@ctrip.com) */ public abstract class AbstractSpringIntegrationTest { private static final Map<String, Config> CONFIG_REGISTRY = Maps.newHashMap(); private static final Map<String, ConfigFile> CONFIG_FILE_REGISTRY = Maps.newHashMap(); private static Method CONFIG_SERVICE_RESET; private static Method PROPERTY_SOURCES_PROCESSOR_RESET; static { try { CONFIG_SERVICE_RESET = ConfigService.class.getDeclaredMethod("reset"); ReflectionUtils.makeAccessible(CONFIG_SERVICE_RESET); PROPERTY_SOURCES_PROCESSOR_RESET = PropertySourcesProcessor.class.getDeclaredMethod("reset"); ReflectionUtils.makeAccessible(PROPERTY_SOURCES_PROCESSOR_RESET); } catch (NoSuchMethodException e) { e.printStackTrace(); } } @Before public void setUp() throws Exception { doSetUp(); } @After public void tearDown() throws Exception { doTearDown(); } protected SimpleConfig prepareConfig(String namespaceName, Properties properties) { ConfigRepository configRepository = mock(ConfigRepository.class); when(configRepository.getConfig()).thenReturn(properties); SimpleConfig config = new SimpleConfig(ConfigConsts.NAMESPACE_APPLICATION, configRepository); mockConfig(namespaceName, config); return config; } protected static Properties readYamlContentAsConfigFileProperties(String caseName) throws IOException { final String filePath = "spring/yaml/" + caseName; ClassLoader classLoader = AbstractSpringIntegrationTest.class.getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(filePath); Objects.requireNonNull(inputStream, filePath + " may be not exist under src/test/resources/"); String yamlContent = CharStreams .toString(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); Properties properties = new Properties(); properties.setProperty(ConfigConsts.CONFIG_FILE_CONTENT_KEY, yamlContent); return properties; } protected static YamlConfigFile prepareYamlConfigFile(String namespaceNameWithFormat, Properties properties) { ConfigRepository configRepository = mock(ConfigRepository.class); when(configRepository.getConfig()).thenReturn(properties); // spy it for testing after YamlConfigFile configFile = spy(new YamlConfigFile(namespaceNameWithFormat, configRepository)); mockConfigFile(namespaceNameWithFormat, configFile); return configFile; } protected Properties assembleProperties(String key, String value) { Properties properties = new Properties(); properties.setProperty(key, value); return properties; } protected Properties assembleProperties(String key, String value, String key2, String value2) { Properties properties = new Properties(); properties.setProperty(key, value); properties.setProperty(key2, value2); return properties; } protected Properties assembleProperties(String key, String value, String key2, String value2, String key3, String value3) { Properties properties = new Properties(); properties.setProperty(key, value); properties.setProperty(key2, value2); properties.setProperty(key3, value3); return properties; } protected Date assembleDate(int year, int month, int day, int hour, int minute, int second, int millisecond) { Calendar date = Calendar.getInstance(); date.set(year, month - 1, day, hour, minute, second); //Month in Calendar is 0 based date.set(Calendar.MILLISECOND, millisecond); return date.getTime(); } protected static void mockConfig(String namespace, Config config) { CONFIG_REGISTRY.put(namespace, config); } protected static void mockConfigFile(String namespaceNameWithFormat, ConfigFile configFile) { CONFIG_FILE_REGISTRY.put(namespaceNameWithFormat, configFile); } protected static void doSetUp() { //as ConfigService is singleton, so we must manually clear its container ReflectionUtils.invokeMethod(CONFIG_SERVICE_RESET, null); //as PropertySourcesProcessor has some static variables, so we must manually clear them ReflectionUtils.invokeMethod(PROPERTY_SOURCES_PROCESSOR_RESET, null); DefaultInjector defaultInjector = new DefaultInjector(); ConfigManager defaultConfigManager = defaultInjector.getInstance(ConfigManager.class); MockInjector.setInstance(ConfigManager.class, new MockConfigManager(defaultConfigManager)); MockInjector.setDelegate(defaultInjector); } protected static void doTearDown() { MockInjector.reset(); CONFIG_REGISTRY.clear(); } private static class MockConfigManager implements ConfigManager { private final ConfigManager delegate; public MockConfigManager(ConfigManager delegate) { this.delegate = delegate; } @Override public Config getConfig(String namespace) { Config config = CONFIG_REGISTRY.get(namespace); if (config != null) { return config; } return delegate.getConfig(namespace); } @Override public ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat) { ConfigFile configFile = CONFIG_FILE_REGISTRY.get(String.format("%s.%s", namespace, configFileFormat.getValue())); if (configFile != null) { return configFile; } return delegate.getConfigFile(namespace, configFileFormat); } } protected static class MockConfigUtil extends ConfigUtil { private boolean isAutoUpdateInjectedSpringProperties; public void setAutoUpdateInjectedSpringProperties(boolean autoUpdateInjectedSpringProperties) { isAutoUpdateInjectedSpringProperties = autoUpdateInjectedSpringProperties; } @Override public boolean isAutoUpdateInjectedSpringPropertiesEnabled() { return isAutoUpdateInjectedSpringProperties; } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.ConfigRepository; import com.ctrip.framework.apollo.internals.DefaultInjector; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.internals.YamlConfigFile; import com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.io.CharStreams; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.Date; import java.util.Map; import java.util.Objects; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.springframework.util.ReflectionUtils; import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.ConfigFile; import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.internals.ConfigManager; import com.google.common.collect.Maps; import org.springframework.util.ReflectionUtils.FieldCallback; import org.springframework.util.ReflectionUtils.FieldFilter; /** * @author Jason Song(song_s@ctrip.com) */ public abstract class AbstractSpringIntegrationTest { private static final Map<String, Config> CONFIG_REGISTRY = Maps.newHashMap(); private static final Map<String, ConfigFile> CONFIG_FILE_REGISTRY = Maps.newHashMap(); private static Method CONFIG_SERVICE_RESET; private static Method PROPERTY_SOURCES_PROCESSOR_RESET; static { try { CONFIG_SERVICE_RESET = ConfigService.class.getDeclaredMethod("reset"); ReflectionUtils.makeAccessible(CONFIG_SERVICE_RESET); PROPERTY_SOURCES_PROCESSOR_RESET = PropertySourcesProcessor.class.getDeclaredMethod("reset"); ReflectionUtils.makeAccessible(PROPERTY_SOURCES_PROCESSOR_RESET); } catch (NoSuchMethodException e) { e.printStackTrace(); } } @Before public void setUp() throws Exception { doSetUp(); } @After public void tearDown() throws Exception { doTearDown(); } protected SimpleConfig prepareConfig(String namespaceName, Properties properties) { ConfigRepository configRepository = mock(ConfigRepository.class); when(configRepository.getConfig()).thenReturn(properties); SimpleConfig config = new SimpleConfig(ConfigConsts.NAMESPACE_APPLICATION, configRepository); mockConfig(namespaceName, config); return config; } protected static Properties readYamlContentAsConfigFileProperties(String caseName) throws IOException { final String filePath = "spring/yaml/" + caseName; ClassLoader classLoader = AbstractSpringIntegrationTest.class.getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(filePath); Objects.requireNonNull(inputStream, filePath + " may be not exist under src/test/resources/"); String yamlContent = CharStreams .toString(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); Properties properties = new Properties(); properties.setProperty(ConfigConsts.CONFIG_FILE_CONTENT_KEY, yamlContent); return properties; } protected static YamlConfigFile prepareYamlConfigFile(String namespaceNameWithFormat, Properties properties) { ConfigRepository configRepository = mock(ConfigRepository.class); when(configRepository.getConfig()).thenReturn(properties); // spy it for testing after YamlConfigFile configFile = spy(new YamlConfigFile(namespaceNameWithFormat, configRepository)); mockConfigFile(namespaceNameWithFormat, configFile); return configFile; } protected Properties assembleProperties(String key, String value) { Properties properties = new Properties(); properties.setProperty(key, value); return properties; } protected Properties assembleProperties(String key, String value, String key2, String value2) { Properties properties = new Properties(); properties.setProperty(key, value); properties.setProperty(key2, value2); return properties; } protected Properties assembleProperties(String key, String value, String key2, String value2, String key3, String value3) { Properties properties = new Properties(); properties.setProperty(key, value); properties.setProperty(key2, value2); properties.setProperty(key3, value3); return properties; } protected Date assembleDate(int year, int month, int day, int hour, int minute, int second, int millisecond) { Calendar date = Calendar.getInstance(); date.set(year, month - 1, day, hour, minute, second); //Month in Calendar is 0 based date.set(Calendar.MILLISECOND, millisecond); return date.getTime(); } protected static void mockConfig(String namespace, Config config) { CONFIG_REGISTRY.put(namespace, config); } protected static void mockConfigFile(String namespaceNameWithFormat, ConfigFile configFile) { CONFIG_FILE_REGISTRY.put(namespaceNameWithFormat, configFile); } protected static void doSetUp() { //as ConfigService is singleton, so we must manually clear its container ReflectionUtils.invokeMethod(CONFIG_SERVICE_RESET, null); //as PropertySourcesProcessor has some static variables, so we must manually clear them ReflectionUtils.invokeMethod(PROPERTY_SOURCES_PROCESSOR_RESET, null); DefaultInjector defaultInjector = new DefaultInjector(); ConfigManager defaultConfigManager = defaultInjector.getInstance(ConfigManager.class); MockInjector.setInstance(ConfigManager.class, new MockConfigManager(defaultConfigManager)); MockInjector.setDelegate(defaultInjector); } protected static void doTearDown() { MockInjector.reset(); CONFIG_REGISTRY.clear(); } private static class MockConfigManager implements ConfigManager { private final ConfigManager delegate; public MockConfigManager(ConfigManager delegate) { this.delegate = delegate; } @Override public Config getConfig(String namespace) { Config config = CONFIG_REGISTRY.get(namespace); if (config != null) { return config; } return delegate.getConfig(namespace); } @Override public ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat) { ConfigFile configFile = CONFIG_FILE_REGISTRY.get(String.format("%s.%s", namespace, configFileFormat.getValue())); if (configFile != null) { return configFile; } return delegate.getConfigFile(namespace, configFileFormat); } } protected static class MockConfigUtil extends ConfigUtil { private boolean isAutoUpdateInjectedSpringProperties; public void setAutoUpdateInjectedSpringProperties(boolean autoUpdateInjectedSpringProperties) { isAutoUpdateInjectedSpringProperties = autoUpdateInjectedSpringProperties; } @Override public boolean isAutoUpdateInjectedSpringPropertiesEnabled() { return isAutoUpdateInjectedSpringProperties; } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; 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.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.core.utils.StringUtils; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; @Service public class AppNamespaceService { private static final Logger logger = LoggerFactory.getLogger(AppNamespaceService.class); private final AppNamespaceRepository appNamespaceRepository; private final NamespaceService namespaceService; private final ClusterService clusterService; private final AuditService auditService; public AppNamespaceService( final AppNamespaceRepository appNamespaceRepository, final @Lazy NamespaceService namespaceService, final @Lazy ClusterService clusterService, final AuditService auditService) { this.appNamespaceRepository = appNamespaceRepository; this.namespaceService = namespaceService; this.clusterService = clusterService; this.auditService = auditService; } public boolean isAppNamespaceNameUnique(String appId, String namespaceName) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(namespaceName, "Namespace must not be null"); return Objects.isNull(appNamespaceRepository.findByAppIdAndName(appId, namespaceName)); } public AppNamespace findPublicNamespaceByName(String namespaceName) { Preconditions.checkArgument(namespaceName != null, "Namespace must not be null"); return appNamespaceRepository.findByNameAndIsPublicTrue(namespaceName); } public List<AppNamespace> findByAppId(String appId) { return appNamespaceRepository.findByAppId(appId); } public List<AppNamespace> findPublicNamespacesByNames(Set<String> namespaceNames) { if (namespaceNames == null || namespaceNames.isEmpty()) { return Collections.emptyList(); } return appNamespaceRepository.findByNameInAndIsPublicTrue(namespaceNames); } public List<AppNamespace> findPrivateAppNamespace(String appId) { return appNamespaceRepository.findByAppIdAndIsPublic(appId, false); } public AppNamespace findOne(String appId, String namespaceName) { Preconditions .checkArgument(!StringUtils.isContainEmpty(appId, namespaceName), "appId or Namespace must not be null"); return appNamespaceRepository.findByAppIdAndName(appId, namespaceName); } public List<AppNamespace> findByAppIdAndNamespaces(String appId, Set<String> namespaceNames) { Preconditions.checkArgument(!Strings.isNullOrEmpty(appId), "appId must not be null"); if (namespaceNames == null || namespaceNames.isEmpty()) { return Collections.emptyList(); } return appNamespaceRepository.findByAppIdAndNameIn(appId, namespaceNames); } @Transactional public void createDefaultAppNamespace(String appId, String createBy) { if (!isAppNamespaceNameUnique(appId, ConfigConsts.NAMESPACE_APPLICATION)) { throw new ServiceException("appnamespace not unique"); } AppNamespace appNs = new AppNamespace(); appNs.setAppId(appId); appNs.setName(ConfigConsts.NAMESPACE_APPLICATION); appNs.setComment("default app namespace"); appNs.setFormat(ConfigFileFormat.Properties.getValue()); appNs.setDataChangeCreatedBy(createBy); appNs.setDataChangeLastModifiedBy(createBy); appNamespaceRepository.save(appNs); auditService.audit(AppNamespace.class.getSimpleName(), appNs.getId(), Audit.OP.INSERT, createBy); } @Transactional public AppNamespace createAppNamespace(AppNamespace appNamespace) { String createBy = appNamespace.getDataChangeCreatedBy(); if (!isAppNamespaceNameUnique(appNamespace.getAppId(), appNamespace.getName())) { throw new ServiceException("appnamespace not unique"); } appNamespace.setId(0);//protection appNamespace.setDataChangeCreatedBy(createBy); appNamespace.setDataChangeLastModifiedBy(createBy); appNamespace = appNamespaceRepository.save(appNamespace); createNamespaceForAppNamespaceInAllCluster(appNamespace.getAppId(), appNamespace.getName(), createBy); auditService.audit(AppNamespace.class.getSimpleName(), appNamespace.getId(), Audit.OP.INSERT, createBy); return appNamespace; } public AppNamespace update(AppNamespace appNamespace) { AppNamespace managedNs = appNamespaceRepository.findByAppIdAndName(appNamespace.getAppId(), appNamespace.getName()); BeanUtils.copyEntityProperties(appNamespace, managedNs); managedNs = appNamespaceRepository.save(managedNs); auditService.audit(AppNamespace.class.getSimpleName(), managedNs.getId(), Audit.OP.UPDATE, managedNs.getDataChangeLastModifiedBy()); return managedNs; } public void createNamespaceForAppNamespaceInAllCluster(String appId, String namespaceName, String createBy) { List<Cluster> clusters = clusterService.findParentClusters(appId); for (Cluster cluster : clusters) { // in case there is some dirty data, e.g. public namespace deleted in other app and now created in this app if (!namespaceService.isNamespaceUnique(appId, cluster.getName(), namespaceName)) { continue; } Namespace namespace = new Namespace(); namespace.setClusterName(cluster.getName()); namespace.setAppId(appId); namespace.setNamespaceName(namespaceName); namespace.setDataChangeCreatedBy(createBy); namespace.setDataChangeLastModifiedBy(createBy); namespaceService.save(namespace); } } @Transactional public void batchDelete(String appId, String operator) { appNamespaceRepository.batchDeleteByAppId(appId, operator); } @Transactional public void deleteAppNamespace(AppNamespace appNamespace, String operator) { String appId = appNamespace.getAppId(); String namespaceName = appNamespace.getName(); logger.info("{} is deleting AppNamespace, appId: {}, namespace: {}", operator, appId, namespaceName); // 1. delete namespaces List<Namespace> namespaces = namespaceService.findByAppIdAndNamespaceName(appId, namespaceName); if (namespaces != null) { for (Namespace namespace : namespaces) { namespaceService.deleteNamespace(namespace, operator); } } // 2. delete app namespace appNamespaceRepository.delete(appId, namespaceName, operator); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.service; 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.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.core.utils.StringUtils; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; @Service public class AppNamespaceService { private static final Logger logger = LoggerFactory.getLogger(AppNamespaceService.class); private final AppNamespaceRepository appNamespaceRepository; private final NamespaceService namespaceService; private final ClusterService clusterService; private final AuditService auditService; public AppNamespaceService( final AppNamespaceRepository appNamespaceRepository, final @Lazy NamespaceService namespaceService, final @Lazy ClusterService clusterService, final AuditService auditService) { this.appNamespaceRepository = appNamespaceRepository; this.namespaceService = namespaceService; this.clusterService = clusterService; this.auditService = auditService; } public boolean isAppNamespaceNameUnique(String appId, String namespaceName) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(namespaceName, "Namespace must not be null"); return Objects.isNull(appNamespaceRepository.findByAppIdAndName(appId, namespaceName)); } public AppNamespace findPublicNamespaceByName(String namespaceName) { Preconditions.checkArgument(namespaceName != null, "Namespace must not be null"); return appNamespaceRepository.findByNameAndIsPublicTrue(namespaceName); } public List<AppNamespace> findByAppId(String appId) { return appNamespaceRepository.findByAppId(appId); } public List<AppNamespace> findPublicNamespacesByNames(Set<String> namespaceNames) { if (namespaceNames == null || namespaceNames.isEmpty()) { return Collections.emptyList(); } return appNamespaceRepository.findByNameInAndIsPublicTrue(namespaceNames); } public List<AppNamespace> findPrivateAppNamespace(String appId) { return appNamespaceRepository.findByAppIdAndIsPublic(appId, false); } public AppNamespace findOne(String appId, String namespaceName) { Preconditions .checkArgument(!StringUtils.isContainEmpty(appId, namespaceName), "appId or Namespace must not be null"); return appNamespaceRepository.findByAppIdAndName(appId, namespaceName); } public List<AppNamespace> findByAppIdAndNamespaces(String appId, Set<String> namespaceNames) { Preconditions.checkArgument(!Strings.isNullOrEmpty(appId), "appId must not be null"); if (namespaceNames == null || namespaceNames.isEmpty()) { return Collections.emptyList(); } return appNamespaceRepository.findByAppIdAndNameIn(appId, namespaceNames); } @Transactional public void createDefaultAppNamespace(String appId, String createBy) { if (!isAppNamespaceNameUnique(appId, ConfigConsts.NAMESPACE_APPLICATION)) { throw new ServiceException("appnamespace not unique"); } AppNamespace appNs = new AppNamespace(); appNs.setAppId(appId); appNs.setName(ConfigConsts.NAMESPACE_APPLICATION); appNs.setComment("default app namespace"); appNs.setFormat(ConfigFileFormat.Properties.getValue()); appNs.setDataChangeCreatedBy(createBy); appNs.setDataChangeLastModifiedBy(createBy); appNamespaceRepository.save(appNs); auditService.audit(AppNamespace.class.getSimpleName(), appNs.getId(), Audit.OP.INSERT, createBy); } @Transactional public AppNamespace createAppNamespace(AppNamespace appNamespace) { String createBy = appNamespace.getDataChangeCreatedBy(); if (!isAppNamespaceNameUnique(appNamespace.getAppId(), appNamespace.getName())) { throw new ServiceException("appnamespace not unique"); } appNamespace.setId(0);//protection appNamespace.setDataChangeCreatedBy(createBy); appNamespace.setDataChangeLastModifiedBy(createBy); appNamespace = appNamespaceRepository.save(appNamespace); createNamespaceForAppNamespaceInAllCluster(appNamespace.getAppId(), appNamespace.getName(), createBy); auditService.audit(AppNamespace.class.getSimpleName(), appNamespace.getId(), Audit.OP.INSERT, createBy); return appNamespace; } public AppNamespace update(AppNamespace appNamespace) { AppNamespace managedNs = appNamespaceRepository.findByAppIdAndName(appNamespace.getAppId(), appNamespace.getName()); BeanUtils.copyEntityProperties(appNamespace, managedNs); managedNs = appNamespaceRepository.save(managedNs); auditService.audit(AppNamespace.class.getSimpleName(), managedNs.getId(), Audit.OP.UPDATE, managedNs.getDataChangeLastModifiedBy()); return managedNs; } public void createNamespaceForAppNamespaceInAllCluster(String appId, String namespaceName, String createBy) { List<Cluster> clusters = clusterService.findParentClusters(appId); for (Cluster cluster : clusters) { // in case there is some dirty data, e.g. public namespace deleted in other app and now created in this app if (!namespaceService.isNamespaceUnique(appId, cluster.getName(), namespaceName)) { continue; } Namespace namespace = new Namespace(); namespace.setClusterName(cluster.getName()); namespace.setAppId(appId); namespace.setNamespaceName(namespaceName); namespace.setDataChangeCreatedBy(createBy); namespace.setDataChangeLastModifiedBy(createBy); namespaceService.save(namespace); } } @Transactional public void batchDelete(String appId, String operator) { appNamespaceRepository.batchDeleteByAppId(appId, operator); } @Transactional public void deleteAppNamespace(AppNamespace appNamespace, String operator) { String appId = appNamespace.getAppId(); String namespaceName = appNamespace.getName(); logger.info("{} is deleting AppNamespace, appId: {}, namespace: {}", operator, appId, namespaceName); // 1. delete namespaces List<Namespace> namespaces = namespaceService.findByAppIdAndNamespaceName(appId, namespaceName); if (namespaces != null) { for (Namespace namespace : namespaces) { namespaceService.deleteNamespace(namespace, operator); } } // 2. delete app namespace appNamespaceRepository.delete(appId, namespaceName, operator); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.spi.UserService; /** * @author vdisk <vdisk@foxmail.com> */ public interface OidcLocalUserService extends UserService { /** * create local user info related to the oidc user * * @param newUserInfo the oidc user's info */ void createLocalUser(UserInfo newUserInfo); /** * update user's info * * @param newUserInfo the new user's info */ void updateUserInfo(UserInfo newUserInfo); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.oidc; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.spi.UserService; /** * @author vdisk <vdisk@foxmail.com> */ public interface OidcLocalUserService extends UserService { /** * create local user info related to the oidc user * * @param newUserInfo the oidc user's info */ void createLocalUser(UserInfo newUserInfo); /** * update user's info * * @param newUserInfo the new user's info */ void updateUserInfo(UserInfo newUserInfo); }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.utils; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.common.utils.UniqueKeyGenerator; /** * @author Jason Song(song_s@ctrip.com) */ public class ReleaseKeyGenerator extends UniqueKeyGenerator { /** * Generate the release key in the format: timestamp+appId+cluster+namespace+hash(ipAsInt+counter) * * @param namespace the namespace of the release * @return the unique release key */ public static String generateReleaseKey(Namespace namespace) { return generate(namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.utils; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.common.utils.UniqueKeyGenerator; /** * @author Jason Song(song_s@ctrip.com) */ public class ReleaseKeyGenerator extends UniqueKeyGenerator { /** * Generate the release key in the format: timestamp+appId+cluster+namespace+hash(ipAsInt+counter) * * @param namespace the namespace of the release * @return the unique release key */ public static String generateReleaseKey(Namespace namespace) { return generate(namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.internals; import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory; import com.ctrip.framework.apollo.enums.ConfigSourceType; import java.io.IOException; import java.io.InputStream; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import org.slf4j.Logger; 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.tracer.Tracer; import com.ctrip.framework.apollo.util.ExceptionUtil; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.RateLimiter; /** * @author Jason Song(song_s@ctrip.com) */ public class DefaultConfig extends AbstractConfig implements RepositoryChangeListener { private static final Logger logger = DeferredLoggerFactory.getLogger(DefaultConfig.class); private final String m_namespace; private final Properties m_resourceProperties; private final AtomicReference<Properties> m_configProperties; private final ConfigRepository m_configRepository; private final RateLimiter m_warnLogRateLimiter; private volatile ConfigSourceType m_sourceType = ConfigSourceType.NONE; /** * Constructor. * * @param namespace the namespace of this config instance * @param configRepository the config repository for this config instance */ public DefaultConfig(String namespace, ConfigRepository configRepository) { m_namespace = namespace; m_resourceProperties = loadFromResource(m_namespace); m_configRepository = configRepository; m_configProperties = new AtomicReference<>(); m_warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute initialize(); } private void initialize() { try { updateConfig(m_configRepository.getConfig(), m_configRepository.getSourceType()); } catch (Throwable ex) { Tracer.logError(ex); logger.warn("Init Apollo Local Config failed - namespace: {}, reason: {}.", m_namespace, ExceptionUtil.getDetailMessage(ex)); } finally { //register the change listener no matter config repository is working or not //so that whenever config repository is recovered, config could get changed m_configRepository.addChangeListener(this); } } @Override public String getProperty(String key, String defaultValue) { // step 1: check system properties, i.e. -Dkey=value String value = System.getProperty(key); // step 2: check local cached properties file if (value == null && m_configProperties.get() != null) { value = m_configProperties.get().getProperty(key); } /** * step 3: check env variable, i.e. PATH=... * normally system environment variables are in UPPERCASE, however there might be exceptions. * so the caller should provide the key in the right case */ if (value == null) { value = System.getenv(key); } // step 4: check properties file from classpath if (value == null && m_resourceProperties != null) { value = m_resourceProperties.getProperty(key); } if (value == null && m_configProperties.get() == null && m_warnLogRateLimiter.tryAcquire()) { logger.warn( "Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!", m_namespace); } return value == null ? defaultValue : value; } @Override public Set<String> getPropertyNames() { Properties properties = m_configProperties.get(); if (properties == null) { return Collections.emptySet(); } return stringPropertyNames(properties); } @Override public ConfigSourceType getSourceType() { return m_sourceType; } private Set<String> stringPropertyNames(Properties properties) { //jdk9以下版本Properties#enumerateStringProperties方法存在性能问题,keys() + get(k) 重复迭代, jdk9之后改为entrySet遍历. Map<String, String> h = new LinkedHashMap<>(); for (Map.Entry<Object, Object> e : properties.entrySet()) { Object k = e.getKey(); Object v = e.getValue(); if (k instanceof String && v instanceof String) { h.put((String) k, (String) v); } } return h.keySet(); } @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); //check double checked result if (actualChanges.isEmpty()) { return; } this.fireConfigChange(m_namespace, actualChanges); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } private void updateConfig(Properties newConfigProperties, ConfigSourceType sourceType) { m_configProperties.set(newConfigProperties); m_sourceType = sourceType; } private Map<String, ConfigChange> updateAndCalcConfigChanges(Properties newConfigProperties, ConfigSourceType sourceType) { List<ConfigChange> configChanges = calcPropertyChanges(m_namespace, m_configProperties.get(), newConfigProperties); ImmutableMap.Builder<String, ConfigChange> actualChanges = new ImmutableMap.Builder<>(); /** === Double check since DefaultConfig has multiple config sources ==== **/ //1. use getProperty to update configChanges's old value for (ConfigChange change : configChanges) { change.setOldValue(this.getProperty(change.getPropertyName(), change.getOldValue())); } //2. update m_configProperties updateConfig(newConfigProperties, sourceType); clearConfigCache(); //3. use getProperty to update configChange's new value and calc the final changes for (ConfigChange change : configChanges) { change.setNewValue(this.getProperty(change.getPropertyName(), change.getNewValue())); switch (change.getChangeType()) { case ADDED: if (Objects.equals(change.getOldValue(), change.getNewValue())) { break; } if (change.getOldValue() != null) { change.setChangeType(PropertyChangeType.MODIFIED); } actualChanges.put(change.getPropertyName(), change); break; case MODIFIED: if (!Objects.equals(change.getOldValue(), change.getNewValue())) { actualChanges.put(change.getPropertyName(), change); } break; case DELETED: if (Objects.equals(change.getOldValue(), change.getNewValue())) { break; } if (change.getNewValue() != null) { change.setChangeType(PropertyChangeType.MODIFIED); } actualChanges.put(change.getPropertyName(), change); break; default: //do nothing break; } } return actualChanges.build(); } private Properties loadFromResource(String namespace) { String name = String.format("META-INF/config/%s.properties", namespace); InputStream in = ClassLoaderUtil.getLoader().getResourceAsStream(name); Properties properties = null; if (in != null) { properties = propertiesFactory.getPropertiesInstance(); try { properties.load(in); } catch (IOException ex) { Tracer.logError(ex); logger.error("Load resource config for namespace {} failed", namespace, ex); } finally { try { in.close(); } catch (IOException ex) { // ignore } } } return properties; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.internals; import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory; import com.ctrip.framework.apollo.enums.ConfigSourceType; import java.io.IOException; import java.io.InputStream; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import org.slf4j.Logger; 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.tracer.Tracer; import com.ctrip.framework.apollo.util.ExceptionUtil; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.RateLimiter; /** * @author Jason Song(song_s@ctrip.com) */ public class DefaultConfig extends AbstractConfig implements RepositoryChangeListener { private static final Logger logger = DeferredLoggerFactory.getLogger(DefaultConfig.class); private final String m_namespace; private final Properties m_resourceProperties; private final AtomicReference<Properties> m_configProperties; private final ConfigRepository m_configRepository; private final RateLimiter m_warnLogRateLimiter; private volatile ConfigSourceType m_sourceType = ConfigSourceType.NONE; /** * Constructor. * * @param namespace the namespace of this config instance * @param configRepository the config repository for this config instance */ public DefaultConfig(String namespace, ConfigRepository configRepository) { m_namespace = namespace; m_resourceProperties = loadFromResource(m_namespace); m_configRepository = configRepository; m_configProperties = new AtomicReference<>(); m_warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute initialize(); } private void initialize() { try { updateConfig(m_configRepository.getConfig(), m_configRepository.getSourceType()); } catch (Throwable ex) { Tracer.logError(ex); logger.warn("Init Apollo Local Config failed - namespace: {}, reason: {}.", m_namespace, ExceptionUtil.getDetailMessage(ex)); } finally { //register the change listener no matter config repository is working or not //so that whenever config repository is recovered, config could get changed m_configRepository.addChangeListener(this); } } @Override public String getProperty(String key, String defaultValue) { // step 1: check system properties, i.e. -Dkey=value String value = System.getProperty(key); // step 2: check local cached properties file if (value == null && m_configProperties.get() != null) { value = m_configProperties.get().getProperty(key); } /** * step 3: check env variable, i.e. PATH=... * normally system environment variables are in UPPERCASE, however there might be exceptions. * so the caller should provide the key in the right case */ if (value == null) { value = System.getenv(key); } // step 4: check properties file from classpath if (value == null && m_resourceProperties != null) { value = m_resourceProperties.getProperty(key); } if (value == null && m_configProperties.get() == null && m_warnLogRateLimiter.tryAcquire()) { logger.warn( "Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!", m_namespace); } return value == null ? defaultValue : value; } @Override public Set<String> getPropertyNames() { Properties properties = m_configProperties.get(); if (properties == null) { return Collections.emptySet(); } return stringPropertyNames(properties); } @Override public ConfigSourceType getSourceType() { return m_sourceType; } private Set<String> stringPropertyNames(Properties properties) { //jdk9以下版本Properties#enumerateStringProperties方法存在性能问题,keys() + get(k) 重复迭代, jdk9之后改为entrySet遍历. Map<String, String> h = new LinkedHashMap<>(); for (Map.Entry<Object, Object> e : properties.entrySet()) { Object k = e.getKey(); Object v = e.getValue(); if (k instanceof String && v instanceof String) { h.put((String) k, (String) v); } } return h.keySet(); } @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); //check double checked result if (actualChanges.isEmpty()) { return; } this.fireConfigChange(m_namespace, actualChanges); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } private void updateConfig(Properties newConfigProperties, ConfigSourceType sourceType) { m_configProperties.set(newConfigProperties); m_sourceType = sourceType; } private Map<String, ConfigChange> updateAndCalcConfigChanges(Properties newConfigProperties, ConfigSourceType sourceType) { List<ConfigChange> configChanges = calcPropertyChanges(m_namespace, m_configProperties.get(), newConfigProperties); ImmutableMap.Builder<String, ConfigChange> actualChanges = new ImmutableMap.Builder<>(); /** === Double check since DefaultConfig has multiple config sources ==== **/ //1. use getProperty to update configChanges's old value for (ConfigChange change : configChanges) { change.setOldValue(this.getProperty(change.getPropertyName(), change.getOldValue())); } //2. update m_configProperties updateConfig(newConfigProperties, sourceType); clearConfigCache(); //3. use getProperty to update configChange's new value and calc the final changes for (ConfigChange change : configChanges) { change.setNewValue(this.getProperty(change.getPropertyName(), change.getNewValue())); switch (change.getChangeType()) { case ADDED: if (Objects.equals(change.getOldValue(), change.getNewValue())) { break; } if (change.getOldValue() != null) { change.setChangeType(PropertyChangeType.MODIFIED); } actualChanges.put(change.getPropertyName(), change); break; case MODIFIED: if (!Objects.equals(change.getOldValue(), change.getNewValue())) { actualChanges.put(change.getPropertyName(), change); } break; case DELETED: if (Objects.equals(change.getOldValue(), change.getNewValue())) { break; } if (change.getNewValue() != null) { change.setChangeType(PropertyChangeType.MODIFIED); } actualChanges.put(change.getPropertyName(), change); break; default: //do nothing break; } } return actualChanges.build(); } private Properties loadFromResource(String namespace) { String name = String.format("META-INF/config/%s.properties", namespace); InputStream in = ClassLoaderUtil.getLoader().getResourceAsStream(name); Properties properties = null; if (in != null) { properties = propertiesFactory.getPropertiesInstance(); try { properties.load(in); } catch (IOException ex) { Tracer.logError(ex); logger.error("Load resource config for namespace {} failed", namespace, ex); } finally { try { in.close(); } catch (IOException ex) { // ignore } } } return properties; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationController.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.configservice.controller; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.ReleaseMessageListener; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.utils.EntityManagerUtil; import com.ctrip.framework.apollo.configservice.service.ReleaseMessageServiceWithCache; 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.tracer.Tracer; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.async.DeferredResult; import java.util.List; import java.util.Set; /** * @author Jason Song(song_s@ctrip.com) */ @Deprecated @RestController @RequestMapping("/notifications") public class NotificationController implements ReleaseMessageListener { private static final Logger logger = LoggerFactory.getLogger(NotificationController.class); private static final long TIMEOUT = 30 * 1000;//30 seconds private final Multimap<String, DeferredResult<ResponseEntity<ApolloConfigNotification>>> deferredResults = Multimaps.synchronizedSetMultimap(HashMultimap.create()); private static final ResponseEntity<ApolloConfigNotification> NOT_MODIFIED_RESPONSE = new ResponseEntity<>(HttpStatus.NOT_MODIFIED); private static final Splitter STRING_SPLITTER = Splitter.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).omitEmptyStrings(); private final WatchKeysUtil watchKeysUtil; private final ReleaseMessageServiceWithCache releaseMessageService; private final EntityManagerUtil entityManagerUtil; private final NamespaceUtil namespaceUtil; public NotificationController( final WatchKeysUtil watchKeysUtil, final ReleaseMessageServiceWithCache releaseMessageService, final EntityManagerUtil entityManagerUtil, final NamespaceUtil namespaceUtil) { this.watchKeysUtil = watchKeysUtil; this.releaseMessageService = releaseMessageService; this.entityManagerUtil = entityManagerUtil; this.namespaceUtil = namespaceUtil; } /** * For single namespace notification, reserved for older version of apollo clients * * @param appId the appId * @param cluster the cluster * @param namespace the namespace name * @param dataCenter the datacenter * @param notificationId the notification id for the namespace * @param clientIp the client side ip * @return a deferred result */ @GetMapping public DeferredResult<ResponseEntity<ApolloConfigNotification>> pollNotification( @RequestParam(value = "appId") String appId, @RequestParam(value = "cluster") String cluster, @RequestParam(value = "namespace", defaultValue = ConfigConsts.NAMESPACE_APPLICATION) String namespace, @RequestParam(value = "dataCenter", required = false) String dataCenter, @RequestParam(value = "notificationId", defaultValue = "-1") long notificationId, @RequestParam(value = "ip", required = false) String clientIp) { //strip out .properties suffix namespace = namespaceUtil.filterNamespaceName(namespace); Set<String> watchedKeys = watchKeysUtil.assembleAllWatchKeys(appId, cluster, namespace, dataCenter); DeferredResult<ResponseEntity<ApolloConfigNotification>> deferredResult = new DeferredResult<>(TIMEOUT, NOT_MODIFIED_RESPONSE); //check whether client is out-dated ReleaseMessage latest = releaseMessageService.findLatestReleaseMessageForMessages(watchedKeys); /** * Manually close the entity manager. * Since for async request, Spring won't do so until the request is finished, * which is unacceptable since we are doing long polling - means the db connection would be hold * for a very long time */ entityManagerUtil.closeEntityManager(); if (latest != null && latest.getId() != notificationId) { deferredResult.setResult(new ResponseEntity<>( new ApolloConfigNotification(namespace, latest.getId()), HttpStatus.OK)); } else { //register all keys for (String key : watchedKeys) { this.deferredResults.put(key, deferredResult); } deferredResult .onTimeout(() -> logWatchedKeys(watchedKeys, "Apollo.LongPoll.TimeOutKeys")); deferredResult.onCompletion(() -> { //unregister all keys for (String key : watchedKeys) { deferredResults.remove(key, deferredResult); } logWatchedKeys(watchedKeys, "Apollo.LongPoll.CompletedKeys"); }); logWatchedKeys(watchedKeys, "Apollo.LongPoll.RegisteredKeys"); logger.debug("Listening {} from appId: {}, cluster: {}, namespace: {}, datacenter: {}", watchedKeys, appId, cluster, namespace, dataCenter); } return deferredResult; } @Override public void handleMessage(ReleaseMessage message, String channel) { logger.info("message received - channel: {}, message: {}", channel, message); String content = message.getMessage(); Tracer.logEvent("Apollo.LongPoll.Messages", content); if (!Topics.APOLLO_RELEASE_TOPIC.equals(channel) || Strings.isNullOrEmpty(content)) { return; } List<String> keys = STRING_SPLITTER.splitToList(content); //message should be appId+cluster+namespace if (keys.size() != 3) { logger.error("message format invalid - {}", content); return; } ResponseEntity<ApolloConfigNotification> notification = new ResponseEntity<>( new ApolloConfigNotification(keys.get(2), message.getId()), HttpStatus.OK); if (!deferredResults.containsKey(content)) { return; } //create a new list to avoid ConcurrentModificationException List<DeferredResult<ResponseEntity<ApolloConfigNotification>>> results = Lists.newArrayList(deferredResults.get(content)); logger.debug("Notify {} clients for key {}", results.size(), content); for (DeferredResult<ResponseEntity<ApolloConfigNotification>> result : results) { result.setResult(notification); } logger.debug("Notification completed"); } private void logWatchedKeys(Set<String> watchedKeys, String eventName) { for (String watchedKey : watchedKeys) { Tracer.logEvent(eventName, watchedKey); } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.configservice.controller; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.ReleaseMessageListener; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.utils.EntityManagerUtil; import com.ctrip.framework.apollo.configservice.service.ReleaseMessageServiceWithCache; 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.tracer.Tracer; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.async.DeferredResult; import java.util.List; import java.util.Set; /** * @author Jason Song(song_s@ctrip.com) */ @Deprecated @RestController @RequestMapping("/notifications") public class NotificationController implements ReleaseMessageListener { private static final Logger logger = LoggerFactory.getLogger(NotificationController.class); private static final long TIMEOUT = 30 * 1000;//30 seconds private final Multimap<String, DeferredResult<ResponseEntity<ApolloConfigNotification>>> deferredResults = Multimaps.synchronizedSetMultimap(HashMultimap.create()); private static final ResponseEntity<ApolloConfigNotification> NOT_MODIFIED_RESPONSE = new ResponseEntity<>(HttpStatus.NOT_MODIFIED); private static final Splitter STRING_SPLITTER = Splitter.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).omitEmptyStrings(); private final WatchKeysUtil watchKeysUtil; private final ReleaseMessageServiceWithCache releaseMessageService; private final EntityManagerUtil entityManagerUtil; private final NamespaceUtil namespaceUtil; public NotificationController( final WatchKeysUtil watchKeysUtil, final ReleaseMessageServiceWithCache releaseMessageService, final EntityManagerUtil entityManagerUtil, final NamespaceUtil namespaceUtil) { this.watchKeysUtil = watchKeysUtil; this.releaseMessageService = releaseMessageService; this.entityManagerUtil = entityManagerUtil; this.namespaceUtil = namespaceUtil; } /** * For single namespace notification, reserved for older version of apollo clients * * @param appId the appId * @param cluster the cluster * @param namespace the namespace name * @param dataCenter the datacenter * @param notificationId the notification id for the namespace * @param clientIp the client side ip * @return a deferred result */ @GetMapping public DeferredResult<ResponseEntity<ApolloConfigNotification>> pollNotification( @RequestParam(value = "appId") String appId, @RequestParam(value = "cluster") String cluster, @RequestParam(value = "namespace", defaultValue = ConfigConsts.NAMESPACE_APPLICATION) String namespace, @RequestParam(value = "dataCenter", required = false) String dataCenter, @RequestParam(value = "notificationId", defaultValue = "-1") long notificationId, @RequestParam(value = "ip", required = false) String clientIp) { //strip out .properties suffix namespace = namespaceUtil.filterNamespaceName(namespace); Set<String> watchedKeys = watchKeysUtil.assembleAllWatchKeys(appId, cluster, namespace, dataCenter); DeferredResult<ResponseEntity<ApolloConfigNotification>> deferredResult = new DeferredResult<>(TIMEOUT, NOT_MODIFIED_RESPONSE); //check whether client is out-dated ReleaseMessage latest = releaseMessageService.findLatestReleaseMessageForMessages(watchedKeys); /** * Manually close the entity manager. * Since for async request, Spring won't do so until the request is finished, * which is unacceptable since we are doing long polling - means the db connection would be hold * for a very long time */ entityManagerUtil.closeEntityManager(); if (latest != null && latest.getId() != notificationId) { deferredResult.setResult(new ResponseEntity<>( new ApolloConfigNotification(namespace, latest.getId()), HttpStatus.OK)); } else { //register all keys for (String key : watchedKeys) { this.deferredResults.put(key, deferredResult); } deferredResult .onTimeout(() -> logWatchedKeys(watchedKeys, "Apollo.LongPoll.TimeOutKeys")); deferredResult.onCompletion(() -> { //unregister all keys for (String key : watchedKeys) { deferredResults.remove(key, deferredResult); } logWatchedKeys(watchedKeys, "Apollo.LongPoll.CompletedKeys"); }); logWatchedKeys(watchedKeys, "Apollo.LongPoll.RegisteredKeys"); logger.debug("Listening {} from appId: {}, cluster: {}, namespace: {}, datacenter: {}", watchedKeys, appId, cluster, namespace, dataCenter); } return deferredResult; } @Override public void handleMessage(ReleaseMessage message, String channel) { logger.info("message received - channel: {}, message: {}", channel, message); String content = message.getMessage(); Tracer.logEvent("Apollo.LongPoll.Messages", content); if (!Topics.APOLLO_RELEASE_TOPIC.equals(channel) || Strings.isNullOrEmpty(content)) { return; } List<String> keys = STRING_SPLITTER.splitToList(content); //message should be appId+cluster+namespace if (keys.size() != 3) { logger.error("message format invalid - {}", content); return; } ResponseEntity<ApolloConfigNotification> notification = new ResponseEntity<>( new ApolloConfigNotification(keys.get(2), message.getId()), HttpStatus.OK); if (!deferredResults.containsKey(content)) { return; } //create a new list to avoid ConcurrentModificationException List<DeferredResult<ResponseEntity<ApolloConfigNotification>>> results = Lists.newArrayList(deferredResults.get(content)); logger.debug("Notify {} clients for key {}", results.size(), content); for (DeferredResult<ResponseEntity<ApolloConfigNotification>> result : results) { result.setResult(notification); } logger.debug("Notification completed"); } private void logWatchedKeys(Set<String> watchedKeys, String eventName) { for (String watchedKey : watchedKeys) { Tracer.logEvent(eventName, watchedKey); } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleDTO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.dto; import com.google.common.collect.Sets; import java.util.Set; public class GrayReleaseRuleDTO extends BaseDTO { private String appId; private String clusterName; private String namespaceName; private String branchName; private Set<GrayReleaseRuleItemDTO> ruleItems; private Long releaseId; public GrayReleaseRuleDTO(String appId, String clusterName, String namespaceName, String branchName) { this.appId = appId; this.clusterName = clusterName; this.namespaceName = namespaceName; this.branchName = branchName; this.ruleItems = Sets.newHashSet(); } public String getAppId() { return appId; } public String getClusterName() { return clusterName; } public String getNamespaceName() { return namespaceName; } public String getBranchName() { return branchName; } public Set<GrayReleaseRuleItemDTO> getRuleItems() { return ruleItems; } public void setRuleItems(Set<GrayReleaseRuleItemDTO> ruleItems) { this.ruleItems = ruleItems; } public void addRuleItem(GrayReleaseRuleItemDTO ruleItem) { this.ruleItems.add(ruleItem); } public Long getReleaseId() { return releaseId; } public void setReleaseId(Long releaseId) { this.releaseId = releaseId; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.common.dto; import com.google.common.collect.Sets; import java.util.Set; public class GrayReleaseRuleDTO extends BaseDTO { private String appId; private String clusterName; private String namespaceName; private String branchName; private Set<GrayReleaseRuleItemDTO> ruleItems; private Long releaseId; public GrayReleaseRuleDTO(String appId, String clusterName, String namespaceName, String branchName) { this.appId = appId; this.clusterName = clusterName; this.namespaceName = namespaceName; this.branchName = branchName; this.ruleItems = Sets.newHashSet(); } public String getAppId() { return appId; } public String getClusterName() { return clusterName; } public String getNamespaceName() { return namespaceName; } public String getBranchName() { return branchName; } public Set<GrayReleaseRuleItemDTO> getRuleItems() { return ruleItems; } public void setRuleItems(Set<GrayReleaseRuleItemDTO> ruleItems) { this.ruleItems = ruleItems; } public void addRuleItem(GrayReleaseRuleItemDTO ruleItem) { this.ruleItems.add(ruleItem); } public Long getReleaseId() { return releaseId; } public void setReleaseId(Long releaseId) { this.releaseId = releaseId; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.service; import com.ctrip.framework.apollo.openapi.entity.ConsumerRole; import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository; import com.ctrip.framework.apollo.portal.entity.po.Permission; import com.ctrip.framework.apollo.portal.entity.po.RolePermission; import com.ctrip.framework.apollo.portal.repository.PermissionRepository; import com.ctrip.framework.apollo.portal.repository.RolePermissionRepository; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /** * @author Jason Song(song_s@ctrip.com) */ @Service public class ConsumerRolePermissionService { private final PermissionRepository permissionRepository; private final ConsumerRoleRepository consumerRoleRepository; private final RolePermissionRepository rolePermissionRepository; public ConsumerRolePermissionService( final PermissionRepository permissionRepository, final ConsumerRoleRepository consumerRoleRepository, final RolePermissionRepository rolePermissionRepository) { this.permissionRepository = permissionRepository; this.consumerRoleRepository = consumerRoleRepository; this.rolePermissionRepository = rolePermissionRepository; } /** * Check whether user has the permission */ public boolean consumerHasPermission(long consumerId, String permissionType, String targetId) { Permission permission = permissionRepository.findTopByPermissionTypeAndTargetId(permissionType, targetId); if (permission == null) { return false; } List<ConsumerRole> consumerRoles = consumerRoleRepository.findByConsumerId(consumerId); if (CollectionUtils.isEmpty(consumerRoles)) { return false; } Set<Long> roleIds = consumerRoles.stream().map(ConsumerRole::getRoleId).collect(Collectors.toSet()); List<RolePermission> rolePermissions = rolePermissionRepository.findByRoleIdIn(roleIds); if (CollectionUtils.isEmpty(rolePermissions)) { return false; } for (RolePermission rolePermission : rolePermissions) { if (rolePermission.getPermissionId() == permission.getId()) { return true; } } return false; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.service; import com.ctrip.framework.apollo.openapi.entity.ConsumerRole; import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository; import com.ctrip.framework.apollo.portal.entity.po.Permission; import com.ctrip.framework.apollo.portal.entity.po.RolePermission; import com.ctrip.framework.apollo.portal.repository.PermissionRepository; import com.ctrip.framework.apollo.portal.repository.RolePermissionRepository; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /** * @author Jason Song(song_s@ctrip.com) */ @Service public class ConsumerRolePermissionService { private final PermissionRepository permissionRepository; private final ConsumerRoleRepository consumerRoleRepository; private final RolePermissionRepository rolePermissionRepository; public ConsumerRolePermissionService( final PermissionRepository permissionRepository, final ConsumerRoleRepository consumerRoleRepository, final RolePermissionRepository rolePermissionRepository) { this.permissionRepository = permissionRepository; this.consumerRoleRepository = consumerRoleRepository; this.rolePermissionRepository = rolePermissionRepository; } /** * Check whether user has the permission */ public boolean consumerHasPermission(long consumerId, String permissionType, String targetId) { Permission permission = permissionRepository.findTopByPermissionTypeAndTargetId(permissionType, targetId); if (permission == null) { return false; } List<ConsumerRole> consumerRoles = consumerRoleRepository.findByConsumerId(consumerId); if (CollectionUtils.isEmpty(consumerRoles)) { return false; } Set<Long> roleIds = consumerRoles.stream().map(ConsumerRole::getRoleId).collect(Collectors.toSet()); List<RolePermission> rolePermissions = rolePermissionRepository.findByRoleIdIn(roleIds); if (CollectionUtils.isEmpty(rolePermissions)) { return false; } for (RolePermission rolePermission : rolePermissions) { if (rolePermission.getPermissionId() == permission.getId()) { return true; } } return false; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/util/parser/ParserException.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util.parser; public class ParserException extends Exception { public ParserException(String message) { super(message); } public ParserException(String message, Throwable cause) { super(message, cause); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.util.parser; public class ParserException extends Exception { public ParserException(String message) { super(message); } public ParserException(String message, Throwable cause) { super(message, cause); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./docs/zh/design/apollo-introduction.md
# &nbsp; # 1、What is Apollo ## 1.1 背景 随着程序功能的日益复杂,程序的配置日益增多:各种功能的开关、参数的配置、服务器的地址…… 对程序配置的期望值也越来越高:配置修改后实时生效,灰度发布,分环境、分集群管理配置,完善的权限、审核机制…… 在这样的大环境下,传统的通过配置文件、数据库等方式已经越来越无法满足开发人员对配置管理的需求。 Apollo配置中心应运而生! ## 1.2 Apollo简介 Apollo(阿波罗)是携程框架部门研发的开源配置管理中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性。 Apollo支持4个维度管理Key-Value格式的配置: 1. application (应用) 2. environment (环境) 3. cluster (集群) 4. namespace (命名空间) 同时,Apollo基于开源模式开发,开源地址:<a href="https://github.com/ctripcorp/apollo" target="_blank">https://github.com/ctripcorp/apollo</a> ## 1.2 配置基本概念 既然Apollo定位于配置中心,那么在这里有必要先简单介绍一下什么是配置。 按照我们的理解,配置有以下几个属性: * **配置是独立于程序的只读变量** * 配置首先是独立于程序的,同一份程序在不同的配置下会有不同的行为。 * 其次,配置对于程序是只读的,程序通过读取配置来改变自己的行为,但是程序不应该去改变配置。 * 常见的配置有:DB Connection Str、Thread Pool Size、Buffer Size、Request Timeout、Feature Switch、Server Urls等。 * **配置伴随应用的整个生命周期** * 配置贯穿于应用的整个生命周期,应用在启动时通过读取配置来初始化,在运行时根据配置调整行为。 * **配置可以有多种加载方式** * 配置也有很多种加载方式,常见的有程序内部hard code,配置文件,环境变量,启动参数,基于数据库等 * **配置需要治理** * 权限控制 * 由于配置能改变程序的行为,不正确的配置甚至能引起灾难,所以对配置的修改必须有比较完善的权限控制 * 不同环境、集群配置管理 * 同一份程序在不同的环境(开发,测试,生产)、不同的集群(如不同的数据中心)经常需要有不同的配置,所以需要有完善的环境、集群配置管理 * 框架类组件配置管理 * 还有一类比较特殊的配置 - 框架类组件配置,比如CAT客户端的配置。 * 虽然这类框架类组件是由其他团队开发、维护,但是运行时是在业务实际应用内的,所以本质上可以认为框架类组件也是应用的一部分。 * 这类组件对应的配置也需要有比较完善的管理方式。 # 2、Why Apollo 正是基于配置的特殊性,所以Apollo从设计之初就立志于成为一个有治理能力的配置发布平台,目前提供了以下的特性: * **统一管理不同环境、不同集群的配置** * Apollo提供了一个统一界面集中式管理不同环境(environment)、不同集群(cluster)、不同命名空间(namespace)的配置。 * 同一份代码部署在不同的集群,可以有不同的配置,比如zookeeper的地址等 * 通过命名空间(namespace)可以很方便地支持多个不同应用共享同一份配置,同时还允许应用对共享的配置进行覆盖 * **配置修改实时生效(热发布)** * 用户在Apollo修改完配置并发布后,客户端能实时(1秒)接收到最新的配置,并通知到应用程序 * **版本发布管理** * 所有的配置发布都有版本概念,从而可以方便地支持配置的回滚 * **灰度发布** * 支持配置的灰度发布,比如点了发布后,只对部分应用实例生效,等观察一段时间没问题后再推给所有应用实例 * **权限管理、发布审核、操作审计** * 应用和配置的管理都有完善的权限管理机制,对配置的管理还分为了编辑和发布两个环节,从而减少人为的错误。 * 所有的操作都有审计日志,可以方便地追踪问题 * **客户端配置信息监控** * 可以在界面上方便地看到配置在被哪些实例使用 * **提供Java和.Net原生客户端** * 提供了Java和.Net的原生客户端,方便应用集成 * 支持Spring Placeholder, Annotation和Spring Boot的ConfigurationProperties,方便应用使用(需要Spring 3.1.1+) * 同时提供了Http接口,非Java和.Net应用也可以方便地使用 * **提供开放平台API** * Apollo自身提供了比较完善的统一配置管理界面,支持多环境、多数据中心配置管理、权限、流程治理等特性。不过Apollo出于通用性考虑,不会对配置的修改做过多限制,只要符合基本的格式就能保存,不会针对不同的配置值进行针对性的校验,如数据库用户名、密码,Redis服务地址等 * 对于这类应用配置,Apollo支持应用方通过开放平台API在Apollo进行配置的修改和发布,并且具备完善的授权和权限控制 * **部署简单** * 配置中心作为基础服务,可用性要求非常高,这就要求Apollo对外部依赖尽可能地少 * 目前唯一的外部依赖是MySQL,所以部署非常简单,只要安装好Java和MySQL就可以让Apollo跑起来 * Apollo还提供了打包脚本,一键就可以生成所有需要的安装包,并且支持自定义运行时参数 # 3、Apollo at a glance ## 3.1 基础模型 如下即是Apollo的基础模型: 1. 用户在配置中心对配置进行修改并发布 2. 配置中心通知Apollo客户端有配置更新 3. Apollo客户端从配置中心拉取最新的配置、更新本地配置并通知到应用 ![basic-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/basic-architecture.png) ## 3.2 界面概览 ![apollo-home-screenshot](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.jpg) 上图是Apollo配置中心中一个项目的配置首页 * 在页面左上方的环境列表模块展示了所有的环境和集群,用户可以随时切换。 * 页面中央展示了两个namespace(application和FX.apollo)的配置信息,默认按照表格模式展示、编辑。用户也可以切换到文本模式,以文件形式查看、编辑。 * 页面上可以方便地进行发布、回滚、灰度、授权、查看更改历史和发布历史等操作 ## 3.3 添加/修改配置项 用户可以通过配置中心界面方便的添加/修改配置项,更多使用说明请参见[应用接入指南](zh/usage/apollo-user-guide) ![edit-item-entry](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/edit-item-entry.png) 输入配置信息: ![edit-item](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/edit-item.png) ## 3.4 发布配置 通过配置中心发布配置: ![publish-items](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items-entry.png) 填写发布信息: ![publish-items](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items.png) ## 3.5 客户端获取配置(Java API样例) 配置发布后,就能在客户端获取到了,以Java为例,获取配置的示例代码如下。Apollo客户端还支持和Spring整合,更多客户端使用说明请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)和[.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide)。 ```java Config config = ConfigService.getAppConfig(); Integer defaultRequestTimeout = 200; Integer requestTimeout = config.getIntProperty("requestTimeout", defaultRequestTimeout); ``` ## 3.6 客户端监听配置变化 通过上述获取配置代码,应用就能实时获取到最新的配置了。 不过在某些场景下,应用还需要在配置变化时获得通知,比如数据库连接的切换等,所以Apollo还提供了监听配置变化的功能,Java示例如下: ```java Config config = ConfigService.getAppConfig(); config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format( "Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ## 3.7 Spring集成样例 Apollo和Spring也可以很方便地集成,只需要标注`@EnableApolloConfig`后就可以通过`@Value`获取配置信息: ```java @Configuration @EnableApolloConfig public class AppConfig {} ``` ```java @Component public class SomeBean { //timeout的值会自动更新 @Value("${request.timeout:200}") private int timeout; } ``` # 4、Apollo in depth 通过上面的介绍,相信大家已经对Apollo有了一个初步的了解,并且相信已经覆盖到了大部分的使用场景。 接下来会主要介绍Apollo的cluster管理(集群)、namespace管理(命名空间)和对应的配置获取规则。 ## 4.1 Core Concepts 在介绍高级特性前,我们有必要先来了解一下Apollo中的几个核心概念: 1. **application (应用)** * 这个很好理解,就是实际使用配置的应用,Apollo客户端在运行时需要知道当前应用是谁,从而可以去获取对应的配置 * 每个应用都需要有唯一的身份标识 -- appId,我们认为应用身份是跟着代码走的,所以需要在代码中配置,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 2. **environment (环境)** * 配置对应的环境,Apollo客户端在运行时需要知道当前应用处于哪个环境,从而可以去获取应用的配置 * 我们认为环境和代码无关,同一份代码部署在不同的环境就应该能够获取到不同环境的配置 * 所以环境默认是通过读取机器上的配置(server.properties中的env属性)指定的,不过为了开发方便,我们也支持运行时通过System Property等指定,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 3. **cluster (集群)** * 一个应用下不同实例的分组,比如典型的可以按照数据中心分,把上海机房的应用实例分为一个集群,把北京机房的应用实例分为另一个集群。 * 对不同的cluster,同一个配置可以有不一样的值,如zookeeper地址。 * 集群默认是通过读取机器上的配置(server.properties中的idc属性)指定的,不过也支持运行时通过System Property指定,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 4. **namespace (命名空间)** * 一个应用下不同配置的分组,可以简单地把namespace类比为文件,不同类型的配置存放在不同的文件中,如数据库配置文件,RPC配置文件,应用自身的配置文件等 * 应用可以直接读取到公共组件的配置namespace,如DAL,RPC等 * 应用也可以通过继承公共组件的配置namespace来对公共组件的配置做调整,如DAL的初始数据库连接数 ## 4.2 自定义Cluster > 【本节内容仅对应用需要对不同集群应用不同配置才需要,如没有相关需求,可以跳过本节】 比如我们有应用在A数据中心和B数据中心都有部署,那么如果希望两个数据中心的配置不一样的话,我们可以通过新建cluster来解决。 ### 4.2.1 新建Cluster 新建Cluster只有项目的管理员才有权限,管理员可以在页面左侧看到“添加集群”按钮。 ![create-cluster](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-cluster.png) 点击后就进入到集群添加页面,一般情况下可以按照数据中心来划分集群,如SHAJQ、SHAOY等。 不过也支持自定义集群,比如可以为A机房的某一台机器和B机房的某一台机创建一个集群,使用一套配置。 ![create-cluster-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-cluster-detail.png) ### 4.2.2 在Cluster中添加配置并发布 集群添加成功后,就可以为该集群添加配置了,首先需要按照下图所示切换到SHAJQ集群,之后配置添加流程和[3.3 添加/修改配置项](#_33-添加修改配置项)一样,这里就不再赘述了。 ![cluster-created](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/cluster-created.png) ### 4.2.3 指定应用实例所属的Cluster Apollo会默认使用应用实例所在的数据中心作为cluster,所以如果两者一致的话,不需要额外配置。 如果cluster和数据中心不一致的话,那么就需要通过System Property方式来指定运行时cluster: * -Dapollo.cluster=SomeCluster * 这里注意`apollo.cluster`为全小写 ## 4.3 自定义Namespace > 【本节仅对公共组件配置或需要多个应用共享配置才需要,如没有相关需求,可以跳过本节】 如果应用有公共组件(如hermes-producer,cat-client等)供其它应用使用,就需要通过自定义namespace来实现公共组件的配置。 ### 4.3.1 新建Namespace 以hermes-producer为例,需要先新建一个namespace,新建namespace只有项目的管理员才有权限,管理员可以在页面左侧看到“添加Namespace”按钮。 ![create-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-namespace.png) 点击后就进入namespace添加页面,Apollo会把应用所属的部门作为namespace的前缀,如FX。 ![create-namespace-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-namespace-detail.png) ### 4.3.2 关联到环境和集群 Namespace创建完,需要选择在哪些环境和集群下使用 ![link-namespace-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/link-namespace-detail.png) ### 4.3.3 在Namespace中添加配置项 接下来在这个新建的namespace下添加配置项 ![add-item-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/add-item-in-new-namespace.png) 添加完成后就能在FX.Hermes.Producer的namespace中看到配置。 ![item-created-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/item-created-in-new-namespace.png) ### 4.3.4 发布namespace的配置 ![publish-items-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items-in-new-namespace.png) ### 4.3.5 客户端获取Namespace配置 对自定义namespace的配置获取,稍有不同,需要程序传入namespace的名字。Apollo客户端还支持和Spring整合,更多客户端使用说明请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)和[.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide)。 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); Integer defaultSenderBatchSize = 200; Integer senderBatchSize = config.getIntProperty("sender.batchsize", defaultSenderBatchSize); ``` ### 4.3.6 客户端监听Namespace配置变化 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { System.out.println("Changes for namespace " + changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format( "Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ### 4.3.7 Spring集成样例 ```java @Configuration @EnableApolloConfig("FX.Hermes.Producer") public class AppConfig {} ``` ```java @Component public class SomeBean { //timeout的值会自动更新 @Value("${request.timeout:200}") private int timeout; } ``` ## 4.4 配置获取规则 > 【本节仅当应用自定义了集群或namespace才需要,如无相关需求,可以跳过本节】 在有了cluster概念后,配置的规则就显得重要了。 比如应用部署在A机房,但是并没有在Apollo新建cluster,这个时候Apollo的行为是怎样的? 或者在运行时指定了cluster=SomeCluster,但是并没有在Apollo新建cluster,这个时候Apollo的行为是怎样的? 接下来就来介绍一下配置获取的规则。 ### 4.4.1 应用自身配置的获取规则 当应用使用下面的语句获取配置时,我们称之为获取应用自身的配置,也就是应用自身的application namespace的配置。 ```java Config config = ConfigService.getAppConfig(); ``` 对这种情况的配置获取规则,简而言之如下: 1. 首先查找运行时cluster的配置(通过apollo.cluster指定) 2. 如果没有找到,则查找数据中心cluster的配置 3. 如果还是没有找到,则返回默认cluster的配置 图示如下: ![application-config-precedence](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/application-config-precedence.png) 所以如果应用部署在A数据中心,但是用户没有在Apollo创建cluster,那么获取的配置就是默认cluster(default)的。 如果应用部署在A数据中心,同时在运行时指定了SomeCluster,但是没有在Apollo创建cluster,那么获取的配置就是A数据中心cluster的配置,如果A数据中心cluster没有配置的话,那么获取的配置就是默认cluster(default)的。 ### 4.4.2 公共组件配置的获取规则 以`FX.Hermes.Producer`为例,hermes producer是hermes发布的公共组件。当使用下面的语句获取配置时,我们称之为获取公共组件的配置。 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); ``` 对这种情况的配置获取规则,简而言之如下: 1. 首先获取当前应用下的`FX.Hermes.Producer` namespace的配置 2. 然后获取hermes应用下`FX.Hermes.Producer` namespace的配置 3. 上面两部分配置的并集就是最终使用的配置,如有key一样的部分,以当前应用优先 图示如下: ![public-namespace-config-precedence](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/public-namespace-config-precedence.png) 通过这种方式,就实现了对框架类组件的配置管理,框架组件提供方提供配置的默认值,应用如果有特殊需求,可以自行覆盖。 ## 4.5 总体设计 ![overall-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/overall-architecture.png) 上图简要描述了Apollo的总体设计,我们可以从下往上看: * Config Service提供配置的读取、推送等功能,服务对象是Apollo客户端 * Admin Service提供配置的修改、发布等功能,服务对象是Apollo Portal(管理界面) * Config Service和Admin Service都是多实例、无状态部署,所以需要将自己注册到Eureka中并保持心跳 * 在Eureka之上我们架了一层Meta Server用于封装Eureka的服务发现接口 * Client通过域名访问Meta Server获取Config Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Client侧会做load balance、错误重试 * Portal通过域名访问Meta Server获取Admin Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Portal侧会做load balance、错误重试 * 为了简化部署,我们实际上会把Config Service、Eureka和Meta Server三个逻辑角色部署在同一个JVM进程中 ### 4.5.1 Why Eureka 为什么我们采用Eureka作为服务注册中心,而不是使用传统的zk、etcd呢?我大致总结了一下,有以下几方面的原因: * 它提供了完整的Service Registry和Service Discovery实现 * 首先是提供了完整的实现,并且也经受住了Netflix自己的生产环境考验,相对使用起来会比较省心。 * 和Spring Cloud无缝集成 * 我们的项目本身就使用了Spring Cloud和Spring Boot,同时Spring Cloud还有一套非常完善的开源代码来整合Eureka,所以使用起来非常方便。 * 另外,Eureka还支持在我们应用自身的容器中启动,也就是说我们的应用启动完之后,既充当了Eureka的角色,同时也是服务的提供者。这样就极大的提高了服务的可用性。 * **这一点是我们选择Eureka而不是zk、etcd等的主要原因,为了提高配置中心的可用性和降低部署复杂度,我们需要尽可能地减少外部依赖。** * Open Source * 最后一点是开源,由于代码是开源的,所以非常便于我们了解它的实现原理和排查问题。 ## 4.6 客户端设计 ![client-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/client-architecture.png) 上图简要描述了Apollo客户端的实现原理: 1. 客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。 2. 客户端还会定时从Apollo配置中心服务端拉取应用的最新配置。 * 这是一个fallback机制,为了防止推送机制失效导致配置不更新 * 客户端定时拉取会上报本地版本,所以一般情况下,对于定时拉取的操作,服务端都会返回304 - Not Modified * 定时频率默认为每5分钟拉取一次,客户端也可以通过在运行时指定System Property: `apollo.refreshInterval`来覆盖,单位为分钟。 3. 客户端从Apollo配置中心服务端获取到应用的最新配置后,会保存在内存中 4. 客户端会把从服务端获取到的配置在本地文件系统缓存一份 * 在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置 5. 应用程序从Apollo客户端获取最新的配置、订阅配置更新通知 ### 4.6.1 配置更新推送实现 前面提到了Apollo客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。 长连接实际上我们是通过Http Long Polling实现的,具体而言: * 客户端发起一个Http请求到服务端 * 服务端会保持住这个连接60秒 * 如果在60秒内有客户端关心的配置变化,被保持住的客户端请求会立即返回,并告知客户端有配置变化的namespace信息,客户端会据此拉取对应namespace的最新配置 * 如果在60秒内没有客户端关心的配置变化,那么会返回Http状态码304给客户端 * 客户端在收到服务端请求后会立即重新发起连接,回到第一步 考虑到会有数万客户端向服务端发起长连,在服务端我们使用了async servlet(Spring DeferredResult)来服务Http Long Polling请求。 ## 4.7 可用性考虑 配置中心作为基础服务,可用性要求非常高,下面的表格描述了不同场景下Apollo的可用性: | 场景 | 影响 | 降级 | 原因 | |------------------------|--------------------------------------|---------------------------------------|-----------------------------------------------------------------------------------------| | 某台config service下线 | 无影响 | | Config service无状态,客户端重连其它config service | | 所有config service下线 | 客户端无法读取最新配置,Portal无影响 | 客户端重启时,可以读取本地缓存配置文件 | | | 某台admin service下线 | 无影响 | | Admin service无状态,Portal重连其它admin service | | 所有admin service下线 | 客户端无影响,portal无法更新配置 | | | | 某台portal下线 | 无影响 | | Portal域名通过slb绑定多台服务器,重试后指向可用的服务器 | | 全部portal下线 | 客户端无影响,portal无法更新配置 | | | | 某个数据中心下线 | 无影响 | | 多数据中心部署,数据完全同步,Meta Server/Portal域名通过slb自动切换到其它存活的数据中心 | # 5、Contribute to Apollo Apollo从开发之初就是以开源模式开发的,所以也非常欢迎有兴趣、有余力的朋友一起加入进来。 服务端开发使用的是Java,基于Spring Cloud和Spring Boot框架。客户端目前提供了Java和.Net两种实现。 Github地址:<a href="https://github.com/ctripcorp/apollo" target="_blank">https://github.com/ctripcorp/apollo</a> 欢迎大家发起Pull Request!
# &nbsp; # 1、What is Apollo ## 1.1 背景 随着程序功能的日益复杂,程序的配置日益增多:各种功能的开关、参数的配置、服务器的地址…… 对程序配置的期望值也越来越高:配置修改后实时生效,灰度发布,分环境、分集群管理配置,完善的权限、审核机制…… 在这样的大环境下,传统的通过配置文件、数据库等方式已经越来越无法满足开发人员对配置管理的需求。 Apollo配置中心应运而生! ## 1.2 Apollo简介 Apollo(阿波罗)是携程框架部门研发的开源配置管理中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性。 Apollo支持4个维度管理Key-Value格式的配置: 1. application (应用) 2. environment (环境) 3. cluster (集群) 4. namespace (命名空间) 同时,Apollo基于开源模式开发,开源地址:<a href="https://github.com/ctripcorp/apollo" target="_blank">https://github.com/ctripcorp/apollo</a> ## 1.2 配置基本概念 既然Apollo定位于配置中心,那么在这里有必要先简单介绍一下什么是配置。 按照我们的理解,配置有以下几个属性: * **配置是独立于程序的只读变量** * 配置首先是独立于程序的,同一份程序在不同的配置下会有不同的行为。 * 其次,配置对于程序是只读的,程序通过读取配置来改变自己的行为,但是程序不应该去改变配置。 * 常见的配置有:DB Connection Str、Thread Pool Size、Buffer Size、Request Timeout、Feature Switch、Server Urls等。 * **配置伴随应用的整个生命周期** * 配置贯穿于应用的整个生命周期,应用在启动时通过读取配置来初始化,在运行时根据配置调整行为。 * **配置可以有多种加载方式** * 配置也有很多种加载方式,常见的有程序内部hard code,配置文件,环境变量,启动参数,基于数据库等 * **配置需要治理** * 权限控制 * 由于配置能改变程序的行为,不正确的配置甚至能引起灾难,所以对配置的修改必须有比较完善的权限控制 * 不同环境、集群配置管理 * 同一份程序在不同的环境(开发,测试,生产)、不同的集群(如不同的数据中心)经常需要有不同的配置,所以需要有完善的环境、集群配置管理 * 框架类组件配置管理 * 还有一类比较特殊的配置 - 框架类组件配置,比如CAT客户端的配置。 * 虽然这类框架类组件是由其他团队开发、维护,但是运行时是在业务实际应用内的,所以本质上可以认为框架类组件也是应用的一部分。 * 这类组件对应的配置也需要有比较完善的管理方式。 # 2、Why Apollo 正是基于配置的特殊性,所以Apollo从设计之初就立志于成为一个有治理能力的配置发布平台,目前提供了以下的特性: * **统一管理不同环境、不同集群的配置** * Apollo提供了一个统一界面集中式管理不同环境(environment)、不同集群(cluster)、不同命名空间(namespace)的配置。 * 同一份代码部署在不同的集群,可以有不同的配置,比如zookeeper的地址等 * 通过命名空间(namespace)可以很方便地支持多个不同应用共享同一份配置,同时还允许应用对共享的配置进行覆盖 * **配置修改实时生效(热发布)** * 用户在Apollo修改完配置并发布后,客户端能实时(1秒)接收到最新的配置,并通知到应用程序 * **版本发布管理** * 所有的配置发布都有版本概念,从而可以方便地支持配置的回滚 * **灰度发布** * 支持配置的灰度发布,比如点了发布后,只对部分应用实例生效,等观察一段时间没问题后再推给所有应用实例 * **权限管理、发布审核、操作审计** * 应用和配置的管理都有完善的权限管理机制,对配置的管理还分为了编辑和发布两个环节,从而减少人为的错误。 * 所有的操作都有审计日志,可以方便地追踪问题 * **客户端配置信息监控** * 可以在界面上方便地看到配置在被哪些实例使用 * **提供Java和.Net原生客户端** * 提供了Java和.Net的原生客户端,方便应用集成 * 支持Spring Placeholder, Annotation和Spring Boot的ConfigurationProperties,方便应用使用(需要Spring 3.1.1+) * 同时提供了Http接口,非Java和.Net应用也可以方便地使用 * **提供开放平台API** * Apollo自身提供了比较完善的统一配置管理界面,支持多环境、多数据中心配置管理、权限、流程治理等特性。不过Apollo出于通用性考虑,不会对配置的修改做过多限制,只要符合基本的格式就能保存,不会针对不同的配置值进行针对性的校验,如数据库用户名、密码,Redis服务地址等 * 对于这类应用配置,Apollo支持应用方通过开放平台API在Apollo进行配置的修改和发布,并且具备完善的授权和权限控制 * **部署简单** * 配置中心作为基础服务,可用性要求非常高,这就要求Apollo对外部依赖尽可能地少 * 目前唯一的外部依赖是MySQL,所以部署非常简单,只要安装好Java和MySQL就可以让Apollo跑起来 * Apollo还提供了打包脚本,一键就可以生成所有需要的安装包,并且支持自定义运行时参数 # 3、Apollo at a glance ## 3.1 基础模型 如下即是Apollo的基础模型: 1. 用户在配置中心对配置进行修改并发布 2. 配置中心通知Apollo客户端有配置更新 3. Apollo客户端从配置中心拉取最新的配置、更新本地配置并通知到应用 ![basic-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/basic-architecture.png) ## 3.2 界面概览 ![apollo-home-screenshot](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.jpg) 上图是Apollo配置中心中一个项目的配置首页 * 在页面左上方的环境列表模块展示了所有的环境和集群,用户可以随时切换。 * 页面中央展示了两个namespace(application和FX.apollo)的配置信息,默认按照表格模式展示、编辑。用户也可以切换到文本模式,以文件形式查看、编辑。 * 页面上可以方便地进行发布、回滚、灰度、授权、查看更改历史和发布历史等操作 ## 3.3 添加/修改配置项 用户可以通过配置中心界面方便的添加/修改配置项,更多使用说明请参见[应用接入指南](zh/usage/apollo-user-guide) ![edit-item-entry](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/edit-item-entry.png) 输入配置信息: ![edit-item](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/edit-item.png) ## 3.4 发布配置 通过配置中心发布配置: ![publish-items](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items-entry.png) 填写发布信息: ![publish-items](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items.png) ## 3.5 客户端获取配置(Java API样例) 配置发布后,就能在客户端获取到了,以Java为例,获取配置的示例代码如下。Apollo客户端还支持和Spring整合,更多客户端使用说明请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)和[.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide)。 ```java Config config = ConfigService.getAppConfig(); Integer defaultRequestTimeout = 200; Integer requestTimeout = config.getIntProperty("requestTimeout", defaultRequestTimeout); ``` ## 3.6 客户端监听配置变化 通过上述获取配置代码,应用就能实时获取到最新的配置了。 不过在某些场景下,应用还需要在配置变化时获得通知,比如数据库连接的切换等,所以Apollo还提供了监听配置变化的功能,Java示例如下: ```java Config config = ConfigService.getAppConfig(); config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format( "Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ## 3.7 Spring集成样例 Apollo和Spring也可以很方便地集成,只需要标注`@EnableApolloConfig`后就可以通过`@Value`获取配置信息: ```java @Configuration @EnableApolloConfig public class AppConfig {} ``` ```java @Component public class SomeBean { //timeout的值会自动更新 @Value("${request.timeout:200}") private int timeout; } ``` # 4、Apollo in depth 通过上面的介绍,相信大家已经对Apollo有了一个初步的了解,并且相信已经覆盖到了大部分的使用场景。 接下来会主要介绍Apollo的cluster管理(集群)、namespace管理(命名空间)和对应的配置获取规则。 ## 4.1 Core Concepts 在介绍高级特性前,我们有必要先来了解一下Apollo中的几个核心概念: 1. **application (应用)** * 这个很好理解,就是实际使用配置的应用,Apollo客户端在运行时需要知道当前应用是谁,从而可以去获取对应的配置 * 每个应用都需要有唯一的身份标识 -- appId,我们认为应用身份是跟着代码走的,所以需要在代码中配置,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 2. **environment (环境)** * 配置对应的环境,Apollo客户端在运行时需要知道当前应用处于哪个环境,从而可以去获取应用的配置 * 我们认为环境和代码无关,同一份代码部署在不同的环境就应该能够获取到不同环境的配置 * 所以环境默认是通过读取机器上的配置(server.properties中的env属性)指定的,不过为了开发方便,我们也支持运行时通过System Property等指定,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 3. **cluster (集群)** * 一个应用下不同实例的分组,比如典型的可以按照数据中心分,把上海机房的应用实例分为一个集群,把北京机房的应用实例分为另一个集群。 * 对不同的cluster,同一个配置可以有不一样的值,如zookeeper地址。 * 集群默认是通过读取机器上的配置(server.properties中的idc属性)指定的,不过也支持运行时通过System Property指定,具体信息请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)。 4. **namespace (命名空间)** * 一个应用下不同配置的分组,可以简单地把namespace类比为文件,不同类型的配置存放在不同的文件中,如数据库配置文件,RPC配置文件,应用自身的配置文件等 * 应用可以直接读取到公共组件的配置namespace,如DAL,RPC等 * 应用也可以通过继承公共组件的配置namespace来对公共组件的配置做调整,如DAL的初始数据库连接数 ## 4.2 自定义Cluster > 【本节内容仅对应用需要对不同集群应用不同配置才需要,如没有相关需求,可以跳过本节】 比如我们有应用在A数据中心和B数据中心都有部署,那么如果希望两个数据中心的配置不一样的话,我们可以通过新建cluster来解决。 ### 4.2.1 新建Cluster 新建Cluster只有项目的管理员才有权限,管理员可以在页面左侧看到“添加集群”按钮。 ![create-cluster](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-cluster.png) 点击后就进入到集群添加页面,一般情况下可以按照数据中心来划分集群,如SHAJQ、SHAOY等。 不过也支持自定义集群,比如可以为A机房的某一台机器和B机房的某一台机创建一个集群,使用一套配置。 ![create-cluster-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-cluster-detail.png) ### 4.2.2 在Cluster中添加配置并发布 集群添加成功后,就可以为该集群添加配置了,首先需要按照下图所示切换到SHAJQ集群,之后配置添加流程和[3.3 添加/修改配置项](#_33-添加修改配置项)一样,这里就不再赘述了。 ![cluster-created](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/cluster-created.png) ### 4.2.3 指定应用实例所属的Cluster Apollo会默认使用应用实例所在的数据中心作为cluster,所以如果两者一致的话,不需要额外配置。 如果cluster和数据中心不一致的话,那么就需要通过System Property方式来指定运行时cluster: * -Dapollo.cluster=SomeCluster * 这里注意`apollo.cluster`为全小写 ## 4.3 自定义Namespace > 【本节仅对公共组件配置或需要多个应用共享配置才需要,如没有相关需求,可以跳过本节】 如果应用有公共组件(如hermes-producer,cat-client等)供其它应用使用,就需要通过自定义namespace来实现公共组件的配置。 ### 4.3.1 新建Namespace 以hermes-producer为例,需要先新建一个namespace,新建namespace只有项目的管理员才有权限,管理员可以在页面左侧看到“添加Namespace”按钮。 ![create-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-namespace.png) 点击后就进入namespace添加页面,Apollo会把应用所属的部门作为namespace的前缀,如FX。 ![create-namespace-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/create-namespace-detail.png) ### 4.3.2 关联到环境和集群 Namespace创建完,需要选择在哪些环境和集群下使用 ![link-namespace-detail](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/link-namespace-detail.png) ### 4.3.3 在Namespace中添加配置项 接下来在这个新建的namespace下添加配置项 ![add-item-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/add-item-in-new-namespace.png) 添加完成后就能在FX.Hermes.Producer的namespace中看到配置。 ![item-created-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/item-created-in-new-namespace.png) ### 4.3.4 发布namespace的配置 ![publish-items-in-new-namespace](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/publish-items-in-new-namespace.png) ### 4.3.5 客户端获取Namespace配置 对自定义namespace的配置获取,稍有不同,需要程序传入namespace的名字。Apollo客户端还支持和Spring整合,更多客户端使用说明请参见[Java客户端使用指南](zh/usage/java-sdk-user-guide)和[.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide)。 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); Integer defaultSenderBatchSize = 200; Integer senderBatchSize = config.getIntProperty("sender.batchsize", defaultSenderBatchSize); ``` ### 4.3.6 客户端监听Namespace配置变化 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); config.addChangeListener(new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { System.out.println("Changes for namespace " + changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); System.out.println(String.format( "Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType())); } } }); ``` ### 4.3.7 Spring集成样例 ```java @Configuration @EnableApolloConfig("FX.Hermes.Producer") public class AppConfig {} ``` ```java @Component public class SomeBean { //timeout的值会自动更新 @Value("${request.timeout:200}") private int timeout; } ``` ## 4.4 配置获取规则 > 【本节仅当应用自定义了集群或namespace才需要,如无相关需求,可以跳过本节】 在有了cluster概念后,配置的规则就显得重要了。 比如应用部署在A机房,但是并没有在Apollo新建cluster,这个时候Apollo的行为是怎样的? 或者在运行时指定了cluster=SomeCluster,但是并没有在Apollo新建cluster,这个时候Apollo的行为是怎样的? 接下来就来介绍一下配置获取的规则。 ### 4.4.1 应用自身配置的获取规则 当应用使用下面的语句获取配置时,我们称之为获取应用自身的配置,也就是应用自身的application namespace的配置。 ```java Config config = ConfigService.getAppConfig(); ``` 对这种情况的配置获取规则,简而言之如下: 1. 首先查找运行时cluster的配置(通过apollo.cluster指定) 2. 如果没有找到,则查找数据中心cluster的配置 3. 如果还是没有找到,则返回默认cluster的配置 图示如下: ![application-config-precedence](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/application-config-precedence.png) 所以如果应用部署在A数据中心,但是用户没有在Apollo创建cluster,那么获取的配置就是默认cluster(default)的。 如果应用部署在A数据中心,同时在运行时指定了SomeCluster,但是没有在Apollo创建cluster,那么获取的配置就是A数据中心cluster的配置,如果A数据中心cluster没有配置的话,那么获取的配置就是默认cluster(default)的。 ### 4.4.2 公共组件配置的获取规则 以`FX.Hermes.Producer`为例,hermes producer是hermes发布的公共组件。当使用下面的语句获取配置时,我们称之为获取公共组件的配置。 ```java Config config = ConfigService.getConfig("FX.Hermes.Producer"); ``` 对这种情况的配置获取规则,简而言之如下: 1. 首先获取当前应用下的`FX.Hermes.Producer` namespace的配置 2. 然后获取hermes应用下`FX.Hermes.Producer` namespace的配置 3. 上面两部分配置的并集就是最终使用的配置,如有key一样的部分,以当前应用优先 图示如下: ![public-namespace-config-precedence](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/public-namespace-config-precedence.png) 通过这种方式,就实现了对框架类组件的配置管理,框架组件提供方提供配置的默认值,应用如果有特殊需求,可以自行覆盖。 ## 4.5 总体设计 ![overall-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/overall-architecture.png) 上图简要描述了Apollo的总体设计,我们可以从下往上看: * Config Service提供配置的读取、推送等功能,服务对象是Apollo客户端 * Admin Service提供配置的修改、发布等功能,服务对象是Apollo Portal(管理界面) * Config Service和Admin Service都是多实例、无状态部署,所以需要将自己注册到Eureka中并保持心跳 * 在Eureka之上我们架了一层Meta Server用于封装Eureka的服务发现接口 * Client通过域名访问Meta Server获取Config Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Client侧会做load balance、错误重试 * Portal通过域名访问Meta Server获取Admin Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Portal侧会做load balance、错误重试 * 为了简化部署,我们实际上会把Config Service、Eureka和Meta Server三个逻辑角色部署在同一个JVM进程中 ### 4.5.1 Why Eureka 为什么我们采用Eureka作为服务注册中心,而不是使用传统的zk、etcd呢?我大致总结了一下,有以下几方面的原因: * 它提供了完整的Service Registry和Service Discovery实现 * 首先是提供了完整的实现,并且也经受住了Netflix自己的生产环境考验,相对使用起来会比较省心。 * 和Spring Cloud无缝集成 * 我们的项目本身就使用了Spring Cloud和Spring Boot,同时Spring Cloud还有一套非常完善的开源代码来整合Eureka,所以使用起来非常方便。 * 另外,Eureka还支持在我们应用自身的容器中启动,也就是说我们的应用启动完之后,既充当了Eureka的角色,同时也是服务的提供者。这样就极大的提高了服务的可用性。 * **这一点是我们选择Eureka而不是zk、etcd等的主要原因,为了提高配置中心的可用性和降低部署复杂度,我们需要尽可能地减少外部依赖。** * Open Source * 最后一点是开源,由于代码是开源的,所以非常便于我们了解它的实现原理和排查问题。 ## 4.6 客户端设计 ![client-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/client-architecture.png) 上图简要描述了Apollo客户端的实现原理: 1. 客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。 2. 客户端还会定时从Apollo配置中心服务端拉取应用的最新配置。 * 这是一个fallback机制,为了防止推送机制失效导致配置不更新 * 客户端定时拉取会上报本地版本,所以一般情况下,对于定时拉取的操作,服务端都会返回304 - Not Modified * 定时频率默认为每5分钟拉取一次,客户端也可以通过在运行时指定System Property: `apollo.refreshInterval`来覆盖,单位为分钟。 3. 客户端从Apollo配置中心服务端获取到应用的最新配置后,会保存在内存中 4. 客户端会把从服务端获取到的配置在本地文件系统缓存一份 * 在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置 5. 应用程序从Apollo客户端获取最新的配置、订阅配置更新通知 ### 4.6.1 配置更新推送实现 前面提到了Apollo客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。 长连接实际上我们是通过Http Long Polling实现的,具体而言: * 客户端发起一个Http请求到服务端 * 服务端会保持住这个连接60秒 * 如果在60秒内有客户端关心的配置变化,被保持住的客户端请求会立即返回,并告知客户端有配置变化的namespace信息,客户端会据此拉取对应namespace的最新配置 * 如果在60秒内没有客户端关心的配置变化,那么会返回Http状态码304给客户端 * 客户端在收到服务端请求后会立即重新发起连接,回到第一步 考虑到会有数万客户端向服务端发起长连,在服务端我们使用了async servlet(Spring DeferredResult)来服务Http Long Polling请求。 ## 4.7 可用性考虑 配置中心作为基础服务,可用性要求非常高,下面的表格描述了不同场景下Apollo的可用性: | 场景 | 影响 | 降级 | 原因 | |------------------------|--------------------------------------|---------------------------------------|-----------------------------------------------------------------------------------------| | 某台config service下线 | 无影响 | | Config service无状态,客户端重连其它config service | | 所有config service下线 | 客户端无法读取最新配置,Portal无影响 | 客户端重启时,可以读取本地缓存配置文件 | | | 某台admin service下线 | 无影响 | | Admin service无状态,Portal重连其它admin service | | 所有admin service下线 | 客户端无影响,portal无法更新配置 | | | | 某台portal下线 | 无影响 | | Portal域名通过slb绑定多台服务器,重试后指向可用的服务器 | | 全部portal下线 | 客户端无影响,portal无法更新配置 | | | | 某个数据中心下线 | 无影响 | | 多数据中心部署,数据完全同步,Meta Server/Portal域名通过slb自动切换到其它存活的数据中心 | # 5、Contribute to Apollo Apollo从开发之初就是以开源模式开发的,所以也非常欢迎有兴趣、有余力的朋友一起加入进来。 服务端开发使用的是Java,基于Spring Cloud和Spring Boot框架。客户端目前提供了Java和.Net两种实现。 Github地址:<a href="https://github.com/ctripcorp/apollo" target="_blank">https://github.com/ctripcorp/apollo</a> 欢迎大家发起Pull Request!
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-openapi/src/main/java/com/ctrip/framework/apollo/openapi/dto/OpenAppNamespaceDTO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class OpenAppNamespaceDTO extends BaseDTO { private String name; private String appId; private String format; private boolean isPublic; // whether to append namespace prefix for public namespace name private boolean appendNamespacePrefix = true; private String comment; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public String getFormat() { return format; } public void setFormat(String format) { this.format = format; } public boolean isPublic() { return isPublic; } public void setPublic(boolean aPublic) { isPublic = aPublic; } public boolean isAppendNamespacePrefix() { return appendNamespacePrefix; } public void setAppendNamespacePrefix(boolean appendNamespacePrefix) { this.appendNamespacePrefix = appendNamespacePrefix; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } @Override public String toString() { return "OpenAppNamespaceDTO{" + "name='" + name + '\'' + ", appId='" + appId + '\'' + ", format='" + format + '\'' + ", isPublic=" + isPublic + ", appendNamespacePrefix=" + appendNamespacePrefix + ", comment='" + comment + '\'' + ", dataChangeCreatedBy='" + dataChangeCreatedBy + '\'' + ", dataChangeLastModifiedBy='" + dataChangeLastModifiedBy + '\'' + ", dataChangeCreatedTime=" + dataChangeCreatedTime + ", dataChangeLastModifiedTime=" + dataChangeLastModifiedTime + '}'; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class OpenAppNamespaceDTO extends BaseDTO { private String name; private String appId; private String format; private boolean isPublic; // whether to append namespace prefix for public namespace name private boolean appendNamespacePrefix = true; private String comment; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public String getFormat() { return format; } public void setFormat(String format) { this.format = format; } public boolean isPublic() { return isPublic; } public void setPublic(boolean aPublic) { isPublic = aPublic; } public boolean isAppendNamespacePrefix() { return appendNamespacePrefix; } public void setAppendNamespacePrefix(boolean appendNamespacePrefix) { this.appendNamespacePrefix = appendNamespacePrefix; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } @Override public String toString() { return "OpenAppNamespaceDTO{" + "name='" + name + '\'' + ", appId='" + appId + '\'' + ", format='" + format + '\'' + ", isPublic=" + isPublic + ", appendNamespacePrefix=" + appendNamespacePrefix + ", comment='" + comment + '\'' + ", dataChangeCreatedBy='" + dataChangeCreatedBy + '\'' + ", dataChangeLastModifiedBy='" + dataChangeLastModifiedBy + '\'' + ", dataChangeCreatedTime=" + dataChangeCreatedTime + ", dataChangeLastModifiedTime=" + dataChangeLastModifiedTime + '}'; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/SpringValueProcessor.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.annotation; import com.ctrip.framework.apollo.build.ApolloInjector; import com.ctrip.framework.apollo.spring.property.PlaceholderHelper; import com.ctrip.framework.apollo.spring.property.SpringValue; import com.ctrip.framework.apollo.spring.property.SpringValueDefinition; import com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor; import com.ctrip.framework.apollo.spring.property.SpringValueRegistry; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Collection; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.context.annotation.Bean; /** * Spring value processor of field or method which has @Value and xml config placeholders. * * @author github.com/zhegexiaohuozi seimimaster@gmail.com * @since 2017/12/20. */ public class SpringValueProcessor extends ApolloProcessor implements BeanFactoryPostProcessor, BeanFactoryAware { private static final Logger logger = LoggerFactory.getLogger(SpringValueProcessor.class); private final ConfigUtil configUtil; private final PlaceholderHelper placeholderHelper; private final SpringValueRegistry springValueRegistry; private BeanFactory beanFactory; private Multimap<String, SpringValueDefinition> beanName2SpringValueDefinitions; public SpringValueProcessor() { configUtil = ApolloInjector.getInstance(ConfigUtil.class); placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class); springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class); beanName2SpringValueDefinitions = LinkedListMultimap.create(); } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() && beanFactory instanceof BeanDefinitionRegistry) { beanName2SpringValueDefinitions = SpringValueDefinitionProcessor .getBeanName2SpringValueDefinitions((BeanDefinitionRegistry) beanFactory); } } @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()) { super.postProcessBeforeInitialization(bean, beanName); processBeanPropertyValues(bean, beanName); } return bean; } @Override protected void processField(Object bean, String beanName, Field field) { // register @Value on field Value value = field.getAnnotation(Value.class); if (value == null) { return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false); springValueRegistry.register(beanFactory, key, springValue); logger.debug("Monitoring {}", springValue); } } @Override protected void processMethod(Object bean, String beanName, Method method) { //register @Value on method Value value = method.getAnnotation(Value.class); if (value == null) { return; } //skip Configuration bean methods if (method.getAnnotation(Bean.class) != null) { return; } if (method.getParameterTypes().length != 1) { logger.error("Ignore @Value setter {}.{}, expecting 1 parameter, actual {} parameters", bean.getClass().getName(), method.getName(), method.getParameterTypes().length); return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, method, false); springValueRegistry.register(beanFactory, key, springValue); logger.info("Monitoring {}", springValue); } } private void processBeanPropertyValues(Object bean, String beanName) { Collection<SpringValueDefinition> propertySpringValues = beanName2SpringValueDefinitions .get(beanName); if (propertySpringValues == null || propertySpringValues.isEmpty()) { return; } for (SpringValueDefinition definition : propertySpringValues) { try { PropertyDescriptor pd = BeanUtils .getPropertyDescriptor(bean.getClass(), definition.getPropertyName()); Method method = pd.getWriteMethod(); if (method == null) { continue; } SpringValue springValue = new SpringValue(definition.getKey(), definition.getPlaceholder(), bean, beanName, method, false); springValueRegistry.register(beanFactory, definition.getKey(), springValue); logger.debug("Monitoring {}", springValue); } catch (Throwable ex) { logger.error("Failed to enable auto update feature for {}.{}", bean.getClass(), definition.getPropertyName()); } } // clear beanName2SpringValueDefinitions.removeAll(beanName); } @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.spring.annotation; import com.ctrip.framework.apollo.build.ApolloInjector; import com.ctrip.framework.apollo.spring.property.PlaceholderHelper; import com.ctrip.framework.apollo.spring.property.SpringValue; import com.ctrip.framework.apollo.spring.property.SpringValueDefinition; import com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor; import com.ctrip.framework.apollo.spring.property.SpringValueRegistry; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Collection; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.context.annotation.Bean; /** * Spring value processor of field or method which has @Value and xml config placeholders. * * @author github.com/zhegexiaohuozi seimimaster@gmail.com * @since 2017/12/20. */ public class SpringValueProcessor extends ApolloProcessor implements BeanFactoryPostProcessor, BeanFactoryAware { private static final Logger logger = LoggerFactory.getLogger(SpringValueProcessor.class); private final ConfigUtil configUtil; private final PlaceholderHelper placeholderHelper; private final SpringValueRegistry springValueRegistry; private BeanFactory beanFactory; private Multimap<String, SpringValueDefinition> beanName2SpringValueDefinitions; public SpringValueProcessor() { configUtil = ApolloInjector.getInstance(ConfigUtil.class); placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class); springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class); beanName2SpringValueDefinitions = LinkedListMultimap.create(); } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() && beanFactory instanceof BeanDefinitionRegistry) { beanName2SpringValueDefinitions = SpringValueDefinitionProcessor .getBeanName2SpringValueDefinitions((BeanDefinitionRegistry) beanFactory); } } @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()) { super.postProcessBeforeInitialization(bean, beanName); processBeanPropertyValues(bean, beanName); } return bean; } @Override protected void processField(Object bean, String beanName, Field field) { // register @Value on field Value value = field.getAnnotation(Value.class); if (value == null) { return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false); springValueRegistry.register(beanFactory, key, springValue); logger.debug("Monitoring {}", springValue); } } @Override protected void processMethod(Object bean, String beanName, Method method) { //register @Value on method Value value = method.getAnnotation(Value.class); if (value == null) { return; } //skip Configuration bean methods if (method.getAnnotation(Bean.class) != null) { return; } if (method.getParameterTypes().length != 1) { logger.error("Ignore @Value setter {}.{}, expecting 1 parameter, actual {} parameters", bean.getClass().getName(), method.getName(), method.getParameterTypes().length); return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, method, false); springValueRegistry.register(beanFactory, key, springValue); logger.info("Monitoring {}", springValue); } } private void processBeanPropertyValues(Object bean, String beanName) { Collection<SpringValueDefinition> propertySpringValues = beanName2SpringValueDefinitions .get(beanName); if (propertySpringValues == null || propertySpringValues.isEmpty()) { return; } for (SpringValueDefinition definition : propertySpringValues) { try { PropertyDescriptor pd = BeanUtils .getPropertyDescriptor(bean.getClass(), definition.getPropertyName()); Method method = pd.getWriteMethod(); if (method == null) { continue; } SpringValue springValue = new SpringValue(definition.getKey(), definition.getPlaceholder(), bean, beanName, method, false); springValueRegistry.register(beanFactory, definition.getKey(), springValue); logger.debug("Monitoring {}", springValue); } catch (Throwable ex) { logger.error("Failed to enable auto update feature for {}.{}", bean.getClass(), definition.getPropertyName()); } } // clear beanName2SpringValueDefinitions.removeAll(beanName); } @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripSsoHeartbeatHandler.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ctrip; import com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author Jason Song(song_s@ctrip.com) */ public class CtripSsoHeartbeatHandler implements SsoHeartbeatHandler { @Override public void doHeartbeat(HttpServletRequest request, HttpServletResponse response) { try { response.sendRedirect("ctrip_sso_heartbeat.html"); } catch (IOException e) { } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.spi.ctrip; import com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author Jason Song(song_s@ctrip.com) */ public class CtripSsoHeartbeatHandler implements SsoHeartbeatHandler { @Override public void doHeartbeat(HttpServletRequest request, HttpServletResponse response) { try { response.sendRedirect("ctrip_sso_heartbeat.html"); } catch (IOException e) { } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.repository; import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; import org.springframework.data.repository.PagingAndSortingRepository; public interface ServerConfigRepository extends PagingAndSortingRepository<ServerConfig, Long> { ServerConfig findByKey(String key); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.repository; import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; import org.springframework.data.repository.PagingAndSortingRepository; public interface ServerConfigRepository extends PagingAndSortingRepository<ServerConfig, Long> { ServerConfig findByKey(String key); }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.entity.App; public interface RoleInitializationService { void initAppRoles(App app); void initNamespaceRoles(String appId, String namespaceName, String operator); void initNamespaceEnvRoles(String appId, String namespaceName, String operator); void initNamespaceSpecificEnvRoles(String appId, String namespaceName, String env, String operator); void initCreateAppRole(); void initManageAppMasterRole(String appId, String operator); }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.entity.App; public interface RoleInitializationService { void initAppRoles(App app); void initNamespaceRoles(String appId, String namespaceName, String operator); void initNamespaceEnvRoles(String appId, String namespaceName, String operator); void initNamespaceSpecificEnvRoles(String appId, String namespaceName, String env, String operator); void initCreateAppRole(); void initManageAppMasterRole(String appId, String operator); }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/views/component/env-selector.html
<table class="table table-hover" style="width: 300px"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <thead> <tr> <td><input type="checkbox" ng-checked="envAllSelected" ng-click="toggleEnvsCheckedStatus()"></td> </td> <td>{{'Common.Environment' | translate }}</td> <td>{{'Common.Cluster' | translate }}</td> </tr> </thead> <tbody> <tr style="cursor: pointer" ng-repeat="cluster in clusters" ng-click="toggleClusterCheckedStatus(cluster)"> <td width="10%"><input type="checkbox" ng-checked="cluster.checked" ng-click="switchSelect(cluster, $event)"></td> <td width="30%" ng-bind="cluster.env"></td> <td width="60%" ng-bind="cluster.name"></td> </tr> </tbody> </table>
<table class="table table-hover" style="width: 300px"> <!-- ~ Copyright 2021 Apollo Authors ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --> <thead> <tr> <td><input type="checkbox" ng-checked="envAllSelected" ng-click="toggleEnvsCheckedStatus()"></td> </td> <td>{{'Common.Environment' | translate }}</td> <td>{{'Common.Cluster' | translate }}</td> </tr> </thead> <tbody> <tr style="cursor: pointer" ng-repeat="cluster in clusters" ng-click="toggleClusterCheckedStatus(cluster)"> <td width="10%"><input type="checkbox" ng-checked="cluster.checked" ng-click="switchSelect(cluster, $event)"></td> <td width="30%" ng-bind="cluster.env"></td> <td width="60%" ng-bind="cluster.name"></td> </tr> </tbody> </table>
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/scripts/directive/item-modal-directive.js
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ directive_module.directive('itemmodal', itemModalDirective); function itemModalDirective($translate, toastr, $sce, AppUtil, EventManager, ConfigService) { return { restrict: 'E', templateUrl: AppUtil.prefixPath() + '/views/component/item-modal.html', transclude: true, replace: true, scope: { appId: '=', env: '=', cluster: '=', toOperationNamespace: '=', item: '=' }, link: function (scope) { var TABLE_VIEW_OPER_TYPE = { CREATE: 'create', UPDATE: 'update' }; scope.doItem = doItem; scope.collectSelectedClusters = collectSelectedClusters; scope.showHiddenChars = showHiddenChars; $('#itemModal').on('show.bs.modal', function (e) { scope.showHiddenCharsContext = false; scope.hiddenCharCounter = 0; scope.valueWithHiddenChars = $sce.trustAsHtml(''); }); $("#valueEditor").textareafullscreen(); function doItem() { if (!scope.item.value) { scope.item.value = ""; } if (scope.item.tableViewOperType == TABLE_VIEW_OPER_TYPE.CREATE) { //check key unique var hasRepeatKey = false; scope.toOperationNamespace.items.forEach(function (item) { if (!item.isDeleted && scope.item.key == item.item.key) { toastr.error($translate.instant('ItemModal.KeyExists', { key: scope.item.key })); hasRepeatKey = true; } }); if (hasRepeatKey) { return; } scope.item.addItemBtnDisabled = true; if (scope.toOperationNamespace.isBranch) { ConfigService.create_item(scope.appId, scope.env, scope.toOperationNamespace.baseInfo.clusterName, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { toastr.success($translate.instant('ItemModal.AddedTips')); scope.item.addItemBtnDisabled = false; AppUtil.hideModal('#itemModal'); EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.AddFailed')); scope.item.addItemBtnDisabled = false; }); } else { if (selectedClusters.length == 0) { toastr.error($translate.instant('ItemModal.PleaseChooseCluster')); scope.item.addItemBtnDisabled = false; return; } selectedClusters.forEach(function (cluster) { ConfigService.create_item(scope.appId, cluster.env, cluster.name, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { scope.item.addItemBtnDisabled = false; AppUtil.hideModal('#itemModal'); toastr.success(cluster.env + " , " + scope.item.key, $translate.instant('ItemModal.AddedTips')); if (cluster.env == scope.env && cluster.name == scope.cluster) { EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); } }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.AddFailed')); scope.item.addItemBtnDisabled = false; }); }); } } else { if (!scope.item.comment) { scope.item.comment = ""; } ConfigService.update_item(scope.appId, scope.env, scope.toOperationNamespace.baseInfo.clusterName, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); AppUtil.hideModal('#itemModal'); toastr.success($translate.instant('ItemModal.ModifiedTips')); }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.ModifyFailed')); }); } } var selectedClusters = []; function collectSelectedClusters(data) { selectedClusters = data; } function showHiddenChars() { var value = scope.item.value; if (!value) { return; } var hiddenCharCounter = 0, valueWithHiddenChars = _.escape(value); for (var i = 0; i < value.length; i++) { var c = value[i]; if (isHiddenChar(c)) { valueWithHiddenChars = valueWithHiddenChars.replace(c, viewHiddenChar); hiddenCharCounter++; } } scope.showHiddenCharsContext = true; scope.hiddenCharCounter = hiddenCharCounter; scope.valueWithHiddenChars = $sce.trustAsHtml(valueWithHiddenChars); } function isHiddenChar(c) { return c == '\t' || c == '\n' || c == ' '; } function viewHiddenChar(c) { if (c == '\t') { return '<mark>#' + $translate.instant('ItemModal.Tabs') + '#</mark>'; } else if (c == '\n') { return '<mark>#' + $translate.instant('ItemModal.NewLine') + '#</mark>'; } else if (c == ' ') { return '<mark>#' + $translate.instant('ItemModal.Space') + '#</mark>'; } } } } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ directive_module.directive('itemmodal', itemModalDirective); function itemModalDirective($translate, toastr, $sce, AppUtil, EventManager, ConfigService) { return { restrict: 'E', templateUrl: AppUtil.prefixPath() + '/views/component/item-modal.html', transclude: true, replace: true, scope: { appId: '=', env: '=', cluster: '=', toOperationNamespace: '=', item: '=' }, link: function (scope) { var TABLE_VIEW_OPER_TYPE = { CREATE: 'create', UPDATE: 'update' }; scope.doItem = doItem; scope.collectSelectedClusters = collectSelectedClusters; scope.showHiddenChars = showHiddenChars; $('#itemModal').on('show.bs.modal', function (e) { scope.showHiddenCharsContext = false; scope.hiddenCharCounter = 0; scope.valueWithHiddenChars = $sce.trustAsHtml(''); }); $("#valueEditor").textareafullscreen(); function doItem() { if (!scope.item.value) { scope.item.value = ""; } if (scope.item.tableViewOperType == TABLE_VIEW_OPER_TYPE.CREATE) { //check key unique var hasRepeatKey = false; scope.toOperationNamespace.items.forEach(function (item) { if (!item.isDeleted && scope.item.key == item.item.key) { toastr.error($translate.instant('ItemModal.KeyExists', { key: scope.item.key })); hasRepeatKey = true; } }); if (hasRepeatKey) { return; } scope.item.addItemBtnDisabled = true; if (scope.toOperationNamespace.isBranch) { ConfigService.create_item(scope.appId, scope.env, scope.toOperationNamespace.baseInfo.clusterName, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { toastr.success($translate.instant('ItemModal.AddedTips')); scope.item.addItemBtnDisabled = false; AppUtil.hideModal('#itemModal'); EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.AddFailed')); scope.item.addItemBtnDisabled = false; }); } else { if (selectedClusters.length == 0) { toastr.error($translate.instant('ItemModal.PleaseChooseCluster')); scope.item.addItemBtnDisabled = false; return; } selectedClusters.forEach(function (cluster) { ConfigService.create_item(scope.appId, cluster.env, cluster.name, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { scope.item.addItemBtnDisabled = false; AppUtil.hideModal('#itemModal'); toastr.success(cluster.env + " , " + scope.item.key, $translate.instant('ItemModal.AddedTips')); if (cluster.env == scope.env && cluster.name == scope.cluster) { EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); } }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.AddFailed')); scope.item.addItemBtnDisabled = false; }); }); } } else { if (!scope.item.comment) { scope.item.comment = ""; } ConfigService.update_item(scope.appId, scope.env, scope.toOperationNamespace.baseInfo.clusterName, scope.toOperationNamespace.baseInfo.namespaceName, scope.item).then( function (result) { EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE, { namespace: scope.toOperationNamespace }); AppUtil.hideModal('#itemModal'); toastr.success($translate.instant('ItemModal.ModifiedTips')); }, function (result) { toastr.error(AppUtil.errorMsg(result), $translate.instant('ItemModal.ModifyFailed')); }); } } var selectedClusters = []; function collectSelectedClusters(data) { selectedClusters = data; } function showHiddenChars() { var value = scope.item.value; if (!value) { return; } var hiddenCharCounter = 0, valueWithHiddenChars = _.escape(value); for (var i = 0; i < value.length; i++) { var c = value[i]; if (isHiddenChar(c)) { valueWithHiddenChars = valueWithHiddenChars.replace(c, viewHiddenChar); hiddenCharCounter++; } } scope.showHiddenCharsContext = true; scope.hiddenCharCounter = hiddenCharCounter; scope.valueWithHiddenChars = $sce.trustAsHtml(valueWithHiddenChars); } function isHiddenChar(c) { return c == '\t' || c == '\n' || c == ' '; } function viewHiddenChar(c) { if (c == '\t') { return '<mark>#' + $translate.instant('ItemModal.Tabs') + '#</mark>'; } else if (c == '\n') { return '<mark>#' + $translate.instant('ItemModal.NewLine') + '#</mark>'; } else if (c == ' ') { return '<mark>#' + $translate.instant('ItemModal.Space') + '#</mark>'; } } } } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./doc/images/logo/logo-detail.png
PNG  IHDR  gAMA a cHRMz&u0`:pQ< pHYs  YiTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:tiff="http://ns.adobe.com/tiff/1.0/"> <tiff:Orientation>1</tiff:Orientation> </rdf:Description> </rdf:RDF> </x:xmpmeta> L'Y@IDATxMvW83VC=!kU]5 \U+H3vz L9i+rA#FēRǽTbīf*#}p-[|yN</ϲ 䃽_bx<A>{ @ @ @ @ 2I @ W!Wg9Q)٫E!Ν{ @ @ @ @,RX7a=~9__VCE,<yR 8 @ @ @ @@5`H|+XWlŢaq_ Ɓ=R? @ @ @ @(E5N}n Ma?[ @ @ @BZ/Fa[_븰oy{¿Ka v @ @ @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nKl}חI0Ƀ        WzT7Nt~'Yȥ(V_&ǻss~=f[WEl NKrjҷ,+ n        lT70Ok)j rb-Swm ^fX.d.`* pIqK6 %x߱vi6dcWҗ@@@@@@@@778YתkK t(d붤KG(2'ur| `kqCH'jtG{Gut=OuR#1       @ =;7XYYGGFGެ        e F1{lIENDB`
PNG  IHDR  gAMA a cHRMz&u0`:pQ< pHYs  YiTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:tiff="http://ns.adobe.com/tiff/1.0/"> <tiff:Orientation>1</tiff:Orientation> </rdf:Description> </rdf:RDF> </x:xmpmeta> L'Y@IDATxMvW83VC=!kU]5 \U+H3vz L9i+rA#FēRǽTbīf*#}p-[|yN</ϲ 䃽_bx<A>{ @ @ @ @ 2I @ W!Wg9Q)٫E!Ν{ @ @ @ @,RX7a=~9__VCE,<yR 8 @ @ @ @@5`H|+XWlŢaq_ Ɓ=R? @ @ @ @(E5N}n Ma?[ @ @ @BZ/Fa[_븰oy{¿Ka v @ @ @ ~Yj p;6ca߭w~VÎ~u6 @ @ @ @P twW+!x?K>ٓa_v۟b  @ @ @ @*'ЯrK&`,ߌt{_{A_`v @ @ @ @`a Fm"/vzYqw_> 1  @ @ @ @D% @`fY^.q^ڷ_xH @ @ @Y@T.$@ uJx}e3{Cn&2:;s @ @ @ @ ([i@ !/b_XLF@r&` @ @ @ @B  P aëVXFԢ,QEΝc05 @ @ @ @`"~?XoؽnY1/c_/\iǶ^G @ @ @ @F (krK@uxUtSЊ @ @ @8S@ߙ4N Pp{W6CmXl[u<|H;w5Ey @ @ @ @PW=Z y!,2II'/5 @ @ @ 0P@@2 Y&bK&  @ @ @ @@ ]ah&verUW( @ @ @B $+/٥د/CowzW @ @ @ @ ([8>zl+>]B/BmuW V! @ @ @ @5PWb_;m8WSU|>Ȟ<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gl[#K%#      d&@_f t:>\kڛ쑍 ~8RJHkptA@@@@@@2 /3ގ=g%zCɐ _Nq$gMM       @)$~~$£ ,^%S @(H@@@@@@([D{O%z9b=`xgv@Ty^*xR@G pɧy@@@@@@@$9ޫW uIŸ}hx{O?IqA,y޺Zo1-A`OIǞ>rH@@@@@@@inwG}(!0Vtoggs< (o\S$pիPc%}ϫ}D      d&@_fi/*ղ`7hymTT=V@τGO       4FDvuY<z`e}+ځ;!,d Q) lYy%KVMU }4MXh       P~%w@۲[eZ2hKIS a߯BĈ^ 0tlq2+ե;i       ~RYp 4O=%m<E,͛'3e#+OoҖҾntIQҼ0eY0e!      SDziU?ִofSV+׿ (oQswVrOaY @@@@@@@TJ/򕕕|6R1RKjѲܗhumkMEr_M:f       e Wv\%y]f+~ruZRb܅ ~<<x5:~X_W?@O0a`@@@@@@@$գS–=Rrȱ-8IRIi$A/E |M@-);<w$3~M(;'Y~0ͭ& F@@@@@@h~'~zJSff'fydO/ ؜[X1k,qHjKYbߜ~/!;!      $ /!XS6t:G$dĿ>OK$-?(]@,Oǣ Y::_ˬzdKŌ}gZ      8-@Vp'3Z(:8]ERfwkĞw|ܛpA?ſ AGKwnKl}חI0Ƀ        WzT7Nt~'Yȥ(V_&ǻss~=f[WEl NKrjҷ,+ n        lT70Ok)j rb-Swm ^fX.d.`* pIqK6 %x߱vi6dcWҗ@@@@@@@@778YתkK t(d붤KG(2'ur| `kqCH'jtG{Gut=OuR#1       @ =;7XYYGGFGެ        e F1{lIENDB`
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-portal/src/main/resources/static/vendor/ui-ace/mode-yaml.js
define("ace/mode/yaml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment",regex:"#.*$"},{token:"list.markup",regex:/^(?:-{3}|\.{3})\s*(?=#|$)/},{token:"list.markup",regex:/^\s*[\-?](?:$|\s)/},{token:"constant",regex:"!![\\w//]+"},{token:"constant.language",regex:"[&\\*][a-zA-Z0-9-_]+"},{token:["meta.tag","keyword"],regex:/^(\s*\w.*?)(:(?=\s|$))/},{token:["meta.tag","keyword"],regex:/(\w+?)(\s*:(?=\s|$))/},{token:"keyword.operator",regex:"<<\\w*:\\w*"},{token:"keyword.operator",regex:"-\\s*(?=[{])"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:/[|>][-+\d\s]*$/,onMatch:function(e,t,n,r){var i=/^\s*/.exec(r)[0];return n.length<1?n.push(this.next):n[0]="mlString",n.length<2?n.push(i.length):n[1]=i.length,this.token},next:"mlString"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"constant.numeric",regex:/(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)(?=[^\d-\w]|$)/},{token:"constant.numeric",regex:/[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/},{token:"constant.language.boolean",regex:"\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"},{token:"text",regex:/[^\s,:\[\]\{\}]+/}],mlString:[{token:"indent",regex:/^\s*$/},{token:"indent",regex:/^\s*/,onMatch:function(e,t,n){var r=n[1];return r>=e.length?(this.next="start",n.splice(0)):this.next="mlString",this.token},next:"mlString"},{token:"string",regex:".+"}]},this.normalizeRules()};r.inherits(s,i),t.YamlHighlightRules=s}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("./fold_mode").FoldMode,s=e("../../range").Range,o=t.FoldMode=function(){};r.inherits(o,i),function(){this.getFoldWidgetRange=function(e,t,n){var r=this.indentationBlock(e,n);if(r)return r;var i=/\S/,o=e.getLine(n),u=o.search(i);if(u==-1||o[u]!="#")return;var a=o.length,f=e.getLength(),l=n,c=n;while(++n<f){o=e.getLine(n);var h=o.search(i);if(h==-1)continue;if(o[h]!="#")break;c=n}if(c>l){var p=e.getLine(c).length;return new s(l,a,c,p)}},this.getFoldWidget=function(e,t,n){var r=e.getLine(n),i=r.search(/\S/),s=e.getLine(n+1),o=e.getLine(n-1),u=o.search(/\S/),a=s.search(/\S/);if(i==-1)return e.foldWidgets[n-1]=u!=-1&&u<a?"start":"","";if(u==-1){if(i==a&&r[i]=="#"&&s[i]=="#")return e.foldWidgets[n-1]="",e.foldWidgets[n+1]="","start"}else if(u==i&&r[i]=="#"&&o[i]=="#"&&e.getLine(n-2).search(/\S/)==-1)return e.foldWidgets[n-1]="start",e.foldWidgets[n+1]="","";return u!=-1&&u<i?e.foldWidgets[n-1]="start":e.foldWidgets[n-1]="",i<a?"start":""}}.call(o.prototype)}),define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./yaml_highlight_rules").YamlHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("./folding/coffee").FoldMode,a=function(){this.HighlightRules=s,this.$outdent=new o,this.foldingRules=new u,this.$behaviour=this.$defaultBehaviour};r.inherits(a,i),function(){this.lineCommentStart=["#","//"],this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);if(e=="start"){var i=t.match(/^.*[\{\(\[]\s*$/);i&&(r+=n)}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/yaml"}.call(a.prototype),t.Mode=a})
define("ace/mode/yaml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment",regex:"#.*$"},{token:"list.markup",regex:/^(?:-{3}|\.{3})\s*(?=#|$)/},{token:"list.markup",regex:/^\s*[\-?](?:$|\s)/},{token:"constant",regex:"!![\\w//]+"},{token:"constant.language",regex:"[&\\*][a-zA-Z0-9-_]+"},{token:["meta.tag","keyword"],regex:/^(\s*\w.*?)(:(?=\s|$))/},{token:["meta.tag","keyword"],regex:/(\w+?)(\s*:(?=\s|$))/},{token:"keyword.operator",regex:"<<\\w*:\\w*"},{token:"keyword.operator",regex:"-\\s*(?=[{])"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:/[|>][-+\d\s]*$/,onMatch:function(e,t,n,r){var i=/^\s*/.exec(r)[0];return n.length<1?n.push(this.next):n[0]="mlString",n.length<2?n.push(i.length):n[1]=i.length,this.token},next:"mlString"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"constant.numeric",regex:/(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)(?=[^\d-\w]|$)/},{token:"constant.numeric",regex:/[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/},{token:"constant.language.boolean",regex:"\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"},{token:"text",regex:/[^\s,:\[\]\{\}]+/}],mlString:[{token:"indent",regex:/^\s*$/},{token:"indent",regex:/^\s*/,onMatch:function(e,t,n){var r=n[1];return r>=e.length?(this.next="start",n.splice(0)):this.next="mlString",this.token},next:"mlString"},{token:"string",regex:".+"}]},this.normalizeRules()};r.inherits(s,i),t.YamlHighlightRules=s}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("./fold_mode").FoldMode,s=e("../../range").Range,o=t.FoldMode=function(){};r.inherits(o,i),function(){this.getFoldWidgetRange=function(e,t,n){var r=this.indentationBlock(e,n);if(r)return r;var i=/\S/,o=e.getLine(n),u=o.search(i);if(u==-1||o[u]!="#")return;var a=o.length,f=e.getLength(),l=n,c=n;while(++n<f){o=e.getLine(n);var h=o.search(i);if(h==-1)continue;if(o[h]!="#")break;c=n}if(c>l){var p=e.getLine(c).length;return new s(l,a,c,p)}},this.getFoldWidget=function(e,t,n){var r=e.getLine(n),i=r.search(/\S/),s=e.getLine(n+1),o=e.getLine(n-1),u=o.search(/\S/),a=s.search(/\S/);if(i==-1)return e.foldWidgets[n-1]=u!=-1&&u<a?"start":"","";if(u==-1){if(i==a&&r[i]=="#"&&s[i]=="#")return e.foldWidgets[n-1]="",e.foldWidgets[n+1]="","start"}else if(u==i&&r[i]=="#"&&o[i]=="#"&&e.getLine(n-2).search(/\S/)==-1)return e.foldWidgets[n-1]="start",e.foldWidgets[n+1]="","";return u!=-1&&u<i?e.foldWidgets[n-1]="start":e.foldWidgets[n-1]="",i<a?"start":""}}.call(o.prototype)}),define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./yaml_highlight_rules").YamlHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("./folding/coffee").FoldMode,a=function(){this.HighlightRules=s,this.$outdent=new o,this.foldingRules=new u,this.$behaviour=this.$defaultBehaviour};r.inherits(a,i),function(){this.lineCommentStart=["#","//"],this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);if(e=="start"){var i=t.match(/^.*[\{\(\[]\s*$/);i&&(r+=n)}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/yaml"}.call(a.prototype),t.Mode=a})
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-core/src/test/resources/META-INF/app-with-utf8bom.properties
app.id=110402
app.id=110402
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.grayReleaseRule; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.ReleaseMessageListener; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.GrayReleaseRuleRepository; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; 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.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.google.common.collect.TreeMultimap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; /** * @author Jason Song(song_s@ctrip.com) */ public class GrayReleaseRulesHolder implements ReleaseMessageListener, InitializingBean { private static final Logger logger = LoggerFactory.getLogger(GrayReleaseRulesHolder.class); private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); private static final Splitter STRING_SPLITTER = Splitter.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).omitEmptyStrings(); @Autowired private GrayReleaseRuleRepository grayReleaseRuleRepository; @Autowired private BizConfig bizConfig; private int databaseScanInterval; private ScheduledExecutorService executorService; //store configAppId+configCluster+configNamespace -> GrayReleaseRuleCache map private Multimap<String, GrayReleaseRuleCache> grayReleaseRuleCache; //store clientAppId+clientNamespace+ip -> ruleId map private Multimap<String, Long> reversedGrayReleaseRuleCache; //an auto increment version to indicate the age of rules private AtomicLong loadVersion; public GrayReleaseRulesHolder() { loadVersion = new AtomicLong(); grayReleaseRuleCache = Multimaps.synchronizedSetMultimap( TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural())); reversedGrayReleaseRuleCache = Multimaps.synchronizedSetMultimap( TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural())); executorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory .create("GrayReleaseRulesHolder", true)); } @Override public void afterPropertiesSet() throws Exception { populateDataBaseInterval(); //force sync load for the first time periodicScanRules(); executorService.scheduleWithFixedDelay(this::periodicScanRules, getDatabaseScanIntervalSecond(), getDatabaseScanIntervalSecond(), getDatabaseScanTimeUnit() ); } @Override public void handleMessage(ReleaseMessage message, String channel) { logger.info("message received - channel: {}, message: {}", channel, message); String releaseMessage = message.getMessage(); if (!Topics.APOLLO_RELEASE_TOPIC.equals(channel) || Strings.isNullOrEmpty(releaseMessage)) { return; } List<String> keys = STRING_SPLITTER.splitToList(releaseMessage); //message should be appId+cluster+namespace if (keys.size() != 3) { logger.error("message format invalid - {}", releaseMessage); return; } String appId = keys.get(0); String cluster = keys.get(1); String namespace = keys.get(2); List<GrayReleaseRule> rules = grayReleaseRuleRepository .findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace); mergeGrayReleaseRules(rules); } private void periodicScanRules() { Transaction transaction = Tracer.newTransaction("Apollo.GrayReleaseRulesScanner", "scanGrayReleaseRules"); try { loadVersion.incrementAndGet(); scanGrayReleaseRules(); transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { transaction.setStatus(ex); logger.error("Scan gray release rule failed", ex); } finally { transaction.complete(); } } public Long findReleaseIdFromGrayReleaseRule(String clientAppId, String clientIp, String configAppId, String configCluster, String configNamespaceName) { String key = assembleGrayReleaseRuleKey(configAppId, configCluster, configNamespaceName); if (!grayReleaseRuleCache.containsKey(key)) { return null; } //create a new list to avoid ConcurrentModificationException List<GrayReleaseRuleCache> rules = Lists.newArrayList(grayReleaseRuleCache.get(key)); for (GrayReleaseRuleCache rule : rules) { //check branch status if (rule.getBranchStatus() != NamespaceBranchStatus.ACTIVE) { continue; } if (rule.matches(clientAppId, clientIp)) { return rule.getReleaseId(); } } return null; } /** * Check whether there are gray release rules for the clientAppId, clientIp, namespace * combination. Please note that even there are gray release rules, it doesn't mean it will always * load gray releases. Because gray release rules actually apply to one more dimension - cluster. */ public boolean hasGrayReleaseRule(String clientAppId, String clientIp, String namespaceName) { return reversedGrayReleaseRuleCache.containsKey(assembleReversedGrayReleaseRuleKey(clientAppId, namespaceName, clientIp)) || reversedGrayReleaseRuleCache.containsKey (assembleReversedGrayReleaseRuleKey(clientAppId, namespaceName, GrayReleaseRuleItemDTO .ALL_IP)); } private void scanGrayReleaseRules() { long maxIdScanned = 0; boolean hasMore = true; while (hasMore && !Thread.currentThread().isInterrupted()) { List<GrayReleaseRule> grayReleaseRules = grayReleaseRuleRepository .findFirst500ByIdGreaterThanOrderByIdAsc(maxIdScanned); if (CollectionUtils.isEmpty(grayReleaseRules)) { break; } mergeGrayReleaseRules(grayReleaseRules); int rulesScanned = grayReleaseRules.size(); maxIdScanned = grayReleaseRules.get(rulesScanned - 1).getId(); //batch is 500 hasMore = rulesScanned == 500; } } private void mergeGrayReleaseRules(List<GrayReleaseRule> grayReleaseRules) { if (CollectionUtils.isEmpty(grayReleaseRules)) { return; } for (GrayReleaseRule grayReleaseRule : grayReleaseRules) { if (grayReleaseRule.getReleaseId() == null || grayReleaseRule.getReleaseId() == 0) { //filter rules with no release id, i.e. never released continue; } String key = assembleGrayReleaseRuleKey(grayReleaseRule.getAppId(), grayReleaseRule .getClusterName(), grayReleaseRule.getNamespaceName()); //create a new list to avoid ConcurrentModificationException List<GrayReleaseRuleCache> rules = Lists.newArrayList(grayReleaseRuleCache.get(key)); GrayReleaseRuleCache oldRule = null; for (GrayReleaseRuleCache ruleCache : rules) { if (ruleCache.getBranchName().equals(grayReleaseRule.getBranchName())) { oldRule = ruleCache; break; } } //if old rule is null and new rule's branch status is not active, ignore if (oldRule == null && grayReleaseRule.getBranchStatus() != NamespaceBranchStatus.ACTIVE) { continue; } //use id comparison to avoid synchronization if (oldRule == null || grayReleaseRule.getId() > oldRule.getRuleId()) { addCache(key, transformRuleToRuleCache(grayReleaseRule)); if (oldRule != null) { removeCache(key, oldRule); } } else { if (oldRule.getBranchStatus() == NamespaceBranchStatus.ACTIVE) { //update load version oldRule.setLoadVersion(loadVersion.get()); } else if ((loadVersion.get() - oldRule.getLoadVersion()) > 1) { //remove outdated inactive branch rule after 2 update cycles removeCache(key, oldRule); } } } } private void addCache(String key, GrayReleaseRuleCache ruleCache) { if (ruleCache.getBranchStatus() == NamespaceBranchStatus.ACTIVE) { for (GrayReleaseRuleItemDTO ruleItemDTO : ruleCache.getRuleItems()) { for (String clientIp : ruleItemDTO.getClientIpList()) { reversedGrayReleaseRuleCache.put(assembleReversedGrayReleaseRuleKey(ruleItemDTO .getClientAppId(), ruleCache.getNamespaceName(), clientIp), ruleCache.getRuleId()); } } } grayReleaseRuleCache.put(key, ruleCache); } private void removeCache(String key, GrayReleaseRuleCache ruleCache) { grayReleaseRuleCache.remove(key, ruleCache); for (GrayReleaseRuleItemDTO ruleItemDTO : ruleCache.getRuleItems()) { for (String clientIp : ruleItemDTO.getClientIpList()) { reversedGrayReleaseRuleCache.remove(assembleReversedGrayReleaseRuleKey(ruleItemDTO .getClientAppId(), ruleCache.getNamespaceName(), clientIp), ruleCache.getRuleId()); } } } private GrayReleaseRuleCache transformRuleToRuleCache(GrayReleaseRule grayReleaseRule) { Set<GrayReleaseRuleItemDTO> ruleItems; try { ruleItems = GrayReleaseRuleItemTransformer.batchTransformFromJSON(grayReleaseRule.getRules()); } catch (Throwable ex) { ruleItems = Sets.newHashSet(); Tracer.logError(ex); logger.error("parse rule for gray release rule {} failed", grayReleaseRule.getId(), ex); } GrayReleaseRuleCache ruleCache = new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(), grayReleaseRule.getNamespaceName(), grayReleaseRule .getReleaseId(), grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems); return ruleCache; } private void populateDataBaseInterval() { databaseScanInterval = bizConfig.grayReleaseRuleScanInterval(); } private int getDatabaseScanIntervalSecond() { return databaseScanInterval; } private TimeUnit getDatabaseScanTimeUnit() { return TimeUnit.SECONDS; } private String assembleGrayReleaseRuleKey(String configAppId, String configCluster, String configNamespaceName) { return STRING_JOINER.join(configAppId, configCluster, configNamespaceName); } private String assembleReversedGrayReleaseRuleKey(String clientAppId, String clientNamespaceName, String clientIp) { return STRING_JOINER.join(clientAppId, clientNamespaceName, clientIp); } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.biz.grayReleaseRule; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.message.ReleaseMessageListener; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.GrayReleaseRuleRepository; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; 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.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.google.common.collect.TreeMultimap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; /** * @author Jason Song(song_s@ctrip.com) */ public class GrayReleaseRulesHolder implements ReleaseMessageListener, InitializingBean { private static final Logger logger = LoggerFactory.getLogger(GrayReleaseRulesHolder.class); private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); private static final Splitter STRING_SPLITTER = Splitter.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).omitEmptyStrings(); @Autowired private GrayReleaseRuleRepository grayReleaseRuleRepository; @Autowired private BizConfig bizConfig; private int databaseScanInterval; private ScheduledExecutorService executorService; //store configAppId+configCluster+configNamespace -> GrayReleaseRuleCache map private Multimap<String, GrayReleaseRuleCache> grayReleaseRuleCache; //store clientAppId+clientNamespace+ip -> ruleId map private Multimap<String, Long> reversedGrayReleaseRuleCache; //an auto increment version to indicate the age of rules private AtomicLong loadVersion; public GrayReleaseRulesHolder() { loadVersion = new AtomicLong(); grayReleaseRuleCache = Multimaps.synchronizedSetMultimap( TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural())); reversedGrayReleaseRuleCache = Multimaps.synchronizedSetMultimap( TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural())); executorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory .create("GrayReleaseRulesHolder", true)); } @Override public void afterPropertiesSet() throws Exception { populateDataBaseInterval(); //force sync load for the first time periodicScanRules(); executorService.scheduleWithFixedDelay(this::periodicScanRules, getDatabaseScanIntervalSecond(), getDatabaseScanIntervalSecond(), getDatabaseScanTimeUnit() ); } @Override public void handleMessage(ReleaseMessage message, String channel) { logger.info("message received - channel: {}, message: {}", channel, message); String releaseMessage = message.getMessage(); if (!Topics.APOLLO_RELEASE_TOPIC.equals(channel) || Strings.isNullOrEmpty(releaseMessage)) { return; } List<String> keys = STRING_SPLITTER.splitToList(releaseMessage); //message should be appId+cluster+namespace if (keys.size() != 3) { logger.error("message format invalid - {}", releaseMessage); return; } String appId = keys.get(0); String cluster = keys.get(1); String namespace = keys.get(2); List<GrayReleaseRule> rules = grayReleaseRuleRepository .findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace); mergeGrayReleaseRules(rules); } private void periodicScanRules() { Transaction transaction = Tracer.newTransaction("Apollo.GrayReleaseRulesScanner", "scanGrayReleaseRules"); try { loadVersion.incrementAndGet(); scanGrayReleaseRules(); transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { transaction.setStatus(ex); logger.error("Scan gray release rule failed", ex); } finally { transaction.complete(); } } public Long findReleaseIdFromGrayReleaseRule(String clientAppId, String clientIp, String configAppId, String configCluster, String configNamespaceName) { String key = assembleGrayReleaseRuleKey(configAppId, configCluster, configNamespaceName); if (!grayReleaseRuleCache.containsKey(key)) { return null; } //create a new list to avoid ConcurrentModificationException List<GrayReleaseRuleCache> rules = Lists.newArrayList(grayReleaseRuleCache.get(key)); for (GrayReleaseRuleCache rule : rules) { //check branch status if (rule.getBranchStatus() != NamespaceBranchStatus.ACTIVE) { continue; } if (rule.matches(clientAppId, clientIp)) { return rule.getReleaseId(); } } return null; } /** * Check whether there are gray release rules for the clientAppId, clientIp, namespace * combination. Please note that even there are gray release rules, it doesn't mean it will always * load gray releases. Because gray release rules actually apply to one more dimension - cluster. */ public boolean hasGrayReleaseRule(String clientAppId, String clientIp, String namespaceName) { return reversedGrayReleaseRuleCache.containsKey(assembleReversedGrayReleaseRuleKey(clientAppId, namespaceName, clientIp)) || reversedGrayReleaseRuleCache.containsKey (assembleReversedGrayReleaseRuleKey(clientAppId, namespaceName, GrayReleaseRuleItemDTO .ALL_IP)); } private void scanGrayReleaseRules() { long maxIdScanned = 0; boolean hasMore = true; while (hasMore && !Thread.currentThread().isInterrupted()) { List<GrayReleaseRule> grayReleaseRules = grayReleaseRuleRepository .findFirst500ByIdGreaterThanOrderByIdAsc(maxIdScanned); if (CollectionUtils.isEmpty(grayReleaseRules)) { break; } mergeGrayReleaseRules(grayReleaseRules); int rulesScanned = grayReleaseRules.size(); maxIdScanned = grayReleaseRules.get(rulesScanned - 1).getId(); //batch is 500 hasMore = rulesScanned == 500; } } private void mergeGrayReleaseRules(List<GrayReleaseRule> grayReleaseRules) { if (CollectionUtils.isEmpty(grayReleaseRules)) { return; } for (GrayReleaseRule grayReleaseRule : grayReleaseRules) { if (grayReleaseRule.getReleaseId() == null || grayReleaseRule.getReleaseId() == 0) { //filter rules with no release id, i.e. never released continue; } String key = assembleGrayReleaseRuleKey(grayReleaseRule.getAppId(), grayReleaseRule .getClusterName(), grayReleaseRule.getNamespaceName()); //create a new list to avoid ConcurrentModificationException List<GrayReleaseRuleCache> rules = Lists.newArrayList(grayReleaseRuleCache.get(key)); GrayReleaseRuleCache oldRule = null; for (GrayReleaseRuleCache ruleCache : rules) { if (ruleCache.getBranchName().equals(grayReleaseRule.getBranchName())) { oldRule = ruleCache; break; } } //if old rule is null and new rule's branch status is not active, ignore if (oldRule == null && grayReleaseRule.getBranchStatus() != NamespaceBranchStatus.ACTIVE) { continue; } //use id comparison to avoid synchronization if (oldRule == null || grayReleaseRule.getId() > oldRule.getRuleId()) { addCache(key, transformRuleToRuleCache(grayReleaseRule)); if (oldRule != null) { removeCache(key, oldRule); } } else { if (oldRule.getBranchStatus() == NamespaceBranchStatus.ACTIVE) { //update load version oldRule.setLoadVersion(loadVersion.get()); } else if ((loadVersion.get() - oldRule.getLoadVersion()) > 1) { //remove outdated inactive branch rule after 2 update cycles removeCache(key, oldRule); } } } } private void addCache(String key, GrayReleaseRuleCache ruleCache) { if (ruleCache.getBranchStatus() == NamespaceBranchStatus.ACTIVE) { for (GrayReleaseRuleItemDTO ruleItemDTO : ruleCache.getRuleItems()) { for (String clientIp : ruleItemDTO.getClientIpList()) { reversedGrayReleaseRuleCache.put(assembleReversedGrayReleaseRuleKey(ruleItemDTO .getClientAppId(), ruleCache.getNamespaceName(), clientIp), ruleCache.getRuleId()); } } } grayReleaseRuleCache.put(key, ruleCache); } private void removeCache(String key, GrayReleaseRuleCache ruleCache) { grayReleaseRuleCache.remove(key, ruleCache); for (GrayReleaseRuleItemDTO ruleItemDTO : ruleCache.getRuleItems()) { for (String clientIp : ruleItemDTO.getClientIpList()) { reversedGrayReleaseRuleCache.remove(assembleReversedGrayReleaseRuleKey(ruleItemDTO .getClientAppId(), ruleCache.getNamespaceName(), clientIp), ruleCache.getRuleId()); } } } private GrayReleaseRuleCache transformRuleToRuleCache(GrayReleaseRule grayReleaseRule) { Set<GrayReleaseRuleItemDTO> ruleItems; try { ruleItems = GrayReleaseRuleItemTransformer.batchTransformFromJSON(grayReleaseRule.getRules()); } catch (Throwable ex) { ruleItems = Sets.newHashSet(); Tracer.logError(ex); logger.error("parse rule for gray release rule {} failed", grayReleaseRule.getId(), ex); } GrayReleaseRuleCache ruleCache = new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(), grayReleaseRule.getNamespaceName(), grayReleaseRule .getReleaseId(), grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems); return ruleCache; } private void populateDataBaseInterval() { databaseScanInterval = bizConfig.grayReleaseRuleScanInterval(); } private int getDatabaseScanIntervalSecond() { return databaseScanInterval; } private TimeUnit getDatabaseScanTimeUnit() { return TimeUnit.SECONDS; } private String assembleGrayReleaseRuleKey(String configAppId, String configCluster, String configNamespaceName) { return STRING_JOINER.join(configAppId, configCluster, configNamespaceName); } private String assembleReversedGrayReleaseRuleKey(String clientAppId, String clientNamespaceName, String clientIp) { return STRING_JOINER.join(clientAppId, clientNamespaceName, clientIp); } }
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-configservice/src/main/docker/Dockerfile
# # Copyright 2021 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Dockerfile for apollo-configservice # 1. ./scripts/build.sh # 2. Build with: mvn docker:build -pl apollo-configservice # 3. Run with: docker run -p 8080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=FillInCorrectUser -e SPRING_DATASOURCE_PASSWORD=FillInCorrectPassword -d -v /tmp/logs:/opt/logs --name apollo-configservice apolloconfig/apollo-configservice FROM openjdk:8-jre-alpine LABEL maintainer="finchcn@gmail.com;ameizi<sxyx2008@163.com>" RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && apk update upgrade \ && apk add --no-cache unzip ARG VERSION ENV VERSION $VERSION COPY apollo-configservice-${VERSION}-github.zip /apollo-configservice/apollo-configservice-${VERSION}-github.zip RUN unzip /apollo-configservice/apollo-configservice-${VERSION}-github.zip -d /apollo-configservice \ && rm -rf /apollo-configservice/apollo-configservice-${VERSION}-github.zip \ && chmod +x /apollo-configservice/scripts/startup.sh FROM openjdk:8-jre-alpine LABEL maintainer="finchcn@gmail.com;ameizi<sxyx2008@163.com>" ENV APOLLO_RUN_MODE "Docker" ENV SERVER_PORT 8080 RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && apk update upgrade \ && apk add --no-cache procps curl bash tzdata \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone COPY --from=0 /apollo-configservice /apollo-configservice EXPOSE $SERVER_PORT CMD ["/apollo-configservice/scripts/startup.sh"]
# # Copyright 2021 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Dockerfile for apollo-configservice # 1. ./scripts/build.sh # 2. Build with: mvn docker:build -pl apollo-configservice # 3. Run with: docker run -p 8080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=FillInCorrectUser -e SPRING_DATASOURCE_PASSWORD=FillInCorrectPassword -d -v /tmp/logs:/opt/logs --name apollo-configservice apolloconfig/apollo-configservice FROM openjdk:8-jre-alpine LABEL maintainer="finchcn@gmail.com;ameizi<sxyx2008@163.com>" RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && apk update upgrade \ && apk add --no-cache unzip ARG VERSION ENV VERSION $VERSION COPY apollo-configservice-${VERSION}-github.zip /apollo-configservice/apollo-configservice-${VERSION}-github.zip RUN unzip /apollo-configservice/apollo-configservice-${VERSION}-github.zip -d /apollo-configservice \ && rm -rf /apollo-configservice/apollo-configservice-${VERSION}-github.zip \ && chmod +x /apollo-configservice/scripts/startup.sh FROM openjdk:8-jre-alpine LABEL maintainer="finchcn@gmail.com;ameizi<sxyx2008@163.com>" ENV APOLLO_RUN_MODE "Docker" ENV SERVER_PORT 8080 RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && apk update upgrade \ && apk add --no-cache procps curl bash tzdata \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone COPY --from=0 /apollo-configservice /apollo-configservice EXPOSE $SERVER_PORT CMD ["/apollo-configservice/scripts/startup.sh"]
-1
apolloconfig/apollo
3,816
Reduce bootstrap time in the situation with large properties
## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
Shawyeok
2021-07-08T09:46:00Z
2021-07-19T13:19:40Z
622e35a199d979e3cc6913c79c53e92491f5bd2e
6d50ca881a6afb2766725bdb3c09c14d450cc12f
Reduce bootstrap time in the situation with large properties. ## What's the purpose of this PR Reduce bootstrap time in the situation with large properties. Use test method described in [#3800](https://github.com/ctripcorp/apollo/issues/3800#issuecomment-876288944), compare results:   | Baseline | New -- | -- | --   | 11717ms | 599ms   | 12755ms | 647ms   | 12849ms | 567ms   | 11482ms | 627ms   | 11903ms | 611ms Stdev | 622ms | 30ms Aveage | 12141ms | 610ms ## Which issue(s) this PR fixes: Fixes #3800 ## Brief changelog Reduce bootstrap time in the situation with large properties. Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making this pull request. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit tests to verify the code. - [x] Run `mvn clean test` to make sure this pull request doesn't break anything. - [x] Update the [`CHANGES` log](https://github.com/ctripcorp/apollo/blob/master/CHANGES.md).
./apollo-openapi/src/main/java/com/ctrip/framework/apollo/openapi/dto/OpenNamespaceLockDTO.java
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class OpenNamespaceLockDTO { private String namespaceName; private boolean isLocked; private String lockedBy; public String getNamespaceName() { return namespaceName; } public void setNamespaceName(String namespaceName) { this.namespaceName = namespaceName; } public boolean isLocked() { return isLocked; } public void setLocked(boolean locked) { isLocked = locked; } public String getLockedBy() { return lockedBy; } public void setLockedBy(String lockedBy) { this.lockedBy = lockedBy; } @Override public String toString() { return "OpenNamespaceLockDTO{" + "namespaceName='" + namespaceName + '\'' + ", isLocked=" + isLocked + ", lockedBy='" + lockedBy + '\'' + '}'; } }
/* * Copyright 2021 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.ctrip.framework.apollo.openapi.dto; public class OpenNamespaceLockDTO { private String namespaceName; private boolean isLocked; private String lockedBy; public String getNamespaceName() { return namespaceName; } public void setNamespaceName(String namespaceName) { this.namespaceName = namespaceName; } public boolean isLocked() { return isLocked; } public void setLocked(boolean locked) { isLocked = locked; } public String getLockedBy() { return lockedBy; } public void setLockedBy(String lockedBy) { this.lockedBy = lockedBy; } @Override public String toString() { return "OpenNamespaceLockDTO{" + "namespaceName='" + namespaceName + '\'' + ", isLocked=" + isLocked + ", lockedBy='" + lockedBy + '\'' + '}'; } }
-1