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,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.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.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 AppInfoChangedListener { private static final Logger logger = LoggerFactory.getLogger(AppInfoChangedListener.class); private final AdminServiceAPI.AppAPI appAPI; private final PortalSettings portalSettings; public AppInfoChangedListener(final AdminServiceAPI.AppAPI appAPI, final PortalSettings portalSettings) { this.appAPI = appAPI; this.portalSettings = portalSettings; } @EventListener public void onAppInfoChange(AppInfoChangedEvent event) { AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp()); String appId = appDTO.getAppId(); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { appAPI.updateApp(env, appDTO); } catch (Throwable e) { logger.error("Update app's info failed. Env = {}, AppId = {}", env, appId, e); Tracer.logError(String.format("Update app's info failed. Env = %s, AppId = %s", env, appId), 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.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 AppInfoChangedListener { private static final Logger logger = LoggerFactory.getLogger(AppInfoChangedListener.class); private final AdminServiceAPI.AppAPI appAPI; private final PortalSettings portalSettings; public AppInfoChangedListener(final AdminServiceAPI.AppAPI appAPI, final PortalSettings portalSettings) { this.appAPI = appAPI; this.portalSettings = portalSettings; } @EventListener public void onAppInfoChange(AppInfoChangedEvent event) { AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp()); String appId = appDTO.getAppId(); List<Env> envs = portalSettings.getActiveEnvs(); for (Env env : envs) { try { appAPI.updateApp(env, appDTO); } catch (Throwable e) { logger.error("Update app's info failed. Env = {}, AppId = {}", env, appId, e); Tracer.logError(String.format("Update app's info failed. Env = %s, AppId = %s", env, appId), e); } } } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/resources/static/img/syntax.png
PNG  IHDRkXTgAMA a cHRMz&u0`:pQ<PLTE6C^4F`4F_3H^@@@2G_3G_3G`3H^2G\5H`3G_3H_3G_2H`3Df3G_3G_3F_$Im+UU3G_3G_1H_1H^3G_3G^3G_6F]2I`2G_3G_UUU3G_4F_@@`3G_3G`4F^3H^2G^3G_3H_4Hb3Ga3G_3G_2G^.F]3G_4F^4G^3G_0@`2F`2F`3G^3J`3G_2F^3G_3G_3G_3G_.F]7I[3G_7Cd3G_3G^3G_3H`3G_;Nb5Db2G`3G_3I_4G_1Jc3G_3F`3G_2F_3G`4G_3G_0H`9Gc3G_3F_3Mf3F^2H`3G_2G_3G_3G`4H_3H^3G^3G_3F_3G_2G`1F_3D^3G^3G_7I[2F_3G_33f3G_5G^3G\3G`3G_4G^3F^3G_4G_4F]4H_+@U2F_3H_3G^3F`3G_4G_4H_3G_4I^3F_2G`3G_4F`4G`2G_9UU4H`2G_3G_3F`3H^2G_3H_6J^2G`3G_5J`2G_5I]3G_4H`3F]4G`2G^3G_3F_1Ia3F`4H_2H^4G_3G_3G_5Fa4G_2H^4G_3G_tRNSbq<Vj$5ݗRC9w!8kZI|'2 TO-LoU "p#x3}  _`鄁ˇe>fDlv,N [Y1=X J(r&Ha?7ԜP.s:QS*AVbKGDH pHYs+tIME'IDATxwE!0"P IT0 bCQ@h(7l`{QDLͷ;s}ys6!ovbX,bX,bX,bX,bX,L`M(,'O\Ԕ Kwiو\:U{?ҙ136 IgV2[{G™ޑpڡ;M:$y[(`dsP@d &hoI6=P;UP;"\%LjoI6K;͵ˠ봷$[J(`s8Qx5zޒlBCp2m|j֬M2aPnY]M<:oq+v;}X5m摩 yӝ3ݽy[1{@mĮ lEEu1Pm_Bu#1P4pS? ?˶m ƋoC7S ϲCvݏִtLـ?vXqLՀw3E=Ylr}'u}Ydhw,ښe ?;P~A8ckա,&Y02˵wz=ǟO҈ 'mpʃ9 1@?!8HH 'Gќck0@̏?cqpСV $^9(tbp T 'Qu Ša?:ԽF8>Q"%ɓp"W`OLw?Z4W-l?y+ޏ5ԏ4؏3ڏ2܏1ޏ0Oяf7Oҏf6Oӏf5OՏa3ˏa3̏yb2͏b1͏ћg1`薀aq?qAH Gk/ڏ0 _a@`?ZÀ ~!Bh Bɋpa@?y `ALbrFf@?yޢ=|fAhYѢ$  GJsV*͑4^<$~4\\,_`um}08 iF>,>`t??}۵g1p>s^P$g=ܘ_Gԏ_̀g?_e E  a~t ?w\Gx%}4?TG %|4?HGsN{4!?G{41?~4??~4??~4??~4??~4??~4??ԏ^֏'6GOj_Oi??ԏn?ԏ^ ~*iE ~ GS G G G+ ^ЏV49ؿf x?Z?4xw?Z?]?Z~2pg?Zqگ~t^P? GG_I?:"(Q=f} Jo:h .}܃Ԏ-qGSv_5܏[n=8n+= |?-<pQaǑiю#7CW࡫* GQ6G2 H9Gy.S?I*m?c i6t5ǜ/}KO4  d3@ՏJ/DGW&[ ?M?: GW'< ]p~tЏV y?b!GW-ޑlp?zdӉC!?+0Px#?wЦ? TN/QLäڛX,bX,bX,bX,bX,?kU)tw%tEXtdate:create2019-02-05T15:01:00+01:00 %tEXtdate:modify2019-02-05T15:01:00+01:00| jtEXtSoftwarewww.inkscape.org<IENDB`
PNG  IHDRkXTgAMA a cHRMz&u0`:pQ<PLTE6C^4F`4F_3H^@@@2G_3G_3G`3H^2G\5H`3G_3H_3G_2H`3Df3G_3G_3F_$Im+UU3G_3G_1H_1H^3G_3G^3G_6F]2I`2G_3G_UUU3G_4F_@@`3G_3G`4F^3H^2G^3G_3H_4Hb3Ga3G_3G_2G^.F]3G_4F^4G^3G_0@`2F`2F`3G^3J`3G_2F^3G_3G_3G_3G_.F]7I[3G_7Cd3G_3G^3G_3H`3G_;Nb5Db2G`3G_3I_4G_1Jc3G_3F`3G_2F_3G`4G_3G_0H`9Gc3G_3F_3Mf3F^2H`3G_2G_3G_3G`4H_3H^3G^3G_3F_3G_2G`1F_3D^3G^3G_7I[2F_3G_33f3G_5G^3G\3G`3G_4G^3F^3G_4G_4F]4H_+@U2F_3H_3G^3F`3G_4G_4H_3G_4I^3F_2G`3G_4F`4G`2G_9UU4H`2G_3G_3F`3H^2G_3H_6J^2G`3G_5J`2G_5I]3G_4H`3F]4G`2G^3G_3F_1Ia3F`4H_2H^4G_3G_3G_5Fa4G_2H^4G_3G_tRNSbq<Vj$5ݗRC9w!8kZI|'2 TO-LoU "p#x3}  _`鄁ˇe>fDlv,N [Y1=X J(r&Ha?7ԜP.s:QS*AVbKGDH pHYs+tIME'IDATxwE!0"P IT0 bCQ@h(7l`{QDLͷ;s}ys6!ovbX,bX,bX,bX,bX,L`M(,'O\Ԕ Kwiو\:U{?ҙ136 IgV2[{G™ޑpڡ;M:$y[(`dsP@d &hoI6=P;UP;"\%LjoI6K;͵ˠ봷$[J(`s8Qx5zޒlBCp2m|j֬M2aPnY]M<:oq+v;}X5m摩 yӝ3ݽy[1{@mĮ lEEu1Pm_Bu#1P4pS? ?˶m ƋoC7S ϲCvݏִtLـ?vXqLՀw3E=Ylr}'u}Ydhw,ښe ?;P~A8ckա,&Y02˵wz=ǟO҈ 'mpʃ9 1@?!8HH 'Gќck0@̏?cqpСV $^9(tbp T 'Qu Ša?:ԽF8>Q"%ɓp"W`OLw?Z4W-l?y+ޏ5ԏ4؏3ڏ2܏1ޏ0Oяf7Oҏf6Oӏf5OՏa3ˏa3̏yb2͏b1͏ћg1`薀aq?qAH Gk/ڏ0 _a@`?ZÀ ~!Bh Bɋpa@?y `ALbrFf@?yޢ=|fAhYѢ$  GJsV*͑4^<$~4\\,_`um}08 iF>,>`t??}۵g1p>s^P$g=ܘ_Gԏ_̀g?_e E  a~t ?w\Gx%}4?TG %|4?HGsN{4!?G{41?~4??~4??~4??~4??~4??~4??ԏ^֏'6GOj_Oi??ԏn?ԏ^ ~*iE ~ GS G G G+ ^ЏV49ؿf x?Z?4xw?Z?]?Z~2pg?Zqگ~t^P? GG_I?:"(Q=f} Jo:h .}܃Ԏ-qGSv_5܏[n=8n+= |?-<pQaǑiю#7CW࡫* GQ6G2 H9Gy.S?I*m?c i6t5ǜ/}KO4  d3@ՏJ/DGW&[ ?M?: GW'< ]p~tЏV y?b!GW-ޑlp?zdӉC!?+0Px#?wЦ? TN/QLäڛX,bX,bX,bX,bX,?kU)tw%tEXtdate:create2019-02-05T15:01:00+01:00 %tEXtdate:modify2019-02-05T15:01:00+01:00| jtEXtSoftwarewww.inkscape.org<IENDB`
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-openapi/src/test/java/com/ctrip/framework/apollo/openapi/client/service/ItemOpenApiServiceTest.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.client.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.util.EntityUtils; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; public class ItemOpenApiServiceTest extends AbstractOpenApiServiceTest { private ItemOpenApiService itemOpenApiService; private String someAppId; private String someEnv; private String someCluster; private String someNamespace; @Override @Before public void setUp() throws Exception { super.setUp(); someAppId = "someAppId"; someEnv = "someEnv"; someCluster = "someCluster"; someNamespace = "someNamespace"; StringEntity responseEntity = new StringEntity("{}"); when(someHttpResponse.getEntity()).thenReturn(responseEntity); itemOpenApiService = new ItemOpenApiService(httpClient, someBaseUrl, gson); } @Test public void testGetItem() throws Exception { String someKey = "someKey"; final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class); itemOpenApiService.getItem(someAppId, someEnv, someCluster, someNamespace, someKey); verify(httpClient, times(1)).execute(request.capture()); HttpGet get = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), get.getURI().toString()); } @Test public void testGetNotExistedItem() throws Exception { String someKey = "someKey"; when(statusLine.getStatusCode()).thenReturn(404); assertNull(itemOpenApiService.getItem(someAppId, someEnv, someCluster, someNamespace, someKey)); } @Test public void testCreateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); final ArgumentCaptor<HttpPost> request = ArgumentCaptor.forClass(HttpPost.class); itemOpenApiService.createItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPost post = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items", someBaseUrl, someEnv, someAppId, someCluster, someNamespace), post.getURI().toString()); StringEntity entity = (StringEntity) post.getEntity(); assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue()); assertEquals(gson.toJson(itemDTO), EntityUtils.toString(entity)); } @Test(expected = RuntimeException.class) public void testCreateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.createItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testUpdateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someModifiedBy = "someModifiedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeLastModifiedBy(someModifiedBy); final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); itemOpenApiService.updateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), put.getURI().toString()); } @Test(expected = RuntimeException.class) public void testUpdateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someModifiedBy = "someModifiedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeLastModifiedBy(someModifiedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.updateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testCreateOrUpdateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); itemOpenApiService.createOrUpdateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?createIfNotExists=true", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), put.getURI().toString()); } @Test(expected = RuntimeException.class) public void testCreateOrUpdateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.createOrUpdateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testRemoveItem() throws Exception { String someKey = "someKey"; String someOperator = "someOperator"; final ArgumentCaptor<HttpDelete> request = ArgumentCaptor.forClass(HttpDelete.class); itemOpenApiService.removeItem(someAppId, someEnv, someCluster, someNamespace, someKey, someOperator); verify(httpClient, times(1)).execute(request.capture()); HttpDelete delete = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?operator=%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey, someOperator), delete.getURI().toString()); } @Test(expected = RuntimeException.class) public void testRemoveItemWithError() throws Exception { String someKey = "someKey"; String someOperator = "someOperator"; when(statusLine.getStatusCode()).thenReturn(404); itemOpenApiService.removeItem(someAppId, someEnv, someCluster, someNamespace, someKey, someOperator); } }
/* * 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.client.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.util.EntityUtils; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; public class ItemOpenApiServiceTest extends AbstractOpenApiServiceTest { private ItemOpenApiService itemOpenApiService; private String someAppId; private String someEnv; private String someCluster; private String someNamespace; @Override @Before public void setUp() throws Exception { super.setUp(); someAppId = "someAppId"; someEnv = "someEnv"; someCluster = "someCluster"; someNamespace = "someNamespace"; StringEntity responseEntity = new StringEntity("{}"); when(someHttpResponse.getEntity()).thenReturn(responseEntity); itemOpenApiService = new ItemOpenApiService(httpClient, someBaseUrl, gson); } @Test public void testGetItem() throws Exception { String someKey = "someKey"; final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class); itemOpenApiService.getItem(someAppId, someEnv, someCluster, someNamespace, someKey); verify(httpClient, times(1)).execute(request.capture()); HttpGet get = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), get.getURI().toString()); } @Test public void testGetNotExistedItem() throws Exception { String someKey = "someKey"; when(statusLine.getStatusCode()).thenReturn(404); assertNull(itemOpenApiService.getItem(someAppId, someEnv, someCluster, someNamespace, someKey)); } @Test public void testCreateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); final ArgumentCaptor<HttpPost> request = ArgumentCaptor.forClass(HttpPost.class); itemOpenApiService.createItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPost post = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items", someBaseUrl, someEnv, someAppId, someCluster, someNamespace), post.getURI().toString()); StringEntity entity = (StringEntity) post.getEntity(); assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue()); assertEquals(gson.toJson(itemDTO), EntityUtils.toString(entity)); } @Test(expected = RuntimeException.class) public void testCreateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.createItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testUpdateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someModifiedBy = "someModifiedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeLastModifiedBy(someModifiedBy); final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); itemOpenApiService.updateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), put.getURI().toString()); } @Test(expected = RuntimeException.class) public void testUpdateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someModifiedBy = "someModifiedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeLastModifiedBy(someModifiedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.updateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testCreateOrUpdateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); itemOpenApiService.createOrUpdateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?createIfNotExists=true", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), put.getURI().toString()); } @Test(expected = RuntimeException.class) public void testCreateOrUpdateItemWithError() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someCreatedBy = "someCreatedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeCreatedBy(someCreatedBy); when(statusLine.getStatusCode()).thenReturn(400); itemOpenApiService.createOrUpdateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); } @Test public void testRemoveItem() throws Exception { String someKey = "someKey"; String someOperator = "someOperator"; final ArgumentCaptor<HttpDelete> request = ArgumentCaptor.forClass(HttpDelete.class); itemOpenApiService.removeItem(someAppId, someEnv, someCluster, someNamespace, someKey, someOperator); verify(httpClient, times(1)).execute(request.capture()); HttpDelete delete = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?operator=%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey, someOperator), delete.getURI().toString()); } @Test(expected = RuntimeException.class) public void testRemoveItemWithError() throws Exception { String someKey = "someKey"; String someOperator = "someOperator"; when(statusLine.getStatusCode()).thenReturn(404); itemOpenApiService.removeItem(someAppId, someEnv, someCluster, someNamespace, someKey, someOperator); } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./doc/images/logo/[email protected]
PNG  IHDRm&pgAMA a cHRMz&u0`:pQ< pHYs%%IR$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@IDATxT3`'v *bɫ1ȂQh4Fd1ZAXSLb$1Ƽ-*%l)gvgv- g?w{O?O?9uv#q6^ۧ:yD@M8>݇Kw Mz7]5p^CBN?Z2BwFp],vB{@+j 4_YSYΩӫ%rC\/2Xb8>| ?9X2p8x縺4ZčNkk+wx?çbNG]-[ D6^1^nqv=g]or`3W 8唸?[r?>dl1~&@ uTg{a.Kq@,9'@q 5d<i_ۮ{؅ /IĘ^o3sB}?C‘F &|%yaϣ\8476yw*_%ޅ VDk߂+Ş~*Ɯhk+%/}@KYÕ|xHlkijy◵ۮ<#zmDj#ۮtж3R+p_ CSѻq۳(B564nB'f_r%okT" [z`{ZtG1nFtSCZbGj0!J" X_ߟ>rUTf7Qolv!W_ ^9ؕ~cm}C~ɕU^Sc4(|"LЗQ"p=q/tԔỸIھ̶V q3<ǿWM2#ޑVTU@ߝ>rJ(dĉjۮ@t]*Pn^1F,Rejiim1)vԯB1(~HeuӸ/ ?_ȵk1û$Y`oh»w) )ɐ;2bWEUeݸlԤ`+u^gwndu߅ [Xe6nc]7tOU8u 3 LQ,]e+cE7ٙLa }Ċcƻ|x Ձ d)c ,RQYV̝r/)wʰ$=97̫Xzhk v2ȐV67>mjNv!l#QBpѸ̷=MͼIu^66j(%ŭAB~s/z~fqxai1DN<N4/TyBQiƏjrX < 5mq) I-Q{YX3q4kώͩ?Tz *$9yb0ܪ <ڍsg蝂ڶ"lWTWpڙ}Q^jTO:z?+K/x`AUS3Cd yf@ uiQTHL¾>)$GWB)y bBLiSϙ]UN W)֚7kvkub0Q_y@ VUR] 1gVS߽YkL%u?uJ?-ZEW4]=臽aӿ<q5n;}[w͛X^Y~^8u֪1Poᲈ<}V`z<x>^]q3U DttØ?r*HqbyeE_x-MJ*'wُ6F9Ab\W )U :z17T(U#P@Q&eeea,^)VN߿edz`wb\g@GɬϹsQ7tSxXҗҷ MMӦ4){di$4ά{iuhՊ j2EOnW&eD;';`6y"`⟍HʫЙ9sL䓝5{| yEXThqMuڞ$; X @aasS}`0"ki{c&k/  cû륻^9D¿Qhr\BrT474rI_P Pӕ8v:Y?[g8&~Vc*%B& te5_}N"V:OzȳkWj,S]7Z(v-6_e^eԑzbRH1cM҆׫޹%SE:2674`)Tĵ~ߧOvxM0J2 ''7N]'BcrTb_)3nˆou&- bǍus#L Rr <8CXNyL\]ӀXj"ñ~soxsSӽC23 :ͬۤ@p7׻~ GYz<qvХ(`TMxg^:r5#ܖh*oE7VF|իW{Gq_rDjj.%/_K=A&x?m}>|sO*t8RrHĉ<ŤX_P|gf?})qElf2|k8\y_B 6.\h,$m={vybol0J2'0zCEpLz4X#3+08!<7mwrI<1ms DU49i&~}(f͏@^~|w:ME6z=x,_nɸ&/lf>{D$}$5Hqcڵ<>iC=!1WLC<:{O&џ`QbJ lQ4HƏs E7KFB<0 ~:_ȫ-]>黐3Nd9 w: ~RcE[ϜV3~KTz,A An# u{DI /sDDlo (.;v(*zى8! aSD.y^wے%w.(%)kX[71>avnTnqF Eo"M+L16WW\fpj)Z+- 191_!W!2a1^^^>ƻ>Pdzt*Co<Ң4>c ? G"@\aI/6rc :fEJ}-Ҭ~KOQ"KnwX=mX *a<m<!p"u.^beR< ;WD>խ3U(bD`xEEP Ɲ) DT>Jq9/E@x p7BD<nq7YeB3ۑFӂ S=4oi<Br6b*Ҥ!ǑC(+;%J:E@I{ر@"Z:qߣ&I(;)!߼2i4?M,λ%OP 2}~/Zb:\B땴!mp,f3EDAh׏ kF5C)6^ D(CJaJfcIF=PϙS\"3-?"(.+2eP؍u> Awжv\ѢE!jɒX+LyRy)32* VEE|OġҖk Gpa鸶9%_ ĭ;!ǻrV\bcҺ1|B 8 bVqCm(IwCPC4hQB'46e`030̸~,p}W"D \Ixt\4f́ B,Pܓq[.ƽx<A}Ӓe4;1A'~ht/=A~w1`"OTWcBJ<7-pEnb'X(u6APT} n}ɜyv\DZEb̭3.:(~+; wX= A\LR-T@FsH&dPe%Wȹ瞻eA( e feRDE-pA0^]m.AY{=Ԭ0֭+H=gRav<aGg!eq@f)(D.@Y#6mCzהt"nU:r)8.fI,y~~l9(Y=x)AIjVB!a]YG; +! l' 0 l""Ա };CN@B9ܫ ;ƇU.ˉ!w=(\J*c{w?(չ~ZZYm$L $lHĚOȆ!̱p86`#mOu]\ N !I8bq ӭ.븸؛]@5cZ3«xu%>9bU^qq2>}J\ǁ6rkcN y~?<xpayT`GQb>+EjғfṇοA*:/ ?n`+ii1 ?y-pn[GfӶQs$uQac(z>I ԾHX1Y8#'.,M=zo"7Gqn$)%D܏]]$A6mԮ7Qy{)KM?#$uУRCf5 0/EH֐OBu3@v8 <rpֲg&\KwB4VDT枔ǞE݊q&QI/Ff3i2`; `*w{ 5gOv R{;!Ї<A$Lq ,v n,ļX8#[XP$~r !'!Ev/NB2٭^L)̈ G$Y0I$6le*'=&ܤ{ab2F]q1|w̯PŜڋB_UQ$|!o+1kID7i%%`MHwO=Ac&^+0ne_֫ӡD BBiAyD@t0RYq0=)}=U`QE5բtzy ֲ/-T@HK{y4Kmy WؚdGJBfVu_Hs3?.u WuZ7?H$G!뽑r( Jk`y3Q[~3Ƽ,mnosqʶ`z=,ҷ9E,BPTnBzesB;=Z* GLZ#x7Hc3dHyQCr *o/6,ɉ[SZgmL5n,b8掊`GM>(n dny=XT82j4o7 7ˎ sUv}a 4Cg5iYyUE V9iF0n@F3c9֑ϯ ֭᪚(0"a \Mѝ给v"_Sn{N%Fs\ B:x:nPIVD_ڗ,/~Ḿ3#] A,:.S=\ ۇ M=o=9S#$ЉLmZ3簽Ojm& jԿ%QiE#rl[ 6jJ6'X 2 Dr?aⳈ-,=*+91#iǸx.M ?e9c3m;=I}Ƭo0FX9$Ӫ+u N@Q6`ܸee(s();aT<ڌ"BZl! N҂`3$Sm{|f IG>8=3φ~oPIR9P z%nxc$"vw>/yU\*ӎֳEJ0%ĜC@r}$(D#u$ _-{R ccZȉRnlPcCY=r}~[oMoK;:ïuj-CC$6n[.bt<'S~ `7n boK90J(eʧwc5IcI}^?YŬ 7٪Fyrю.\&ͧkޏ[Ի16s<>G{vاf՚~wǐqcCulߐ`]9ڱPqFZKϻ[Fz#[^QQ^c27ݶBU%r͹mK2Gpi㨥_ImȢDyiG~XBrFACΪխ\-JK^7~=+A8"5gX9qO҆>"zD6ڙ/ o\6`iLbji{K8rM Ac0Ϳ;lNR r$^ 堛ĝbBP Պ rH)Xl]pRzkIȡHA18u^^a IkTqC < 8qh%7I0hɒXFFI@dv!괕 H.3dgmR"*fC{pS}c?릻^D>aeS%sI/[VpݡZ܄\H#z &@ tVR}L]:Q%fKA2|g&.\G$K,yk,?e e+eQ(kZbPuM~rN$μ̱WW_@DN!?Gs,tE=_WbVݼUU8$ہF[6ou:j(U'‰ I<q>P>LTWf8qD|YxoYK @V4'Ka7g\d4-EZZU;pp3G%wKEr@c4ྉr&4h^:/2 .ōGf9r2WtTdF̉܇N-fN$y鮍ivI%R'Qq*]e+J{('$lwk20lҥ넨\Ś}7| 8p8\@dz5=95_1y30ֈrWu$+MjPK5"oڝ-;%1 Z҃l&io$ݰV[5%"⢸G7ܩ#/~Du̙65&3 8UJ!<?U ..˶;zin̩"mjlla1DbEinluw?Z1;h,\T9=AGU\˟瓯6؆eT#J5NaB/&L:lWWm%w['A{8 r*+A;Gιgxm*]*F<z(<`鉺Mm{ J\O'mi 8"׉Gͪ`V݂k " qS-.yn׈S䡓slrַG]k0{4% ֌5{i{ۜ8"?sߜ={v.Ktۯ_?#VU44̆D4YI|,V⧵B>)%'nX$tս.jP:o`')8MMHiL}oDqG,ZJH#`.v](ai8&;۝jZ)i~>ZQKNq#Ɗ##eaM[y] ;h,8 s֦ 2y]Ά nZylL@J duvQ]%z>;~]s+3%.b5̈QKadξ/ c~=]L˦m7ᱛ;"R^VS1 wUP[+*uy8 م#܎= `t~#gvUݳq;*i~B[ݴ\QQYORPf[L{f&䐲.m6DP9NRq<\MTYm*3iDR_麪^UBV ~0Q M.1.ei/(䡖ryb}Rfʥ^==N vi5Ekynd~I(aHZ<dٌ]֍b=š{}ޭzaÆ.5iS#:# u~0`D-+r⿮3e(R YxE~7i{ _O2 W^M[wlvziٿ]g ]с6.$ɑұ;kuEd)oBD/a~PJŮPdSOCFh+cd͝vںT>P_̾Rg6)CZrV(R+| bܱ,^VABvReſLXْ QW{)$ٞ ȒbeXJ+ x*f35FN|EU!.c]Pb1f <8+a9f)sTUPx ᡣ <6/މ;杗2P,)ET3 6$ 8q"l=w(քuJNBSi _L:`2ebUZsƟ|0oQ IžƧ-ZcV_>& =Ht޽{af~}kt``YJ_#;pjO_omDOHBhPMĚZUF--r&B&$ɩ5NN&Gw8QTuך<|Ó++r!\sU˄\S@͆:  <׉o\Vs[s,6Rل2HdDӖVgoذa'|RiԢH FZz9|PݺI,rX7¡ij-F[FeJm_ipY.(~@T4Q iZ.9{8Qʷ0`AL@FiϩDYAF&t3yeo޼tn%K%mnKL-r~"ey*2nP[y{կkIB3H>+WTh)n\ lvfׯWVyC'1-3`z`0AYʵA7,ㅺ`KR{\ǭvO$@8"vc\H[w,$E?G++mN/d~/}[ VqfwtX͉n)qȡ/ʵyK Z2\Xus0ku%y$t|YSs5B1f!Ǐ?}ݝ, r0N0 dv7V\~Oaʘ=4ǣr +Kİfe a)ߍ14Х(СCw&T$NU}!|ӄWV[wgzZIdKuo`XJ#tU%3KA;]O vmGaɖW3ˮ՟_ |&DdVYX#A[K[{7+-KK-O9BG tqiv^b(QYD 4K9gC҇6yu鐃sF_Dk?NLXTBFēfaѸt thFNy=v>HtլT4O߸(ߟg=BO/GŶTQ7z6,d!ͺkޑ8 .[iY4 #$*835SFeޕ~Ү<lvM@)՝( DC"qS<r`EVʉB,vсۏ`ePh*܂&ޠ  /C|`շ"D9?XJK"Z1psC 7=UnQTsLl'ol\\J4yc <$GC@ %>SM@D(j[$sKHY<r/O|e(@.ȨC_aUșSޥ DŽ{TߤN̥^UC%R̵QDg K]e{f&i[IT,I>ID4Vq<:ǎRU4MW<T*[!s8Fe+׬(iͬ7ݳdw7d$RvhkkKv{7swO צ_2yNf(nJ,̔ -|4!JRhM 9$R9hCW\C:l"a,( x!(THL<kՙPRp9zfbjF+9<H<. 6䉬9^x_}mU ~\Q!I["JV*v 9O[" rc(IxԲ|GiXDKe0\D\W 4b$PȢ'Ep0FNvI VxkM8a6 @5h4<*-!J)(ϴ(|)=#tŁ|tVT1^1M/Z%T{JsHߥQ9dW6ZSKL8␢SA-W.I?x숁OTlj|sx*NA:֝ȃ>Fqs''LmnlEq%pJsF_<vҋg@; ).rw3l*(Ɉ Y~wXTS2|1CY^ԓKէ_w!CnDʫsg?هΌc$D!t%Sϙ0ue#"7E^%^k^v׵eA Ir:'@hI2tLRq{ùrkBs`^ VU!™Bַ`ƂVyL~w lԱDM(AU ^sHY8z ƃUt5vTBI |H<^h ܬ5_93Qy磊"s&8wWAyWxQGN~аvɶ--j2ZѣI:Ek!lZ9Vz HRdvNT<dGG9!)梘#:Jܮ>s(!,a>j<ݑCrMOTJ.씟 5FlD<˥,: eeDzBRH"=<RmpG"묾_rƼnW9?x<kPh,?pT.pF|$,@4f3 A$m| Y7"Y0@?atC ,QE['9XTCuHt;8;9;'>VF5u6UYin#J71pyux I[Q (o)KGM)rviJ:,5yEg&0Rj!Xl FF>Qͭ u }~^ŔFi "dAq]>qxU!JU%Za!_|8-NFN%Cp&:7t*OYgB5UUU{p:HJ ż5Ow VX|㸠,@ PRds\<; Yy>?g~s_AyMK<?dJOI`Zq%uhUBW;IqHY.Ik}ou\㏯{OJhJS&YKjFd!?7V]npӊÑaUd) d|Q &C-MMrb̒~- < `jJH 1f }(vUT<-RIsP͘1Cqܦѫ$!ΗvmӘ;nY$nm 'H Y6AFI:99Ќifo/Z2i~TԴA!,h^gd[mvsZ8%^U)飦|Ne& k恷u)$7oE2rWp4CC:U~}^xA }ҟ ];xd0{j:馋ƌ90ypǙW|}a/^: mn'bوG 8 ԟ.A8AلR!?{# :wT``9:L<{OG1T*}Iĭn¹JΈY̎|}Zd 7֟l8 oQ2 qm\F+I_!\p|pKKHbuLyNkK\Nlֽu ~ƀ fgҸGzb!/b9L Aǔa0b)h#CtCԞCjHM:̤ൈV߱b\>ۑjPg^@wC@osc]PwLR!E6#Z<!(w T~Ll`A(JH%KFR28ap*AG |&BURT"xk,+Cup Q|R@k1-5"a):r4$,8OUa< E" @g% n2.Zŵ#fF!Mg?ـbu޳ E4\ʾ |F /4rPQPJ:Iqv>+ (`o<n8;Kk,YkFՎ|])<lߣۖk .7#'=Ƥ?bbee}X$L󟊫8蓢ydxV1xavMRdk^v3 8J_XKW)Je`vDS"$) q5[G/)2!'Ik XY|űd ,GfZHu%W*2JuP=Ee:o7vpxiߘH[bpYA(K/$KNb#v'1If 3a%/$E =F:UK!^34g[j8 PJxRۚSE49սw',-6cBHİNyI)2[LG-qk߭qvå#ޏMY&M%V[CL'mvFo;3Ľ&^2$!$pAUVl=At}>7!\;kge ;."fw®Y" /_PBъ*)MOtcO2 8#KјVl^Gy='CO\ zGy++{gmB I [0jzK,!dVA[fCs=b%sieeu5UC{.Hm%a<'CWM#lyfe:#HXt GJ$ ՛Cj{'p!5nh_G|7ŬYߦis fU s,pWuH*PWQn_8~,=NLcDbȐ!{Sg^b6 Q 'AC\*5XYr=ܸjwtM*9Vaec7rWuO#?|ӵ%T-*}-I-,3f<=*nxq=?%(d|@l7dEEyy 9"|:cѬ$UE:\i*^*䐷̆1zpE!:B1BEj>.B8Nz&˰Sz_-aBtxb`J*1],ꕐ'30$ nAFWj|tO3! Bջ"~qLA8nN9^96]<Ѽ\$WpeEA~.M: ?qdyKȟwF*2tEҌoy3bD$G#-w'[?"|)Dc!@>"4UJoA0Đ{hnfo ")m96 <*ޯ╙A[N QXJ"S"ǭ?X4U671!#%I%.݃mudAu98T /Ү5 FL*qFLB‘5l8-e|}3Ǘv<+fmhǏO@Ah+VHHE@_3 -BQ!2ʈvS[q o*{ 9u6VȡvpF*<JͶO7 j14pVd*ud񢈸W_o!@6Hq_[`%B飑&\)땀BԾ`VyRt@V]Lm3eqwTP vſ͑rF 9UVΈ.:.vɾY:d=U!ŜNY3EVƊymk^D08\|Qِm~KҊJiN"¯:wN NZ!A#NA2R`禺yߪlZt#c)stĤ`RTE[UQXw6O,-Xtҭhm22$,2HJRf°@C(9 Cz*vAfxM솻MܫVqboWN/v^MM#51C?R^E҈t6L%I;Lo{,۾o[3à- D1/W* mK{Y?{ Vl^\>X cnrli:{/k=~9~$ @=U3A;Z;;5ewp ae$RV${.pDYKUU?l%i2Yzۖ}ߊcLKhoh7-lĮ'T]c }V҈,XE#^%cBqe2rt`-g ~H, uaEpvX.$oVMB(u[Bz8 *q`xspڻe%V"QYl}w]+[Z'{g4Yu@t-jjMxh̦ a2@է|9΀<ļx v}A\22lҲAKpX "Qg31Yyp7LqMH@5{r9FJ`کA1k@u/w~=ʖIm)MAK@akw,ĶO(LپN, *u}|&SP>(Hn;﬒ 4s5q9RjZs4֢~F*# ųxrcA87r<98s[,=Ru{bAtہ,46#=eޤx%N_}F$iWxYm畲޽_kW[OW6elnCC`B3IDAT]L%<} !]Xٝ,k8ȌK f 6A{ט=dsai!H2Oc"vlmM4c*Jھbtt =frH3YwԮ}Ŭ GI  r^6AZufDq :dt6WsH,aFВNnEQNY;90!OǶCʹWF&H$ɉz w3H**'`K9k7 ļ/f0 7澪m62[] AvCkG9d:ml^{aMDG=RX2k[ \lV^KOn)M;?DzQ9?Vvq1=hU@taX54̢PC 5֝1fR o4~=$CՐ)ec*qmŽ;rUTfkEbl\r R۱dJ (E]`&3:h-K0Hlz v},$fat\>}TbʴUɣa\ ?ߴ}XD%@͂j1rz׋~1/Sc,vjЮmz xJpzQkLʊeԚ =n֢ͼێ VlFLHƼ/El㽬 l2lY0qIҊl;Fv{P HDqv-lWp^] [h *hA8XrpɕŕW%3GЫjkjŮe9#XE|"xn~ %g<*  h:b#$5 @5غ^uJ]/J, %7AvqT0tp\Msfғ!*3'ޖ&L*=qdO̅1آ yD\A8jnhjNB*ADf;JV]K{@ڑ\JKT&Ct3z=JxJ)i2KpyoInІ"QVΣ}jթZNmH ڏG R=6r5q27}=~=};Jgd|Y$h}rjS9}].J4PY$#1wa%y)J1MI1˭Աp丽D.@[541h{gS,HrϺ?5v~(^j 祏ZFܮNW]|+}a C;eE/r"lʨ6#ſOLVcqL;7Ȝay[x^sem7k^d ԏZ}7z;\ooKunH"bۯ".Rf{WD"e\Іvp5z[4! Sh2ԹdL574|W\,_zsAPڋ]Kc5SD""IJ_m?ou*V,ZtL\QyM,HTB{$"LeieeBv";Llk98d$C`3ӱo▗nj0'JBg}fͪh*/(J.RFga|${o/UeL9Mbr pqQYOct"A} h;ϋP>.jO޽pE>mkʁ!!϶Syc3f{t06g.oqfH0C2&#q/t୓~dڵFTeAbj{f{}u_߼"S,RyZzU7lnkatko]!YjL1>'Q9B kY:HX^G|@P$t]-Z!W.*9X(`Y{RB"n?m9r`r/6\<&)g)Wܼbw<Qۤ)4(77zgM<5fnmF5'uOGр"I r"ɝWy)@;v]IZ{s&c#u_{D Dv[ث3>h:L Ky5Իv:^"5`@ՈLidBۏ۴Foe:߇AT(Vݫ g-ܧoG.d(,ʃ<d+ra(`{a{~͚[藉~qy *}GVӟ]) }4ܣ[ᨭtAϪiVDPTIllBۙBh3#Pɪed)c96gsyeCHbI;* Ua߆#ONLÇ9(WN" 3#+^ NܵeW(cF}rlM!: 1DU8C㋗O $|NpYr3b2e|i^&w2c{Ro ]Akq{5)E1 Wk~mC:L9y&F}sAMv>Զ:3s$h?Y}#6l飦~Ymwo[} =p) |/f ` v)})Q{lB<+a?DC0,g3#J"g 1~k͛? /s( -MMTðD>sw NT ]Ƅl;@ j|Oo0)}L2֓ǯƺ+De%켾f@0+gCA|?7e NqJ~޴)21 K`S8C0~g;$+k[RNW~{Y^ONB>y T-ڡ|}Z+,S+Q]!JVvߙ.CiopܸU+(;E3[3h,EK|RMvSy tHE+$hW)e`(3kVywk=ڎqN!yx4 :t^u׌Sk<B II%l`Op9p l-aDyA?BU7?,"=wNe+4r&<FqDTw%0w߷[ @,};v ^nHLCEB $d5[:4/l4(@v*[/`Nȗ34k͛<|Ľdi֝jnjf'zH0 tw@ޛԸk1>s'-y96̶n5G:8BE%YN+Eg5\dN?PQ(C1;$3}x~+t LE G8<!Jeɵw8x~O< PDVmaXx7JRVYYlg>9`Ɍ "R̃O TXIA9lr$P}p+VV9^VvK:+őqeF>⋛(CB^bE$خ1cl>|Dp -[Hʥ ;ⰶ*qCV@(0#фcwLjin.FHsKKKgf Al%۟8*()T]xSe9$PP 5{qH#^sE|~AJoU!|e8JA$7!<CzYǎ -F(ba\K)z f1ИE0 K'%^0nܬHRS004-2! #2.ؔ腷߾1#i EcRl! I$7% I`$.[(qKBˠl2 =U6$'Q:"V߹PlJ=m\KaU>laeiUdqCiOa$$Eqw!Ext jrbGrX+N)OVLݸ9ptb([BL2VKQ#B#SYH,LzEG }@!坽&\{GގB~!)֊9! =_ȡx.Un)g'F<swXo0BTxVEĻYHA V0uYi<ү3}mZS S@Deem}bzx{Poҡ4vqۗu#&?^ I*Pͩp"mU AumE)Ōlz]nNOMOXs4U vW&3b \x %KQh. fȅ*d\pC[[Z2GN D#^ZLo7u(D߰%xNEkǞs =DʋbXZLt ,}xm^kÕPw9ـв ib =5ktfQ:Q^Fڳ -ý7ĩ3ɒ: M9o dK1&fE ͐kbu~iJ;[t駃ʨo";#J&?ȼ 1Io&E Mcн@k;8NiQͣ¦]-epϲf稣i{mQ:}cڴR(ꗭ[W:`m^,) Q9U]lYPGx6e5hջz4mD*q%Z+ȬK-pa?Ylu-6Ä+S}̾1tr)2չbf :掖x|ǹmx_2h,@tasB !8f&cyآ3hs7KG.O *ɝ (+]a\L=[c1pm0Y0L*.;3N"2_OB' BZcc| |k:YDSw)xtiX_ *J/ qGРQ&#[L1/? %JZ~~,68FF^TC@a^ O~ 0wDkp)',re1 m1c` PE$0 XAT{dy2^5MLT~"( b0Ucùe\ bVINI;fwU\B4uf |k=ux&IDZ<:p~\rPz^95ANZ\D0} +w gU<1~>c\|n~CJPt=}4}4"oE͡$"/kތÞHڵXl(cH :t%ꪱRYo@r3iElZW1? AD:M*"*LzݵÇ%Y(wTxA'.~wu|E)2m* wk< DlWOu}1BQԗ1gRFGQ kz.^Fd^B6 4͂.^+vThZ~7z/{{ck " )JB<ӖCQʣ+J&2͓ ?nݺąMT=՞cʆ}xi:vg4u8n1ϫ w؝_ '`KJhlp<Ob"hٲ;nN% A >nZ'b)3]$ KAcM>jV":C HLO[ N햏,}vSSo]Tl*[ @L2&uGh%蝾)5Vrwx~ ǕlZ!QԲٖh,$HYlPh _ӯfWVDZMƭ?XѪrAN gz6O0qVHbkf@KuJ{ϦQAv3jmK~+@N*sq{BIY4N@\@D~Ⱥ4Cim'O'{8ɱ>.sTTT99W?k ʴ < Hܒxw~ʳ%-L9w1fp~[$b".`h\T!VUoCP9& $u/p=$TΘ»qg0*di~tVmG/ I4/Qջ$f $TU=$0w{ͭ7QƍYӈuk^{qHr "T+|I!&eޱuaX r~xm#8?qj5.Bd46.Žpt6%KU wHr}YOfɿB&rQ`7;qt)׎Swqyg~3dȐ cBk\4&=m\@0b <ĵ՛;wWA莲.)* ofH UJt9E@~q[jv 0t?WYVD^ov24ïA-OpUDb!_PY|L{X||EjE)DG̭ n] չ#0 []u0;|o6i~QֻW3Sv WyD堻0#2b4A }z5XP*1HG 4`0F`m(!i71nƋj9K\SqYv 2>[b\`}v=D1"8bh%:߰`E=ߥ&Z%EU0P8^Ђ+ZE(apG(.g:E[p MhI%s;%|%d dEYRCj/ƅ+Rɻ#R[$mb }u."eQE"*,JU ]a֤(u|:fPԭMa$/,OڵdQ?BU]TXV: ܬ=s9~2t5`Z.aEKG(#@Qު=)b2öנkܜVDq ujGk7qXX,\Kh8ø#$-]:.D(C=! u(>Tڿ)^-,cʕ!2ѥ o < Xd&d!Q)dc[HT=*>vmŶA.[k\`٫E~vgR󸆣tYRQE(=.[!Gv 2GWw[wI%Դa -48(ΛoOkPN#j=Ae[Vv\mиR/U~p`>ee|كDaI,u˜1CX:s<J^e.@!-}uUDUr yN [& Xo\3dk^aWlatOL߻D[Qʖy<z`l:;g"~ن$?Ϳ'4gQVIY$Ks<j\.RO=zrƆ>JMuߦ c>>&Ĺ_7lVnm_lUU}ta͵;2E!(л<*ok{ l5HNr f{>}<G QqyP.'ٝ{]A!2>z_@z;x-kofwM@D56m\?ף7VLIENDB`
PNG  IHDRm&pgAMA a cHRMz&u0`:pQ< pHYs%%IR$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@IDATxT3`'v *bɫ1ȂQh4Fd1ZAXSLb$1Ƽ-*%l)gvgv- g?w{O?O?9uv#q6^ۧ:yD@M8>݇Kw Mz7]5p^CBN?Z2BwFp],vB{@+j 4_YSYΩӫ%rC\/2Xb8>| ?9X2p8x縺4ZčNkk+wx?çbNG]-[ D6^1^nqv=g]or`3W 8唸?[r?>dl1~&@ uTg{a.Kq@,9'@q 5d<i_ۮ{؅ /IĘ^o3sB}?C‘F &|%yaϣ\8476yw*_%ޅ VDk߂+Ş~*Ɯhk+%/}@KYÕ|xHlkijy◵ۮ<#zmDj#ۮtж3R+p_ CSѻq۳(B564nB'f_r%okT" [z`{ZtG1nFtSCZbGj0!J" X_ߟ>rUTf7Qolv!W_ ^9ؕ~cm}C~ɕU^Sc4(|"LЗQ"p=q/tԔỸIھ̶V q3<ǿWM2#ޑVTU@ߝ>rJ(dĉjۮ@t]*Pn^1F,Rejiim1)vԯB1(~HeuӸ/ ?_ȵk1û$Y`oh»w) )ɐ;2bWEUeݸlԤ`+u^gwndu߅ [Xe6nc]7tOU8u 3 LQ,]e+cE7ٙLa }Ċcƻ|x Ձ d)c ,RQYV̝r/)wʰ$=97̫Xzhk v2ȐV67>mjNv!l#QBpѸ̷=MͼIu^66j(%ŭAB~s/z~fqxai1DN<N4/TyBQiƏjrX < 5mq) I-Q{YX3q4kώͩ?Tz *$9yb0ܪ <ڍsg蝂ڶ"lWTWpڙ}Q^jTO:z?+K/x`AUS3Cd yf@ uiQTHL¾>)$GWB)y bBLiSϙ]UN W)֚7kvkub0Q_y@ VUR] 1gVS߽YkL%u?uJ?-ZEW4]=臽aӿ<q5n;}[w͛X^Y~^8u֪1Poᲈ<}V`z<x>^]q3U DttØ?r*HqbyeE_x-MJ*'wُ6F9Ab\W )U :z17T(U#P@Q&eeea,^)VN߿edz`wb\g@GɬϹsQ7tSxXҗҷ MMӦ4){di$4ά{iuhՊ j2EOnW&eD;';`6y"`⟍HʫЙ9sL䓝5{| yEXThqMuڞ$; X @aasS}`0"ki{c&k/  cû륻^9D¿Qhr\BrT474rI_P Pӕ8v:Y?[g8&~Vc*%B& te5_}N"V:OzȳkWj,S]7Z(v-6_e^eԑzbRH1cM҆׫޹%SE:2674`)Tĵ~ߧOvxM0J2 ''7N]'BcrTb_)3nˆou&- bǍus#L Rr <8CXNyL\]ӀXj"ñ~soxsSӽC23 :ͬۤ@p7׻~ GYz<qvХ(`TMxg^:r5#ܖh*oE7VF|իW{Gq_rDjj.%/_K=A&x?m}>|sO*t8RrHĉ<ŤX_P|gf?})qElf2|k8\y_B 6.\h,$m={vybol0J2'0zCEpLz4X#3+08!<7mwrI<1ms DU49i&~}(f͏@^~|w:ME6z=x,_nɸ&/lf>{D$}$5Hqcڵ<>iC=!1WLC<:{O&џ`QbJ lQ4HƏs E7KFB<0 ~:_ȫ-]>黐3Nd9 w: ~RcE[ϜV3~KTz,A An# u{DI /sDDlo (.;v(*zى8! aSD.y^wے%w.(%)kX[71>avnTnqF Eo"M+L16WW\fpj)Z+- 191_!W!2a1^^^>ƻ>Pdzt*Co<Ң4>c ? G"@\aI/6rc :fEJ}-Ҭ~KOQ"KnwX=mX *a<m<!p"u.^beR< ;WD>խ3U(bD`xEEP Ɲ) DT>Jq9/E@x p7BD<nq7YeB3ۑFӂ S=4oi<Br6b*Ҥ!ǑC(+;%J:E@I{ر@"Z:qߣ&I(;)!߼2i4?M,λ%OP 2}~/Zb:\B땴!mp,f3EDAh׏ kF5C)6^ D(CJaJfcIF=PϙS\"3-?"(.+2eP؍u> Awжv\ѢE!jɒX+LyRy)32* VEE|OġҖk Gpa鸶9%_ ĭ;!ǻrV\bcҺ1|B 8 bVqCm(IwCPC4hQB'46e`030̸~,p}W"D \Ixt\4f́ B,Pܓq[.ƽx<A}Ӓe4;1A'~ht/=A~w1`"OTWcBJ<7-pEnb'X(u6APT} n}ɜyv\DZEb̭3.:(~+; wX= A\LR-T@FsH&dPe%Wȹ瞻eA( e feRDE-pA0^]m.AY{=Ԭ0֭+H=gRav<aGg!eq@f)(D.@Y#6mCzהt"nU:r)8.fI,y~~l9(Y=x)AIjVB!a]YG; +! l' 0 l""Ա };CN@B9ܫ ;ƇU.ˉ!w=(\J*c{w?(չ~ZZYm$L $lHĚOȆ!̱p86`#mOu]\ N !I8bq ӭ.븸؛]@5cZ3«xu%>9bU^qq2>}J\ǁ6rkcN y~?<xpayT`GQb>+EjғfṇοA*:/ ?n`+ii1 ?y-pn[GfӶQs$uQac(z>I ԾHX1Y8#'.,M=zo"7Gqn$)%D܏]]$A6mԮ7Qy{)KM?#$uУRCf5 0/EH֐OBu3@v8 <rpֲg&\KwB4VDT枔ǞE݊q&QI/Ff3i2`; `*w{ 5gOv R{;!Ї<A$Lq ,v n,ļX8#[XP$~r !'!Ev/NB2٭^L)̈ G$Y0I$6le*'=&ܤ{ab2F]q1|w̯PŜڋB_UQ$|!o+1kID7i%%`MHwO=Ac&^+0ne_֫ӡD BBiAyD@t0RYq0=)}=U`QE5բtzy ֲ/-T@HK{y4Kmy WؚdGJBfVu_Hs3?.u WuZ7?H$G!뽑r( Jk`y3Q[~3Ƽ,mnosqʶ`z=,ҷ9E,BPTnBzesB;=Z* GLZ#x7Hc3dHyQCr *o/6,ɉ[SZgmL5n,b8掊`GM>(n dny=XT82j4o7 7ˎ sUv}a 4Cg5iYyUE V9iF0n@F3c9֑ϯ ֭᪚(0"a \Mѝ给v"_Sn{N%Fs\ B:x:nPIVD_ڗ,/~Ḿ3#] A,:.S=\ ۇ M=o=9S#$ЉLmZ3簽Ojm& jԿ%QiE#rl[ 6jJ6'X 2 Dr?aⳈ-,=*+91#iǸx.M ?e9c3m;=I}Ƭo0FX9$Ӫ+u N@Q6`ܸee(s();aT<ڌ"BZl! N҂`3$Sm{|f IG>8=3φ~oPIR9P z%nxc$"vw>/yU\*ӎֳEJ0%ĜC@r}$(D#u$ _-{R ccZȉRnlPcCY=r}~[oMoK;:ïuj-CC$6n[.bt<'S~ `7n boK90J(eʧwc5IcI}^?YŬ 7٪Fyrю.\&ͧkޏ[Ի16s<>G{vاf՚~wǐqcCulߐ`]9ڱPqFZKϻ[Fz#[^QQ^c27ݶBU%r͹mK2Gpi㨥_ImȢDyiG~XBrFACΪխ\-JK^7~=+A8"5gX9qO҆>"zD6ڙ/ o\6`iLbji{K8rM Ac0Ϳ;lNR r$^ 堛ĝbBP Պ rH)Xl]pRzkIȡHA18u^^a IkTqC < 8qh%7I0hɒXFFI@dv!괕 H.3dgmR"*fC{pS}c?릻^D>aeS%sI/[VpݡZ܄\H#z &@ tVR}L]:Q%fKA2|g&.\G$K,yk,?e e+eQ(kZbPuM~rN$μ̱WW_@DN!?Gs,tE=_WbVݼUU8$ہF[6ou:j(U'‰ I<q>P>LTWf8qD|YxoYK @V4'Ka7g\d4-EZZU;pp3G%wKEr@c4ྉr&4h^:/2 .ōGf9r2WtTdF̉܇N-fN$y鮍ivI%R'Qq*]e+J{('$lwk20lҥ넨\Ś}7| 8p8\@dz5=95_1y30ֈrWu$+MjPK5"oڝ-;%1 Z҃l&io$ݰV[5%"⢸G7ܩ#/~Du̙65&3 8UJ!<?U ..˶;zin̩"mjlla1DbEinluw?Z1;h,\T9=AGU\˟瓯6؆eT#J5NaB/&L:lWWm%w['A{8 r*+A;Gιgxm*]*F<z(<`鉺Mm{ J\O'mi 8"׉Gͪ`V݂k " qS-.yn׈S䡓slrַG]k0{4% ֌5{i{ۜ8"?sߜ={v.Ktۯ_?#VU44̆D4YI|,V⧵B>)%'nX$tս.jP:o`')8MMHiL}oDqG,ZJH#`.v](ai8&;۝jZ)i~>ZQKNq#Ɗ##eaM[y] ;h,8 s֦ 2y]Ά nZylL@J duvQ]%z>;~]s+3%.b5̈QKadξ/ c~=]L˦m7ᱛ;"R^VS1 wUP[+*uy8 م#܎= `t~#gvUݳq;*i~B[ݴ\QQYORPf[L{f&䐲.m6DP9NRq<\MTYm*3iDR_麪^UBV ~0Q M.1.ei/(䡖ryb}Rfʥ^==N vi5Ekynd~I(aHZ<dٌ]֍b=š{}ޭzaÆ.5iS#:# u~0`D-+r⿮3e(R YxE~7i{ _O2 W^M[wlvziٿ]g ]с6.$ɑұ;kuEd)oBD/a~PJŮPdSOCFh+cd͝vںT>P_̾Rg6)CZrV(R+| bܱ,^VABvReſLXْ QW{)$ٞ ȒbeXJ+ x*f35FN|EU!.c]Pb1f <8+a9f)sTUPx ᡣ <6/މ;杗2P,)ET3 6$ 8q"l=w(քuJNBSi _L:`2ebUZsƟ|0oQ IžƧ-ZcV_>& =Ht޽{af~}kt``YJ_#;pjO_omDOHBhPMĚZUF--r&B&$ɩ5NN&Gw8QTuך<|Ó++r!\sU˄\S@͆:  <׉o\Vs[s,6Rل2HdDӖVgoذa'|RiԢH FZz9|PݺI,rX7¡ij-F[FeJm_ipY.(~@T4Q iZ.9{8Qʷ0`AL@FiϩDYAF&t3yeo޼tn%K%mnKL-r~"ey*2nP[y{կkIB3H>+WTh)n\ lvfׯWVyC'1-3`z`0AYʵA7,ㅺ`KR{\ǭvO$@8"vc\H[w,$E?G++mN/d~/}[ VqfwtX͉n)qȡ/ʵyK Z2\Xus0ku%y$t|YSs5B1f!Ǐ?}ݝ, r0N0 dv7V\~Oaʘ=4ǣr +Kİfe a)ߍ14Х(СCw&T$NU}!|ӄWV[wgzZIdKuo`XJ#tU%3KA;]O vmGaɖW3ˮ՟_ |&DdVYX#A[K[{7+-KK-O9BG tqiv^b(QYD 4K9gC҇6yu鐃sF_Dk?NLXTBFēfaѸt thFNy=v>HtլT4O߸(ߟg=BO/GŶTQ7z6,d!ͺkޑ8 .[iY4 #$*835SFeޕ~Ү<lvM@)՝( DC"qS<r`EVʉB,vсۏ`ePh*܂&ޠ  /C|`շ"D9?XJK"Z1psC 7=UnQTsLl'ol\\J4yc <$GC@ %>SM@D(j[$sKHY<r/O|e(@.ȨC_aUșSޥ DŽ{TߤN̥^UC%R̵QDg K]e{f&i[IT,I>ID4Vq<:ǎRU4MW<T*[!s8Fe+׬(iͬ7ݳdw7d$RvhkkKv{7swO צ_2yNf(nJ,̔ -|4!JRhM 9$R9hCW\C:l"a,( x!(THL<kՙPRp9zfbjF+9<H<. 6䉬9^x_}mU ~\Q!I["JV*v 9O[" rc(IxԲ|GiXDKe0\D\W 4b$PȢ'Ep0FNvI VxkM8a6 @5h4<*-!J)(ϴ(|)=#tŁ|tVT1^1M/Z%T{JsHߥQ9dW6ZSKL8␢SA-W.I?x숁OTlj|sx*NA:֝ȃ>Fqs''LmnlEq%pJsF_<vҋg@; ).rw3l*(Ɉ Y~wXTS2|1CY^ԓKէ_w!CnDʫsg?هΌc$D!t%Sϙ0ue#"7E^%^k^v׵eA Ir:'@hI2tLRq{ùrkBs`^ VU!™Bַ`ƂVyL~w lԱDM(AU ^sHY8z ƃUt5vTBI |H<^h ܬ5_93Qy磊"s&8wWAyWxQGN~аvɶ--j2ZѣI:Ek!lZ9Vz HRdvNT<dGG9!)梘#:Jܮ>s(!,a>j<ݑCrMOTJ.씟 5FlD<˥,: eeDzBRH"=<RmpG"묾_rƼnW9?x<kPh,?pT.pF|$,@4f3 A$m| Y7"Y0@?atC ,QE['9XTCuHt;8;9;'>VF5u6UYin#J71pyux I[Q (o)KGM)rviJ:,5yEg&0Rj!Xl FF>Qͭ u }~^ŔFi "dAq]>qxU!JU%Za!_|8-NFN%Cp&:7t*OYgB5UUU{p:HJ ż5Ow VX|㸠,@ PRds\<; Yy>?g~s_AyMK<?dJOI`Zq%uhUBW;IqHY.Ik}ou\㏯{OJhJS&YKjFd!?7V]npӊÑaUd) d|Q &C-MMrb̒~- < `jJH 1f }(vUT<-RIsP͘1Cqܦѫ$!ΗvmӘ;nY$nm 'H Y6AFI:99Ќifo/Z2i~TԴA!,h^gd[mvsZ8%^U)飦|Ne& k恷u)$7oE2rWp4CC:U~}^xA }ҟ ];xd0{j:馋ƌ90ypǙW|}a/^: mn'bوG 8 ԟ.A8AلR!?{# :wT``9:L<{OG1T*}Iĭn¹JΈY̎|}Zd 7֟l8 oQ2 qm\F+I_!\p|pKKHbuLyNkK\Nlֽu ~ƀ fgҸGzb!/b9L Aǔa0b)h#CtCԞCjHM:̤ൈV߱b\>ۑjPg^@wC@osc]PwLR!E6#Z<!(w T~Ll`A(JH%KFR28ap*AG |&BURT"xk,+Cup Q|R@k1-5"a):r4$,8OUa< E" @g% n2.Zŵ#fF!Mg?ـbu޳ E4\ʾ |F /4rPQPJ:Iqv>+ (`o<n8;Kk,YkFՎ|])<lߣۖk .7#'=Ƥ?bbee}X$L󟊫8蓢ydxV1xavMRdk^v3 8J_XKW)Je`vDS"$) q5[G/)2!'Ik XY|űd ,GfZHu%W*2JuP=Ee:o7vpxiߘH[bpYA(K/$KNb#v'1If 3a%/$E =F:UK!^34g[j8 PJxRۚSE49սw',-6cBHİNyI)2[LG-qk߭qvå#ޏMY&M%V[CL'mvFo;3Ľ&^2$!$pAUVl=At}>7!\;kge ;."fw®Y" /_PBъ*)MOtcO2 8#KјVl^Gy='CO\ zGy++{gmB I [0jzK,!dVA[fCs=b%sieeu5UC{.Hm%a<'CWM#lyfe:#HXt GJ$ ՛Cj{'p!5nh_G|7ŬYߦis fU s,pWuH*PWQn_8~,=NLcDbȐ!{Sg^b6 Q 'AC\*5XYr=ܸjwtM*9Vaec7rWuO#?|ӵ%T-*}-I-,3f<=*nxq=?%(d|@l7dEEyy 9"|:cѬ$UE:\i*^*䐷̆1zpE!:B1BEj>.B8Nz&˰Sz_-aBtxb`J*1],ꕐ'30$ nAFWj|tO3! Bջ"~qLA8nN9^96]<Ѽ\$WpeEA~.M: ?qdyKȟwF*2tEҌoy3bD$G#-w'[?"|)Dc!@>"4UJoA0Đ{hnfo ")m96 <*ޯ╙A[N QXJ"S"ǭ?X4U671!#%I%.݃mudAu98T /Ү5 FL*qFLB‘5l8-e|}3Ǘv<+fmhǏO@Ah+VHHE@_3 -BQ!2ʈvS[q o*{ 9u6VȡvpF*<JͶO7 j14pVd*ud񢈸W_o!@6Hq_[`%B飑&\)땀BԾ`VyRt@V]Lm3eqwTP vſ͑rF 9UVΈ.:.vɾY:d=U!ŜNY3EVƊymk^D08\|Qِm~KҊJiN"¯:wN NZ!A#NA2R`禺yߪlZt#c)stĤ`RTE[UQXw6O,-Xtҭhm22$,2HJRf°@C(9 Cz*vAfxM솻MܫVqboWN/v^MM#51C?R^E҈t6L%I;Lo{,۾o[3à- D1/W* mK{Y?{ Vl^\>X cnrli:{/k=~9~$ @=U3A;Z;;5ewp ae$RV${.pDYKUU?l%i2Yzۖ}ߊcLKhoh7-lĮ'T]c }V҈,XE#^%cBqe2rt`-g ~H, uaEpvX.$oVMB(u[Bz8 *q`xspڻe%V"QYl}w]+[Z'{g4Yu@t-jjMxh̦ a2@է|9΀<ļx v}A\22lҲAKpX "Qg31Yyp7LqMH@5{r9FJ`کA1k@u/w~=ʖIm)MAK@akw,ĶO(LپN, *u}|&SP>(Hn;﬒ 4s5q9RjZs4֢~F*# ųxrcA87r<98s[,=Ru{bAtہ,46#=eޤx%N_}F$iWxYm畲޽_kW[OW6elnCC`B3IDAT]L%<} !]Xٝ,k8ȌK f 6A{ט=dsai!H2Oc"vlmM4c*Jھbtt =frH3YwԮ}Ŭ GI  r^6AZufDq :dt6WsH,aFВNnEQNY;90!OǶCʹWF&H$ɉz w3H**'`K9k7 ļ/f0 7澪m62[] AvCkG9d:ml^{aMDG=RX2k[ \lV^KOn)M;?DzQ9?Vvq1=hU@taX54̢PC 5֝1fR o4~=$CՐ)ec*qmŽ;rUTfkEbl\r R۱dJ (E]`&3:h-K0Hlz v},$fat\>}TbʴUɣa\ ?ߴ}XD%@͂j1rz׋~1/Sc,vjЮmz xJpzQkLʊeԚ =n֢ͼێ VlFLHƼ/El㽬 l2lY0qIҊl;Fv{P HDqv-lWp^] [h *hA8XrpɕŕW%3GЫjkjŮe9#XE|"xn~ %g<*  h:b#$5 @5غ^uJ]/J, %7AvqT0tp\Msfғ!*3'ޖ&L*=qdO̅1آ yD\A8jnhjNB*ADf;JV]K{@ڑ\JKT&Ct3z=JxJ)i2KpyoInІ"QVΣ}jթZNmH ڏG R=6r5q27}=~=};Jgd|Y$h}rjS9}].J4PY$#1wa%y)J1MI1˭Աp丽D.@[541h{gS,HrϺ?5v~(^j 祏ZFܮNW]|+}a C;eE/r"lʨ6#ſOLVcqL;7Ȝay[x^sem7k^d ԏZ}7z;\ooKunH"bۯ".Rf{WD"e\Іvp5z[4! Sh2ԹdL574|W\,_zsAPڋ]Kc5SD""IJ_m?ou*V,ZtL\QyM,HTB{$"LeieeBv";Llk98d$C`3ӱo▗nj0'JBg}fͪh*/(J.RFga|${o/UeL9Mbr pqQYOct"A} h;ϋP>.jO޽pE>mkʁ!!϶Syc3f{t06g.oqfH0C2&#q/t୓~dڵFTeAbj{f{}u_߼"S,RyZzU7lnkatko]!YjL1>'Q9B kY:HX^G|@P$t]-Z!W.*9X(`Y{RB"n?m9r`r/6\<&)g)Wܼbw<Qۤ)4(77zgM<5fnmF5'uOGр"I r"ɝWy)@;v]IZ{s&c#u_{D Dv[ث3>h:L Ky5Իv:^"5`@ՈLidBۏ۴Foe:߇AT(Vݫ g-ܧoG.d(,ʃ<d+ra(`{a{~͚[藉~qy *}GVӟ]) }4ܣ[ᨭtAϪiVDPTIllBۙBh3#Pɪed)c96gsyeCHbI;* Ua߆#ONLÇ9(WN" 3#+^ NܵeW(cF}rlM!: 1DU8C㋗O $|NpYr3b2e|i^&w2c{Ro ]Akq{5)E1 Wk~mC:L9y&F}sAMv>Զ:3s$h?Y}#6l飦~Ymwo[} =p) |/f ` v)})Q{lB<+a?DC0,g3#J"g 1~k͛? /s( -MMTðD>sw NT ]Ƅl;@ j|Oo0)}L2֓ǯƺ+De%켾f@0+gCA|?7e NqJ~޴)21 K`S8C0~g;$+k[RNW~{Y^ONB>y T-ڡ|}Z+,S+Q]!JVvߙ.CiopܸU+(;E3[3h,EK|RMvSy tHE+$hW)e`(3kVywk=ڎqN!yx4 :t^u׌Sk<B II%l`Op9p l-aDyA?BU7?,"=wNe+4r&<FqDTw%0w߷[ @,};v ^nHLCEB $d5[:4/l4(@v*[/`Nȗ34k͛<|Ľdi֝jnjf'zH0 tw@ޛԸk1>s'-y96̶n5G:8BE%YN+Eg5\dN?PQ(C1;$3}x~+t LE G8<!Jeɵw8x~O< PDVmaXx7JRVYYlg>9`Ɍ "R̃O TXIA9lr$P}p+VV9^VvK:+őqeF>⋛(CB^bE$خ1cl>|Dp -[Hʥ ;ⰶ*qCV@(0#фcwLjin.FHsKKKgf Al%۟8*()T]xSe9$PP 5{qH#^sE|~AJoU!|e8JA$7!<CzYǎ -F(ba\K)z f1ИE0 K'%^0nܬHRS004-2! #2.ؔ腷߾1#i EcRl! I$7% I`$.[(qKBˠl2 =U6$'Q:"V߹PlJ=m\KaU>laeiUdqCiOa$$Eqw!Ext jrbGrX+N)OVLݸ9ptb([BL2VKQ#B#SYH,LzEG }@!坽&\{GގB~!)֊9! =_ȡx.Un)g'F<swXo0BTxVEĻYHA V0uYi<ү3}mZS S@Deem}bzx{Poҡ4vqۗu#&?^ I*Pͩp"mU AumE)Ōlz]nNOMOXs4U vW&3b \x %KQh. fȅ*d\pC[[Z2GN D#^ZLo7u(D߰%xNEkǞs =DʋbXZLt ,}xm^kÕPw9ـв ib =5ktfQ:Q^Fڳ -ý7ĩ3ɒ: M9o dK1&fE ͐kbu~iJ;[t駃ʨo";#J&?ȼ 1Io&E Mcн@k;8NiQͣ¦]-epϲf稣i{mQ:}cڴR(ꗭ[W:`m^,) Q9U]lYPGx6e5hջz4mD*q%Z+ȬK-pa?Ylu-6Ä+S}̾1tr)2չbf :掖x|ǹmx_2h,@tasB !8f&cyآ3hs7KG.O *ɝ (+]a\L=[c1pm0Y0L*.;3N"2_OB' BZcc| |k:YDSw)xtiX_ *J/ qGРQ&#[L1/? %JZ~~,68FF^TC@a^ O~ 0wDkp)',re1 m1c` PE$0 XAT{dy2^5MLT~"( b0Ucùe\ bVINI;fwU\B4uf |k=ux&IDZ<:p~\rPz^95ANZ\D0} +w gU<1~>c\|n~CJPt=}4}4"oE͡$"/kތÞHڵXl(cH :t%ꪱRYo@r3iElZW1? AD:M*"*LzݵÇ%Y(wTxA'.~wu|E)2m* wk< DlWOu}1BQԗ1gRFGQ kz.^Fd^B6 4͂.^+vThZ~7z/{{ck " )JB<ӖCQʣ+J&2͓ ?nݺąMT=՞cʆ}xi:vg4u8n1ϫ w؝_ '`KJhlp<Ob"hٲ;nN% A >nZ'b)3]$ KAcM>jV":C HLO[ N햏,}vSSo]Tl*[ @L2&uGh%蝾)5Vrwx~ ǕlZ!QԲٖh,$HYlPh _ӯfWVDZMƭ?XѪrAN gz6O0qVHbkf@KuJ{ϦQAv3jmK~+@N*sq{BIY4N@\@D~Ⱥ4Cim'O'{8ɱ>.sTTT99W?k ʴ < Hܒxw~ʳ%-L9w1fp~[$b".`h\T!VUoCP9& $u/p=$TΘ»qg0*di~tVmG/ I4/Qջ$f $TU=$0w{ͭ7QƍYӈuk^{qHr "T+|I!&eޱuaX r~xm#8?qj5.Bd46.Žpt6%KU wHr}YOfɿB&rQ`7;qt)׎Swqyg~3dȐ cBk\4&=m\@0b <ĵ՛;wWA莲.)* ofH UJt9E@~q[jv 0t?WYVD^ov24ïA-OpUDb!_PY|L{X||EjE)DG̭ n] չ#0 []u0;|o6i~QֻW3Sv WyD堻0#2b4A }z5XP*1HG 4`0F`m(!i71nƋj9K\SqYv 2>[b\`}v=D1"8bh%:߰`E=ߥ&Z%EU0P8^Ђ+ZE(apG(.g:E[p MhI%s;%|%d dEYRCj/ƅ+Rɻ#R[$mb }u."eQE"*,JU ]a֤(u|:fPԭMa$/,OڵdQ?BU]TXV: ܬ=s9~2t5`Z.aEKG(#@Qު=)b2öנkܜVDq ujGk7qXX,\Kh8ø#$-]:.D(C=! u(>Tڿ)^-,cʕ!2ѥ o < Xd&d!Q)dc[HT=*>vmŶA.[k\`٫E~vgR󸆣tYRQE(=.[!Gv 2GWw[wI%Դa -48(ΛoOkPN#j=Ae[Vv\mиR/U~p`>ee|كDaI,u˜1CX:s<J^e.@!-}uUDUr yN [& Xo\3dk^aWlatOL߻D[Qʖy<z`l:;g"~ن$?Ϳ'4gQVIY$Ks<j\.RO=zrƆ>JMuߦ c>>&Ĺ_7lVnm_lUU}ta͵;2E!(л<*ok{ l5HNr f{>}<G QqyP.'ٝ{]A!2>z_@z;x-kofwM@D56m\?ף7VLIENDB`
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/config/application-ldap-activedirectory-sample.yml
# # 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. # # ldap sample for active directory, need to rename this file to application-ldap.yml to make it effective spring: ldap: base: "dc=example,dc=com" username: "admin" # 配置管理员账号,用于搜索、匹配用户 password: "password" searchFilter: "(sAMAccountName={0})" # 用户过滤器,登录的时候用这个过滤器来搜索用户 urls: - "ldap://1.1.1.1:389" ldap: mapping: # 配置 ldap 属性 objectClass: "user" # ldap 用户 objectClass 配置 loginId: "sAMAccountName" # ldap 用户惟一 id,用来作为登录的 id userDisplayName: "cn" # ldap 用户名,用来作为显示名 email: "userPrincipalName" # ldap 邮箱属性 # filter: # 可选项,配置过滤,目前只支持 memberOf # memberOf: "CN=ServiceDEV,OU=test,DC=example,DC=com|CN=WebDEV,OU=test,DC=example,DC=com" # 只允许 memberOf 属性为 ServiceDEV 和 WebDEV 的用户访问
# # 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. # # ldap sample for active directory, need to rename this file to application-ldap.yml to make it effective spring: ldap: base: "dc=example,dc=com" username: "admin" # 配置管理员账号,用于搜索、匹配用户 password: "password" searchFilter: "(sAMAccountName={0})" # 用户过滤器,登录的时候用这个过滤器来搜索用户 urls: - "ldap://1.1.1.1:389" ldap: mapping: # 配置 ldap 属性 objectClass: "user" # ldap 用户 objectClass 配置 loginId: "sAMAccountName" # ldap 用户惟一 id,用来作为登录的 id userDisplayName: "cn" # ldap 用户名,用来作为显示名 email: "userPrincipalName" # ldap 邮箱属性 # filter: # 可选项,配置过滤,目前只支持 memberOf # memberOf: "CN=ServiceDEV,OU=test,DC=example,DC=com|CN=WebDEV,OU=test,DC=example,DC=com" # 只允许 memberOf 属性为 ServiceDEV 和 WebDEV 的用户访问
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.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.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.message.MessageSender; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.ConfigConsts; import com.google.common.collect.Maps; import com.google.gson.Gson; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.Collections; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @Service public class NamespaceService { private static final Gson GSON = new Gson(); private final NamespaceRepository namespaceRepository; private final AuditService auditService; private final AppNamespaceService appNamespaceService; private final ItemService itemService; private final CommitService commitService; private final ReleaseService releaseService; private final ClusterService clusterService; private final NamespaceBranchService namespaceBranchService; private final ReleaseHistoryService releaseHistoryService; private final NamespaceLockService namespaceLockService; private final InstanceService instanceService; private final MessageSender messageSender; public NamespaceService( final ReleaseHistoryService releaseHistoryService, final NamespaceRepository namespaceRepository, final AuditService auditService, final @Lazy AppNamespaceService appNamespaceService, final MessageSender messageSender, final @Lazy ItemService itemService, final CommitService commitService, final @Lazy ReleaseService releaseService, final @Lazy ClusterService clusterService, final @Lazy NamespaceBranchService namespaceBranchService, final NamespaceLockService namespaceLockService, final InstanceService instanceService) { this.releaseHistoryService = releaseHistoryService; this.namespaceRepository = namespaceRepository; this.auditService = auditService; this.appNamespaceService = appNamespaceService; this.messageSender = messageSender; this.itemService = itemService; this.commitService = commitService; this.releaseService = releaseService; this.clusterService = clusterService; this.namespaceBranchService = namespaceBranchService; this.namespaceLockService = namespaceLockService; this.instanceService = instanceService; } public Namespace findOne(Long namespaceId) { return namespaceRepository.findById(namespaceId).orElse(null); } public Namespace findOne(String appId, String clusterName, String namespaceName) { return namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName, namespaceName); } public Namespace findPublicNamespaceForAssociatedNamespace(String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (appNamespace == null) { throw new BadRequestException("namespace not exist"); } String appId = appNamespace.getAppId(); Namespace namespace = findOne(appId, clusterName, namespaceName); //default cluster's namespace if (Objects.equals(clusterName, ConfigConsts.CLUSTER_NAME_DEFAULT)) { return namespace; } //custom cluster's namespace not exist. //return default cluster's namespace if (namespace == null) { return findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); } //custom cluster's namespace exist and has published. //return custom cluster's namespace Release latestActiveRelease = releaseService.findLatestActiveRelease(namespace); if (latestActiveRelease != null) { return namespace; } Namespace defaultNamespace = findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); //custom cluster's namespace exist but never published. //and default cluster's namespace not exist. //return custom cluster's namespace if (defaultNamespace == null) { return namespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist and has published. //return default cluster's namespace Release defaultNamespaceLatestActiveRelease = releaseService.findLatestActiveRelease(defaultNamespace); if (defaultNamespaceLatestActiveRelease != null) { return defaultNamespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist but never published. //return custom cluster's namespace return namespace; } public List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", namespaceName)); } List<Namespace> namespaces = namespaceRepository.findByNamespaceName(namespaceName, page); return filterChildNamespace(namespaces); } private List<Namespace> filterChildNamespace(List<Namespace> namespaces) { List<Namespace> result = new LinkedList<>(); if (CollectionUtils.isEmpty(namespaces)) { return result; } for (Namespace namespace : namespaces) { if (!isChildNamespace(namespace)) { result.add(namespace); } } return result; } public int countPublicAppNamespaceAssociatedNamespaces(String publicNamespaceName) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(publicNamespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", publicNamespaceName)); } return namespaceRepository.countByNamespaceNameAndAppIdNot(publicNamespaceName, publicAppNamespace.getAppId()); } public List<Namespace> findNamespaces(String appId, String clusterName) { List<Namespace> namespaces = namespaceRepository.findByAppIdAndClusterNameOrderByIdAsc(appId, clusterName); if (namespaces == null) { return Collections.emptyList(); } return namespaces; } public List<Namespace> findByAppIdAndNamespaceName(String appId, String namespaceName) { return namespaceRepository.findByAppIdAndNamespaceNameOrderByIdAsc(appId, namespaceName); } public Namespace findChildNamespace(String appId, String parentClusterName, String namespaceName) { List<Namespace> namespaces = findByAppIdAndNamespaceName(appId, namespaceName); if (CollectionUtils.isEmpty(namespaces) || namespaces.size() == 1) { return null; } List<Cluster> childClusters = clusterService.findChildClusters(appId, parentClusterName); if (CollectionUtils.isEmpty(childClusters)) { return null; } Set<String> childClusterNames = childClusters.stream().map(Cluster::getName).collect(Collectors.toSet()); //the child namespace is the intersection of the child clusters and child namespaces for (Namespace namespace : namespaces) { if (childClusterNames.contains(namespace.getClusterName())) { return namespace; } } return null; } public Namespace findChildNamespace(Namespace parentNamespace) { String appId = parentNamespace.getAppId(); String parentClusterName = parentNamespace.getClusterName(); String namespaceName = parentNamespace.getNamespaceName(); return findChildNamespace(appId, parentClusterName, namespaceName); } public Namespace findParentNamespace(String appId, String clusterName, String namespaceName) { return findParentNamespace(new Namespace(appId, clusterName, namespaceName)); } public Namespace findParentNamespace(Namespace namespace) { String appId = namespace.getAppId(); String namespaceName = namespace.getNamespaceName(); Cluster cluster = clusterService.findOne(appId, namespace.getClusterName()); if (cluster != null && cluster.getParentClusterId() > 0) { Cluster parentCluster = clusterService.findOne(cluster.getParentClusterId()); return findOne(appId, parentCluster.getName(), namespaceName); } return null; } public boolean isChildNamespace(String appId, String clusterName, String namespaceName) { return isChildNamespace(new Namespace(appId, clusterName, namespaceName)); } public boolean isChildNamespace(Namespace namespace) { return findParentNamespace(namespace) != null; } public boolean isNamespaceUnique(String appId, String cluster, String namespace) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(cluster, "Cluster must not be null"); Objects.requireNonNull(namespace, "Namespace must not be null"); return Objects.isNull( namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace)); } @Transactional public void deleteByAppIdAndClusterName(String appId, String clusterName, String operator) { List<Namespace> toDeleteNamespaces = findNamespaces(appId, clusterName); for (Namespace namespace : toDeleteNamespaces) { deleteNamespace(namespace, operator); } } @Transactional public Namespace deleteNamespace(Namespace namespace, String operator) { String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); itemService.batchDelete(namespace.getId(), operator); commitService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); // Child namespace releases should retain as long as the parent namespace exists, because parent namespaces' release // histories need them if (!isChildNamespace(namespace)) { releaseService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); } //delete child namespace Namespace childNamespace = findChildNamespace(namespace); if (childNamespace != null) { namespaceBranchService.deleteBranch(appId, clusterName, namespaceName, childNamespace.getClusterName(), NamespaceBranchStatus.DELETED, operator); //delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases releaseService.batchDelete(appId, childNamespace.getClusterName(), namespaceName, operator); } releaseHistoryService.batchDelete(appId, clusterName, namespaceName, operator); instanceService.batchDeleteInstanceConfig(appId, clusterName, namespaceName); namespaceLockService.unlock(namespace.getId()); namespace.setDeleted(true); namespace.setDataChangeLastModifiedBy(operator); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.DELETE, operator); Namespace deleted = namespaceRepository.save(namespace); //Publish release message to do some clean up in config service, such as updating the cache messageSender.sendMessage(ReleaseMessageKeyGenerator.generate(appId, clusterName, namespaceName), Topics.APOLLO_RELEASE_TOPIC); return deleted; } @Transactional public Namespace save(Namespace entity) { if (!isNamespaceUnique(entity.getAppId(), entity.getClusterName(), entity.getNamespaceName())) { throw new ServiceException("namespace not unique"); } entity.setId(0);//protection Namespace namespace = namespaceRepository.save(entity); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.INSERT, namespace.getDataChangeCreatedBy()); return namespace; } @Transactional public Namespace update(Namespace namespace) { Namespace managedNamespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName( namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); BeanUtils.copyEntityProperties(namespace, managedNamespace); managedNamespace = namespaceRepository.save(managedNamespace); auditService.audit(Namespace.class.getSimpleName(), managedNamespace.getId(), Audit.OP.UPDATE, managedNamespace.getDataChangeLastModifiedBy()); return managedNamespace; } @Transactional public void instanceOfAppNamespaces(String appId, String clusterName, String createBy) { List<AppNamespace> appNamespaces = appNamespaceService.findByAppId(appId); for (AppNamespace appNamespace : appNamespaces) { Namespace ns = new Namespace(); ns.setAppId(appId); ns.setClusterName(clusterName); ns.setNamespaceName(appNamespace.getName()); ns.setDataChangeCreatedBy(createBy); ns.setDataChangeLastModifiedBy(createBy); namespaceRepository.save(ns); auditService.audit(Namespace.class.getSimpleName(), ns.getId(), Audit.OP.INSERT, createBy); } } public Map<String, Boolean> namespacePublishInfo(String appId) { List<Cluster> clusters = clusterService.findParentClusters(appId); if (CollectionUtils.isEmpty(clusters)) { throw new BadRequestException("app not exist"); } Map<String, Boolean> clusterHasNotPublishedItems = Maps.newHashMap(); for (Cluster cluster : clusters) { String clusterName = cluster.getName(); List<Namespace> namespaces = findNamespaces(appId, clusterName); for (Namespace namespace : namespaces) { boolean isNamespaceNotPublished = isNamespaceNotPublished(namespace); if (isNamespaceNotPublished) { clusterHasNotPublishedItems.put(clusterName, true); break; } } clusterHasNotPublishedItems.putIfAbsent(clusterName, false); } return clusterHasNotPublishedItems; } private boolean isNamespaceNotPublished(Namespace namespace) { Release latestRelease = releaseService.findLatestActiveRelease(namespace); long namespaceId = namespace.getId(); if (latestRelease == null) { Item lastItem = itemService.findLastOne(namespaceId); return lastItem != null; } Date lastPublishTime = latestRelease.getDataChangeLastModifiedTime(); List<Item> itemsModifiedAfterLastPublish = itemService.findItemsModifiedAfterDate(namespaceId, lastPublishTime); if (CollectionUtils.isEmpty(itemsModifiedAfterLastPublish)) { return false; } Map<String, String> publishedConfiguration = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); for (Item item : itemsModifiedAfterLastPublish) { if (!Objects.equals(item.getValue(), publishedConfiguration.get(item.getKey()))) { 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.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.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.message.MessageSender; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.ConfigConsts; import com.google.common.collect.Maps; import com.google.gson.Gson; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.Collections; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @Service public class NamespaceService { private static final Gson GSON = new Gson(); private final NamespaceRepository namespaceRepository; private final AuditService auditService; private final AppNamespaceService appNamespaceService; private final ItemService itemService; private final CommitService commitService; private final ReleaseService releaseService; private final ClusterService clusterService; private final NamespaceBranchService namespaceBranchService; private final ReleaseHistoryService releaseHistoryService; private final NamespaceLockService namespaceLockService; private final InstanceService instanceService; private final MessageSender messageSender; public NamespaceService( final ReleaseHistoryService releaseHistoryService, final NamespaceRepository namespaceRepository, final AuditService auditService, final @Lazy AppNamespaceService appNamespaceService, final MessageSender messageSender, final @Lazy ItemService itemService, final CommitService commitService, final @Lazy ReleaseService releaseService, final @Lazy ClusterService clusterService, final @Lazy NamespaceBranchService namespaceBranchService, final NamespaceLockService namespaceLockService, final InstanceService instanceService) { this.releaseHistoryService = releaseHistoryService; this.namespaceRepository = namespaceRepository; this.auditService = auditService; this.appNamespaceService = appNamespaceService; this.messageSender = messageSender; this.itemService = itemService; this.commitService = commitService; this.releaseService = releaseService; this.clusterService = clusterService; this.namespaceBranchService = namespaceBranchService; this.namespaceLockService = namespaceLockService; this.instanceService = instanceService; } public Namespace findOne(Long namespaceId) { return namespaceRepository.findById(namespaceId).orElse(null); } public Namespace findOne(String appId, String clusterName, String namespaceName) { return namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName, namespaceName); } public Namespace findPublicNamespaceForAssociatedNamespace(String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (appNamespace == null) { throw new BadRequestException("namespace not exist"); } String appId = appNamespace.getAppId(); Namespace namespace = findOne(appId, clusterName, namespaceName); //default cluster's namespace if (Objects.equals(clusterName, ConfigConsts.CLUSTER_NAME_DEFAULT)) { return namespace; } //custom cluster's namespace not exist. //return default cluster's namespace if (namespace == null) { return findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); } //custom cluster's namespace exist and has published. //return custom cluster's namespace Release latestActiveRelease = releaseService.findLatestActiveRelease(namespace); if (latestActiveRelease != null) { return namespace; } Namespace defaultNamespace = findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); //custom cluster's namespace exist but never published. //and default cluster's namespace not exist. //return custom cluster's namespace if (defaultNamespace == null) { return namespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist and has published. //return default cluster's namespace Release defaultNamespaceLatestActiveRelease = releaseService.findLatestActiveRelease(defaultNamespace); if (defaultNamespaceLatestActiveRelease != null) { return defaultNamespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist but never published. //return custom cluster's namespace return namespace; } public List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", namespaceName)); } List<Namespace> namespaces = namespaceRepository.findByNamespaceName(namespaceName, page); return filterChildNamespace(namespaces); } private List<Namespace> filterChildNamespace(List<Namespace> namespaces) { List<Namespace> result = new LinkedList<>(); if (CollectionUtils.isEmpty(namespaces)) { return result; } for (Namespace namespace : namespaces) { if (!isChildNamespace(namespace)) { result.add(namespace); } } return result; } public int countPublicAppNamespaceAssociatedNamespaces(String publicNamespaceName) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(publicNamespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", publicNamespaceName)); } return namespaceRepository.countByNamespaceNameAndAppIdNot(publicNamespaceName, publicAppNamespace.getAppId()); } public List<Namespace> findNamespaces(String appId, String clusterName) { List<Namespace> namespaces = namespaceRepository.findByAppIdAndClusterNameOrderByIdAsc(appId, clusterName); if (namespaces == null) { return Collections.emptyList(); } return namespaces; } public List<Namespace> findByAppIdAndNamespaceName(String appId, String namespaceName) { return namespaceRepository.findByAppIdAndNamespaceNameOrderByIdAsc(appId, namespaceName); } public Namespace findChildNamespace(String appId, String parentClusterName, String namespaceName) { List<Namespace> namespaces = findByAppIdAndNamespaceName(appId, namespaceName); if (CollectionUtils.isEmpty(namespaces) || namespaces.size() == 1) { return null; } List<Cluster> childClusters = clusterService.findChildClusters(appId, parentClusterName); if (CollectionUtils.isEmpty(childClusters)) { return null; } Set<String> childClusterNames = childClusters.stream().map(Cluster::getName).collect(Collectors.toSet()); //the child namespace is the intersection of the child clusters and child namespaces for (Namespace namespace : namespaces) { if (childClusterNames.contains(namespace.getClusterName())) { return namespace; } } return null; } public Namespace findChildNamespace(Namespace parentNamespace) { String appId = parentNamespace.getAppId(); String parentClusterName = parentNamespace.getClusterName(); String namespaceName = parentNamespace.getNamespaceName(); return findChildNamespace(appId, parentClusterName, namespaceName); } public Namespace findParentNamespace(String appId, String clusterName, String namespaceName) { return findParentNamespace(new Namespace(appId, clusterName, namespaceName)); } public Namespace findParentNamespace(Namespace namespace) { String appId = namespace.getAppId(); String namespaceName = namespace.getNamespaceName(); Cluster cluster = clusterService.findOne(appId, namespace.getClusterName()); if (cluster != null && cluster.getParentClusterId() > 0) { Cluster parentCluster = clusterService.findOne(cluster.getParentClusterId()); return findOne(appId, parentCluster.getName(), namespaceName); } return null; } public boolean isChildNamespace(String appId, String clusterName, String namespaceName) { return isChildNamespace(new Namespace(appId, clusterName, namespaceName)); } public boolean isChildNamespace(Namespace namespace) { return findParentNamespace(namespace) != null; } public boolean isNamespaceUnique(String appId, String cluster, String namespace) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(cluster, "Cluster must not be null"); Objects.requireNonNull(namespace, "Namespace must not be null"); return Objects.isNull( namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace)); } @Transactional public void deleteByAppIdAndClusterName(String appId, String clusterName, String operator) { List<Namespace> toDeleteNamespaces = findNamespaces(appId, clusterName); for (Namespace namespace : toDeleteNamespaces) { deleteNamespace(namespace, operator); } } @Transactional public Namespace deleteNamespace(Namespace namespace, String operator) { String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); itemService.batchDelete(namespace.getId(), operator); commitService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); // Child namespace releases should retain as long as the parent namespace exists, because parent namespaces' release // histories need them if (!isChildNamespace(namespace)) { releaseService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); } //delete child namespace Namespace childNamespace = findChildNamespace(namespace); if (childNamespace != null) { namespaceBranchService.deleteBranch(appId, clusterName, namespaceName, childNamespace.getClusterName(), NamespaceBranchStatus.DELETED, operator); //delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases releaseService.batchDelete(appId, childNamespace.getClusterName(), namespaceName, operator); } releaseHistoryService.batchDelete(appId, clusterName, namespaceName, operator); instanceService.batchDeleteInstanceConfig(appId, clusterName, namespaceName); namespaceLockService.unlock(namespace.getId()); namespace.setDeleted(true); namespace.setDataChangeLastModifiedBy(operator); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.DELETE, operator); Namespace deleted = namespaceRepository.save(namespace); //Publish release message to do some clean up in config service, such as updating the cache messageSender.sendMessage(ReleaseMessageKeyGenerator.generate(appId, clusterName, namespaceName), Topics.APOLLO_RELEASE_TOPIC); return deleted; } @Transactional public Namespace save(Namespace entity) { if (!isNamespaceUnique(entity.getAppId(), entity.getClusterName(), entity.getNamespaceName())) { throw new ServiceException("namespace not unique"); } entity.setId(0);//protection Namespace namespace = namespaceRepository.save(entity); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.INSERT, namespace.getDataChangeCreatedBy()); return namespace; } @Transactional public Namespace update(Namespace namespace) { Namespace managedNamespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName( namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); BeanUtils.copyEntityProperties(namespace, managedNamespace); managedNamespace = namespaceRepository.save(managedNamespace); auditService.audit(Namespace.class.getSimpleName(), managedNamespace.getId(), Audit.OP.UPDATE, managedNamespace.getDataChangeLastModifiedBy()); return managedNamespace; } @Transactional public void instanceOfAppNamespaces(String appId, String clusterName, String createBy) { List<AppNamespace> appNamespaces = appNamespaceService.findByAppId(appId); for (AppNamespace appNamespace : appNamespaces) { Namespace ns = new Namespace(); ns.setAppId(appId); ns.setClusterName(clusterName); ns.setNamespaceName(appNamespace.getName()); ns.setDataChangeCreatedBy(createBy); ns.setDataChangeLastModifiedBy(createBy); namespaceRepository.save(ns); auditService.audit(Namespace.class.getSimpleName(), ns.getId(), Audit.OP.INSERT, createBy); } } public Map<String, Boolean> namespacePublishInfo(String appId) { List<Cluster> clusters = clusterService.findParentClusters(appId); if (CollectionUtils.isEmpty(clusters)) { throw new BadRequestException("app not exist"); } Map<String, Boolean> clusterHasNotPublishedItems = Maps.newHashMap(); for (Cluster cluster : clusters) { String clusterName = cluster.getName(); List<Namespace> namespaces = findNamespaces(appId, clusterName); for (Namespace namespace : namespaces) { boolean isNamespaceNotPublished = isNamespaceNotPublished(namespace); if (isNamespaceNotPublished) { clusterHasNotPublishedItems.put(clusterName, true); break; } } clusterHasNotPublishedItems.putIfAbsent(clusterName, false); } return clusterHasNotPublishedItems; } private boolean isNamespaceNotPublished(Namespace namespace) { Release latestRelease = releaseService.findLatestActiveRelease(namespace); long namespaceId = namespace.getId(); if (latestRelease == null) { Item lastItem = itemService.findLastOne(namespaceId); return lastItem != null; } Date lastPublishTime = latestRelease.getDataChangeLastModifiedTime(); List<Item> itemsModifiedAfterLastPublish = itemService.findItemsModifiedAfterDate(namespaceId, lastPublishTime); if (CollectionUtils.isEmpty(itemsModifiedAfterLastPublish)) { return false; } Map<String, String> publishedConfiguration = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); for (Item item : itemsModifiedAfterLastPublish) { if (!Objects.equals(item.getValue(), publishedConfiguration.get(item.getKey()))) { return true; } } return false; } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/IndexController.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 org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(path = "/") public class IndexController { @GetMapping public String index() { return "apollo-adminservice"; } }
/* * 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 org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(path = "/") public class IndexController { @GetMapping public String index() { return "apollo-adminservice"; } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-configservice/src/main/resources/configservice.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. # #Used for apollo-assembly spring.application.name= apollo-configservice ctrip.appid= 100003171 server.port= 8080 logging.file.name= /opt/logs/100003171/apollo-configservice.log spring.jmx.default-domain = apollo-configservice
# # 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. # #Used for apollo-assembly spring.application.name= apollo-configservice ctrip.appid= 100003171 server.port= 8080 logging.file.name= /opt/logs/100003171/apollo-configservice.log spring.jmx.default-domain = apollo-configservice
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.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.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.vo.PageSetting; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class PageSettingController { private final PortalConfig portalConfig; public PageSettingController(final PortalConfig portalConfig) { this.portalConfig = portalConfig; } @GetMapping("/page-settings") public PageSetting getPageSetting() { PageSetting setting = new PageSetting(); setting.setWikiAddress(portalConfig.wikiAddress()); setting.setCanAppAdminCreatePrivateNamespace(portalConfig.canAppAdminCreatePrivateNamespace()); return setting; } }
/* * 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.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.vo.PageSetting; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class PageSettingController { private final PortalConfig portalConfig; public PageSettingController(final PortalConfig portalConfig) { this.portalConfig = portalConfig; } @GetMapping("/page-settings") public PageSetting getPageSetting() { PageSetting setting = new PageSetting(); setting.setWikiAddress(portalConfig.wikiAddress()); setting.setCanAppAdminCreatePrivateNamespace(portalConfig.canAppAdminCreatePrivateNamespace()); return setting; } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/javaConfigDemo/AnnotationApplication.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.demo.spring.javaConfigDemo; import com.ctrip.framework.apollo.demo.spring.common.bean.AnnotatedBean; import com.google.common.base.Charsets; import com.google.common.base.Strings; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; /** * @author Jason Song([email protected]) */ public class AnnotationApplication { public static void main(String[] args) throws IOException { ApplicationContext context = new AnnotationConfigApplicationContext("com.ctrip.framework.apollo.demo.spring.common"); AnnotatedBean annotatedBean = context.getBean(AnnotatedBean.class); System.out.println("AnnotationApplication Demo. Input any key except quit to print the values. Input quit to exit."); while (true) { System.out.print("> "); String input = new BufferedReader(new InputStreamReader(System.in, Charsets.UTF_8)).readLine(); if (!Strings.isNullOrEmpty(input) && input.trim().equalsIgnoreCase("quit")) { System.exit(0); } System.out.println(annotatedBean.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.demo.spring.javaConfigDemo; import com.ctrip.framework.apollo.demo.spring.common.bean.AnnotatedBean; import com.google.common.base.Charsets; import com.google.common.base.Strings; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; /** * @author Jason Song([email protected]) */ public class AnnotationApplication { public static void main(String[] args) throws IOException { ApplicationContext context = new AnnotationConfigApplicationContext("com.ctrip.framework.apollo.demo.spring.common"); AnnotatedBean annotatedBean = context.getBean(AnnotatedBean.class); System.out.println("AnnotationApplication Demo. Input any key except quit to print the values. Input quit to exit."); while (true) { System.out.print("> "); String input = new BufferedReader(new InputStreamReader(System.in, Charsets.UTF_8)).readLine(); if (!Strings.isNullOrEmpty(input) && input.trim().equalsIgnoreCase("quit")) { System.exit(0); } System.out.println(annotatedBean.toString()); } } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-client/src/test/resources/spring/XmlConfigPlaceholderTest8.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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. ~ --> <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.XmlConfigPlaceholderAutoUpdateTest.TestXmlBeanWithConstructorArgs"> <constructor-arg index="0" value="${timeout}"/> <constructor-arg index="1" value="${batch}"/> </bean> </beans>
<?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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. ~ --> <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.XmlConfigPlaceholderAutoUpdateTest.TestXmlBeanWithConstructorArgs"> <constructor-arg index="0" value="${timeout}"/> <constructor-arg index="1" value="${batch}"/> </bean> </beans>
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-client/src/main/java/com/ctrip/framework/apollo/enums/ConfigSourceType.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.enums; /** * To indicate the config's source type, i.e. where is the config loaded from * * @since 1.1.0 */ public enum ConfigSourceType { REMOTE("Loaded from remote config service"), LOCAL("Loaded from local cache"), NONE("Load failed"); private final String description; ConfigSourceType(String description) { this.description = description; } public String getDescription() { return description; } }
/* * 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.enums; /** * To indicate the config's source type, i.e. where is the config loaded from * * @since 1.1.0 */ public enum ConfigSourceType { REMOTE("Loaded from remote config service"), LOCAL("Loaded from local cache"), NONE("Load failed"); private final String description; ConfigSourceType(String description) { this.description = description; } public String getDescription() { return description; } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-biz/src/test/resources/sql/release-creation-test.sql
-- -- 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. -- INSERT INTO `app` ( `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES('test', 'test0620-06', 'default', 'default', 'default', 'default', 0, 'default', 'default'); /* normal namespace*/ INSERT INTO `cluster` ( `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES ( 'only-master', 'test', 0, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'test', 'only-master', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k3', 'v3', '', 'apollo', 'apollo'); /* namespace has branch. master has items but branch has not item*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (101, 'default1', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(102, 'child-cluster1', 'test', 101, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'test', 'default1', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(102, 'test', 'child-cluster1', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k3', 'v3', '', 'apollo', 'apollo'); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default1', 'application', 'child-cluster1', '[]', 1155, 1); /* namespace has branch. master has items and branch has item*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (103, 'default2', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'child-cluster2', 'test', 103, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'test', 'default2', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'test', 'child-cluster2', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k3', 'v3', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'k1', 'v1-1', '', 'apollo', 'apollo'); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default2', 'application', 'child-cluster2', '[]', 1155, 1); /* namespace has branch. master has items and branch has cover item */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (105, 'default3', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'child-cluster3', 'test', 105, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'test', 'default3', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'test', 'child-cluster3', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(1, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default3', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(2, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster3', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default3', 'application', 'child-cluster3', '[]', 1155, 1); /*publish branch at first time */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (107, 'default4', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'child-cluster4', 'test', 107, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'test', 'default4', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'test', 'child-cluster4', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k4', 'v4', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(3, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default4', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default4', 'application', 'child-cluster4', '[]', 1155, 1); /*publish branch*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (109, 'default5', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'child-cluster5', 'test', 109, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'test', 'default5', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'test', 'child-cluster5', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k4', 'v4', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k6', 'v6', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(4, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default5', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(5, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster5', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3","k4":"v4","k5":"v5"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default5', 'application', 'child-cluster5', '[]', 1155, 1); /* rollback */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (1011, 'default6', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1012, 'child-cluster6', 'test', 1011, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1011, 'test', 'default6', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1012, 'test', 'child-cluster6', 'application', 0, 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(6, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default6', 'application', '{"k1":"v1-1","k2":"v2-1","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(7, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default6', 'application', '{"k1":"v1","k2":"v2"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(8, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster6', 'application', '{"k1":"v1-2","k2":"v2","k3":"v3"}', 0);
-- -- 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. -- INSERT INTO `app` ( `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES('test', 'test0620-06', 'default', 'default', 'default', 'default', 0, 'default', 'default'); /* normal namespace*/ INSERT INTO `cluster` ( `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES ( 'only-master', 'test', 0, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'test', 'only-master', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k3', 'v3', '', 'apollo', 'apollo'); /* namespace has branch. master has items but branch has not item*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (101, 'default1', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(102, 'child-cluster1', 'test', 101, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'test', 'default1', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(102, 'test', 'child-cluster1', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k3', 'v3', '', 'apollo', 'apollo'); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default1', 'application', 'child-cluster1', '[]', 1155, 1); /* namespace has branch. master has items and branch has item*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (103, 'default2', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'child-cluster2', 'test', 103, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'test', 'default2', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'test', 'child-cluster2', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k2', 'v2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k3', 'v3', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'k1', 'v1-1', '', 'apollo', 'apollo'); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default2', 'application', 'child-cluster2', '[]', 1155, 1); /* namespace has branch. master has items and branch has cover item */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (105, 'default3', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'child-cluster3', 'test', 105, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'test', 'default3', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'test', 'child-cluster3', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(1, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default3', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(2, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster3', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default3', 'application', 'child-cluster3', '[]', 1155, 1); /*publish branch at first time */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (107, 'default4', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'child-cluster4', 'test', 107, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'test', 'default4', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'test', 'child-cluster4', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k4', 'v4', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(3, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default4', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default4', 'application', 'child-cluster4', '[]', 1155, 1); /*publish branch*/ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (109, 'default5', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'child-cluster5', 'test', 109, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'test', 'default5', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'test', 'child-cluster5', 'application', 0, 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k1', 'v1', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k2', 'v2-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k1', 'v1-2', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k4', 'v4', '', 'apollo', 'apollo'); INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k6', 'v6', '', 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(4, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default5', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(5, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster5', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3","k4":"v4","k5":"v5"}', 0); INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default5', 'application', 'child-cluster5', '[]', 1155, 1); /* rollback */ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES (1011, 'default6', 'test', 0, 0, 'default', 'default'); INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1012, 'child-cluster6', 'test', 1011, 0, 'default', 'default'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1011, 'test', 'default6', 'application', 0, 'apollo', 'apollo'); INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1012, 'test', 'child-cluster6', 'application', 0, 'apollo', 'apollo'); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(6, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default6', 'application', '{"k1":"v1-1","k2":"v2-1","k3":"v3"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(7, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default6', 'application', '{"k1":"v1","k2":"v2"}', 0); INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(8, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster6', 'application', '{"k1":"v1-2","k2":"v2","k3":"v3"}', 0);
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-client/src/test/resources/yaml/case7.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. # xxx
# # 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. # xxx
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/resources/static/img/sync-error.png
PNG  IHDRXIDATx^OR3n1'v0'x O`|O`#vb¼ ނ#,v:_HRG+eUe}Ÿ́?(f* @ (0GpS=nHHCj)@tC(@hTMR5D'@z *IC4B5c)ТNx8r`zXG0 DF K`LH3Z[*@,Y3 ͌;jm fT43R(5S̸֖ K`LH3Z[*h@;{ K`MB[Wƒ!=F,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDF@ζj|&!ѨhmX:!kJ F$meX6;|b@Trh @,@, XX  (*33bPb)Tff2Re@PˀK23  Bef@, K0;j J&{ئhh@4jea @4a  0ZYMF,l&DVDFQ+ k,K+#7ܱ`:c|OG~-hYzDp#p<} |=xM,3A $ͭ%&^媸#̯ @H6{fWAgѻ\,VJр/)@ IkWeUVD'"|"K{ƣ,F4W=5b^30p e щXxiQxT.ȂGq<tu0m&^Q%!910t30$Fk Pg[E{L"@,e$V!2q$vn2%* 0Eǯc"v?ORQѨUx?Л4z {hE;d"^=Ƞ WVfUh=FiE޵[oi F5+fIuQ] yتGkʩFWS_ aU^ڃdxe#q  $Mrâm:f2x$i@N:N|wj鷪@6Tқyej\wE#eb'#iJ},?bu i}MI!#b~^wQ)| 8^0x 1*GBFm ˸VK gIe10Ed{GK4Ҩ5w-RC9ovzOL le`Ι8Xe>(|ȉV[=eY] uyVOp s%MLSwg׽:ūF^ή&.Ŧ HI7+{CՅ>bKSO3`} wˤqV=)?ous=n4HOI5%O67xjafE;BW;jTF'K"U)I:SY xP7V38]f0[pU9>RvcAE|yqRyf[?Ccquqwn<YQ?9h28z!S {qŜƗPGHE@BpĄ  6  {h-! ԋ rA-Q!xOf@ߴ.cdmxTu1+߀_T L?^  j.tST^m8Vs{@ #[g>/Ĕ/qV.#2;} .M[Lt}a~s71m˝;ʹq˼2˧UWZ3+D H٫Ćd M^D HiĂ$8~>70% 6(,CC c@ib<65ٓڴ]JiGr:QoZ ѓ)X_q`Զ6LHM{3amH,-5I㨯m'4tnj8bZS4Hi_QʺfX7$Ia@lpi]$ /;U Ȥ=ߖ2O V4e@bB<MlcUEڞBsV=B@b|@1X"aݐ, ĶXeȸ}Lgf,ò: =;C@|o<- $MJ =,~ M  h-6&gfܕk#&yH633$FqW! F:HuM+4A/sN8Df0Ol,ݼezz6#TLM9!=)HAJZWr;E8R{ݲ}=0ЃO(k3s߭ݺxLq*i89+.EKRbo8nVX+$QULV(8M8OR$ۢQa븸!4Aw Ă#H?Ѓ8aړ, ~zHΞoSqHH"m\5=bqD\7f-zqd2lDpl{BD 줞_H(N`W#$g[_Qi]A*aN>JKl'W>! в/Hx]p<PʃLmK*e N"$3ZEg&p-ӼZ؟myb6% $1{ЪþW|Hb$ƟP"ĆXp='@N{?,}]y6" yHL/Bۗ9cV܉O$Wb eW^6xAMhNiIz:nUb<a0Hl&"OOY" | A/xlW=YUXDhԲ7`p&Wpl JYUR(wOmXu RF[$>H@lTrqšF%|F;b #MIzAp_ x5?,&}@4j9^1Üsi Dh-(,"Ŏ:c5;[@M΅ a1m)eL!;1'U{ jH Wv^{q;RG. !auhY9|% B-򷤏u%Ei=f7-w;%Zb*CC+Kmx+ ֫?hs-ο7s*hN/oA:&1*hp,E H`e5/Y'l.[T> &Rk̊ XFJ>ƻp7ԁ2 =):{Ge@)Xf /tH-کpė%L?ʥh]m:ݠ"禷(Zn{\R*{+8E;b3/Qpݠ6R""'$&g`_ڍ e0 4BP;~1xd`ߚD'q7r\ΟwVK< @<SSȣģ*?H~1E<*@<SSȣģ*?H~1E<*@<SSȣģ*?H~1E<*]1UIENDB`
PNG  IHDRXIDATx^OR3n1'v0'x O`|O`#vb¼ ނ#,v:_HRG+eUe}Ÿ́?(f* @ (0GpS=nHHCj)@tC(@hTMR5D'@z *IC4B5c)ТNx8r`zXG0 DF K`LH3Z[*@,Y3 ͌;jm fT43R(5S̸֖ K`LH3Z[*h@;{ K`MB[Wƒ!=F,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDFQ+ [ #Ѩ-фhh@4jea @4a  0ZYMF,l&DVDF@ζj|&!ѨhmX:!kJ F$meX6;|b@Trh @,@, XX  (*33bPb)Tff2Re@PˀK23  Bef@, K0;j J&{ئhh@4jea @4a  0ZYMF,l&DVDFQ+ k,K+#7ܱ`:c|OG~-hYzDp#p<} |=xM,3A $ͭ%&^媸#̯ @H6{fWAgѻ\,VJр/)@ IkWeUVD'"|"K{ƣ,F4W=5b^30p e щXxiQxT.ȂGq<tu0m&^Q%!910t30$Fk Pg[E{L"@,e$V!2q$vn2%* 0Eǯc"v?ORQѨUx?Л4z {hE;d"^=Ƞ WVfUh=FiE޵[oi F5+fIuQ] yتGkʩFWS_ aU^ڃdxe#q  $Mrâm:f2x$i@N:N|wj鷪@6Tқyej\wE#eb'#iJ},?bu i}MI!#b~^wQ)| 8^0x 1*GBFm ˸VK gIe10Ed{GK4Ҩ5w-RC9ovzOL le`Ι8Xe>(|ȉV[=eY] uyVOp s%MLSwg׽:ūF^ή&.Ŧ HI7+{CՅ>bKSO3`} wˤqV=)?ous=n4HOI5%O67xjafE;BW;jTF'K"U)I:SY xP7V38]f0[pU9>RvcAE|yqRyf[?Ccquqwn<YQ?9h28z!S {qŜƗPGHE@BpĄ  6  {h-! ԋ rA-Q!xOf@ߴ.cdmxTu1+߀_T L?^  j.tST^m8Vs{@ #[g>/Ĕ/qV.#2;} .M[Lt}a~s71m˝;ʹq˼2˧UWZ3+D H٫Ćd M^D HiĂ$8~>70% 6(,CC c@ib<65ٓڴ]JiGr:QoZ ѓ)X_q`Զ6LHM{3amH,-5I㨯m'4tnj8bZS4Hi_QʺfX7$Ia@lpi]$ /;U Ȥ=ߖ2O V4e@bB<MlcUEڞBsV=B@b|@1X"aݐ, ĶXeȸ}Lgf,ò: =;C@|o<- $MJ =,~ M  h-6&gfܕk#&yH633$FqW! F:HuM+4A/sN8Df0Ol,ݼezz6#TLM9!=)HAJZWr;E8R{ݲ}=0ЃO(k3s߭ݺxLq*i89+.EKRbo8nVX+$QULV(8M8OR$ۢQa븸!4Aw Ă#H?Ѓ8aړ, ~zHΞoSqHH"m\5=bqD\7f-zqd2lDpl{BD 줞_H(N`W#$g[_Qi]A*aN>JKl'W>! в/Hx]p<PʃLmK*e N"$3ZEg&p-ӼZ؟myb6% $1{ЪþW|Hb$ƟP"ĆXp='@N{?,}]y6" yHL/Bۗ9cV܉O$Wb eW^6xAMhNiIz:nUb<a0Hl&"OOY" | A/xlW=YUXDhԲ7`p&Wpl JYUR(wOmXu RF[$>H@lTrqšF%|F;b #MIzAp_ x5?,&}@4j9^1Üsi Dh-(,"Ŏ:c5;[@M΅ a1m)eL!;1'U{ jH Wv^{q;RG. !auhY9|% B-򷤏u%Ei=f7-w;%Zb*CC+Kmx+ ֫?hs-ο7s*hN/oA:&1*hp,E H`e5/Y'l.[T> &Rk̊ XFJ>ƻp7ԁ2 =):{Ge@)Xf /tH-کpė%L?ʥh]m:ݠ"禷(Zn{\R*{+8E;b3/Qpݠ6R""'$&g`_ڍ e0 4BP;~1xd`ߚD'q7r\ΟwVK< @<SSȣģ*?H~1E<*@<SSȣģ*?H~1E<*@<SSȣģ*?H~1E<*]1UIENDB`
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./.github/workflows/build.yml
# # 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. # # This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven name: build on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: matrix: jdk: [7, 8, 11] steps: - uses: actions/checkout@v2 - name: Set up JDK uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }} - name: Cache Maven packages uses: actions/cache@v1 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build SDK with JDK 7 if: matrix.jdk == '7' run: mvn clean compile -pl apollo-client,apollo-mockserver,apollo-openapi -am -Dmaven.gitcommitid.skip=true - name: JDK 8 if: matrix.jdk == '8' run: mvn -B clean package -P travis jacoco:report -Dmaven.gitcommitid.skip=true - name: JDK 11 if: matrix.jdk == '11' run: mvn clean compile -Dmaven.gitcommitid.skip=true - name: Upload coverage to Codecov if: matrix.jdk == '8' uses: codecov/codecov-action@v1 with: file: ${{ github.workspace }}/apollo-*/target/site/jacoco/jacoco.xml
# # 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. # # This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven name: build on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: matrix: jdk: [7, 8, 11] steps: - uses: actions/checkout@v2 - name: Set up JDK uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }} - name: Cache Maven packages uses: actions/cache@v1 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build SDK with JDK 7 if: matrix.jdk == '7' run: mvn clean compile -pl apollo-client,apollo-mockserver,apollo-openapi -am -Dmaven.gitcommitid.skip=true - name: JDK 8 if: matrix.jdk == '8' run: mvn -B clean package -P travis jacoco:report -Dmaven.gitcommitid.skip=true - name: JDK 11 if: matrix.jdk == '11' run: mvn clean compile -Dmaven.gitcommitid.skip=true - name: Upload coverage to Codecov if: matrix.jdk == '8' uses: codecov/codecov-action@v1 with: file: ${{ github.workspace }}/apollo-*/target/site/jacoco/jacoco.xml
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-portal/src/main/resources/static/scripts/controller/role/SystemRoleController.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. * */ angular.module('systemRole', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']) .controller('SystemRoleController', ['$scope', '$location', '$window', '$translate', 'toastr', 'AppService', 'UserService', 'AppUtil', 'EnvService', 'PermissionService', 'SystemRoleService', function SystemRoleController($scope, $location, $window, $translate, toastr, AppService, UserService, AppUtil, EnvService, PermissionService, SystemRoleService) { $scope.addCreateApplicationBtnDisabled = false; $scope.deleteCreateApplicationBtnDisabled = false; $scope.modifySystemRoleWidgetId = 'modifySystemRoleWidgetId'; $scope.modifyManageAppMasterRoleWidgetId = 'modifyManageAppMasterRoleWidgetId'; $scope.hasCreateApplicationPermissionUserList = []; $scope.operateManageAppMasterRoleBtn = true; $scope.app = { appId: "", info: "" }; initPermission(); $scope.addCreateApplicationRoleToUser = function () { var user = $('.' + $scope.modifySystemRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } SystemRoleService.add_create_application_role(user.id) .then( function (value) { toastr.info($translate.instant('SystemRole.Added')); getCreateApplicationRoleUsers(); }, function (reason) { toastr.warning(AppUtil.errorMsg(reason), $translate.instant('SystemRole.AddFailed')); } ); }; $scope.deleteCreateApplicationRoleFromUser = function (userId) { SystemRoleService.delete_create_application_role(userId) .then( function (value) { toastr.info($translate.instant('SystemRole.Deleted')); getCreateApplicationRoleUsers(); }, function (reason) { toastr.warn(AppUtil.errorMsg(reason), $translate.instant('SystemRole.DeleteFailed')); } ); }; function getCreateApplicationRoleUsers() { SystemRoleService.get_create_application_role_users() .then( function (result) { $scope.hasCreateApplicationPermissionUserList = result; }, function (reason) { toastr.warning(AppUtil.errorMsg(reason), $translate.instant('SystemRole.GetCanCreateProjectUsersError')); } ) } function initPermission() { PermissionService.has_root_permission() .then(function (result) { $scope.isRootUser = result.hasPermission; if ($scope.isRootUser) { getCreateApplicationRoleUsers(); } }); } $scope.getAppInfo = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); $scope.operateManageAppMasterRoleBtn = true; return; } $scope.app.info = ""; AppService.load($scope.app.appId).then(function (result) { if (!result.appId) { toastr.warning($translate.instant('SystemRole.AppIdNotFound', { appId: $scope.app.appId })); $scope.operateManageAppMasterRoleBtn = true; return; } $scope.app.info = $translate.instant('SystemRole.AppInfoContent', { appName: result.name, departmentName: result.orgName, departmentId: result.orgId, ownerName: result.ownerName }); $scope.operateManageAppMasterRoleBtn = false; }, function (result) { AppUtil.showErrorMsg(result); $scope.operateManageAppMasterRoleBt = true; }); }; $scope.deleteAppMasterAssignRole = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); return; } var user = $('.' + $scope.modifyManageAppMasterRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } var confirmTips = $translate.instant('SystemRole.DeleteMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); if (confirm(confirmTips)) { AppService.delete_app_master_assign_role($scope.app.appId, user.id).then(function (result) { var deletedTips = $translate.instant('SystemRole.DeletedMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); toastr.success(deletedTips); $scope.operateManageAppMasterRoleBtn = true; }, function (result) { AppUtil.showErrorMsg(result); }) } }; $scope.allowAppMasterAssignRole = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); return; } var user = $('.' + $scope.modifyManageAppMasterRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } var confirmTips = $translate.instant('SystemRole.AllowAppMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); if (confirm(confirmTips)) { AppService.allow_app_master_assign_role($scope.app.appId, user.id).then(function (result) { var allowedTips = $translate.instant('SystemRole.AllowedAppMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); toastr.success(allowedTips); $scope.operateManageAppMasterRoleBtn = true; }, function (result) { AppUtil.showErrorMsg(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. * */ angular.module('systemRole', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']) .controller('SystemRoleController', ['$scope', '$location', '$window', '$translate', 'toastr', 'AppService', 'UserService', 'AppUtil', 'EnvService', 'PermissionService', 'SystemRoleService', function SystemRoleController($scope, $location, $window, $translate, toastr, AppService, UserService, AppUtil, EnvService, PermissionService, SystemRoleService) { $scope.addCreateApplicationBtnDisabled = false; $scope.deleteCreateApplicationBtnDisabled = false; $scope.modifySystemRoleWidgetId = 'modifySystemRoleWidgetId'; $scope.modifyManageAppMasterRoleWidgetId = 'modifyManageAppMasterRoleWidgetId'; $scope.hasCreateApplicationPermissionUserList = []; $scope.operateManageAppMasterRoleBtn = true; $scope.app = { appId: "", info: "" }; initPermission(); $scope.addCreateApplicationRoleToUser = function () { var user = $('.' + $scope.modifySystemRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } SystemRoleService.add_create_application_role(user.id) .then( function (value) { toastr.info($translate.instant('SystemRole.Added')); getCreateApplicationRoleUsers(); }, function (reason) { toastr.warning(AppUtil.errorMsg(reason), $translate.instant('SystemRole.AddFailed')); } ); }; $scope.deleteCreateApplicationRoleFromUser = function (userId) { SystemRoleService.delete_create_application_role(userId) .then( function (value) { toastr.info($translate.instant('SystemRole.Deleted')); getCreateApplicationRoleUsers(); }, function (reason) { toastr.warn(AppUtil.errorMsg(reason), $translate.instant('SystemRole.DeleteFailed')); } ); }; function getCreateApplicationRoleUsers() { SystemRoleService.get_create_application_role_users() .then( function (result) { $scope.hasCreateApplicationPermissionUserList = result; }, function (reason) { toastr.warning(AppUtil.errorMsg(reason), $translate.instant('SystemRole.GetCanCreateProjectUsersError')); } ) } function initPermission() { PermissionService.has_root_permission() .then(function (result) { $scope.isRootUser = result.hasPermission; if ($scope.isRootUser) { getCreateApplicationRoleUsers(); } }); } $scope.getAppInfo = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); $scope.operateManageAppMasterRoleBtn = true; return; } $scope.app.info = ""; AppService.load($scope.app.appId).then(function (result) { if (!result.appId) { toastr.warning($translate.instant('SystemRole.AppIdNotFound', { appId: $scope.app.appId })); $scope.operateManageAppMasterRoleBtn = true; return; } $scope.app.info = $translate.instant('SystemRole.AppInfoContent', { appName: result.name, departmentName: result.orgName, departmentId: result.orgId, ownerName: result.ownerName }); $scope.operateManageAppMasterRoleBtn = false; }, function (result) { AppUtil.showErrorMsg(result); $scope.operateManageAppMasterRoleBt = true; }); }; $scope.deleteAppMasterAssignRole = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); return; } var user = $('.' + $scope.modifyManageAppMasterRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } var confirmTips = $translate.instant('SystemRole.DeleteMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); if (confirm(confirmTips)) { AppService.delete_app_master_assign_role($scope.app.appId, user.id).then(function (result) { var deletedTips = $translate.instant('SystemRole.DeletedMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); toastr.success(deletedTips); $scope.operateManageAppMasterRoleBtn = true; }, function (result) { AppUtil.showErrorMsg(result); }) } }; $scope.allowAppMasterAssignRole = function () { if (!$scope.app.appId) { toastr.warning($translate.instant('SystemRole.PleaseEnterAppId')); return; } var user = $('.' + $scope.modifyManageAppMasterRoleWidgetId).select2('data')[0]; if (!user) { toastr.warning($translate.instant('SystemRole.PleaseChooseUser')); return; } var confirmTips = $translate.instant('SystemRole.AllowAppMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); if (confirm(confirmTips)) { AppService.allow_app_master_assign_role($scope.app.appId, user.id).then(function (result) { var allowedTips = $translate.instant('SystemRole.AllowedAppMasterAssignRoleTips', { appId: $scope.app.appId, userId: user.id }); toastr.success(allowedTips); $scope.operateManageAppMasterRoleBtn = true; }, function (result) { AppUtil.showErrorMsg(result); }) } }; }]);
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-openapi/src/main/java/com/ctrip/framework/apollo/openapi/client/service/ItemOpenApiService.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.client.service; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.openapi.client.exception.ApolloOpenApiException; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.google.common.base.Strings; import com.google.gson.Gson; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; public class ItemOpenApiService extends AbstractOpenApiService { public ItemOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson) { super(client, baseUrl, gson); } public OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(key, "Item key"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(key)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenItemDTO.class); } catch (Throwable ex) { // return null if item doesn't exist if (ex instanceof ApolloOpenApiException && ((ApolloOpenApiException)ex).getStatus() == 404) { return null; } throw new RuntimeException(String .format("Get item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", key, appId, clusterName, namespaceName, env), ex); } } public OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = post(path, itemDTO)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenItemDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Create item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by"); if (Strings.isNullOrEmpty(itemDTO.getDataChangeLastModifiedBy())) { itemDTO.setDataChangeLastModifiedBy(itemDTO.getDataChangeCreatedBy()); } String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?createIfNotExists=true", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("CreateOrUpdate item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(key, "Item key"); checkNotEmpty(operator, "Operator"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?operator=%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(key), escapeParam(operator)); try (CloseableHttpResponse ignored = delete(path)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Remove item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", key, appId, clusterName, namespaceName, env), 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.client.service; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.openapi.client.exception.ApolloOpenApiException; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.google.common.base.Strings; import com.google.gson.Gson; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; public class ItemOpenApiService extends AbstractOpenApiService { public ItemOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson) { super(client, baseUrl, gson); } public OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(key, "Item key"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(key)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenItemDTO.class); } catch (Throwable ex) { // return null if item doesn't exist if (ex instanceof ApolloOpenApiException && ((ApolloOpenApiException)ex).getStatus() == 404) { return null; } throw new RuntimeException(String .format("Get item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", key, appId, clusterName, namespaceName, env), ex); } } public OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = post(path, itemDTO)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenItemDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Create item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by"); if (Strings.isNullOrEmpty(itemDTO.getDataChangeLastModifiedBy())) { itemDTO.setDataChangeLastModifiedBy(itemDTO.getDataChangeCreatedBy()); } String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?createIfNotExists=true", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("CreateOrUpdate item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } public void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(key, "Item key"); checkNotEmpty(operator, "Operator"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s?operator=%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(key), escapeParam(operator)); try (CloseableHttpResponse ignored = delete(path)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Remove item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", key, appId, clusterName, namespaceName, env), ex); } } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.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.enums.ConfigFileFormat; public class TxtConfigFile extends PlainTextConfigFile { public TxtConfigFile(String namespace, ConfigRepository configRepository) { super(namespace, configRepository); } @Override public ConfigFileFormat getConfigFileFormat() { return ConfigFileFormat.TXT; } }
/* * 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.enums.ConfigFileFormat; public class TxtConfigFile extends PlainTextConfigFile { public TxtConfigFile(String namespace, ConfigRepository configRepository) { super(namespace, configRepository); } @Override public ConfigFileFormat getConfigFileFormat() { return ConfigFileFormat.TXT; } }
-1
apolloconfig/apollo
3,666
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent
## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
Anilople
2021-05-08T11:52:42Z
2021-06-11T00:09:40Z
ff38fe06208a3a1e07ce59f8699703cb33bcee2e
44cf586c4b5b1b9df8c63a49f4b1d3b9d4d01baa
feat(apollo-client): add method interestedChangedKeys to ConfigChangeEvent. ## What's the purpose of this PR Let user can get interestedChangedKeys through ConfigChangeEvent ## Which issue(s) this PR fixes: Fixes #3664 ## Brief changelog resolve interestedChangedKeys in class AbstractConfig 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.
./scripts/helm/apollo-portal/templates/deployment-portal.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. # --- # configmap for apollo-portal kind: ConfigMap apiVersion: v1 metadata: {{- $portalFullName := include "apollo.portal.fullName" . }} name: {{ $portalFullName }} data: application-github.properties: | spring.datasource.url = jdbc:mysql://{{include "apollo.portaldb.serviceName" .}}:{{include "apollo.portaldb.servicePort" .}}/{{ .Values.portaldb.dbName }}{{ if .Values.portaldb.connectionStringProperties }}?{{ .Values.portaldb.connectionStringProperties }}{{ end }} spring.datasource.username = {{ required "portaldb.userName is required!" .Values.portaldb.userName }} spring.datasource.password = {{ required "portaldb.password is required!" .Values.portaldb.password }} {{- if .Values.config.envs }} apollo.portal.envs = {{ .Values.config.envs }} {{- end }} {{- if .Values.config.contextPath }} server.servlet.context-path = {{ .Values.config.contextPath }} {{- end }} apollo-env.properties: | {{- range $env, $address := .Values.config.metaServers }} {{ $env }}.meta = {{ $address }} {{- end }} {{- range $fileName, $content := .Values.config.files }} {{ $fileName | indent 2 }}: | {{ $content | indent 4 }} {{- end }} --- kind: Deployment apiVersion: apps/v1 metadata: name: {{ $portalFullName }} labels: {{- include "apollo.portal.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ $portalFullName }} {{- with .Values.strategy }} strategy: {{- toYaml . | nindent 4 }} {{- end }} template: metadata: labels: app: {{ $portalFullName }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} volumes: - name: configmap-{{ $portalFullName }} configMap: name: {{ $portalFullName }} items: - key: application-github.properties path: application-github.properties - key: apollo-env.properties path: apollo-env.properties {{- range $fileName, $content := .Values.config.files }} - key: {{ $fileName }} path: {{ $fileName }} {{- end }} defaultMode: 420 containers: - name: {{ .Values.name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.containerPort }} protocol: TCP env: - name: SPRING_PROFILES_ACTIVE value: {{ .Values.config.profiles | quote }} {{- range $key, $value := .Values.env }} - name: {{ $key }} value: {{ $value }} {{- end }} volumeMounts: - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/application-github.properties subPath: application-github.properties - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/apollo-env.properties subPath: apollo-env.properties {{- range $fileName, $content := .Values.config.files }} - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/{{ $fileName }} subPath: {{ $fileName }} {{- end }} livenessProbe: tcpSocket: port: {{ .Values.containerPort }} initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} periodSeconds: {{ .Values.liveness.periodSeconds }} readinessProbe: httpGet: path: {{ .Values.config.contextPath }}/health port: {{ .Values.containerPort }} initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} periodSeconds: {{ .Values.readiness.periodSeconds }} resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }}
# # 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. # --- # configmap for apollo-portal kind: ConfigMap apiVersion: v1 metadata: {{- $portalFullName := include "apollo.portal.fullName" . }} name: {{ $portalFullName }} data: application-github.properties: | spring.datasource.url = jdbc:mysql://{{include "apollo.portaldb.serviceName" .}}:{{include "apollo.portaldb.servicePort" .}}/{{ .Values.portaldb.dbName }}{{ if .Values.portaldb.connectionStringProperties }}?{{ .Values.portaldb.connectionStringProperties }}{{ end }} spring.datasource.username = {{ required "portaldb.userName is required!" .Values.portaldb.userName }} spring.datasource.password = {{ required "portaldb.password is required!" .Values.portaldb.password }} {{- if .Values.config.envs }} apollo.portal.envs = {{ .Values.config.envs }} {{- end }} {{- if .Values.config.contextPath }} server.servlet.context-path = {{ .Values.config.contextPath }} {{- end }} apollo-env.properties: | {{- range $env, $address := .Values.config.metaServers }} {{ $env }}.meta = {{ $address }} {{- end }} {{- range $fileName, $content := .Values.config.files }} {{ $fileName | indent 2 }}: | {{ $content | indent 4 }} {{- end }} --- kind: Deployment apiVersion: apps/v1 metadata: name: {{ $portalFullName }} labels: {{- include "apollo.portal.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ $portalFullName }} {{- with .Values.strategy }} strategy: {{- toYaml . | nindent 4 }} {{- end }} template: metadata: labels: app: {{ $portalFullName }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} volumes: - name: configmap-{{ $portalFullName }} configMap: name: {{ $portalFullName }} items: - key: application-github.properties path: application-github.properties - key: apollo-env.properties path: apollo-env.properties {{- range $fileName, $content := .Values.config.files }} - key: {{ $fileName }} path: {{ $fileName }} {{- end }} defaultMode: 420 containers: - name: {{ .Values.name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.containerPort }} protocol: TCP env: - name: SPRING_PROFILES_ACTIVE value: {{ .Values.config.profiles | quote }} {{- range $key, $value := .Values.env }} - name: {{ $key }} value: {{ $value }} {{- end }} volumeMounts: - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/application-github.properties subPath: application-github.properties - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/apollo-env.properties subPath: apollo-env.properties {{- range $fileName, $content := .Values.config.files }} - name: configmap-{{ $portalFullName }} mountPath: /apollo-portal/config/{{ $fileName }} subPath: {{ $fileName }} {{- end }} livenessProbe: tcpSocket: port: {{ .Values.containerPort }} initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} periodSeconds: {{ .Values.liveness.periodSeconds }} readinessProbe: httpGet: path: {{ .Values.config.contextPath }}/health port: {{ .Values.containerPort }} initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} periodSeconds: {{ .Values.readiness.periodSeconds }} resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }}
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./.github/ISSUE_TEMPLATE/bug_report_en.md
--- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- <!-- The content in here will not be show。To forbid duplication,easier search in the feature,before you create an issue,please check the following. If your question is a newer/beginner's,recommand to https://github.com/ctripcorp/apollo/discussions to ask it. --> - [ ] I have checked the [discussions](https://github.com/ctripcorp/apollo/discussions) - [ ] I have searched the [issues](https://github.com/ctripcorp/apollo/issues) of this repository and believe that this is not a duplicate. - [ ] I have checked the [FAQ](https://ctripcorp.github.io/apollo/#/zh/faq/common-issues-in-deployment-and-development-phase) of this repository and believe that this is not a duplicate. **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. 2. 3. 4. **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. ### Additional Details & Logs - Version - Error logs - Configuration - Platform and Operating System
--- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- <!-- The content in here will not be show。To forbid duplication,easier search in the feature,before you create an issue,please check the following. If your question is a newer/beginner's,recommand to https://github.com/ctripcorp/apollo/discussions to ask it. --> - [ ] I have checked the [discussions](https://github.com/ctripcorp/apollo/discussions) - [ ] I have searched the [issues](https://github.com/ctripcorp/apollo/issues) of this repository and believe that this is not a duplicate. - [ ] I have checked the [FAQ](https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase) of this repository and believe that this is not a duplicate. **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. 2. 3. 4. **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. ### Additional Details & Logs - Version - Error logs - Configuration - Platform and Operating System
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./.github/ISSUE_TEMPLATE/bug_report_zh.md
--- name: 报告Bug/使用疑问 about: 提交Apollo Bug/使用疑问,使用这个模板 title: '' labels: '' assignees: '' --- <!-- 这段文字不会显示在你的内容中。为了避免重复的信息,方便后续的检索,在提issue之前,请检查如下事项。如果是比较新手级别的问题,推荐到讨论区https://github.com/ctripcorp/apollo/discussions 提问 --> - [ ] 我已经检查过[discussions](https://github.com/ctripcorp/apollo/discussions) - [ ] 我已经搜索过[issues](https://github.com/ctripcorp/apollo/issues) - [ ] 我已经仔细检查过[FAQ](https://ctripcorp.github.io/apollo/#/zh/faq/common-issues-in-deployment-and-development-phase) **描述bug** 简洁明了地描述一下bug **复现** 通过如下步骤可以复现: 1. 2. 3. 4. **期望** 简介明了地描述你希望正常情况下应该发生什么 **截图** 如果可以,附上截图来描述你的问题 ### 额外的细节和日志 - 版本: - 错误日志 - 配置: - 平台和操作系统
--- name: 报告Bug/使用疑问 about: 提交Apollo Bug/使用疑问,使用这个模板 title: '' labels: '' assignees: '' --- <!-- 这段文字不会显示在你的内容中。为了避免重复的信息,方便后续的检索,在提issue之前,请检查如下事项。如果是比较新手级别的问题,推荐到讨论区https://github.com/ctripcorp/apollo/discussions 提问 --> - [ ] 我已经检查过[discussions](https://github.com/ctripcorp/apollo/discussions) - [ ] 我已经搜索过[issues](https://github.com/ctripcorp/apollo/issues) - [ ] 我已经仔细检查过[FAQ](https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase) **描述bug** 简洁明了地描述一下bug **复现** 通过如下步骤可以复现: 1. 2. 3. 4. **期望** 简介明了地描述你希望正常情况下应该发生什么 **截图** 如果可以,附上截图来描述你的问题 ### 额外的细节和日志 - 版本: - 错误日志 - 配置: - 平台和操作系统
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./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://ctripcorp.github.io/apollo/#/zh/design/apollo-introduction). For local demo purpose, please refer [Quick Start](https://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-guide) 2. [Java SDK User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/java-sdk-user-guide) 3. [.Net SDK user Guide](https://ctripcorp.github.io/apollo/#/zh/usage/dotnet-sdk-user-guide) 4. [Third Party SDK User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/third-party-sdks-user-guide) 5. [Other Language Client User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/other-language-client-user-guide) 6. [Apollo Open APIs](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-open-api-platform) 7. [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo User Practices](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-practices) 9. [Apollo Security Best Practices](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design * [Apollo Design](https://ctripcorp.github.io/apollo/#/zh/design/apollo-design) * [Apollo Core Concept - Namespace](https://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/zh/deployment/quick-start) * [Distributed Deployment Guide](https://ctripcorp.github.io/apollo/#/zh/deployment/distributed-deployment-guide) # Release Notes * [Releases](https://github.com/ctripcorp/apollo/releases) # FAQ * [FAQ](https://ctripcorp.github.io/apollo/#/zh/faq/faq) * [Common Issues in Deployment & Development Phase](https://ctripcorp.github.io/apollo/#/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) # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # 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> </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) # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # 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> </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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-openapi/src/main/java/com/ctrip/framework/apollo/openapi/client/ApolloOpenApiClient.java
package com.ctrip.framework.apollo.openapi.client; import com.ctrip.framework.apollo.openapi.client.constant.ApolloOpenApiConstants; import com.ctrip.framework.apollo.openapi.client.service.AppOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ClusterOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ItemOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.NamespaceOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ReleaseOpenApiService; import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.OpenAppDTO; import com.ctrip.framework.apollo.openapi.dto.OpenAppNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenClusterDTO; import com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO; import com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.apache.http.client.config.RequestConfig; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicHeader; import java.util.List; /** * This class contains collections of methods to access Apollo Open Api. * <br /> * For more information, please refer <a href="https://ctripcorp.github.io/apollo/#/zh/usage/apollo-open-api-platform">Apollo Wiki</a>. * */ public class ApolloOpenApiClient { private final String portalUrl; private final String token; private final AppOpenApiService appService; private final ItemOpenApiService itemService; private final ReleaseOpenApiService releaseService; private final NamespaceOpenApiService namespaceService; private final ClusterOpenApiService clusterService; private static final Gson GSON = new GsonBuilder().setDateFormat(ApolloOpenApiConstants.JSON_DATE_FORMAT).create(); private ApolloOpenApiClient(String portalUrl, String token, RequestConfig requestConfig) { this.portalUrl = portalUrl; this.token = token; CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig) .setDefaultHeaders(Lists.newArrayList(new BasicHeader("Authorization", token))).build(); String baseUrl = this.portalUrl + ApolloOpenApiConstants.OPEN_API_V1_PREFIX; appService = new AppOpenApiService(client, baseUrl, GSON); clusterService = new ClusterOpenApiService(client, baseUrl, GSON); namespaceService = new NamespaceOpenApiService(client, baseUrl, GSON); itemService = new ItemOpenApiService(client, baseUrl, GSON); releaseService = new ReleaseOpenApiService(client, baseUrl, GSON); } /** * Get the environment and cluster information */ public List<OpenEnvClusterDTO> getEnvClusterInfo(String appId) { return appService.getEnvClusterInfo(appId); } /** * Get all App information */ public List<OpenAppDTO> getAllApps() { return appService.getAppsInfo(null); } /** * Get App information by app ids */ public List<OpenAppDTO> getAppsByIds(List<String> appIds) { return appService.getAppsInfo(appIds); } /** * Get the namespaces */ public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { return namespaceService.getNamespaces(appId, env, clusterName); } /** * Get the cluster * * @since 1.5.0 */ public OpenClusterDTO getCluster(String appId, String env, String clusterName) { return clusterService.getCluster(appId, env, clusterName); } /** * Create the cluster * * @since 1.5.0 */ public OpenClusterDTO createCluster(String env, OpenClusterDTO openClusterDTO) { return clusterService.createCluster(env, openClusterDTO); } /** * Get the namespace */ public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName) { return namespaceService.getNamespace(appId, env, clusterName, namespaceName); } /** * Create the app namespace */ public OpenAppNamespaceDTO createAppNamespace(OpenAppNamespaceDTO appNamespaceDTO) { return namespaceService.createAppNamespace(appNamespaceDTO); } /** * Get the namespace lock */ public OpenNamespaceLockDTO getNamespaceLock(String appId, String env, String clusterName, String namespaceName) { return namespaceService.getNamespaceLock(appId, env, clusterName, namespaceName); } /** * Get config * * @return the item or null if not exists * * @since 1.2.0 */ public OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key) { return itemService.getItem(appId, env, clusterName, namespaceName, key); } /** * Add config * @return the created config */ public OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { return itemService.createItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Update config */ public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { itemService.updateItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Create config if not exists or update config if already exists */ public void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { itemService.createOrUpdateItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Remove config * * @param operator the user who removes the item */ public void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator) { itemService.removeItem(appId, env, clusterName, namespaceName, key, operator); } /** * publish namespace * @return the released configurations */ public OpenReleaseDTO publishNamespace(String appId, String env, String clusterName, String namespaceName, NamespaceReleaseDTO releaseDTO) { return releaseService.publishNamespace(appId, env, clusterName, namespaceName, releaseDTO); } /** * @return the latest active release information or <code>null</code> if not found */ public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { return releaseService.getLatestActiveRelease(appId, env, clusterName, namespaceName); } /** * Rollback the release * * @param operator the user who rollbacks the release * @since 1.5.0 */ public void rollbackRelease(String env, long releaseId, String operator) { releaseService.rollbackRelease(env, releaseId, operator); } public String getPortalUrl() { return portalUrl; } public String getToken() { return token; } public static ApolloOpenApiClientBuilder newBuilder() { return new ApolloOpenApiClientBuilder(); } public static class ApolloOpenApiClientBuilder { private String portalUrl; private String token; private int connectTimeout = -1; private int readTimeout = -1; /** * @param portalUrl The apollo portal url, e.g http://localhost:8070 */ public ApolloOpenApiClientBuilder withPortalUrl(String portalUrl) { this.portalUrl = portalUrl; return this; } /** * @param token The authorization token, e.g. e16e5cd903fd0c97a116c873b448544b9d086de8 */ public ApolloOpenApiClientBuilder withToken(String token) { this.token = token; return this; } /** * @param connectTimeout an int that specifies the connect timeout value in milliseconds */ public ApolloOpenApiClientBuilder withConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; return this; } /** * @param readTimeout an int that specifies the timeout value to be used in milliseconds */ public ApolloOpenApiClientBuilder withReadTimeout(int readTimeout) { this.readTimeout = readTimeout; return this; } public ApolloOpenApiClient build() { Preconditions.checkArgument(!Strings.isNullOrEmpty(portalUrl), "Portal url should not be null or empty!"); Preconditions.checkArgument(portalUrl.startsWith("http://") || portalUrl.startsWith("https://"), "Portal url should start with http:// or https://" ); Preconditions.checkArgument(!Strings.isNullOrEmpty(token), "Token should not be null or empty!"); if (connectTimeout < 0) { connectTimeout = ApolloOpenApiConstants.DEFAULT_CONNECT_TIMEOUT; } if (readTimeout < 0) { readTimeout = ApolloOpenApiConstants.DEFAULT_READ_TIMEOUT; } RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout) .setSocketTimeout(readTimeout).build(); return new ApolloOpenApiClient(portalUrl, token, requestConfig); } } }
package com.ctrip.framework.apollo.openapi.client; import com.ctrip.framework.apollo.openapi.client.constant.ApolloOpenApiConstants; import com.ctrip.framework.apollo.openapi.client.service.AppOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ClusterOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ItemOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.NamespaceOpenApiService; import com.ctrip.framework.apollo.openapi.client.service.ReleaseOpenApiService; import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.OpenAppDTO; import com.ctrip.framework.apollo.openapi.dto.OpenAppNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenClusterDTO; import com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO; import com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.apache.http.client.config.RequestConfig; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicHeader; import java.util.List; /** * This class contains collections of methods to access Apollo Open Api. * <br /> * For more information, please refer <a href="https://www.apolloconfig.com/#/zh/usage/apollo-open-api-platform">Apollo Wiki</a>. * */ public class ApolloOpenApiClient { private final String portalUrl; private final String token; private final AppOpenApiService appService; private final ItemOpenApiService itemService; private final ReleaseOpenApiService releaseService; private final NamespaceOpenApiService namespaceService; private final ClusterOpenApiService clusterService; private static final Gson GSON = new GsonBuilder().setDateFormat(ApolloOpenApiConstants.JSON_DATE_FORMAT).create(); private ApolloOpenApiClient(String portalUrl, String token, RequestConfig requestConfig) { this.portalUrl = portalUrl; this.token = token; CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig) .setDefaultHeaders(Lists.newArrayList(new BasicHeader("Authorization", token))).build(); String baseUrl = this.portalUrl + ApolloOpenApiConstants.OPEN_API_V1_PREFIX; appService = new AppOpenApiService(client, baseUrl, GSON); clusterService = new ClusterOpenApiService(client, baseUrl, GSON); namespaceService = new NamespaceOpenApiService(client, baseUrl, GSON); itemService = new ItemOpenApiService(client, baseUrl, GSON); releaseService = new ReleaseOpenApiService(client, baseUrl, GSON); } /** * Get the environment and cluster information */ public List<OpenEnvClusterDTO> getEnvClusterInfo(String appId) { return appService.getEnvClusterInfo(appId); } /** * Get all App information */ public List<OpenAppDTO> getAllApps() { return appService.getAppsInfo(null); } /** * Get App information by app ids */ public List<OpenAppDTO> getAppsByIds(List<String> appIds) { return appService.getAppsInfo(appIds); } /** * Get the namespaces */ public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { return namespaceService.getNamespaces(appId, env, clusterName); } /** * Get the cluster * * @since 1.5.0 */ public OpenClusterDTO getCluster(String appId, String env, String clusterName) { return clusterService.getCluster(appId, env, clusterName); } /** * Create the cluster * * @since 1.5.0 */ public OpenClusterDTO createCluster(String env, OpenClusterDTO openClusterDTO) { return clusterService.createCluster(env, openClusterDTO); } /** * Get the namespace */ public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName) { return namespaceService.getNamespace(appId, env, clusterName, namespaceName); } /** * Create the app namespace */ public OpenAppNamespaceDTO createAppNamespace(OpenAppNamespaceDTO appNamespaceDTO) { return namespaceService.createAppNamespace(appNamespaceDTO); } /** * Get the namespace lock */ public OpenNamespaceLockDTO getNamespaceLock(String appId, String env, String clusterName, String namespaceName) { return namespaceService.getNamespaceLock(appId, env, clusterName, namespaceName); } /** * Get config * * @return the item or null if not exists * * @since 1.2.0 */ public OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key) { return itemService.getItem(appId, env, clusterName, namespaceName, key); } /** * Add config * @return the created config */ public OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { return itemService.createItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Update config */ public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { itemService.updateItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Create config if not exists or update config if already exists */ public void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { itemService.createOrUpdateItem(appId, env, clusterName, namespaceName, itemDTO); } /** * Remove config * * @param operator the user who removes the item */ public void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator) { itemService.removeItem(appId, env, clusterName, namespaceName, key, operator); } /** * publish namespace * @return the released configurations */ public OpenReleaseDTO publishNamespace(String appId, String env, String clusterName, String namespaceName, NamespaceReleaseDTO releaseDTO) { return releaseService.publishNamespace(appId, env, clusterName, namespaceName, releaseDTO); } /** * @return the latest active release information or <code>null</code> if not found */ public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { return releaseService.getLatestActiveRelease(appId, env, clusterName, namespaceName); } /** * Rollback the release * * @param operator the user who rollbacks the release * @since 1.5.0 */ public void rollbackRelease(String env, long releaseId, String operator) { releaseService.rollbackRelease(env, releaseId, operator); } public String getPortalUrl() { return portalUrl; } public String getToken() { return token; } public static ApolloOpenApiClientBuilder newBuilder() { return new ApolloOpenApiClientBuilder(); } public static class ApolloOpenApiClientBuilder { private String portalUrl; private String token; private int connectTimeout = -1; private int readTimeout = -1; /** * @param portalUrl The apollo portal url, e.g http://localhost:8070 */ public ApolloOpenApiClientBuilder withPortalUrl(String portalUrl) { this.portalUrl = portalUrl; return this; } /** * @param token The authorization token, e.g. e16e5cd903fd0c97a116c873b448544b9d086de8 */ public ApolloOpenApiClientBuilder withToken(String token) { this.token = token; return this; } /** * @param connectTimeout an int that specifies the connect timeout value in milliseconds */ public ApolloOpenApiClientBuilder withConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; return this; } /** * @param readTimeout an int that specifies the timeout value to be used in milliseconds */ public ApolloOpenApiClientBuilder withReadTimeout(int readTimeout) { this.readTimeout = readTimeout; return this; } public ApolloOpenApiClient build() { Preconditions.checkArgument(!Strings.isNullOrEmpty(portalUrl), "Portal url should not be null or empty!"); Preconditions.checkArgument(portalUrl.startsWith("http://") || portalUrl.startsWith("https://"), "Portal url should start with http:// or https://" ); Preconditions.checkArgument(!Strings.isNullOrEmpty(token), "Token should not be null or empty!"); if (connectTimeout < 0) { connectTimeout = ApolloOpenApiConstants.DEFAULT_CONNECT_TIMEOUT; } if (readTimeout < 0) { readTimeout = ApolloOpenApiConstants.DEFAULT_READ_TIMEOUT; } RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout) .setSocketTimeout(readTimeout).build(); return new ApolloOpenApiClient(portalUrl, token, requestConfig); } } }
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java
package com.ctrip.framework.apollo.portal.component.config; import com.ctrip.framework.apollo.common.config.RefreshableConfig; import com.ctrip.framework.apollo.common.config.RefreshablePropertySource; import com.ctrip.framework.apollo.portal.entity.vo.Organization; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.PortalDBPropertySource; import com.ctrip.framework.apollo.portal.service.SystemRoleManagerService; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.lang.reflect.Type; import java.util.*; @Component public class PortalConfig extends RefreshableConfig { private static final Logger logger = LoggerFactory.getLogger(PortalConfig.class); private static final Gson GSON = new Gson(); private static final Type ORGANIZATION = new TypeToken<List<Organization>>() { }.getType(); /** * meta servers config in "PortalDB.ServerConfig" */ private static final Type META_SERVERS = new TypeToken<Map<String, String>>(){}.getType(); private final PortalDBPropertySource portalDBPropertySource; public PortalConfig(final PortalDBPropertySource portalDBPropertySource) { this.portalDBPropertySource = portalDBPropertySource; } @Override public List<RefreshablePropertySource> getRefreshablePropertySources() { return Collections.singletonList(portalDBPropertySource); } /*** * Level: important **/ public List<Env> portalSupportedEnvs() { String[] configurations = getArrayProperty("apollo.portal.envs", new String[]{"FAT", "UAT", "PRO"}); List<Env> envs = Lists.newLinkedList(); for (String env : configurations) { envs.add(Env.addEnvironment(env)); } return envs; } /** * @return the relationship between environment and its meta server. empty if meet exception */ public Map<String, String> getMetaServers() { final String key = "apollo.portal.meta.servers"; String jsonContent = getValue(key); if(null == jsonContent) { return Collections.emptyMap(); } // watch out that the format of content may be wrong // that will cause exception Map<String, String> map = Collections.emptyMap(); try { // try to parse map = GSON.fromJson(jsonContent, META_SERVERS); } catch (Exception e) { logger.error("Wrong format for: {}", key, e); } return map; } public List<String> superAdmins() { String superAdminConfig = getValue("superAdmin", ""); if (Strings.isNullOrEmpty(superAdminConfig)) { return Collections.emptyList(); } return splitter.splitToList(superAdminConfig); } public Set<Env> emailSupportedEnvs() { String[] configurations = getArrayProperty("email.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public Set<Env> webHookSupportedEnvs() { String[] configurations = getArrayProperty("webhook.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public boolean isConfigViewMemberOnly(String env) { String[] configViewMemberOnlyEnvs = getArrayProperty("configView.memberOnly.envs", new String[0]); for (String memberOnlyEnv : configViewMemberOnlyEnvs) { if (memberOnlyEnv.equalsIgnoreCase(env)) { return true; } } return false; } /*** * Level: normal **/ public int connectTimeout() { return getIntProperty("api.connectTimeout", 3000); } public int readTimeout() { return getIntProperty("api.readTimeout", 10000); } public List<Organization> organizations() { String organizations = getValue("organizations"); return organizations == null ? Collections.emptyList() : GSON.fromJson(organizations, ORGANIZATION); } public String portalAddress() { return getValue("apollo.portal.address"); } public boolean isEmergencyPublishAllowed(Env env) { String targetEnv = env.name(); String[] emergencyPublishSupportedEnvs = getArrayProperty("emergencyPublish.supported.envs", new String[0]); for (String supportedEnv : emergencyPublishSupportedEnvs) { if (Objects.equals(targetEnv, supportedEnv.toUpperCase().trim())) { return true; } } return false; } /*** * Level: low **/ public Set<Env> publishTipsSupportedEnvs() { String[] configurations = getArrayProperty("namespace.publish.tips.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public String consumerTokenSalt() { return getValue("consumer.token.salt", "apollo-portal"); } public boolean isEmailEnabled() { return getBooleanProperty("email.enabled", false); } public String emailConfigHost() { return getValue("email.config.host", ""); } public String emailConfigUser() { return getValue("email.config.user", ""); } public String emailConfigPassword() { return getValue("email.config.password", ""); } public String emailSender() { String value = getValue("email.sender", ""); if (Strings.isNullOrEmpty(value)) { value = emailConfigUser(); } return value; } public String emailTemplateFramework() { return getValue("email.template.framework", ""); } public String emailReleaseDiffModuleTemplate() { return getValue("email.template.release.module.diff", ""); } public String emailRollbackDiffModuleTemplate() { return getValue("email.template.rollback.module.diff", ""); } public String emailGrayRulesModuleTemplate() { return getValue("email.template.release.module.rules", ""); } public String wikiAddress() { return getValue("wiki.address", "https://ctripcorp.github.io/apollo"); } public boolean canAppAdminCreatePrivateNamespace() { return getBooleanProperty("admin.createPrivateNamespace.switch", true); } public boolean isCreateApplicationPermissionEnabled() { return getBooleanProperty(SystemRoleManagerService.CREATE_APPLICATION_LIMIT_SWITCH_KEY, false); } public boolean isManageAppMasterPermissionEnabled() { return getBooleanProperty(SystemRoleManagerService.MANAGE_APP_MASTER_LIMIT_SWITCH_KEY, false); } public String getAdminServiceAccessTokens() { return getValue("admin-service.access.tokens"); } /*** * The following configurations are used in ctrip profile **/ public int appId() { return getIntProperty("ctrip.appid", 0); } //send code & template id. apply from ewatch public String sendCode() { return getValue("ctrip.email.send.code"); } public int templateId() { return getIntProperty("ctrip.email.template.id", 0); } //email retention time in email server queue.TimeUnit: hour public int survivalDuration() { return getIntProperty("ctrip.email.survival.duration", 5); } public boolean isSendEmailAsync() { return getBooleanProperty("email.send.async", true); } public String portalServerName() { return getValue("serverName"); } public String casServerLoginUrl() { return getValue("casServerLoginUrl"); } public String casServerUrlPrefix() { return getValue("casServerUrlPrefix"); } public String credisServiceUrl() { return getValue("credisServiceUrl"); } public String userServiceUrl() { return getValue("userService.url"); } public String userServiceAccessToken() { return getValue("userService.accessToken"); } public String soaServerAddress() { return getValue("soa.server.address"); } public String cloggingUrl() { return getValue("clogging.server.url"); } public String cloggingPort() { return getValue("clogging.server.port"); } public String hermesServerAddress() { return getValue("hermes.server.address"); } public String[] webHookUrls() { return getArrayProperty("config.release.webhook.service.url", null); } }
package com.ctrip.framework.apollo.portal.component.config; import com.ctrip.framework.apollo.common.config.RefreshableConfig; import com.ctrip.framework.apollo.common.config.RefreshablePropertySource; import com.ctrip.framework.apollo.portal.entity.vo.Organization; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.PortalDBPropertySource; import com.ctrip.framework.apollo.portal.service.SystemRoleManagerService; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.lang.reflect.Type; import java.util.*; @Component public class PortalConfig extends RefreshableConfig { private static final Logger logger = LoggerFactory.getLogger(PortalConfig.class); private static final Gson GSON = new Gson(); private static final Type ORGANIZATION = new TypeToken<List<Organization>>() { }.getType(); /** * meta servers config in "PortalDB.ServerConfig" */ private static final Type META_SERVERS = new TypeToken<Map<String, String>>(){}.getType(); private final PortalDBPropertySource portalDBPropertySource; public PortalConfig(final PortalDBPropertySource portalDBPropertySource) { this.portalDBPropertySource = portalDBPropertySource; } @Override public List<RefreshablePropertySource> getRefreshablePropertySources() { return Collections.singletonList(portalDBPropertySource); } /*** * Level: important **/ public List<Env> portalSupportedEnvs() { String[] configurations = getArrayProperty("apollo.portal.envs", new String[]{"FAT", "UAT", "PRO"}); List<Env> envs = Lists.newLinkedList(); for (String env : configurations) { envs.add(Env.addEnvironment(env)); } return envs; } /** * @return the relationship between environment and its meta server. empty if meet exception */ public Map<String, String> getMetaServers() { final String key = "apollo.portal.meta.servers"; String jsonContent = getValue(key); if(null == jsonContent) { return Collections.emptyMap(); } // watch out that the format of content may be wrong // that will cause exception Map<String, String> map = Collections.emptyMap(); try { // try to parse map = GSON.fromJson(jsonContent, META_SERVERS); } catch (Exception e) { logger.error("Wrong format for: {}", key, e); } return map; } public List<String> superAdmins() { String superAdminConfig = getValue("superAdmin", ""); if (Strings.isNullOrEmpty(superAdminConfig)) { return Collections.emptyList(); } return splitter.splitToList(superAdminConfig); } public Set<Env> emailSupportedEnvs() { String[] configurations = getArrayProperty("email.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public Set<Env> webHookSupportedEnvs() { String[] configurations = getArrayProperty("webhook.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public boolean isConfigViewMemberOnly(String env) { String[] configViewMemberOnlyEnvs = getArrayProperty("configView.memberOnly.envs", new String[0]); for (String memberOnlyEnv : configViewMemberOnlyEnvs) { if (memberOnlyEnv.equalsIgnoreCase(env)) { return true; } } return false; } /*** * Level: normal **/ public int connectTimeout() { return getIntProperty("api.connectTimeout", 3000); } public int readTimeout() { return getIntProperty("api.readTimeout", 10000); } public List<Organization> organizations() { String organizations = getValue("organizations"); return organizations == null ? Collections.emptyList() : GSON.fromJson(organizations, ORGANIZATION); } public String portalAddress() { return getValue("apollo.portal.address"); } public boolean isEmergencyPublishAllowed(Env env) { String targetEnv = env.name(); String[] emergencyPublishSupportedEnvs = getArrayProperty("emergencyPublish.supported.envs", new String[0]); for (String supportedEnv : emergencyPublishSupportedEnvs) { if (Objects.equals(targetEnv, supportedEnv.toUpperCase().trim())) { return true; } } return false; } /*** * Level: low **/ public Set<Env> publishTipsSupportedEnvs() { String[] configurations = getArrayProperty("namespace.publish.tips.supported.envs", null); Set<Env> result = Sets.newHashSet(); if (configurations == null || configurations.length == 0) { return result; } for (String env : configurations) { result.add(Env.valueOf(env)); } return result; } public String consumerTokenSalt() { return getValue("consumer.token.salt", "apollo-portal"); } public boolean isEmailEnabled() { return getBooleanProperty("email.enabled", false); } public String emailConfigHost() { return getValue("email.config.host", ""); } public String emailConfigUser() { return getValue("email.config.user", ""); } public String emailConfigPassword() { return getValue("email.config.password", ""); } public String emailSender() { String value = getValue("email.sender", ""); if (Strings.isNullOrEmpty(value)) { value = emailConfigUser(); } return value; } public String emailTemplateFramework() { return getValue("email.template.framework", ""); } public String emailReleaseDiffModuleTemplate() { return getValue("email.template.release.module.diff", ""); } public String emailRollbackDiffModuleTemplate() { return getValue("email.template.rollback.module.diff", ""); } public String emailGrayRulesModuleTemplate() { return getValue("email.template.release.module.rules", ""); } public String wikiAddress() { return getValue("wiki.address", "https://www.apolloconfig.com"); } public boolean canAppAdminCreatePrivateNamespace() { return getBooleanProperty("admin.createPrivateNamespace.switch", true); } public boolean isCreateApplicationPermissionEnabled() { return getBooleanProperty(SystemRoleManagerService.CREATE_APPLICATION_LIMIT_SWITCH_KEY, false); } public boolean isManageAppMasterPermissionEnabled() { return getBooleanProperty(SystemRoleManagerService.MANAGE_APP_MASTER_LIMIT_SWITCH_KEY, false); } public String getAdminServiceAccessTokens() { return getValue("admin-service.access.tokens"); } /*** * The following configurations are used in ctrip profile **/ public int appId() { return getIntProperty("ctrip.appid", 0); } //send code & template id. apply from ewatch public String sendCode() { return getValue("ctrip.email.send.code"); } public int templateId() { return getIntProperty("ctrip.email.template.id", 0); } //email retention time in email server queue.TimeUnit: hour public int survivalDuration() { return getIntProperty("ctrip.email.survival.duration", 5); } public boolean isSendEmailAsync() { return getBooleanProperty("email.send.async", true); } public String portalServerName() { return getValue("serverName"); } public String casServerLoginUrl() { return getValue("casServerLoginUrl"); } public String casServerUrlPrefix() { return getValue("casServerUrlPrefix"); } public String credisServiceUrl() { return getValue("credisServiceUrl"); } public String userServiceUrl() { return getValue("userService.url"); } public String userServiceAccessToken() { return getValue("userService.accessToken"); } public String soaServerAddress() { return getValue("soa.server.address"); } public String cloggingUrl() { return getValue("clogging.server.url"); } public String cloggingPort() { return getValue("clogging.server.port"); } public String hermesServerAddress() { return getValue("hermes.server.address"); } public String[] webHookUrls() { return getArrayProperty("config.release.webhook.service.url", null); } }
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/resources/static/namespace.html
<!doctype html> <html ng-app="namespace"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="./img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <title>{{'Namespace.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid apollo-container hidden" ng-controller="LinkNamespaceController"> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="panel"> <header class="panel-heading"> <div class="row"> <div class="col-md-6">{{'Namespace.Title' | translate }} <small><a target="_blank" href="https://ctripcorp.github.io/apollo/#/zh/design/apollo-core-concept-namespace"> {{'Namespace.UnderstandMore' | translate }} </a> </small> </div> <div class="col-md-6 text-right"> <button type="button" class="btn btn-info" ng-click="back()">{{'Common.ReturnToIndex' | translate }} </button> </div> </div> </header> <div class="panel-body"> <div class="alert alert-info no-radius"> <strong>Tips:</strong> <ul ng-show="type == 'link'"> <li>{{'Namespace.Link.Tips1' | translate }}</li> <li>{{'Namespace.Link.Tips2' | translate }}</li> </ul> <ul ng-show="type == 'create' && appNamespace.isPublic"> <li>{{'Namespace.CreatePublic.Tips1' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips2' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips3' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips4' | translate }}</li> </ul> <ul ng-show="type == 'create' && !appNamespace.isPublic"> <li>{{'Namespace.CreatePrivate.Tips1' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips2' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips3' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips4' | translate }}</li> </ul> </div> <div class="row text-right" style="padding-right: 20px;"> <div class="btn-group btn-group-sm" role="group" aria-label="..."> <button type="button" class="btn btn-default" ng-class="{active:type=='link'}" ng-click="switchType('link')">{{'Namespace.AssociationPublicNamespace' | translate }} </button> <button type="button" class="btn btn-default" ng-class="{active:type=='create'}" ng-click="switchType('create')">{{'Namespace.CreateNamespace' | translate }} </button> </div> </div> <form class="form-horizontal" name="namespaceForm" valdr-type="AppNamespace" style="margin-top: 30px;" ng-show="step == 1" ng-submit="createNamespace()"> <div class="form-group"> <label class="col-sm-3 control-label">{{'Common.AppId' | translate }}</label> <div class="col-sm-6" valdr-form-group> <label class="form-control-static" ng-bind="appId"></label> </div> </div> <div class="form-horizontal" ng-show="type == 'link'"> <div class="form-group"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.ChooseCluster' | translate }} </label> <div class="col-sm-6" valdr-form-group> <apolloclusterselector apollo-app-id="appId" apollo-default-all-checked="true" apollo-select="collectSelectedClusters"></apolloclusterselector> </div> </div> </div> <div class="form-group" ng-show="type == 'create'"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.NamespaceName' | translate }} </label> <div class="col-sm-5" valdr-form-group> <div ng-class="{'input-group':appNamespace.isPublic && appendNamespacePrefix}"> <span class="input-group-addon" ng-show="appNamespace.isPublic && appendNamespacePrefix" ng-bind="appBaseInfo.namespacePrefix"></span> <input type="text" name="namespaceName" class="form-control" ng-model="appNamespace.name"> </div> </div> <!--public namespace can only be properties --> <div class="col-sm-2" ng-show="!appNamespace.isPublic"> <select class="form-control" name="format" ng-model="appNamespace.format"> <option value="properties">properties</option> <option value="xml">xml</option> <option value="json">json</option> <option value="yml">yml</option> <option value="yaml">yaml</option> <option value="txt">txt</option> </select> </div> &nbsp;&nbsp; <span ng-show="appNamespace.isPublic && appendNamespacePrefix" ng-bind="concatNamespace()" style="line-height: 34px;"></span> </div> <div class="form-group" ng-show="type == 'create' && appNamespace.isPublic"> <label class="col-sm-3 control-label"> {{'Namespace.AutoAddDepartmentPrefix' | translate }} </label> <div class="col-sm-6" valdr-form-group> <div> <label class="checkbox-inline"> <input type="checkbox" ng-model="appendNamespacePrefix" /> {{appBaseInfo.namespacePrefix}} </label> </div> <small>{{'Namespace.AutoAddDepartmentPrefixTips' | translate }}</small> </div> </div> <div class="form-group" ng-show="type == 'create' && (pageSetting.canAppAdminCreatePrivateNamespace || hasRootPermission)"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.NamespaceType' | translate }} </label> <div class="col-sm-4" valdr-form-group> <label class="radio-inline"> <input type="radio" name="namespaceType" value="true" ng-value="true" ng-model="appNamespace.isPublic"> {{'Namespace.NamespaceType.Public' | translate }} </label> <label class="radio-inline"> <input type="radio" name="namespaceType" value="false" ng-value="false" ng-model="appNamespace.isPublic"> {{'Namespace.NamespaceType.Private' | translate }} </label> </div> </div> <div class="form-group" ng-show="type == 'create'" valdr-form-group> <label class="col-sm-3 control-label">{{'Namespace.Remark' | translate }}</label> <div class="col-sm-7" valdr-form-group> <textarea class="form-control" rows="3" name="comment" ng-model="appNamespace.comment"></textarea> </div> </div> <div class="form-group" ng-show="type == 'link'"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.Namespace' | translate }} </label> <div class="col-sm-4" valdr-form-group> <select id="namespaces"> <option></option> </select> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-10"> <button type="submit" class="btn btn-primary" ng-disabled="(type == 'create' && namespaceForm.$invalid) || submitBtnDisabled"> {{'Common.Submit' | translate }} </button> </div> </div> </form> <div class="row text-center" ng-show="step == 2"> <img src="img/sync-succ.png" style="height: 100px; width: 100px"> <h3>{{'Common.Created' | translate }}</h3> </div> </div> </div> </div> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <!--directive--> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/controller/NamespaceController.js"></script> <script src="scripts/valdr.js" type="text/javascript"></script> </body> </html>
<!doctype html> <html ng-app="namespace"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="./img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <title>{{'Namespace.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid apollo-container hidden" ng-controller="LinkNamespaceController"> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="panel"> <header class="panel-heading"> <div class="row"> <div class="col-md-6">{{'Namespace.Title' | translate }} <small><a target="_blank" href="https://www.apolloconfig.com/#/zh/design/apollo-core-concept-namespace"> {{'Namespace.UnderstandMore' | translate }} </a> </small> </div> <div class="col-md-6 text-right"> <button type="button" class="btn btn-info" ng-click="back()">{{'Common.ReturnToIndex' | translate }} </button> </div> </div> </header> <div class="panel-body"> <div class="alert alert-info no-radius"> <strong>Tips:</strong> <ul ng-show="type == 'link'"> <li>{{'Namespace.Link.Tips1' | translate }}</li> <li>{{'Namespace.Link.Tips2' | translate }}</li> </ul> <ul ng-show="type == 'create' && appNamespace.isPublic"> <li>{{'Namespace.CreatePublic.Tips1' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips2' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips3' | translate }}</li> <li>{{'Namespace.CreatePublic.Tips4' | translate }}</li> </ul> <ul ng-show="type == 'create' && !appNamespace.isPublic"> <li>{{'Namespace.CreatePrivate.Tips1' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips2' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips3' | translate }}</li> <li>{{'Namespace.CreatePrivate.Tips4' | translate }}</li> </ul> </div> <div class="row text-right" style="padding-right: 20px;"> <div class="btn-group btn-group-sm" role="group" aria-label="..."> <button type="button" class="btn btn-default" ng-class="{active:type=='link'}" ng-click="switchType('link')">{{'Namespace.AssociationPublicNamespace' | translate }} </button> <button type="button" class="btn btn-default" ng-class="{active:type=='create'}" ng-click="switchType('create')">{{'Namespace.CreateNamespace' | translate }} </button> </div> </div> <form class="form-horizontal" name="namespaceForm" valdr-type="AppNamespace" style="margin-top: 30px;" ng-show="step == 1" ng-submit="createNamespace()"> <div class="form-group"> <label class="col-sm-3 control-label">{{'Common.AppId' | translate }}</label> <div class="col-sm-6" valdr-form-group> <label class="form-control-static" ng-bind="appId"></label> </div> </div> <div class="form-horizontal" ng-show="type == 'link'"> <div class="form-group"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.ChooseCluster' | translate }} </label> <div class="col-sm-6" valdr-form-group> <apolloclusterselector apollo-app-id="appId" apollo-default-all-checked="true" apollo-select="collectSelectedClusters"></apolloclusterselector> </div> </div> </div> <div class="form-group" ng-show="type == 'create'"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.NamespaceName' | translate }} </label> <div class="col-sm-5" valdr-form-group> <div ng-class="{'input-group':appNamespace.isPublic && appendNamespacePrefix}"> <span class="input-group-addon" ng-show="appNamespace.isPublic && appendNamespacePrefix" ng-bind="appBaseInfo.namespacePrefix"></span> <input type="text" name="namespaceName" class="form-control" ng-model="appNamespace.name"> </div> </div> <!--public namespace can only be properties --> <div class="col-sm-2" ng-show="!appNamespace.isPublic"> <select class="form-control" name="format" ng-model="appNamespace.format"> <option value="properties">properties</option> <option value="xml">xml</option> <option value="json">json</option> <option value="yml">yml</option> <option value="yaml">yaml</option> <option value="txt">txt</option> </select> </div> &nbsp;&nbsp; <span ng-show="appNamespace.isPublic && appendNamespacePrefix" ng-bind="concatNamespace()" style="line-height: 34px;"></span> </div> <div class="form-group" ng-show="type == 'create' && appNamespace.isPublic"> <label class="col-sm-3 control-label"> {{'Namespace.AutoAddDepartmentPrefix' | translate }} </label> <div class="col-sm-6" valdr-form-group> <div> <label class="checkbox-inline"> <input type="checkbox" ng-model="appendNamespacePrefix" /> {{appBaseInfo.namespacePrefix}} </label> </div> <small>{{'Namespace.AutoAddDepartmentPrefixTips' | translate }}</small> </div> </div> <div class="form-group" ng-show="type == 'create' && (pageSetting.canAppAdminCreatePrivateNamespace || hasRootPermission)"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.NamespaceType' | translate }} </label> <div class="col-sm-4" valdr-form-group> <label class="radio-inline"> <input type="radio" name="namespaceType" value="true" ng-value="true" ng-model="appNamespace.isPublic"> {{'Namespace.NamespaceType.Public' | translate }} </label> <label class="radio-inline"> <input type="radio" name="namespaceType" value="false" ng-value="false" ng-model="appNamespace.isPublic"> {{'Namespace.NamespaceType.Private' | translate }} </label> </div> </div> <div class="form-group" ng-show="type == 'create'" valdr-form-group> <label class="col-sm-3 control-label">{{'Namespace.Remark' | translate }}</label> <div class="col-sm-7" valdr-form-group> <textarea class="form-control" rows="3" name="comment" ng-model="appNamespace.comment"></textarea> </div> </div> <div class="form-group" ng-show="type == 'link'"> <label class="col-sm-3 control-label"> <apollorequiredfield></apollorequiredfield> {{'Namespace.Namespace' | translate }} </label> <div class="col-sm-4" valdr-form-group> <select id="namespaces"> <option></option> </select> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-10"> <button type="submit" class="btn btn-primary" ng-disabled="(type == 'create' && namespaceForm.$invalid) || submitBtnDisabled"> {{'Common.Submit' | translate }} </button> </div> </div> </form> <div class="row text-center" ng-show="step == 2"> <img src="img/sync-succ.png" style="height: 100px; width: 100px"> <h3>{{'Common.Created' | translate }}</h3> </div> </div> </div> </div> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <!--directive--> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/controller/NamespaceController.js"></script> <script src="scripts/valdr.js" type="text/javascript"></script> </body> </html>
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/resources/static/system_info.html
<!doctype html> <html ng-app="system_info"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <title>{{'SystemInfo.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid" ng-controller="SystemInfoController"> <div class="col-md-10 col-md-offset-1 panel"> <section class="panel-body" ng-show="isRootUser"> <section class="row"> <h3>{{'SystemInfo.Title' | translate }} </h3> <h6 ng-show="systemInfo.version">{{'SystemInfo.SystemVersion' | translate }}: {{systemInfo.version}} </h6> <h6 translate="SystemInfo.Tips1" translate-value-server-config-url="server_config.html" translate-value-wiki-url="https://ctripcorp.github.io/apollo/#/zh/deployment/distributed-deployment-guide"> </h6> <h6 translate="SystemInfo.Tips2" translate-value-wiki-url="https://ctripcorp.github.io/apollo/#/zh/deployment/distributed-deployment-guide"> </h6> <div ng-repeat="env in systemInfo.environments"> <hr> <h4>{{'Common.Environment' | translate }}: {{env.env}} </h4> <h5>{{'SystemInfo.Active' | translate }}: {{env.active}} <span ng-show="env.active == false" style="color: #a94442;">{{'SystemInfo.ActiveTips' | translate }}</span> </h5> <h5>{{'SystemInfo.MetaServerAddress' | translate }}: {{env.metaServerAddress}}</h5> <div ng-show="env.errorMessage" ng-bind="env.errorMessage" class="alert alert-danger" role="alert"> </div> <h4 class="text-center">{{'SystemInfo.ConfigServices' | translate }}</h4> <table class="table table-striped table-hover table-bordered"> <thead> <tr> <th>{{'SystemInfo.ConfigServices.Name' | translate }}</th> <th>{{'SystemInfo.ConfigServices.InstanceId' | translate }}</th> <th>{{'SystemInfo.ConfigServices.HomePageUrl' | translate }}</th> <th>{{'SystemInfo.ConfigServices.CheckHealth' | translate }}</th> </tr> </thead> <tbody> <tr ng-show="(!env.configServices || env.configServices.length < 1)"> <td colspan="4">{{'SystemInfo.NoConfigServiceTips' | translate }}</td> </tr> <tr ng-show="env.configServices && env.configServices.length > 0" ng-repeat="service in env.configServices"> <td>{{service.appName}}</td> <td>{{service.instanceId}}</td> <td>{{service.homepageUrl}}</td> <td><a href="javascript:;" ng-click="check(service.instanceId, service.homepageUrl)">{{'SystemInfo.Check' | translate }}</a> </td> </tr> </tbody> </table> <h4 class="text-center">{{'SystemInfo.AdminServices' | translate }}</h4> <table class="table table-striped table-hover table-bordered"> <thead> <tr> <th>{{'SystemInfo.AdminServices.Name' | translate }}</th> <th>{{'SystemInfo.AdminServices.InstanceId' | translate }}</th> <th>{{'SystemInfo.AdminServices.HomePageUrl' | translate }}</th> <th>{{'SystemInfo.AdminServices.CheckHealth' | translate }}</th> </tr> </thead> <tbody> <tr ng-show="(!env.adminServices || env.adminServices.length < 1)"> <td colspan="4">{{'SystemInfo.NoAdminServiceTips' | translate }}</td> </tr> <tr ng-show="env.adminServices && env.adminServices.length > 0" ng-repeat="service in env.adminServices"> <td>{{service.appName}}</td> <td>{{service.instanceId}}</td> <td>{{service.homepageUrl}}</td> <td><a href="javascript:;" ng-click="check(service.instanceId, service.homepageUrl)">{{'SystemInfo.Check' | translate }}</a> </tr> </tbody> </table> </div> </section> </section> <section class="panel-body text-center" ng-if="!isRootUser"> <h4>{{'Common.IsRootUser' | translate }}</h4> </section> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-route.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!--valdr--> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/lodash.min.js"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/services/ClusterService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/SystemInfoService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <script type="application/javascript" src="scripts/PageCommon.js"></script> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/valdr.js"></script> <script type="application/javascript" src="scripts/controller/SystemInfoController.js"></script> </body> </html>
<!doctype html> <html ng-app="system_info"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <title>{{'SystemInfo.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid" ng-controller="SystemInfoController"> <div class="col-md-10 col-md-offset-1 panel"> <section class="panel-body" ng-show="isRootUser"> <section class="row"> <h3>{{'SystemInfo.Title' | translate }} </h3> <h6 ng-show="systemInfo.version">{{'SystemInfo.SystemVersion' | translate }}: {{systemInfo.version}} </h6> <h6 translate="SystemInfo.Tips1" translate-value-server-config-url="server_config.html" translate-value-wiki-url="https://www.apolloconfig.com/#/zh/deployment/distributed-deployment-guide"> </h6> <h6 translate="SystemInfo.Tips2" translate-value-wiki-url="https://www.apolloconfig.com/#/zh/deployment/distributed-deployment-guide"> </h6> <div ng-repeat="env in systemInfo.environments"> <hr> <h4>{{'Common.Environment' | translate }}: {{env.env}} </h4> <h5>{{'SystemInfo.Active' | translate }}: {{env.active}} <span ng-show="env.active == false" style="color: #a94442;">{{'SystemInfo.ActiveTips' | translate }}</span> </h5> <h5>{{'SystemInfo.MetaServerAddress' | translate }}: {{env.metaServerAddress}}</h5> <div ng-show="env.errorMessage" ng-bind="env.errorMessage" class="alert alert-danger" role="alert"> </div> <h4 class="text-center">{{'SystemInfo.ConfigServices' | translate }}</h4> <table class="table table-striped table-hover table-bordered"> <thead> <tr> <th>{{'SystemInfo.ConfigServices.Name' | translate }}</th> <th>{{'SystemInfo.ConfigServices.InstanceId' | translate }}</th> <th>{{'SystemInfo.ConfigServices.HomePageUrl' | translate }}</th> <th>{{'SystemInfo.ConfigServices.CheckHealth' | translate }}</th> </tr> </thead> <tbody> <tr ng-show="(!env.configServices || env.configServices.length < 1)"> <td colspan="4">{{'SystemInfo.NoConfigServiceTips' | translate }}</td> </tr> <tr ng-show="env.configServices && env.configServices.length > 0" ng-repeat="service in env.configServices"> <td>{{service.appName}}</td> <td>{{service.instanceId}}</td> <td>{{service.homepageUrl}}</td> <td><a href="javascript:;" ng-click="check(service.instanceId, service.homepageUrl)">{{'SystemInfo.Check' | translate }}</a> </td> </tr> </tbody> </table> <h4 class="text-center">{{'SystemInfo.AdminServices' | translate }}</h4> <table class="table table-striped table-hover table-bordered"> <thead> <tr> <th>{{'SystemInfo.AdminServices.Name' | translate }}</th> <th>{{'SystemInfo.AdminServices.InstanceId' | translate }}</th> <th>{{'SystemInfo.AdminServices.HomePageUrl' | translate }}</th> <th>{{'SystemInfo.AdminServices.CheckHealth' | translate }}</th> </tr> </thead> <tbody> <tr ng-show="(!env.adminServices || env.adminServices.length < 1)"> <td colspan="4">{{'SystemInfo.NoAdminServiceTips' | translate }}</td> </tr> <tr ng-show="env.adminServices && env.adminServices.length > 0" ng-repeat="service in env.adminServices"> <td>{{service.appName}}</td> <td>{{service.instanceId}}</td> <td>{{service.homepageUrl}}</td> <td><a href="javascript:;" ng-click="check(service.instanceId, service.homepageUrl)">{{'SystemInfo.Check' | translate }}</a> </tr> </tbody> </table> </div> </section> </section> <section class="panel-body text-center" ng-if="!isRootUser"> <h4>{{'Common.IsRootUser' | translate }}</h4> </section> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-route.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!--valdr--> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/lodash.min.js"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/services/ClusterService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/SystemInfoService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <script type="application/javascript" src="scripts/PageCommon.js"></script> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/valdr.js"></script> <script type="application/javascript" src="scripts/controller/SystemInfoController.js"></script> </body> </html>
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/en/README.md
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Introduction 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://ctripcorp.github.io/apollo/#/zh/design/apollo-introduction). For local demo purpose, please refer [Quick Start](https://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-guide) 2. [Java SDK User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/java-sdk-user-guide) 3. [.Net SDK user Guide](https://ctripcorp.github.io/apollo/#/zh/usage/dotnet-sdk-user-guide) 4. [Third Party SDK User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/third-party-sdks-user-guide) 5. [Other Language Client User Guide](https://ctripcorp.github.io/apollo/#/zh/usage/other-language-client-user-guide) 6. [Apollo Open APIs](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-open-api-platform) 7. [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo User Practices](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-practices) 9. [Apollo Security Best Practices](https://ctripcorp.github.io/apollo/#/zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design * [Apollo Design](https://ctripcorp.github.io/apollo/#/zh/design/apollo-design) * [Apollo Core Concept - Namespace](https://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/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://ctripcorp.github.io/apollo/#/zh/deployment/quick-start) * [Distributed Deployment Guide](https://ctripcorp.github.io/apollo/#/zh/deployment/distributed-deployment-guide) # Release Notes * [Releases](https://github.com/ctripcorp/apollo/releases) # FAQ * [FAQ](https://ctripcorp.github.io/apollo/#/zh/faq/faq) * [Common Issues in Deployment & Development Phase](https://ctripcorp.github.io/apollo/#/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) # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE).
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Introduction 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](zh/design/apollo-introduction). For local demo purpose, please refer [Quick Start](zh/deployment/quick-start). Demo Environment: - [http://106.54.227.205](http://106.54.227.205/) - User/Password: apollo/admin # Screenshots ![Screenshot](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](zh/usage/apollo-user-guide) 2. [Java SDK User Guide](zh/usage/java-sdk-user-guide) 3. [.Net SDK user Guide](zh/usage/dotnet-sdk-user-guide) 4. [Third Party SDK User Guide](zh/usage/third-party-sdks-user-guide) 5. [Other Language Client User Guide](zh/usage/other-language-client-user-guide) 6. [Apollo Open APIs](zh/usage/apollo-open-api-platform) 7. [Apollo Use Cases](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo User Practices](zh/usage/apollo-user-practices) 9. [Apollo Security Best Practices](zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design * [Apollo Design](zh/design/apollo-design) * [Apollo Core Concept - Namespace](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](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](zh/deployment/quick-start) * [Distributed Deployment Guide](zh/deployment/distributed-deployment-guide) # Release Notes * [Releases](https://github.com/ctripcorp/apollo/releases) # FAQ * [FAQ](zh/faq/faq) * [Common Issues in Deployment & Development Phase](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) # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE).
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/README.md
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Introduction Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。 服务端基于Spring Boot和Spring Cloud开发,打包后可以直接运行,不需要额外安装Tomcat等应用容器。 Java客户端不依赖任何框架,能够运行于所有Java运行时环境,同时对Spring/Spring Boot环境也有较好的支持。 .Net客户端不依赖任何框架,能够运行于所有.Net运行时环境。 更多产品介绍参见[Apollo配置中心介绍](zh/design/apollo-introduction) 本地快速部署请参见[Quick Start](zh/deployment/quick-start) 演示环境(Demo): - [106.54.227.205](http://106.54.227.205/) - 账号/密码:apollo/admin > 如访问github速度缓慢,可以访问[gitee镜像](https://gitee.com/nobodyiam/apollo),不定期同步 # Screenshots ![配置界面](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.jpg) # Features * **统一管理不同环境、不同集群的配置** * Apollo提供了一个统一界面集中式管理不同环境(environment)、不同集群(cluster)、不同命名空间(namespace)的配置。 * 同一份代码部署在不同的集群,可以有不同的配置,比如zk的地址等 * 通过命名空间(namespace)可以很方便的支持多个不同应用共享同一份配置,同时还允许应用对共享的配置进行覆盖 * 配置界面支持多语言(中文,English) * **配置修改实时生效(热发布)** * 用户在Apollo修改完配置并发布后,客户端能实时(1秒)接收到最新的配置,并通知到应用程序。 * **版本发布管理** * 所有的配置发布都有版本概念,从而可以方便的支持配置的回滚。 * **灰度发布** * 支持配置的灰度发布,比如点了发布后,只对部分应用实例生效,等观察一段时间没问题后再推给所有应用实例。 * **权限管理、发布审核、操作审计** * 应用和配置的管理都有完善的权限管理机制,对配置的管理还分为了编辑和发布两个环节,从而减少人为的错误。 * 所有的操作都有审计日志,可以方便的追踪问题。 * **客户端配置信息监控** * 可以方便的看到配置在被哪些实例使用 * **提供Java和.Net原生客户端** * 提供了Java和.Net的原生客户端,方便应用集成 * 支持Spring Placeholder,Annotation和Spring Boot的ConfigurationProperties,方便应用使用(需要Spring 3.1.1+) * 同时提供了Http接口,非Java和.Net应用也可以方便的使用 * **提供开放平台API** * Apollo自身提供了比较完善的统一配置管理界面,支持多环境、多数据中心配置管理、权限、流程治理等特性。 * 不过Apollo出于通用性考虑,对配置的修改不会做过多限制,只要符合基本的格式就能够保存。 * 在我们的调研中发现,对于有些使用方,它们的配置可能会有比较复杂的格式,如xml, json,需要对格式做校验。 * 还有一些使用方如DAL,不仅有特定的格式,而且对输入的值也需要进行校验后方可保存,如检查数据库、用户名和密码是否匹配。 * 对于这类应用,Apollo支持应用方通过开放接口在Apollo进行配置的修改和发布,并且具备完善的授权和权限控制 * **部署简单** * 配置中心作为基础服务,可用性要求非常高,这就要求Apollo对外部依赖尽可能地少 * 目前唯一的外部依赖是MySQL,所以部署非常简单,只要安装好Java和MySQL就可以让Apollo跑起来 * Apollo还提供了打包脚本,一键就可以生成所有需要的安装包,并且支持自定义运行时参数 # Usage 1. [应用接入指南](zh/usage/apollo-user-guide) 2. [Java客户端使用指南](zh/usage/java-sdk-user-guide) 3. [.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide) 4. [其它语言客户端接入指南](zh/usage/other-language-client-user-guide) 5. [Apollo开放平台接入指南](zh/usage/apollo-open-api-platform) 6. [Apollo使用场景和示例代码](https://github.com/ctripcorp/apollo-use-cases) 7. [Apollo实践案例](zh/usage/apollo-user-practices) 8. [Apollo安全相关最佳实践](zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design - [Apollo配置中心设计](zh/design/apollo-design.md) - [Apollo配置中心介绍](zh/design/apollo-introduction.md) - [Apollo核心概念之“Namespace”](zh/design/apollo-core-concept-namespace.md) - [Apollo源码解析](http://www.iocoder.cn/categories/Apollo/)(据说Apollo非常适合作为初学者第一个通读源码学习的分布式中间件产品) # Development - [Apollo开发指南](zh/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实现用户登录功能](zh/development/portal-how-to-implement-user-login-function.md) - [Portal接入邮件服务](zh/development/portal-how-to-enable-email-service.md) - [Portal启用webhook通知](zh/development/portal-how-to-enable-webhook-notification.md) # Deployment - [Quick Start](zh/deployment/quick-start.md) - [Docker方式部署Quick Start](zh/deployment/quick-start-docker.md) - [分布式部署指南](zh/deployment/distributed-deployment-guide.md) # Release Notes * [版本发布历史](https://github.com/ctripcorp/apollo/releases) # FAQ * [常见问题回答](zh/faq/faq.md) * [部署&开发遇到的常见问题](zh/faq/common-issues-in-deployment-and-development-phase.md) # Presentation * [携程开源配置中心Apollo的设计与实现](http://www.itdks.com/dakalive/detail/3420) * [Slides](https://myslide.cn/slides/10168) * [配置中心,让微服务更『智能』](https://2018.qconshanghai.com/presentation/799) * [Slides](https://myslide.cn/slides/10035) # Publication * [开源配置中心Apollo的设计与实现](https://www.infoq.cn/article/open-source-configuration-center-apollo) * [配置中心,让微服务更『智能』](https://mp.weixin.qq.com/s/iDmYJre_ULEIxuliu1EbIQ) # Support <table> <thead> <th>Apollo技术支持②群<br />群号:904287263(未满)</th> <th>Apollo技术支持⑤群<br />群号:914839843(已满)</th> <th>Apollo技术支持④群<br />群号:516773934(已满)</th> <th>Apollo技术支持③群<br />群号:742035428(已满)</th> <th>Apollo技术支持①群<br />群号:375526581(已满)</th> </thead> <tbody> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-2.png" alt="tech-support-qq-2"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-5.png" alt="tech-support-qq-5"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-4.png" alt="tech-support-qq-4"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-3.png" alt="tech-support-qq-3"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-1.png" alt="tech-support-qq-1"></td> </tr> </tbody> </table> # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE).
<img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/logo/logo-simple.png" alt="apollo-logo" width="40%"> # Introduction Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。 服务端基于Spring Boot和Spring Cloud开发,打包后可以直接运行,不需要额外安装Tomcat等应用容器。 Java客户端不依赖任何框架,能够运行于所有Java运行时环境,同时对Spring/Spring Boot环境也有较好的支持。 .Net客户端不依赖任何框架,能够运行于所有.Net运行时环境。 更多产品介绍参见[Apollo配置中心介绍](zh/design/apollo-introduction) 本地快速部署请参见[Quick Start](zh/deployment/quick-start) 演示环境(Demo): - [http://106.54.227.205](http://106.54.227.205/) - 账号/密码:apollo/admin > 如访问github速度缓慢,可以访问[gitee镜像](https://gitee.com/nobodyiam/apollo),不定期同步 # Screenshots ![配置界面](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.jpg) # Features * **统一管理不同环境、不同集群的配置** * Apollo提供了一个统一界面集中式管理不同环境(environment)、不同集群(cluster)、不同命名空间(namespace)的配置。 * 同一份代码部署在不同的集群,可以有不同的配置,比如zk的地址等 * 通过命名空间(namespace)可以很方便的支持多个不同应用共享同一份配置,同时还允许应用对共享的配置进行覆盖 * 配置界面支持多语言(中文,English) * **配置修改实时生效(热发布)** * 用户在Apollo修改完配置并发布后,客户端能实时(1秒)接收到最新的配置,并通知到应用程序。 * **版本发布管理** * 所有的配置发布都有版本概念,从而可以方便的支持配置的回滚。 * **灰度发布** * 支持配置的灰度发布,比如点了发布后,只对部分应用实例生效,等观察一段时间没问题后再推给所有应用实例。 * **权限管理、发布审核、操作审计** * 应用和配置的管理都有完善的权限管理机制,对配置的管理还分为了编辑和发布两个环节,从而减少人为的错误。 * 所有的操作都有审计日志,可以方便的追踪问题。 * **客户端配置信息监控** * 可以方便的看到配置在被哪些实例使用 * **提供Java和.Net原生客户端** * 提供了Java和.Net的原生客户端,方便应用集成 * 支持Spring Placeholder,Annotation和Spring Boot的ConfigurationProperties,方便应用使用(需要Spring 3.1.1+) * 同时提供了Http接口,非Java和.Net应用也可以方便的使用 * **提供开放平台API** * Apollo自身提供了比较完善的统一配置管理界面,支持多环境、多数据中心配置管理、权限、流程治理等特性。 * 不过Apollo出于通用性考虑,对配置的修改不会做过多限制,只要符合基本的格式就能够保存。 * 在我们的调研中发现,对于有些使用方,它们的配置可能会有比较复杂的格式,如xml, json,需要对格式做校验。 * 还有一些使用方如DAL,不仅有特定的格式,而且对输入的值也需要进行校验后方可保存,如检查数据库、用户名和密码是否匹配。 * 对于这类应用,Apollo支持应用方通过开放接口在Apollo进行配置的修改和发布,并且具备完善的授权和权限控制 * **部署简单** * 配置中心作为基础服务,可用性要求非常高,这就要求Apollo对外部依赖尽可能地少 * 目前唯一的外部依赖是MySQL,所以部署非常简单,只要安装好Java和MySQL就可以让Apollo跑起来 * Apollo还提供了打包脚本,一键就可以生成所有需要的安装包,并且支持自定义运行时参数 # Usage 1. [应用接入指南](zh/usage/apollo-user-guide) 2. [Java客户端使用指南](zh/usage/java-sdk-user-guide) 3. [.Net客户端使用指南](zh/usage/dotnet-sdk-user-guide) 4. [Go、Python、NodeJS、PHP等客户端使用指南](zh/usage/third-party-sdks-user-guide) 5. [其它语言客户端接入指南](zh/usage/other-language-client-user-guide) 6. [Apollo开放平台接入指南](zh/usage/apollo-open-api-platform) 7. [Apollo使用场景和示例代码](https://github.com/ctripcorp/apollo-use-cases) 8. [Apollo实践案例](zh/usage/apollo-user-practices) 9. [Apollo安全相关最佳实践](zh/usage/apollo-user-guide?id=_71-%e5%ae%89%e5%85%a8%e7%9b%b8%e5%85%b3) # Design - [Apollo配置中心设计](zh/design/apollo-design.md) - [Apollo配置中心介绍](zh/design/apollo-introduction.md) - [Apollo核心概念之“Namespace”](zh/design/apollo-core-concept-namespace.md) - [Apollo源码解析](http://www.iocoder.cn/categories/Apollo/)(据说Apollo非常适合作为初学者第一个通读源码学习的分布式中间件产品) # Development - [Apollo开发指南](zh/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实现用户登录功能](zh/development/portal-how-to-implement-user-login-function.md) - [Portal接入邮件服务](zh/development/portal-how-to-enable-email-service.md) - [Portal启用webhook通知](zh/development/portal-how-to-enable-webhook-notification.md) # Deployment - [Quick Start](zh/deployment/quick-start.md) - [Docker方式部署Quick Start](zh/deployment/quick-start-docker.md) - [分布式部署指南](zh/deployment/distributed-deployment-guide.md) # Release Notes * [版本发布历史](https://github.com/ctripcorp/apollo/releases) # FAQ * [常见问题回答](zh/faq/faq.md) * [部署&开发遇到的常见问题](zh/faq/common-issues-in-deployment-and-development-phase.md) # Presentation * [携程开源配置中心Apollo的设计与实现](http://www.itdks.com/dakalive/detail/3420) * [Slides](https://myslide.cn/slides/10168) * [配置中心,让微服务更『智能』](https://2018.qconshanghai.com/presentation/799) * [Slides](https://myslide.cn/slides/10035) # Publication * [开源配置中心Apollo的设计与实现](https://www.infoq.cn/article/open-source-configuration-center-apollo) * [配置中心,让微服务更『智能』](https://mp.weixin.qq.com/s/iDmYJre_ULEIxuliu1EbIQ) # Support <table> <thead> <th>Apollo技术支持②群<br />群号:904287263(未满)</th> <th>Apollo技术支持⑤群<br />群号:914839843(已满)</th> <th>Apollo技术支持④群<br />群号:516773934(已满)</th> <th>Apollo技术支持③群<br />群号:742035428(已满)</th> <th>Apollo技术支持①群<br />群号:375526581(已满)</th> </thead> <tbody> <tr> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-2.png" alt="tech-support-qq-2"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-5.png" alt="tech-support-qq-5"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-4.png" alt="tech-support-qq-4"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-3.png" alt="tech-support-qq-3"></td> <td><img src="https://raw.githubusercontent.com/ctripcorp/apollo-community/master/images/tech-support/tech-support-qq-1.png" alt="tech-support-qq-1"></td> </tr> </tbody> </table> # Contribution Please make sure to read the [Contributing Guide](https://github.com/ctripcorp/apollo/blob/master/CONTRIBUTING.md) before making a pull request. Thanks for all the people who contributed to Apollo! <a href="https://github.com/ctripcorp/apollo/graphs/contributors"><img src="https://opencollective.com/apollo/contributors.svg?width=880&button=false" /></a> # License The project is licensed under the [Apache 2 license](https://github.com/ctripcorp/apollo/blob/master/LICENSE).
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/deployment/distributed-deployment-guide.md
本文档介绍了如何按照分布式部署的方式编译、打包、部署Apollo配置中心,从而可以在开发、测试、生产等环境分别部署运行。 > 如果只是需要在本地快速部署试用Apollo的话,可以参考[Quick Start](zh/deployment/quick-start) # &nbsp; # 一、准备工作 ## 1.1 运行时环境 ### 1.1.1 OS 服务端基于Spring Boot,启动脚本理论上支持所有Linux发行版,建议[CentOS 7](https://www.centos.org/)。 ### 1.1.2 Java * Apollo服务端:1.8+ * Apollo客户端:1.7+ 由于需要同时运行服务端和客户端,所以建议安装Java 1.8+。 >对于Apollo客户端,运行时环境只需要1.7+即可。 >注:对于Apollo客户端,如果有需要的话,可以做少量代码修改来降级到Java 1.6,详细信息可以参考[Issue 483](https://github.com/ctripcorp/apollo/issues/483) 在配置好后,可以通过如下命令检查: ```sh java -version ``` 样例输出: ```sh java version "1.8.0_74" Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode) ``` ## 1.2 MySQL * 版本要求:5.6.5+ Apollo的表结构对`timestamp`使用了多个default声明,所以需要5.6.5以上版本。 连接上MySQL后,可以通过如下命令检查: ```sql SHOW VARIABLES WHERE Variable_name = 'version'; ``` | Variable_name | Value | |---------------|--------| | version | 5.7.11 | > 注1:MySQL版本可以降级到5.5,详见[mysql 依赖降级讨论](https://github.com/ctripcorp/apollo/issues/481)。 > 注2:如果希望使用Oracle的话,可以参考[vanpersl](https://github.com/vanpersl)在Apollo 0.8.0基础上开发的[Oracle适配代码](https://github.com/ctripcorp/apollo/compare/v0.8.0...vanpersl:db-oracle),Oracle版本为10.2.0.1.0。 > 注3:如果希望使用Postgres的话,可以参考[oaksharks](https://github.com/oaksharks)在Apollo 0.9.1基础上开发的[Pg适配代码](https://github.com/oaksharks/apollo/compare/ac10768ee2e11c488523ca0e845984f6f71499ac...oaksharks:pg),Postgres的版本为9.3.20,也可以参考[xiao0yy](https://github.com/xiao0yy)在Apollo 0.10.2基础上开发的[Pg适配代码](https://github.com/ctripcorp/apollo/issues/1293),Postgres的版本为9.5。 ## 1.3 环境 分布式部署需要事先确定部署的环境以及部署方式。 Apollo目前支持以下环境: * DEV * 开发环境 * FAT * 测试环境,相当于alpha环境(功能测试) * UAT * 集成环境,相当于beta环境(回归测试) * PRO * 生产环境 > 如果希望添加自定义的环境名称,具体步骤可以参考[Portal如何增加环境](zh/faq/common-issues-in-deployment-and-development-phase?id=_4-portal如何增加环境?) 以ctrip为例,我们的部署策略如下: ![Deployment](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-deployment.png) * Portal部署在生产环境的机房,通过它来直接管理FAT、UAT、PRO等环境的配置 * Meta Server、Config Service和Admin Service在每个环境都单独部署,使用独立的数据库 * Meta Server、Config Service和Admin Service在生产环境部署在两个机房,实现双活 * Meta Server和Config Service部署在同一个JVM进程内,Admin Service部署在同一台服务器的另一个JVM进程内 另外也可以参考下[@lyliyongblue](https://github.com/lyliyongblue) 贡献的样例部署图(建议右键新窗口打开看大图): ![Deployment](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/lyliyongblue-apollo-deployment.png) ## 1.4 网络策略 分布式部署的时候,`apollo-configservice`和`apollo-adminservice`需要把自己的IP和端口注册到Meta Server(apollo-configservice本身)。 Apollo客户端和Portal会从Meta Server获取服务的地址(IP+端口),然后通过服务地址直接访问。 需要注意的是,`apollo-configservice`和`apollo-adminservice`是基于内网可信网络设计的,所以出于安全考虑,**请不要将`apollo-configservice`和`apollo-adminservice`直接暴露在公网**。 所以如果实际部署的机器有多块网卡(如docker),或者存在某些网卡的IP是Apollo客户端和Portal无法访问的(如网络安全限制),那么我们就需要在`apollo-configservice`和`apollo-adminservice`中做相关配置来解决连通性问题。 ### 1.4.1 忽略某些网卡 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会把`docker0`和`veth`开头的网卡在注册到Eureka时忽略掉。 JVM System Property示例: ```properties -Dspring.cloud.inetutils.ignoredInterfaces[0]=docker0 -Dspring.cloud.inetutils.ignoredInterfaces[1]=veth.* ``` OS Environment Variable示例: ```properties SPRING_CLOUD_INETUTILS_IGNORED_INTERFACES[0]=docker0 SPRING_CLOUD_INETUTILS_IGNORED_INTERFACES[1]=veth.* ``` ### 1.4.2 指定要注册的IP 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会指定注册的IP为`1.2.3.4`。 JVM System Property示例: ```properties -Deureka.instance.ip-address=1.2.3.4 ``` OS Environment Variable示例: ```properties EUREKA_INSTANCE_IP_ADDRESS=1.2.3.4 ``` ### 1.4.3 指定要注册的URL 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会指定注册的URL为`http://1.2.3.4:8080`。 JVM System Property示例: ```properties -Deureka.instance.homePageUrl=http://1.2.3.4:8080 -Deureka.instance.preferIpAddress=false ``` OS Environment Variable示例: ```properties EUREKA_INSTANCE_HOME_PAGE_URL=http://1.2.3.4:8080 EUREKA_INSTANCE_PREFER_IP_ADDRESS=false ``` ### 1.4.4 直接指定apollo-configservice地址 如果Apollo部署在公有云上,本地开发环境无法连接,但又需要做开发测试的话,客户端可以升级到0.11.0版本及以上,然后配置[跳过Apollo Meta Server服务发现](zh/usage/java-sdk-user-guide#_1222-跳过apollo-meta-server服务发现) # 二、部署步骤 部署步骤总体还是比较简单的,Apollo的唯一依赖是数据库,所以需要首先把数据库准备好,然后根据实际情况,选择不同的部署方式: > [@lingjiaju](https://github.com/lingjiaju)录制了一系列Apollo快速上手视频,如果看文档觉得略繁琐的话,不妨可以先看一下他的[视频教程](https://pan.baidu.com/s/1blv87EOZS77NWT8Amkijkw#list/path=%2F)。 > 如果部署过程中遇到了问题,可以参考[部署&开发遇到的常见问题](zh/faq/common-issues-in-deployment-and-development-phase),一般都能找到答案。 ## 2.1 创建数据库 Apollo服务端共需要两个数据库:`ApolloPortalDB`和`ApolloConfigDB`,我们把数据库、表的创建和样例数据都分别准备了sql文件,只需要导入数据库即可。 需要注意的是ApolloPortalDB只需要在生产环境部署一个即可,而ApolloConfigDB需要在每个环境部署一套,如fat、uat和pro分别部署3套ApolloConfigDB。 > 注意:如果你本地已经创建过Apollo数据库,请注意备份数据。我们准备的sql文件会清空Apollo相关的表。 ### 2.1.1 创建ApolloPortalDB 可以根据实际情况选择通过手动导入SQL或是通过[Flyway](https://flywaydb.org/)自动导入SQL创建。 #### 2.1.1.1 手动导入SQL创建 通过各种MySQL客户端导入[apolloportaldb.sql](https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloportaldb.sql)即可。 以MySQL原生客户端为例: ```sql source /your_local_path/scripts/sql/apolloportaldb.sql ``` #### 2.1.1.2 通过Flyway导入SQL创建 > 需要1.3.0及以上版本 1. 根据实际情况修改[flyway-portaldb.properties](https://github.com/ctripcorp/apollo/blob/master/scripts/flyway/flyway-portaldb.properties)中的`flyway.user`、`flyway.password`和`flyway.url`配置 2. 在apollo项目根目录下执行`mvn -N -Pportaldb flyway:migrate` #### 2.1.1.3 验证 导入成功后,可以通过执行以下sql语句来验证: ```sql select `Id`, `Key`, `Value`, `Comment` from `ApolloPortalDB`.`ServerConfig` limit 1; ``` | Id | Key | Value | Comment | |----|--------------------|-------|------------------| | 1 | apollo.portal.envs | dev | 可支持的环境列表 | > 注:ApolloPortalDB只需要在生产环境部署一个即可 ### 2.1.2 创建ApolloConfigDB 可以根据实际情况选择通过手动导入SQL或是通过[Flyway](https://flywaydb.org/)自动导入SQL创建。 #### 2.1.2.1 手动导入SQL 通过各种MySQL客户端导入[apolloconfigdb.sql](https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloconfigdb.sql)即可。 以MySQL原生客户端为例: ```sql source /your_local_path/scripts/sql/apolloconfigdb.sql ``` #### 2.1.2.2 通过Flyway导入SQL > 需要1.3.0及以上版本 1. 根据实际情况修改[flyway-configdb.properties](https://github.com/ctripcorp/apollo/blob/master/scripts/flyway/flyway-configdb.properties)中的`flyway.user`、`flyway.password`和`flyway.url`配置 2. 在apollo项目根目录下执行`mvn -N -Pconfigdb flyway:migrate` #### 2.1.2.3 验证 导入成功后,可以通过执行以下sql语句来验证: ```sql select `Id`, `Key`, `Value`, `Comment` from `ApolloConfigDB`.`ServerConfig` limit 1; ``` | Id | Key | Value | Comment | |----|--------------------|-------------------------------|---------------| | 1 | eureka.service.url | http://127.0.0.1:8080/eureka/ | Eureka服务Url | > 注:ApolloConfigDB需要在每个环境部署一套,如fat、uat和pro分别部署3套ApolloConfigDB #### 2.1.2.4 从别的环境导入ApolloConfigDB的项目数据 如果是全新部署的Apollo配置中心,请忽略此步。 如果不是全新部署的Apollo配置中心,比如已经使用了一段时间,这时在Apollo配置中心已经创建了不少项目以及namespace等,那么在新环境中的ApolloConfigDB中需要从其它正常运行的环境中导入必要的项目数据。 主要涉及ApolloConfigDB的下面4张表,下面同时附上需要导入的数据查询语句: 1. App * 导入全部的App * 如:insert into `新环境的ApolloConfigDB`.`App` select * from `其它环境的ApolloConfigDB`.`App` where `IsDeleted` = 0; 2. AppNamespace * 导入全部的AppNamespace * 如:insert into `新环境的ApolloConfigDB`.`AppNamespace` select * from `其它环境的ApolloConfigDB`.`AppNamespace` where `IsDeleted` = 0; 3. Cluster * 导入默认的default集群 * 如:insert into `新环境的ApolloConfigDB`.`Cluster` select * from `其它环境的ApolloConfigDB`.`Cluster` where `Name` = 'default' and `IsDeleted` = 0; 4. Namespace * 导入默认的default集群中的namespace * 如:insert into `新环境的ApolloConfigDB`.`Namespace` select * from `其它环境的ApolloConfigDB`.`Namespace` where `ClusterName` = 'default' and `IsDeleted` = 0; 同时也别忘了通知用户在新的环境给自己的项目设置正确的配置信息,尤其是一些影响面比较大的公共namespace配置。 > 如果是为正在运行的环境迁移数据,建议迁移完重启一下config service,因为config service中有appnamespace的缓存数据 ### 2.1.3 调整服务端配置 Apollo自身的一些配置是放在数据库里面的,所以需要针对实际情况做一些调整,具体参数说明请参考[三、服务端配置说明](#三、服务端配置说明)。 大部分配置可以先使用默认值,不过 [apollo.portal.envs](#_311-apolloportalenvs-可支持的环境列表) 和 [eureka.service.url](#_321-eurekaserviceurl-eureka服务url) 请务必配置正确后再进行下面的部署步骤。 ## 2.2 虚拟机/物理机部署 ### 2.2.1 获取安装包 可以通过两种方式获取安装包: 1. 直接下载安装包 * 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载预先打好的安装包 * 如果对Apollo的代码没有定制需求,建议使用这种方式,可以省去本地打包的过程 2. 通过源码构建 * 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载Source code包或直接clone[源码](https://github.com/ctripcorp/apollo)后在本地构建 * 如果需要对Apollo的做定制开发,需要使用这种方式 #### 2.2.1.1 直接下载安装包 ##### 2.2.1.1.1 获取apollo-configservice、apollo-adminservice、apollo-portal安装包 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载最新版本的`apollo-configservice-x.x.x-github.zip`、`apollo-adminservice-x.x.x-github.zip`和`apollo-portal-x.x.x-github.zip`即可。 ##### 2.2.1.1.2 配置数据库连接信息 Apollo服务端需要知道如何连接到你前面创建的数据库,数据库连接串信息位于上一步下载的压缩包中的`config/application-github.properties`中。 ###### 2.2.1.1.2.1 配置apollo-configservice的数据库连接信息 1. 解压`apollo-configservice-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloConfigDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境config-service需要配置对应环境的数据库参数 ###### 2.2.1.1.2.2 配置apollo-adminservice的数据库连接信息 1. 解压`apollo-adminservice-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloConfigDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境admin-service需要配置对应环境的数据库参数 ###### 2.2.1.1.2.3 配置apollo-portal的数据库连接信息 1. 解压`apollo-portal-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloPortalDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` ###### 2.2.1.1.2.4 配置apollo-portal的meta service信息 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以我们需要在配置中提供这些信息。默认情况下,meta service和config service是部署在同一个JVM进程,所以meta service的地址就是config service的地址。 > 对于1.6.0及以上版本,可以通过ApolloPortalDB.ServerConfig中的配置项来配置Meta Service地址,详见[apollo.portal.meta.servers - 各环境Meta Service列表](#_312-apolloportalmetaservers-各环境meta-service列表) 使用程序员专用编辑器(如vim,notepad++,sublime等)打开`apollo-portal-x.x.x-github.zip`中`config`目录下的`apollo-env.properties`文件。 假设DEV的apollo-configservice未绑定域名,地址是1.1.1.1:8080,FAT的apollo-configservice绑定了域名apollo.fat.xxx.com,UAT的apollo-configservice绑定了域名apollo.uat.xxx.com,PRO的apollo-configservice绑定了域名apollo.xxx.com,那么可以如下修改各环境meta service服务地址,格式为`${env}.meta=http://${config-service-url:port}`,如果某个环境不需要,也可以直接删除对应的配置项(如lpt.meta): ```sh 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 ``` 除了通过`apollo-env.properties`方式配置meta service以外,apollo也支持在运行时指定meta service(优先级比`apollo-env.properties`高): 1. 通过Java System Property `${env}_meta` * 可以通过Java的System Property `${env}_meta`来指定 * 如`java -Ddev_meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("dev_meta", "http://config-service-url");` 2. 通过操作系统的System Environment`${ENV}_META` * 如`DEV_META=http://config-service-url` * 注意key为全大写,且中间是`_`分隔 >注1: 为了实现meta service的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡 >注2: meta service地址也可以填入IP,0.11.0版本之前只支持填入一个IP。从0.11.0版本开始支持填入以逗号分隔的多个地址([PR #1214](https://github.com/ctripcorp/apollo/pull/1214)),如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 #### 2.2.1.2 通过源码构建 ##### 2.2.1.2.1 配置数据库连接信息 Apollo服务端需要知道如何连接到你前面创建的数据库,所以需要编辑[scripts/build.sh](https://github.com/ctripcorp/apollo/blob/master/scripts/build.sh),修改ApolloPortalDB和ApolloConfigDB相关的数据库连接串信息。 > 注意:填入的用户需要具备对ApolloPortalDB和ApolloConfigDB数据的读写权限。 ```sh #apollo config db info apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 apollo_config_db_username=用户名 apollo_config_db_password=密码(如果没有密码,留空即可) # apollo portal db info apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?useSSL=false&characterEncoding=utf8 apollo_portal_db_username=用户名 apollo_portal_db_password=密码(如果没有密码,留空即可) ``` > 注1:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境config-service和admin-service需要使用不同的数据库参数打不同的包,portal只需要打一次包即可 > 注2:如果不想config-service和admin-service每个环境打一个包的话,也可以通过运行时传入数据库连接串信息实现,具体可以参考 [Issue 869](https://github.com/ctripcorp/apollo/issues/869) > 注3:每个环境都需要独立部署一套config-service、admin-service和ApolloConfigDB ##### 2.2.1.2.2 配置各环境meta service地址 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以需要在打包时提供这些信息。 假设DEV的apollo-configservice未绑定域名,地址是1.1.1.1:8080,FAT的apollo-configservice绑定了域名apollo.fat.xxx.com,UAT的apollo-configservice绑定了域名apollo.uat.xxx.com,PRO的apollo-configservice绑定了域名apollo.xxx.com,那么编辑[scripts/build.sh](https://github.com/ctripcorp/apollo/blob/master/scripts/build.sh),如下修改各环境meta service服务地址,格式为`${env}_meta=http://${config-service-url:port}`,如果某个环境不需要,也可以直接删除对应的配置项: ```sh 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_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta" ``` 除了在打包时配置meta service以外,apollo也支持在运行时指定meta service: 1. 通过Java System Property `${env}_meta` * 可以通过Java的System Property `${env}_meta`来指定 * 如`java -Ddev_meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("dev_meta", "http://config-service-url");` 2. 通过操作系统的System Environment`${ENV}_META` * 如`DEV_META=http://config-service-url` * 注意key为全大写,且中间是`_`分隔 >注1: 为了实现meta service的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡 >注2: meta service地址也可以填入IP,0.11.0版本之前只支持填入一个IP。从0.11.0版本开始支持填入以逗号分隔的多个地址([PR #1214](https://github.com/ctripcorp/apollo/pull/1214)),如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 ##### 2.2.1.2.3 执行编译、打包 做完上述配置后,就可以执行编译和打包了。 > 注:初次编译会从Maven中央仓库下载不少依赖,如果网络情况不佳时很容易出错,建议使用国内的Maven仓库源,比如[阿里云Maven镜像](http://www.cnblogs.com/geektown/p/5705405.html) ```sh ./build.sh ``` 该脚本会依次打包apollo-configservice, apollo-adminservice, apollo-portal。 > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同环境的config-service和admin-service需要使用不同的数据库连接信息打不同的包,portal只需要打一次包即可 ##### 2.2.1.2.4 获取apollo-configservice安装包 位于`apollo-configservice/target/`目录下的`apollo-configservice-x.x.x-github.zip` 需要注意的是由于ApolloConfigDB在每个环境都有部署,所以对不同环境的config-service需要使用不同的数据库参数打不同的包后分别部署 ##### 2.2.1.2.5 获取apollo-adminservice安装包 位于`apollo-adminservice/target/`目录下的`apollo-adminservice-x.x.x-github.zip` 需要注意的是由于ApolloConfigDB在每个环境都有部署,所以对不同环境的admin-service需要使用不同的数据库参数打不同的包后分别部署 ##### 2.2.1.2.6 获取apollo-portal安装包 位于`apollo-portal/target/`目录下的`apollo-portal-x.x.x-github.zip` ##### 2.2.1.2.7 启用外部nacos服务注册中心替换内置eureka 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell mvn clean package -Pgithub,nacos-discovery -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,nacos-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password ``` 2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置nacos服务器地址 ```properties nacos.discovery.server-addr=127.0.0.1:8848 ``` ##### 2.2.1.2.8 启用外部Consul服务注册中心替换内置eureka 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,consul-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password ``` 2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置consul服务器地址 ```properties spring.cloud.consul.host=127.0.0.1 spring.cloud.consul.port=8500 ``` ### 2.2.2 部署Apollo服务端 #### 2.2.2.1 部署apollo-configservice 将对应环境的`apollo-configservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-configservice.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。另外apollo-configservice同时承担meta server职责,如果要修改端口,注意要同时ApolloConfigDB.ServerConfig表中的`eureka.service.url`配置项以及apollo-portal和apollo-client中的使用到的meta server信息,详见:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)和[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 > 注4:如果ApolloConfigDB.ServerConfig的eureka.service.url只配了当前正在启动的机器的话,在启动apollo-configservice的过程中会在日志中输出eureka注册失败的信息,如`com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused`。需要注意的是,这个是预期的情况,因为apollo-configservice需要向Meta Server(它自己)注册服务,但是因为在启动过程中,自己还没起来,所以会报这个错。后面会进行重试的动作,所以等自己服务起来后就会注册正常了。 > 注5:如果你看到了这里,相信你一定是一个细心阅读文档的人,而且离成功就差一点点了,继续加油,应该很快就能完成Apollo的分布式部署了!不过你是否有感觉Apollo的分布式部署步骤有点繁琐?是否有啥建议想要和作者说?如果答案是肯定的话,请移步 [#1424](https://github.com/ctripcorp/apollo/issues/1424),期待你的建议! #### 2.2.2.2 部署apollo-adminservice 将对应环境的`apollo-adminservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-adminservice.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 #### 2.2.2.3 部署apollo-portal 将`apollo-portal-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-portal.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 ## 2.3 Docker部署 ### 2.3.1 1.7.0及以上版本 Apollo 1.7.0版本开始会默认上传Docker镜像到[Docker Hub](https://hub.docker.com/u/apolloconfig),可以按照如下步骤获取 #### 2.3.1.1 Apollo Config Service ##### 2.3.1.1.1 获取镜像 ```bash docker pull apolloconfig/apollo-configservice:${version} ``` ##### 2.3.1.1.2 运行镜像 示例: ```bash 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:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloConfigDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloConfigDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloConfigDB的密码 #### 2.3.1.2 Apollo Admin Service ##### 2.3.1.2.1 获取镜像 ```bash docker pull apolloconfig/apollo-adminservice:${version} ``` ##### 2.3.1.2.2 运行镜像 示例: ```bash docker run -p 8090:8090 \ -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-adminservice apolloconfig/apollo-adminservice:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloConfigDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloConfigDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloConfigDB的密码 #### 2.3.1.3 Apollo Portal ##### 2.3.1.3.1 获取镜像 ```bash docker pull apolloconfig/apollo-portal:${version} ``` ##### 2.3.1.3.2 运行镜像 示例: ```bash docker run -p 8070:8070 \ -e SPRING_DATASOURCE_URL="jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8" \ -e SPRING_DATASOURCE_USERNAME=FillInCorrectUser -e SPRING_DATASOURCE_PASSWORD=FillInCorrectPassword \ -e APOLLO_PORTAL_ENVS=dev,pro \ -e DEV_META=http://fill-in-dev-meta-server:8080 -e PRO_META=http://fill-in-pro-meta-server:8080 \ -d -v /tmp/logs:/opt/logs --name apollo-portal apolloconfig/apollo-portal:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloPortalDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloPortalDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloPortalDB的密码 * APOLLO_PORTAL_ENVS(可选): 对应ApolloPortalDB中的[apollo.portal.envs](#_311-apolloportalenvs-可支持的环境列表)配置项,如果没有在数据库中配置的话,可以通过此环境参数配置 * DEV_META/PRO_META(可选): 配置对应环境的Meta Service地址,以${ENV}_META命名,需要注意的是如果配置了ApolloPortalDB中的[apollo.portal.meta.servers](#_312-apolloportalmetaservers-各环境meta-service列表)配置,则以apollo.portal.meta.servers中的配置为准 #### 2.3.1.4 通过源码构建 Docker 镜像 如果修改了 apollo 服务端的代码,希望通过源码构建 Docker 镜像,可以参考下面的步骤: 1. 通过源码构建安装包:`./scripts/build.sh` 2. 构建 Docker 镜像:`mvn docker:build -pl apollo-configservice,apollo-adminservice,apollo-portal` ### 2.3.2 1.7.0之前的版本 Apollo项目已经自带了Docker file,可以参照[2.2.1 获取安装包](#_221-获取安装包)配置好安装包后通过下面的文件来打Docker镜像: 1. [apollo-configservice](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/docker/Dockerfile) 2. [apollo-adminservice](https://github.com/ctripcorp/apollo/blob/master/apollo-adminservice/src/main/docker/Dockerfile) 3. [apollo-portal](https://github.com/ctripcorp/apollo/blob/master/apollo-portal/src/main/docker/Dockerfile) 也可以参考Apollo用户[@kulovecc](https://github.com/kulovecc)的[docker-apollo](https://github.com/kulovecc/docker-apollo)项目和[@idoop](https://github.com/idoop)的[docker-apollo](https://github.com/idoop/docker-apollo)项目。 ## 2.4 Kubernetes部署 ### 2.4.1 基于Kubernetes原生服务发现 Apollo 1.7.0版本增加了基于Kubernetes原生服务发现的部署模式,由于不再使用内置的Eureka,所以在整体部署上有很大简化,同时也提供了Helm Charts,便于部署。 > 更多设计说明可以参考[#3054](https://github.com/ctripcorp/apollo/issues/3054)。 #### 2.4.1.1 环境要求 - Kubernetes 1.10+ - Helm 3 #### 2.4.1.2 添加Apollo Helm Chart仓库 ```bash $ helm repo add apollo https://ctripcorp.github.io/apollo/charts $ helm search repo apollo ``` #### 2.4.1.3 部署apollo-configservice和apollo-adminservice ##### 2.4.1.3.1 安装apollo-configservice和apollo-adminservice 需要在每个环境中安装apollo-configservice和apollo-adminservice,所以建议在release名称中加入环境信息,例如:`apollo-service-dev` ```bash $ helm install apollo-service-dev \ --set configdb.host=1.2.3.4 \ --set configdb.userName=apollo \ --set configdb.password=apollo \ --set configdb.service.enabled=true \ --set configService.replicaCount=1 \ --set adminService.replicaCount=1 \ -n your-namespace \ apollo/apollo-service ``` 一般部署建议通过 values.yaml 来配置: ```bash $ helm install apollo-service-dev -f values.yaml -n your-namespace apollo/apollo-service ``` 安装完成后会提示对应环境的Meta Server地址,需要记录下来,apollo-portal安装时需要用到: ```bash Get meta service url for current release by running these commands: echo http://apollo-service-dev-apollo-configservice:8080 ``` > 更多配置项说明可以参考[2.4.1.3.3 配置项说明](#_24133-配置项说明) ##### 2.4.1.3.2 卸载apollo-configservice和apollo-adminservice 例如要卸载`apollo-service-dev`的部署: ```bash $ helm uninstall -n your-namespace apollo-service-dev ``` ##### 2.4.1.3.3 配置项说明 下表列出了apollo-service chart的可配置参数及其默认值: | Parameter | Description | Default | |----------------------|---------------------------------------------|---------------------| | `configdb.host` | The host for apollo config db | `nil` | | `configdb.port` | The port for apollo config db | `3306` | | `configdb.dbName` | The database name for apollo config db | `ApolloConfigDB` | | `configdb.userName` | The user name for apollo config db | `nil` | | `configdb.password` | The password for apollo config db | `nil` | | `configdb.connectionStringProperties` | The connection string properties for apollo config db | `characterEncoding=utf8` | | `configdb.service.enabled` | Whether to create a Kubernetes Service for `configdb.host` or not. Set it to `true` if `configdb.host` is an endpoint outside of the kubernetes cluster | `false` | | `configdb.service.fullNameOverride` | Override the service name for apollo config db | `nil` | | `configdb.service.port` | The port for the service of apollo config db | `3306` | | `configdb.service.type` | The service type of apollo config db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. `xxx.mysql.rds.aliyuncs.com` | `ClusterIP` | | `configService.fullNameOverride` | Override the deployment name for apollo-configservice | `nil` | | `configService.replicaCount` | Replica count of apollo-configservice | `2` | | `configService.containerPort` | Container port of apollo-configservice | `8080` | | `configService.image.repository` | Image repository of apollo-configservice | `apolloconfig/apollo-configservice` | | `configService.image.tag` | Image tag of apollo-configservice, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `configService.image.pullPolicy` | Image pull policy of apollo-configservice | `IfNotPresent` | | `configService.imagePullSecrets` | Image pull secrets of apollo-configservice | `[]` | | `configService.service.fullNameOverride` | Override the service name for apollo-configservice | `nil` | | `configService.service.port` | The port for the service of apollo-configservice | `8080` | | `configService.service.targetPort` | The target port for the service of apollo-configservice | `8080` | | `configService.service.type` | The service type of apollo-configservice | `ClusterIP` | | `configService.ingress.enabled` | Whether to enable the ingress for config-service or not. _(chart version >= 0.2.0)_ | `false` | | `configService.ingress.annotations` | The annotations of the ingress for config-service. _(chart version >= 0.2.0)_ | `{}` | | `configService.ingress.hosts.host` | The host of the ingress for config-service. _(chart version >= 0.2.0)_ | `nil` | | `configService.ingress.hosts.paths` | The paths of the ingress for config-service. _(chart version >= 0.2.0)_ | `[]` | | `configService.ingress.tls` | The tls definition of the ingress for config-service. _(chart version >= 0.2.0)_ | `[]` | | `configService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `configService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `configService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `configService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `configService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `configService.config.configServiceUrlOverride` | Override `apollo.config-service.url`: config service url to be accessed by apollo-client, e.g. `http://apollo-config-service-dev:8080` | `nil` | | `configService.config.adminServiceUrlOverride` | Override `apollo.admin-service.url`: admin service url to be accessed by apollo-portal, e.g. `http://apollo-admin-service-dev:8090` | `nil` | | `configService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access config service via `http://{config_service_address}/apollo`. _(chart version >= 0.2.0)_ | `nil` | | `configService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `configService.strategy` | The deployment strategy of apollo-configservice | `{}` | | `configService.resources` | The resources definition of apollo-configservice | `{}` | | `configService.nodeSelector` | The node selector definition of apollo-configservice | `{}` | | `configService.tolerations` | The tolerations definition of apollo-configservice | `[]` | | `configService.affinity` | The affinity definition of apollo-configservice | `{}` | | `adminService.fullNameOverride` | Override the deployment name for apollo-adminservice | `nil` | | `adminService.replicaCount` | Replica count of apollo-adminservice | `2` | | `adminService.containerPort` | Container port of apollo-adminservice | `8090` | | `adminService.image.repository` | Image repository of apollo-adminservice | `apolloconfig/apollo-adminservice` | | `adminService.image.tag` | Image tag of apollo-adminservice, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `adminService.image.pullPolicy` | Image pull policy of apollo-adminservice | `IfNotPresent` | | `adminService.imagePullSecrets` | Image pull secrets of apollo-adminservice | `[]` | | `adminService.service.fullNameOverride` | Override the service name for apollo-adminservice | `nil` | | `adminService.service.port` | The port for the service of apollo-adminservice | `8090` | | `adminService.service.targetPort` | The target port for the service of apollo-adminservice | `8090` | | `adminService.service.type` | The service type of apollo-adminservice | `ClusterIP` | | `adminService.ingress.enabled` | Whether to enable the ingress for admin-service or not. _(chart version >= 0.2.0)_ | `false` | | `adminService.ingress.annotations` | The annotations of the ingress for admin-service. _(chart version >= 0.2.0)_ | `{}` | | `adminService.ingress.hosts.host` | The host of the ingress for admin-service. _(chart version >= 0.2.0)_ | `nil` | | `adminService.ingress.hosts.paths` | The paths of the ingress for admin-service. _(chart version >= 0.2.0)_ | `[]` | | `adminService.ingress.tls` | The tls definition of the ingress for admin-service. _(chart version >= 0.2.0)_ | `[]` | | `adminService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `adminService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `adminService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `adminService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `adminService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `adminService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access admin service via `http://{admin_service_address}/apollo`. _(chart version >= 0.2.0)_ | `nil` | | `adminService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `adminService.strategy` | The deployment strategy of apollo-adminservice | `{}` | | `adminService.resources` | The resources definition of apollo-adminservice | `{}` | | `adminService.nodeSelector` | The node selector definition of apollo-adminservice | `{}` | | `adminService.tolerations` | The tolerations definition of apollo-adminservice | `[]` | | `adminService.affinity` | The affinity definition of apollo-adminservice | `{}` | ##### 2.4.1.3.4 配置样例 ###### 2.4.1.3.4.1 ConfigDB的host是k8s集群外的IP ```yaml configdb: host: 1.2.3.4 dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` ###### 2.4.1.3.4.2 ConfigDB的host是k8s集群外的域名 ```yaml configdb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` ###### 2.4.1.3.4.3 ConfigDB的host是k8s集群内的一个服务 ```yaml configdb: host: apollodb-mysql.mysql dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` ###### 2.4.1.3.4.4 指定Meta Server返回的apollo-configservice地址 如果apollo-client无法直接访问apollo-configservice的Service(比如不在同一个k8s集群),那么可以参照下面的示例指定Meta Server返回给apollo-client的地址(比如可以通过nodeport访问) ```yaml configService: config: configServiceUrlOverride: http://1.2.3.4:12345 ``` ###### 2.4.1.3.4.5 指定Meta Server返回的apollo-adminservice地址 如果apollo-portal无法直接访问apollo-adminservice的Service(比如不在同一个k8s集群),那么可以参照下面的示例指定Meta Server返回给apollo-portal的地址(比如可以通过nodeport访问) ```yaml configService: config: adminServiceUrlOverride: http://1.2.3.4:23456 ``` ###### 2.4.1.3.4.6 以Ingress配置自定义路径`/config`形式暴露apollo-configservice服务 ```yaml # use /config as root, should specify configService.config.contextPath as /config configService: config: contextPath: /config ingress: enabled: true hosts: - paths: - /config ``` ###### 2.4.1.3.4.7 以Ingress配置自定义路径`/admin`形式暴露apollo-adminservice服务 ```yaml # use /admin as root, should specify adminService.config.contextPath as /admin adminService: config: contextPath: /admin ingress: enabled: true hosts: - paths: - /admin ``` #### 2.4.1.4 部署apollo-portal ##### 2.4.1.4.1 安装apollo-portal 假设有dev, pro两个环境,且meta server地址分别为`http://apollo-service-dev-apollo-configservice:8080`和`http://apollo-service-pro-apollo-configservice:8080`: ```bash $ helm install apollo-portal \ --set portaldb.host=1.2.3.4 \ --set portaldb.userName=apollo \ --set portaldb.password=apollo \ --set portaldb.service.enabled=true \ --set config.envs="dev\,pro" \ --set config.metaServers.dev=http://apollo-service-dev-apollo-configservice:8080 \ --set config.metaServers.pro=http://apollo-service-pro-apollo-configservice:8080 \ --set replicaCount=1 \ -n your-namespace \ apollo/apollo-portal ``` 一般部署建议通过 values.yaml 来配置: ```bash $ helm install apollo-portal -f values.yaml -n your-namespace apollo/apollo-portal ``` > 更多配置项说明可以参考[2.4.1.4.3 配置项说明](#_24143-配置项说明) ##### 2.4.1.4.2 卸载apollo-portal 例如要卸载`apollo-portal`的部署: ```bash $ helm uninstall -n your-namespace apollo-portal ``` ##### 2.4.1.4.3 配置项说明 下表列出了apollo-portal chart的可配置参数及其默认值: | Parameter | Description | Default | |----------------------|---------------------------------------------|-----------------------| | `fullNameOverride` | Override the deployment name for apollo-portal | `nil` | | `replicaCount` | Replica count of apollo-portal | `2` | | `containerPort` | Container port of apollo-portal | `8070` | | `image.repository` | Image repository of apollo-portal | `apolloconfig/apollo-portal` | | `image.tag` | Image tag of apollo-portal, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `image.pullPolicy` | Image pull policy of apollo-portal | `IfNotPresent` | | `imagePullSecrets` | Image pull secrets of apollo-portal | `[]` | | `service.fullNameOverride` | Override the service name for apollo-portal | `nil` | | `service.port` | The port for the service of apollo-portal | `8070` | | `service.targetPort` | The target port for the service of apollo-portal | `8070` | | `service.type` | The service type of apollo-portal | `ClusterIP` | | `service.sessionAffinity` | The session affinity for the service of apollo-portal | `ClientIP` | | `ingress.enabled` | Whether to enable the ingress or not | `false` | | `ingress.annotations` | The annotations of the ingress | `{}` | | `ingress.hosts.host` | The host of the ingress | `nil` | | `ingress.hosts.paths` | The paths of the ingress | `[]` | | `ingress.tls` | The tls definition of the ingress | `[]` | | `liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `strategy` | The deployment strategy of apollo-portal | `{}` | | `resources` | The resources definition of apollo-portal | `{}` | | `nodeSelector` | The node selector definition of apollo-portal | `{}` | | `tolerations` | The tolerations definition of apollo-portal | `[]` | | `affinity` | The affinity definition of apollo-portal | `{}` | | `config.profiles` | specify the spring profiles to activate | `github,auth` | | `config.envs` | specify the env names, e.g. `dev,pro` | `nil` | | `config.contextPath` | specify the context path, e.g. `/apollo`, then users could access portal via `http://{portal_address}/apollo` | `nil` | | `config.metaServers` | specify the meta servers, e.g.<br />`dev: http://apollo-configservice-dev:8080`<br />`pro: http://apollo-configservice-pro:8080` | `{}` | | `config.files` | specify the extra config files for apollo-portal, e.g. `application-ldap.yml` | `{}` | | `portaldb.host` | The host for apollo portal db | `nil` | | `portaldb.port` | The port for apollo portal db | `3306` | | `portaldb.dbName` | The database name for apollo portal db | `ApolloPortalDB` | | `portaldb.userName` | The user name for apollo portal db | `nil` | | `portaldb.password` | The password for apollo portal db | `nil` | | `portaldb.connectionStringProperties` | The connection string properties for apollo portal db | `characterEncoding=utf8` | | `portaldb.service.enabled` | Whether to create a Kubernetes Service for `portaldb.host` or not. Set it to `true` if `portaldb.host` is an endpoint outside of the kubernetes cluster | `false` | | `portaldb.service.fullNameOverride` | Override the service name for apollo portal db | `nil` | | `portaldb.service.port` | The port for the service of apollo portal db | `3306` | | `portaldb.service.type` | The service type of apollo portal db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. `xxx.mysql.rds.aliyuncs.com` | `ClusterIP` | ##### 2.4.1.4.4 配置样例 ###### 2.4.1.4.4.1 PortalDB的host是k8s集群外的IP ```yaml portaldb: host: 1.2.3.4 dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` ###### 2.4.1.4.4.2 PortalDB的host是k8s集群外的域名 ```yaml portaldb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` ###### 2.4.1.4.4.3 PortalDB的host是k8s集群内的一个服务 ```yaml portaldb: host: apollodb-mysql.mysql dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` ###### 2.4.1.4.4.4 配置环境信息 ```yaml config: envs: dev,pro metaServers: dev: http://apollo-service-dev-apollo-configservice:8080 pro: http://apollo-service-pro-apollo-configservice:8080 ``` ###### 2.4.1.4.4.5 以Load Balancer形式暴露服务 ```yaml service: type: LoadBalancer ``` ###### 2.4.1.4.4.6 以Ingress形式暴露服务 ```yaml ingress: enabled: true hosts: - paths: - / ``` ###### 2.4.1.4.4.7 以Ingress配置自定义路径`/apollo`形式暴露服务 ```yaml # use /apollo as root, should specify config.contextPath as /apollo ingress: enabled: true hosts: - paths: - /apollo config: ... contextPath: /apollo ... ``` ###### 2.4.1.4.4.8 以Ingress配置session affinity形式暴露服务 ```yaml ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/affinity: "cookie" nginx.ingress.kubernetes.io/affinity-mode: "persistent" nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none: "true" nginx.ingress.kubernetes.io/session-cookie-expires: "172800" nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" hosts: - host: xxx.somedomain.com # host is required to make session affinity work paths: - / ``` ###### 2.4.1.4.4.9 启用 LDAP 支持 ```yaml config: ... profiles: github,ldap ... files: application-ldap.yml: | spring: ldap: base: "dc=example,dc=org" username: "cn=admin,dc=example,dc=org" password: "password" searchFilter: "(uid={0})" urls: - "ldap://xxx.somedomain.com:389" ldap: mapping: objectClass: "inetOrgPerson" loginId: "uid" userDisplayName: "cn" email: "mail" ``` #### 2.4.1.5 通过源码构建 Docker 镜像 如果修改了 apollo 服务端的代码,希望通过源码构建 Docker 镜像,可以参考[2.3.1.4 通过源码构建 Docker 镜像](#_2314-通过源码构建-docker-镜像)的步骤。 ### 2.4.2 基于内置的Eureka服务发现 感谢[AiotCEO](https://github.com/AiotCEO)提供了k8s的部署支持,使用说明可以参考[apollo-on-kubernetes](https://github.com/ctripcorp/apollo/blob/master/scripts/apollo-on-kubernetes/README.md)。 感谢[qct](https://github.com/qct)提供的Helm Chart部署支持,使用说明可以参考[qct/apollo-helm](https://github.com/qct/apollo-helm)。 # 三、服务端配置说明 > 以下配置除了支持在数据库中配置以外,也支持通过-D参数、application.properties等配置,且-D参数、application.properties等优先级高于数据库中的配置 ## 3.1 调整ApolloPortalDB配置 配置项统一存储在ApolloPortalDB.ServerConfig表中,也可以通过`管理员工具 - 系统参数`页面进行配置,无特殊说明则修改完一分钟实时生效。 ### 3.1.1 apollo.portal.envs - 可支持的环境列表 默认值是dev,如果portal需要管理多个环境的话,以逗号分隔即可(大小写不敏感),如: ``` DEV,FAT,UAT,PRO ``` 修改完需要重启生效。 >注1:一套Portal可以管理多个环境,但是每个环境都需要独立部署一套Config Service、Admin Service和ApolloConfigDB,具体请参考:[2.1.2 创建ApolloConfigDB](#_212-创建apolloconfigdb),[3.2 调整ApolloConfigDB配置](zh/deployment/distributed-deployment-guide?id=_32-调整apolloconfigdb配置),[2.2.1.1.2 配置数据库连接信息](#_22112-配置数据库连接信息),另外如果是为已经运行了一段时间的Apollo配置中心增加环境,别忘了参考[2.1.2.4 从别的环境导入ApolloConfigDB的项目数据](#_2124-从别的环境导入apolloconfigdb的项目数据)对新的环境做初始化。 >注2:只在数据库添加环境是不起作用的,还需要为apollo-portal添加新增环境对应的meta server地址,具体参考:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)。apollo-client在新的环境下使用时也需要做好相应的配置,具体参考:[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 >注3:如果希望添加自定义的环境名称,具体步骤可以参考[Portal如何增加环境](zh/faq/common-issues-in-deployment-and-development-phase?id=_4-portal如何增加环境?)。 >注4:1.1.0版本增加了系统信息页面(`管理员工具` -> `系统信息`),可以通过该页面检查配置是否正确 ### 3.1.2 apollo.portal.meta.servers - 各环境Meta Service列表 > 适用于1.6.0及以上版本 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以我们需要在配置中提供这些信息。默认情况下,meta service和config service是部署在同一个JVM进程,所以meta service的地址就是config service的地址。 样例如下: ```json { "DEV":"http://1.1.1.1:8080", "FAT":"http://apollo.fat.xxx.com", "UAT":"http://apollo.uat.xxx.com", "PRO":"http://apollo.xxx.com" } ``` 修改完需要重启生效。 > 该配置优先级高于其它方式设置的Meta Service地址,更多信息可以参考[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)。 ### 3.1.3 organizations - 部门列表 Portal中新建的App都需要选择部门,所以需要在这里配置可选的部门信息,样例如下: ```json [{"orgId":"TEST1","orgName":"样例部门1"},{"orgId":"TEST2","orgName":"样例部门2"}] ``` ### 3.1.4 superAdmin - Portal超级管理员 超级管理员拥有所有权限,需要谨慎设置。 如果没有接入自己公司的SSO系统的话,可以先暂时使用默认值apollo(默认用户)。等接入后,修改为实际使用的账号,多个账号以英文逗号分隔(,)。 ### 3.1.5 consumer.token.salt - consumer token salt 如果会使用开放平台API的话,可以设置一个token salt。如果不使用,可以忽略。 ### 3.1.6 wiki.address portal上“帮助”链接的地址,默认是Apollo github的wiki首页,可自行设置。 ### 3.1.7 admin.createPrivateNamespace.switch 是否允许项目管理员创建private namespace。设置为`true`允许创建,设置为`false`则项目管理员在页面上看不到创建private namespace的选项。[了解更多Namespace](zh/design/apollo-core-concept-namespace) ### 3.1.8 emergencyPublish.supported.envs 配置允许紧急发布的环境列表,多个env以英文逗号分隔。 当config service开启一次发布只能有一个人修改开关(`namespace.lock.switch`)后,一次配置发布只能是一个人修改,另一个发布。为了避免遇到紧急情况时(如非工作时间、节假日)无法发布配置,可以配置此项以允许某些环境可以操作紧急发布,即同一个人可以修改并发布配置。 ### 3.1.9 configView.memberOnly.envs 只对项目成员显示配置信息的环境列表,多个env以英文逗号分隔。 对设定了只对项目成员显示配置信息的环境,只有该项目的管理员或拥有该namespace的编辑或发布权限的用户才能看到该私有namespace的配置信息和发布历史。公共namespace始终对所有用户可见。 > 从1.1.0版本开始支持,详见[PR 1531](https://github.com/ctripcorp/apollo/pull/1531) ### 3.1.10 role.create-application.enabled - 是否开启创建项目权限控制 > 适用于1.5.0及以上版本 默认为false,所有用户都可以创建项目 如果设置为true,那么只有超级管理员和拥有创建项目权限的帐号可以创建项目,超级管理员可以通过`管理员工具 - 系统权限管理`给用户分配创建项目权限 ### 3.1.11 role.manage-app-master.enabled - 是否开启项目管理员分配权限控制 > 适用于1.5.0及以上版本 默认为false,所有项目的管理员可以为项目添加/删除管理员 如果设置为true,那么只有超级管理员和拥有项目管理员分配权限的帐号可以为特定项目添加/删除管理员,超级管理员可以通过`管理员工具 - 系统权限管理`给用户分配特定项目的管理员分配权限 ### 3.1.12 admin-service.access.tokens - 设置apollo-portal访问各环境apollo-adminservice所需的access token > 适用于1.7.1及以上版本 如果对应环境的apollo-adminservice开启了[访问控制](#_326-admin-serviceaccesscontrolenabled-配置apollo-adminservice是否开启访问控制),那么需要在此配置apollo-portal访问该环境apollo-adminservice所需的access token,否则会访问失败 格式为json,如下所示: ```json { "dev" : "098f6bcd4621d373cade4e832627b4f6", "pro" : "ad0234829205b9033196ba818f7a872b" } ``` ## 3.2 调整ApolloConfigDB配置 配置项统一存储在ApolloConfigDB.ServerConfig表中,需要注意每个环境的ApolloConfigDB.ServerConfig都需要单独配置,修改完一分钟实时生效。 ### 3.2.1 eureka.service.url - Eureka服务Url > 不适用于基于Kubernetes原生服务发现场景 不管是apollo-configservice还是apollo-adminservice都需要向eureka服务注册,所以需要配置eureka服务地址。 按照目前的实现,apollo-configservice本身就是一个eureka服务,所以只需要填入apollo-configservice的地址即可,如有多个,用逗号分隔(注意不要忘了/eureka/后缀)。 需要注意的是每个环境只填入自己环境的eureka服务地址,比如FAT的apollo-configservice是1.1.1.1:8080和2.2.2.2:8080,UAT的apollo-configservice是3.3.3.3:8080和4.4.4.4:8080,PRO的apollo-configservice是5.5.5.5:8080和6.6.6.6:8080,那么: 1. 在FAT环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://1.1.1.1:8080/eureka/,http://2.2.2.2:8080/eureka/ ``` 2. 在UAT环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://3.3.3.3:8080/eureka/,http://4.4.4.4:8080/eureka/ ``` 3. 在PRO环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://5.5.5.5:8080/eureka/,http://6.6.6.6:8080/eureka/ ``` >注1:这里需要填写本环境中全部的eureka服务地址,因为eureka需要互相复制注册信息 >注2:如果希望将Config Service和Admin Service注册到公司统一的Eureka上,可以参考[部署&开发遇到的常见问题 - 将Config Service和Admin Service注册到单独的Eureka Server上](zh/faq/common-issues-in-deployment-and-development-phase#_8-将config-service和admin-service注册到单独的eureka-server上)章节 >注3:在多机房部署时,往往希望config service和admin service只向同机房的eureka注册,要实现这个效果,需要利用`ServerConfig`表中的cluster字段,config service和admin service会读取所在机器的`/opt/settings/server.properties`(Mac/Linux)或`C:\opt\settings\server.properties`(Windows)中的idc属性,如果该idc有对应的eureka.service.url配置,那么就只会向该机房的eureka注册。比如config service和admin service会部署到`SHAOY`和`SHAJQ`两个IDC,那么为了实现这两个机房中的服务只向该机房注册,那么可以在`ServerConfig`表中新增两条记录,分别填入`SHAOY`和`SHAJQ`两个机房的eureka地址即可,`default` cluster的记录可以保留,如果有config service和admin service不是部署在`SHAOY`和`SHAJQ`这两个机房的,就会使用这条默认配置。 | Key |Cluster | Value | Comment | |--------------------|-----------|-------------------------------|---------------------| | eureka.service.url | default | http://1.1.1.1:8080/eureka/ | 默认的Eureka服务Url | | eureka.service.url | SHAOY | http://2.2.2.2:8080/eureka/ | SHAOY的Eureka服务Url | | eureka.service.url | SHAJQ | http://3.3.3.3:8080/eureka/ | SHAJQ的Eureka服务Url | ### 3.2.2 namespace.lock.switch - 一次发布只能有一个人修改开关,用于发布审核 这是一个功能开关,如果配置为true的话,那么一次配置发布只能是一个人修改,另一个发布。 > 生产环境建议开启此选项 ### 3.2.3 config-service.cache.enabled - 是否开启配置缓存 这是一个功能开关,如果配置为true的话,config service会缓存加载过的配置信息,从而加快后续配置获取性能。 默认为false,开启前请先评估总配置大小并调整config service内存配置。 > 开启缓存后必须确保应用中配置的app.id大小写正确,否则将获取不到正确的配置 ### 3.2.4 item.key.length.limit - 配置项 key 最大长度限制 默认配置是128。 ### 3.2.5 item.value.length.limit - 配置项 value 最大长度限制 默认配置是20000。 ### 3.2.6 admin-service.access.control.enabled - 配置apollo-adminservice是否开启访问控制 > 适用于1.7.1及以上版本 默认为false,如果配置为true,那么apollo-portal就需要[正确配置](#_3112-admin-serviceaccesstokens-设置apollo-portal访问各环境apollo-adminservice所需的access-token)访问该环境的access token,否则访问会被拒绝 ### 3.2.7 admin-service.access.tokens - 配置允许访问apollo-adminservice的access token列表 > 适用于1.7.1及以上版本 如果该配置项为空,那么访问控制不会生效。如果允许多个token,token 之间以英文逗号分隔 样例: ```properties admin-service.access.tokens=098f6bcd4621d373cade4e832627b4f6 admin-service.access.tokens=098f6bcd4621d373cade4e832627b4f6,ad0234829205b9033196ba818f7a872b ```
本文档介绍了如何按照分布式部署的方式编译、打包、部署Apollo配置中心,从而可以在开发、测试、生产等环境分别部署运行。 > 如果只是需要在本地快速部署试用Apollo的话,可以参考[Quick Start](zh/deployment/quick-start) # &nbsp; # 一、准备工作 ## 1.1 运行时环境 ### 1.1.1 OS 服务端基于Spring Boot,启动脚本理论上支持所有Linux发行版,建议[CentOS 7](https://www.centos.org/)。 ### 1.1.2 Java * Apollo服务端:1.8+ * Apollo客户端:1.7+ 由于需要同时运行服务端和客户端,所以建议安装Java 1.8+。 >对于Apollo客户端,运行时环境只需要1.7+即可。 >注:对于Apollo客户端,如果有需要的话,可以做少量代码修改来降级到Java 1.6,详细信息可以参考[Issue 483](https://github.com/ctripcorp/apollo/issues/483) 在配置好后,可以通过如下命令检查: ```sh java -version ``` 样例输出: ```sh java version "1.8.0_74" Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode) ``` ## 1.2 MySQL * 版本要求:5.6.5+ Apollo的表结构对`timestamp`使用了多个default声明,所以需要5.6.5以上版本。 连接上MySQL后,可以通过如下命令检查: ```sql SHOW VARIABLES WHERE Variable_name = 'version'; ``` | Variable_name | Value | |---------------|--------| | version | 5.7.11 | > 注1:MySQL版本可以降级到5.5,详见[mysql 依赖降级讨论](https://github.com/ctripcorp/apollo/issues/481)。 > 注2:如果希望使用Oracle的话,可以参考[vanpersl](https://github.com/vanpersl)在Apollo 0.8.0基础上开发的[Oracle适配代码](https://github.com/ctripcorp/apollo/compare/v0.8.0...vanpersl:db-oracle),Oracle版本为10.2.0.1.0。 > 注3:如果希望使用Postgres的话,可以参考[oaksharks](https://github.com/oaksharks)在Apollo 0.9.1基础上开发的[Pg适配代码](https://github.com/oaksharks/apollo/compare/ac10768ee2e11c488523ca0e845984f6f71499ac...oaksharks:pg),Postgres的版本为9.3.20,也可以参考[xiao0yy](https://github.com/xiao0yy)在Apollo 0.10.2基础上开发的[Pg适配代码](https://github.com/ctripcorp/apollo/issues/1293),Postgres的版本为9.5。 ## 1.3 环境 分布式部署需要事先确定部署的环境以及部署方式。 Apollo目前支持以下环境: * DEV * 开发环境 * FAT * 测试环境,相当于alpha环境(功能测试) * UAT * 集成环境,相当于beta环境(回归测试) * PRO * 生产环境 > 如果希望添加自定义的环境名称,具体步骤可以参考[Portal如何增加环境](zh/faq/common-issues-in-deployment-and-development-phase?id=_4-portal如何增加环境?) 以ctrip为例,我们的部署策略如下: ![Deployment](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-deployment.png) * Portal部署在生产环境的机房,通过它来直接管理FAT、UAT、PRO等环境的配置 * Meta Server、Config Service和Admin Service在每个环境都单独部署,使用独立的数据库 * Meta Server、Config Service和Admin Service在生产环境部署在两个机房,实现双活 * Meta Server和Config Service部署在同一个JVM进程内,Admin Service部署在同一台服务器的另一个JVM进程内 另外也可以参考下[@lyliyongblue](https://github.com/lyliyongblue) 贡献的样例部署图(建议右键新窗口打开看大图): ![Deployment](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/lyliyongblue-apollo-deployment.png) ## 1.4 网络策略 分布式部署的时候,`apollo-configservice`和`apollo-adminservice`需要把自己的IP和端口注册到Meta Server(apollo-configservice本身)。 Apollo客户端和Portal会从Meta Server获取服务的地址(IP+端口),然后通过服务地址直接访问。 需要注意的是,`apollo-configservice`和`apollo-adminservice`是基于内网可信网络设计的,所以出于安全考虑,**请不要将`apollo-configservice`和`apollo-adminservice`直接暴露在公网**。 所以如果实际部署的机器有多块网卡(如docker),或者存在某些网卡的IP是Apollo客户端和Portal无法访问的(如网络安全限制),那么我们就需要在`apollo-configservice`和`apollo-adminservice`中做相关配置来解决连通性问题。 ### 1.4.1 忽略某些网卡 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会把`docker0`和`veth`开头的网卡在注册到Eureka时忽略掉。 JVM System Property示例: ```properties -Dspring.cloud.inetutils.ignoredInterfaces[0]=docker0 -Dspring.cloud.inetutils.ignoredInterfaces[1]=veth.* ``` OS Environment Variable示例: ```properties SPRING_CLOUD_INETUTILS_IGNORED_INTERFACES[0]=docker0 SPRING_CLOUD_INETUTILS_IGNORED_INTERFACES[1]=veth.* ``` ### 1.4.2 指定要注册的IP 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会指定注册的IP为`1.2.3.4`。 JVM System Property示例: ```properties -Deureka.instance.ip-address=1.2.3.4 ``` OS Environment Variable示例: ```properties EUREKA_INSTANCE_IP_ADDRESS=1.2.3.4 ``` ### 1.4.3 指定要注册的URL 可以分别修改`apollo-configservice`和`apollo-adminservice`的startup.sh,通过JVM System Property传入-D参数,也可以通过OS Environment Variable传入,下面的例子会指定注册的URL为`http://1.2.3.4:8080`。 JVM System Property示例: ```properties -Deureka.instance.homePageUrl=http://1.2.3.4:8080 -Deureka.instance.preferIpAddress=false ``` OS Environment Variable示例: ```properties EUREKA_INSTANCE_HOME_PAGE_URL=http://1.2.3.4:8080 EUREKA_INSTANCE_PREFER_IP_ADDRESS=false ``` ### 1.4.4 直接指定apollo-configservice地址 如果Apollo部署在公有云上,本地开发环境无法连接,但又需要做开发测试的话,客户端可以升级到0.11.0版本及以上,然后配置[跳过Apollo Meta Server服务发现](zh/usage/java-sdk-user-guide#_1222-跳过apollo-meta-server服务发现) # 二、部署步骤 部署步骤总体还是比较简单的,Apollo的唯一依赖是数据库,所以需要首先把数据库准备好,然后根据实际情况,选择不同的部署方式: > [@lingjiaju](https://github.com/lingjiaju)录制了一系列Apollo快速上手视频,如果看文档觉得略繁琐的话,不妨可以先看一下他的[视频教程](https://pan.baidu.com/s/1blv87EOZS77NWT8Amkijkw#list/path=%2F)。 > 如果部署过程中遇到了问题,可以参考[部署&开发遇到的常见问题](zh/faq/common-issues-in-deployment-and-development-phase),一般都能找到答案。 ## 2.1 创建数据库 Apollo服务端共需要两个数据库:`ApolloPortalDB`和`ApolloConfigDB`,我们把数据库、表的创建和样例数据都分别准备了sql文件,只需要导入数据库即可。 需要注意的是ApolloPortalDB只需要在生产环境部署一个即可,而ApolloConfigDB需要在每个环境部署一套,如fat、uat和pro分别部署3套ApolloConfigDB。 > 注意:如果你本地已经创建过Apollo数据库,请注意备份数据。我们准备的sql文件会清空Apollo相关的表。 ### 2.1.1 创建ApolloPortalDB 可以根据实际情况选择通过手动导入SQL或是通过[Flyway](https://flywaydb.org/)自动导入SQL创建。 #### 2.1.1.1 手动导入SQL创建 通过各种MySQL客户端导入[apolloportaldb.sql](https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloportaldb.sql)即可。 以MySQL原生客户端为例: ```sql source /your_local_path/scripts/sql/apolloportaldb.sql ``` #### 2.1.1.2 通过Flyway导入SQL创建 > 需要1.3.0及以上版本 1. 根据实际情况修改[flyway-portaldb.properties](https://github.com/ctripcorp/apollo/blob/master/scripts/flyway/flyway-portaldb.properties)中的`flyway.user`、`flyway.password`和`flyway.url`配置 2. 在apollo项目根目录下执行`mvn -N -Pportaldb flyway:migrate` #### 2.1.1.3 验证 导入成功后,可以通过执行以下sql语句来验证: ```sql select `Id`, `Key`, `Value`, `Comment` from `ApolloPortalDB`.`ServerConfig` limit 1; ``` | Id | Key | Value | Comment | |----|--------------------|-------|------------------| | 1 | apollo.portal.envs | dev | 可支持的环境列表 | > 注:ApolloPortalDB只需要在生产环境部署一个即可 ### 2.1.2 创建ApolloConfigDB 可以根据实际情况选择通过手动导入SQL或是通过[Flyway](https://flywaydb.org/)自动导入SQL创建。 #### 2.1.2.1 手动导入SQL 通过各种MySQL客户端导入[apolloconfigdb.sql](https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloconfigdb.sql)即可。 以MySQL原生客户端为例: ```sql source /your_local_path/scripts/sql/apolloconfigdb.sql ``` #### 2.1.2.2 通过Flyway导入SQL > 需要1.3.0及以上版本 1. 根据实际情况修改[flyway-configdb.properties](https://github.com/ctripcorp/apollo/blob/master/scripts/flyway/flyway-configdb.properties)中的`flyway.user`、`flyway.password`和`flyway.url`配置 2. 在apollo项目根目录下执行`mvn -N -Pconfigdb flyway:migrate` #### 2.1.2.3 验证 导入成功后,可以通过执行以下sql语句来验证: ```sql select `Id`, `Key`, `Value`, `Comment` from `ApolloConfigDB`.`ServerConfig` limit 1; ``` | Id | Key | Value | Comment | |----|--------------------|-------------------------------|---------------| | 1 | eureka.service.url | http://127.0.0.1:8080/eureka/ | Eureka服务Url | > 注:ApolloConfigDB需要在每个环境部署一套,如fat、uat和pro分别部署3套ApolloConfigDB #### 2.1.2.4 从别的环境导入ApolloConfigDB的项目数据 如果是全新部署的Apollo配置中心,请忽略此步。 如果不是全新部署的Apollo配置中心,比如已经使用了一段时间,这时在Apollo配置中心已经创建了不少项目以及namespace等,那么在新环境中的ApolloConfigDB中需要从其它正常运行的环境中导入必要的项目数据。 主要涉及ApolloConfigDB的下面4张表,下面同时附上需要导入的数据查询语句: 1. App * 导入全部的App * 如:insert into `新环境的ApolloConfigDB`.`App` select * from `其它环境的ApolloConfigDB`.`App` where `IsDeleted` = 0; 2. AppNamespace * 导入全部的AppNamespace * 如:insert into `新环境的ApolloConfigDB`.`AppNamespace` select * from `其它环境的ApolloConfigDB`.`AppNamespace` where `IsDeleted` = 0; 3. Cluster * 导入默认的default集群 * 如:insert into `新环境的ApolloConfigDB`.`Cluster` select * from `其它环境的ApolloConfigDB`.`Cluster` where `Name` = 'default' and `IsDeleted` = 0; 4. Namespace * 导入默认的default集群中的namespace * 如:insert into `新环境的ApolloConfigDB`.`Namespace` select * from `其它环境的ApolloConfigDB`.`Namespace` where `ClusterName` = 'default' and `IsDeleted` = 0; 同时也别忘了通知用户在新的环境给自己的项目设置正确的配置信息,尤其是一些影响面比较大的公共namespace配置。 > 如果是为正在运行的环境迁移数据,建议迁移完重启一下config service,因为config service中有appnamespace的缓存数据 ### 2.1.3 调整服务端配置 Apollo自身的一些配置是放在数据库里面的,所以需要针对实际情况做一些调整,具体参数说明请参考[三、服务端配置说明](#三、服务端配置说明)。 大部分配置可以先使用默认值,不过 [apollo.portal.envs](#_311-apolloportalenvs-可支持的环境列表) 和 [eureka.service.url](#_321-eurekaserviceurl-eureka服务url) 请务必配置正确后再进行下面的部署步骤。 ## 2.2 虚拟机/物理机部署 ### 2.2.1 获取安装包 可以通过两种方式获取安装包: 1. 直接下载安装包 * 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载预先打好的安装包 * 如果对Apollo的代码没有定制需求,建议使用这种方式,可以省去本地打包的过程 2. 通过源码构建 * 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载Source code包或直接clone[源码](https://github.com/ctripcorp/apollo)后在本地构建 * 如果需要对Apollo的做定制开发,需要使用这种方式 #### 2.2.1.1 直接下载安装包 ##### 2.2.1.1.1 获取apollo-configservice、apollo-adminservice、apollo-portal安装包 从[GitHub Release](https://github.com/ctripcorp/apollo/releases)页面下载最新版本的`apollo-configservice-x.x.x-github.zip`、`apollo-adminservice-x.x.x-github.zip`和`apollo-portal-x.x.x-github.zip`即可。 ##### 2.2.1.1.2 配置数据库连接信息 Apollo服务端需要知道如何连接到你前面创建的数据库,数据库连接串信息位于上一步下载的压缩包中的`config/application-github.properties`中。 ###### 2.2.1.1.2.1 配置apollo-configservice的数据库连接信息 1. 解压`apollo-configservice-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloConfigDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境config-service需要配置对应环境的数据库参数 ###### 2.2.1.1.2.2 配置apollo-adminservice的数据库连接信息 1. 解压`apollo-adminservice-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloConfigDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境admin-service需要配置对应环境的数据库参数 ###### 2.2.1.1.2.3 配置apollo-portal的数据库连接信息 1. 解压`apollo-portal-x.x.x-github.zip` 2. 用程序员专用编辑器(如vim,notepad++,sublime等)打开`config`目录下的`application-github.properties`文件 3. 填写正确的ApolloPortalDB数据库连接串信息,注意用户名和密码后面不要有空格! 4. 修改完的效果如下: ```properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?useSSL=false&characterEncoding=utf8 spring.datasource.username = someuser spring.datasource.password = somepwd ``` ###### 2.2.1.1.2.4 配置apollo-portal的meta service信息 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以我们需要在配置中提供这些信息。默认情况下,meta service和config service是部署在同一个JVM进程,所以meta service的地址就是config service的地址。 > 对于1.6.0及以上版本,可以通过ApolloPortalDB.ServerConfig中的配置项来配置Meta Service地址,详见[apollo.portal.meta.servers - 各环境Meta Service列表](#_312-apolloportalmetaservers-各环境meta-service列表) 使用程序员专用编辑器(如vim,notepad++,sublime等)打开`apollo-portal-x.x.x-github.zip`中`config`目录下的`apollo-env.properties`文件。 假设DEV的apollo-configservice未绑定域名,地址是1.1.1.1:8080,FAT的apollo-configservice绑定了域名apollo.fat.xxx.com,UAT的apollo-configservice绑定了域名apollo.uat.xxx.com,PRO的apollo-configservice绑定了域名apollo.xxx.com,那么可以如下修改各环境meta service服务地址,格式为`${env}.meta=http://${config-service-url:port}`,如果某个环境不需要,也可以直接删除对应的配置项(如lpt.meta): ```sh 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 ``` 除了通过`apollo-env.properties`方式配置meta service以外,apollo也支持在运行时指定meta service(优先级比`apollo-env.properties`高): 1. 通过Java System Property `${env}_meta` * 可以通过Java的System Property `${env}_meta`来指定 * 如`java -Ddev_meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("dev_meta", "http://config-service-url");` 2. 通过操作系统的System Environment`${ENV}_META` * 如`DEV_META=http://config-service-url` * 注意key为全大写,且中间是`_`分隔 >注1: 为了实现meta service的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡 >注2: meta service地址也可以填入IP,0.11.0版本之前只支持填入一个IP。从0.11.0版本开始支持填入以逗号分隔的多个地址([PR #1214](https://github.com/ctripcorp/apollo/pull/1214)),如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 #### 2.2.1.2 通过源码构建 ##### 2.2.1.2.1 配置数据库连接信息 Apollo服务端需要知道如何连接到你前面创建的数据库,所以需要编辑[scripts/build.sh](https://github.com/ctripcorp/apollo/blob/master/scripts/build.sh),修改ApolloPortalDB和ApolloConfigDB相关的数据库连接串信息。 > 注意:填入的用户需要具备对ApolloPortalDB和ApolloConfigDB数据的读写权限。 ```sh #apollo config db info apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?useSSL=false&characterEncoding=utf8 apollo_config_db_username=用户名 apollo_config_db_password=密码(如果没有密码,留空即可) # apollo portal db info apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?useSSL=false&characterEncoding=utf8 apollo_portal_db_username=用户名 apollo_portal_db_password=密码(如果没有密码,留空即可) ``` > 注1:由于ApolloConfigDB在每个环境都有部署,所以对不同的环境config-service和admin-service需要使用不同的数据库参数打不同的包,portal只需要打一次包即可 > 注2:如果不想config-service和admin-service每个环境打一个包的话,也可以通过运行时传入数据库连接串信息实现,具体可以参考 [Issue 869](https://github.com/ctripcorp/apollo/issues/869) > 注3:每个环境都需要独立部署一套config-service、admin-service和ApolloConfigDB ##### 2.2.1.2.2 配置各环境meta service地址 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以需要在打包时提供这些信息。 假设DEV的apollo-configservice未绑定域名,地址是1.1.1.1:8080,FAT的apollo-configservice绑定了域名apollo.fat.xxx.com,UAT的apollo-configservice绑定了域名apollo.uat.xxx.com,PRO的apollo-configservice绑定了域名apollo.xxx.com,那么编辑[scripts/build.sh](https://github.com/ctripcorp/apollo/blob/master/scripts/build.sh),如下修改各环境meta service服务地址,格式为`${env}_meta=http://${config-service-url:port}`,如果某个环境不需要,也可以直接删除对应的配置项: ```sh 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_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta" ``` 除了在打包时配置meta service以外,apollo也支持在运行时指定meta service: 1. 通过Java System Property `${env}_meta` * 可以通过Java的System Property `${env}_meta`来指定 * 如`java -Ddev_meta=http://config-service-url -jar xxx.jar` * 也可以通过程序指定,如`System.setProperty("dev_meta", "http://config-service-url");` 2. 通过操作系统的System Environment`${ENV}_META` * 如`DEV_META=http://config-service-url` * 注意key为全大写,且中间是`_`分隔 >注1: 为了实现meta service的高可用,推荐通过SLB(Software Load Balancer)做动态负载均衡 >注2: meta service地址也可以填入IP,0.11.0版本之前只支持填入一个IP。从0.11.0版本开始支持填入以逗号分隔的多个地址([PR #1214](https://github.com/ctripcorp/apollo/pull/1214)),如`http://1.1.1.1:8080,http://2.2.2.2:8080`,不过生产环境还是建议使用域名(走slb),因为机器扩容、缩容等都可能导致IP列表的变化。 ##### 2.2.1.2.3 执行编译、打包 做完上述配置后,就可以执行编译和打包了。 > 注:初次编译会从Maven中央仓库下载不少依赖,如果网络情况不佳时很容易出错,建议使用国内的Maven仓库源,比如[阿里云Maven镜像](http://www.cnblogs.com/geektown/p/5705405.html) ```sh ./build.sh ``` 该脚本会依次打包apollo-configservice, apollo-adminservice, apollo-portal。 > 注:由于ApolloConfigDB在每个环境都有部署,所以对不同环境的config-service和admin-service需要使用不同的数据库连接信息打不同的包,portal只需要打一次包即可 ##### 2.2.1.2.4 获取apollo-configservice安装包 位于`apollo-configservice/target/`目录下的`apollo-configservice-x.x.x-github.zip` 需要注意的是由于ApolloConfigDB在每个环境都有部署,所以对不同环境的config-service需要使用不同的数据库参数打不同的包后分别部署 ##### 2.2.1.2.5 获取apollo-adminservice安装包 位于`apollo-adminservice/target/`目录下的`apollo-adminservice-x.x.x-github.zip` 需要注意的是由于ApolloConfigDB在每个环境都有部署,所以对不同环境的admin-service需要使用不同的数据库参数打不同的包后分别部署 ##### 2.2.1.2.6 获取apollo-portal安装包 位于`apollo-portal/target/`目录下的`apollo-portal-x.x.x-github.zip` ##### 2.2.1.2.7 启用外部nacos服务注册中心替换内置eureka 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell mvn clean package -Pgithub,nacos-discovery -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,nacos-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password ``` 2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置nacos服务器地址 ```properties nacos.discovery.server-addr=127.0.0.1:8848 ``` ##### 2.2.1.2.8 启用外部Consul服务注册中心替换内置eureka 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,consul-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password ``` 2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置consul服务器地址 ```properties spring.cloud.consul.host=127.0.0.1 spring.cloud.consul.port=8500 ``` ### 2.2.2 部署Apollo服务端 #### 2.2.2.1 部署apollo-configservice 将对应环境的`apollo-configservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-configservice.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。另外apollo-configservice同时承担meta server职责,如果要修改端口,注意要同时ApolloConfigDB.ServerConfig表中的`eureka.service.url`配置项以及apollo-portal和apollo-client中的使用到的meta server信息,详见:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)和[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 > 注4:如果ApolloConfigDB.ServerConfig的eureka.service.url只配了当前正在启动的机器的话,在启动apollo-configservice的过程中会在日志中输出eureka注册失败的信息,如`com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused`。需要注意的是,这个是预期的情况,因为apollo-configservice需要向Meta Server(它自己)注册服务,但是因为在启动过程中,自己还没起来,所以会报这个错。后面会进行重试的动作,所以等自己服务起来后就会注册正常了。 > 注5:如果你看到了这里,相信你一定是一个细心阅读文档的人,而且离成功就差一点点了,继续加油,应该很快就能完成Apollo的分布式部署了!不过你是否有感觉Apollo的分布式部署步骤有点繁琐?是否有啥建议想要和作者说?如果答案是肯定的话,请移步 [#1424](https://github.com/ctripcorp/apollo/issues/1424),期待你的建议! #### 2.2.2.2 部署apollo-adminservice 将对应环境的`apollo-adminservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-adminservice.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 #### 2.2.2.3 部署apollo-portal 将`apollo-portal-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. 记得在startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: ```bash export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" ``` > 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 > 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-portal.conf中的`LOG_DIR`。 > 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 ## 2.3 Docker部署 ### 2.3.1 1.7.0及以上版本 Apollo 1.7.0版本开始会默认上传Docker镜像到[Docker Hub](https://hub.docker.com/u/apolloconfig),可以按照如下步骤获取 #### 2.3.1.1 Apollo Config Service ##### 2.3.1.1.1 获取镜像 ```bash docker pull apolloconfig/apollo-configservice:${version} ``` ##### 2.3.1.1.2 运行镜像 示例: ```bash 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:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloConfigDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloConfigDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloConfigDB的密码 #### 2.3.1.2 Apollo Admin Service ##### 2.3.1.2.1 获取镜像 ```bash docker pull apolloconfig/apollo-adminservice:${version} ``` ##### 2.3.1.2.2 运行镜像 示例: ```bash docker run -p 8090:8090 \ -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-adminservice apolloconfig/apollo-adminservice:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloConfigDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloConfigDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloConfigDB的密码 #### 2.3.1.3 Apollo Portal ##### 2.3.1.3.1 获取镜像 ```bash docker pull apolloconfig/apollo-portal:${version} ``` ##### 2.3.1.3.2 运行镜像 示例: ```bash docker run -p 8070:8070 \ -e SPRING_DATASOURCE_URL="jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8" \ -e SPRING_DATASOURCE_USERNAME=FillInCorrectUser -e SPRING_DATASOURCE_PASSWORD=FillInCorrectPassword \ -e APOLLO_PORTAL_ENVS=dev,pro \ -e DEV_META=http://fill-in-dev-meta-server:8080 -e PRO_META=http://fill-in-pro-meta-server:8080 \ -d -v /tmp/logs:/opt/logs --name apollo-portal apolloconfig/apollo-portal:${version} ``` 参数说明: * SPRING_DATASOURCE_URL: 对应环境ApolloPortalDB的地址 * SPRING_DATASOURCE_USERNAME: 对应环境ApolloPortalDB的用户名 * SPRING_DATASOURCE_PASSWORD: 对应环境ApolloPortalDB的密码 * APOLLO_PORTAL_ENVS(可选): 对应ApolloPortalDB中的[apollo.portal.envs](#_311-apolloportalenvs-可支持的环境列表)配置项,如果没有在数据库中配置的话,可以通过此环境参数配置 * DEV_META/PRO_META(可选): 配置对应环境的Meta Service地址,以${ENV}_META命名,需要注意的是如果配置了ApolloPortalDB中的[apollo.portal.meta.servers](#_312-apolloportalmetaservers-各环境meta-service列表)配置,则以apollo.portal.meta.servers中的配置为准 #### 2.3.1.4 通过源码构建 Docker 镜像 如果修改了 apollo 服务端的代码,希望通过源码构建 Docker 镜像,可以参考下面的步骤: 1. 通过源码构建安装包:`./scripts/build.sh` 2. 构建 Docker 镜像:`mvn docker:build -pl apollo-configservice,apollo-adminservice,apollo-portal` ### 2.3.2 1.7.0之前的版本 Apollo项目已经自带了Docker file,可以参照[2.2.1 获取安装包](#_221-获取安装包)配置好安装包后通过下面的文件来打Docker镜像: 1. [apollo-configservice](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/docker/Dockerfile) 2. [apollo-adminservice](https://github.com/ctripcorp/apollo/blob/master/apollo-adminservice/src/main/docker/Dockerfile) 3. [apollo-portal](https://github.com/ctripcorp/apollo/blob/master/apollo-portal/src/main/docker/Dockerfile) 也可以参考Apollo用户[@kulovecc](https://github.com/kulovecc)的[docker-apollo](https://github.com/kulovecc/docker-apollo)项目和[@idoop](https://github.com/idoop)的[docker-apollo](https://github.com/idoop/docker-apollo)项目。 ## 2.4 Kubernetes部署 ### 2.4.1 基于Kubernetes原生服务发现 Apollo 1.7.0版本增加了基于Kubernetes原生服务发现的部署模式,由于不再使用内置的Eureka,所以在整体部署上有很大简化,同时也提供了Helm Charts,便于部署。 > 更多设计说明可以参考[#3054](https://github.com/ctripcorp/apollo/issues/3054)。 #### 2.4.1.1 环境要求 - Kubernetes 1.10+ - Helm 3 #### 2.4.1.2 添加Apollo Helm Chart仓库 ```bash $ helm repo add apollo https://www.apolloconfig.com/charts $ helm search repo apollo ``` #### 2.4.1.3 部署apollo-configservice和apollo-adminservice ##### 2.4.1.3.1 安装apollo-configservice和apollo-adminservice 需要在每个环境中安装apollo-configservice和apollo-adminservice,所以建议在release名称中加入环境信息,例如:`apollo-service-dev` ```bash $ helm install apollo-service-dev \ --set configdb.host=1.2.3.4 \ --set configdb.userName=apollo \ --set configdb.password=apollo \ --set configdb.service.enabled=true \ --set configService.replicaCount=1 \ --set adminService.replicaCount=1 \ -n your-namespace \ apollo/apollo-service ``` 一般部署建议通过 values.yaml 来配置: ```bash $ helm install apollo-service-dev -f values.yaml -n your-namespace apollo/apollo-service ``` 安装完成后会提示对应环境的Meta Server地址,需要记录下来,apollo-portal安装时需要用到: ```bash Get meta service url for current release by running these commands: echo http://apollo-service-dev-apollo-configservice:8080 ``` > 更多配置项说明可以参考[2.4.1.3.3 配置项说明](#_24133-配置项说明) ##### 2.4.1.3.2 卸载apollo-configservice和apollo-adminservice 例如要卸载`apollo-service-dev`的部署: ```bash $ helm uninstall -n your-namespace apollo-service-dev ``` ##### 2.4.1.3.3 配置项说明 下表列出了apollo-service chart的可配置参数及其默认值: | Parameter | Description | Default | |----------------------|---------------------------------------------|---------------------| | `configdb.host` | The host for apollo config db | `nil` | | `configdb.port` | The port for apollo config db | `3306` | | `configdb.dbName` | The database name for apollo config db | `ApolloConfigDB` | | `configdb.userName` | The user name for apollo config db | `nil` | | `configdb.password` | The password for apollo config db | `nil` | | `configdb.connectionStringProperties` | The connection string properties for apollo config db | `characterEncoding=utf8` | | `configdb.service.enabled` | Whether to create a Kubernetes Service for `configdb.host` or not. Set it to `true` if `configdb.host` is an endpoint outside of the kubernetes cluster | `false` | | `configdb.service.fullNameOverride` | Override the service name for apollo config db | `nil` | | `configdb.service.port` | The port for the service of apollo config db | `3306` | | `configdb.service.type` | The service type of apollo config db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. `xxx.mysql.rds.aliyuncs.com` | `ClusterIP` | | `configService.fullNameOverride` | Override the deployment name for apollo-configservice | `nil` | | `configService.replicaCount` | Replica count of apollo-configservice | `2` | | `configService.containerPort` | Container port of apollo-configservice | `8080` | | `configService.image.repository` | Image repository of apollo-configservice | `apolloconfig/apollo-configservice` | | `configService.image.tag` | Image tag of apollo-configservice, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `configService.image.pullPolicy` | Image pull policy of apollo-configservice | `IfNotPresent` | | `configService.imagePullSecrets` | Image pull secrets of apollo-configservice | `[]` | | `configService.service.fullNameOverride` | Override the service name for apollo-configservice | `nil` | | `configService.service.port` | The port for the service of apollo-configservice | `8080` | | `configService.service.targetPort` | The target port for the service of apollo-configservice | `8080` | | `configService.service.type` | The service type of apollo-configservice | `ClusterIP` | | `configService.ingress.enabled` | Whether to enable the ingress for config-service or not. _(chart version >= 0.2.0)_ | `false` | | `configService.ingress.annotations` | The annotations of the ingress for config-service. _(chart version >= 0.2.0)_ | `{}` | | `configService.ingress.hosts.host` | The host of the ingress for config-service. _(chart version >= 0.2.0)_ | `nil` | | `configService.ingress.hosts.paths` | The paths of the ingress for config-service. _(chart version >= 0.2.0)_ | `[]` | | `configService.ingress.tls` | The tls definition of the ingress for config-service. _(chart version >= 0.2.0)_ | `[]` | | `configService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `configService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `configService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `configService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `configService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `configService.config.configServiceUrlOverride` | Override `apollo.config-service.url`: config service url to be accessed by apollo-client, e.g. `http://apollo-config-service-dev:8080` | `nil` | | `configService.config.adminServiceUrlOverride` | Override `apollo.admin-service.url`: admin service url to be accessed by apollo-portal, e.g. `http://apollo-admin-service-dev:8090` | `nil` | | `configService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access config service via `http://{config_service_address}/apollo`. _(chart version >= 0.2.0)_ | `nil` | | `configService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `configService.strategy` | The deployment strategy of apollo-configservice | `{}` | | `configService.resources` | The resources definition of apollo-configservice | `{}` | | `configService.nodeSelector` | The node selector definition of apollo-configservice | `{}` | | `configService.tolerations` | The tolerations definition of apollo-configservice | `[]` | | `configService.affinity` | The affinity definition of apollo-configservice | `{}` | | `adminService.fullNameOverride` | Override the deployment name for apollo-adminservice | `nil` | | `adminService.replicaCount` | Replica count of apollo-adminservice | `2` | | `adminService.containerPort` | Container port of apollo-adminservice | `8090` | | `adminService.image.repository` | Image repository of apollo-adminservice | `apolloconfig/apollo-adminservice` | | `adminService.image.tag` | Image tag of apollo-adminservice, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `adminService.image.pullPolicy` | Image pull policy of apollo-adminservice | `IfNotPresent` | | `adminService.imagePullSecrets` | Image pull secrets of apollo-adminservice | `[]` | | `adminService.service.fullNameOverride` | Override the service name for apollo-adminservice | `nil` | | `adminService.service.port` | The port for the service of apollo-adminservice | `8090` | | `adminService.service.targetPort` | The target port for the service of apollo-adminservice | `8090` | | `adminService.service.type` | The service type of apollo-adminservice | `ClusterIP` | | `adminService.ingress.enabled` | Whether to enable the ingress for admin-service or not. _(chart version >= 0.2.0)_ | `false` | | `adminService.ingress.annotations` | The annotations of the ingress for admin-service. _(chart version >= 0.2.0)_ | `{}` | | `adminService.ingress.hosts.host` | The host of the ingress for admin-service. _(chart version >= 0.2.0)_ | `nil` | | `adminService.ingress.hosts.paths` | The paths of the ingress for admin-service. _(chart version >= 0.2.0)_ | `[]` | | `adminService.ingress.tls` | The tls definition of the ingress for admin-service. _(chart version >= 0.2.0)_ | `[]` | | `adminService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `adminService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `adminService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `adminService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `adminService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `adminService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access admin service via `http://{admin_service_address}/apollo`. _(chart version >= 0.2.0)_ | `nil` | | `adminService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `adminService.strategy` | The deployment strategy of apollo-adminservice | `{}` | | `adminService.resources` | The resources definition of apollo-adminservice | `{}` | | `adminService.nodeSelector` | The node selector definition of apollo-adminservice | `{}` | | `adminService.tolerations` | The tolerations definition of apollo-adminservice | `[]` | | `adminService.affinity` | The affinity definition of apollo-adminservice | `{}` | ##### 2.4.1.3.4 配置样例 ###### 2.4.1.3.4.1 ConfigDB的host是k8s集群外的IP ```yaml configdb: host: 1.2.3.4 dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` ###### 2.4.1.3.4.2 ConfigDB的host是k8s集群外的域名 ```yaml configdb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` ###### 2.4.1.3.4.3 ConfigDB的host是k8s集群内的一个服务 ```yaml configdb: host: apollodb-mysql.mysql dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` ###### 2.4.1.3.4.4 指定Meta Server返回的apollo-configservice地址 如果apollo-client无法直接访问apollo-configservice的Service(比如不在同一个k8s集群),那么可以参照下面的示例指定Meta Server返回给apollo-client的地址(比如可以通过nodeport访问) ```yaml configService: config: configServiceUrlOverride: http://1.2.3.4:12345 ``` ###### 2.4.1.3.4.5 指定Meta Server返回的apollo-adminservice地址 如果apollo-portal无法直接访问apollo-adminservice的Service(比如不在同一个k8s集群),那么可以参照下面的示例指定Meta Server返回给apollo-portal的地址(比如可以通过nodeport访问) ```yaml configService: config: adminServiceUrlOverride: http://1.2.3.4:23456 ``` ###### 2.4.1.3.4.6 以Ingress配置自定义路径`/config`形式暴露apollo-configservice服务 ```yaml # use /config as root, should specify configService.config.contextPath as /config configService: config: contextPath: /config ingress: enabled: true hosts: - paths: - /config ``` ###### 2.4.1.3.4.7 以Ingress配置自定义路径`/admin`形式暴露apollo-adminservice服务 ```yaml # use /admin as root, should specify adminService.config.contextPath as /admin adminService: config: contextPath: /admin ingress: enabled: true hosts: - paths: - /admin ``` #### 2.4.1.4 部署apollo-portal ##### 2.4.1.4.1 安装apollo-portal 假设有dev, pro两个环境,且meta server地址分别为`http://apollo-service-dev-apollo-configservice:8080`和`http://apollo-service-pro-apollo-configservice:8080`: ```bash $ helm install apollo-portal \ --set portaldb.host=1.2.3.4 \ --set portaldb.userName=apollo \ --set portaldb.password=apollo \ --set portaldb.service.enabled=true \ --set config.envs="dev\,pro" \ --set config.metaServers.dev=http://apollo-service-dev-apollo-configservice:8080 \ --set config.metaServers.pro=http://apollo-service-pro-apollo-configservice:8080 \ --set replicaCount=1 \ -n your-namespace \ apollo/apollo-portal ``` 一般部署建议通过 values.yaml 来配置: ```bash $ helm install apollo-portal -f values.yaml -n your-namespace apollo/apollo-portal ``` > 更多配置项说明可以参考[2.4.1.4.3 配置项说明](#_24143-配置项说明) ##### 2.4.1.4.2 卸载apollo-portal 例如要卸载`apollo-portal`的部署: ```bash $ helm uninstall -n your-namespace apollo-portal ``` ##### 2.4.1.4.3 配置项说明 下表列出了apollo-portal chart的可配置参数及其默认值: | Parameter | Description | Default | |----------------------|---------------------------------------------|-----------------------| | `fullNameOverride` | Override the deployment name for apollo-portal | `nil` | | `replicaCount` | Replica count of apollo-portal | `2` | | `containerPort` | Container port of apollo-portal | `8070` | | `image.repository` | Image repository of apollo-portal | `apolloconfig/apollo-portal` | | `image.tag` | Image tag of apollo-portal, e.g. `1.8.0`, leave it to `nil` to use the default version. _(chart version >= 0.2.0)_ | `nil` | | `image.pullPolicy` | Image pull policy of apollo-portal | `IfNotPresent` | | `imagePullSecrets` | Image pull secrets of apollo-portal | `[]` | | `service.fullNameOverride` | Override the service name for apollo-portal | `nil` | | `service.port` | The port for the service of apollo-portal | `8070` | | `service.targetPort` | The target port for the service of apollo-portal | `8070` | | `service.type` | The service type of apollo-portal | `ClusterIP` | | `service.sessionAffinity` | The session affinity for the service of apollo-portal | `ClientIP` | | `ingress.enabled` | Whether to enable the ingress or not | `false` | | `ingress.annotations` | The annotations of the ingress | `{}` | | `ingress.hosts.host` | The host of the ingress | `nil` | | `ingress.hosts.paths` | The paths of the ingress | `[]` | | `ingress.tls` | The tls definition of the ingress | `[]` | | `liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `strategy` | The deployment strategy of apollo-portal | `{}` | | `resources` | The resources definition of apollo-portal | `{}` | | `nodeSelector` | The node selector definition of apollo-portal | `{}` | | `tolerations` | The tolerations definition of apollo-portal | `[]` | | `affinity` | The affinity definition of apollo-portal | `{}` | | `config.profiles` | specify the spring profiles to activate | `github,auth` | | `config.envs` | specify the env names, e.g. `dev,pro` | `nil` | | `config.contextPath` | specify the context path, e.g. `/apollo`, then users could access portal via `http://{portal_address}/apollo` | `nil` | | `config.metaServers` | specify the meta servers, e.g.<br />`dev: http://apollo-configservice-dev:8080`<br />`pro: http://apollo-configservice-pro:8080` | `{}` | | `config.files` | specify the extra config files for apollo-portal, e.g. `application-ldap.yml` | `{}` | | `portaldb.host` | The host for apollo portal db | `nil` | | `portaldb.port` | The port for apollo portal db | `3306` | | `portaldb.dbName` | The database name for apollo portal db | `ApolloPortalDB` | | `portaldb.userName` | The user name for apollo portal db | `nil` | | `portaldb.password` | The password for apollo portal db | `nil` | | `portaldb.connectionStringProperties` | The connection string properties for apollo portal db | `characterEncoding=utf8` | | `portaldb.service.enabled` | Whether to create a Kubernetes Service for `portaldb.host` or not. Set it to `true` if `portaldb.host` is an endpoint outside of the kubernetes cluster | `false` | | `portaldb.service.fullNameOverride` | Override the service name for apollo portal db | `nil` | | `portaldb.service.port` | The port for the service of apollo portal db | `3306` | | `portaldb.service.type` | The service type of apollo portal db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. `xxx.mysql.rds.aliyuncs.com` | `ClusterIP` | ##### 2.4.1.4.4 配置样例 ###### 2.4.1.4.4.1 PortalDB的host是k8s集群外的IP ```yaml portaldb: host: 1.2.3.4 dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` ###### 2.4.1.4.4.2 PortalDB的host是k8s集群外的域名 ```yaml portaldb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` ###### 2.4.1.4.4.3 PortalDB的host是k8s集群内的一个服务 ```yaml portaldb: host: apollodb-mysql.mysql dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` ###### 2.4.1.4.4.4 配置环境信息 ```yaml config: envs: dev,pro metaServers: dev: http://apollo-service-dev-apollo-configservice:8080 pro: http://apollo-service-pro-apollo-configservice:8080 ``` ###### 2.4.1.4.4.5 以Load Balancer形式暴露服务 ```yaml service: type: LoadBalancer ``` ###### 2.4.1.4.4.6 以Ingress形式暴露服务 ```yaml ingress: enabled: true hosts: - paths: - / ``` ###### 2.4.1.4.4.7 以Ingress配置自定义路径`/apollo`形式暴露服务 ```yaml # use /apollo as root, should specify config.contextPath as /apollo ingress: enabled: true hosts: - paths: - /apollo config: ... contextPath: /apollo ... ``` ###### 2.4.1.4.4.8 以Ingress配置session affinity形式暴露服务 ```yaml ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/affinity: "cookie" nginx.ingress.kubernetes.io/affinity-mode: "persistent" nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none: "true" nginx.ingress.kubernetes.io/session-cookie-expires: "172800" nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" hosts: - host: xxx.somedomain.com # host is required to make session affinity work paths: - / ``` ###### 2.4.1.4.4.9 启用 LDAP 支持 ```yaml config: ... profiles: github,ldap ... files: application-ldap.yml: | spring: ldap: base: "dc=example,dc=org" username: "cn=admin,dc=example,dc=org" password: "password" searchFilter: "(uid={0})" urls: - "ldap://xxx.somedomain.com:389" ldap: mapping: objectClass: "inetOrgPerson" loginId: "uid" userDisplayName: "cn" email: "mail" ``` #### 2.4.1.5 通过源码构建 Docker 镜像 如果修改了 apollo 服务端的代码,希望通过源码构建 Docker 镜像,可以参考[2.3.1.4 通过源码构建 Docker 镜像](#_2314-通过源码构建-docker-镜像)的步骤。 ### 2.4.2 基于内置的Eureka服务发现 感谢[AiotCEO](https://github.com/AiotCEO)提供了k8s的部署支持,使用说明可以参考[apollo-on-kubernetes](https://github.com/ctripcorp/apollo/blob/master/scripts/apollo-on-kubernetes/README.md)。 感谢[qct](https://github.com/qct)提供的Helm Chart部署支持,使用说明可以参考[qct/apollo-helm](https://github.com/qct/apollo-helm)。 # 三、服务端配置说明 > 以下配置除了支持在数据库中配置以外,也支持通过-D参数、application.properties等配置,且-D参数、application.properties等优先级高于数据库中的配置 ## 3.1 调整ApolloPortalDB配置 配置项统一存储在ApolloPortalDB.ServerConfig表中,也可以通过`管理员工具 - 系统参数`页面进行配置,无特殊说明则修改完一分钟实时生效。 ### 3.1.1 apollo.portal.envs - 可支持的环境列表 默认值是dev,如果portal需要管理多个环境的话,以逗号分隔即可(大小写不敏感),如: ``` DEV,FAT,UAT,PRO ``` 修改完需要重启生效。 >注1:一套Portal可以管理多个环境,但是每个环境都需要独立部署一套Config Service、Admin Service和ApolloConfigDB,具体请参考:[2.1.2 创建ApolloConfigDB](#_212-创建apolloconfigdb),[3.2 调整ApolloConfigDB配置](zh/deployment/distributed-deployment-guide?id=_32-调整apolloconfigdb配置),[2.2.1.1.2 配置数据库连接信息](#_22112-配置数据库连接信息),另外如果是为已经运行了一段时间的Apollo配置中心增加环境,别忘了参考[2.1.2.4 从别的环境导入ApolloConfigDB的项目数据](#_2124-从别的环境导入apolloconfigdb的项目数据)对新的环境做初始化。 >注2:只在数据库添加环境是不起作用的,还需要为apollo-portal添加新增环境对应的meta server地址,具体参考:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)。apollo-client在新的环境下使用时也需要做好相应的配置,具体参考:[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 >注3:如果希望添加自定义的环境名称,具体步骤可以参考[Portal如何增加环境](zh/faq/common-issues-in-deployment-and-development-phase?id=_4-portal如何增加环境?)。 >注4:1.1.0版本增加了系统信息页面(`管理员工具` -> `系统信息`),可以通过该页面检查配置是否正确 ### 3.1.2 apollo.portal.meta.servers - 各环境Meta Service列表 > 适用于1.6.0及以上版本 Apollo Portal需要在不同的环境访问不同的meta service(apollo-configservice)地址,所以我们需要在配置中提供这些信息。默认情况下,meta service和config service是部署在同一个JVM进程,所以meta service的地址就是config service的地址。 样例如下: ```json { "DEV":"http://1.1.1.1:8080", "FAT":"http://apollo.fat.xxx.com", "UAT":"http://apollo.uat.xxx.com", "PRO":"http://apollo.xxx.com" } ``` 修改完需要重启生效。 > 该配置优先级高于其它方式设置的Meta Service地址,更多信息可以参考[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)。 ### 3.1.3 organizations - 部门列表 Portal中新建的App都需要选择部门,所以需要在这里配置可选的部门信息,样例如下: ```json [{"orgId":"TEST1","orgName":"样例部门1"},{"orgId":"TEST2","orgName":"样例部门2"}] ``` ### 3.1.4 superAdmin - Portal超级管理员 超级管理员拥有所有权限,需要谨慎设置。 如果没有接入自己公司的SSO系统的话,可以先暂时使用默认值apollo(默认用户)。等接入后,修改为实际使用的账号,多个账号以英文逗号分隔(,)。 ### 3.1.5 consumer.token.salt - consumer token salt 如果会使用开放平台API的话,可以设置一个token salt。如果不使用,可以忽略。 ### 3.1.6 wiki.address portal上“帮助”链接的地址,默认是Apollo github的wiki首页,可自行设置。 ### 3.1.7 admin.createPrivateNamespace.switch 是否允许项目管理员创建private namespace。设置为`true`允许创建,设置为`false`则项目管理员在页面上看不到创建private namespace的选项。[了解更多Namespace](zh/design/apollo-core-concept-namespace) ### 3.1.8 emergencyPublish.supported.envs 配置允许紧急发布的环境列表,多个env以英文逗号分隔。 当config service开启一次发布只能有一个人修改开关(`namespace.lock.switch`)后,一次配置发布只能是一个人修改,另一个发布。为了避免遇到紧急情况时(如非工作时间、节假日)无法发布配置,可以配置此项以允许某些环境可以操作紧急发布,即同一个人可以修改并发布配置。 ### 3.1.9 configView.memberOnly.envs 只对项目成员显示配置信息的环境列表,多个env以英文逗号分隔。 对设定了只对项目成员显示配置信息的环境,只有该项目的管理员或拥有该namespace的编辑或发布权限的用户才能看到该私有namespace的配置信息和发布历史。公共namespace始终对所有用户可见。 > 从1.1.0版本开始支持,详见[PR 1531](https://github.com/ctripcorp/apollo/pull/1531) ### 3.1.10 role.create-application.enabled - 是否开启创建项目权限控制 > 适用于1.5.0及以上版本 默认为false,所有用户都可以创建项目 如果设置为true,那么只有超级管理员和拥有创建项目权限的帐号可以创建项目,超级管理员可以通过`管理员工具 - 系统权限管理`给用户分配创建项目权限 ### 3.1.11 role.manage-app-master.enabled - 是否开启项目管理员分配权限控制 > 适用于1.5.0及以上版本 默认为false,所有项目的管理员可以为项目添加/删除管理员 如果设置为true,那么只有超级管理员和拥有项目管理员分配权限的帐号可以为特定项目添加/删除管理员,超级管理员可以通过`管理员工具 - 系统权限管理`给用户分配特定项目的管理员分配权限 ### 3.1.12 admin-service.access.tokens - 设置apollo-portal访问各环境apollo-adminservice所需的access token > 适用于1.7.1及以上版本 如果对应环境的apollo-adminservice开启了[访问控制](#_326-admin-serviceaccesscontrolenabled-配置apollo-adminservice是否开启访问控制),那么需要在此配置apollo-portal访问该环境apollo-adminservice所需的access token,否则会访问失败 格式为json,如下所示: ```json { "dev" : "098f6bcd4621d373cade4e832627b4f6", "pro" : "ad0234829205b9033196ba818f7a872b" } ``` ## 3.2 调整ApolloConfigDB配置 配置项统一存储在ApolloConfigDB.ServerConfig表中,需要注意每个环境的ApolloConfigDB.ServerConfig都需要单独配置,修改完一分钟实时生效。 ### 3.2.1 eureka.service.url - Eureka服务Url > 不适用于基于Kubernetes原生服务发现场景 不管是apollo-configservice还是apollo-adminservice都需要向eureka服务注册,所以需要配置eureka服务地址。 按照目前的实现,apollo-configservice本身就是一个eureka服务,所以只需要填入apollo-configservice的地址即可,如有多个,用逗号分隔(注意不要忘了/eureka/后缀)。 需要注意的是每个环境只填入自己环境的eureka服务地址,比如FAT的apollo-configservice是1.1.1.1:8080和2.2.2.2:8080,UAT的apollo-configservice是3.3.3.3:8080和4.4.4.4:8080,PRO的apollo-configservice是5.5.5.5:8080和6.6.6.6:8080,那么: 1. 在FAT环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://1.1.1.1:8080/eureka/,http://2.2.2.2:8080/eureka/ ``` 2. 在UAT环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://3.3.3.3:8080/eureka/,http://4.4.4.4:8080/eureka/ ``` 3. 在PRO环境的ApolloConfigDB.ServerConfig表中设置eureka.service.url为: ``` http://5.5.5.5:8080/eureka/,http://6.6.6.6:8080/eureka/ ``` >注1:这里需要填写本环境中全部的eureka服务地址,因为eureka需要互相复制注册信息 >注2:如果希望将Config Service和Admin Service注册到公司统一的Eureka上,可以参考[部署&开发遇到的常见问题 - 将Config Service和Admin Service注册到单独的Eureka Server上](zh/faq/common-issues-in-deployment-and-development-phase#_8-将config-service和admin-service注册到单独的eureka-server上)章节 >注3:在多机房部署时,往往希望config service和admin service只向同机房的eureka注册,要实现这个效果,需要利用`ServerConfig`表中的cluster字段,config service和admin service会读取所在机器的`/opt/settings/server.properties`(Mac/Linux)或`C:\opt\settings\server.properties`(Windows)中的idc属性,如果该idc有对应的eureka.service.url配置,那么就只会向该机房的eureka注册。比如config service和admin service会部署到`SHAOY`和`SHAJQ`两个IDC,那么为了实现这两个机房中的服务只向该机房注册,那么可以在`ServerConfig`表中新增两条记录,分别填入`SHAOY`和`SHAJQ`两个机房的eureka地址即可,`default` cluster的记录可以保留,如果有config service和admin service不是部署在`SHAOY`和`SHAJQ`这两个机房的,就会使用这条默认配置。 | Key |Cluster | Value | Comment | |--------------------|-----------|-------------------------------|---------------------| | eureka.service.url | default | http://1.1.1.1:8080/eureka/ | 默认的Eureka服务Url | | eureka.service.url | SHAOY | http://2.2.2.2:8080/eureka/ | SHAOY的Eureka服务Url | | eureka.service.url | SHAJQ | http://3.3.3.3:8080/eureka/ | SHAJQ的Eureka服务Url | ### 3.2.2 namespace.lock.switch - 一次发布只能有一个人修改开关,用于发布审核 这是一个功能开关,如果配置为true的话,那么一次配置发布只能是一个人修改,另一个发布。 > 生产环境建议开启此选项 ### 3.2.3 config-service.cache.enabled - 是否开启配置缓存 这是一个功能开关,如果配置为true的话,config service会缓存加载过的配置信息,从而加快后续配置获取性能。 默认为false,开启前请先评估总配置大小并调整config service内存配置。 > 开启缓存后必须确保应用中配置的app.id大小写正确,否则将获取不到正确的配置 ### 3.2.4 item.key.length.limit - 配置项 key 最大长度限制 默认配置是128。 ### 3.2.5 item.value.length.limit - 配置项 value 最大长度限制 默认配置是20000。 ### 3.2.6 admin-service.access.control.enabled - 配置apollo-adminservice是否开启访问控制 > 适用于1.7.1及以上版本 默认为false,如果配置为true,那么apollo-portal就需要[正确配置](#_3112-admin-serviceaccesstokens-设置apollo-portal访问各环境apollo-adminservice所需的access-token)访问该环境的access token,否则访问会被拒绝 ### 3.2.7 admin-service.access.tokens - 配置允许访问apollo-adminservice的access token列表 > 适用于1.7.1及以上版本 如果该配置项为空,那么访问控制不会生效。如果允许多个token,token 之间以英文逗号分隔 样例: ```properties admin-service.access.tokens=098f6bcd4621d373cade4e832627b4f6 admin-service.access.tokens=098f6bcd4621d373cade4e832627b4f6,ad0234829205b9033196ba818f7a872b ```
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./scripts/helm/README.md
# Apollo Helm Chart [Apollo](https://github.com/ctripcorp/apollo) is a reliable configuration management system. ## 1. Introduction The apollo-service and apollo-portal charts create deployments for apollo-configservice, apollo-adminservice and apollo-portal, which utilize the kubernetes native service discovery. ## 2. Prerequisites - Kubernetes 1.10+ - Helm 3 ## 3. Add Apollo Helm Chart Repository ```bash $ helm repo add apollo https://ctripcorp.github.io/apollo/charts $ helm search repo apollo ``` ## 4. Deployments of apollo-configservice and apollo-adminservice ### 4.1 Install apollo-configservice and apollo-adminservice should be installed per environment, so it is suggested to indicate environment in the release name, e.g. `apollo-service-dev` ```bash $ helm install apollo-service-dev \ --set configdb.host=1.2.3.4 \ --set configdb.userName=apollo \ --set configdb.password=apollo \ --set configdb.service.enabled=true \ --set configService.replicaCount=1 \ --set adminService.replicaCount=1 \ -n your-namespace \ apollo/apollo-service ``` Or customize it with values.yaml ```bash $ helm install apollo-service-dev -f values.yaml -n your-namespace apollo/apollo-service ``` ### 4.2 Uninstall To uninstall/delete the `apollo-service-dev` deployment: ```bash $ helm uninstall -n your-namespace apollo-service-dev ``` ### 4.3 Configuration The following table lists the configurable parameters of the apollo-service chart and their default values. | Parameter | Description | Default | |----------------------|---------------------------------------------|---------------------| | `configdb.host` | The host for apollo config db | `nil` | | `configdb.port` | The port for apollo config db | `3306` | | `configdb.dbName` | The database name for apollo config db | `ApolloConfigDB` | | `configdb.userName` | The user name for apollo config db | `nil` | | `configdb.password` | The password for apollo config db | `nil` | | `configdb.connectionStringProperties` | The connection string properties for apollo config db | `characterEncoding=utf8` | | `configdb.service.enabled` | Whether to create a Kubernetes Service for `configdb.host` or not. Set it to `true` if `configdb.host` is an endpoint outside of the kubernetes cluster | `false` | | `configdb.service.fullNameOverride` | Override the service name for apollo config db | `nil` | | `configdb.service.port` | The port for the service of apollo config db | `3306` | | `configdb.service.type` | The service type of apollo config db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. xxx.mysql.rds.aliyuncs.com | `ClusterIP` | | `configService.fullNameOverride` | Override the deployment name for apollo-configservice | `nil` | | `configService.replicaCount` | Replica count of apollo-configservice | `2` | | `configService.containerPort` | Container port of apollo-configservice | `8080` | | `configService.image.repository` | Image repository of apollo-configservice | `apolloconfig/apollo-configservice` | | `configService.image.tag` | Image tag of apollo-configservice, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `configService.image.pullPolicy` | Image pull policy of apollo-configservice | `IfNotPresent` | | `configService.imagePullSecrets` | Image pull secrets of apollo-configservice | `[]` | | `configService.service.fullNameOverride` | Override the service name for apollo-configservice | `nil` | | `configService.service.port` | The port for the service of apollo-configservice | `8080` | | `configService.service.targetPort` | The target port for the service of apollo-configservice | `8080` | | `configService.service.type` | The service type of apollo-configservice | `ClusterIP` | | `configService.ingress.enabled` | Whether to enable the ingress for config-service or not | `false` | | `configService.ingress.annotations` | The annotations of the ingress for config-service | `{}` | | `configService.ingress.hosts.host` | The host of the ingress for config-service | `nil` | | `configService.ingress.hosts.paths` | The paths of the ingress for config-service | `[]` | | `configService.ingress.tls` | The tls definition of the ingress for config-service | `[]` | | `configService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `configService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `configService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `configService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `configService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `configService.config.configServiceUrlOverride` | Override `apollo.config-service.url`: config service url to be accessed by apollo-client | `nil` | | `configService.config.adminServiceUrlOverride` | Override `apollo.admin-service.url`: admin service url to be accessed by apollo-portal | `nil` | | `configService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access config service via `http://{config_service_address}/apollo` | `nil` | | `configService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `configService.strategy` | The deployment strategy of apollo-configservice | `{}` | | `configService.resources` | The resources definition of apollo-configservice | `{}` | | `configService.nodeSelector` | The node selector definition of apollo-configservice | `{}` | | `configService.tolerations` | The tolerations definition of apollo-configservice | `[]` | | `configService.affinity` | The affinity definition of apollo-configservice | `{}` | | `adminService.fullNameOverride` | Override the deployment name for apollo-adminservice | `nil` | | `adminService.replicaCount` | Replica count of apollo-adminservice | `2` | | `adminService.containerPort` | Container port of apollo-adminservice | `8090` | | `adminService.image.repository` | Image repository of apollo-adminservice | `apolloconfig/apollo-adminservice` | | `adminService.image.tag` | Image tag of apollo-adminservice, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `adminService.image.pullPolicy` | Image pull policy of apollo-adminservice | `IfNotPresent` | | `adminService.imagePullSecrets` | Image pull secrets of apollo-adminservice | `[]` | | `adminService.service.fullNameOverride` | Override the service name for apollo-adminservice | `nil` | | `adminService.service.port` | The port for the service of apollo-adminservice | `8090` | | `adminService.service.targetPort` | The target port for the service of apollo-adminservice | `8090` | | `adminService.service.type` | The service type of apollo-adminservice | `ClusterIP` | | `adminService.ingress.enabled` | Whether to enable the ingress for admin-service or not | `false` | | `adminService.ingress.annotations` | The annotations of the ingress for admin-service | `{}` | | `adminService.ingress.hosts.host` | The host of the ingress for admin-service | `nil` | | `adminService.ingress.hosts.paths` | The paths of the ingress for admin-service | `[]` | | `adminService.ingress.tls` | The tls definition of the ingress for admin-service | `[]` | | `adminService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `adminService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `adminService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `adminService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `adminService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `adminService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access admin service via `http://{admin_service_address}/apollo` | `nil` | | `adminService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `adminService.strategy` | The deployment strategy of apollo-adminservice | `{}` | | `adminService.resources` | The resources definition of apollo-adminservice | `{}` | | `adminService.nodeSelector` | The node selector definition of apollo-adminservice | `{}` | | `adminService.tolerations` | The tolerations definition of apollo-adminservice | `[]` | | `adminService.affinity` | The affinity definition of apollo-adminservice | `{}` | ### 4.4 Sample 1. ConfigDB host is an IP outside of kubernetes cluster ```yaml configdb: host: 1.2.3.4 dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` 2. ConfigDB host is a dns name outside of kubernetes cluster ```yaml configdb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` 3. ConfigDB host is a kubernetes service ```yaml configdb: host: apollodb-mysql.mysql dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` 4. Expose config service as Ingress with custom path `/config` ```yaml # use /config as root, should specify configService.config.contextPath as /config configService: config: contextPath: /config ingress: enabled: true hosts: - paths: - /config ``` 5. Expose admin service as Ingress with custom path `/admin` ```yaml # use /admin as root, should specify adminService.config.contextPath as /admin adminService: config: contextPath: /admin ingress: enabled: true hosts: - paths: - /admin ``` ## 5. Deployments of apollo-portal ### 5.1 Install To install the apollo-portal chart with the release name `apollo-portal`: ```bash $ helm install apollo-portal \ --set portaldb.host=1.2.3.4 \ --set portaldb.userName=apollo \ --set portaldb.password=apollo \ --set portaldb.service.enabled=true \ --set config.envs="dev\,pro" \ --set config.metaServers.dev=http://apollo-service-dev-apollo-configservice:8080 \ --set config.metaServers.pro=http://apollo-service-pro-apollo-configservice:8080 \ --set replicaCount=1 \ -n your-namespace \ apollo/apollo-portal ``` Or customize it with values.yaml ```bash $ helm install apollo-portal -f values.yaml -n your-namespace apollo/apollo-portal ``` ### 5.2 Uninstallation To uninstall/delete the `apollo-portal` deployment: ```bash $ helm uninstall -n your-namespace apollo-portal ``` ### 5.3 Configuration The following table lists the configurable parameters of the apollo-portal chart and their default values. | Parameter | Description | Default | |----------------------|---------------------------------------------|-----------------------| | `fullNameOverride` | Override the deployment name for apollo-portal | `nil` | | `replicaCount` | Replica count of apollo-portal | `2` | | `containerPort` | Container port of apollo-portal | `8070` | | `image.repository` | Image repository of apollo-portal | `apolloconfig/apollo-portal` | | `image.tag` | Image tag of apollo-portal, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `image.pullPolicy` | Image pull policy of apollo-portal | `IfNotPresent` | | `imagePullSecrets` | Image pull secrets of apollo-portal | `[]` | | `service.fullNameOverride` | Override the service name for apollo-portal | `nil` | | `service.port` | The port for the service of apollo-portal | `8070` | | `service.targetPort` | The target port for the service of apollo-portal | `8070` | | `service.type` | The service type of apollo-portal | `ClusterIP` | | `service.sessionAffinity` | The session affinity for the service of apollo-portal | `ClientIP` | | `ingress.enabled` | Whether to enable the ingress or not | `false` | | `ingress.annotations` | The annotations of the ingress | `{}` | | `ingress.hosts.host` | The host of the ingress | `nil` | | `ingress.hosts.paths` | The paths of the ingress | `[]` | | `ingress.tls` | The tls definition of the ingress | `[]` | | `liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `strategy` | The deployment strategy of apollo-portal | `{}` | | `resources` | The resources definition of apollo-portal | `{}` | | `nodeSelector` | The node selector definition of apollo-portal | `{}` | | `tolerations` | The tolerations definition of apollo-portal | `[]` | | `affinity` | The affinity definition of apollo-portal | `{}` | | `config.profiles` | specify the spring profiles to activate | `github,auth` | | `config.envs` | specify the env names, e.g. dev,pro | `nil` | | `config.contextPath` | specify the context path, e.g. `/apollo`, then users could access portal via `http://{portal_address}/apollo` | `nil` | | `config.metaServers` | specify the meta servers, e.g.<br />`dev: http://apollo-configservice-dev:8080`<br />`pro: http://apollo-configservice-pro:8080` | `{}` | | `config.files` | specify the extra config files for apollo-portal, e.g. application-ldap.yml | `{}` | | `portaldb.host` | The host for apollo portal db | `nil` | | `portaldb.port` | The port for apollo portal db | `3306` | | `portaldb.dbName` | The database name for apollo portal db | `ApolloPortalDB` | | `portaldb.userName` | The user name for apollo portal db | `nil` | | `portaldb.password` | The password for apollo portal db | `nil` | | `portaldb.connectionStringProperties` | The connection string properties for apollo portal db | `characterEncoding=utf8` | | `portaldb.service.enabled` | Whether to create a Kubernetes Service for `portaldb.host` or not. Set it to `true` if `portaldb.host` is an endpoint outside of the kubernetes cluster | `false` | | `portaldb.service.fullNameOverride` | Override the service name for apollo portal db | `nil` | | `portaldb.service.port` | The port for the service of apollo portal db | `3306` | | `portaldb.service.type` | The service type of apollo portal db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. xxx.mysql.rds.aliyuncs.com | `ClusterIP` | ### 5.4 Sample 1. PortalDB host is an IP outside of kubernetes cluster ```yaml portaldb: host: 1.2.3.4 dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` 2. PortalDB host is a dns name outside of kubernetes cluster ```yaml portaldb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` 3. PortalDB host is a kubernetes service ```yaml portaldb: host: apollodb-mysql.mysql dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` 4. Specify environments ```yaml config: envs: dev,pro metaServers: dev: http://apollo-service-dev-apollo-configservice:8080 pro: http://apollo-service-pro-apollo-configservice:8080 ``` 5. Expose service as Load Balancer ```yaml service: type: LoadBalancer ``` 6. Expose service as Ingress ```yaml ingress: enabled: true hosts: - paths: - / ``` 7. Expose service as Ingress with custom path `/apollo` ```yaml # use /apollo as root, should specify config.contextPath as /apollo ingress: enabled: true hosts: - paths: - /apollo config: ... contextPath: /apollo ... ``` 8. Expose service as Ingress with session affinity ```yaml ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/affinity: "cookie" nginx.ingress.kubernetes.io/affinity-mode: "persistent" nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none: "true" nginx.ingress.kubernetes.io/session-cookie-expires: "172800" nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" hosts: - host: xxx.somedomain.com # host is required to make session affinity work paths: - / ``` 9. Enable LDAP support ```yaml config: ... profiles: github,ldap ... files: application-ldap.yml: | spring: ldap: base: "dc=example,dc=org" username: "cn=admin,dc=example,dc=org" password: "password" searchFilter: "(uid={0})" urls: - "ldap://xxx.somedomain.com:389" ldap: mapping: objectClass: "inetOrgPerson" loginId: "uid" userDisplayName: "cn" email: "mail" ```
# Apollo Helm Chart [Apollo](https://github.com/ctripcorp/apollo) is a reliable configuration management system. ## 1. Introduction The apollo-service and apollo-portal charts create deployments for apollo-configservice, apollo-adminservice and apollo-portal, which utilize the kubernetes native service discovery. ## 2. Prerequisites - Kubernetes 1.10+ - Helm 3 ## 3. Add Apollo Helm Chart Repository ```bash $ helm repo add apollo https://www.apolloconfig.com/charts $ helm search repo apollo ``` ## 4. Deployments of apollo-configservice and apollo-adminservice ### 4.1 Install apollo-configservice and apollo-adminservice should be installed per environment, so it is suggested to indicate environment in the release name, e.g. `apollo-service-dev` ```bash $ helm install apollo-service-dev \ --set configdb.host=1.2.3.4 \ --set configdb.userName=apollo \ --set configdb.password=apollo \ --set configdb.service.enabled=true \ --set configService.replicaCount=1 \ --set adminService.replicaCount=1 \ -n your-namespace \ apollo/apollo-service ``` Or customize it with values.yaml ```bash $ helm install apollo-service-dev -f values.yaml -n your-namespace apollo/apollo-service ``` ### 4.2 Uninstall To uninstall/delete the `apollo-service-dev` deployment: ```bash $ helm uninstall -n your-namespace apollo-service-dev ``` ### 4.3 Configuration The following table lists the configurable parameters of the apollo-service chart and their default values. | Parameter | Description | Default | |----------------------|---------------------------------------------|---------------------| | `configdb.host` | The host for apollo config db | `nil` | | `configdb.port` | The port for apollo config db | `3306` | | `configdb.dbName` | The database name for apollo config db | `ApolloConfigDB` | | `configdb.userName` | The user name for apollo config db | `nil` | | `configdb.password` | The password for apollo config db | `nil` | | `configdb.connectionStringProperties` | The connection string properties for apollo config db | `characterEncoding=utf8` | | `configdb.service.enabled` | Whether to create a Kubernetes Service for `configdb.host` or not. Set it to `true` if `configdb.host` is an endpoint outside of the kubernetes cluster | `false` | | `configdb.service.fullNameOverride` | Override the service name for apollo config db | `nil` | | `configdb.service.port` | The port for the service of apollo config db | `3306` | | `configdb.service.type` | The service type of apollo config db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. xxx.mysql.rds.aliyuncs.com | `ClusterIP` | | `configService.fullNameOverride` | Override the deployment name for apollo-configservice | `nil` | | `configService.replicaCount` | Replica count of apollo-configservice | `2` | | `configService.containerPort` | Container port of apollo-configservice | `8080` | | `configService.image.repository` | Image repository of apollo-configservice | `apolloconfig/apollo-configservice` | | `configService.image.tag` | Image tag of apollo-configservice, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `configService.image.pullPolicy` | Image pull policy of apollo-configservice | `IfNotPresent` | | `configService.imagePullSecrets` | Image pull secrets of apollo-configservice | `[]` | | `configService.service.fullNameOverride` | Override the service name for apollo-configservice | `nil` | | `configService.service.port` | The port for the service of apollo-configservice | `8080` | | `configService.service.targetPort` | The target port for the service of apollo-configservice | `8080` | | `configService.service.type` | The service type of apollo-configservice | `ClusterIP` | | `configService.ingress.enabled` | Whether to enable the ingress for config-service or not | `false` | | `configService.ingress.annotations` | The annotations of the ingress for config-service | `{}` | | `configService.ingress.hosts.host` | The host of the ingress for config-service | `nil` | | `configService.ingress.hosts.paths` | The paths of the ingress for config-service | `[]` | | `configService.ingress.tls` | The tls definition of the ingress for config-service | `[]` | | `configService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `configService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `configService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `configService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `configService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `configService.config.configServiceUrlOverride` | Override `apollo.config-service.url`: config service url to be accessed by apollo-client | `nil` | | `configService.config.adminServiceUrlOverride` | Override `apollo.admin-service.url`: admin service url to be accessed by apollo-portal | `nil` | | `configService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access config service via `http://{config_service_address}/apollo` | `nil` | | `configService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `configService.strategy` | The deployment strategy of apollo-configservice | `{}` | | `configService.resources` | The resources definition of apollo-configservice | `{}` | | `configService.nodeSelector` | The node selector definition of apollo-configservice | `{}` | | `configService.tolerations` | The tolerations definition of apollo-configservice | `[]` | | `configService.affinity` | The affinity definition of apollo-configservice | `{}` | | `adminService.fullNameOverride` | Override the deployment name for apollo-adminservice | `nil` | | `adminService.replicaCount` | Replica count of apollo-adminservice | `2` | | `adminService.containerPort` | Container port of apollo-adminservice | `8090` | | `adminService.image.repository` | Image repository of apollo-adminservice | `apolloconfig/apollo-adminservice` | | `adminService.image.tag` | Image tag of apollo-adminservice, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `adminService.image.pullPolicy` | Image pull policy of apollo-adminservice | `IfNotPresent` | | `adminService.imagePullSecrets` | Image pull secrets of apollo-adminservice | `[]` | | `adminService.service.fullNameOverride` | Override the service name for apollo-adminservice | `nil` | | `adminService.service.port` | The port for the service of apollo-adminservice | `8090` | | `adminService.service.targetPort` | The target port for the service of apollo-adminservice | `8090` | | `adminService.service.type` | The service type of apollo-adminservice | `ClusterIP` | | `adminService.ingress.enabled` | Whether to enable the ingress for admin-service or not | `false` | | `adminService.ingress.annotations` | The annotations of the ingress for admin-service | `{}` | | `adminService.ingress.hosts.host` | The host of the ingress for admin-service | `nil` | | `adminService.ingress.hosts.paths` | The paths of the ingress for admin-service | `[]` | | `adminService.ingress.tls` | The tls definition of the ingress for admin-service | `[]` | | `adminService.liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `adminService.liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `adminService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `adminService.readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `adminService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` | | `adminService.config.contextPath` | specify the context path, e.g. `/apollo`, then users could access admin service via `http://{admin_service_address}/apollo` | `nil` | | `adminService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `adminService.strategy` | The deployment strategy of apollo-adminservice | `{}` | | `adminService.resources` | The resources definition of apollo-adminservice | `{}` | | `adminService.nodeSelector` | The node selector definition of apollo-adminservice | `{}` | | `adminService.tolerations` | The tolerations definition of apollo-adminservice | `[]` | | `adminService.affinity` | The affinity definition of apollo-adminservice | `{}` | ### 4.4 Sample 1. ConfigDB host is an IP outside of kubernetes cluster ```yaml configdb: host: 1.2.3.4 dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` 2. ConfigDB host is a dns name outside of kubernetes cluster ```yaml configdb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` 3. ConfigDB host is a kubernetes service ```yaml configdb: host: apollodb-mysql.mysql dbName: ApolloConfigDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` 4. Expose config service as Ingress with custom path `/config` ```yaml # use /config as root, should specify configService.config.contextPath as /config configService: config: contextPath: /config ingress: enabled: true hosts: - paths: - /config ``` 5. Expose admin service as Ingress with custom path `/admin` ```yaml # use /admin as root, should specify adminService.config.contextPath as /admin adminService: config: contextPath: /admin ingress: enabled: true hosts: - paths: - /admin ``` ## 5. Deployments of apollo-portal ### 5.1 Install To install the apollo-portal chart with the release name `apollo-portal`: ```bash $ helm install apollo-portal \ --set portaldb.host=1.2.3.4 \ --set portaldb.userName=apollo \ --set portaldb.password=apollo \ --set portaldb.service.enabled=true \ --set config.envs="dev\,pro" \ --set config.metaServers.dev=http://apollo-service-dev-apollo-configservice:8080 \ --set config.metaServers.pro=http://apollo-service-pro-apollo-configservice:8080 \ --set replicaCount=1 \ -n your-namespace \ apollo/apollo-portal ``` Or customize it with values.yaml ```bash $ helm install apollo-portal -f values.yaml -n your-namespace apollo/apollo-portal ``` ### 5.2 Uninstallation To uninstall/delete the `apollo-portal` deployment: ```bash $ helm uninstall -n your-namespace apollo-portal ``` ### 5.3 Configuration The following table lists the configurable parameters of the apollo-portal chart and their default values. | Parameter | Description | Default | |----------------------|---------------------------------------------|-----------------------| | `fullNameOverride` | Override the deployment name for apollo-portal | `nil` | | `replicaCount` | Replica count of apollo-portal | `2` | | `containerPort` | Container port of apollo-portal | `8070` | | `image.repository` | Image repository of apollo-portal | `apolloconfig/apollo-portal` | | `image.tag` | Image tag of apollo-portal, e.g. `1.8.0`, leave it to `nil` to use the default version | `nil` | | `image.pullPolicy` | Image pull policy of apollo-portal | `IfNotPresent` | | `imagePullSecrets` | Image pull secrets of apollo-portal | `[]` | | `service.fullNameOverride` | Override the service name for apollo-portal | `nil` | | `service.port` | The port for the service of apollo-portal | `8070` | | `service.targetPort` | The target port for the service of apollo-portal | `8070` | | `service.type` | The service type of apollo-portal | `ClusterIP` | | `service.sessionAffinity` | The session affinity for the service of apollo-portal | `ClientIP` | | `ingress.enabled` | Whether to enable the ingress or not | `false` | | `ingress.annotations` | The annotations of the ingress | `{}` | | `ingress.hosts.host` | The host of the ingress | `nil` | | `ingress.hosts.paths` | The paths of the ingress | `[]` | | `ingress.tls` | The tls definition of the ingress | `[]` | | `liveness.initialDelaySeconds` | The initial delay seconds of liveness probe | `100` | | `liveness.periodSeconds` | The period seconds of liveness probe | `10` | | `readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` | | `readiness.periodSeconds` | The period seconds of readiness probe | `5` | | `env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` | | `strategy` | The deployment strategy of apollo-portal | `{}` | | `resources` | The resources definition of apollo-portal | `{}` | | `nodeSelector` | The node selector definition of apollo-portal | `{}` | | `tolerations` | The tolerations definition of apollo-portal | `[]` | | `affinity` | The affinity definition of apollo-portal | `{}` | | `config.profiles` | specify the spring profiles to activate | `github,auth` | | `config.envs` | specify the env names, e.g. dev,pro | `nil` | | `config.contextPath` | specify the context path, e.g. `/apollo`, then users could access portal via `http://{portal_address}/apollo` | `nil` | | `config.metaServers` | specify the meta servers, e.g.<br />`dev: http://apollo-configservice-dev:8080`<br />`pro: http://apollo-configservice-pro:8080` | `{}` | | `config.files` | specify the extra config files for apollo-portal, e.g. application-ldap.yml | `{}` | | `portaldb.host` | The host for apollo portal db | `nil` | | `portaldb.port` | The port for apollo portal db | `3306` | | `portaldb.dbName` | The database name for apollo portal db | `ApolloPortalDB` | | `portaldb.userName` | The user name for apollo portal db | `nil` | | `portaldb.password` | The password for apollo portal db | `nil` | | `portaldb.connectionStringProperties` | The connection string properties for apollo portal db | `characterEncoding=utf8` | | `portaldb.service.enabled` | Whether to create a Kubernetes Service for `portaldb.host` or not. Set it to `true` if `portaldb.host` is an endpoint outside of the kubernetes cluster | `false` | | `portaldb.service.fullNameOverride` | Override the service name for apollo portal db | `nil` | | `portaldb.service.port` | The port for the service of apollo portal db | `3306` | | `portaldb.service.type` | The service type of apollo portal db: `ClusterIP` or `ExternalName`. If the host is a DNS name, please specify `ExternalName` as the service type, e.g. xxx.mysql.rds.aliyuncs.com | `ClusterIP` | ### 5.4 Sample 1. PortalDB host is an IP outside of kubernetes cluster ```yaml portaldb: host: 1.2.3.4 dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true ``` 2. PortalDB host is a dns name outside of kubernetes cluster ```yaml portaldb: host: xxx.mysql.rds.aliyuncs.com dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false service: enabled: true type: ExternalName ``` 3. PortalDB host is a kubernetes service ```yaml portaldb: host: apollodb-mysql.mysql dbName: ApolloPortalDBName userName: someUserName password: somePassword connectionStringProperties: characterEncoding=utf8&useSSL=false ``` 4. Specify environments ```yaml config: envs: dev,pro metaServers: dev: http://apollo-service-dev-apollo-configservice:8080 pro: http://apollo-service-pro-apollo-configservice:8080 ``` 5. Expose service as Load Balancer ```yaml service: type: LoadBalancer ``` 6. Expose service as Ingress ```yaml ingress: enabled: true hosts: - paths: - / ``` 7. Expose service as Ingress with custom path `/apollo` ```yaml # use /apollo as root, should specify config.contextPath as /apollo ingress: enabled: true hosts: - paths: - /apollo config: ... contextPath: /apollo ... ``` 8. Expose service as Ingress with session affinity ```yaml ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/affinity: "cookie" nginx.ingress.kubernetes.io/affinity-mode: "persistent" nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none: "true" nginx.ingress.kubernetes.io/session-cookie-expires: "172800" nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" hosts: - host: xxx.somedomain.com # host is required to make session affinity work paths: - / ``` 9. Enable LDAP support ```yaml config: ... profiles: github,ldap ... files: application-ldap.yml: | spring: ldap: base: "dc=example,dc=org" username: "cn=admin,dc=example,dc=org" password: "password" searchFilter: "(uid={0})" urls: - "ldap://xxx.somedomain.com:389" ldap: mapping: objectClass: "inetOrgPerson" loginId: "uid" userDisplayName: "cn" email: "mail" ```
1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/test/java/com/ctrip/framework/apollo/metaservice/service/NacosDiscoveryServiceTest.java
package com.ctrip.framework.apollo.metaservice.service; import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * @author kl (http://kailing.pub) * @since 2020/12/21 */ @RunWith(MockitoJUnitRunner.class) public class NacosDiscoveryServiceTest { private NacosDiscoveryService nacosDiscoveryService; @Mock private NamingService nacosNamingService; private String someServiceId; @Before public void setUp() throws Exception { nacosDiscoveryService = new NacosDiscoveryService(); nacosDiscoveryService.setNamingService(nacosNamingService); someServiceId = "someServiceId"; } @Test public void testGetServiceInstancesWithEmptyInstances() throws Exception { assertTrue(nacosNamingService.selectInstances(someServiceId, true).isEmpty()); } @Test public void testGetServiceInstancesWithInvalidServiceId() { assertTrue(nacosDiscoveryService.getServiceInstances(someServiceId).isEmpty()); } @Test public void testGetServiceInstances() throws Exception { String someIp = "1.2.3.4"; int somePort = 8080; String someInstanceId = "someInstanceId"; Instance someServiceInstance = mockServiceInstance(someInstanceId, someIp, somePort); when(nacosNamingService.selectInstances(someServiceId, true)).thenReturn( Lists.newArrayList(someServiceInstance)); List<ServiceDTO> serviceDTOList = nacosDiscoveryService.getServiceInstances(someServiceId); ServiceDTO serviceDTO = serviceDTOList.get(0); assertEquals(1, serviceDTOList.size()); assertEquals(someServiceId, serviceDTO.getAppName()); assertEquals("http://1.2.3.4:8080/", serviceDTO.getHomepageUrl()); } private Instance mockServiceInstance(String instanceId, String ip, int port) { Instance serviceInstance = mock(Instance.class); when(serviceInstance.getInstanceId()).thenReturn(instanceId); when(serviceInstance.getIp()).thenReturn(ip); when(serviceInstance.getPort()).thenReturn(port); return serviceInstance; } }
package com.ctrip.framework.apollo.metaservice.service; import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * @author kl (http://kailing.pub) * @since 2020/12/21 */ @RunWith(MockitoJUnitRunner.class) public class NacosDiscoveryServiceTest { private NacosDiscoveryService nacosDiscoveryService; @Mock private NamingService nacosNamingService; private String someServiceId; @Before public void setUp() throws Exception { nacosDiscoveryService = new NacosDiscoveryService(); nacosDiscoveryService.setNamingService(nacosNamingService); someServiceId = "someServiceId"; } @Test public void testGetServiceInstancesWithEmptyInstances() throws Exception { assertTrue(nacosNamingService.selectInstances(someServiceId, true).isEmpty()); } @Test public void testGetServiceInstancesWithInvalidServiceId() { assertTrue(nacosDiscoveryService.getServiceInstances(someServiceId).isEmpty()); } @Test public void testGetServiceInstances() throws Exception { String someIp = "1.2.3.4"; int somePort = 8080; String someInstanceId = "someInstanceId"; Instance someServiceInstance = mockServiceInstance(someInstanceId, someIp, somePort); when(nacosNamingService.selectInstances(someServiceId, true)).thenReturn( Lists.newArrayList(someServiceInstance)); List<ServiceDTO> serviceDTOList = nacosDiscoveryService.getServiceInstances(someServiceId); ServiceDTO serviceDTO = serviceDTOList.get(0); assertEquals(1, serviceDTOList.size()); assertEquals(someServiceId, serviceDTO.getAppName()); assertEquals("http://1.2.3.4:8080/", serviceDTO.getHomepageUrl()); } private Instance mockServiceInstance(String instanceId, String ip, int port) { Instance serviceInstance = mock(Instance.class); when(serviceInstance.getInstanceId()).thenReturn(instanceId); when(serviceInstance.getIp()).thenReturn(ip); when(serviceInstance.getPort()).thenReturn(port); return serviceInstance; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvClusterInfo.java
package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.common.dto.ClusterDTO; import com.ctrip.framework.apollo.portal.environment.Env; import java.util.List; public class EnvClusterInfo { private String env; private List<ClusterDTO> clusters; public EnvClusterInfo(Env env) { this.env = env.toString(); } public Env getEnv() { return Env.valueOf(env); } public void setEnv(Env env) { this.env = env.toString(); } public List<ClusterDTO> getClusters() { return clusters; } public void setClusters(List<ClusterDTO> clusters) { this.clusters = clusters; } }
package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.common.dto.ClusterDTO; import com.ctrip.framework.apollo.portal.environment.Env; import java.util.List; public class EnvClusterInfo { private String env; private List<ClusterDTO> clusters; public EnvClusterInfo(Env env) { this.env = env.toString(); } public Env getEnv() { return Env.valueOf(env); } public void setEnv(Env env) { this.env = env.toString(); } public List<ClusterDTO> getClusters() { return clusters; } public void setClusters(List<ClusterDTO> clusters) { this.clusters = clusters; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/MergeEmailBuilder.java
package com.ctrip.framework.apollo.portal.component.emailbuilder; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO; import org.springframework.stereotype.Component; @Component public class MergeEmailBuilder extends ConfigPublishEmailBuilder { private static final String EMAIL_SUBJECT = "[Apollo] 全量发布"; @Override protected String subject() { return EMAIL_SUBJECT; } @Override protected String emailContent(Env env, ReleaseHistoryBO releaseHistory) { return renderEmailCommonContent(env, releaseHistory); } @Override protected String getTemplateFramework() { return portalConfig.emailTemplateFramework(); } @Override protected String getDiffModuleTemplate() { return portalConfig.emailReleaseDiffModuleTemplate(); } }
package com.ctrip.framework.apollo.portal.component.emailbuilder; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO; import org.springframework.stereotype.Component; @Component public class MergeEmailBuilder extends ConfigPublishEmailBuilder { private static final String EMAIL_SUBJECT = "[Apollo] 全量发布"; @Override protected String subject() { return EMAIL_SUBJECT; } @Override protected String emailContent(Env env, ReleaseHistoryBO releaseHistory) { return renderEmailCommonContent(env, releaseHistory); } @Override protected String getTemplateFramework() { return portalConfig.emailTemplateFramework(); } @Override protected String getDiffModuleTemplate() { return portalConfig.emailReleaseDiffModuleTemplate(); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/GrayReleaseRuleItemTransformer.java
package com.ctrip.framework.apollo.common.utils; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO; import java.lang.reflect.Type; import java.util.Set; /** * @author Jason Song([email protected]) */ public class GrayReleaseRuleItemTransformer { private static final Gson gson = new Gson(); private static final Type grayReleaseRuleItemsType = new TypeToken<Set<GrayReleaseRuleItemDTO>>() { }.getType(); public static Set<GrayReleaseRuleItemDTO> batchTransformFromJSON(String content) { return gson.fromJson(content, grayReleaseRuleItemsType); } public static String batchTransformToJSON(Set<GrayReleaseRuleItemDTO> ruleItems) { return gson.toJson(ruleItems); } }
package com.ctrip.framework.apollo.common.utils; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO; import java.lang.reflect.Type; import java.util.Set; /** * @author Jason Song([email protected]) */ public class GrayReleaseRuleItemTransformer { private static final Gson gson = new Gson(); private static final Type grayReleaseRuleItemsType = new TypeToken<Set<GrayReleaseRuleItemDTO>>() { }.getType(); public static Set<GrayReleaseRuleItemDTO> batchTransformFromJSON(String content) { return gson.fromJson(content, grayReleaseRuleItemsType); } public static String batchTransformToJSON(Set<GrayReleaseRuleItemDTO> ruleItems) { return gson.toJson(ruleItems); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigException.java
package com.ctrip.framework.apollo.exceptions; /** * @author Jason Song([email protected]) */ public class ApolloConfigException extends RuntimeException { public ApolloConfigException(String message) { super(message); } public ApolloConfigException(String message, Throwable cause) { super(message, cause); } }
package com.ctrip.framework.apollo.exceptions; /** * @author Jason Song([email protected]) */ public class ApolloConfigException extends RuntimeException { public ApolloConfigException(String message) { super(message); } public ApolloConfigException(String message, Throwable cause) { super(message, cause); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/resources/static/system-role-manage.html
<!doctype html> <html ng-app="systemRole"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <title>{{'SystemRole.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid" ng-controller="SystemRoleController"> <div class="col-md-10 col-md-offset-1 panel"> <section class="panel-body" ng-show="isRootUser"> <section class="row"> <h5>{{'SystemRole.AddCreateAppRoleToUser' | translate }} <small> {{'SystemRole.AddCreateAppRoleToUserTips' | translate }} </small> </h5> <hr> <div class="row"> <div class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">{{'SystemRole.ChooseUser' | translate }}<br></label> <div class="col-sm-8"> <form class="form-inline" ng-submit="addCreateApplicationRoleToUser()"> <div class="form-group"> <apollouserselector apollo-id="modifySystemRoleWidgetId"> </apollouserselector> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;">{{'SystemRole.Add' | translate }}</button> </form> <div class="item-container"> <h5>{{'SystemRole.AuthorizedUser' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in hasCreateApplicationPermissionUserList"> <button type="button" class="btn btn-default" ng-bind="user"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="deleteCreateApplicationRoleFromUser(user)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> </div> </section> <section class="row"> <h5>{{'SystemRole.ModifyAppAdminUser' | translate }} <small> {{'SystemRole.ModifyAppAdminUserTips' | translate }} </small> </h5> <hr> <form class="form-horizontal"> <div class="form-group" valdr-form-group> <label class="col-sm-2 control-label"> <apollorequiredfield></apollorequiredfield> {{'SystemRole.AppIdTips' | translate }} </label> <div class="col-sm-5"> <input type="text" class="form-control" ng-model="app.appId"> <small>{{'SystemRole.Title' | translate }}</small> </div> <div class="col-sm-1"> <button class="btn btn-info" ng-click="getAppInfo()">{{'Common.Search' | translate }}</button> </div> </div> <div class="form-group" valdr-form-group> <label class="col-sm-2 control-label"> {{'SystemRole.AppInfo' | translate }}</label> <div class="col-sm-5"> <h5 ng-show="app.info" ng-bind="app.info"></h5> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">{{'SystemRole.ChooseUser' | translate }}<br></label> <div class="col-sm-8"> <form class="form-inline"> <div class="form-group"> <apollouserselector apollo-id="modifyManageAppMasterRoleWidgetId"> </apollouserselector> </div> </form> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-9"> <button type="submit" class="btn btn-primary" ng-disabled="operateManageAppMasterRoleBtn" ng-click="allowAppMasterAssignRole()"> {{'SystemRole.AllowAppMasterAssignRole' | translate }} </button> <button type="submit" class="btn btn-primary" ng-disabled="operateManageAppMasterRoleBtn" ng-click="deleteAppMasterAssignRole()"> {{'SystemRole.DeleteAppMasterAssignRole' | translate }} </button> </div> </div> </form> </section> </section> <section class="panel-body text-center" ng-if="!isRootUser"> <h4>{{'Common.IsRootUser' | translate }}</h4> </section> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-route.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!--valdr--> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/lodash.min.js"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/services/ClusterService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/SystemRoleService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <script type="application/javascript" src="scripts/PageCommon.js"></script> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/valdr.js"></script> <script type="application/javascript" src="scripts/controller/role/SystemRoleController.js"></script> </body> </html>
<!doctype html> <html ng-app="systemRole"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="styles/common-style.css"> <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"> <title>{{'SystemRole.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid" ng-controller="SystemRoleController"> <div class="col-md-10 col-md-offset-1 panel"> <section class="panel-body" ng-show="isRootUser"> <section class="row"> <h5>{{'SystemRole.AddCreateAppRoleToUser' | translate }} <small> {{'SystemRole.AddCreateAppRoleToUserTips' | translate }} </small> </h5> <hr> <div class="row"> <div class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">{{'SystemRole.ChooseUser' | translate }}<br></label> <div class="col-sm-8"> <form class="form-inline" ng-submit="addCreateApplicationRoleToUser()"> <div class="form-group"> <apollouserselector apollo-id="modifySystemRoleWidgetId"> </apollouserselector> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;">{{'SystemRole.Add' | translate }}</button> </form> <div class="item-container"> <h5>{{'SystemRole.AuthorizedUser' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in hasCreateApplicationPermissionUserList"> <button type="button" class="btn btn-default" ng-bind="user"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="deleteCreateApplicationRoleFromUser(user)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> </div> </section> <section class="row"> <h5>{{'SystemRole.ModifyAppAdminUser' | translate }} <small> {{'SystemRole.ModifyAppAdminUserTips' | translate }} </small> </h5> <hr> <form class="form-horizontal"> <div class="form-group" valdr-form-group> <label class="col-sm-2 control-label"> <apollorequiredfield></apollorequiredfield> {{'SystemRole.AppIdTips' | translate }} </label> <div class="col-sm-5"> <input type="text" class="form-control" ng-model="app.appId"> <small>{{'SystemRole.Title' | translate }}</small> </div> <div class="col-sm-1"> <button class="btn btn-info" ng-click="getAppInfo()">{{'Common.Search' | translate }}</button> </div> </div> <div class="form-group" valdr-form-group> <label class="col-sm-2 control-label"> {{'SystemRole.AppInfo' | translate }}</label> <div class="col-sm-5"> <h5 ng-show="app.info" ng-bind="app.info"></h5> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">{{'SystemRole.ChooseUser' | translate }}<br></label> <div class="col-sm-8"> <form class="form-inline"> <div class="form-group"> <apollouserselector apollo-id="modifyManageAppMasterRoleWidgetId"> </apollouserselector> </div> </form> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-9"> <button type="submit" class="btn btn-primary" ng-disabled="operateManageAppMasterRoleBtn" ng-click="allowAppMasterAssignRole()"> {{'SystemRole.AllowAppMasterAssignRole' | translate }} </button> <button type="submit" class="btn btn-primary" ng-disabled="operateManageAppMasterRoleBtn" ng-click="deleteAppMasterAssignRole()"> {{'SystemRole.DeleteAppMasterAssignRole' | translate }} </button> </div> </div> </form> </section> </section> <section class="panel-body text-center" ng-if="!isRootUser"> <h4>{{'Common.IsRootUser' | translate }}</h4> </section> </div> </div> <div ng-include="'views/common/footer.html'"></div> <!-- jquery.js --> <script src="vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="vendor/angular/angular.min.js"></script> <script src="vendor/angular/angular-route.min.js"></script> <script src="vendor/angular/angular-resource.min.js"></script> <script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="vendor/angular/loading-bar.min.js"></script> <script src="vendor/angular/angular-cookies.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!--valdr--> <script src="vendor/valdr/valdr.min.js" type="text/javascript"></script> <script src="vendor/valdr/valdr-message.min.js" type="text/javascript"></script> <!-- bootstrap.js --> <script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="vendor/lodash.min.js"></script> <script src="vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="scripts/app.js"></script> <script type="application/javascript" src="scripts/services/AppService.js"></script> <script type="application/javascript" src="scripts/services/EnvService.js"></script> <script type="application/javascript" src="scripts/services/UserService.js"></script> <script type="application/javascript" src="scripts/services/CommonService.js"></script> <script type="application/javascript" src="scripts/services/PermissionService.js"></script> <script type="application/javascript" src="scripts/services/ClusterService.js"></script> <script type="application/javascript" src="scripts/services/NamespaceService.js"></script> <script type="application/javascript" src="scripts/services/SystemRoleService.js"></script> <script type="application/javascript" src="scripts/AppUtils.js"></script> <script type="application/javascript" src="scripts/PageCommon.js"></script> <script type="application/javascript" src="scripts/directive/directive.js"></script> <script type="application/javascript" src="scripts/valdr.js"></script> <script type="application/javascript" src="scripts/controller/role/SystemRoleController.js"></script> </body> </html>
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-core/src/main/java/com/ctrip/framework/apollo/core/spi/MetaServerProvider.java
package com.ctrip.framework.apollo.core.spi; import com.ctrip.framework.apollo.core.enums.Env; /** * @since 1.0.0 */ public interface MetaServerProvider extends Ordered { /** * Provide the Apollo meta server address, could be a domain url or comma separated ip addresses, like http://1.2.3.4:8080,http://2.3.4.5:8080. * <br/> * In production environment, we suggest using one single domain like http://config.xxx.com(backed by software load balancers like nginx) instead of multiple ip addresses */ String getMetaServerAddress(Env targetEnv); }
package com.ctrip.framework.apollo.core.spi; import com.ctrip.framework.apollo.core.enums.Env; /** * @since 1.0.0 */ public interface MetaServerProvider extends Ordered { /** * Provide the Apollo meta server address, could be a domain url or comma separated ip addresses, like http://1.2.3.4:8080,http://2.3.4.5:8080. * <br/> * In production environment, we suggest using one single domain like http://config.xxx.com(backed by software load balancers like nginx) instead of multiple ip addresses */ String getMetaServerAddress(Env targetEnv); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainServiceTest.java
package com.ctrip.framework.apollo.portal.environment; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PortalMetaDomainServiceTest extends BaseIntegrationTest { private PortalMetaDomainService portalMetaDomainService; @Mock private PortalConfig portalConfig; @Before public void init() { final Map<String, String> map = new HashMap<>(); map.put("nothing", "http://unknown.com"); Mockito.when(portalConfig.getMetaServers()).thenReturn(map); portalMetaDomainService = new PortalMetaDomainService(portalConfig); } @Test public void testGetMetaDomain() { // local String localMetaServerAddress = "http://localhost:8080"; mockMetaServerAddress(Env.LOCAL, localMetaServerAddress); assertEquals(localMetaServerAddress, portalMetaDomainService.getDomain(Env.LOCAL)); // add this environment without meta server address String randomEnvironment = "randomEnvironment"; Env.addEnvironment(randomEnvironment); assertEquals(PortalMetaDomainService.DEFAULT_META_URL, portalMetaDomainService.getDomain(Env.valueOf(randomEnvironment))); } @Test public void testGetValidAddress() throws Exception { String someResponse = "some response"; startServerWithHandlers(mockServerHandler(HttpServletResponse.SC_OK, someResponse)); String validServer = " http://localhost:" + PORT + " "; String invalidServer = "http://localhost:" + findFreePort(); mockMetaServerAddress(Env.FAT, validServer + "," + invalidServer); mockMetaServerAddress(Env.UAT, invalidServer + "," + validServer); portalMetaDomainService.reload(); assertEquals(validServer.trim(), portalMetaDomainService.getDomain(Env.FAT)); assertEquals(validServer.trim(), portalMetaDomainService.getDomain(Env.UAT)); } @Test public void testInvalidAddress() { String invalidServer = "http://localhost:" + findFreePort() + " "; String anotherInvalidServer = "http://localhost:" + findFreePort() + " "; mockMetaServerAddress(Env.LPT, invalidServer + "," + anotherInvalidServer); portalMetaDomainService.reload(); String metaServer = portalMetaDomainService.getDomain(Env.LPT); assertTrue(metaServer.equals(invalidServer.trim()) || metaServer.equals(anotherInvalidServer.trim())); } private void mockMetaServerAddress(Env env, String metaServerAddress) { // add it to system's property System.setProperty(env.getName() + "_meta", metaServerAddress); } }
package com.ctrip.framework.apollo.portal.environment; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PortalMetaDomainServiceTest extends BaseIntegrationTest { private PortalMetaDomainService portalMetaDomainService; @Mock private PortalConfig portalConfig; @Before public void init() { final Map<String, String> map = new HashMap<>(); map.put("nothing", "http://unknown.com"); Mockito.when(portalConfig.getMetaServers()).thenReturn(map); portalMetaDomainService = new PortalMetaDomainService(portalConfig); } @Test public void testGetMetaDomain() { // local String localMetaServerAddress = "http://localhost:8080"; mockMetaServerAddress(Env.LOCAL, localMetaServerAddress); assertEquals(localMetaServerAddress, portalMetaDomainService.getDomain(Env.LOCAL)); // add this environment without meta server address String randomEnvironment = "randomEnvironment"; Env.addEnvironment(randomEnvironment); assertEquals(PortalMetaDomainService.DEFAULT_META_URL, portalMetaDomainService.getDomain(Env.valueOf(randomEnvironment))); } @Test public void testGetValidAddress() throws Exception { String someResponse = "some response"; startServerWithHandlers(mockServerHandler(HttpServletResponse.SC_OK, someResponse)); String validServer = " http://localhost:" + PORT + " "; String invalidServer = "http://localhost:" + findFreePort(); mockMetaServerAddress(Env.FAT, validServer + "," + invalidServer); mockMetaServerAddress(Env.UAT, invalidServer + "," + validServer); portalMetaDomainService.reload(); assertEquals(validServer.trim(), portalMetaDomainService.getDomain(Env.FAT)); assertEquals(validServer.trim(), portalMetaDomainService.getDomain(Env.UAT)); } @Test public void testInvalidAddress() { String invalidServer = "http://localhost:" + findFreePort() + " "; String anotherInvalidServer = "http://localhost:" + findFreePort() + " "; mockMetaServerAddress(Env.LPT, invalidServer + "," + anotherInvalidServer); portalMetaDomainService.reload(); String metaServer = portalMetaDomainService.getDomain(Env.LPT); assertTrue(metaServer.equals(invalidServer.trim()) || metaServer.equals(anotherInvalidServer.trim())); } private void mockMetaServerAddress(Env env, String metaServerAddress) { // add it to system's property System.setProperty(env.getName() + "_meta", metaServerAddress); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
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); } }
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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java
package com.ctrip.framework.apollo.spring.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ctrip.framework.apollo.core.ConfigConsts; /** * Use this annotation to inject Apollo Config Instance. * * <p>Usage example:</p> * <pre class="code"> * //Inject the config for "someNamespace" * &#064;ApolloConfig("someNamespace") * private Config config; * </pre> * * <p>Usage example with placeholder:</p> * <pre class="code"> * // The namespace could also be specified as a placeholder, e.g. ${redis.namespace:xxx}, * // which will use the value of the key "redis.namespace" or "xxx" if this key is not configured. * &#064;ApolloConfig("${redis.namespace:xxx}") * private Config config; * </pre> * * * @author Jason Song([email protected]) */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented public @interface ApolloConfig { /** * Apollo namespace for the config, if not specified then default to application */ String value() default ConfigConsts.NAMESPACE_APPLICATION; }
package com.ctrip.framework.apollo.spring.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ctrip.framework.apollo.core.ConfigConsts; /** * Use this annotation to inject Apollo Config Instance. * * <p>Usage example:</p> * <pre class="code"> * //Inject the config for "someNamespace" * &#064;ApolloConfig("someNamespace") * private Config config; * </pre> * * <p>Usage example with placeholder:</p> * <pre class="code"> * // The namespace could also be specified as a placeholder, e.g. ${redis.namespace:xxx}, * // which will use the value of the key "redis.namespace" or "xxx" if this key is not configured. * &#064;ApolloConfig("${redis.namespace:xxx}") * private Config config; * </pre> * * * @author Jason Song([email protected]) */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented public @interface ApolloConfig { /** * Apollo namespace for the config, if not specified then default to application */ String value() default ConfigConsts.NAMESPACE_APPLICATION; }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java
package com.ctrip.framework.apollo.spi; /** * The manually config registry, use with caution! * * @author Jason Song([email protected]) */ public interface ConfigRegistry { /** * Register the config factory for the namespace specified. * * @param namespace the namespace * @param factory the factory for this namespace */ void register(String namespace, ConfigFactory factory); /** * Get the registered config factory for the namespace. * * @param namespace the namespace * @return the factory registered for this namespace */ ConfigFactory getFactory(String namespace); }
package com.ctrip.framework.apollo.spi; /** * The manually config registry, use with caution! * * @author Jason Song([email protected]) */ public interface ConfigRegistry { /** * Register the config factory for the namespace specified. * * @param namespace the namespace * @param factory the factory for this namespace */ void register(String namespace, ConfigFactory factory); /** * Get the registered config factory for the namespace. * * @param namespace the namespace * @return the factory registered for this namespace */ ConfigFactory getFactory(String namespace); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
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); } }
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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
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); } }
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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/condition/OnProfileCondition.java
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([email protected]) */ 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; } }
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([email protected]) */ 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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DiscoveryService.java
package com.ctrip.framework.apollo.metaservice.service; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import java.util.List; public interface DiscoveryService { /** * @param serviceId the service id * @return the service instance list for the specified service id, or an empty list if no service * instance available */ List<ServiceDTO> getServiceInstances(String serviceId); }
package com.ctrip.framework.apollo.metaservice.service; import com.ctrip.framework.apollo.core.dto.ServiceDTO; import java.util.List; public interface DiscoveryService { /** * @param serviceId the service id * @return the service instance list for the specified service id, or an empty list if no service * instance available */ List<ServiceDTO> getServiceInstances(String serviceId); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/util/RoleUtilsTest.java
package com.ctrip.framework.apollo.portal.util; import static org.junit.Assert.*; import org.junit.Test; public class RoleUtilsTest { @Test public void testExtractAppIdFromMasterRoleName() throws Exception { assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp")); assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp+xx")); assertNull(RoleUtils.extractAppIdFromMasterRoleName("ReleaseNamespace+app1+application")); } @Test public void testExtractAppIdFromRoleName() throws Exception { assertEquals("someApp", RoleUtils.extractAppIdFromRoleName("Master+someApp")); assertEquals("someApp", RoleUtils.extractAppIdFromRoleName("ModifyNamespace+someApp+xx")); assertEquals("app1", RoleUtils.extractAppIdFromRoleName("ReleaseNamespace+app1+application")); } }
package com.ctrip.framework.apollo.portal.util; import static org.junit.Assert.*; import org.junit.Test; public class RoleUtilsTest { @Test public void testExtractAppIdFromMasterRoleName() throws Exception { assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp")); assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp+xx")); assertNull(RoleUtils.extractAppIdFromMasterRoleName("ReleaseNamespace+app1+application")); } @Test public void testExtractAppIdFromRoleName() throws Exception { assertEquals("someApp", RoleUtils.extractAppIdFromRoleName("Master+someApp")); assertEquals("someApp", RoleUtils.extractAppIdFromRoleName("ModifyNamespace+someApp+xx")); assertEquals("app1", RoleUtils.extractAppIdFromRoleName("ReleaseNamespace+app1+application")); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/resources/static/namespace/role.html
<!doctype html> <html ng-app="role"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="../img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="../styles/common-style.css"> <link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css"> <title>{{'Namespace.Role.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid apollo-container"> <section class="panel col-md-offset-1 col-md-10" ng-controller="NamespaceRoleController"> <header class="panel-heading"> <div class="row"> <div class="col-md-9"> <h4 class="modal-title"> {{'Namespace.Role.Title' | translate }}<small>({{'Common.AppId' | translate }}:<label ng-bind="pageContext.appId"></label> {{'Common.Namespace' | translate }}:<label ng-bind="pageContext.namespaceName"></label>)</small> </h4> </div> <div class="col-md-3 text-right"> <a type="button" class="btn btn-info" data-dismiss="modal" href="{{ '/config.html' | prefixPath }}?#appid={{pageContext.appId}}">{{'Common.ReturnToIndex' | translate }} </a> </div> </div> </header> <div class="panel-body" ng-show="hasAssignUserPermission"> <div class="row"> <div class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">{{'Namespace.Role.GrantModifyTo' | translate }}<br><small>{{'Namespace.Role.GrantModifyTo2' | translate }}</small></label> <div class="col-sm-8"> <form class="form-inline" ng-submit="assignRoleToUser('ModifyNamespace')"> <div class="form-group"> <apollouserselector apollo-id="modifyRoleWidgetId"></apollouserselector> <select class="form-control input-sm" ng-model="modifyRoleSelectedEnv"> <option value="">{{'Namespace.Role.AllEnv' | translate }}</option> <option ng-repeat="env in envs" ng-value="env">{{env}}</option> </select> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;" ng-disabled="modifyRoleSubmitBtnDisabled">{{'Namespace.Role.Add' | translate }}</button> </form> <!-- Split button --> <div class="item-container"> <h5>{{'Namespace.Role.AllEnv' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in rolesAssignedUsers.modifyRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ModifyNamespace', user.userId, null)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> <div class="item-container" ng-repeat="env in envs"> <h5>{{env}}</h5> <div class="btn-group item-info" ng-repeat="user in envRolesAssignedUsers[env].modifyRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ModifyNamespace', user.userId, env)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> <hr> <div class="row" style="margin-top: 10px;"> <div class="form-horizontal"> <div class="col-sm-2 text-right"> <label class="control-label">{{'Namespace.Role.GrantPublishTo' | translate }}<br><small>{{'Namespace.Role.GrantPublishTo2' | translate }}</small></label> </div> <div class="col-sm-8"> <form class="form-inline" ng-submit="assignRoleToUser('ReleaseNamespace')"> <div class="form-group"> <apollouserselector apollo-id="releaseRoleWidgetId"></apollouserselector> <select class="form-control input-sm" ng-model="releaseRoleSelectedEnv"> <option value="">{{'Namespace.Role.AllEnv' | translate }}</option> <option ng-repeat="env in envs" ng-value="env">{{env}}</option> </select> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;" ng-disabled="ReleaseRoleSubmitBtnDisabled">{{'Namespace.Role.Add' | translate }}</button> </form> <!-- Split button --> <div class="item-container"> <h5>{{'Namespace.Role.AllEnv' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in rolesAssignedUsers.releaseRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ReleaseNamespace', user.userId, null)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> <div class="item-container" ng-repeat="env in envs"> <h5>{{env}}</h5> <div class="btn-group item-info" ng-repeat="user in envRolesAssignedUsers[env].releaseRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ReleaseNamespace', user.userId, env)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> </div> </div> <div class="panel-body text-center" ng-show="!hasAssignUserPermission"> <h2>{{'Namespace.Role.NoPermission' | translate }}</h2> </div> </section> </div> <div ng-include="'../views/common/footer.html'"></div> <!-- jquery.js --> <script src="../vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="../vendor/angular/angular.min.js"></script> <script src="../vendor/angular/angular-resource.min.js"></script> <script src="../vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="../vendor/angular/loading-bar.min.js"></script> <script src="../vendor/angular/angular-cookies.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!-- bootstrap.js --> <script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="../vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="../scripts/app.js"></script> <script type="application/javascript" src="../scripts/services/AppService.js"></script> <script type="application/javascript" src="../scripts/services/EnvService.js"></script> <script type="application/javascript" src="../scripts/services/UserService.js"></script> <script type="application/javascript" src="../scripts/services/CommonService.js"></script> <script type="application/javascript" src="../scripts/services/PermissionService.js"></script> <script type="application/javascript" src="../scripts/AppUtils.js"></script> <script type="application/javascript" src="../scripts/PageCommon.js"></script> <script type="application/javascript" src="../scripts/directive/directive.js"></script> <script type="application/javascript" src="../scripts/controller/role/NamespaceRoleController.js"></script> </body> </html>
<!doctype html> <html ng-app="role"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="../img/config.png"> <!-- styles --> <link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" href="../styles/common-style.css"> <link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css"> <title>{{'Namespace.Role.Title' | translate }}</title> </head> <body> <apollonav></apollonav> <div class="container-fluid apollo-container"> <section class="panel col-md-offset-1 col-md-10" ng-controller="NamespaceRoleController"> <header class="panel-heading"> <div class="row"> <div class="col-md-9"> <h4 class="modal-title"> {{'Namespace.Role.Title' | translate }}<small>({{'Common.AppId' | translate }}:<label ng-bind="pageContext.appId"></label> {{'Common.Namespace' | translate }}:<label ng-bind="pageContext.namespaceName"></label>)</small> </h4> </div> <div class="col-md-3 text-right"> <a type="button" class="btn btn-info" data-dismiss="modal" href="{{ '/config.html' | prefixPath }}?#appid={{pageContext.appId}}">{{'Common.ReturnToIndex' | translate }} </a> </div> </div> </header> <div class="panel-body" ng-show="hasAssignUserPermission"> <div class="row"> <div class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">{{'Namespace.Role.GrantModifyTo' | translate }}<br><small>{{'Namespace.Role.GrantModifyTo2' | translate }}</small></label> <div class="col-sm-8"> <form class="form-inline" ng-submit="assignRoleToUser('ModifyNamespace')"> <div class="form-group"> <apollouserselector apollo-id="modifyRoleWidgetId"></apollouserselector> <select class="form-control input-sm" ng-model="modifyRoleSelectedEnv"> <option value="">{{'Namespace.Role.AllEnv' | translate }}</option> <option ng-repeat="env in envs" ng-value="env">{{env}}</option> </select> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;" ng-disabled="modifyRoleSubmitBtnDisabled">{{'Namespace.Role.Add' | translate }}</button> </form> <!-- Split button --> <div class="item-container"> <h5>{{'Namespace.Role.AllEnv' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in rolesAssignedUsers.modifyRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ModifyNamespace', user.userId, null)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> <div class="item-container" ng-repeat="env in envs"> <h5>{{env}}</h5> <div class="btn-group item-info" ng-repeat="user in envRolesAssignedUsers[env].modifyRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ModifyNamespace', user.userId, env)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> <hr> <div class="row" style="margin-top: 10px;"> <div class="form-horizontal"> <div class="col-sm-2 text-right"> <label class="control-label">{{'Namespace.Role.GrantPublishTo' | translate }}<br><small>{{'Namespace.Role.GrantPublishTo2' | translate }}</small></label> </div> <div class="col-sm-8"> <form class="form-inline" ng-submit="assignRoleToUser('ReleaseNamespace')"> <div class="form-group"> <apollouserselector apollo-id="releaseRoleWidgetId"></apollouserselector> <select class="form-control input-sm" ng-model="releaseRoleSelectedEnv"> <option value="">{{'Namespace.Role.AllEnv' | translate }}</option> <option ng-repeat="env in envs" ng-value="env">{{env}}</option> </select> </div> <button type="submit" class="btn btn-default" style="margin-left: 20px;" ng-disabled="ReleaseRoleSubmitBtnDisabled">{{'Namespace.Role.Add' | translate }}</button> </form> <!-- Split button --> <div class="item-container"> <h5>{{'Namespace.Role.AllEnv' | translate }}</h5> <div class="btn-group item-info" ng-repeat="user in rolesAssignedUsers.releaseRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ReleaseNamespace', user.userId, null)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> <div class="item-container" ng-repeat="env in envs"> <h5>{{env}}</h5> <div class="btn-group item-info" ng-repeat="user in envRolesAssignedUsers[env].releaseRoleUsers"> <button type="button" class="btn btn-default" ng-bind="user.userId"></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ng-click="removeUserRole('ReleaseNamespace', user.userId, env)"> <span class="glyphicon glyphicon-remove"></span> </button> </div> </div> </div> </div> </div> </div> </div> <div class="panel-body text-center" ng-show="!hasAssignUserPermission"> <h2>{{'Namespace.Role.NoPermission' | translate }}</h2> </div> </section> </div> <div ng-include="'../views/common/footer.html'"></div> <!-- jquery.js --> <script src="../vendor/jquery.min.js" type="text/javascript"></script> <!--angular--> <script src="../vendor/angular/angular.min.js"></script> <script src="../vendor/angular/angular-resource.min.js"></script> <script src="../vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script> <script src="../vendor/angular/loading-bar.min.js"></script> <script src="../vendor/angular/angular-cookies.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script> <script src="../vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script> <!-- bootstrap.js --> <script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="../vendor/select2/select2.min.js" type="text/javascript"></script> <!--biz--> <!--must import--> <script type="application/javascript" src="../scripts/app.js"></script> <script type="application/javascript" src="../scripts/services/AppService.js"></script> <script type="application/javascript" src="../scripts/services/EnvService.js"></script> <script type="application/javascript" src="../scripts/services/UserService.js"></script> <script type="application/javascript" src="../scripts/services/CommonService.js"></script> <script type="application/javascript" src="../scripts/services/PermissionService.js"></script> <script type="application/javascript" src="../scripts/AppUtils.js"></script> <script type="application/javascript" src="../scripts/PageCommon.js"></script> <script type="application/javascript" src="../scripts/directive/directive.js"></script> <script type="application/javascript" src="../scripts/controller/role/NamespaceRoleController.js"></script> </body> </html>
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java
package com.ctrip.framework.apollo.adminservice; import com.ctrip.framework.apollo.biz.service.AppService; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Component; @Component public class AdminServiceHealthIndicator implements HealthIndicator { private final AppService appService; public AdminServiceHealthIndicator(final AppService appService) { this.appService = appService; } @Override public Health health() { check(); return Health.up().build(); } private void check() { PageRequest pageable = PageRequest.of(0, 1); appService.findAll(pageable); } }
package com.ctrip.framework.apollo.adminservice; import com.ctrip.framework.apollo.biz.service.AppService; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Component; @Component public class AdminServiceHealthIndicator implements HealthIndicator { private final AppService appService; public AdminServiceHealthIndicator(final AppService appService) { this.appService = appService; } @Override public Health health() { check(); return Health.up().build(); } private void check() { PageRequest pageable = PageRequest.of(0, 1); appService.findAll(pageable); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceAcquireLockAspect.java
package com.ctrip.framework.apollo.adminservice.aop; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.NamespaceLock; import com.ctrip.framework.apollo.biz.service.ItemService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Component; /** * 一个namespace在一次发布中只能允许一个人修改配置 * 通过数据库lock表来实现 */ @Aspect @Component public class NamespaceAcquireLockAspect { private static final Logger logger = LoggerFactory.getLogger(NamespaceAcquireLockAspect.class); private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final ItemService itemService; private final BizConfig bizConfig; public NamespaceAcquireLockAspect( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final ItemService itemService, final BizConfig bizConfig) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.itemService = itemService; this.bizConfig = bizConfig; } //create item @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, item, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, ItemDTO item) { acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy()); } //update item @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, itemId, item, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, long itemId, ItemDTO item) { acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy()); } //update by change set @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, changeSet, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, ItemChangeSets changeSet) { acquireLock(appId, clusterName, namespaceName, changeSet.getDataChangeLastModifiedBy()); } //delete item @Before("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)") public void requireLockAdvice(long itemId, String operator) { Item item = itemService.findOne(itemId); if (item == null){ throw new BadRequestException("item not exist."); } acquireLock(item.getNamespaceId(), operator); } void acquireLock(String appId, String clusterName, String namespaceName, String currentUser) { if (bizConfig.isNamespaceLockSwitchOff()) { return; } Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); acquireLock(namespace, currentUser); } void acquireLock(long namespaceId, String currentUser) { if (bizConfig.isNamespaceLockSwitchOff()) { return; } Namespace namespace = namespaceService.findOne(namespaceId); acquireLock(namespace, currentUser); } private void acquireLock(Namespace namespace, String currentUser) { if (namespace == null) { throw new BadRequestException("namespace not exist."); } long namespaceId = namespace.getId(); NamespaceLock namespaceLock = namespaceLockService.findLock(namespaceId); if (namespaceLock == null) { try { tryLock(namespaceId, currentUser); //lock success } catch (DataIntegrityViolationException e) { //lock fail namespaceLock = namespaceLockService.findLock(namespaceId); checkLock(namespace, namespaceLock, currentUser); } catch (Exception e) { logger.error("try lock error", e); throw e; } } else { //check lock owner is current user checkLock(namespace, namespaceLock, currentUser); } } private void tryLock(long namespaceId, String user) { NamespaceLock lock = new NamespaceLock(); lock.setNamespaceId(namespaceId); lock.setDataChangeCreatedBy(user); lock.setDataChangeLastModifiedBy(user); namespaceLockService.tryLock(lock); } private void checkLock(Namespace namespace, NamespaceLock namespaceLock, String currentUser) { if (namespaceLock == null) { throw new ServiceException( String.format("Check lock for %s failed, please retry.", namespace.getNamespaceName())); } String lockOwner = namespaceLock.getDataChangeCreatedBy(); if (!lockOwner.equals(currentUser)) { throw new BadRequestException( "namespace:" + namespace.getNamespaceName() + " is modified by " + lockOwner); } } }
package com.ctrip.framework.apollo.adminservice.aop; import com.ctrip.framework.apollo.biz.config.BizConfig; import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.NamespaceLock; import com.ctrip.framework.apollo.biz.service.ItemService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Component; /** * 一个namespace在一次发布中只能允许一个人修改配置 * 通过数据库lock表来实现 */ @Aspect @Component public class NamespaceAcquireLockAspect { private static final Logger logger = LoggerFactory.getLogger(NamespaceAcquireLockAspect.class); private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final ItemService itemService; private final BizConfig bizConfig; public NamespaceAcquireLockAspect( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final ItemService itemService, final BizConfig bizConfig) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.itemService = itemService; this.bizConfig = bizConfig; } //create item @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, item, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, ItemDTO item) { acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy()); } //update item @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, itemId, item, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, long itemId, ItemDTO item) { acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy()); } //update by change set @Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, changeSet, ..)") public void requireLockAdvice(String appId, String clusterName, String namespaceName, ItemChangeSets changeSet) { acquireLock(appId, clusterName, namespaceName, changeSet.getDataChangeLastModifiedBy()); } //delete item @Before("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)") public void requireLockAdvice(long itemId, String operator) { Item item = itemService.findOne(itemId); if (item == null){ throw new BadRequestException("item not exist."); } acquireLock(item.getNamespaceId(), operator); } void acquireLock(String appId, String clusterName, String namespaceName, String currentUser) { if (bizConfig.isNamespaceLockSwitchOff()) { return; } Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); acquireLock(namespace, currentUser); } void acquireLock(long namespaceId, String currentUser) { if (bizConfig.isNamespaceLockSwitchOff()) { return; } Namespace namespace = namespaceService.findOne(namespaceId); acquireLock(namespace, currentUser); } private void acquireLock(Namespace namespace, String currentUser) { if (namespace == null) { throw new BadRequestException("namespace not exist."); } long namespaceId = namespace.getId(); NamespaceLock namespaceLock = namespaceLockService.findLock(namespaceId); if (namespaceLock == null) { try { tryLock(namespaceId, currentUser); //lock success } catch (DataIntegrityViolationException e) { //lock fail namespaceLock = namespaceLockService.findLock(namespaceId); checkLock(namespace, namespaceLock, currentUser); } catch (Exception e) { logger.error("try lock error", e); throw e; } } else { //check lock owner is current user checkLock(namespace, namespaceLock, currentUser); } } private void tryLock(long namespaceId, String user) { NamespaceLock lock = new NamespaceLock(); lock.setNamespaceId(namespaceId); lock.setDataChangeCreatedBy(user); lock.setDataChangeLastModifiedBy(user); namespaceLockService.tryLock(lock); } private void checkLock(Namespace namespace, NamespaceLock namespaceLock, String currentUser) { if (namespaceLock == null) { throw new ServiceException( String.format("Check lock for %s failed, please retry.", namespace.getNamespaceName())); } String lockOwner = namespaceLock.getDataChangeCreatedBy(); if (!lockOwner.equals(currentUser)) { throw new BadRequestException( "namespace:" + namespace.getNamespaceName() + " is modified by " + lockOwner); } } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/development/apollo-development-guide.md
本文档介绍了如何在本地使用IDE编译、运行Apollo,从而可以帮助大家了解Apollo的内在运行机制,同时也为自定义开发做好准备。 # &nbsp; # 一、准备工作 ## 1.1 本地运行时环境 Apollo本地开发需要以下组件: 1. Java: 1.8+ 2. MySQL: 5.6.5+ 3. IDE: 没有特殊要求 其中MySQL需要创建Apollo数据库并导入基础数据。 具体步骤请参考[分布式部署指南](zh/deployment/distributed-deployment-guide)中的以下部分: 1. [一、准备工作](zh/deployment/distributed-deployment-guide#一、准备工作) 2. [2.1 创建数据库](zh/deployment/distributed-deployment-guide#_21-创建数据库) ## 1.2 Apollo总体设计 具体请参考[Apollo配置中心设计](zh/design/apollo-design) # 二、本地启动 ## 2.1 Apollo Config Service和Apollo Admin Service 我们在本地开发时,一般会在IDE中同时启动`apollo-configservice`和`apollo-adminservice`。 下面以Intellij Community 2016.2版本为例来说明如何在本地启动`apollo-configservice`和`apollo-adminservice`。 ![ConfigAdminApplication-Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Overview.png) ### 2.1.1 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.1.2 Main class配置 `com.ctrip.framework.apollo.assembly.ApolloApplication` > 注:如果希望独立启动`apollo-configservice`和`apollo-adminservice`,可以把Main Class分别换成 > `com.ctrip.framework.apollo.configservice.ConfigServiceApplication`和 > `com.ctrip.framework.apollo.adminservice.AdminServiceApplication` ### 2.1.3 VM options配置 ![ConfigAdminApplication-VM-Options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-VM-Options.png) -Dapollo_profile=github -Dspring.datasource.url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8 -Dspring.datasource.username=root -Dspring.datasource.password= >注1:spring.datasource相关配置替换成你自己的数据库连接信息,注意数据库是`ApolloConfigDB` > >注2:程序默认日志输出为/opt/logs/100003171/apollo-assembly.log,如果需要修改日志文件路径,可以增加`logging.file.name`参数,如下: > >-Dlogging.file.name=/your-path/apollo-assembly.log ### 2.1.4 Program arguments配置 `--configservice --adminservice` ### 2.1.5 运行 对新建的运行配置点击Run或Debug皆可。 ![ConfigAdminApplication-Run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Run.png) 启动完后,打开[http://localhost:8080](http://localhost:8080)可以看到`apollo-configservice`和`apollo-adminservice`都已经启动完成并注册到Eureka。 ![ConfigAdminApplication-Eureka](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Eureka.png) > 注:除了在Eureka确认服务状态外,还可以通过健康检查接口确认服务健康状况: > > apollo-adminservice: [http://localhost:8090/health](http://localhost:8090/health) > apollo-configservice: [http://localhost:8080/health](http://localhost:8080/health) > > 如果服务健康,返回内容中的status.code应当为`UP`: > > { > "status": { > "code": "UP", > ... > }, > ... > } ## 2.2 Apollo-Portal 下面以Intellij Community 2016.2版本为例来说明如何在本地启动`apollo-portal`。 ![PortalApplication-Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Overview.png) ### 2.2.1 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.2.2 Main class配置 `com.ctrip.framework.apollo.portal.PortalApplication` ### 2.2.3 VM options配置 ![PortalApplication-VM-Options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-VM-Options.png) -Dapollo_profile=github,auth -Ddev_meta=http://localhost:8080/ -Dserver.port=8070 -Dspring.datasource.url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 -Dspring.datasource.username=root -Dspring.datasource.password= >注1:这里指定了apollo_profile是`github`和`auth`,其中`github`是Apollo必须的一个profile,用于数据库的配置,`auth`是从0.9.0新增的,用来支持使用apollo提供的Spring Security简单认证,更多信息可以参考[Portal-实现用户登录功能](zh/development/portal-how-to-implement-user-login-function) > >注2:spring.datasource相关配置替换成你自己的数据库连接信息,注意数据库是`ApolloPortalDB `。 > >注3:默认ApolloPortalDB中导入的配置只会展示DEV环境的配置,所以这里配置了dev\_meta属性,如果你希望在本地展示其它环境的配置,需要在这里增加其它环境的meta服务器地址,如fat\_meta。 > >注4:这里指定了server.port=8070是因为`apollo-configservice`启动在8080端口,所以这里配置`apollo-portal`启动在8070端口。 > >注5:程序默认日志输出为/opt/logs/100003173/apollo-portal.log,如果需要修改日志文件路径,可以增加`logging.file.name`参数,如下: > >-Dlogging.file.name=/your-path/apollo-portal.log ### 2.2.4 运行 对新建的运行配置点击Run或Debug皆可。 ![PortalApplication-Run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Run.png) 启动完后,打开[http://localhost:8070](http://localhost:8070)就可以看到Apollo配置中心界面了。 ![PortalApplication-Home](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Home.png) >注:如果启用了`auth` profile的话,默认的用户名是apollo,密码是admin ### 2.2.5 Demo应用接入 为了更好的开发和调试,一般我们都会自己创建一个demo项目给自己使用。 可以参考[一、普通应用接入指南](zh/usage/apollo-user-guide#一、普通应用接入指南)创建自己的demo项目。 ## 2.3 Java样例客户端启动 项目中有一个样例客户端的项目:`apollo-demo`,下面以Intellij Community 2016.2版本为例来说明如何在本地启动。 ### 2.3.1 配置项目AppId 在`2.2.5 Demo应用接入`中创建Demo项目时,系统会要求填入一个全局唯一的AppId,我们需要把这个AppId配置到`apollo-demo`项目的app.properties文件中:`apollo-demo/src/main/resources/META-INF/app.properties`。 ![apollo-demo-app-properties](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-app-properties.png) 如我们自己的demo项目使用的AppId是100004458,那么文件内容就是: app.id=100004458 >注:AppId是应用的唯一身份标识,Apollo客户端使用这个标识来获取应用自己的私有Namespace配置。 > 对于公共Namespace的配置,没有AppId也可以获取到配置,但是就失去了应用覆盖公共Namespace配置的能力。 > 更多配置AppId的方式可以参考[1.2.1 AppId](zh/usage/java-sdk-user-guide#_121-appid) ### 2.3.2 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.3.3 Main class配置 `SimpleApolloConfigDemo` ### 2.3.4 VM options配置 ![apollo-demo-vm-options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-vm-options.png) -Dapollo.meta=http://localhost:8080 > 注:这里当前环境的meta server地址为`http://localhost:8080`,也就是`apollo-configservice`的地址。 > 更多配置Apollo Meta Server的方式可以参考[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server) ### 2.3.5 概览 ![apollo-demo-overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-overview.png) ### 2.3.6 运行 对新建的运行配置点击Run或Debug皆可。 ![apollo-demo-run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-run.png) 启动完后,忽略前面的调试信息,可以看到如下提示: Apollo Config Demo. Please input key to get the value. Input quit to exit. > 输入你之前在Portal上配置的值,如我们的Demo项目中配置了`timeout`,会看到如下信息: > timeout > [SimpleApolloConfigDemo] Loading key : timeout with value: 100 > 客户端日志级别默认是`DEBUG`,如果需要调整,可以通过修改`apollo-demo/src/main/resources/log4j2.xml`中的level配置 > ```xml > <logger name="com.ctrip.framework.apollo" additivity="false" level="trace"> > <AppenderRef ref="Async" level="DEBUG"/> > </logger> > ``` ## 2.4 .Net样例客户端启动 [apollo.net](https://github.com/ctripcorp/apollo.net)项目中有一个样例客户端的项目:`ApolloDemo`,下面就以VS 2010为例来说明如何在本地启动。 ### 2.4.1 配置项目AppId 在`2.2.5 Demo应用接入`中创建Demo项目时,系统会要求填入一个全局唯一的AppId,我们需要把这个AppId配置到`ApolloDemo`项目的APP.config文件中:`apollo.net\ApolloDemo\App.config`。 ![apollo-demo-app-config](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-net-app-config.png) 如我们自己的demo项目使用的AppId是100004458,那么文件内容就是: ```xml <add key="AppID" value="100004458"/> ``` >注:AppId是应用的唯一身份标识,Apollo客户端使用这个标识来获取应用自己的私有Namespace配置。 > 对于公共Namespace的配置,没有AppId也可以获取到配置,但是就失去了应用覆盖公共Namespace配置的能力。 ### 2.4.2 配置服务地址 Apollo客户端针对不同的环境会从不同的服务器获取配置,所以我们需要在app.config或web.config配置服务器地址(Apollo.{ENV}.Meta)。假设DEV环境的配置服务(apollo-configservice)地址是11.22.33.44,那么我们就做如下配置: ![apollo-net-server-url-config](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-net-server-url-config.png) ### 2.4.3 运行 运行`ApolloConfigDemo.cs`即可。 启动完后,忽略前面的调试信息,可以看到如下提示: Apollo Config Demo. Please input key to get the value. Input quit to exit. > 输入你之前在Portal上配置的值,如我们的Demo项目中配置了`timeout`,会看到如下信息: > timeout > Loading key: timeout with value: 100 >注:Apollo .Net客户端开源版目前默认会把日志直接输出到Console,大家可以自己实现Logging相关功能。 > > 详见[https://github.com/ctripcorp/apollo.net/tree/master/Apollo/Logging/Spi](https://github.com/ctripcorp/apollo.net/tree/master/Apollo/Logging/Spi) # 三、开发 ## 模块依赖图 ![模块依赖图](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/module-dependency.png) ## 3.1 Portal 实现用户登录功能 请参考[Portal 实现用户登录功能](zh/development/portal-how-to-implement-user-login-function) ## 3.2 Portal 接入邮件服务 请参考[Portal 接入邮件服务](zh/development/portal-how-to-enable-email-service)
本文档介绍了如何在本地使用IDE编译、运行Apollo,从而可以帮助大家了解Apollo的内在运行机制,同时也为自定义开发做好准备。 # &nbsp; # 一、准备工作 ## 1.1 本地运行时环境 Apollo本地开发需要以下组件: 1. Java: 1.8+ 2. MySQL: 5.6.5+ 3. IDE: 没有特殊要求 其中MySQL需要创建Apollo数据库并导入基础数据。 具体步骤请参考[分布式部署指南](zh/deployment/distributed-deployment-guide)中的以下部分: 1. [一、准备工作](zh/deployment/distributed-deployment-guide#一、准备工作) 2. [2.1 创建数据库](zh/deployment/distributed-deployment-guide#_21-创建数据库) ## 1.2 Apollo总体设计 具体请参考[Apollo配置中心设计](zh/design/apollo-design) # 二、本地启动 ## 2.1 Apollo Config Service和Apollo Admin Service 我们在本地开发时,一般会在IDE中同时启动`apollo-configservice`和`apollo-adminservice`。 下面以Intellij Community 2016.2版本为例来说明如何在本地启动`apollo-configservice`和`apollo-adminservice`。 ![ConfigAdminApplication-Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Overview.png) ### 2.1.1 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.1.2 Main class配置 `com.ctrip.framework.apollo.assembly.ApolloApplication` > 注:如果希望独立启动`apollo-configservice`和`apollo-adminservice`,可以把Main Class分别换成 > `com.ctrip.framework.apollo.configservice.ConfigServiceApplication`和 > `com.ctrip.framework.apollo.adminservice.AdminServiceApplication` ### 2.1.3 VM options配置 ![ConfigAdminApplication-VM-Options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-VM-Options.png) -Dapollo_profile=github -Dspring.datasource.url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8 -Dspring.datasource.username=root -Dspring.datasource.password= >注1:spring.datasource相关配置替换成你自己的数据库连接信息,注意数据库是`ApolloConfigDB` > >注2:程序默认日志输出为/opt/logs/100003171/apollo-assembly.log,如果需要修改日志文件路径,可以增加`logging.file.name`参数,如下: > >-Dlogging.file.name=/your-path/apollo-assembly.log ### 2.1.4 Program arguments配置 `--configservice --adminservice` ### 2.1.5 运行 对新建的运行配置点击Run或Debug皆可。 ![ConfigAdminApplication-Run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Run.png) 启动完后,打开[http://localhost:8080](http://localhost:8080)可以看到`apollo-configservice`和`apollo-adminservice`都已经启动完成并注册到Eureka。 ![ConfigAdminApplication-Eureka](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/ConfigAdminApplication-Eureka.png) > 注:除了在Eureka确认服务状态外,还可以通过健康检查接口确认服务健康状况: > > apollo-adminservice: [http://localhost:8090/health](http://localhost:8090/health) > apollo-configservice: [http://localhost:8080/health](http://localhost:8080/health) > > 如果服务健康,返回内容中的status.code应当为`UP`: > > { > "status": { > "code": "UP", > ... > }, > ... > } ## 2.2 Apollo-Portal 下面以Intellij Community 2016.2版本为例来说明如何在本地启动`apollo-portal`。 ![PortalApplication-Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Overview.png) ### 2.2.1 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.2.2 Main class配置 `com.ctrip.framework.apollo.portal.PortalApplication` ### 2.2.3 VM options配置 ![PortalApplication-VM-Options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-VM-Options.png) -Dapollo_profile=github,auth -Ddev_meta=http://localhost:8080/ -Dserver.port=8070 -Dspring.datasource.url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 -Dspring.datasource.username=root -Dspring.datasource.password= >注1:这里指定了apollo_profile是`github`和`auth`,其中`github`是Apollo必须的一个profile,用于数据库的配置,`auth`是从0.9.0新增的,用来支持使用apollo提供的Spring Security简单认证,更多信息可以参考[Portal-实现用户登录功能](zh/development/portal-how-to-implement-user-login-function) > >注2:spring.datasource相关配置替换成你自己的数据库连接信息,注意数据库是`ApolloPortalDB `。 > >注3:默认ApolloPortalDB中导入的配置只会展示DEV环境的配置,所以这里配置了dev\_meta属性,如果你希望在本地展示其它环境的配置,需要在这里增加其它环境的meta服务器地址,如fat\_meta。 > >注4:这里指定了server.port=8070是因为`apollo-configservice`启动在8080端口,所以这里配置`apollo-portal`启动在8070端口。 > >注5:程序默认日志输出为/opt/logs/100003173/apollo-portal.log,如果需要修改日志文件路径,可以增加`logging.file.name`参数,如下: > >-Dlogging.file.name=/your-path/apollo-portal.log ### 2.2.4 运行 对新建的运行配置点击Run或Debug皆可。 ![PortalApplication-Run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Run.png) 启动完后,打开[http://localhost:8070](http://localhost:8070)就可以看到Apollo配置中心界面了。 ![PortalApplication-Home](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/PortalApplication-Home.png) >注:如果启用了`auth` profile的话,默认的用户名是apollo,密码是admin ### 2.2.5 Demo应用接入 为了更好的开发和调试,一般我们都会自己创建一个demo项目给自己使用。 可以参考[一、普通应用接入指南](zh/usage/apollo-user-guide#一、普通应用接入指南)创建自己的demo项目。 ## 2.3 Java样例客户端启动 项目中有一个样例客户端的项目:`apollo-demo`,下面以Intellij Community 2016.2版本为例来说明如何在本地启动。 ### 2.3.1 配置项目AppId 在`2.2.5 Demo应用接入`中创建Demo项目时,系统会要求填入一个全局唯一的AppId,我们需要把这个AppId配置到`apollo-demo`项目的app.properties文件中:`apollo-demo/src/main/resources/META-INF/app.properties`。 ![apollo-demo-app-properties](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-app-properties.png) 如我们自己的demo项目使用的AppId是100004458,那么文件内容就是: app.id=100004458 >注:AppId是应用的唯一身份标识,Apollo客户端使用这个标识来获取应用自己的私有Namespace配置。 > 对于公共Namespace的配置,没有AppId也可以获取到配置,但是就失去了应用覆盖公共Namespace配置的能力。 > 更多配置AppId的方式可以参考[1.2.1 AppId](zh/usage/java-sdk-user-guide#_121-appid) ### 2.3.2 新建运行配置 ![NewConfiguration-Application](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/NewConfiguration-Application.png) ### 2.3.3 Main class配置 `SimpleApolloConfigDemo` ### 2.3.4 VM options配置 ![apollo-demo-vm-options](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-vm-options.png) -Dapollo.meta=http://localhost:8080 > 注:这里当前环境的meta server地址为`http://localhost:8080`,也就是`apollo-configservice`的地址。 > 更多配置Apollo Meta Server的方式可以参考[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server) ### 2.3.5 概览 ![apollo-demo-overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-overview.png) ### 2.3.6 运行 对新建的运行配置点击Run或Debug皆可。 ![apollo-demo-run](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/local-development/apollo-demo-run.png) 启动完后,忽略前面的调试信息,可以看到如下提示: Apollo Config Demo. Please input key to get the value. Input quit to exit. > 输入你之前在Portal上配置的值,如我们的Demo项目中配置了`timeout`,会看到如下信息: > timeout > [SimpleApolloConfigDemo] Loading key : timeout with value: 100 > 客户端日志级别默认是`DEBUG`,如果需要调整,可以通过修改`apollo-demo/src/main/resources/log4j2.xml`中的level配置 > ```xml > <logger name="com.ctrip.framework.apollo" additivity="false" level="trace"> > <AppenderRef ref="Async" level="DEBUG"/> > </logger> > ``` ## 2.4 .Net样例客户端启动 [apollo.net](https://github.com/ctripcorp/apollo.net)项目中有一个样例客户端的项目:`ApolloDemo`,下面就以VS 2010为例来说明如何在本地启动。 ### 2.4.1 配置项目AppId 在`2.2.5 Demo应用接入`中创建Demo项目时,系统会要求填入一个全局唯一的AppId,我们需要把这个AppId配置到`ApolloDemo`项目的APP.config文件中:`apollo.net\ApolloDemo\App.config`。 ![apollo-demo-app-config](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-net-app-config.png) 如我们自己的demo项目使用的AppId是100004458,那么文件内容就是: ```xml <add key="AppID" value="100004458"/> ``` >注:AppId是应用的唯一身份标识,Apollo客户端使用这个标识来获取应用自己的私有Namespace配置。 > 对于公共Namespace的配置,没有AppId也可以获取到配置,但是就失去了应用覆盖公共Namespace配置的能力。 ### 2.4.2 配置服务地址 Apollo客户端针对不同的环境会从不同的服务器获取配置,所以我们需要在app.config或web.config配置服务器地址(Apollo.{ENV}.Meta)。假设DEV环境的配置服务(apollo-configservice)地址是11.22.33.44,那么我们就做如下配置: ![apollo-net-server-url-config](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-net-server-url-config.png) ### 2.4.3 运行 运行`ApolloConfigDemo.cs`即可。 启动完后,忽略前面的调试信息,可以看到如下提示: Apollo Config Demo. Please input key to get the value. Input quit to exit. > 输入你之前在Portal上配置的值,如我们的Demo项目中配置了`timeout`,会看到如下信息: > timeout > Loading key: timeout with value: 100 >注:Apollo .Net客户端开源版目前默认会把日志直接输出到Console,大家可以自己实现Logging相关功能。 > > 详见[https://github.com/ctripcorp/apollo.net/tree/master/Apollo/Logging/Spi](https://github.com/ctripcorp/apollo.net/tree/master/Apollo/Logging/Spi) # 三、开发 ## 模块依赖图 ![模块依赖图](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/module-dependency.png) ## 3.1 Portal 实现用户登录功能 请参考[Portal 实现用户登录功能](zh/development/portal-how-to-implement-user-login-function) ## 3.2 Portal 接入邮件服务 请参考[Portal 接入邮件服务](zh/development/portal-how-to-enable-email-service)
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java
package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.dto.CommitDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.component.PermissionValidator; import com.ctrip.framework.apollo.portal.service.CommitService; import javax.validation.Valid; import javax.validation.constraints.Positive; import javax.validation.constraints.PositiveOrZero; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.Collections; import java.util.List; @Validated @RestController public class CommitController { private final CommitService commitService; private final PermissionValidator permissionValidator; public CommitController(final CommitService commitService, final PermissionValidator permissionValidator) { this.commitService = commitService; this.permissionValidator = permissionValidator; } @GetMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits") public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page, @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "10") int size) { if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) { return Collections.emptyList(); } return commitService.find(appId, Env.valueOf(env), clusterName, namespaceName, page, size); } }
package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.dto.CommitDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.component.PermissionValidator; import com.ctrip.framework.apollo.portal.service.CommitService; import javax.validation.Valid; import javax.validation.constraints.Positive; import javax.validation.constraints.PositiveOrZero; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.Collections; import java.util.List; @Validated @RestController public class CommitController { private final CommitService commitService; private final PermissionValidator permissionValidator; public CommitController(final CommitService commitService, final PermissionValidator permissionValidator) { this.commitService = commitService; this.permissionValidator = permissionValidator; } @GetMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits") public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page, @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "10") int size) { if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) { return Collections.emptyList(); } return commitService.find(appId, Env.valueOf(env), clusterName, namespaceName, page, size); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/ExcludeClientCredentialsClientRegistrationRepository.java
package com.ctrip.framework.apollo.portal.spi.oidc; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.springframework.security.oauth2.client.registration.ClientRegistration; import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; import org.springframework.security.oauth2.core.AuthorizationGrantType; /** * @author vdisk <[email protected]> */ public class ExcludeClientCredentialsClientRegistrationRepository implements ClientRegistrationRepository, Iterable<ClientRegistration> { /** * origin clientRegistrationRepository */ private final InMemoryClientRegistrationRepository delegate; /** * exclude client_credentials */ private final List<ClientRegistration> clientRegistrationList; public ExcludeClientCredentialsClientRegistrationRepository( InMemoryClientRegistrationRepository delegate) { Objects.requireNonNull(delegate, "clientRegistrationRepository cannot be null"); this.delegate = delegate; this.clientRegistrationList = Collections.unmodifiableList(StreamSupport .stream(Spliterators.spliteratorUnknownSize(delegate.iterator(), Spliterator.ORDERED), false) .filter(clientRegistration -> !AuthorizationGrantType.CLIENT_CREDENTIALS .equals(clientRegistration.getAuthorizationGrantType())) .collect(Collectors.toList())); } @Override public ClientRegistration findByRegistrationId(String registrationId) { ClientRegistration clientRegistration = this.delegate.findByRegistrationId(registrationId); if (clientRegistration == null) { return null; } if (AuthorizationGrantType.CLIENT_CREDENTIALS .equals(clientRegistration.getAuthorizationGrantType())) { return null; } return clientRegistration; } @Override public Iterator<ClientRegistration> iterator() { return this.clientRegistrationList.iterator(); } }
package com.ctrip.framework.apollo.portal.spi.oidc; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.springframework.security.oauth2.client.registration.ClientRegistration; import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; import org.springframework.security.oauth2.core.AuthorizationGrantType; /** * @author vdisk <[email protected]> */ public class ExcludeClientCredentialsClientRegistrationRepository implements ClientRegistrationRepository, Iterable<ClientRegistration> { /** * origin clientRegistrationRepository */ private final InMemoryClientRegistrationRepository delegate; /** * exclude client_credentials */ private final List<ClientRegistration> clientRegistrationList; public ExcludeClientCredentialsClientRegistrationRepository( InMemoryClientRegistrationRepository delegate) { Objects.requireNonNull(delegate, "clientRegistrationRepository cannot be null"); this.delegate = delegate; this.clientRegistrationList = Collections.unmodifiableList(StreamSupport .stream(Spliterators.spliteratorUnknownSize(delegate.iterator(), Spliterator.ORDERED), false) .filter(clientRegistration -> !AuthorizationGrantType.CLIENT_CREDENTIALS .equals(clientRegistration.getAuthorizationGrantType())) .collect(Collectors.toList())); } @Override public ClientRegistration findByRegistrationId(String registrationId) { ClientRegistration clientRegistration = this.delegate.findByRegistrationId(registrationId); if (clientRegistration == null) { return null; } if (AuthorizationGrantType.CLIENT_CREDENTIALS .equals(clientRegistration.getAuthorizationGrantType())) { return null; } return clientRegistration; } @Override public Iterator<ClientRegistration> iterator() { return this.clientRegistrationList.iterator(); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AbstractUnitTest.java
package com.ctrip.framework.apollo.portal; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.Silent.class) public abstract class AbstractUnitTest { }
package com.ctrip.framework.apollo.portal; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.Silent.class) public abstract class AbstractUnitTest { }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshablePropertySource.java
package com.ctrip.framework.apollo.common.config; import org.springframework.core.env.MapPropertySource; import java.util.Map; public abstract class RefreshablePropertySource extends MapPropertySource { public RefreshablePropertySource(String name, Map<String, Object> source) { super(name, source); } @Override public Object getProperty(String name) { return this.source.get(name); } /** * refresh property */ protected abstract void refresh(); }
package com.ctrip.framework.apollo.common.config; import org.springframework.core.env.MapPropertySource; import java.util.Map; public abstract class RefreshablePropertySource extends MapPropertySource { public RefreshablePropertySource(String name, Map<String, Object> source) { super(name, source); } @Override public Object getProperty(String name) { return this.source.get(name); } /** * refresh property */ protected abstract void refresh(); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/Email.java
package com.ctrip.framework.apollo.portal.entity.bo; import java.util.List; public class Email { private String senderEmailAddress; private List<String> recipients; private String subject; private String body; public String getSenderEmailAddress() { return senderEmailAddress; } public void setSenderEmailAddress(String senderEmailAddress) { this.senderEmailAddress = senderEmailAddress; } public List<String> getRecipients() { return recipients; } public String getRecipientsString() { return String.join(",", recipients); } public void setRecipients(List<String> recipients) { this.recipients = recipients; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } }
package com.ctrip.framework.apollo.portal.entity.bo; import java.util.List; public class Email { private String senderEmailAddress; private List<String> recipients; private String subject; private String body; public String getSenderEmailAddress() { return senderEmailAddress; } public void setSenderEmailAddress(String senderEmailAddress) { this.senderEmailAddress = senderEmailAddress; } public List<String> getRecipients() { return recipients; } public String getRecipientsString() { return String.join(",", recipients); } public void setRecipients(List<String> recipients) { this.recipients = recipients; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ApolloInjectorCustomizer.java
package com.ctrip.framework.apollo.spi; import com.ctrip.framework.apollo.core.spi.Ordered; import com.ctrip.framework.apollo.internals.DefaultInjector; import com.ctrip.framework.apollo.internals.Injector; /** * Allow users to inject customized instances, see {@link DefaultInjector#getInstance(java.lang.Class)} */ public interface ApolloInjectorCustomizer extends Injector, Ordered { }
package com.ctrip.framework.apollo.spi; import com.ctrip.framework.apollo.core.spi.Ordered; import com.ctrip.framework.apollo.internals.DefaultInjector; import com.ctrip.framework.apollo.internals.Injector; /** * Allow users to inject customized instances, see {@link DefaultInjector#getInstance(java.lang.Class)} */ public interface ApolloInjectorCustomizer extends Injector, Ordered { }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/usage/third-party-sdks-user-guide.md
## 1. Go ### Apollo Go 客户端 1 项目地址:[zouyx/agollo](https://github.com/zouyx/agollo) > 非常感谢[@zouyx](https://github.com/zouyx)提供Go Apollo客户端的支持 ### Apollo Go 客户端 2 项目地址:[philchia/agollo](https://github.com/philchia/agollo) > 非常感谢[@philchia](https://github.com/philchia)提供Go Apollo客户端的支持 ### Apollo Go 客户端 3 项目地址:[shima-park/agollo](https://github.com/shima-park/agollo) > 非常感谢[@shima-park](https://github.com/shima-park)提供Go Apollo客户端的支持 ### Apollo Go 客户端 4 项目地址:[go-microservices/php_conf_agent](https://github.com/go-microservices/php_conf_agent) > 非常感谢[@GanymedeNil](https://github.com/GanymedeNil)提供Go Apollo客户端的支持 ### Apollo Go 客户端 5 项目地址:[hyperjiang/lunar](https://github.com/hyperjiang/lunar) > 非常感谢[@hyperjiang](https://github.com/hyperjiang)提供Go Apollo客户端的支持 ### Apollo Go 客户端 6 项目地址:[tagconfig/tagconfig](https://github.com/tagconfig/tagconfig) > 非常感谢[@n0trace](https://github.com/n0trace)提供Go Apollo客户端的支持 ### Apollo Go 客户端 7 项目地址:[go-chassis/go-archaius](https://github.com/go-chassis/go-archaius/tree/master/examples/apollo) > 非常感谢[@tianxiaoliang](https://github.com/tianxiaoliang) 和 [@Shonminh](https://github.com/Shonminh)提供Go Apollo客户端的支持 ### Apollo Go 客户端 8 项目地址:[xhrg-product/apollo-client-golang](https://github.com/xhrg-product/apollo-client-golang) > 非常感谢[@xhrg](https://github.com/xhrg)提供Go Apollo客户端的支持 ## 2. Python ### Apollo Python 客户端 1 项目地址:[pyapollo](https://github.com/filamoon/pyapollo) > 非常感谢[@filamoon](https://github.com/filamoon)提供Python Apollo客户端的支持 ### Apollo Python 客户端 2 项目地址:[BruceWW-pyapollo](https://github.com/BruceWW/pyapollo) > 非常感谢[@BruceWW](https://github.com/BruceWW)提供Python Apollo客户端的支持 ### Apollo Python 客户端 3 项目地址:[xhrg-product/apollo-client-python](https://github.com/xhrg-product/apollo-client-python) > 非常感谢[@xhrg-product](https://github.com/xhrg-product)提供Python Apollo客户端的支持 ## 3. NodeJS ### Apollo NodeJS 客户端 1 项目地址:[node-apollo](https://github.com/Quinton/node-apollo) > 非常感谢[@Quinton](https://github.com/Quinton)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 2 项目地址:[ctrip-apollo](https://github.com/kaelzhang/ctrip-apollo) > 非常感谢[@kaelzhang](https://github.com/kaelzhang)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 3 项目地址:[node-apollo-client](https://github.com/shinux/node-apollo-client) > 非常感谢[@shinux](https://github.com/shinux)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 4 项目地址:[ctrip-apollo-client](https://github.com/lvgithub/ctrip-apollo-client) > 非常感谢[@lvgithub](https://github.com/lvgithub)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 5 项目地址:[apollo-node](https://github.com/lengyuxuan/apollo-node) > 非常感谢[@lengyuxuan](https://github.com/lengyuxuan)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 6 项目地址:[egg-apollo-client](https://github.com/xuezier/egg-apollo-client) > 非常感谢[@xuezier](https://github.com/xuezier)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 7 项目地址:[apollo-node-client](https://github.com/zhangxh1023/apollo-node-client) > 非常感谢[@zhangxh1023](https://github.com/zhangxh1023)提供NodeJS Apollo客户端的支持 ## 4. PHP ### Apollo PHP 客户端 1 项目地址:[apollo-php-client](https://github.com/multilinguals/apollo-php-client) > 非常感谢[@t04041143](https://github.com/t04041143)提供PHP Apollo客户端的支持 ### Apollo PHP 客户端 2 项目地址:[apollo-sdk-config](https://github.com/fengzhibin/apollo-sdk-config) > 非常感谢[@fengzhibin](https://github.com/fengzhibin)提供PHP Apollo客户端的支持 ## 5. C ### Apollo C 客户端 项目地址:[apollo-c-client](https://github.com/lzeqian/apollo) > 非常感谢[@lzeqian](https://github.com/lzeqian)提供C Apollo客户端的支持
## 1. Go ### Apollo Go 客户端 1 项目地址:[zouyx/agollo](https://github.com/zouyx/agollo) > 非常感谢[@zouyx](https://github.com/zouyx)提供Go Apollo客户端的支持 ### Apollo Go 客户端 2 项目地址:[philchia/agollo](https://github.com/philchia/agollo) > 非常感谢[@philchia](https://github.com/philchia)提供Go Apollo客户端的支持 ### Apollo Go 客户端 3 项目地址:[shima-park/agollo](https://github.com/shima-park/agollo) > 非常感谢[@shima-park](https://github.com/shima-park)提供Go Apollo客户端的支持 ### Apollo Go 客户端 4 项目地址:[go-microservices/php_conf_agent](https://github.com/go-microservices/php_conf_agent) > 非常感谢[@GanymedeNil](https://github.com/GanymedeNil)提供Go Apollo客户端的支持 ### Apollo Go 客户端 5 项目地址:[hyperjiang/lunar](https://github.com/hyperjiang/lunar) > 非常感谢[@hyperjiang](https://github.com/hyperjiang)提供Go Apollo客户端的支持 ### Apollo Go 客户端 6 项目地址:[tagconfig/tagconfig](https://github.com/tagconfig/tagconfig) > 非常感谢[@n0trace](https://github.com/n0trace)提供Go Apollo客户端的支持 ### Apollo Go 客户端 7 项目地址:[go-chassis/go-archaius](https://github.com/go-chassis/go-archaius/tree/master/examples/apollo) > 非常感谢[@tianxiaoliang](https://github.com/tianxiaoliang) 和 [@Shonminh](https://github.com/Shonminh)提供Go Apollo客户端的支持 ### Apollo Go 客户端 8 项目地址:[xhrg-product/apollo-client-golang](https://github.com/xhrg-product/apollo-client-golang) > 非常感谢[@xhrg](https://github.com/xhrg)提供Go Apollo客户端的支持 ## 2. Python ### Apollo Python 客户端 1 项目地址:[pyapollo](https://github.com/filamoon/pyapollo) > 非常感谢[@filamoon](https://github.com/filamoon)提供Python Apollo客户端的支持 ### Apollo Python 客户端 2 项目地址:[BruceWW-pyapollo](https://github.com/BruceWW/pyapollo) > 非常感谢[@BruceWW](https://github.com/BruceWW)提供Python Apollo客户端的支持 ### Apollo Python 客户端 3 项目地址:[xhrg-product/apollo-client-python](https://github.com/xhrg-product/apollo-client-python) > 非常感谢[@xhrg-product](https://github.com/xhrg-product)提供Python Apollo客户端的支持 ## 3. NodeJS ### Apollo NodeJS 客户端 1 项目地址:[node-apollo](https://github.com/Quinton/node-apollo) > 非常感谢[@Quinton](https://github.com/Quinton)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 2 项目地址:[ctrip-apollo](https://github.com/kaelzhang/ctrip-apollo) > 非常感谢[@kaelzhang](https://github.com/kaelzhang)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 3 项目地址:[node-apollo-client](https://github.com/shinux/node-apollo-client) > 非常感谢[@shinux](https://github.com/shinux)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 4 项目地址:[ctrip-apollo-client](https://github.com/lvgithub/ctrip-apollo-client) > 非常感谢[@lvgithub](https://github.com/lvgithub)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 5 项目地址:[apollo-node](https://github.com/lengyuxuan/apollo-node) > 非常感谢[@lengyuxuan](https://github.com/lengyuxuan)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 6 项目地址:[egg-apollo-client](https://github.com/xuezier/egg-apollo-client) > 非常感谢[@xuezier](https://github.com/xuezier)提供NodeJS Apollo客户端的支持 ### Apollo NodeJS 客户端 7 项目地址:[apollo-node-client](https://github.com/zhangxh1023/apollo-node-client) > 非常感谢[@zhangxh1023](https://github.com/zhangxh1023)提供NodeJS Apollo客户端的支持 ## 4. PHP ### Apollo PHP 客户端 1 项目地址:[apollo-php-client](https://github.com/multilinguals/apollo-php-client) > 非常感谢[@t04041143](https://github.com/t04041143)提供PHP Apollo客户端的支持 ### Apollo PHP 客户端 2 项目地址:[apollo-sdk-config](https://github.com/fengzhibin/apollo-sdk-config) > 非常感谢[@fengzhibin](https://github.com/fengzhibin)提供PHP Apollo客户端的支持 ## 5. C ### Apollo C 客户端 项目地址:[apollo-c-client](https://github.com/lzeqian/apollo) > 非常感谢[@lzeqian](https://github.com/lzeqian)提供C Apollo客户端的支持
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/AbstractConfigService.java
package com.ctrip.framework.apollo.configservice.service.config; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolder; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages; import com.google.common.base.Strings; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; /** * @author Jason Song([email protected]) */ public abstract class AbstractConfigService implements ConfigService { @Autowired private GrayReleaseRulesHolder grayReleaseRulesHolder; @Override public Release loadConfig(String clientAppId, String clientIp, String configAppId, String configClusterName, String configNamespace, String dataCenter, ApolloNotificationMessages clientMessages) { // load from specified cluster fist if (!Objects.equals(ConfigConsts.CLUSTER_NAME_DEFAULT, configClusterName)) { Release clusterRelease = findRelease(clientAppId, clientIp, configAppId, configClusterName, configNamespace, clientMessages); if (!Objects.isNull(clusterRelease)) { return clusterRelease; } } // try to load via data center if (!Strings.isNullOrEmpty(dataCenter) && !Objects.equals(dataCenter, configClusterName)) { Release dataCenterRelease = findRelease(clientAppId, clientIp, configAppId, dataCenter, configNamespace, clientMessages); if (!Objects.isNull(dataCenterRelease)) { return dataCenterRelease; } } // fallback to default release return findRelease(clientAppId, clientIp, configAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, configNamespace, clientMessages); } /** * Find release * * @param clientAppId the client's app id * @param clientIp the client ip * @param configAppId the requested config's app id * @param configClusterName the requested config's cluster name * @param configNamespace the requested config's namespace name * @param clientMessages the messages received in client side * @return the release */ private Release findRelease(String clientAppId, String clientIp, String configAppId, String configClusterName, String configNamespace, ApolloNotificationMessages clientMessages) { Long grayReleaseId = grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(clientAppId, clientIp, configAppId, configClusterName, configNamespace); Release release = null; if (grayReleaseId != null) { release = findActiveOne(grayReleaseId, clientMessages); } if (release == null) { release = findLatestActiveRelease(configAppId, configClusterName, configNamespace, clientMessages); } return release; } /** * Find active release by id */ protected abstract Release findActiveOne(long id, ApolloNotificationMessages clientMessages); /** * Find active release by app id, cluster name and namespace name */ protected abstract Release findLatestActiveRelease(String configAppId, String configClusterName, String configNamespaceName, ApolloNotificationMessages clientMessages); }
package com.ctrip.framework.apollo.configservice.service.config; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolder; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages; import com.google.common.base.Strings; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; /** * @author Jason Song([email protected]) */ public abstract class AbstractConfigService implements ConfigService { @Autowired private GrayReleaseRulesHolder grayReleaseRulesHolder; @Override public Release loadConfig(String clientAppId, String clientIp, String configAppId, String configClusterName, String configNamespace, String dataCenter, ApolloNotificationMessages clientMessages) { // load from specified cluster fist if (!Objects.equals(ConfigConsts.CLUSTER_NAME_DEFAULT, configClusterName)) { Release clusterRelease = findRelease(clientAppId, clientIp, configAppId, configClusterName, configNamespace, clientMessages); if (!Objects.isNull(clusterRelease)) { return clusterRelease; } } // try to load via data center if (!Strings.isNullOrEmpty(dataCenter) && !Objects.equals(dataCenter, configClusterName)) { Release dataCenterRelease = findRelease(clientAppId, clientIp, configAppId, dataCenter, configNamespace, clientMessages); if (!Objects.isNull(dataCenterRelease)) { return dataCenterRelease; } } // fallback to default release return findRelease(clientAppId, clientIp, configAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, configNamespace, clientMessages); } /** * Find release * * @param clientAppId the client's app id * @param clientIp the client ip * @param configAppId the requested config's app id * @param configClusterName the requested config's cluster name * @param configNamespace the requested config's namespace name * @param clientMessages the messages received in client side * @return the release */ private Release findRelease(String clientAppId, String clientIp, String configAppId, String configClusterName, String configNamespace, ApolloNotificationMessages clientMessages) { Long grayReleaseId = grayReleaseRulesHolder.findReleaseIdFromGrayReleaseRule(clientAppId, clientIp, configAppId, configClusterName, configNamespace); Release release = null; if (grayReleaseId != null) { release = findActiveOne(grayReleaseId, clientMessages); } if (release == null) { release = findLatestActiveRelease(configAppId, configClusterName, configNamespace, clientMessages); } return release; } /** * Find active release by id */ protected abstract Release findActiveOne(long id, ApolloNotificationMessages clientMessages); /** * Find active release by app id, cluster name and namespace name */ protected abstract Release findLatestActiveRelease(String configAppId, String configClusterName, String configNamespaceName, ApolloNotificationMessages clientMessages); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.Privilege; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.List; public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> { List<Privilege> findByNamespaceId(long namespaceId); List<Privilege> findByNamespaceIdAndPrivilType(long namespaceId, String privilType); Privilege findByNamespaceIdAndNameAndPrivilType(long namespaceId, String name, String privilType); }
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.Privilege; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.List; public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> { List<Privilege> findByNamespaceId(long namespaceId); List<Privilege> findByNamespaceIdAndPrivilType(long namespaceId, String privilType); Privilege findByNamespaceIdAndNameAndPrivilType(long namespaceId, String name, String privilType); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.AccessKey; import java.util.Date; import java.util.List; import org.springframework.data.repository.PagingAndSortingRepository; public interface AccessKeyRepository extends PagingAndSortingRepository<AccessKey, Long> { long countByAppId(String appId); AccessKey findOneByAppIdAndId(String appId, long id); List<AccessKey> findByAppId(String appId); List<AccessKey> findFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTimeAsc(Date date); List<AccessKey> findByDataChangeLastModifiedTime(Date date); }
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.AccessKey; import java.util.Date; import java.util.List; import org.springframework.data.repository.PagingAndSortingRepository; public interface AccessKeyRepository extends PagingAndSortingRepository<AccessKey, Long> { long countByAppId(String appId); AccessKey findOneByAppIdAndId(String appId, long id); List<AccessKey> findByAppId(String appId); List<AccessKey> findFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTimeAsc(Date date); List<AccessKey> findByDataChangeLastModifiedTime(Date date); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/CommitService.java
package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.CommitDTO; 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; @Service public class CommitService { private final AdminServiceAPI.CommitAPI commitAPI; public CommitService(final AdminServiceAPI.CommitAPI commitAPI) { this.commitAPI = commitAPI; } public List<CommitDTO> find(String appId, Env env, String clusterName, String namespaceName, int page, int size) { return commitAPI.find(appId, env, clusterName, namespaceName, page, size); } }
package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.dto.CommitDTO; 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; @Service public class CommitService { private final AdminServiceAPI.CommitAPI commitAPI; public CommitService(final AdminServiceAPI.CommitAPI commitAPI) { this.commitAPI = commitAPI; } public List<CommitDTO> find(String appId, Env env, String clusterName, String namespaceName, int page, int size) { return commitAPI.find(appId, env, clusterName, namespaceName, page, size); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/exception/BadRequestException.java
package com.ctrip.framework.apollo.common.exception; import org.springframework.http.HttpStatus; public class BadRequestException extends AbstractApolloHttpException { public BadRequestException(String str) { super(str); setHttpStatus(HttpStatus.BAD_REQUEST); } }
package com.ctrip.framework.apollo.common.exception; import org.springframework.http.HttpStatus; public class BadRequestException extends AbstractApolloHttpException { public BadRequestException(String str) { super(str); setHttpStatus(HttpStatus.BAD_REQUEST); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/util/SpringInjector.java
package com.ctrip.framework.apollo.spring.util; import com.ctrip.framework.apollo.exceptions.ApolloConfigException; import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory; import com.ctrip.framework.apollo.spring.property.PlaceholderHelper; import com.ctrip.framework.apollo.spring.property.SpringValueRegistry; import com.ctrip.framework.apollo.tracer.Tracer; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Singleton; public class SpringInjector { private static volatile Injector s_injector; private static final Object lock = new Object(); private static Injector getInjector() { if (s_injector == null) { synchronized (lock) { if (s_injector == null) { try { s_injector = Guice.createInjector(new SpringModule()); } catch (Throwable ex) { ApolloConfigException exception = new ApolloConfigException("Unable to initialize Apollo Spring Injector!", ex); Tracer.logError(exception); throw exception; } } } } return s_injector; } public static <T> T getInstance(Class<T> clazz) { try { return getInjector().getInstance(clazz); } catch (Throwable ex) { Tracer.logError(ex); throw new ApolloConfigException( String.format("Unable to load instance for %s!", clazz.getName()), ex); } } private static class SpringModule extends AbstractModule { @Override protected void configure() { bind(PlaceholderHelper.class).in(Singleton.class); bind(ConfigPropertySourceFactory.class).in(Singleton.class); bind(SpringValueRegistry.class).in(Singleton.class); } } }
package com.ctrip.framework.apollo.spring.util; import com.ctrip.framework.apollo.exceptions.ApolloConfigException; import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory; import com.ctrip.framework.apollo.spring.property.PlaceholderHelper; import com.ctrip.framework.apollo.spring.property.SpringValueRegistry; import com.ctrip.framework.apollo.tracer.Tracer; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Singleton; public class SpringInjector { private static volatile Injector s_injector; private static final Object lock = new Object(); private static Injector getInjector() { if (s_injector == null) { synchronized (lock) { if (s_injector == null) { try { s_injector = Guice.createInjector(new SpringModule()); } catch (Throwable ex) { ApolloConfigException exception = new ApolloConfigException("Unable to initialize Apollo Spring Injector!", ex); Tracer.logError(exception); throw exception; } } } } return s_injector; } public static <T> T getInstance(Class<T> clazz) { try { return getInjector().getInstance(clazz); } catch (Throwable ex) { Tracer.logError(ex); throw new ApolloConfigException( String.format("Unable to load instance for %s!", clazz.getName()), ex); } } private static class SpringModule extends AbstractModule { @Override protected void configure() { bind(PlaceholderHelper.class).in(Singleton.class); bind(ConfigPropertySourceFactory.class).in(Singleton.class); bind(SpringValueRegistry.class).in(Singleton.class); } } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.constant.RoleType; import com.ctrip.framework.apollo.portal.constant.TracerEventType; import com.ctrip.framework.apollo.portal.entity.bo.ItemBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.util.RoleUtils; import com.ctrip.framework.apollo.tracer.Tracer; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.gson.Gson; 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.*; @Service public class NamespaceService { private Logger logger = LoggerFactory.getLogger(NamespaceService.class); private static final Gson GSON = new Gson(); private final PortalConfig portalConfig; private final PortalSettings portalSettings; private final UserInfoHolder userInfoHolder; private final AdminServiceAPI.NamespaceAPI namespaceAPI; private final ItemService itemService; private final ReleaseService releaseService; private final AppNamespaceService appNamespaceService; private final InstanceService instanceService; private final NamespaceBranchService branchService; private final RolePermissionService rolePermissionService; public NamespaceService( final PortalConfig portalConfig, final PortalSettings portalSettings, final UserInfoHolder userInfoHolder, final AdminServiceAPI.NamespaceAPI namespaceAPI, final ItemService itemService, final ReleaseService releaseService, final AppNamespaceService appNamespaceService, final InstanceService instanceService, final @Lazy NamespaceBranchService branchService, final RolePermissionService rolePermissionService) { this.portalConfig = portalConfig; this.portalSettings = portalSettings; this.userInfoHolder = userInfoHolder; this.namespaceAPI = namespaceAPI; this.itemService = itemService; this.releaseService = releaseService; this.appNamespaceService = appNamespaceService; this.instanceService = instanceService; this.branchService = branchService; this.rolePermissionService = rolePermissionService; } public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) { if (StringUtils.isEmpty(namespace.getDataChangeCreatedBy())) { namespace.setDataChangeCreatedBy(userInfoHolder.getUser().getUserId()); } namespace.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUserId()); NamespaceDTO createdNamespace = namespaceAPI.createNamespace(env, namespace); Tracer.logEvent(TracerEventType.CREATE_NAMESPACE, String.format("%s+%s+%s+%s", namespace.getAppId(), env, namespace.getClusterName(), namespace.getNamespaceName())); return createdNamespace; } @Transactional public void deleteNamespace(String appId, Env env, String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findByAppIdAndName(appId, namespaceName); //1. check parent namespace has not instances if (namespaceHasInstances(appId, env, clusterName, namespaceName)) { throw new BadRequestException( "Can not delete namespace because namespace has active instances"); } //2. check child namespace has not instances NamespaceDTO childNamespace = branchService .findBranchBaseInfo(appId, env, clusterName, namespaceName); if (childNamespace != null && namespaceHasInstances(appId, env, childNamespace.getClusterName(), namespaceName)) { throw new BadRequestException( "Can not delete namespace because namespace's branch has active instances"); } //3. check public namespace has not associated namespace if (appNamespace != null && appNamespace.isPublic() && publicAppNamespaceHasAssociatedNamespace( namespaceName, env)) { throw new BadRequestException( "Can not delete public namespace which has associated namespaces"); } String operator = userInfoHolder.getUser().getUserId(); namespaceAPI.deleteNamespace(env, appId, clusterName, namespaceName, operator); } public NamespaceDTO loadNamespaceBaseInfo(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException(String.format("Namespace: %s not exist.", namespaceName)); } return namespace; } /** * load cluster all namespace info with items */ public List<NamespaceBO> findNamespaceBOs(String appId, Env env, String clusterName) { List<NamespaceDTO> namespaces = namespaceAPI.findNamespaceByCluster(appId, env, clusterName); if (namespaces == null || namespaces.size() == 0) { throw new BadRequestException("namespaces not exist"); } List<NamespaceBO> namespaceBOs = new LinkedList<>(); for (NamespaceDTO namespace : namespaces) { NamespaceBO namespaceBO; try { namespaceBO = transformNamespace2BO(env, namespace); namespaceBOs.add(namespaceBO); } catch (Exception e) { logger.error("parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}", appId, env, clusterName, namespace.getNamespaceName(), e); throw e; } } return namespaceBOs; } public List<NamespaceDTO> findNamespaces(String appId, Env env, String clusterName) { return namespaceAPI.findNamespaceByCluster(appId, env, clusterName); } public List<NamespaceDTO> getPublicAppNamespaceAllNamespaces(Env env, String publicNamespaceName, int page, int size) { return namespaceAPI.getPublicAppNamespaceAllNamespaces(env, publicNamespaceName, page, size); } public NamespaceBO loadNamespaceBO(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException("namespaces not exist"); } return transformNamespace2BO(env, namespace); } public boolean namespaceHasInstances(String appId, Env env, String clusterName, String namespaceName) { return instanceService.getInstanceCountByNamepsace(appId, env, clusterName, namespaceName) > 0; } public boolean publicAppNamespaceHasAssociatedNamespace(String publicNamespaceName, Env env) { return namespaceAPI.countPublicAppNamespaceAssociatedNamespaces(env, publicNamespaceName) > 0; } public NamespaceBO findPublicNamespaceForAssociatedNamespace(Env env, String appId, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI .findPublicNamespaceForAssociatedNamespace(env, appId, clusterName, namespaceName); return transformNamespace2BO(env, namespace); } public Map<String, Map<String, Boolean>> getNamespacesPublishInfo(String appId) { Map<String, Map<String, Boolean>> result = Maps.newHashMap(); Set<Env> envs = portalConfig.publishTipsSupportedEnvs(); for (Env env : envs) { if (portalSettings.isEnvActive(env)) { result.put(env.toString(), namespaceAPI.getNamespacePublishInfo(env, appId)); } } return result; } private NamespaceBO transformNamespace2BO(Env env, NamespaceDTO namespace) { NamespaceBO namespaceBO = new NamespaceBO(); namespaceBO.setBaseInfo(namespace); String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); fillAppNamespaceProperties(namespaceBO); List<ItemBO> itemBOs = new LinkedList<>(); namespaceBO.setItems(itemBOs); //latest Release ReleaseDTO latestRelease; Map<String, String> releaseItems = new HashMap<>(); Map<String, ItemDTO> deletedItemDTOs = new HashMap<>(); latestRelease = releaseService.loadLatestRelease(appId, env, clusterName, namespaceName); if (latestRelease != null) { releaseItems = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); } //not Release config items List<ItemDTO> items = itemService.findItems(appId, env, clusterName, namespaceName); int modifiedItemCnt = 0; for (ItemDTO itemDTO : items) { ItemBO itemBO = transformItem2BO(itemDTO, releaseItems); if (itemBO.isModified()) { modifiedItemCnt++; } itemBOs.add(itemBO); } //deleted items itemService.findDeletedItems(appId, env, clusterName, namespaceName).forEach(item -> { deletedItemDTOs.put(item.getKey(),item); }); List<ItemBO> deletedItems = parseDeletedItems(items, releaseItems, deletedItemDTOs); itemBOs.addAll(deletedItems); modifiedItemCnt += deletedItems.size(); namespaceBO.setItemModifiedCnt(modifiedItemCnt); return namespaceBO; } private void fillAppNamespaceProperties(NamespaceBO namespace) { final NamespaceDTO namespaceDTO = namespace.getBaseInfo(); final String appId = namespaceDTO.getAppId(); final String clusterName = namespaceDTO.getClusterName(); final String namespaceName = namespaceDTO.getNamespaceName(); //先从当前appId下面找,包含私有的和公共的 AppNamespace appNamespace = appNamespaceService .findByAppIdAndName(appId, namespaceName); //再从公共的app namespace里面找 if (appNamespace == null) { appNamespace = appNamespaceService.findPublicAppNamespace(namespaceName); } final String format; final boolean isPublic; if (appNamespace == null) { //dirty data logger.warn("Dirty data, cannot find appNamespace by namespaceName [{}], appId = {}, cluster = {}, set it format to {}, make public", namespaceName, appId, clusterName, ConfigFileFormat.Properties.getValue()); format = ConfigFileFormat.Properties.getValue(); isPublic = true; // set to true, because public namespace allowed to delete by user } else { format = appNamespace.getFormat(); isPublic = appNamespace.isPublic(); namespace.setParentAppId(appNamespace.getAppId()); namespace.setComment(appNamespace.getComment()); } namespace.setFormat(format); namespace.setPublic(isPublic); } private List<ItemBO> parseDeletedItems(List<ItemDTO> newItems, Map<String, String> releaseItems, Map<String, ItemDTO> deletedItemDTOs) { Map<String, ItemDTO> newItemMap = BeanUtils.mapByKey("key", newItems); List<ItemBO> deletedItems = new LinkedList<>(); for (Map.Entry<String, String> entry : releaseItems.entrySet()) { String key = entry.getKey(); if (newItemMap.get(key) == null) { ItemBO deletedItem = new ItemBO(); deletedItem.setDeleted(true); ItemDTO deletedItemDto = deletedItemDTOs.computeIfAbsent(key, k -> new ItemDTO()); deletedItemDto.setKey(key); String oldValue = entry.getValue(); deletedItem.setItem(deletedItemDto); deletedItemDto.setValue(oldValue); deletedItem.setModified(true); deletedItem.setOldValue(oldValue); deletedItem.setNewValue(""); deletedItems.add(deletedItem); } } return deletedItems; } private ItemBO transformItem2BO(ItemDTO itemDTO, Map<String, String> releaseItems) { String key = itemDTO.getKey(); ItemBO itemBO = new ItemBO(); itemBO.setItem(itemDTO); String newValue = itemDTO.getValue(); String oldValue = releaseItems.get(key); //new item or modified if (!StringUtils.isEmpty(key) && (!newValue.equals(oldValue))) { itemBO.setModified(true); itemBO.setOldValue(oldValue == null ? "" : oldValue); itemBO.setNewValue(newValue); } return itemBO; } public void assignNamespaceRoleToOperator(String appId, String namespaceName, String operator) { //default assign modify、release namespace role to namespace creator rolePermissionService .assignRoleToUsers( RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.MODIFY_NAMESPACE), Sets.newHashSet(operator), operator); rolePermissionService .assignRoleToUsers( RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.RELEASE_NAMESPACE), Sets.newHashSet(operator), operator); } }
package com.ctrip.framework.apollo.portal.service; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.component.PortalSettings; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.constant.RoleType; import com.ctrip.framework.apollo.portal.constant.TracerEventType; import com.ctrip.framework.apollo.portal.entity.bo.ItemBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.util.RoleUtils; import com.ctrip.framework.apollo.tracer.Tracer; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.gson.Gson; 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.*; @Service public class NamespaceService { private Logger logger = LoggerFactory.getLogger(NamespaceService.class); private static final Gson GSON = new Gson(); private final PortalConfig portalConfig; private final PortalSettings portalSettings; private final UserInfoHolder userInfoHolder; private final AdminServiceAPI.NamespaceAPI namespaceAPI; private final ItemService itemService; private final ReleaseService releaseService; private final AppNamespaceService appNamespaceService; private final InstanceService instanceService; private final NamespaceBranchService branchService; private final RolePermissionService rolePermissionService; public NamespaceService( final PortalConfig portalConfig, final PortalSettings portalSettings, final UserInfoHolder userInfoHolder, final AdminServiceAPI.NamespaceAPI namespaceAPI, final ItemService itemService, final ReleaseService releaseService, final AppNamespaceService appNamespaceService, final InstanceService instanceService, final @Lazy NamespaceBranchService branchService, final RolePermissionService rolePermissionService) { this.portalConfig = portalConfig; this.portalSettings = portalSettings; this.userInfoHolder = userInfoHolder; this.namespaceAPI = namespaceAPI; this.itemService = itemService; this.releaseService = releaseService; this.appNamespaceService = appNamespaceService; this.instanceService = instanceService; this.branchService = branchService; this.rolePermissionService = rolePermissionService; } public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) { if (StringUtils.isEmpty(namespace.getDataChangeCreatedBy())) { namespace.setDataChangeCreatedBy(userInfoHolder.getUser().getUserId()); } namespace.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUserId()); NamespaceDTO createdNamespace = namespaceAPI.createNamespace(env, namespace); Tracer.logEvent(TracerEventType.CREATE_NAMESPACE, String.format("%s+%s+%s+%s", namespace.getAppId(), env, namespace.getClusterName(), namespace.getNamespaceName())); return createdNamespace; } @Transactional public void deleteNamespace(String appId, Env env, String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findByAppIdAndName(appId, namespaceName); //1. check parent namespace has not instances if (namespaceHasInstances(appId, env, clusterName, namespaceName)) { throw new BadRequestException( "Can not delete namespace because namespace has active instances"); } //2. check child namespace has not instances NamespaceDTO childNamespace = branchService .findBranchBaseInfo(appId, env, clusterName, namespaceName); if (childNamespace != null && namespaceHasInstances(appId, env, childNamespace.getClusterName(), namespaceName)) { throw new BadRequestException( "Can not delete namespace because namespace's branch has active instances"); } //3. check public namespace has not associated namespace if (appNamespace != null && appNamespace.isPublic() && publicAppNamespaceHasAssociatedNamespace( namespaceName, env)) { throw new BadRequestException( "Can not delete public namespace which has associated namespaces"); } String operator = userInfoHolder.getUser().getUserId(); namespaceAPI.deleteNamespace(env, appId, clusterName, namespaceName, operator); } public NamespaceDTO loadNamespaceBaseInfo(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException(String.format("Namespace: %s not exist.", namespaceName)); } return namespace; } /** * load cluster all namespace info with items */ public List<NamespaceBO> findNamespaceBOs(String appId, Env env, String clusterName) { List<NamespaceDTO> namespaces = namespaceAPI.findNamespaceByCluster(appId, env, clusterName); if (namespaces == null || namespaces.size() == 0) { throw new BadRequestException("namespaces not exist"); } List<NamespaceBO> namespaceBOs = new LinkedList<>(); for (NamespaceDTO namespace : namespaces) { NamespaceBO namespaceBO; try { namespaceBO = transformNamespace2BO(env, namespace); namespaceBOs.add(namespaceBO); } catch (Exception e) { logger.error("parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}", appId, env, clusterName, namespace.getNamespaceName(), e); throw e; } } return namespaceBOs; } public List<NamespaceDTO> findNamespaces(String appId, Env env, String clusterName) { return namespaceAPI.findNamespaceByCluster(appId, env, clusterName); } public List<NamespaceDTO> getPublicAppNamespaceAllNamespaces(Env env, String publicNamespaceName, int page, int size) { return namespaceAPI.getPublicAppNamespaceAllNamespaces(env, publicNamespaceName, page, size); } public NamespaceBO loadNamespaceBO(String appId, Env env, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName); if (namespace == null) { throw new BadRequestException("namespaces not exist"); } return transformNamespace2BO(env, namespace); } public boolean namespaceHasInstances(String appId, Env env, String clusterName, String namespaceName) { return instanceService.getInstanceCountByNamepsace(appId, env, clusterName, namespaceName) > 0; } public boolean publicAppNamespaceHasAssociatedNamespace(String publicNamespaceName, Env env) { return namespaceAPI.countPublicAppNamespaceAssociatedNamespaces(env, publicNamespaceName) > 0; } public NamespaceBO findPublicNamespaceForAssociatedNamespace(Env env, String appId, String clusterName, String namespaceName) { NamespaceDTO namespace = namespaceAPI .findPublicNamespaceForAssociatedNamespace(env, appId, clusterName, namespaceName); return transformNamespace2BO(env, namespace); } public Map<String, Map<String, Boolean>> getNamespacesPublishInfo(String appId) { Map<String, Map<String, Boolean>> result = Maps.newHashMap(); Set<Env> envs = portalConfig.publishTipsSupportedEnvs(); for (Env env : envs) { if (portalSettings.isEnvActive(env)) { result.put(env.toString(), namespaceAPI.getNamespacePublishInfo(env, appId)); } } return result; } private NamespaceBO transformNamespace2BO(Env env, NamespaceDTO namespace) { NamespaceBO namespaceBO = new NamespaceBO(); namespaceBO.setBaseInfo(namespace); String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); fillAppNamespaceProperties(namespaceBO); List<ItemBO> itemBOs = new LinkedList<>(); namespaceBO.setItems(itemBOs); //latest Release ReleaseDTO latestRelease; Map<String, String> releaseItems = new HashMap<>(); Map<String, ItemDTO> deletedItemDTOs = new HashMap<>(); latestRelease = releaseService.loadLatestRelease(appId, env, clusterName, namespaceName); if (latestRelease != null) { releaseItems = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); } //not Release config items List<ItemDTO> items = itemService.findItems(appId, env, clusterName, namespaceName); int modifiedItemCnt = 0; for (ItemDTO itemDTO : items) { ItemBO itemBO = transformItem2BO(itemDTO, releaseItems); if (itemBO.isModified()) { modifiedItemCnt++; } itemBOs.add(itemBO); } //deleted items itemService.findDeletedItems(appId, env, clusterName, namespaceName).forEach(item -> { deletedItemDTOs.put(item.getKey(),item); }); List<ItemBO> deletedItems = parseDeletedItems(items, releaseItems, deletedItemDTOs); itemBOs.addAll(deletedItems); modifiedItemCnt += deletedItems.size(); namespaceBO.setItemModifiedCnt(modifiedItemCnt); return namespaceBO; } private void fillAppNamespaceProperties(NamespaceBO namespace) { final NamespaceDTO namespaceDTO = namespace.getBaseInfo(); final String appId = namespaceDTO.getAppId(); final String clusterName = namespaceDTO.getClusterName(); final String namespaceName = namespaceDTO.getNamespaceName(); //先从当前appId下面找,包含私有的和公共的 AppNamespace appNamespace = appNamespaceService .findByAppIdAndName(appId, namespaceName); //再从公共的app namespace里面找 if (appNamespace == null) { appNamespace = appNamespaceService.findPublicAppNamespace(namespaceName); } final String format; final boolean isPublic; if (appNamespace == null) { //dirty data logger.warn("Dirty data, cannot find appNamespace by namespaceName [{}], appId = {}, cluster = {}, set it format to {}, make public", namespaceName, appId, clusterName, ConfigFileFormat.Properties.getValue()); format = ConfigFileFormat.Properties.getValue(); isPublic = true; // set to true, because public namespace allowed to delete by user } else { format = appNamespace.getFormat(); isPublic = appNamespace.isPublic(); namespace.setParentAppId(appNamespace.getAppId()); namespace.setComment(appNamespace.getComment()); } namespace.setFormat(format); namespace.setPublic(isPublic); } private List<ItemBO> parseDeletedItems(List<ItemDTO> newItems, Map<String, String> releaseItems, Map<String, ItemDTO> deletedItemDTOs) { Map<String, ItemDTO> newItemMap = BeanUtils.mapByKey("key", newItems); List<ItemBO> deletedItems = new LinkedList<>(); for (Map.Entry<String, String> entry : releaseItems.entrySet()) { String key = entry.getKey(); if (newItemMap.get(key) == null) { ItemBO deletedItem = new ItemBO(); deletedItem.setDeleted(true); ItemDTO deletedItemDto = deletedItemDTOs.computeIfAbsent(key, k -> new ItemDTO()); deletedItemDto.setKey(key); String oldValue = entry.getValue(); deletedItem.setItem(deletedItemDto); deletedItemDto.setValue(oldValue); deletedItem.setModified(true); deletedItem.setOldValue(oldValue); deletedItem.setNewValue(""); deletedItems.add(deletedItem); } } return deletedItems; } private ItemBO transformItem2BO(ItemDTO itemDTO, Map<String, String> releaseItems) { String key = itemDTO.getKey(); ItemBO itemBO = new ItemBO(); itemBO.setItem(itemDTO); String newValue = itemDTO.getValue(); String oldValue = releaseItems.get(key); //new item or modified if (!StringUtils.isEmpty(key) && (!newValue.equals(oldValue))) { itemBO.setModified(true); itemBO.setOldValue(oldValue == null ? "" : oldValue); itemBO.setNewValue(newValue); } return itemBO; } public void assignNamespaceRoleToOperator(String appId, String namespaceName, String operator) { //default assign modify、release namespace role to namespace creator rolePermissionService .assignRoleToUsers( RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.MODIFY_NAMESPACE), Sets.newHashSet(operator), operator); rolePermissionService .assignRoleToUsers( RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.RELEASE_NAMESPACE), Sets.newHashSet(operator), operator); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/AutoUpdateConfigChangeListener.java
package com.ctrip.framework.apollo.spring.property; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.google.gson.Gson; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.Collection; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.TypeConverter; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.core.env.Environment; import org.springframework.util.CollectionUtils; /** * Create by zhangzheng on 2018/3/6 */ public class AutoUpdateConfigChangeListener implements ConfigChangeListener{ private static final Logger logger = LoggerFactory.getLogger(AutoUpdateConfigChangeListener.class); private final boolean typeConverterHasConvertIfNecessaryWithFieldParameter; private final Environment environment; private final ConfigurableBeanFactory beanFactory; private final TypeConverter typeConverter; private final PlaceholderHelper placeholderHelper; private final SpringValueRegistry springValueRegistry; private final Gson gson; public AutoUpdateConfigChangeListener(Environment environment, ConfigurableListableBeanFactory beanFactory){ this.typeConverterHasConvertIfNecessaryWithFieldParameter = testTypeConverterHasConvertIfNecessaryWithFieldParameter(); this.beanFactory = beanFactory; this.typeConverter = this.beanFactory.getTypeConverter(); this.environment = environment; this.placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class); this.springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class); this.gson = new Gson(); } @Override public void onChange(ConfigChangeEvent changeEvent) { Set<String> keys = changeEvent.changedKeys(); if (CollectionUtils.isEmpty(keys)) { return; } for (String key : keys) { // 1. check whether the changed key is relevant Collection<SpringValue> targetValues = springValueRegistry.get(beanFactory, key); if (targetValues == null || targetValues.isEmpty()) { continue; } // 2. update the value for (SpringValue val : targetValues) { updateSpringValue(val); } } } private void updateSpringValue(SpringValue springValue) { try { Object value = resolvePropertyValue(springValue); springValue.update(value); logger.info("Auto update apollo changed value successfully, new value: {}, {}", value, springValue); } catch (Throwable ex) { logger.error("Auto update apollo changed value failed, {}", springValue.toString(), ex); } } /** * Logic transplanted from DefaultListableBeanFactory * @see org.springframework.beans.factory.support.DefaultListableBeanFactory#doResolveDependency(org.springframework.beans.factory.config.DependencyDescriptor, java.lang.String, java.util.Set, org.springframework.beans.TypeConverter) */ private Object resolvePropertyValue(SpringValue springValue) { // value will never be null, as @Value and @ApolloJsonValue will not allow that Object value = placeholderHelper .resolvePropertyValue(beanFactory, springValue.getBeanName(), springValue.getPlaceholder()); if (springValue.isJson()) { value = parseJsonValue((String)value, springValue.getGenericType()); } else { if (springValue.isField()) { // org.springframework.beans.TypeConverter#convertIfNecessary(java.lang.Object, java.lang.Class, java.lang.reflect.Field) is available from Spring 3.2.0+ if (typeConverterHasConvertIfNecessaryWithFieldParameter) { value = this.typeConverter .convertIfNecessary(value, springValue.getTargetType(), springValue.getField()); } else { value = this.typeConverter.convertIfNecessary(value, springValue.getTargetType()); } } else { value = this.typeConverter.convertIfNecessary(value, springValue.getTargetType(), springValue.getMethodParameter()); } } return value; } private Object parseJsonValue(String json, Type targetType) { try { return gson.fromJson(json, targetType); } catch (Throwable ex) { logger.error("Parsing json '{}' to type {} failed!", json, targetType, ex); throw ex; } } private boolean testTypeConverterHasConvertIfNecessaryWithFieldParameter() { try { TypeConverter.class.getMethod("convertIfNecessary", Object.class, Class.class, Field.class); } catch (Throwable ex) { return false; } return true; } }
package com.ctrip.framework.apollo.spring.property; import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.spring.util.SpringInjector; import com.google.gson.Gson; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.Collection; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.TypeConverter; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.core.env.Environment; import org.springframework.util.CollectionUtils; /** * Create by zhangzheng on 2018/3/6 */ public class AutoUpdateConfigChangeListener implements ConfigChangeListener{ private static final Logger logger = LoggerFactory.getLogger(AutoUpdateConfigChangeListener.class); private final boolean typeConverterHasConvertIfNecessaryWithFieldParameter; private final Environment environment; private final ConfigurableBeanFactory beanFactory; private final TypeConverter typeConverter; private final PlaceholderHelper placeholderHelper; private final SpringValueRegistry springValueRegistry; private final Gson gson; public AutoUpdateConfigChangeListener(Environment environment, ConfigurableListableBeanFactory beanFactory){ this.typeConverterHasConvertIfNecessaryWithFieldParameter = testTypeConverterHasConvertIfNecessaryWithFieldParameter(); this.beanFactory = beanFactory; this.typeConverter = this.beanFactory.getTypeConverter(); this.environment = environment; this.placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class); this.springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class); this.gson = new Gson(); } @Override public void onChange(ConfigChangeEvent changeEvent) { Set<String> keys = changeEvent.changedKeys(); if (CollectionUtils.isEmpty(keys)) { return; } for (String key : keys) { // 1. check whether the changed key is relevant Collection<SpringValue> targetValues = springValueRegistry.get(beanFactory, key); if (targetValues == null || targetValues.isEmpty()) { continue; } // 2. update the value for (SpringValue val : targetValues) { updateSpringValue(val); } } } private void updateSpringValue(SpringValue springValue) { try { Object value = resolvePropertyValue(springValue); springValue.update(value); logger.info("Auto update apollo changed value successfully, new value: {}, {}", value, springValue); } catch (Throwable ex) { logger.error("Auto update apollo changed value failed, {}", springValue.toString(), ex); } } /** * Logic transplanted from DefaultListableBeanFactory * @see org.springframework.beans.factory.support.DefaultListableBeanFactory#doResolveDependency(org.springframework.beans.factory.config.DependencyDescriptor, java.lang.String, java.util.Set, org.springframework.beans.TypeConverter) */ private Object resolvePropertyValue(SpringValue springValue) { // value will never be null, as @Value and @ApolloJsonValue will not allow that Object value = placeholderHelper .resolvePropertyValue(beanFactory, springValue.getBeanName(), springValue.getPlaceholder()); if (springValue.isJson()) { value = parseJsonValue((String)value, springValue.getGenericType()); } else { if (springValue.isField()) { // org.springframework.beans.TypeConverter#convertIfNecessary(java.lang.Object, java.lang.Class, java.lang.reflect.Field) is available from Spring 3.2.0+ if (typeConverterHasConvertIfNecessaryWithFieldParameter) { value = this.typeConverter .convertIfNecessary(value, springValue.getTargetType(), springValue.getField()); } else { value = this.typeConverter.convertIfNecessary(value, springValue.getTargetType()); } } else { value = this.typeConverter.convertIfNecessary(value, springValue.getTargetType(), springValue.getMethodParameter()); } } return value; } private Object parseJsonValue(String json, Type targetType) { try { return gson.fromJson(json, targetType); } catch (Throwable ex) { logger.error("Parsing json '{}' to type {} failed!", json, targetType, ex); throw ex; } } private boolean testTypeConverterHasConvertIfNecessaryWithFieldParameter() { try { TypeConverter.class.getMethod("convertIfNecessary", Object.class, Class.class, Field.class); } catch (Throwable ex) { return false; } return true; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/util/BeanRegistrationUtil.java
package com.ctrip.framework.apollo.spring.util; import java.util.Map; import java.util.Objects; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionRegistry; /** * @author Jason Song([email protected]) */ public class BeanRegistrationUtil { public static boolean registerBeanDefinitionIfNotExists(BeanDefinitionRegistry registry, String beanName, Class<?> beanClass) { return registerBeanDefinitionIfNotExists(registry, beanName, beanClass, null); } public static boolean registerBeanDefinitionIfNotExists(BeanDefinitionRegistry registry, String beanName, Class<?> beanClass, Map<String, Object> extraPropertyValues) { if (registry.containsBeanDefinition(beanName)) { return false; } String[] candidates = registry.getBeanDefinitionNames(); for (String candidate : candidates) { BeanDefinition beanDefinition = registry.getBeanDefinition(candidate); if (Objects.equals(beanDefinition.getBeanClassName(), beanClass.getName())) { return false; } } BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(beanClass).getBeanDefinition(); if (extraPropertyValues != null) { for (Map.Entry<String, Object> entry : extraPropertyValues.entrySet()) { beanDefinition.getPropertyValues().add(entry.getKey(), entry.getValue()); } } registry.registerBeanDefinition(beanName, beanDefinition); return true; } }
package com.ctrip.framework.apollo.spring.util; import java.util.Map; import java.util.Objects; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionRegistry; /** * @author Jason Song([email protected]) */ public class BeanRegistrationUtil { public static boolean registerBeanDefinitionIfNotExists(BeanDefinitionRegistry registry, String beanName, Class<?> beanClass) { return registerBeanDefinitionIfNotExists(registry, beanName, beanClass, null); } public static boolean registerBeanDefinitionIfNotExists(BeanDefinitionRegistry registry, String beanName, Class<?> beanClass, Map<String, Object> extraPropertyValues) { if (registry.containsBeanDefinition(beanName)) { return false; } String[] candidates = registry.getBeanDefinitionNames(); for (String candidate : candidates) { BeanDefinition beanDefinition = registry.getBeanDefinition(candidate); if (Objects.equals(beanDefinition.getBeanClassName(), beanClass.getName())) { return false; } } BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(beanClass).getBeanDefinition(); if (extraPropertyValues != null) { for (Map.Entry<String, Object> entry : extraPropertyValues.entrySet()) { beanDefinition.getPropertyValues().add(entry.getKey(), entry.getValue()); } } registry.registerBeanDefinition(beanName, beanDefinition); return true; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-core/src/main/java/com/ctrip/framework/apollo/core/spi/Ordered.java
package com.ctrip.framework.apollo.core.spi; /** * {@code Ordered} is an interface that can be implemented by objects that * should be <em>orderable</em>, for example in a {@code Collection}. * * <p>The actual {@link #getOrder() order} can be interpreted as prioritization, * with the first object (with the lowest order value) having the highest * priority. * * @since 1.0.0 */ public interface Ordered { /** * Useful constant for the highest precedence value. * @see java.lang.Integer#MIN_VALUE */ int HIGHEST_PRECEDENCE = Integer.MIN_VALUE; /** * Useful constant for the lowest precedence value. * @see java.lang.Integer#MAX_VALUE */ int LOWEST_PRECEDENCE = Integer.MAX_VALUE; /** * Get the order value of this object. * <p>Higher values are interpreted as lower priority. As a consequence, * the object with the lowest value has the highest priority (somewhat * analogous to Servlet {@code load-on-startup} values). * <p>Same order values will result in arbitrary sort positions for the * affected objects. * @return the order value * @see #HIGHEST_PRECEDENCE * @see #LOWEST_PRECEDENCE */ int getOrder(); }
package com.ctrip.framework.apollo.core.spi; /** * {@code Ordered} is an interface that can be implemented by objects that * should be <em>orderable</em>, for example in a {@code Collection}. * * <p>The actual {@link #getOrder() order} can be interpreted as prioritization, * with the first object (with the lowest order value) having the highest * priority. * * @since 1.0.0 */ public interface Ordered { /** * Useful constant for the highest precedence value. * @see java.lang.Integer#MIN_VALUE */ int HIGHEST_PRECEDENCE = Integer.MIN_VALUE; /** * Useful constant for the lowest precedence value. * @see java.lang.Integer#MAX_VALUE */ int LOWEST_PRECEDENCE = Integer.MAX_VALUE; /** * Get the order value of this object. * <p>Higher values are interpreted as lower priority. As a consequence, * the object with the lowest value has the highest priority (somewhat * analogous to Servlet {@code load-on-startup} values). * <p>Same order values will result in arbitrary sort positions for the * affected objects. * @return the order value * @see #HIGHEST_PRECEDENCE * @see #LOWEST_PRECEDENCE */ int getOrder(); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java
package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapMappingProperties description. * * @author wuzishu */ public class LdapMappingProperties { /** * user ldap objectClass */ private String objectClass; /** * user login Id */ private String loginId; /** * user rdn key */ private String rdnKey; /** * user display name */ private String userDisplayName; /** * email */ private String email; public String getObjectClass() { return objectClass; } public void setObjectClass(String objectClass) { this.objectClass = objectClass; } public String getLoginId() { return loginId; } public void setLoginId(String loginId) { this.loginId = loginId; } public String getRdnKey() { return rdnKey; } public void setRdnKey(String rdnKey) { this.rdnKey = rdnKey; } public String getUserDisplayName() { return userDisplayName; } public void setUserDisplayName(String userDisplayName) { this.userDisplayName = userDisplayName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }
package com.ctrip.framework.apollo.portal.spi.configuration; /** * the LdapMappingProperties description. * * @author wuzishu */ public class LdapMappingProperties { /** * user ldap objectClass */ private String objectClass; /** * user login Id */ private String loginId; /** * user rdn key */ private String rdnKey; /** * user display name */ private String userDisplayName; /** * email */ private String email; public String getObjectClass() { return objectClass; } public void setObjectClass(String objectClass) { this.objectClass = objectClass; } public String getLoginId() { return loginId; } public void setLoginId(String loginId) { this.loginId = loginId; } public String getRdnKey() { return rdnKey; } public void setRdnKey(String rdnKey) { this.rdnKey = rdnKey; } public String getUserDisplayName() { return userDisplayName; } public void setUserDisplayName(String userDisplayName) { this.userDisplayName = userDisplayName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/test/java/com/ctrip/framework/apollo/util/parser/DurationParserTest.java
package com.ctrip.framework.apollo.util.parser; import static org.junit.Assert.assertEquals; import org.junit.Test; public class DurationParserTest { private Parsers.DurationParser durationParser = Parsers.forDuration(); @Test public void testParseMilliSeconds() throws Exception { String text = "345MS"; long expected = 345; checkParseToMillis(expected, text); } @Test public void testParseMilliSecondsWithNoSuffix() throws Exception { String text = "123"; long expected = 123; checkParseToMillis(expected, text); } @Test public void testParseSeconds() throws Exception { String text = "20S"; long expected = 20 * 1000; checkParseToMillis(expected, text); } @Test public void testParseMinutes() throws Exception { String text = "15M"; long expected = 15 * 60 * 1000; checkParseToMillis(expected, text); } @Test public void testParseHours() throws Exception { String text = "10H"; long expected = 10 * 3600 * 1000; checkParseToMillis(expected, text); } @Test public void testParseDays() throws Exception { String text = "2D"; long expected = 2 * 24 * 3600 * 1000; checkParseToMillis(expected, text); } @Test public void testParseFullText() throws Exception { String text = "2D3H4M5S123MS"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test public void testParseFullTextWithLowerCase() throws Exception { String text = "2d3h4m5s123ms"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test public void testParseFullTextWithNoMS() throws Exception { String text = "2D3H4M5S123"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test(expected = ParserException.class) public void testParseException() throws Exception { String text = "someInvalidText"; durationParser.parseToMillis(text); } private void checkParseToMillis(long expected, String text) throws Exception { assertEquals(expected, durationParser.parseToMillis(text)); } }
package com.ctrip.framework.apollo.util.parser; import static org.junit.Assert.assertEquals; import org.junit.Test; public class DurationParserTest { private Parsers.DurationParser durationParser = Parsers.forDuration(); @Test public void testParseMilliSeconds() throws Exception { String text = "345MS"; long expected = 345; checkParseToMillis(expected, text); } @Test public void testParseMilliSecondsWithNoSuffix() throws Exception { String text = "123"; long expected = 123; checkParseToMillis(expected, text); } @Test public void testParseSeconds() throws Exception { String text = "20S"; long expected = 20 * 1000; checkParseToMillis(expected, text); } @Test public void testParseMinutes() throws Exception { String text = "15M"; long expected = 15 * 60 * 1000; checkParseToMillis(expected, text); } @Test public void testParseHours() throws Exception { String text = "10H"; long expected = 10 * 3600 * 1000; checkParseToMillis(expected, text); } @Test public void testParseDays() throws Exception { String text = "2D"; long expected = 2 * 24 * 3600 * 1000; checkParseToMillis(expected, text); } @Test public void testParseFullText() throws Exception { String text = "2D3H4M5S123MS"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test public void testParseFullTextWithLowerCase() throws Exception { String text = "2d3h4m5s123ms"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test public void testParseFullTextWithNoMS() throws Exception { String text = "2D3H4M5S123"; long expected = 2 * 24 * 3600 * 1000 + 3 * 3600 * 1000 + 4 * 60 * 1000 + 5 * 1000 + 123; checkParseToMillis(expected, text); } @Test(expected = ParserException.class) public void testParseException() throws Exception { String text = "someInvalidText"; durationParser.parseToMillis(text); } private void checkParseToMillis(long expected, String text) throws Exception { assertEquals(expected, durationParser.parseToMillis(text)); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/cat/CatMessageProducer.java
package com.ctrip.framework.apollo.tracer.internals.cat; import com.ctrip.framework.apollo.tracer.spi.MessageProducer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import java.lang.reflect.Method; /** * @author Jason Song([email protected]) */ public class CatMessageProducer implements MessageProducer { private static Class CAT_CLASS; private static Method LOG_ERROR_WITH_CAUSE; private static Method LOG_ERROR_WITH_MESSAGE_AND_CAUSE; private static Method LOG_EVENT_WITH_TYPE_AND_NAME; private static Method LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS; private static Method NEW_TRANSACTION_WITH_TYPE_AND_NAME; static { try { CAT_CLASS = Class.forName(CatNames.CAT_CLASS); LOG_ERROR_WITH_CAUSE = CAT_CLASS.getMethod(CatNames.LOG_ERROR_METHOD, Throwable.class); LOG_ERROR_WITH_MESSAGE_AND_CAUSE = CAT_CLASS.getMethod(CatNames.LOG_ERROR_METHOD, String.class, Throwable.class); LOG_EVENT_WITH_TYPE_AND_NAME = CAT_CLASS.getMethod(CatNames.LOG_EVENT_METHOD, String.class, String.class); LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS = CAT_CLASS.getMethod(CatNames.LOG_EVENT_METHOD, String.class, String.class, String.class, String.class); NEW_TRANSACTION_WITH_TYPE_AND_NAME = CAT_CLASS.getMethod( CatNames.NEW_TRANSACTION_METHOD, String.class, String.class); //eager init CatTransaction CatTransaction.init(); } catch (Throwable ex) { throw new IllegalStateException("Initialize Cat message producer failed", ex); } } @Override public void logError(Throwable cause) { try { LOG_ERROR_WITH_CAUSE.invoke(null, cause); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logError(String message, Throwable cause) { try { LOG_ERROR_WITH_MESSAGE_AND_CAUSE.invoke(null, message, cause); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logEvent(String type, String name) { try { LOG_EVENT_WITH_TYPE_AND_NAME.invoke(null, type, name); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logEvent(String type, String name, String status, String nameValuePairs) { try { LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS.invoke(null, type, name, status, nameValuePairs); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public Transaction newTransaction(String type, String name) { try { return new CatTransaction(NEW_TRANSACTION_WITH_TYPE_AND_NAME.invoke(null, type, name)); } catch (Throwable ex) { throw new IllegalStateException(ex); } } }
package com.ctrip.framework.apollo.tracer.internals.cat; import com.ctrip.framework.apollo.tracer.spi.MessageProducer; import com.ctrip.framework.apollo.tracer.spi.Transaction; import java.lang.reflect.Method; /** * @author Jason Song([email protected]) */ public class CatMessageProducer implements MessageProducer { private static Class CAT_CLASS; private static Method LOG_ERROR_WITH_CAUSE; private static Method LOG_ERROR_WITH_MESSAGE_AND_CAUSE; private static Method LOG_EVENT_WITH_TYPE_AND_NAME; private static Method LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS; private static Method NEW_TRANSACTION_WITH_TYPE_AND_NAME; static { try { CAT_CLASS = Class.forName(CatNames.CAT_CLASS); LOG_ERROR_WITH_CAUSE = CAT_CLASS.getMethod(CatNames.LOG_ERROR_METHOD, Throwable.class); LOG_ERROR_WITH_MESSAGE_AND_CAUSE = CAT_CLASS.getMethod(CatNames.LOG_ERROR_METHOD, String.class, Throwable.class); LOG_EVENT_WITH_TYPE_AND_NAME = CAT_CLASS.getMethod(CatNames.LOG_EVENT_METHOD, String.class, String.class); LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS = CAT_CLASS.getMethod(CatNames.LOG_EVENT_METHOD, String.class, String.class, String.class, String.class); NEW_TRANSACTION_WITH_TYPE_AND_NAME = CAT_CLASS.getMethod( CatNames.NEW_TRANSACTION_METHOD, String.class, String.class); //eager init CatTransaction CatTransaction.init(); } catch (Throwable ex) { throw new IllegalStateException("Initialize Cat message producer failed", ex); } } @Override public void logError(Throwable cause) { try { LOG_ERROR_WITH_CAUSE.invoke(null, cause); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logError(String message, Throwable cause) { try { LOG_ERROR_WITH_MESSAGE_AND_CAUSE.invoke(null, message, cause); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logEvent(String type, String name) { try { LOG_EVENT_WITH_TYPE_AND_NAME.invoke(null, type, name); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public void logEvent(String type, String name, String status, String nameValuePairs) { try { LOG_EVENT_WITH_TYPE_AND_NAME_AND_STATUS_AND_NAME_VALUE_PAIRS.invoke(null, type, name, status, nameValuePairs); } catch (Throwable ex) { throw new IllegalStateException(ex); } } @Override public Transaction newTransaction(String type, String name) { try { return new CatTransaction(NEW_TRANSACTION_WITH_TYPE_AND_NAME.invoke(null, type, name)); } catch (Throwable ex) { throw new IllegalStateException(ex); } } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java
package com.ctrip.framework.foundation.internals.provider; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ctrip.framework.foundation.internals.Utils; import com.ctrip.framework.foundation.internals.io.BOMInputStream; import com.ctrip.framework.foundation.spi.provider.ApplicationProvider; import com.ctrip.framework.foundation.spi.provider.Provider; public class DefaultApplicationProvider implements ApplicationProvider { private static final Logger logger = LoggerFactory.getLogger(DefaultApplicationProvider.class); public static final String APP_PROPERTIES_CLASSPATH = "/META-INF/app.properties"; private Properties m_appProperties = new Properties(); private String m_appId; private String accessKeySecret; @Override public void initialize() { try { InputStream in = Thread.currentThread().getContextClassLoader() .getResourceAsStream(APP_PROPERTIES_CLASSPATH.substring(1)); if (in == null) { in = DefaultApplicationProvider.class.getResourceAsStream(APP_PROPERTIES_CLASSPATH); } initialize(in); } catch (Throwable ex) { logger.error("Initialize DefaultApplicationProvider failed.", ex); } } @Override public void initialize(InputStream in) { try { if (in != null) { try { m_appProperties .load(new InputStreamReader(new BOMInputStream(in), StandardCharsets.UTF_8)); } finally { in.close(); } } initAppId(); initAccessKey(); } catch (Throwable ex) { logger.error("Initialize DefaultApplicationProvider failed.", ex); } } @Override public String getAppId() { return m_appId; } @Override public String getAccessKeySecret() { return accessKeySecret; } @Override public boolean isAppIdSet() { return !Utils.isBlank(m_appId); } @Override public String getProperty(String name, String defaultValue) { if ("app.id".equals(name)) { String val = getAppId(); return val == null ? defaultValue : val; } if ("apollo.accesskey.secret".equals(name)) { String val = getAccessKeySecret(); return val == null ? defaultValue : val; } String val = m_appProperties.getProperty(name, defaultValue); return val == null ? defaultValue : val; } @Override public Class<? extends Provider> getType() { return ApplicationProvider.class; } private void initAppId() { // 1. Get app.id from System Property m_appId = System.getProperty("app.id"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by app.id property from System Property", m_appId); return; } //2. Try to get app id from OS environment variable m_appId = System.getenv("APP_ID"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by APP_ID property from OS environment variable", m_appId); return; } // 3. Try to get app id from app.properties. m_appId = m_appProperties.getProperty("app.id"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by app.id property from {}", m_appId, APP_PROPERTIES_CLASSPATH); return; } m_appId = null; logger.warn("app.id is not available from System Property and {}. It is set to null", APP_PROPERTIES_CLASSPATH); } private void initAccessKey() { // 1. Get accesskey secret from System Property accessKeySecret = System.getProperty("apollo.accesskey.secret"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger .info("ACCESSKEY SECRET is set by apollo.accesskey.secret property from System Property"); return; } //2. Try to get accesskey secret from OS environment variable accessKeySecret = System.getenv("APOLLO_ACCESSKEY_SECRET"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger.info( "ACCESSKEY SECRET is set by APOLLO_ACCESSKEY_SECRET property from OS environment variable"); return; } // 3. Try to get accesskey secret from app.properties. accessKeySecret = m_appProperties.getProperty("apollo.accesskey.secret"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger.info("ACCESSKEY SECRET is set by apollo.accesskey.secret property from {}", APP_PROPERTIES_CLASSPATH); return; } accessKeySecret = null; } @Override public String toString() { return "appId [" + getAppId() + "] properties: " + m_appProperties + " (DefaultApplicationProvider)"; } }
package com.ctrip.framework.foundation.internals.provider; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ctrip.framework.foundation.internals.Utils; import com.ctrip.framework.foundation.internals.io.BOMInputStream; import com.ctrip.framework.foundation.spi.provider.ApplicationProvider; import com.ctrip.framework.foundation.spi.provider.Provider; public class DefaultApplicationProvider implements ApplicationProvider { private static final Logger logger = LoggerFactory.getLogger(DefaultApplicationProvider.class); public static final String APP_PROPERTIES_CLASSPATH = "/META-INF/app.properties"; private Properties m_appProperties = new Properties(); private String m_appId; private String accessKeySecret; @Override public void initialize() { try { InputStream in = Thread.currentThread().getContextClassLoader() .getResourceAsStream(APP_PROPERTIES_CLASSPATH.substring(1)); if (in == null) { in = DefaultApplicationProvider.class.getResourceAsStream(APP_PROPERTIES_CLASSPATH); } initialize(in); } catch (Throwable ex) { logger.error("Initialize DefaultApplicationProvider failed.", ex); } } @Override public void initialize(InputStream in) { try { if (in != null) { try { m_appProperties .load(new InputStreamReader(new BOMInputStream(in), StandardCharsets.UTF_8)); } finally { in.close(); } } initAppId(); initAccessKey(); } catch (Throwable ex) { logger.error("Initialize DefaultApplicationProvider failed.", ex); } } @Override public String getAppId() { return m_appId; } @Override public String getAccessKeySecret() { return accessKeySecret; } @Override public boolean isAppIdSet() { return !Utils.isBlank(m_appId); } @Override public String getProperty(String name, String defaultValue) { if ("app.id".equals(name)) { String val = getAppId(); return val == null ? defaultValue : val; } if ("apollo.accesskey.secret".equals(name)) { String val = getAccessKeySecret(); return val == null ? defaultValue : val; } String val = m_appProperties.getProperty(name, defaultValue); return val == null ? defaultValue : val; } @Override public Class<? extends Provider> getType() { return ApplicationProvider.class; } private void initAppId() { // 1. Get app.id from System Property m_appId = System.getProperty("app.id"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by app.id property from System Property", m_appId); return; } //2. Try to get app id from OS environment variable m_appId = System.getenv("APP_ID"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by APP_ID property from OS environment variable", m_appId); return; } // 3. Try to get app id from app.properties. m_appId = m_appProperties.getProperty("app.id"); if (!Utils.isBlank(m_appId)) { m_appId = m_appId.trim(); logger.info("App ID is set to {} by app.id property from {}", m_appId, APP_PROPERTIES_CLASSPATH); return; } m_appId = null; logger.warn("app.id is not available from System Property and {}. It is set to null", APP_PROPERTIES_CLASSPATH); } private void initAccessKey() { // 1. Get accesskey secret from System Property accessKeySecret = System.getProperty("apollo.accesskey.secret"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger .info("ACCESSKEY SECRET is set by apollo.accesskey.secret property from System Property"); return; } //2. Try to get accesskey secret from OS environment variable accessKeySecret = System.getenv("APOLLO_ACCESSKEY_SECRET"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger.info( "ACCESSKEY SECRET is set by APOLLO_ACCESSKEY_SECRET property from OS environment variable"); return; } // 3. Try to get accesskey secret from app.properties. accessKeySecret = m_appProperties.getProperty("apollo.accesskey.secret"); if (!Utils.isBlank(accessKeySecret)) { accessKeySecret = accessKeySecret.trim(); logger.info("ACCESSKEY SECRET is set by apollo.accesskey.secret property from {}", APP_PROPERTIES_CLASSPATH); return; } accessKeySecret = null; } @Override public String toString() { return "appId [" + getAppId() + "] properties: " + m_appProperties + " (DefaultApplicationProvider)"; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java
package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; 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.auth.ConsumerPermissionValidator; import com.ctrip.framework.apollo.openapi.dto.NamespaceGrayDelReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.entity.model.NamespaceGrayDelReleaseModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.service.NamespaceBranchService; import com.ctrip.framework.apollo.portal.service.ReleaseService; import com.ctrip.framework.apollo.portal.spi.UserService; import javax.servlet.http.HttpServletRequest; import org.springframework.security.access.AccessDeniedException; 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.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; @RestController("openapiReleaseController") @RequestMapping("/openapi/v1/envs/{env}") public class ReleaseController { private final ReleaseService releaseService; private final UserService userService; private final NamespaceBranchService namespaceBranchService; private final ConsumerPermissionValidator consumerPermissionValidator; public ReleaseController( final ReleaseService releaseService, final UserService userService, final NamespaceBranchService namespaceBranchService, final ConsumerPermissionValidator consumerPermissionValidator) { this.releaseService = releaseService; this.userService = userService; this.namespaceBranchService = namespaceBranchService; this.consumerPermissionValidator = consumerPermissionValidator; } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases") public OpenReleaseDTO createRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceReleaseModel releaseModel = BeanUtils.transform(NamespaceReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(Env.valueOf(env).toString()); releaseModel.setClusterName(clusterName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel)); } @GetMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest") public OpenReleaseDTO loadLatestActiveRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { ReleaseDTO releaseDTO = releaseService.loadLatestRelease(appId, Env.valueOf (env), clusterName, namespaceName); if (releaseDTO == null) { return null; } return OpenApiBeanUtils.transformFromReleaseDTO(releaseDTO); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge") public OpenReleaseDTO merge(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestParam(value = "deleteBranch", defaultValue = "true") boolean deleteBranch, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } ReleaseDTO mergedRelease = namespaceBranchService.merge(appId, Env.valueOf(env.toUpperCase()), clusterName, namespaceName, branchName, model.getReleaseTitle(), model.getReleaseComment(), model.isEmergencyPublish(), deleteBranch, model.getReleasedBy()); return OpenApiBeanUtils.transformFromReleaseDTO(mergedRelease); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases") public OpenReleaseDTO createGrayRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceReleaseModel releaseModel = BeanUtils.transform(NamespaceReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(Env.valueOf(env).toString()); releaseModel.setClusterName(branchName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel)); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/gray-del-releases") public OpenReleaseDTO createGrayDelRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody NamespaceGrayDelReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); RequestPrecondition.checkArguments(model.getGrayDelKeys() != null, "Params(grayDelKeys) can not be null"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceGrayDelReleaseModel releaseModel = BeanUtils.transform(NamespaceGrayDelReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(env.toUpperCase()); releaseModel.setClusterName(branchName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel, releaseModel.getReleasedBy())); } @PutMapping(path = "/releases/{releaseId}/rollback") public void rollback(@PathVariable String env, @PathVariable long releaseId, @RequestParam String operator, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(operator), "Param operator can not be empty"); if (userService.findByUserId(operator) == null) { throw new BadRequestException("user(operator) not exists"); } ReleaseDTO release = releaseService.findReleaseById(Env.valueOf(env), releaseId); if (release == null) { throw new BadRequestException("release not found"); } if (!consumerPermissionValidator.hasReleaseNamespacePermission(request,release.getAppId(), release.getNamespaceName(), env)) { throw new AccessDeniedException("Forbidden operation. you don't have release permission"); } releaseService.rollback(Env.valueOf(env), releaseId, operator); } }
package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.BeanUtils; 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.auth.ConsumerPermissionValidator; import com.ctrip.framework.apollo.openapi.dto.NamespaceGrayDelReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO; import com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.entity.model.NamespaceGrayDelReleaseModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.service.NamespaceBranchService; import com.ctrip.framework.apollo.portal.service.ReleaseService; import com.ctrip.framework.apollo.portal.spi.UserService; import javax.servlet.http.HttpServletRequest; import org.springframework.security.access.AccessDeniedException; 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.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; @RestController("openapiReleaseController") @RequestMapping("/openapi/v1/envs/{env}") public class ReleaseController { private final ReleaseService releaseService; private final UserService userService; private final NamespaceBranchService namespaceBranchService; private final ConsumerPermissionValidator consumerPermissionValidator; public ReleaseController( final ReleaseService releaseService, final UserService userService, final NamespaceBranchService namespaceBranchService, final ConsumerPermissionValidator consumerPermissionValidator) { this.releaseService = releaseService; this.userService = userService; this.namespaceBranchService = namespaceBranchService; this.consumerPermissionValidator = consumerPermissionValidator; } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases") public OpenReleaseDTO createRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceReleaseModel releaseModel = BeanUtils.transform(NamespaceReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(Env.valueOf(env).toString()); releaseModel.setClusterName(clusterName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel)); } @GetMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest") public OpenReleaseDTO loadLatestActiveRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { ReleaseDTO releaseDTO = releaseService.loadLatestRelease(appId, Env.valueOf (env), clusterName, namespaceName); if (releaseDTO == null) { return null; } return OpenApiBeanUtils.transformFromReleaseDTO(releaseDTO); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge") public OpenReleaseDTO merge(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestParam(value = "deleteBranch", defaultValue = "true") boolean deleteBranch, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } ReleaseDTO mergedRelease = namespaceBranchService.merge(appId, Env.valueOf(env.toUpperCase()), clusterName, namespaceName, branchName, model.getReleaseTitle(), model.getReleaseComment(), model.isEmergencyPublish(), deleteBranch, model.getReleasedBy()); return OpenApiBeanUtils.transformFromReleaseDTO(mergedRelease); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases") public OpenReleaseDTO createGrayRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceReleaseModel releaseModel = BeanUtils.transform(NamespaceReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(Env.valueOf(env).toString()); releaseModel.setClusterName(branchName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel)); } @PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/gray-del-releases") public OpenReleaseDTO createGrayDelRelease(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody NamespaceGrayDelReleaseDTO model, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model .getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty"); RequestPrecondition.checkArguments(model.getGrayDelKeys() != null, "Params(grayDelKeys) can not be null"); if (userService.findByUserId(model.getReleasedBy()) == null) { throw new BadRequestException("user(releaseBy) not exists"); } NamespaceGrayDelReleaseModel releaseModel = BeanUtils.transform(NamespaceGrayDelReleaseModel.class, model); releaseModel.setAppId(appId); releaseModel.setEnv(env.toUpperCase()); releaseModel.setClusterName(branchName); releaseModel.setNamespaceName(namespaceName); return OpenApiBeanUtils.transformFromReleaseDTO(releaseService.publish(releaseModel, releaseModel.getReleasedBy())); } @PutMapping(path = "/releases/{releaseId}/rollback") public void rollback(@PathVariable String env, @PathVariable long releaseId, @RequestParam String operator, HttpServletRequest request) { RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(operator), "Param operator can not be empty"); if (userService.findByUserId(operator) == null) { throw new BadRequestException("user(operator) not exists"); } ReleaseDTO release = releaseService.findReleaseById(Env.valueOf(env), releaseId); if (release == null) { throw new BadRequestException("release not found"); } if (!consumerPermissionValidator.hasReleaseNamespacePermission(request,release.getAppId(), release.getNamespaceName(), env)) { throw new AccessDeniedException("Forbidden operation. you don't have release permission"); } releaseService.rollback(Env.valueOf(env), releaseId, operator); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesConstants.java
package com.ctrip.framework.apollo.spring.config; public interface PropertySourcesConstants { String APOLLO_PROPERTY_SOURCE_NAME = "ApolloPropertySources"; String APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME = "ApolloBootstrapPropertySources"; String APOLLO_BOOTSTRAP_ENABLED = "apollo.bootstrap.enabled"; String APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED = "apollo.bootstrap.eagerLoad.enabled"; String APOLLO_BOOTSTRAP_NAMESPACES = "apollo.bootstrap.namespaces"; }
package com.ctrip.framework.apollo.spring.config; public interface PropertySourcesConstants { String APOLLO_PROPERTY_SOURCE_NAME = "ApolloPropertySources"; String APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME = "ApolloBootstrapPropertySources"; String APOLLO_BOOTSTRAP_ENABLED = "apollo.bootstrap.enabled"; String APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED = "apollo.bootstrap.eagerLoad.enabled"; String APOLLO_BOOTSTRAP_NAMESPACES = "apollo.bootstrap.namespaces"; }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java
package com.ctrip.framework.apollo.portal.spi.defaultimpl; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; /** * 不是ctrip的公司默认提供一个假用户 */ public class DefaultUserInfoHolder implements UserInfoHolder { public DefaultUserInfoHolder() { } @Override public UserInfo getUser() { UserInfo userInfo = new UserInfo(); userInfo.setUserId("apollo"); return userInfo; } }
package com.ctrip.framework.apollo.portal.spi.defaultimpl; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; /** * 不是ctrip的公司默认提供一个假用户 */ public class DefaultUserInfoHolder implements UserInfoHolder { public DefaultUserInfoHolder() { } @Override public UserInfo getUser() { UserInfo userInfo = new UserInfo(); userInfo.setUserId("apollo"); return userInfo; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
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.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.message.MessageSender; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.ConfigConsts; import com.google.common.collect.Maps; import com.google.gson.Gson; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.Collections; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @Service public class NamespaceService { private static final Gson GSON = new Gson(); private final NamespaceRepository namespaceRepository; private final AuditService auditService; private final AppNamespaceService appNamespaceService; private final ItemService itemService; private final CommitService commitService; private final ReleaseService releaseService; private final ClusterService clusterService; private final NamespaceBranchService namespaceBranchService; private final ReleaseHistoryService releaseHistoryService; private final NamespaceLockService namespaceLockService; private final InstanceService instanceService; private final MessageSender messageSender; public NamespaceService( final ReleaseHistoryService releaseHistoryService, final NamespaceRepository namespaceRepository, final AuditService auditService, final @Lazy AppNamespaceService appNamespaceService, final MessageSender messageSender, final @Lazy ItemService itemService, final CommitService commitService, final @Lazy ReleaseService releaseService, final @Lazy ClusterService clusterService, final @Lazy NamespaceBranchService namespaceBranchService, final NamespaceLockService namespaceLockService, final InstanceService instanceService) { this.releaseHistoryService = releaseHistoryService; this.namespaceRepository = namespaceRepository; this.auditService = auditService; this.appNamespaceService = appNamespaceService; this.messageSender = messageSender; this.itemService = itemService; this.commitService = commitService; this.releaseService = releaseService; this.clusterService = clusterService; this.namespaceBranchService = namespaceBranchService; this.namespaceLockService = namespaceLockService; this.instanceService = instanceService; } public Namespace findOne(Long namespaceId) { return namespaceRepository.findById(namespaceId).orElse(null); } public Namespace findOne(String appId, String clusterName, String namespaceName) { return namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName, namespaceName); } public Namespace findPublicNamespaceForAssociatedNamespace(String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (appNamespace == null) { throw new BadRequestException("namespace not exist"); } String appId = appNamespace.getAppId(); Namespace namespace = findOne(appId, clusterName, namespaceName); //default cluster's namespace if (Objects.equals(clusterName, ConfigConsts.CLUSTER_NAME_DEFAULT)) { return namespace; } //custom cluster's namespace not exist. //return default cluster's namespace if (namespace == null) { return findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); } //custom cluster's namespace exist and has published. //return custom cluster's namespace Release latestActiveRelease = releaseService.findLatestActiveRelease(namespace); if (latestActiveRelease != null) { return namespace; } Namespace defaultNamespace = findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); //custom cluster's namespace exist but never published. //and default cluster's namespace not exist. //return custom cluster's namespace if (defaultNamespace == null) { return namespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist and has published. //return default cluster's namespace Release defaultNamespaceLatestActiveRelease = releaseService.findLatestActiveRelease(defaultNamespace); if (defaultNamespaceLatestActiveRelease != null) { return defaultNamespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist but never published. //return custom cluster's namespace return namespace; } public List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", namespaceName)); } List<Namespace> namespaces = namespaceRepository.findByNamespaceName(namespaceName, page); return filterChildNamespace(namespaces); } private List<Namespace> filterChildNamespace(List<Namespace> namespaces) { List<Namespace> result = new LinkedList<>(); if (CollectionUtils.isEmpty(namespaces)) { return result; } for (Namespace namespace : namespaces) { if (!isChildNamespace(namespace)) { result.add(namespace); } } return result; } public int countPublicAppNamespaceAssociatedNamespaces(String publicNamespaceName) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(publicNamespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", publicNamespaceName)); } return namespaceRepository.countByNamespaceNameAndAppIdNot(publicNamespaceName, publicAppNamespace.getAppId()); } public List<Namespace> findNamespaces(String appId, String clusterName) { List<Namespace> namespaces = namespaceRepository.findByAppIdAndClusterNameOrderByIdAsc(appId, clusterName); if (namespaces == null) { return Collections.emptyList(); } return namespaces; } public List<Namespace> findByAppIdAndNamespaceName(String appId, String namespaceName) { return namespaceRepository.findByAppIdAndNamespaceNameOrderByIdAsc(appId, namespaceName); } public Namespace findChildNamespace(String appId, String parentClusterName, String namespaceName) { List<Namespace> namespaces = findByAppIdAndNamespaceName(appId, namespaceName); if (CollectionUtils.isEmpty(namespaces) || namespaces.size() == 1) { return null; } List<Cluster> childClusters = clusterService.findChildClusters(appId, parentClusterName); if (CollectionUtils.isEmpty(childClusters)) { return null; } Set<String> childClusterNames = childClusters.stream().map(Cluster::getName).collect(Collectors.toSet()); //the child namespace is the intersection of the child clusters and child namespaces for (Namespace namespace : namespaces) { if (childClusterNames.contains(namespace.getClusterName())) { return namespace; } } return null; } public Namespace findChildNamespace(Namespace parentNamespace) { String appId = parentNamespace.getAppId(); String parentClusterName = parentNamespace.getClusterName(); String namespaceName = parentNamespace.getNamespaceName(); return findChildNamespace(appId, parentClusterName, namespaceName); } public Namespace findParentNamespace(String appId, String clusterName, String namespaceName) { return findParentNamespace(new Namespace(appId, clusterName, namespaceName)); } public Namespace findParentNamespace(Namespace namespace) { String appId = namespace.getAppId(); String namespaceName = namespace.getNamespaceName(); Cluster cluster = clusterService.findOne(appId, namespace.getClusterName()); if (cluster != null && cluster.getParentClusterId() > 0) { Cluster parentCluster = clusterService.findOne(cluster.getParentClusterId()); return findOne(appId, parentCluster.getName(), namespaceName); } return null; } public boolean isChildNamespace(String appId, String clusterName, String namespaceName) { return isChildNamespace(new Namespace(appId, clusterName, namespaceName)); } public boolean isChildNamespace(Namespace namespace) { return findParentNamespace(namespace) != null; } public boolean isNamespaceUnique(String appId, String cluster, String namespace) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(cluster, "Cluster must not be null"); Objects.requireNonNull(namespace, "Namespace must not be null"); return Objects.isNull( namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace)); } @Transactional public void deleteByAppIdAndClusterName(String appId, String clusterName, String operator) { List<Namespace> toDeleteNamespaces = findNamespaces(appId, clusterName); for (Namespace namespace : toDeleteNamespaces) { deleteNamespace(namespace, operator); } } @Transactional public Namespace deleteNamespace(Namespace namespace, String operator) { String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); itemService.batchDelete(namespace.getId(), operator); commitService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); // Child namespace releases should retain as long as the parent namespace exists, because parent namespaces' release // histories need them if (!isChildNamespace(namespace)) { releaseService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); } //delete child namespace Namespace childNamespace = findChildNamespace(namespace); if (childNamespace != null) { namespaceBranchService.deleteBranch(appId, clusterName, namespaceName, childNamespace.getClusterName(), NamespaceBranchStatus.DELETED, operator); //delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases releaseService.batchDelete(appId, childNamespace.getClusterName(), namespaceName, operator); } releaseHistoryService.batchDelete(appId, clusterName, namespaceName, operator); instanceService.batchDeleteInstanceConfig(appId, clusterName, namespaceName); namespaceLockService.unlock(namespace.getId()); namespace.setDeleted(true); namespace.setDataChangeLastModifiedBy(operator); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.DELETE, operator); Namespace deleted = namespaceRepository.save(namespace); //Publish release message to do some clean up in config service, such as updating the cache messageSender.sendMessage(ReleaseMessageKeyGenerator.generate(appId, clusterName, namespaceName), Topics.APOLLO_RELEASE_TOPIC); return deleted; } @Transactional public Namespace save(Namespace entity) { if (!isNamespaceUnique(entity.getAppId(), entity.getClusterName(), entity.getNamespaceName())) { throw new ServiceException("namespace not unique"); } entity.setId(0);//protection Namespace namespace = namespaceRepository.save(entity); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.INSERT, namespace.getDataChangeCreatedBy()); return namespace; } @Transactional public Namespace update(Namespace namespace) { Namespace managedNamespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName( namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); BeanUtils.copyEntityProperties(namespace, managedNamespace); managedNamespace = namespaceRepository.save(managedNamespace); auditService.audit(Namespace.class.getSimpleName(), managedNamespace.getId(), Audit.OP.UPDATE, managedNamespace.getDataChangeLastModifiedBy()); return managedNamespace; } @Transactional public void instanceOfAppNamespaces(String appId, String clusterName, String createBy) { List<AppNamespace> appNamespaces = appNamespaceService.findByAppId(appId); for (AppNamespace appNamespace : appNamespaces) { Namespace ns = new Namespace(); ns.setAppId(appId); ns.setClusterName(clusterName); ns.setNamespaceName(appNamespace.getName()); ns.setDataChangeCreatedBy(createBy); ns.setDataChangeLastModifiedBy(createBy); namespaceRepository.save(ns); auditService.audit(Namespace.class.getSimpleName(), ns.getId(), Audit.OP.INSERT, createBy); } } public Map<String, Boolean> namespacePublishInfo(String appId) { List<Cluster> clusters = clusterService.findParentClusters(appId); if (CollectionUtils.isEmpty(clusters)) { throw new BadRequestException("app not exist"); } Map<String, Boolean> clusterHasNotPublishedItems = Maps.newHashMap(); for (Cluster cluster : clusters) { String clusterName = cluster.getName(); List<Namespace> namespaces = findNamespaces(appId, clusterName); for (Namespace namespace : namespaces) { boolean isNamespaceNotPublished = isNamespaceNotPublished(namespace); if (isNamespaceNotPublished) { clusterHasNotPublishedItems.put(clusterName, true); break; } } clusterHasNotPublishedItems.putIfAbsent(clusterName, false); } return clusterHasNotPublishedItems; } private boolean isNamespaceNotPublished(Namespace namespace) { Release latestRelease = releaseService.findLatestActiveRelease(namespace); long namespaceId = namespace.getId(); if (latestRelease == null) { Item lastItem = itemService.findLastOne(namespaceId); return lastItem != null; } Date lastPublishTime = latestRelease.getDataChangeLastModifiedTime(); List<Item> itemsModifiedAfterLastPublish = itemService.findItemsModifiedAfterDate(namespaceId, lastPublishTime); if (CollectionUtils.isEmpty(itemsModifiedAfterLastPublish)) { return false; } Map<String, String> publishedConfiguration = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); for (Item item : itemsModifiedAfterLastPublish) { if (!Objects.equals(item.getValue(), publishedConfiguration.get(item.getKey()))) { return true; } } return false; } }
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.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.message.MessageSender; import com.ctrip.framework.apollo.biz.message.Topics; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator; import com.ctrip.framework.apollo.common.constants.GsonType; import com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.core.ConfigConsts; import com.google.common.collect.Maps; import com.google.gson.Gson; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.Collections; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @Service public class NamespaceService { private static final Gson GSON = new Gson(); private final NamespaceRepository namespaceRepository; private final AuditService auditService; private final AppNamespaceService appNamespaceService; private final ItemService itemService; private final CommitService commitService; private final ReleaseService releaseService; private final ClusterService clusterService; private final NamespaceBranchService namespaceBranchService; private final ReleaseHistoryService releaseHistoryService; private final NamespaceLockService namespaceLockService; private final InstanceService instanceService; private final MessageSender messageSender; public NamespaceService( final ReleaseHistoryService releaseHistoryService, final NamespaceRepository namespaceRepository, final AuditService auditService, final @Lazy AppNamespaceService appNamespaceService, final MessageSender messageSender, final @Lazy ItemService itemService, final CommitService commitService, final @Lazy ReleaseService releaseService, final @Lazy ClusterService clusterService, final @Lazy NamespaceBranchService namespaceBranchService, final NamespaceLockService namespaceLockService, final InstanceService instanceService) { this.releaseHistoryService = releaseHistoryService; this.namespaceRepository = namespaceRepository; this.auditService = auditService; this.appNamespaceService = appNamespaceService; this.messageSender = messageSender; this.itemService = itemService; this.commitService = commitService; this.releaseService = releaseService; this.clusterService = clusterService; this.namespaceBranchService = namespaceBranchService; this.namespaceLockService = namespaceLockService; this.instanceService = instanceService; } public Namespace findOne(Long namespaceId) { return namespaceRepository.findById(namespaceId).orElse(null); } public Namespace findOne(String appId, String clusterName, String namespaceName) { return namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName, namespaceName); } public Namespace findPublicNamespaceForAssociatedNamespace(String clusterName, String namespaceName) { AppNamespace appNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (appNamespace == null) { throw new BadRequestException("namespace not exist"); } String appId = appNamespace.getAppId(); Namespace namespace = findOne(appId, clusterName, namespaceName); //default cluster's namespace if (Objects.equals(clusterName, ConfigConsts.CLUSTER_NAME_DEFAULT)) { return namespace; } //custom cluster's namespace not exist. //return default cluster's namespace if (namespace == null) { return findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); } //custom cluster's namespace exist and has published. //return custom cluster's namespace Release latestActiveRelease = releaseService.findLatestActiveRelease(namespace); if (latestActiveRelease != null) { return namespace; } Namespace defaultNamespace = findOne(appId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName); //custom cluster's namespace exist but never published. //and default cluster's namespace not exist. //return custom cluster's namespace if (defaultNamespace == null) { return namespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist and has published. //return default cluster's namespace Release defaultNamespaceLatestActiveRelease = releaseService.findLatestActiveRelease(defaultNamespace); if (defaultNamespaceLatestActiveRelease != null) { return defaultNamespace; } //custom cluster's namespace exist but never published. //and default cluster's namespace exist but never published. //return custom cluster's namespace return namespace; } public List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", namespaceName)); } List<Namespace> namespaces = namespaceRepository.findByNamespaceName(namespaceName, page); return filterChildNamespace(namespaces); } private List<Namespace> filterChildNamespace(List<Namespace> namespaces) { List<Namespace> result = new LinkedList<>(); if (CollectionUtils.isEmpty(namespaces)) { return result; } for (Namespace namespace : namespaces) { if (!isChildNamespace(namespace)) { result.add(namespace); } } return result; } public int countPublicAppNamespaceAssociatedNamespaces(String publicNamespaceName) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(publicNamespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", publicNamespaceName)); } return namespaceRepository.countByNamespaceNameAndAppIdNot(publicNamespaceName, publicAppNamespace.getAppId()); } public List<Namespace> findNamespaces(String appId, String clusterName) { List<Namespace> namespaces = namespaceRepository.findByAppIdAndClusterNameOrderByIdAsc(appId, clusterName); if (namespaces == null) { return Collections.emptyList(); } return namespaces; } public List<Namespace> findByAppIdAndNamespaceName(String appId, String namespaceName) { return namespaceRepository.findByAppIdAndNamespaceNameOrderByIdAsc(appId, namespaceName); } public Namespace findChildNamespace(String appId, String parentClusterName, String namespaceName) { List<Namespace> namespaces = findByAppIdAndNamespaceName(appId, namespaceName); if (CollectionUtils.isEmpty(namespaces) || namespaces.size() == 1) { return null; } List<Cluster> childClusters = clusterService.findChildClusters(appId, parentClusterName); if (CollectionUtils.isEmpty(childClusters)) { return null; } Set<String> childClusterNames = childClusters.stream().map(Cluster::getName).collect(Collectors.toSet()); //the child namespace is the intersection of the child clusters and child namespaces for (Namespace namespace : namespaces) { if (childClusterNames.contains(namespace.getClusterName())) { return namespace; } } return null; } public Namespace findChildNamespace(Namespace parentNamespace) { String appId = parentNamespace.getAppId(); String parentClusterName = parentNamespace.getClusterName(); String namespaceName = parentNamespace.getNamespaceName(); return findChildNamespace(appId, parentClusterName, namespaceName); } public Namespace findParentNamespace(String appId, String clusterName, String namespaceName) { return findParentNamespace(new Namespace(appId, clusterName, namespaceName)); } public Namespace findParentNamespace(Namespace namespace) { String appId = namespace.getAppId(); String namespaceName = namespace.getNamespaceName(); Cluster cluster = clusterService.findOne(appId, namespace.getClusterName()); if (cluster != null && cluster.getParentClusterId() > 0) { Cluster parentCluster = clusterService.findOne(cluster.getParentClusterId()); return findOne(appId, parentCluster.getName(), namespaceName); } return null; } public boolean isChildNamespace(String appId, String clusterName, String namespaceName) { return isChildNamespace(new Namespace(appId, clusterName, namespaceName)); } public boolean isChildNamespace(Namespace namespace) { return findParentNamespace(namespace) != null; } public boolean isNamespaceUnique(String appId, String cluster, String namespace) { Objects.requireNonNull(appId, "AppId must not be null"); Objects.requireNonNull(cluster, "Cluster must not be null"); Objects.requireNonNull(namespace, "Namespace must not be null"); return Objects.isNull( namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, cluster, namespace)); } @Transactional public void deleteByAppIdAndClusterName(String appId, String clusterName, String operator) { List<Namespace> toDeleteNamespaces = findNamespaces(appId, clusterName); for (Namespace namespace : toDeleteNamespaces) { deleteNamespace(namespace, operator); } } @Transactional public Namespace deleteNamespace(Namespace namespace, String operator) { String appId = namespace.getAppId(); String clusterName = namespace.getClusterName(); String namespaceName = namespace.getNamespaceName(); itemService.batchDelete(namespace.getId(), operator); commitService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); // Child namespace releases should retain as long as the parent namespace exists, because parent namespaces' release // histories need them if (!isChildNamespace(namespace)) { releaseService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator); } //delete child namespace Namespace childNamespace = findChildNamespace(namespace); if (childNamespace != null) { namespaceBranchService.deleteBranch(appId, clusterName, namespaceName, childNamespace.getClusterName(), NamespaceBranchStatus.DELETED, operator); //delete child namespace's releases. Notice: delete child namespace will not delete child namespace's releases releaseService.batchDelete(appId, childNamespace.getClusterName(), namespaceName, operator); } releaseHistoryService.batchDelete(appId, clusterName, namespaceName, operator); instanceService.batchDeleteInstanceConfig(appId, clusterName, namespaceName); namespaceLockService.unlock(namespace.getId()); namespace.setDeleted(true); namespace.setDataChangeLastModifiedBy(operator); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.DELETE, operator); Namespace deleted = namespaceRepository.save(namespace); //Publish release message to do some clean up in config service, such as updating the cache messageSender.sendMessage(ReleaseMessageKeyGenerator.generate(appId, clusterName, namespaceName), Topics.APOLLO_RELEASE_TOPIC); return deleted; } @Transactional public Namespace save(Namespace entity) { if (!isNamespaceUnique(entity.getAppId(), entity.getClusterName(), entity.getNamespaceName())) { throw new ServiceException("namespace not unique"); } entity.setId(0);//protection Namespace namespace = namespaceRepository.save(entity); auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.INSERT, namespace.getDataChangeCreatedBy()); return namespace; } @Transactional public Namespace update(Namespace namespace) { Namespace managedNamespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName( namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); BeanUtils.copyEntityProperties(namespace, managedNamespace); managedNamespace = namespaceRepository.save(managedNamespace); auditService.audit(Namespace.class.getSimpleName(), managedNamespace.getId(), Audit.OP.UPDATE, managedNamespace.getDataChangeLastModifiedBy()); return managedNamespace; } @Transactional public void instanceOfAppNamespaces(String appId, String clusterName, String createBy) { List<AppNamespace> appNamespaces = appNamespaceService.findByAppId(appId); for (AppNamespace appNamespace : appNamespaces) { Namespace ns = new Namespace(); ns.setAppId(appId); ns.setClusterName(clusterName); ns.setNamespaceName(appNamespace.getName()); ns.setDataChangeCreatedBy(createBy); ns.setDataChangeLastModifiedBy(createBy); namespaceRepository.save(ns); auditService.audit(Namespace.class.getSimpleName(), ns.getId(), Audit.OP.INSERT, createBy); } } public Map<String, Boolean> namespacePublishInfo(String appId) { List<Cluster> clusters = clusterService.findParentClusters(appId); if (CollectionUtils.isEmpty(clusters)) { throw new BadRequestException("app not exist"); } Map<String, Boolean> clusterHasNotPublishedItems = Maps.newHashMap(); for (Cluster cluster : clusters) { String clusterName = cluster.getName(); List<Namespace> namespaces = findNamespaces(appId, clusterName); for (Namespace namespace : namespaces) { boolean isNamespaceNotPublished = isNamespaceNotPublished(namespace); if (isNamespaceNotPublished) { clusterHasNotPublishedItems.put(clusterName, true); break; } } clusterHasNotPublishedItems.putIfAbsent(clusterName, false); } return clusterHasNotPublishedItems; } private boolean isNamespaceNotPublished(Namespace namespace) { Release latestRelease = releaseService.findLatestActiveRelease(namespace); long namespaceId = namespace.getId(); if (latestRelease == null) { Item lastItem = itemService.findLastOne(namespaceId); return lastItem != null; } Date lastPublishTime = latestRelease.getDataChangeLastModifiedTime(); List<Item> itemsModifiedAfterLastPublish = itemService.findItemsModifiedAfterDate(namespaceId, lastPublishTime); if (CollectionUtils.isEmpty(itemsModifiedAfterLastPublish)) { return false; } Map<String, String> publishedConfiguration = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG); for (Item item : itemsModifiedAfterLastPublish) { if (!Objects.equals(item.getValue(), publishedConfiguration.get(item.getKey()))) { return true; } } return false; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java
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([email protected]) */ 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()); } }
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([email protected]) */ 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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/FileTextResolver.java
package com.ctrip.framework.apollo.portal.component.txtresolver; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.utils.StringUtils; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; @Component("fileTextResolver") public class FileTextResolver implements ConfigTextResolver { @Override public ItemChangeSets resolve(long namespaceId, String configText, List<ItemDTO> baseItems) { ItemChangeSets changeSets = new ItemChangeSets(); if (CollectionUtils.isEmpty(baseItems) && StringUtils.isEmpty(configText)) { return changeSets; } if (CollectionUtils.isEmpty(baseItems)) { changeSets.addCreateItem(createItem(namespaceId, 0, configText)); } else { ItemDTO beforeItem = baseItems.get(0); if (!configText.equals(beforeItem.getValue())) {//update changeSets.addUpdateItem(createItem(namespaceId, beforeItem.getId(), configText)); } } return changeSets; } private ItemDTO createItem(long namespaceId, long itemId, String value) { ItemDTO item = new ItemDTO(); item.setId(itemId); item.setNamespaceId(namespaceId); item.setValue(value); item.setLineNum(1); item.setKey(ConfigConsts.CONFIG_FILE_CONTENT_KEY); return item; } }
package com.ctrip.framework.apollo.portal.component.txtresolver; import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.utils.StringUtils; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; @Component("fileTextResolver") public class FileTextResolver implements ConfigTextResolver { @Override public ItemChangeSets resolve(long namespaceId, String configText, List<ItemDTO> baseItems) { ItemChangeSets changeSets = new ItemChangeSets(); if (CollectionUtils.isEmpty(baseItems) && StringUtils.isEmpty(configText)) { return changeSets; } if (CollectionUtils.isEmpty(baseItems)) { changeSets.addCreateItem(createItem(namespaceId, 0, configText)); } else { ItemDTO beforeItem = baseItems.get(0); if (!configText.equals(beforeItem.getValue())) {//update changeSets.addUpdateItem(createItem(namespaceId, beforeItem.getId(), configText)); } } return changeSets; } private ItemDTO createItem(long namespaceId, long itemId, String value) { ItemDTO item = new ItemDTO(); item.setId(itemId); item.setNamespaceId(namespaceId); item.setValue(value); item.setLineNum(1); item.setKey(ConfigConsts.CONFIG_FILE_CONTENT_KEY); return item; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerIntegrationExceptionTest.java
package com.ctrip.framework.apollo.adminservice.controller; import com.google.gson.Gson; import com.ctrip.framework.apollo.biz.service.AdminService; import com.ctrip.framework.apollo.biz.service.AppService; import com.ctrip.framework.apollo.common.dto.AppDTO; import com.ctrip.framework.apollo.common.entity.App; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.HttpStatusCodeException; import java.util.Map; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; public class ControllerIntegrationExceptionTest extends AbstractControllerTest { @Autowired AppController appController; @Mock AdminService adminService; private Object realAdminService; @Autowired AppService appService; private static final Gson GSON = new Gson(); @Before public void setUp() { MockitoAnnotations.initMocks(this); realAdminService = ReflectionTestUtils.getField(appController, "adminService"); ReflectionTestUtils.setField(appController, "adminService", adminService); } @After public void tearDown() throws Exception { ReflectionTestUtils.setField(appController, "adminService", realAdminService); } private String getBaseAppUrl() { return "http://localhost:" + port + "/apps/"; } @Test @Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD) public void testCreateFailed() { AppDTO dto = generateSampleDTOData(); when(adminService.createNewApp(any(App.class))).thenThrow(new RuntimeException("save failed")); try { restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class); } catch (HttpStatusCodeException e) { @SuppressWarnings("unchecked") Map<String, String> attr = GSON.fromJson(e.getResponseBodyAsString(), Map.class); Assert.assertEquals("save failed", attr.get("message")); } App savedApp = appService.findOne(dto.getAppId()); Assert.assertNull(savedApp); } private AppDTO generateSampleDTOData() { AppDTO dto = new AppDTO(); dto.setAppId("someAppId"); dto.setName("someName"); dto.setOwnerName("someOwner"); dto.setOwnerEmail("[email protected]"); return dto; } }
package com.ctrip.framework.apollo.adminservice.controller; import com.google.gson.Gson; import com.ctrip.framework.apollo.biz.service.AdminService; import com.ctrip.framework.apollo.biz.service.AppService; import com.ctrip.framework.apollo.common.dto.AppDTO; import com.ctrip.framework.apollo.common.entity.App; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.HttpStatusCodeException; import java.util.Map; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; public class ControllerIntegrationExceptionTest extends AbstractControllerTest { @Autowired AppController appController; @Mock AdminService adminService; private Object realAdminService; @Autowired AppService appService; private static final Gson GSON = new Gson(); @Before public void setUp() { MockitoAnnotations.initMocks(this); realAdminService = ReflectionTestUtils.getField(appController, "adminService"); ReflectionTestUtils.setField(appController, "adminService", adminService); } @After public void tearDown() throws Exception { ReflectionTestUtils.setField(appController, "adminService", realAdminService); } private String getBaseAppUrl() { return "http://localhost:" + port + "/apps/"; } @Test @Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD) public void testCreateFailed() { AppDTO dto = generateSampleDTOData(); when(adminService.createNewApp(any(App.class))).thenThrow(new RuntimeException("save failed")); try { restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class); } catch (HttpStatusCodeException e) { @SuppressWarnings("unchecked") Map<String, String> attr = GSON.fromJson(e.getResponseBodyAsString(), Map.class); Assert.assertEquals("save failed", attr.get("message")); } App savedApp = appService.findOne(dto.getAppId()); Assert.assertNull(savedApp); } private AppDTO generateSampleDTOData() { AppDTO dto = new AppDTO(); dto.setAppId("someAppId"); dto.setName("someName"); dto.setOwnerName("someOwner"); dto.setOwnerEmail("[email protected]"); return dto; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/design/apollo-design.md
# &nbsp; # 一、总体设计 ## 1.1 基础模型 如下即是Apollo的基础模型: 1. 用户在配置中心对配置进行修改并发布 2. 配置中心通知Apollo客户端有配置更新 3. Apollo客户端从配置中心拉取最新的配置、更新本地配置并通知到应用 ![basic-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/basic-architecture.png) ## 1.2 架构模块 下图是Apollo架构模块的概览,详细说明可以参考[Apollo配置中心架构剖析](https://mp.weixin.qq.com/s/-hUaQPzfsl9Lm3IqQW3VDQ)。 ![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进程中 ### 1.2.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 * 最后一点是开源,由于代码是开源的,所以非常便于我们了解它的实现原理和排查问题。 ## 1.3 各模块概要介绍 ### 1.3.1 Config Service * 提供配置获取接口 * 提供配置更新推送接口(基于Http long polling) * 服务端使用[Spring DeferredResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html)实现异步化,从而大大增加长连接数量 * 目前使用的tomcat embed默认配置是最多10000个连接(可以调整),使用了4C8G的虚拟机实测可以支撑10000个连接,所以满足需求(一个应用实例只会发起一个长连接)。 * 接口服务对象为Apollo客户端 ### 1.3.2 Admin Service * 提供配置管理接口 * 提供配置修改、发布等接口 * 接口服务对象为Portal ### 1.3.3 Meta Server * Portal通过域名访问Meta Server获取Admin Service服务列表(IP+Port) * Client通过域名访问Meta Server获取Config Service服务列表(IP+Port) * Meta Server从Eureka获取Config Service和Admin Service的服务信息,相当于是一个Eureka Client * 增设一个Meta Server的角色主要是为了封装服务发现的细节,对Portal和Client而言,永远通过一个Http接口获取Admin Service和Config Service的服务信息,而不需要关心背后实际的服务注册和发现组件 * Meta Server只是一个逻辑角色,在部署时和Config Service是在一个JVM进程中的,所以IP、端口和Config Service一致 ### 1.3.4 Eureka * 基于[Eureka](https://github.com/Netflix/eureka)和[Spring Cloud Netflix](https://cloud.spring.io/spring-cloud-netflix/)提供服务注册和发现 * Config Service和Admin Service会向Eureka注册服务,并保持心跳 * 为了简单起见,目前Eureka在部署时和Config Service是在一个JVM进程中的(通过Spring Cloud Netflix) ### 1.3.5 Portal * 提供Web界面供用户管理配置 * 通过Meta Server获取Admin Service服务列表(IP+Port),通过IP+Port访问服务 * 在Portal侧做load balance、错误重试 ### 1.3.6 Client * Apollo提供的客户端程序,为应用提供配置获取、实时更新等功能 * 通过Meta Server获取Config Service服务列表(IP+Port),通过IP+Port访问服务 * 在Client侧做load balance、错误重试 ## 1.4 E-R Diagram ### 1.4.1 主体E-R Diagram ![apollo-erd](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-erd.png) * **App** * App信息 * **AppNamespace** * App下Namespace的元信息 * **Cluster** * 集群信息 * **Namespace** * 集群下的namespace * **Item** * Namespace的配置,每个Item是一个key, value组合 * **Release** * Namespace发布的配置,每个发布包含发布时该Namespace的所有配置 * **Commit** * Namespace下的配置更改记录 * **Audit** * 审计信息,记录用户在何时使用何种方式操作了哪个实体。 ### 1.4.2 权限相关E-R Diagram ![apollo-erd-role-permission](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-erd-role-permission.png) * **User** * Apollo portal用户 * **UserRole** * 用户和角色的关系 * **Role** * 角色 * **RolePermission** * 角色和权限的关系 * **Permission** * 权限 * 对应到具体的实体资源和操作,如修改NamespaceA的配置,发布NamespaceB的配置等。 * **Consumer** * 第三方应用 * **ConsumerToken** * 发给第三方应用的token * **ConsumerRole** * 第三方应用和角色的关系 * **ConsumerAudit** * 第三方应用访问审计 # 二、服务端设计 ## 2.1 配置发布后的实时推送设计 在配置中心中,一个重要的功能就是配置发布后实时推送到客户端。下面我们简要看一下这块是怎么设计实现的。 ![release-message-notification-design](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/release-message-notification-design.png) 上图简要描述了配置发布的大致过程: 1. 用户在Portal操作配置发布 2. Portal调用Admin Service的接口操作发布 3. Admin Service发布配置后,发送ReleaseMessage给各个Config Service 4. Config Service收到ReleaseMessage后,通知对应的客户端 ### 2.1.1 发送ReleaseMessage的实现方式 Admin Service在配置发布后,需要通知所有的Config Service有配置发布,从而Config Service可以通知对应的客户端来拉取最新的配置。 从概念上来看,这是一个典型的消息使用场景,Admin Service作为producer发出消息,各个Config Service作为consumer消费消息。通过一个消息组件(Message Queue)就能很好的实现Admin Service和Config Service的解耦。 在实现上,考虑到Apollo的实际使用场景,以及为了尽可能减少外部依赖,我们没有采用外部的消息中间件,而是通过数据库实现了一个简单的消息队列。 实现方式如下: 1. Admin Service在配置发布后会往ReleaseMessage表插入一条消息记录,消息内容就是配置发布的AppId+Cluster+Namespace,参见[DatabaseMessageSender](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java) 2. Config Service有一个线程会每秒扫描一次ReleaseMessage表,看看是否有新的消息记录,参见[ReleaseMessageScanner](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java) 3. Config Service如果发现有新的消息记录,那么就会通知到所有的消息监听器([ReleaseMessageListener](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java)),如[NotificationControllerV2](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java),消息监听器的注册过程参见[ConfigServiceAutoConfiguration](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ConfigServiceAutoConfiguration.java) 4. NotificationControllerV2得到配置发布的AppId+Cluster+Namespace后,会通知对应的客户端 示意图如下: <img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/release-message-design.png" alt="release-message-design" width="400px"> ### 2.1.2 Config Service通知客户端的实现方式 上一节中简要描述了NotificationControllerV2是如何得知有配置发布的,那NotificationControllerV2在得知有配置发布后是如何通知到客户端的呢? 实现方式如下: 1. 客户端会发起一个Http请求到Config Service的`notifications/v2`接口,也就是[NotificationControllerV2](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java),参见[RemoteConfigLongPollService](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java) 2. NotificationControllerV2不会立即返回结果,而是通过[Spring DeferredResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html)把请求挂起 3. 如果在60秒内没有该客户端关心的配置发布,那么会返回Http状态码304给客户端 4. 如果有该客户端关心的配置发布,NotificationControllerV2会调用DeferredResult的[setResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html#setResult-T-)方法,传入有配置变化的namespace信息,同时该请求会立即返回。客户端从返回的结果中获取到配置变化的namespace后,会立即请求Config Service获取该namespace的最新配置。 # 三、客户端设计 ![client-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/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客户端获取最新的配置、订阅配置更新通知 ## 3.1 和Spring集成的原理 Apollo除了支持API方式获取配置,也支持和Spring/Spring Boot集成,集成原理简述如下。 Spring从3.1版本开始增加了`ConfigurableEnvironment`和`PropertySource`: * ConfigurableEnvironment * Spring的ApplicationContext会包含一个Environment(实现ConfigurableEnvironment接口) * ConfigurableEnvironment自身包含了很多个PropertySource * PropertySource * 属性源 * 可以理解为很多个Key - Value的属性配置 在运行时的结构形如: ![Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/environment.png) 需要注意的是,PropertySource之间是有优先级顺序的,如果有一个Key在多个property source中都存在,那么在前面的property source优先。 所以对上图的例子: * env.getProperty(“key1”) -> value1 * **env.getProperty(“key2”) -> value2** * env.getProperty(“key3”) -> value4 在理解了上述原理后,Apollo和Spring/Spring Boot集成的手段就呼之欲出了:在应用启动阶段,Apollo从远端获取配置,然后组装成PropertySource并插入到第一个即可,如下图所示: ![Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/environment-remote-source.png) 相关代码可以参考[PropertySourcesProcessor](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java) # 四、可用性考虑 <table> <thead> <tr> <th width="20%">场景</th> <th width="20%">影响</th> <th width="30%">降级</th> <th width="30%">原因</th> </tr> </thead> <tbody> <tr> <td>某台Config Service下线</td> <td>无影响</td> <td></td> <td>Config Service无状态,客户端重连其它Config Service</td> </tr> <tr> <td>所有Config Service下线</td> <td>客户端无法读取最新配置,Portal无影响</td> <td>客户端重启时,可以读取本地缓存配置文件。如果是新扩容的机器,可以从其它机器上获取已缓存的配置文件,具体信息可以参考<a href='/#/zh/usage/java-sdk-user-guide?id=_123-本地缓存路径'>Java客户端使用指南 - 1.2.3 本地缓存路径</a> </td> <td></td> </tr> <tr> <td>某台Admin Service下线</td> <td>无影响</td> <td></td> <td>Admin Service无状态,Portal重连其它Admin Service</td> </tr> <tr> <td>所有Admin Service下线</td> <td>客户端无影响,Portal无法更新配置</td> <td></td> <td></td> </tr> <tr> <td>某台Portal下线</td> <td>无影响</td> <td></td> <td>Portal域名通过SLB绑定多台服务器,重试后指向可用的服务器</td> </tr> <tr> <td>全部Portal下线</td> <td>客户端无影响,Portal无法更新配置</td> <td></td> <td></td> </tr> <tr> <td>某个数据中心下线</td> <td>无影响</td> <td></td> <td>多数据中心部署,数据完全同步,Meta Server/Portal域名通过SLB自动切换到其它存活的数据中心</td> </tr> <tr> <td>数据库宕机</td> <td>客户端无影响,Portal无法更新配置</td> <td>Config Service开启<a href="/#/zh/deployment/distributed-deployment-guide?id=_323-config-servicecacheenabled-是否开启配置缓存">配置缓存</a>后,对配置的读取不受数据库宕机影响</td> <td></td> </tr> </tbody> </table> # 五、监控相关 ## 5.1 Tracing ### 5.1.1 CAT Apollo客户端和服务端目前支持[CAT](https://github.com/dianping/cat)自动打点,所以如果自己公司内部部署了CAT的话,只要引入cat-client后Apollo就会自动启用CAT打点。 如果不使用CAT的话,也不用担心,只要不引入cat-client,Apollo是不会启用CAT打点的。 Apollo也提供了Tracer相关的SPI,可以方便地对接自己公司的监控系统。 更多信息,可以参考[v0.4.0 Release Note](https://github.com/ctripcorp/apollo/releases/tag/v0.4.0) ### 5.1.2 SkyWalking 可以参考[@hepyu](https://github.com/hepyu)贡献的[apollo-skywalking-pro样例](https://github.com/hepyu/k8s-app-config/tree/master/product/standard/apollo-skywalking-pro)。 ## 5.2 Metrics 从1.5.0版本开始,Apollo服务端支持通过`/prometheus`暴露prometheus格式的metrics,如`http://${someIp:somePort}/prometheus`
# &nbsp; # 一、总体设计 ## 1.1 基础模型 如下即是Apollo的基础模型: 1. 用户在配置中心对配置进行修改并发布 2. 配置中心通知Apollo客户端有配置更新 3. Apollo客户端从配置中心拉取最新的配置、更新本地配置并通知到应用 ![basic-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/basic-architecture.png) ## 1.2 架构模块 下图是Apollo架构模块的概览,详细说明可以参考[Apollo配置中心架构剖析](https://mp.weixin.qq.com/s/-hUaQPzfsl9Lm3IqQW3VDQ)。 ![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进程中 ### 1.2.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 * 最后一点是开源,由于代码是开源的,所以非常便于我们了解它的实现原理和排查问题。 ## 1.3 各模块概要介绍 ### 1.3.1 Config Service * 提供配置获取接口 * 提供配置更新推送接口(基于Http long polling) * 服务端使用[Spring DeferredResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html)实现异步化,从而大大增加长连接数量 * 目前使用的tomcat embed默认配置是最多10000个连接(可以调整),使用了4C8G的虚拟机实测可以支撑10000个连接,所以满足需求(一个应用实例只会发起一个长连接)。 * 接口服务对象为Apollo客户端 ### 1.3.2 Admin Service * 提供配置管理接口 * 提供配置修改、发布等接口 * 接口服务对象为Portal ### 1.3.3 Meta Server * Portal通过域名访问Meta Server获取Admin Service服务列表(IP+Port) * Client通过域名访问Meta Server获取Config Service服务列表(IP+Port) * Meta Server从Eureka获取Config Service和Admin Service的服务信息,相当于是一个Eureka Client * 增设一个Meta Server的角色主要是为了封装服务发现的细节,对Portal和Client而言,永远通过一个Http接口获取Admin Service和Config Service的服务信息,而不需要关心背后实际的服务注册和发现组件 * Meta Server只是一个逻辑角色,在部署时和Config Service是在一个JVM进程中的,所以IP、端口和Config Service一致 ### 1.3.4 Eureka * 基于[Eureka](https://github.com/Netflix/eureka)和[Spring Cloud Netflix](https://cloud.spring.io/spring-cloud-netflix/)提供服务注册和发现 * Config Service和Admin Service会向Eureka注册服务,并保持心跳 * 为了简单起见,目前Eureka在部署时和Config Service是在一个JVM进程中的(通过Spring Cloud Netflix) ### 1.3.5 Portal * 提供Web界面供用户管理配置 * 通过Meta Server获取Admin Service服务列表(IP+Port),通过IP+Port访问服务 * 在Portal侧做load balance、错误重试 ### 1.3.6 Client * Apollo提供的客户端程序,为应用提供配置获取、实时更新等功能 * 通过Meta Server获取Config Service服务列表(IP+Port),通过IP+Port访问服务 * 在Client侧做load balance、错误重试 ## 1.4 E-R Diagram ### 1.4.1 主体E-R Diagram ![apollo-erd](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-erd.png) * **App** * App信息 * **AppNamespace** * App下Namespace的元信息 * **Cluster** * 集群信息 * **Namespace** * 集群下的namespace * **Item** * Namespace的配置,每个Item是一个key, value组合 * **Release** * Namespace发布的配置,每个发布包含发布时该Namespace的所有配置 * **Commit** * Namespace下的配置更改记录 * **Audit** * 审计信息,记录用户在何时使用何种方式操作了哪个实体。 ### 1.4.2 权限相关E-R Diagram ![apollo-erd-role-permission](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-erd-role-permission.png) * **User** * Apollo portal用户 * **UserRole** * 用户和角色的关系 * **Role** * 角色 * **RolePermission** * 角色和权限的关系 * **Permission** * 权限 * 对应到具体的实体资源和操作,如修改NamespaceA的配置,发布NamespaceB的配置等。 * **Consumer** * 第三方应用 * **ConsumerToken** * 发给第三方应用的token * **ConsumerRole** * 第三方应用和角色的关系 * **ConsumerAudit** * 第三方应用访问审计 # 二、服务端设计 ## 2.1 配置发布后的实时推送设计 在配置中心中,一个重要的功能就是配置发布后实时推送到客户端。下面我们简要看一下这块是怎么设计实现的。 ![release-message-notification-design](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/release-message-notification-design.png) 上图简要描述了配置发布的大致过程: 1. 用户在Portal操作配置发布 2. Portal调用Admin Service的接口操作发布 3. Admin Service发布配置后,发送ReleaseMessage给各个Config Service 4. Config Service收到ReleaseMessage后,通知对应的客户端 ### 2.1.1 发送ReleaseMessage的实现方式 Admin Service在配置发布后,需要通知所有的Config Service有配置发布,从而Config Service可以通知对应的客户端来拉取最新的配置。 从概念上来看,这是一个典型的消息使用场景,Admin Service作为producer发出消息,各个Config Service作为consumer消费消息。通过一个消息组件(Message Queue)就能很好的实现Admin Service和Config Service的解耦。 在实现上,考虑到Apollo的实际使用场景,以及为了尽可能减少外部依赖,我们没有采用外部的消息中间件,而是通过数据库实现了一个简单的消息队列。 实现方式如下: 1. Admin Service在配置发布后会往ReleaseMessage表插入一条消息记录,消息内容就是配置发布的AppId+Cluster+Namespace,参见[DatabaseMessageSender](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java) 2. Config Service有一个线程会每秒扫描一次ReleaseMessage表,看看是否有新的消息记录,参见[ReleaseMessageScanner](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java) 3. Config Service如果发现有新的消息记录,那么就会通知到所有的消息监听器([ReleaseMessageListener](https://github.com/ctripcorp/apollo/blob/master/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java)),如[NotificationControllerV2](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java),消息监听器的注册过程参见[ConfigServiceAutoConfiguration](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ConfigServiceAutoConfiguration.java) 4. NotificationControllerV2得到配置发布的AppId+Cluster+Namespace后,会通知对应的客户端 示意图如下: <img src="https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/release-message-design.png" alt="release-message-design" width="400px"> ### 2.1.2 Config Service通知客户端的实现方式 上一节中简要描述了NotificationControllerV2是如何得知有配置发布的,那NotificationControllerV2在得知有配置发布后是如何通知到客户端的呢? 实现方式如下: 1. 客户端会发起一个Http请求到Config Service的`notifications/v2`接口,也就是[NotificationControllerV2](https://github.com/ctripcorp/apollo/blob/master/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java),参见[RemoteConfigLongPollService](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java) 2. NotificationControllerV2不会立即返回结果,而是通过[Spring DeferredResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html)把请求挂起 3. 如果在60秒内没有该客户端关心的配置发布,那么会返回Http状态码304给客户端 4. 如果有该客户端关心的配置发布,NotificationControllerV2会调用DeferredResult的[setResult](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/async/DeferredResult.html#setResult-T-)方法,传入有配置变化的namespace信息,同时该请求会立即返回。客户端从返回的结果中获取到配置变化的namespace后,会立即请求Config Service获取该namespace的最新配置。 # 三、客户端设计 ![client-architecture](https://raw.githubusercontent.com/ctripcorp/apollo/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客户端获取最新的配置、订阅配置更新通知 ## 3.1 和Spring集成的原理 Apollo除了支持API方式获取配置,也支持和Spring/Spring Boot集成,集成原理简述如下。 Spring从3.1版本开始增加了`ConfigurableEnvironment`和`PropertySource`: * ConfigurableEnvironment * Spring的ApplicationContext会包含一个Environment(实现ConfigurableEnvironment接口) * ConfigurableEnvironment自身包含了很多个PropertySource * PropertySource * 属性源 * 可以理解为很多个Key - Value的属性配置 在运行时的结构形如: ![Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/environment.png) 需要注意的是,PropertySource之间是有优先级顺序的,如果有一个Key在多个property source中都存在,那么在前面的property source优先。 所以对上图的例子: * env.getProperty(“key1”) -> value1 * **env.getProperty(“key2”) -> value2** * env.getProperty(“key3”) -> value4 在理解了上述原理后,Apollo和Spring/Spring Boot集成的手段就呼之欲出了:在应用启动阶段,Apollo从远端获取配置,然后组装成PropertySource并插入到第一个即可,如下图所示: ![Overview](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/environment-remote-source.png) 相关代码可以参考[PropertySourcesProcessor](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java) # 四、可用性考虑 <table> <thead> <tr> <th width="20%">场景</th> <th width="20%">影响</th> <th width="30%">降级</th> <th width="30%">原因</th> </tr> </thead> <tbody> <tr> <td>某台Config Service下线</td> <td>无影响</td> <td></td> <td>Config Service无状态,客户端重连其它Config Service</td> </tr> <tr> <td>所有Config Service下线</td> <td>客户端无法读取最新配置,Portal无影响</td> <td>客户端重启时,可以读取本地缓存配置文件。如果是新扩容的机器,可以从其它机器上获取已缓存的配置文件,具体信息可以参考<a href='/#/zh/usage/java-sdk-user-guide?id=_123-本地缓存路径'>Java客户端使用指南 - 1.2.3 本地缓存路径</a> </td> <td></td> </tr> <tr> <td>某台Admin Service下线</td> <td>无影响</td> <td></td> <td>Admin Service无状态,Portal重连其它Admin Service</td> </tr> <tr> <td>所有Admin Service下线</td> <td>客户端无影响,Portal无法更新配置</td> <td></td> <td></td> </tr> <tr> <td>某台Portal下线</td> <td>无影响</td> <td></td> <td>Portal域名通过SLB绑定多台服务器,重试后指向可用的服务器</td> </tr> <tr> <td>全部Portal下线</td> <td>客户端无影响,Portal无法更新配置</td> <td></td> <td></td> </tr> <tr> <td>某个数据中心下线</td> <td>无影响</td> <td></td> <td>多数据中心部署,数据完全同步,Meta Server/Portal域名通过SLB自动切换到其它存活的数据中心</td> </tr> <tr> <td>数据库宕机</td> <td>客户端无影响,Portal无法更新配置</td> <td>Config Service开启<a href="/#/zh/deployment/distributed-deployment-guide?id=_323-config-servicecacheenabled-是否开启配置缓存">配置缓存</a>后,对配置的读取不受数据库宕机影响</td> <td></td> </tr> </tbody> </table> # 五、监控相关 ## 5.1 Tracing ### 5.1.1 CAT Apollo客户端和服务端目前支持[CAT](https://github.com/dianping/cat)自动打点,所以如果自己公司内部部署了CAT的话,只要引入cat-client后Apollo就会自动启用CAT打点。 如果不使用CAT的话,也不用担心,只要不引入cat-client,Apollo是不会启用CAT打点的。 Apollo也提供了Tracer相关的SPI,可以方便地对接自己公司的监控系统。 更多信息,可以参考[v0.4.0 Release Note](https://github.com/ctripcorp/apollo/releases/tag/v0.4.0) ### 5.1.2 SkyWalking 可以参考[@hepyu](https://github.com/hepyu)贡献的[apollo-skywalking-pro样例](https://github.com/hepyu/k8s-app-config/tree/master/product/standard/apollo-skywalking-pro)。 ## 5.2 Metrics 从1.5.0版本开始,Apollo服务端支持通过`/prometheus`暴露prometheus格式的metrics,如`http://${someIp:somePort}/prometheus`
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java
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([email protected]) */ @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; } }
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([email protected]) */ @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,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ConfigServiceApplication.java
package com.ctrip.framework.apollo.configservice; import com.ctrip.framework.apollo.biz.ApolloBizConfig; import com.ctrip.framework.apollo.common.ApolloCommonConfig; import com.ctrip.framework.apollo.metaservice.ApolloMetaServiceConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.PropertySource; import org.springframework.transaction.annotation.EnableTransactionManagement; /** * Spring boot application entry point * * @author Jason Song([email protected]) */ @EnableAspectJAutoProxy @EnableAutoConfiguration @Configuration @EnableTransactionManagement @PropertySource(value = {"classpath:configservice.properties"}) @ComponentScan(basePackageClasses = {ApolloCommonConfig.class, ApolloBizConfig.class, ConfigServiceApplication.class, ApolloMetaServiceConfig.class}) public class ConfigServiceApplication { public static void main(String[] args) throws Exception { SpringApplication.run(ConfigServiceApplication.class, args); } }
package com.ctrip.framework.apollo.configservice; import com.ctrip.framework.apollo.biz.ApolloBizConfig; import com.ctrip.framework.apollo.common.ApolloCommonConfig; import com.ctrip.framework.apollo.metaservice.ApolloMetaServiceConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.PropertySource; import org.springframework.transaction.annotation.EnableTransactionManagement; /** * Spring boot application entry point * * @author Jason Song([email protected]) */ @EnableAspectJAutoProxy @EnableAutoConfiguration @Configuration @EnableTransactionManagement @PropertySource(value = {"classpath:configservice.properties"}) @ComponentScan(basePackageClasses = {ApolloCommonConfig.class, ApolloBizConfig.class, ConfigServiceApplication.class, ApolloMetaServiceConfig.class}) public class ConfigServiceApplication { public static void main(String[] args) throws Exception { SpringApplication.run(ConfigServiceApplication.class, args); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./docs/zh/usage/other-language-client-user-guide.md
目前Apollo团队由于人力所限,只提供了Java和.Net的客户端,对于其它语言的应用,可以通过本文的介绍来直接通过Http接口获取配置。 另外,如果有团队/个人有兴趣的话,也欢迎帮助我们来实现其它语言的客户端,具体细节可以联系@nobodyiam和@lepdou。 >注:目前已有热心用户贡献了Go、Python、NodeJS、PHP、C++的客户端,更多信息可以参考[Go、Python、NodeJS、PHP等客户端使用指南](zh/usage/third-party-sdks-user-guide) ## 1.1 应用接入Apollo 首先需要在Apollo中接入你的应用,具体步骤可以参考[应用接入文档](zh/usage/apollo-user-guide?id=一、普通应用接入指南)。 ## 1.2 通过带缓存的Http接口从Apollo读取配置 该接口会从缓存中获取配置,适合频率较高的配置拉取请求,如简单的每30秒轮询一次配置。 由于缓存最多会有一秒的延时,所以如果需要配合配置推送通知实现实时更新配置的话,请参考[1.3 通过不带缓存的Http接口从Apollo读取配置](#_13-%E9%80%9A%E8%BF%87%E4%B8%8D%E5%B8%A6%E7%BC%93%E5%AD%98%E7%9A%84http%E6%8E%A5%E5%8F%A3%E4%BB%8Eapollo%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE)。 ### 1.2.1 Http接口说明 **URL**: {config_server_url}/configfiles/json/{appId}/{clusterName}/{namespaceName}?ip={clientIp} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | namespaceName | 是 | Namespace的名字 | 如果没有新建过Namespace的话,传入application即可。 如果创建了Namespace,并且需要使用该Namespace的配置,则传入对应的Namespace名字。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | | ip | 否 | 应用部署的机器ip | 这个参数是可选的,用来实现灰度发布。 如果不想传这个参数,请注意URL中从?号开始的query parameters整个都不要出现。 | ### 1.2.2 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码,包含了对应namespace中所有的配置项。 返回内容Sample如下: ```json { "portal.elastic.document.type":"biz", "portal.elastic.cluster.name":"hermes-es-fws" } ``` > 通过`{config_server_url}/configfiles/{appId}/{clusterName}/{namespaceName}?ip={clientIp}`可以获取到properties形式的配置 ### 1.2.3 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.3 通过不带缓存的Http接口从Apollo读取配置 该接口会直接从数据库中获取配置,可以配合配置推送通知实现实时更新配置。 ### 1.3.1 Http接口说明 **URL**: {config_server_url}/configs/{appId}/{clusterName}/{namespaceName}?releaseKey={releaseKey}&ip={clientIp} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | namespaceName | 是 | Namespace的名字 | 如果没有新建过Namespace的话,传入application即可。 如果创建了Namespace,并且需要使用该Namespace的配置,则传入对应的Namespace名字。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | | releaseKey | 否 | 上一次的releaseKey | 将上一次返回对象中的releaseKey传入即可,用来给服务端比较版本,如果版本比下来没有变化,则服务端直接返回304以节省流量和运算 | | ip | 否 | 应用部署的机器ip | 这个参数是可选的,用来实现灰度发布。 | ### 1.3.2 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码。 如果配置没有变化(传入的releaseKey和服务端的相等),则返回HttpStatus 304,response body为空。 如果配置有变化,则会返回HttpStatus 200,response body为对应namespace的meta信息以及其中所有的配置项。 返回内容Sample如下: ```json { "appId": "100004458", "cluster": "default", "namespaceName": "application", "configurations": { "portal.elastic.document.type":"biz", "portal.elastic.cluster.name":"hermes-es-fws" }, "releaseKey": "20170430092936-dee2d58e74515ff3" } ``` ### 1.3.3 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.4 应用感知配置更新 Apollo提供了基于Http long polling的配置更新推送通知,第三方客户端可以看自己实际的需求决定是否需要使用这个功能。 如果对配置更新时间不是那么敏感的话,可以通过定时刷新来感知配置更新,刷新频率可以视应用自身情况来定,建议在30秒以上。 如果需要做到实时感知配置更新(1秒)的话,可以参考下面的文档实现配置更新推送的功能。 ### 1.4.1 配置更新推送实现思路 这里建议大家可以参考Apollo的Java实现:[RemoteConfigLongPollService.java](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java),代码量200多行,总体上还是比较简单的。 #### 1.4.1.1 初始化 首先需要确定哪些namespace需要配置更新推送,Apollo的实现方式是程序第一次获取某个namespace的配置时就会来注册一下,我们就知道有哪些namespace需要配置更新推送了。 初始化后的结果就是得到一个notifications的Map,内容是namespaceName -> notificationId(初始值为-1)。 运行过程中如果发现有新的namespace需要配置更新推送,直接塞到notifications这个Map里面即可。 #### 1.4.1.2 请求服务 有了notifications这个Map之后,就可以请求服务了。这里先描述一下请求服务的逻辑,具体的URL参数和说明请参见后面的接口说明。 1. 请求远端服务,带上自己的应用信息以及notifications信息 2. 服务端针对传过来的每一个namespace和对应的notificationId,检查notificationId是否是最新的 3. 如果都是最新的,则保持住请求60秒,如果60秒内没有配置变化,则返回HttpStatus 304。如果60秒内有配置变化,则返回对应namespace的最新notificationId, HttpStatus 200。 4. 如果传过来的notifications信息中发现有notificationId比服务端老,则直接返回对应namespace的最新notificationId, HttpStatus 200。 5. 客户端拿到服务端返回后,判断返回的HttpStatus 6. 如果返回的HttpStatus是304,说明配置没有变化,重新执行第1步 7. 如果返回的HttpStauts是200,说明配置有变化,针对变化的namespace重新去服务端拉取配置,参见[1.3 通过不带缓存的Http接口从Apollo读取配置](#_13-%E9%80%9A%E8%BF%87%E4%B8%8D%E5%B8%A6%E7%BC%93%E5%AD%98%E7%9A%84http%E6%8E%A5%E5%8F%A3%E4%BB%8Eapollo%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE)。同时更新notifications map中的notificationId。重新执行第1步。 ### 1.4.2 Http接口说明 **URL**: {config_server_url}/notifications/v2?appId={appId}&cluster={clusterName}&notifications={notifications} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | notifications | 是 | notifications信息 | 传入本地的notifications信息,注意这里需要以array形式转为json传入,如:[{"namespaceName": "application", "notificationId": 100}, {"namespaceName": "FX.apollo", "notificationId": 200}]。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | > 注1:由于服务端会hold住请求60秒,所以请确保客户端访问服务端的超时时间要大于60秒。 > 注2:别忘了对参数进行[url encode](https://en.wikipedia.org/wiki/Percent-encoding) ### 1.4.3 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码,包含了有变化的namespace和最新的notificationId。 返回内容Sample如下: ```json [ { "namespaceName": "application", "notificationId": 101 } ] ``` ### 1.4.4 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.5 配置访问密钥 Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端发出请求时需要增加签名,否则无法获取配置。 需要设置的Header信息: | Header | Value | 备注 | |---------------|------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | Authorization | Apollo ${appId}:${signature} | appId: 应用的appId,signature:使用访问密钥对当前时间以及所访问的URL加签后的值,具体实现可以参考[Signature.signature](https://github.com/ctripcorp/apollo/blob/aa184a2e11d6e7e3f519d860d69f3cf30ccfcf9c/apollo-core/src/main/java/com/ctrip/framework/apollo/core/signature/Signature.java#L22) | | Timestamp | 从`1970-1-1 00:00:00 UTC+0`到现在所经过的毫秒数 | 可以参考[System.currentTimeMillis](https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis()) | ## 1.6 错误码说明 正常情况下,接口返回的Http状态码是200,下面列举了Apollo会返回的非200错误码说明。 ### 1.6.1 400 - Bad Request 客户端传入参数的错误,如必选参数没有传入等,客户端需要根据提示信息检查对应的参数是否正确。 ### 1.6.2 401 - Unauthorized 客户端未授权,如服务端配置了访问密钥,客户端未配置或配置错误。 ### 1.6.3 404 - Not Found 接口要访问的资源不存在,一般是URL或URL的参数错误,或者是对应的namespace还没有发布过配置。 ### 1.6.4 405 - Method Not Allowed 接口访问的Method不正确,比如应该使用GET的接口使用了POST访问等,客户端需要检查接口访问方式是否正确。 ### 1.6.5 500 - Internal Server Error 其它类型的错误默认都会返回500,对这类错误如果应用无法根据提示信息找到原因的话,可以尝试查看服务端日志来排查问题。
目前Apollo团队由于人力所限,只提供了Java和.Net的客户端,对于其它语言的应用,可以通过本文的介绍来直接通过Http接口获取配置。 另外,如果有团队/个人有兴趣的话,也欢迎帮助我们来实现其它语言的客户端,具体细节可以联系@nobodyiam和@lepdou。 >注:目前已有热心用户贡献了Go、Python、NodeJS、PHP、C++的客户端,更多信息可以参考[Go、Python、NodeJS、PHP等客户端使用指南](zh/usage/third-party-sdks-user-guide) ## 1.1 应用接入Apollo 首先需要在Apollo中接入你的应用,具体步骤可以参考[应用接入文档](zh/usage/apollo-user-guide?id=一、普通应用接入指南)。 ## 1.2 通过带缓存的Http接口从Apollo读取配置 该接口会从缓存中获取配置,适合频率较高的配置拉取请求,如简单的每30秒轮询一次配置。 由于缓存最多会有一秒的延时,所以如果需要配合配置推送通知实现实时更新配置的话,请参考[1.3 通过不带缓存的Http接口从Apollo读取配置](#_13-%E9%80%9A%E8%BF%87%E4%B8%8D%E5%B8%A6%E7%BC%93%E5%AD%98%E7%9A%84http%E6%8E%A5%E5%8F%A3%E4%BB%8Eapollo%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE)。 ### 1.2.1 Http接口说明 **URL**: {config_server_url}/configfiles/json/{appId}/{clusterName}/{namespaceName}?ip={clientIp} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | namespaceName | 是 | Namespace的名字 | 如果没有新建过Namespace的话,传入application即可。 如果创建了Namespace,并且需要使用该Namespace的配置,则传入对应的Namespace名字。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | | ip | 否 | 应用部署的机器ip | 这个参数是可选的,用来实现灰度发布。 如果不想传这个参数,请注意URL中从?号开始的query parameters整个都不要出现。 | ### 1.2.2 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码,包含了对应namespace中所有的配置项。 返回内容Sample如下: ```json { "portal.elastic.document.type":"biz", "portal.elastic.cluster.name":"hermes-es-fws" } ``` > 通过`{config_server_url}/configfiles/{appId}/{clusterName}/{namespaceName}?ip={clientIp}`可以获取到properties形式的配置 ### 1.2.3 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.3 通过不带缓存的Http接口从Apollo读取配置 该接口会直接从数据库中获取配置,可以配合配置推送通知实现实时更新配置。 ### 1.3.1 Http接口说明 **URL**: {config_server_url}/configs/{appId}/{clusterName}/{namespaceName}?releaseKey={releaseKey}&ip={clientIp} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | namespaceName | 是 | Namespace的名字 | 如果没有新建过Namespace的话,传入application即可。 如果创建了Namespace,并且需要使用该Namespace的配置,则传入对应的Namespace名字。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | | releaseKey | 否 | 上一次的releaseKey | 将上一次返回对象中的releaseKey传入即可,用来给服务端比较版本,如果版本比下来没有变化,则服务端直接返回304以节省流量和运算 | | ip | 否 | 应用部署的机器ip | 这个参数是可选的,用来实现灰度发布。 | ### 1.3.2 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码。 如果配置没有变化(传入的releaseKey和服务端的相等),则返回HttpStatus 304,response body为空。 如果配置有变化,则会返回HttpStatus 200,response body为对应namespace的meta信息以及其中所有的配置项。 返回内容Sample如下: ```json { "appId": "100004458", "cluster": "default", "namespaceName": "application", "configurations": { "portal.elastic.document.type":"biz", "portal.elastic.cluster.name":"hermes-es-fws" }, "releaseKey": "20170430092936-dee2d58e74515ff3" } ``` ### 1.3.3 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.4 应用感知配置更新 Apollo提供了基于Http long polling的配置更新推送通知,第三方客户端可以看自己实际的需求决定是否需要使用这个功能。 如果对配置更新时间不是那么敏感的话,可以通过定时刷新来感知配置更新,刷新频率可以视应用自身情况来定,建议在30秒以上。 如果需要做到实时感知配置更新(1秒)的话,可以参考下面的文档实现配置更新推送的功能。 ### 1.4.1 配置更新推送实现思路 这里建议大家可以参考Apollo的Java实现:[RemoteConfigLongPollService.java](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java),代码量200多行,总体上还是比较简单的。 #### 1.4.1.1 初始化 首先需要确定哪些namespace需要配置更新推送,Apollo的实现方式是程序第一次获取某个namespace的配置时就会来注册一下,我们就知道有哪些namespace需要配置更新推送了。 初始化后的结果就是得到一个notifications的Map,内容是namespaceName -> notificationId(初始值为-1)。 运行过程中如果发现有新的namespace需要配置更新推送,直接塞到notifications这个Map里面即可。 #### 1.4.1.2 请求服务 有了notifications这个Map之后,就可以请求服务了。这里先描述一下请求服务的逻辑,具体的URL参数和说明请参见后面的接口说明。 1. 请求远端服务,带上自己的应用信息以及notifications信息 2. 服务端针对传过来的每一个namespace和对应的notificationId,检查notificationId是否是最新的 3. 如果都是最新的,则保持住请求60秒,如果60秒内没有配置变化,则返回HttpStatus 304。如果60秒内有配置变化,则返回对应namespace的最新notificationId, HttpStatus 200。 4. 如果传过来的notifications信息中发现有notificationId比服务端老,则直接返回对应namespace的最新notificationId, HttpStatus 200。 5. 客户端拿到服务端返回后,判断返回的HttpStatus 6. 如果返回的HttpStatus是304,说明配置没有变化,重新执行第1步 7. 如果返回的HttpStauts是200,说明配置有变化,针对变化的namespace重新去服务端拉取配置,参见[1.3 通过不带缓存的Http接口从Apollo读取配置](#_13-%E9%80%9A%E8%BF%87%E4%B8%8D%E5%B8%A6%E7%BC%93%E5%AD%98%E7%9A%84http%E6%8E%A5%E5%8F%A3%E4%BB%8Eapollo%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE)。同时更新notifications map中的notificationId。重新执行第1步。 ### 1.4.2 Http接口说明 **URL**: {config_server_url}/notifications/v2?appId={appId}&cluster={clusterName}&notifications={notifications} **Method**: GET **参数说明**: | 参数名 | 是否必须 | 参数值 | 备注 | |-------------------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | config_server_url | 是 | Apollo配置服务的地址 | | | appId | 是 | 应用的appId | | | clusterName | 是 | 集群名 | 一般情况下传入 default 即可。 如果希望配置按集群划分,可以参考[集群独立配置说明](zh/usage/apollo-user-guide?id=三、集群独立配置说明)做相关配置,然后在这里填入对应的集群名。 | | notifications | 是 | notifications信息 | 传入本地的notifications信息,注意这里需要以array形式转为json传入,如:[{"namespaceName": "application", "notificationId": 100}, {"namespaceName": "FX.apollo", "notificationId": 200}]。**需要注意的是对于properties类型的namespace,只需要传入namespace的名字即可,如application。对于其它类型的namespace,需要传入namespace的名字加上后缀名,如datasources.json** | > 注1:由于服务端会hold住请求60秒,所以请确保客户端访问服务端的超时时间要大于60秒。 > 注2:别忘了对参数进行[url encode](https://en.wikipedia.org/wiki/Percent-encoding) ### 1.4.3 Http接口返回格式 该Http接口返回的是JSON格式、UTF-8编码,包含了有变化的namespace和最新的notificationId。 返回内容Sample如下: ```json [ { "namespaceName": "application", "notificationId": 101 } ] ``` ### 1.4.4 测试 由于是Http接口,所以在URL组装OK之后,直接通过浏览器、或者相关的http接口测试工具访问即可。 ## 1.5 配置访问密钥 Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端发出请求时需要增加签名,否则无法获取配置。 需要设置的Header信息: | Header | Value | 备注 | |---------------|------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | Authorization | Apollo ${appId}:${signature} | appId: 应用的appId,signature:使用访问密钥对当前时间以及所访问的URL加签后的值,具体实现可以参考[Signature.signature](https://github.com/ctripcorp/apollo/blob/aa184a2e11d6e7e3f519d860d69f3cf30ccfcf9c/apollo-core/src/main/java/com/ctrip/framework/apollo/core/signature/Signature.java#L22) | | Timestamp | 从`1970-1-1 00:00:00 UTC+0`到现在所经过的毫秒数 | 可以参考[System.currentTimeMillis](https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis()) | ## 1.6 错误码说明 正常情况下,接口返回的Http状态码是200,下面列举了Apollo会返回的非200错误码说明。 ### 1.6.1 400 - Bad Request 客户端传入参数的错误,如必选参数没有传入等,客户端需要根据提示信息检查对应的参数是否正确。 ### 1.6.2 401 - Unauthorized 客户端未授权,如服务端配置了访问密钥,客户端未配置或配置错误。 ### 1.6.3 404 - Not Found 接口要访问的资源不存在,一般是URL或URL的参数错误,或者是对应的namespace还没有发布过配置。 ### 1.6.4 405 - Method Not Allowed 接口访问的Method不正确,比如应该使用GET的接口使用了POST访问等,客户端需要检查接口访问方式是否正确。 ### 1.6.5 500 - Internal Server Error 其它类型的错误默认都会返回500,对这类错误如果应用无法根据提示信息找到原因的话,可以尝试查看服务端日志来排查问题。
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/ConfigPropertySourcesProcessorHelper.java
package com.ctrip.framework.apollo.spring.spi; import com.ctrip.framework.apollo.core.spi.Ordered; import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.BeanDefinitionRegistry; public interface ConfigPropertySourcesProcessorHelper extends Ordered { void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException; }
package com.ctrip.framework.apollo.spring.spi; import com.ctrip.framework.apollo.core.spi.Ordered; import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.BeanDefinitionRegistry; public interface ConfigPropertySourcesProcessorHelper extends Ordered { void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException; }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java
package com.ctrip.framework.apollo.biz.message; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; /** * @author Jason Song([email protected]) */ public interface ReleaseMessageListener { void handleMessage(ReleaseMessage message, String channel); }
package com.ctrip.framework.apollo.biz.message; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; /** * @author Jason Song([email protected]) */ public interface ReleaseMessageListener { void handleMessage(ReleaseMessage message, String channel); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseMessageKeyGenerator.java
package com.ctrip.framework.apollo.biz.utils; import com.google.common.base.Joiner; import com.ctrip.framework.apollo.core.ConfigConsts; public class ReleaseMessageKeyGenerator { private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); public static String generate(String appId, String cluster, String namespace) { return STRING_JOINER.join(appId, cluster, namespace); } }
package com.ctrip.framework.apollo.biz.utils; import com.google.common.base.Joiner; import com.ctrip.framework.apollo.core.ConfigConsts; public class ReleaseMessageKeyGenerator { private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); public static String generate(String appId, String cluster, String namespace) { return STRING_JOINER.join(appId, cluster, namespace); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/DefaultConfigService.java
package com.ctrip.framework.apollo.configservice.service.config; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.service.ReleaseService; import com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages; import org.springframework.beans.factory.annotation.Autowired; /** * config service with no cache * * @author Jason Song([email protected]) */ public class DefaultConfigService extends AbstractConfigService { @Autowired private ReleaseService releaseService; @Override protected Release findActiveOne(long id, ApolloNotificationMessages clientMessages) { return releaseService.findActiveOne(id); } @Override protected Release findLatestActiveRelease(String configAppId, String configClusterName, String configNamespace, ApolloNotificationMessages clientMessages) { return releaseService.findLatestActiveRelease(configAppId, configClusterName, configNamespace); } @Override public void handleMessage(ReleaseMessage message, String channel) { // since there is no cache, so do nothing } }
package com.ctrip.framework.apollo.configservice.service.config; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.ReleaseMessage; import com.ctrip.framework.apollo.biz.service.ReleaseService; import com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages; import org.springframework.beans.factory.annotation.Autowired; /** * config service with no cache * * @author Jason Song([email protected]) */ public class DefaultConfigService extends AbstractConfigService { @Autowired private ReleaseService releaseService; @Override protected Release findActiveOne(long id, ApolloNotificationMessages clientMessages) { return releaseService.findActiveOne(id); } @Override protected Release findLatestActiveRelease(String configAppId, String configClusterName, String configNamespace, ApolloNotificationMessages clientMessages) { return releaseService.findLatestActiveRelease(configAppId, configClusterName, configNamespace); } @Override public void handleMessage(ReleaseMessage message, String channel) { // since there is no cache, so do nothing } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java
package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.openapi.dto.OpenAppNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent; import com.ctrip.framework.apollo.portal.service.AppNamespaceService; import com.ctrip.framework.apollo.portal.service.NamespaceLockService; import com.ctrip.framework.apollo.portal.service.NamespaceService; import com.ctrip.framework.apollo.portal.spi.UserService; import org.springframework.context.ApplicationEventPublisher; 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; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Objects; @RestController("openapiNamespaceController") public class NamespaceController { private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final AppNamespaceService appNamespaceService; private final ApplicationEventPublisher publisher; private final UserService userService; public NamespaceController( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final AppNamespaceService appNamespaceService, final ApplicationEventPublisher publisher, final UserService userService) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.appNamespaceService = appNamespaceService; this.publisher = publisher; this.userService = userService; } @PreAuthorize(value = "@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)") @PostMapping(value = "/openapi/v1/apps/{appId}/appnamespaces") public OpenAppNamespaceDTO createNamespace(@PathVariable String appId, @RequestBody OpenAppNamespaceDTO appNamespaceDTO, HttpServletRequest request) { if (!Objects.equals(appId, appNamespaceDTO.getAppId())) { throw new BadRequestException(String.format("AppId not equal. AppId in path = %s, AppId in payload = %s", appId, appNamespaceDTO.getAppId())); } RequestPrecondition.checkArgumentsNotEmpty(appNamespaceDTO.getAppId(), appNamespaceDTO.getName(), appNamespaceDTO.getFormat(), appNamespaceDTO.getDataChangeCreatedBy()); if (!InputValidator.isValidAppNamespace(appNamespaceDTO.getName())) { throw new BadRequestException(String.format("Invalid Namespace format: %s", InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & " + InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE)); } if (!ConfigFileFormat.isValidFormat(appNamespaceDTO.getFormat())) { throw new BadRequestException(String.format("Invalid namespace format. format = %s", appNamespaceDTO.getFormat())); } String operator = appNamespaceDTO.getDataChangeCreatedBy(); if (userService.findByUserId(operator) == null) { throw new BadRequestException(String.format("Illegal user. user = %s", operator)); } AppNamespace appNamespace = OpenApiBeanUtils.transformToAppNamespace(appNamespaceDTO); AppNamespace createdAppNamespace = appNamespaceService.createAppNamespaceInLocal(appNamespace, appNamespaceDTO.isAppendNamespacePrefix()); publisher.publishEvent(new AppNamespaceCreationEvent(createdAppNamespace)); return OpenApiBeanUtils.transformToOpenAppNamespaceDTO(createdAppNamespace); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces") public List<OpenNamespaceDTO> findNamespaces(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName) { return OpenApiBeanUtils .batchTransformFromNamespaceBOs(namespaceService.findNamespaceBOs(appId, Env .valueOf(env), clusterName)); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}") public OpenNamespaceDTO loadNamespace(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { NamespaceBO namespaceBO = namespaceService.loadNamespaceBO(appId, Env.valueOf (env), clusterName, namespaceName); if (namespaceBO == null) { return null; } return OpenApiBeanUtils.transformFromNamespaceBO(namespaceBO); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock") public OpenNamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { NamespaceDTO namespace = namespaceService.loadNamespaceBaseInfo(appId, Env .valueOf(env), clusterName, namespaceName); NamespaceLockDTO lockDTO = namespaceLockService.getNamespaceLock(appId, Env .valueOf(env), clusterName, namespaceName); return OpenApiBeanUtils.transformFromNamespaceLockDTO(namespace.getNamespaceName(), lockDTO); } }
package com.ctrip.framework.apollo.openapi.v1.controller; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.openapi.dto.OpenAppNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO; import com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO; import com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent; import com.ctrip.framework.apollo.portal.service.AppNamespaceService; import com.ctrip.framework.apollo.portal.service.NamespaceLockService; import com.ctrip.framework.apollo.portal.service.NamespaceService; import com.ctrip.framework.apollo.portal.spi.UserService; import org.springframework.context.ApplicationEventPublisher; 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; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Objects; @RestController("openapiNamespaceController") public class NamespaceController { private final NamespaceLockService namespaceLockService; private final NamespaceService namespaceService; private final AppNamespaceService appNamespaceService; private final ApplicationEventPublisher publisher; private final UserService userService; public NamespaceController( final NamespaceLockService namespaceLockService, final NamespaceService namespaceService, final AppNamespaceService appNamespaceService, final ApplicationEventPublisher publisher, final UserService userService) { this.namespaceLockService = namespaceLockService; this.namespaceService = namespaceService; this.appNamespaceService = appNamespaceService; this.publisher = publisher; this.userService = userService; } @PreAuthorize(value = "@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)") @PostMapping(value = "/openapi/v1/apps/{appId}/appnamespaces") public OpenAppNamespaceDTO createNamespace(@PathVariable String appId, @RequestBody OpenAppNamespaceDTO appNamespaceDTO, HttpServletRequest request) { if (!Objects.equals(appId, appNamespaceDTO.getAppId())) { throw new BadRequestException(String.format("AppId not equal. AppId in path = %s, AppId in payload = %s", appId, appNamespaceDTO.getAppId())); } RequestPrecondition.checkArgumentsNotEmpty(appNamespaceDTO.getAppId(), appNamespaceDTO.getName(), appNamespaceDTO.getFormat(), appNamespaceDTO.getDataChangeCreatedBy()); if (!InputValidator.isValidAppNamespace(appNamespaceDTO.getName())) { throw new BadRequestException(String.format("Invalid Namespace format: %s", InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & " + InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE)); } if (!ConfigFileFormat.isValidFormat(appNamespaceDTO.getFormat())) { throw new BadRequestException(String.format("Invalid namespace format. format = %s", appNamespaceDTO.getFormat())); } String operator = appNamespaceDTO.getDataChangeCreatedBy(); if (userService.findByUserId(operator) == null) { throw new BadRequestException(String.format("Illegal user. user = %s", operator)); } AppNamespace appNamespace = OpenApiBeanUtils.transformToAppNamespace(appNamespaceDTO); AppNamespace createdAppNamespace = appNamespaceService.createAppNamespaceInLocal(appNamespace, appNamespaceDTO.isAppendNamespacePrefix()); publisher.publishEvent(new AppNamespaceCreationEvent(createdAppNamespace)); return OpenApiBeanUtils.transformToOpenAppNamespaceDTO(createdAppNamespace); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces") public List<OpenNamespaceDTO> findNamespaces(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName) { return OpenApiBeanUtils .batchTransformFromNamespaceBOs(namespaceService.findNamespaceBOs(appId, Env .valueOf(env), clusterName)); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}") public OpenNamespaceDTO loadNamespace(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { NamespaceBO namespaceBO = namespaceService.loadNamespaceBO(appId, Env.valueOf (env), clusterName, namespaceName); if (namespaceBO == null) { return null; } return OpenApiBeanUtils.transformFromNamespaceBO(namespaceBO); } @GetMapping(value = "/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock") public OpenNamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { NamespaceDTO namespace = namespaceService.loadNamespaceBaseInfo(appId, Env .valueOf(env), clusterName, namespaceName); NamespaceLockDTO lockDTO = namespaceLockService.getNamespaceLock(appId, Env .valueOf(env), clusterName, namespaceName); return OpenApiBeanUtils.transformFromNamespaceLockDTO(namespace.getNamespaceName(), lockDTO); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceLockTest.java
package com.ctrip.framework.apollo.adminservice.aop; 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.ItemService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.dao.DataIntegrityViolationException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class NamespaceLockTest { private static final String APP = "app-test"; private static final String CLUSTER = "cluster-test"; private static final String NAMESPACE = "namespace-test"; private static final String CURRENT_USER = "user-test"; private static final String ANOTHER_USER = "user-test2"; private static final long NAMESPACE_ID = 100; @Mock private NamespaceLockService namespaceLockService; @Mock private NamespaceService namespaceService; @Mock private ItemService itemService; @Mock private BizConfig bizConfig; @InjectMocks NamespaceAcquireLockAspect namespaceLockAspect; @Test public void acquireLockWithNotLockedAndSwitchON() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(true); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(namespaceService, times(0)).findOne(APP, CLUSTER, NAMESPACE); } @Test public void acquireLockWithNotLockedAndSwitchOFF() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(anyLong())).thenReturn(null); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(anyLong()); verify(namespaceLockService).tryLock(any()); } @Test(expected = BadRequestException.class) public void acquireLockWithAlreadyLockedByOtherGuy() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(mockNamespaceLock(ANOTHER_USER)); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(NAMESPACE_ID); } @Test public void acquireLockWithAlreadyLockedBySelf() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(mockNamespaceLock(CURRENT_USER)); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(NAMESPACE_ID); } @Test public void acquireLockWithNamespaceIdSwitchOn(){ when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(NAMESPACE_ID)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(null); namespaceLockAspect.acquireLock(NAMESPACE_ID, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(NAMESPACE_ID); verify(namespaceLockService).findLock(NAMESPACE_ID); verify(namespaceLockService).tryLock(any()); } @Test(expected = ServiceException.class) public void testDuplicateLock(){ when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(NAMESPACE_ID)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(null); when(namespaceLockService.tryLock(any())).thenThrow(DataIntegrityViolationException.class); namespaceLockAspect.acquireLock(NAMESPACE_ID, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(NAMESPACE_ID); verify(namespaceLockService, times(2)).findLock(NAMESPACE_ID); verify(namespaceLockService).tryLock(any()); } private Namespace mockNamespace() { Namespace namespace = new Namespace(); namespace.setId(NAMESPACE_ID); namespace.setAppId(APP); namespace.setClusterName(CLUSTER); namespace.setNamespaceName(NAMESPACE); return namespace; } private NamespaceLock mockNamespaceLock(String locedUser) { NamespaceLock lock = new NamespaceLock(); lock.setNamespaceId(NAMESPACE_ID); lock.setDataChangeCreatedBy(locedUser); return lock; } }
package com.ctrip.framework.apollo.adminservice.aop; 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.ItemService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.ServiceException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.dao.DataIntegrityViolationException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class NamespaceLockTest { private static final String APP = "app-test"; private static final String CLUSTER = "cluster-test"; private static final String NAMESPACE = "namespace-test"; private static final String CURRENT_USER = "user-test"; private static final String ANOTHER_USER = "user-test2"; private static final long NAMESPACE_ID = 100; @Mock private NamespaceLockService namespaceLockService; @Mock private NamespaceService namespaceService; @Mock private ItemService itemService; @Mock private BizConfig bizConfig; @InjectMocks NamespaceAcquireLockAspect namespaceLockAspect; @Test public void acquireLockWithNotLockedAndSwitchON() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(true); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(namespaceService, times(0)).findOne(APP, CLUSTER, NAMESPACE); } @Test public void acquireLockWithNotLockedAndSwitchOFF() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(anyLong())).thenReturn(null); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(anyLong()); verify(namespaceLockService).tryLock(any()); } @Test(expected = BadRequestException.class) public void acquireLockWithAlreadyLockedByOtherGuy() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(mockNamespaceLock(ANOTHER_USER)); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(NAMESPACE_ID); } @Test public void acquireLockWithAlreadyLockedBySelf() { when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(APP, CLUSTER, NAMESPACE)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(mockNamespaceLock(CURRENT_USER)); namespaceLockAspect.acquireLock(APP, CLUSTER, NAMESPACE, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(APP, CLUSTER, NAMESPACE); verify(namespaceLockService).findLock(NAMESPACE_ID); } @Test public void acquireLockWithNamespaceIdSwitchOn(){ when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(NAMESPACE_ID)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(null); namespaceLockAspect.acquireLock(NAMESPACE_ID, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(NAMESPACE_ID); verify(namespaceLockService).findLock(NAMESPACE_ID); verify(namespaceLockService).tryLock(any()); } @Test(expected = ServiceException.class) public void testDuplicateLock(){ when(bizConfig.isNamespaceLockSwitchOff()).thenReturn(false); when(namespaceService.findOne(NAMESPACE_ID)).thenReturn(mockNamespace()); when(namespaceLockService.findLock(NAMESPACE_ID)).thenReturn(null); when(namespaceLockService.tryLock(any())).thenThrow(DataIntegrityViolationException.class); namespaceLockAspect.acquireLock(NAMESPACE_ID, CURRENT_USER); verify(bizConfig).isNamespaceLockSwitchOff(); verify(namespaceService).findOne(NAMESPACE_ID); verify(namespaceLockService, times(2)).findLock(NAMESPACE_ID); verify(namespaceLockService).tryLock(any()); } private Namespace mockNamespace() { Namespace namespace = new Namespace(); namespace.setId(NAMESPACE_ID); namespace.setAppId(APP); namespace.setClusterName(CLUSTER); namespace.setNamespaceName(NAMESPACE); return namespace; } private NamespaceLock mockNamespaceLock(String locedUser) { NamespaceLock lock = new NamespaceLock(); lock.setNamespaceId(NAMESPACE_ID); lock.setDataChangeCreatedBy(locedUser); return lock; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java
package com.ctrip.framework.apollo.internals; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.PropertiesCompatibleConfigFile; import com.ctrip.framework.apollo.enums.ConfigSourceType; import com.ctrip.framework.apollo.model.ConfigFileChangeEvent; import java.util.Properties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PropertiesCompatibleFileConfigRepositoryTest { @Mock private PropertiesCompatibleConfigFile configFile; private String someNamespaceName; @Mock private Properties someProperties; @Before public void setUp() throws Exception { someNamespaceName = "someNamespaceName"; when(configFile.getNamespace()).thenReturn(someNamespaceName); when(configFile.asProperties()).thenReturn(someProperties); } @Test public void testGetConfig() throws Exception { PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); assertSame(someProperties, configFileRepository.getConfig()); verify(configFile, times(1)).addChangeListener(configFileRepository); } @Test public void testGetConfigFailedAndThenRecovered() throws Exception { RuntimeException someException = new RuntimeException("some exception"); when(configFile.asProperties()).thenThrow(someException); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); Throwable exceptionThrown = null; try { configFileRepository.getConfig(); } catch (Throwable ex) { exceptionThrown = ex; } assertSame(someException, exceptionThrown); // recovered reset(configFile); Properties someProperties = mock(Properties.class); when(configFile.asProperties()).thenReturn(someProperties); assertSame(someProperties, configFileRepository.getConfig()); } @Test(expected = IllegalStateException.class) public void testGetConfigWithConfigFileReturnNullProperties() throws Exception { when(configFile.asProperties()).thenReturn(null); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); configFileRepository.getConfig(); } @Test public void testGetSourceType() throws Exception { ConfigSourceType someType = ConfigSourceType.REMOTE; when(configFile.getSourceType()).thenReturn(someType); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); assertSame(someType, configFileRepository.getSourceType()); } @Test public void testOnChange() throws Exception { Properties anotherProperties = mock(Properties.class); ConfigFileChangeEvent someChangeEvent = mock(ConfigFileChangeEvent.class); RepositoryChangeListener someListener = mock(RepositoryChangeListener.class); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); configFileRepository.addChangeListener(someListener); assertSame(someProperties, configFileRepository.getConfig()); when(configFile.asProperties()).thenReturn(anotherProperties); configFileRepository.onChange(someChangeEvent); assertSame(anotherProperties, configFileRepository.getConfig()); verify(someListener, times(1)).onRepositoryChange(someNamespaceName, anotherProperties); } }
package com.ctrip.framework.apollo.internals; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.PropertiesCompatibleConfigFile; import com.ctrip.framework.apollo.enums.ConfigSourceType; import com.ctrip.framework.apollo.model.ConfigFileChangeEvent; import java.util.Properties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PropertiesCompatibleFileConfigRepositoryTest { @Mock private PropertiesCompatibleConfigFile configFile; private String someNamespaceName; @Mock private Properties someProperties; @Before public void setUp() throws Exception { someNamespaceName = "someNamespaceName"; when(configFile.getNamespace()).thenReturn(someNamespaceName); when(configFile.asProperties()).thenReturn(someProperties); } @Test public void testGetConfig() throws Exception { PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); assertSame(someProperties, configFileRepository.getConfig()); verify(configFile, times(1)).addChangeListener(configFileRepository); } @Test public void testGetConfigFailedAndThenRecovered() throws Exception { RuntimeException someException = new RuntimeException("some exception"); when(configFile.asProperties()).thenThrow(someException); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); Throwable exceptionThrown = null; try { configFileRepository.getConfig(); } catch (Throwable ex) { exceptionThrown = ex; } assertSame(someException, exceptionThrown); // recovered reset(configFile); Properties someProperties = mock(Properties.class); when(configFile.asProperties()).thenReturn(someProperties); assertSame(someProperties, configFileRepository.getConfig()); } @Test(expected = IllegalStateException.class) public void testGetConfigWithConfigFileReturnNullProperties() throws Exception { when(configFile.asProperties()).thenReturn(null); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); configFileRepository.getConfig(); } @Test public void testGetSourceType() throws Exception { ConfigSourceType someType = ConfigSourceType.REMOTE; when(configFile.getSourceType()).thenReturn(someType); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); assertSame(someType, configFileRepository.getSourceType()); } @Test public void testOnChange() throws Exception { Properties anotherProperties = mock(Properties.class); ConfigFileChangeEvent someChangeEvent = mock(ConfigFileChangeEvent.class); RepositoryChangeListener someListener = mock(RepositoryChangeListener.class); PropertiesCompatibleFileConfigRepository configFileRepository = new PropertiesCompatibleFileConfigRepository( configFile); configFileRepository.addChangeListener(someListener); assertSame(someProperties, configFileRepository.getConfig()); when(configFile.asProperties()).thenReturn(anotherProperties); configFileRepository.onChange(someChangeEvent); assertSame(anotherProperties, configFileRepository.getConfig()); verify(someListener, times(1)).onRepositoryChange(someNamespaceName, anotherProperties); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserServiceTest.java
package com.ctrip.framework.apollo.portal.spi.ctrip; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.ctrip.framework.apollo.portal.AbstractUnitTest; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; /** * @author Jason Song([email protected]) */ public class CtripUserServiceTest extends AbstractUnitTest{ private CtripUserService ctripUserService; private String someUserServiceUrl; private String someUserServiceToken; private ParameterizedTypeReference<Map<String, List<CtripUserService.UserServiceResponse>>> someResponseType; @Mock private PortalConfig portalConfig; @Mock private RestTemplate restTemplate; @Before public void setUp() throws Exception { when(portalConfig.connectTimeout()).thenReturn(3000); when(portalConfig.readTimeout()).thenReturn(3000); ctripUserService = new CtripUserService(portalConfig); ReflectionTestUtils.setField(ctripUserService, "restTemplate", restTemplate); someResponseType = (ParameterizedTypeReference<Map<String, List<CtripUserService.UserServiceResponse>>>) ReflectionTestUtils .getField(ctripUserService, "responseType"); someUserServiceUrl = "http://someurl"; someUserServiceToken = "someToken"; when(portalConfig.userServiceUrl()).thenReturn(someUserServiceUrl); when(portalConfig.userServiceAccessToken()).thenReturn(someUserServiceToken); } @Test public void testAssembleSearchUserRequest() throws Exception { String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; CtripUserService.UserServiceRequest request = ctripUserService.assembleSearchUserRequest(someKeyword, someOffset, someLimit); assertEquals(someUserServiceToken, request.getAccess_token()); CtripUserService.UserServiceRequestBody requestBody = request.getRequest_body(); assertEquals("itdb_emloyee", requestBody.getIndexAlias()); Map<String, Object> queryJson = requestBody.getQueryJson(); assertEquals(someOffset, queryJson.get("from")); assertEquals(someLimit, queryJson.get("size")); Map<String, Object> query = (Map<String, Object>) queryJson.get("query"); Map<String, Object> multiMatchMap = (Map<String, Object>) query.get("multi_match"); assertEquals(someKeyword, multiMatchMap.get("query")); } @Test public void testAssembleFindUserRequest() throws Exception { String someUserId = "someUser"; String anotherUserId = "anotherUser"; List<String> userIds = Lists.newArrayList(someUserId, anotherUserId); CtripUserService.UserServiceRequest request = ctripUserService.assembleFindUserRequest(userIds); assertEquals(someUserServiceToken, request.getAccess_token()); CtripUserService.UserServiceRequestBody requestBody = request.getRequest_body(); assertEquals("itdb_emloyee", requestBody.getIndexAlias()); Map<String, Object> queryJson = requestBody.getQueryJson(); assertEquals(0, queryJson.get("from")); assertEquals(2, queryJson.get("size")); Map<String, Object> query = (Map<String, Object>) queryJson.get("query"); Map<String, Object> terms = getMapFromMap(getMapFromMap(getMapFromMap(query, "filtered"), "filter"), "terms"); List<String> userIdTerms = (List<String>) terms.get("empaccount"); assertTrue(userIdTerms.containsAll(userIds)); } private Map<String, Object> getMapFromMap(Map<String, Object> map, String key) { return (Map<String, Object>) map.get(key); } @Test public void testSearchUsers() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; String anotherUserId = "anotherUserId"; String anotherName = "anotherName"; String anotherEmail = "anotherEmail"; String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); CtripUserService.UserServiceResponse anotherUserResponse = assembleUserServiceResponse(anotherUserId, anotherName, anotherEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse, anotherUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); List<UserInfo> users = ctripUserService.searchUsers(someKeyword, someOffset, someLimit); assertEquals(2, users.size()); compareUserInfoAndUserServiceResponse(someUserResponse, users.get(0)); compareUserInfoAndUserServiceResponse(anotherUserResponse, users.get(1)); } @Test(expected = HttpClientErrorException.class) public void testSearchUsersWithError() throws Exception { when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; ctripUserService.searchUsers(someKeyword, someOffset, someLimit); } @Test public void testFindByUserId() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); UserInfo user = ctripUserService.findByUserId(someUserId); compareUserInfoAndUserServiceResponse(someUserResponse, user); } @Test public void testFindByUserIds() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; String anotherUserId = "anotherUserId"; String anotherName = "anotherName"; String anotherEmail = "anotherEmail"; String someKeyword = "someKeyword"; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); CtripUserService.UserServiceResponse anotherUserResponse = assembleUserServiceResponse(anotherUserId, anotherName, anotherEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse, anotherUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); List<UserInfo> users = ctripUserService.findByUserIds(Lists.newArrayList(someUserId, anotherUserId)); assertEquals(2, users.size()); compareUserInfoAndUserServiceResponse(someUserResponse, users.get(0)); compareUserInfoAndUserServiceResponse(anotherUserResponse, users.get(1)); } private void compareUserInfoAndUserServiceResponse( CtripUserService.UserServiceResponse userServiceReponse, UserInfo userInfo) { assertEquals(userServiceReponse.getEmpaccount(), userInfo.getUserId()); assertEquals(userServiceReponse.getDisplayname(), userInfo.getName()); assertEquals(userServiceReponse.getEmail(), userInfo.getEmail()); } private CtripUserService.UserServiceResponse assembleUserServiceResponse(String userId, String name, String email) { CtripUserService.UserServiceResponse response = new CtripUserService.UserServiceResponse(); response.setEmpaccount(userId); response.setDisplayname(name); response.setEmail(email); return response; } }
package com.ctrip.framework.apollo.portal.spi.ctrip; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.ctrip.framework.apollo.portal.AbstractUnitTest; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; /** * @author Jason Song([email protected]) */ public class CtripUserServiceTest extends AbstractUnitTest{ private CtripUserService ctripUserService; private String someUserServiceUrl; private String someUserServiceToken; private ParameterizedTypeReference<Map<String, List<CtripUserService.UserServiceResponse>>> someResponseType; @Mock private PortalConfig portalConfig; @Mock private RestTemplate restTemplate; @Before public void setUp() throws Exception { when(portalConfig.connectTimeout()).thenReturn(3000); when(portalConfig.readTimeout()).thenReturn(3000); ctripUserService = new CtripUserService(portalConfig); ReflectionTestUtils.setField(ctripUserService, "restTemplate", restTemplate); someResponseType = (ParameterizedTypeReference<Map<String, List<CtripUserService.UserServiceResponse>>>) ReflectionTestUtils .getField(ctripUserService, "responseType"); someUserServiceUrl = "http://someurl"; someUserServiceToken = "someToken"; when(portalConfig.userServiceUrl()).thenReturn(someUserServiceUrl); when(portalConfig.userServiceAccessToken()).thenReturn(someUserServiceToken); } @Test public void testAssembleSearchUserRequest() throws Exception { String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; CtripUserService.UserServiceRequest request = ctripUserService.assembleSearchUserRequest(someKeyword, someOffset, someLimit); assertEquals(someUserServiceToken, request.getAccess_token()); CtripUserService.UserServiceRequestBody requestBody = request.getRequest_body(); assertEquals("itdb_emloyee", requestBody.getIndexAlias()); Map<String, Object> queryJson = requestBody.getQueryJson(); assertEquals(someOffset, queryJson.get("from")); assertEquals(someLimit, queryJson.get("size")); Map<String, Object> query = (Map<String, Object>) queryJson.get("query"); Map<String, Object> multiMatchMap = (Map<String, Object>) query.get("multi_match"); assertEquals(someKeyword, multiMatchMap.get("query")); } @Test public void testAssembleFindUserRequest() throws Exception { String someUserId = "someUser"; String anotherUserId = "anotherUser"; List<String> userIds = Lists.newArrayList(someUserId, anotherUserId); CtripUserService.UserServiceRequest request = ctripUserService.assembleFindUserRequest(userIds); assertEquals(someUserServiceToken, request.getAccess_token()); CtripUserService.UserServiceRequestBody requestBody = request.getRequest_body(); assertEquals("itdb_emloyee", requestBody.getIndexAlias()); Map<String, Object> queryJson = requestBody.getQueryJson(); assertEquals(0, queryJson.get("from")); assertEquals(2, queryJson.get("size")); Map<String, Object> query = (Map<String, Object>) queryJson.get("query"); Map<String, Object> terms = getMapFromMap(getMapFromMap(getMapFromMap(query, "filtered"), "filter"), "terms"); List<String> userIdTerms = (List<String>) terms.get("empaccount"); assertTrue(userIdTerms.containsAll(userIds)); } private Map<String, Object> getMapFromMap(Map<String, Object> map, String key) { return (Map<String, Object>) map.get(key); } @Test public void testSearchUsers() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; String anotherUserId = "anotherUserId"; String anotherName = "anotherName"; String anotherEmail = "anotherEmail"; String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); CtripUserService.UserServiceResponse anotherUserResponse = assembleUserServiceResponse(anotherUserId, anotherName, anotherEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse, anotherUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); List<UserInfo> users = ctripUserService.searchUsers(someKeyword, someOffset, someLimit); assertEquals(2, users.size()); compareUserInfoAndUserServiceResponse(someUserResponse, users.get(0)); compareUserInfoAndUserServiceResponse(anotherUserResponse, users.get(1)); } @Test(expected = HttpClientErrorException.class) public void testSearchUsersWithError() throws Exception { when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))) .thenThrow(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); String someKeyword = "someKeyword"; int someOffset = 0; int someLimit = 10; ctripUserService.searchUsers(someKeyword, someOffset, someLimit); } @Test public void testFindByUserId() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); UserInfo user = ctripUserService.findByUserId(someUserId); compareUserInfoAndUserServiceResponse(someUserResponse, user); } @Test public void testFindByUserIds() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; String anotherUserId = "anotherUserId"; String anotherName = "anotherName"; String anotherEmail = "anotherEmail"; String someKeyword = "someKeyword"; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); CtripUserService.UserServiceResponse anotherUserResponse = assembleUserServiceResponse(anotherUserId, anotherName, anotherEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse, anotherUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); List<UserInfo> users = ctripUserService.findByUserIds(Lists.newArrayList(someUserId, anotherUserId)); assertEquals(2, users.size()); compareUserInfoAndUserServiceResponse(someUserResponse, users.get(0)); compareUserInfoAndUserServiceResponse(anotherUserResponse, users.get(1)); } private void compareUserInfoAndUserServiceResponse( CtripUserService.UserServiceResponse userServiceReponse, UserInfo userInfo) { assertEquals(userServiceReponse.getEmpaccount(), userInfo.getUserId()); assertEquals(userServiceReponse.getDisplayname(), userInfo.getName()); assertEquals(userServiceReponse.getEmail(), userInfo.getEmail()); } private CtripUserService.UserServiceResponse assembleUserServiceResponse(String userId, String name, String email) { CtripUserService.UserServiceResponse response = new CtripUserService.UserServiceResponse(); response.setEmpaccount(userId); response.setDisplayname(name); response.setEmail(email); return response; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/MockBeanFactory.java
package com.ctrip.framework.apollo.biz; import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.ServerConfig; import com.ctrip.framework.apollo.common.entity.AppNamespace; public class MockBeanFactory { public static Namespace mockNamespace(String appId, String clusterName, String namespaceName) { Namespace instance = new Namespace(); instance.setAppId(appId); instance.setClusterName(clusterName); instance.setNamespaceName(namespaceName); return instance; } public static AppNamespace mockAppNamespace(String appId, String name, boolean isPublic) { AppNamespace instance = new AppNamespace(); instance.setAppId(appId); instance.setName(name); instance.setPublic(isPublic); return instance; } public static ServerConfig mockServerConfig(String key, String value, String cluster) { ServerConfig instance = new ServerConfig(); instance.setKey(key); instance.setValue(value); instance.setCluster(cluster); return instance; } public static Release mockRelease(long releaseId, String releaseKey, String appId, String clusterName, String groupName, String configurations) { Release instance = new Release(); instance.setId(releaseId); instance.setReleaseKey(releaseKey); instance.setAppId(appId); instance.setClusterName(clusterName); instance.setNamespaceName(groupName); instance.setConfigurations(configurations); return instance; } public static Item mockItem(long id, long namespaceId, String itemKey, String itemValue, int lineNum) { Item item = new Item(); item.setId(id); item.setKey(itemKey); item.setValue(itemValue); item.setLineNum(lineNum); item.setNamespaceId(namespaceId); return item; } }
package com.ctrip.framework.apollo.biz; import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.ServerConfig; import com.ctrip.framework.apollo.common.entity.AppNamespace; public class MockBeanFactory { public static Namespace mockNamespace(String appId, String clusterName, String namespaceName) { Namespace instance = new Namespace(); instance.setAppId(appId); instance.setClusterName(clusterName); instance.setNamespaceName(namespaceName); return instance; } public static AppNamespace mockAppNamespace(String appId, String name, boolean isPublic) { AppNamespace instance = new AppNamespace(); instance.setAppId(appId); instance.setName(name); instance.setPublic(isPublic); return instance; } public static ServerConfig mockServerConfig(String key, String value, String cluster) { ServerConfig instance = new ServerConfig(); instance.setKey(key); instance.setValue(value); instance.setCluster(cluster); return instance; } public static Release mockRelease(long releaseId, String releaseKey, String appId, String clusterName, String groupName, String configurations) { Release instance = new Release(); instance.setId(releaseId); instance.setReleaseKey(releaseKey); instance.setAppId(appId); instance.setClusterName(clusterName); instance.setNamespaceName(groupName); instance.setConfigurations(configurations); return instance; } public static Item mockItem(long id, long namespaceId, String itemKey, String itemValue, int lineNum) { Item item = new Item(); item.setId(id); item.setKey(itemKey); item.setValue(itemValue); item.setLineNum(lineNum); item.setNamespaceId(namespaceId); return item; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java
package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.common.entity.EntityPair; import com.ctrip.framework.apollo.portal.entity.bo.KVEntity; import com.ctrip.framework.apollo.portal.enums.ChangeType; import java.util.LinkedList; import java.util.List; public class ReleaseCompareResult { private List<Change> changes = new LinkedList<>(); public void addEntityPair(ChangeType type, KVEntity firstEntity, KVEntity secondEntity) { changes.add(new Change(type, new EntityPair<>(firstEntity, secondEntity))); } public boolean hasContent(){ return !changes.isEmpty(); } public List<Change> getChanges() { return changes; } public void setChanges(List<Change> changes) { this.changes = changes; } }
package com.ctrip.framework.apollo.portal.entity.vo; import com.ctrip.framework.apollo.common.entity.EntityPair; import com.ctrip.framework.apollo.portal.entity.bo.KVEntity; import com.ctrip.framework.apollo.portal.enums.ChangeType; import java.util.LinkedList; import java.util.List; public class ReleaseCompareResult { private List<Change> changes = new LinkedList<>(); public void addEntityPair(ChangeType type, KVEntity firstEntity, KVEntity secondEntity) { changes.add(new Change(type, new EntityPair<>(firstEntity, secondEntity))); } public boolean hasContent(){ return !changes.isEmpty(); } public List<Change> getChanges() { return changes; } public void setChanges(List<Change> changes) { this.changes = changes; } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-common/src/main/java/com/ctrip/framework/apollo/common/exception/ServiceException.java
package com.ctrip.framework.apollo.common.exception; import org.springframework.http.HttpStatus; public class ServiceException extends AbstractApolloHttpException { public ServiceException(String str) { super(str); setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR); } public ServiceException(String str, Exception e) { super(str, e); setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR); } }
package com.ctrip.framework.apollo.common.exception; import org.springframework.http.HttpStatus; public class ServiceException extends AbstractApolloHttpException { public ServiceException(String str) { super(str); setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR); } public ServiceException(String str, Exception e) { super(str, e); setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
package com.ctrip.framework.apollo.internals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.ConfigFileChangeListener; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.enums.PropertyChangeType; import com.ctrip.framework.apollo.model.ConfigFileChangeEvent; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import com.google.common.util.concurrent.SettableFuture; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.runners.MockitoJUnitRunner; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import org.mockito.stubbing.Answer; /** * @author Jason Song([email protected]) */ @RunWith(MockitoJUnitRunner.class) public class XmlConfigFileTest { private String someNamespace; @Mock private ConfigRepository configRepository; @Mock private PropertiesFactory propertiesFactory; @Before public void setUp() throws Exception { someNamespace = "someName"; when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() { @Override public Properties answer(InvocationOnMock invocation) { return new Properties(); } }); MockInjector.setInstance(PropertiesFactory.class, propertiesFactory); } @After public void tearDown() throws Exception { MockInjector.reset(); System.clearProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE); } @Test public void testWhenHasContent() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(ConfigFileFormat.XML, configFile.getConfigFileFormat()); assertEquals(someNamespace, configFile.getNamespace()); assertTrue(configFile.hasContent()); assertEquals(someValue, configFile.getContent()); } @Test public void testWhenHasNoContent() throws Exception { when(configRepository.getConfig()).thenReturn(null); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); } @Test public void testWhenConfigRepositoryHasError() throws Exception { when(configRepository.getConfig()).thenThrow(new RuntimeException("someError")); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); } @Test public void testOnRepositoryChange() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; String anotherValue = "anotherValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(someValue, configFile.getContent()); Properties anotherProperties = new Properties(); anotherProperties.setProperty(key, anotherValue); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(anotherValue, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(someValue, changeEvent.getOldValue()); assertEquals(anotherValue, changeEvent.getNewValue()); assertEquals(PropertyChangeType.MODIFIED, changeEvent.getChangeType()); } @Test public void testOnRepositoryChangeWithContentAdded() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(null, configFile.getContent()); Properties anotherProperties = new Properties(); anotherProperties.setProperty(key, someValue); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(someValue, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(null, changeEvent.getOldValue()); assertEquals(someValue, changeEvent.getNewValue()); assertEquals(PropertyChangeType.ADDED, changeEvent.getChangeType()); } @Test public void testOnRepositoryChangeWithContentDeleted() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(someValue, configFile.getContent()); Properties anotherProperties = new Properties(); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(null, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(someValue, changeEvent.getOldValue()); assertEquals(null, changeEvent.getNewValue()); assertEquals(PropertyChangeType.DELETED, changeEvent.getChangeType()); } @Test public void testWhenConfigRepositoryHasErrorAndThenRecovered() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenThrow(new RuntimeException("someError")); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); configFile.onRepositoryChange(someNamespace, someProperties); assertTrue(configFile.hasContent()); assertEquals(someValue, configFile.getContent()); } }
package com.ctrip.framework.apollo.internals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import com.ctrip.framework.apollo.ConfigFileChangeListener; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.enums.PropertyChangeType; import com.ctrip.framework.apollo.model.ConfigFileChangeEvent; import com.ctrip.framework.apollo.util.factory.PropertiesFactory; import com.google.common.util.concurrent.SettableFuture; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.runners.MockitoJUnitRunner; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import org.mockito.stubbing.Answer; /** * @author Jason Song([email protected]) */ @RunWith(MockitoJUnitRunner.class) public class XmlConfigFileTest { private String someNamespace; @Mock private ConfigRepository configRepository; @Mock private PropertiesFactory propertiesFactory; @Before public void setUp() throws Exception { someNamespace = "someName"; when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() { @Override public Properties answer(InvocationOnMock invocation) { return new Properties(); } }); MockInjector.setInstance(PropertiesFactory.class, propertiesFactory); } @After public void tearDown() throws Exception { MockInjector.reset(); System.clearProperty(PropertiesFactory.APOLLO_PROPERTY_ORDER_ENABLE); } @Test public void testWhenHasContent() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(ConfigFileFormat.XML, configFile.getConfigFileFormat()); assertEquals(someNamespace, configFile.getNamespace()); assertTrue(configFile.hasContent()); assertEquals(someValue, configFile.getContent()); } @Test public void testWhenHasNoContent() throws Exception { when(configRepository.getConfig()).thenReturn(null); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); } @Test public void testWhenConfigRepositoryHasError() throws Exception { when(configRepository.getConfig()).thenThrow(new RuntimeException("someError")); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); } @Test public void testOnRepositoryChange() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; String anotherValue = "anotherValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(someValue, configFile.getContent()); Properties anotherProperties = new Properties(); anotherProperties.setProperty(key, anotherValue); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(anotherValue, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(someValue, changeEvent.getOldValue()); assertEquals(anotherValue, changeEvent.getNewValue()); assertEquals(PropertyChangeType.MODIFIED, changeEvent.getChangeType()); } @Test public void testOnRepositoryChangeWithContentAdded() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(null, configFile.getContent()); Properties anotherProperties = new Properties(); anotherProperties.setProperty(key, someValue); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(someValue, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(null, changeEvent.getOldValue()); assertEquals(someValue, changeEvent.getNewValue()); assertEquals(PropertyChangeType.ADDED, changeEvent.getChangeType()); } @Test public void testOnRepositoryChangeWithContentDeleted() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenReturn(someProperties); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertEquals(someValue, configFile.getContent()); Properties anotherProperties = new Properties(); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertEquals(null, configFile.getContent()); assertEquals(someNamespace, changeEvent.getNamespace()); assertEquals(someValue, changeEvent.getOldValue()); assertEquals(null, changeEvent.getNewValue()); assertEquals(PropertyChangeType.DELETED, changeEvent.getChangeType()); } @Test public void testWhenConfigRepositoryHasErrorAndThenRecovered() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someValue"; someProperties.setProperty(key, someValue); when(configRepository.getConfig()).thenThrow(new RuntimeException("someError")); XmlConfigFile configFile = new XmlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); configFile.onRepositoryChange(someNamespace, someProperties); assertTrue(configFile.hasContent()); assertEquals(someValue, configFile.getContent()); } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-portal/src/main/resources/static/views/component/delete-namespace-modal.html
<div id="deleteNamespaceModal" class="modal fade"> <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.DeleteNamespace.Title' | translate }} </h4> </div> <div class="modal-body form-horizontal" ng-show="toDeleteNamespace.isPublic"> {{'Component.DeleteNamespace.PublicContent' | translate }} </div> <div class="modal-body form-horizontal" ng-show="!toDeleteNamespace.isPublic"> {{'Component.DeleteNamespace.PrivateContent' | translate }} </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-danger" data-dismiss="modal" ng-click="doDeleteNamespace()"> {{'Common.Ok' | translate }} </button> </div> </div> </div> </div>
<div id="deleteNamespaceModal" class="modal fade"> <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.DeleteNamespace.Title' | translate }} </h4> </div> <div class="modal-body form-horizontal" ng-show="toDeleteNamespace.isPublic"> {{'Component.DeleteNamespace.PublicContent' | translate }} </div> <div class="modal-body form-horizontal" ng-show="!toDeleteNamespace.isPublic"> {{'Component.DeleteNamespace.PrivateContent' | translate }} </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-danger" data-dismiss="modal" ng-click="doDeleteNamespace()"> {{'Common.Ok' | translate }} </button> </div> </div> </div> </div>
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.List; public interface GrayReleaseRuleRepository extends PagingAndSortingRepository<GrayReleaseRule, Long> { GrayReleaseRule findTopByAppIdAndClusterNameAndNamespaceNameAndBranchNameOrderByIdDesc(String appId, String clusterName, String namespaceName, String branchName); List<GrayReleaseRule> findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName); List<GrayReleaseRule> findFirst500ByIdGreaterThanOrderByIdAsc(Long id); }
package com.ctrip.framework.apollo.biz.repository; import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule; import org.springframework.data.repository.PagingAndSortingRepository; import java.util.List; public interface GrayReleaseRuleRepository extends PagingAndSortingRepository<GrayReleaseRule, Long> { GrayReleaseRule findTopByAppIdAndClusterNameAndNamespaceNameAndBranchNameOrderByIdDesc(String appId, String clusterName, String namespaceName, String branchName); List<GrayReleaseRule> findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName); List<GrayReleaseRule> findFirst500ByIdGreaterThanOrderByIdAsc(Long id); }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./scripts/apollo-on-kubernetes/db/portal-db/apolloportaldb.sql
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; # Create Database # ------------------------------------------------------------ CREATE DATABASE IF NOT EXISTS ApolloPortalDB DEFAULT CHARACTER SET = utf8mb4; Use ApolloPortalDB; # Dump of table app # ------------------------------------------------------------ DROP TABLE IF EXISTS `App`; CREATE TABLE `App` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名', `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id', `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字', `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; # Dump of table appnamespace # ------------------------------------------------------------ DROP TABLE IF EXISTS `AppNamespace`; CREATE TABLE `AppNamespace` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键', `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'namespace名字,注意,需要全局唯一', `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'app id', `Format` varchar(32) NOT NULL DEFAULT 'properties' COMMENT 'namespace的format类型', `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_AppId` (`AppId`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; # Dump of table consumer # ------------------------------------------------------------ DROP TABLE IF EXISTS `Consumer`; CREATE TABLE `Consumer` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名', `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id', `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字', `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开放API消费者'; # Dump of table consumeraudit # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerAudit`; CREATE TABLE `ConsumerAudit` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `Uri` varchar(1024) NOT NULL DEFAULT '' COMMENT '访问的Uri', `Method` varchar(16) NOT NULL DEFAULT '' COMMENT '访问的Method', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_ConsumerId` (`ConsumerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer审计表'; # Dump of table consumerrole # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerRole`; CREATE TABLE `ConsumerRole` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_ConsumerId_RoleId` (`ConsumerId`,`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer和role的绑定表'; # Dump of table consumertoken # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerToken`; CREATE TABLE `ConsumerToken` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'ConsumerId', `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), UNIQUE KEY `IX_Token` (`Token`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer token表'; # Dump of table favorite # ------------------------------------------------------------ DROP TABLE IF EXISTS `Favorite`; CREATE TABLE `Favorite` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `UserId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '收藏的用户', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `IX_UserId` (`UserId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COMMENT='应用收藏表'; # Dump of table permission # ------------------------------------------------------------ DROP TABLE IF EXISTS `Permission`; CREATE TABLE `Permission` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_TargetId_PermissionType` (`TargetId`(191),`PermissionType`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission表'; # Dump of table role # ------------------------------------------------------------ DROP TABLE IF EXISTS `Role`; CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_RoleName` (`RoleName`(191)), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表'; # Dump of table rolepermission # ------------------------------------------------------------ DROP TABLE IF EXISTS `RolePermission`; CREATE TABLE `RolePermission` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和权限的绑定表'; # Dump of table serverconfig # ------------------------------------------------------------ DROP TABLE IF EXISTS `ServerConfig`; CREATE TABLE `ServerConfig` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Key` varchar(64) NOT NULL DEFAULT 'default' COMMENT '配置项Key', `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_Key` (`Key`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; # Dump of table userrole # ------------------------------------------------------------ DROP TABLE IF EXISTS `UserRole`; CREATE TABLE `UserRole` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_UserId_RoleId` (`UserId`,`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和role的绑定表'; # Dump of table Users # ------------------------------------------------------------ DROP TABLE IF EXISTS `Users`; CREATE TABLE `Users` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户名', `Password` varchar(64) NOT NULL DEFAULT 'default' COMMENT '密码', `Email` varchar(64) NOT NULL DEFAULT 'default' COMMENT '邮箱地址', `Enabled` tinyint(4) DEFAULT NULL COMMENT '是否有效', PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表'; # Dump of table Authorities # ------------------------------------------------------------ DROP TABLE IF EXISTS `Authorities`; CREATE TABLE `Authorities` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Username` varchar(64) NOT NULL, `Authority` varchar(50) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; # Config # ------------------------------------------------------------ INSERT INTO `ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.portal.envs', 'dev, fat, uat, pro', '可支持的环境列表'), ('organizations', '[{\"orgId\":\"TEST1\",\"orgName\":\"样例部门1\"},{\"orgId\":\"TEST2\",\"orgName\":\"样例部门2\"}]', '部门列表'), ('superAdmin', 'apollo', 'Portal超级管理员'), ('api.readTimeout', '10000', 'http接口read timeout'), ('consumer.token.salt', 'someSalt', 'consumer token salt'), ('admin.createPrivateNamespace.switch', 'true', '是否允许项目管理员创建私有namespace'), ('configView.memberOnly.envs', 'pro', '只对项目成员显示配置信息的环境列表,多个env以英文逗号分隔'), ('apollo.portal.meta.servers', '{}', '各环境Meta Service列表'); INSERT INTO `Users` (`Username`, `Password`, `Email`, `Enabled`) VALUES ('apollo', '$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS', '[email protected]', 1); INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user'); /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; # Create Database # ------------------------------------------------------------ CREATE DATABASE IF NOT EXISTS ApolloPortalDB DEFAULT CHARACTER SET = utf8mb4; Use ApolloPortalDB; # Dump of table app # ------------------------------------------------------------ DROP TABLE IF EXISTS `App`; CREATE TABLE `App` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名', `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id', `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字', `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; # Dump of table appnamespace # ------------------------------------------------------------ DROP TABLE IF EXISTS `AppNamespace`; CREATE TABLE `AppNamespace` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键', `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'namespace名字,注意,需要全局唯一', `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'app id', `Format` varchar(32) NOT NULL DEFAULT 'properties' COMMENT 'namespace的format类型', `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_AppId` (`AppId`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; # Dump of table consumer # ------------------------------------------------------------ DROP TABLE IF EXISTS `Consumer`; CREATE TABLE `Consumer` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名', `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id', `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字', `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开放API消费者'; # Dump of table consumeraudit # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerAudit`; CREATE TABLE `ConsumerAudit` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `Uri` varchar(1024) NOT NULL DEFAULT '' COMMENT '访问的Uri', `Method` varchar(16) NOT NULL DEFAULT '' COMMENT '访问的Method', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_ConsumerId` (`ConsumerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer审计表'; # Dump of table consumerrole # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerRole`; CREATE TABLE `ConsumerRole` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_ConsumerId_RoleId` (`ConsumerId`,`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer和role的绑定表'; # Dump of table consumertoken # ------------------------------------------------------------ DROP TABLE IF EXISTS `ConsumerToken`; CREATE TABLE `ConsumerToken` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'ConsumerId', `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), UNIQUE KEY `IX_Token` (`Token`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer token表'; # Dump of table favorite # ------------------------------------------------------------ DROP TABLE IF EXISTS `Favorite`; CREATE TABLE `Favorite` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `UserId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '收藏的用户', `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `AppId` (`AppId`(191)), KEY `IX_UserId` (`UserId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COMMENT='应用收藏表'; # Dump of table permission # ------------------------------------------------------------ DROP TABLE IF EXISTS `Permission`; CREATE TABLE `Permission` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_TargetId_PermissionType` (`TargetId`(191),`PermissionType`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission表'; # Dump of table role # ------------------------------------------------------------ DROP TABLE IF EXISTS `Role`; CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_RoleName` (`RoleName`(191)), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表'; # Dump of table rolepermission # ------------------------------------------------------------ DROP TABLE IF EXISTS `RolePermission`; CREATE TABLE `RolePermission` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和权限的绑定表'; # Dump of table serverconfig # ------------------------------------------------------------ DROP TABLE IF EXISTS `ServerConfig`; CREATE TABLE `ServerConfig` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Key` varchar(64) NOT NULL DEFAULT 'default' COMMENT '配置项Key', `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_Key` (`Key`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; # Dump of table userrole # ------------------------------------------------------------ DROP TABLE IF EXISTS `UserRole`; CREATE TABLE `UserRole` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_RoleId` (`RoleId`), KEY `IX_UserId_RoleId` (`UserId`,`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和role的绑定表'; # Dump of table Users # ------------------------------------------------------------ DROP TABLE IF EXISTS `Users`; CREATE TABLE `Users` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户名', `Password` varchar(64) NOT NULL DEFAULT 'default' COMMENT '密码', `Email` varchar(64) NOT NULL DEFAULT 'default' COMMENT '邮箱地址', `Enabled` tinyint(4) DEFAULT NULL COMMENT '是否有效', PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表'; # Dump of table Authorities # ------------------------------------------------------------ DROP TABLE IF EXISTS `Authorities`; CREATE TABLE `Authorities` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `Username` varchar(64) NOT NULL, `Authority` varchar(50) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; # Config # ------------------------------------------------------------ INSERT INTO `ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.portal.envs', 'dev, fat, uat, pro', '可支持的环境列表'), ('organizations', '[{\"orgId\":\"TEST1\",\"orgName\":\"样例部门1\"},{\"orgId\":\"TEST2\",\"orgName\":\"样例部门2\"}]', '部门列表'), ('superAdmin', 'apollo', 'Portal超级管理员'), ('api.readTimeout', '10000', 'http接口read timeout'), ('consumer.token.salt', 'someSalt', 'consumer token salt'), ('admin.createPrivateNamespace.switch', 'true', '是否允许项目管理员创建私有namespace'), ('configView.memberOnly.envs', 'pro', '只对项目成员显示配置信息的环境列表,多个env以英文逗号分隔'), ('apollo.portal.meta.servers', '{}', '各环境Meta Service列表'); INSERT INTO `Users` (`Username`, `Password`, `Email`, `Enabled`) VALUES ('apollo', '$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS', '[email protected]', 1); INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user'); /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java
package com.ctrip.framework.apollo.spring; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.spring.XmlConfigPlaceholderTest.TestXmlBean; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.primitives.Ints; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.support.ClassPathXmlApplicationContext; public class XmlConfigPlaceholderAutoUpdateTest extends AbstractSpringIntegrationTest { private static final String TIMEOUT_PROPERTY = "timeout"; private static final int DEFAULT_TIMEOUT = 100; private static final String BATCH_PROPERTY = "batch"; private static final int DEFAULT_BATCH = 200; private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; @Test public void testAutoUpdateWithOneNamespace() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateDisabled() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; MockConfigUtil mockConfigUtil = new MockConfigUtil(); mockConfigUtil.setAutoUpdateInjectedSpringProperties(false); MockInjector.setInstance(ConfigUtil.class, mockConfigUtil); Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespaces() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout)); Properties fxApolloProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); SimpleConfig fxApolloConfig = prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout)); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newFxApolloProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(newBatch)); fxApolloConfig.onRepositoryChange(FX_APOLLO_NAMESPACE, newFxApolloProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespacesWithSameProperties() throws Exception { int someTimeout = 1000; int someBatch = 2000; int anotherBatch = 3000; int someNewTimeout = 1001; int someNewBatch = 2001; Properties applicationProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(someBatch)); Properties fxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someTimeout), BATCH_PROPERTY, String.valueOf(anotherBatch)); prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); SimpleConfig fxApolloConfig = prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(someTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); Properties newFxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someNewTimeout), BATCH_PROPERTY, String.valueOf(someNewBatch)); fxApolloConfig.onRepositoryChange(FX_APOLLO_NAMESPACE, newFxApolloProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someNewTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); } @Test public void testAutoUpdateWithNewProperties() throws Exception { int initialTimeout = 1000; int newTimeout = 1001; int newBatch = 2001; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithIrrelevantProperties() throws Exception { int initialTimeout = 1000; String someIrrelevantKey = "someIrrelevantKey"; String someIrrelevantValue = "someIrrelevantValue"; String anotherIrrelevantKey = "anotherIrrelevantKey"; String anotherIrrelevantValue = "anotherIrrelevantValue"; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), someIrrelevantKey, someIrrelevantValue); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), anotherIrrelevantKey, anotherIrrelevantValue); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); } @Test public void testAutoUpdateWithDeletedProperties() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = new Properties(); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(DEFAULT_TIMEOUT, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted() throws Exception { int someTimeout = 1000; int someBatch = 2000; int anotherBatch = 3000; Properties applicationProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(someBatch)); Properties fxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someTimeout), BATCH_PROPERTY, String.valueOf(anotherBatch)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(someTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); Properties newProperties = new Properties(); applicationConfig.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someTimeout, bean.getTimeout()); assertEquals(anotherBatch, bean.getBatch()); } @Test public void testAutoUpdateWithDeletedPropertiesWithNoDefaultValue() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest7.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(300); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithTypeMismatch() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; String newBatch = "newBatch"; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, newBatch); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(300); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithValueInjectedAsConstructorArgs() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest8.xml"); TestXmlBeanWithConstructorArgs bean = context.getBean(TestXmlBeanWithConstructorArgs.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); // Does not support this scenario assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithValueAndProperty() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest9.xml"); TestXmlBeanWithInjectedValue bean = context.getBean(TestXmlBeanWithInjectedValue.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithAllKindsOfDataTypes() throws Exception { int someInt = 1000; int someNewInt = 1001; int[] someIntArray = {1, 2, 3, 4}; int[] someNewIntArray = {5, 6, 7, 8}; long someLong = 2000L; long someNewLong = 2001L; short someShort = 3000; short someNewShort = 3001; float someFloat = 1.2F; float someNewFloat = 2.2F; double someDouble = 3.10D; double someNewDouble = 4.10D; byte someByte = 123; byte someNewByte = 124; boolean someBoolean = true; boolean someNewBoolean = !someBoolean; String someString = "someString"; String someNewString = "someNewString"; String someDateFormat = "yyyy-MM-dd HH:mm:ss.SSS"; Date someDate = assembleDate(2018, 2, 23, 20, 1, 2, 123); Date someNewDate = assembleDate(2018, 2, 23, 21, 2, 3, 345); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(someDateFormat, Locale.US); Properties properties = new Properties(); properties.setProperty("intProperty", String.valueOf(someInt)); properties.setProperty("intArrayProperty", Ints.join(", ", someIntArray)); properties.setProperty("longProperty", String.valueOf(someLong)); properties.setProperty("shortProperty", String.valueOf(someShort)); properties.setProperty("floatProperty", String.valueOf(someFloat)); properties.setProperty("doubleProperty", String.valueOf(someDouble)); properties.setProperty("byteProperty", String.valueOf(someByte)); properties.setProperty("booleanProperty", String.valueOf(someBoolean)); properties.setProperty("stringProperty", someString); properties.setProperty("dateFormat", someDateFormat); properties.setProperty("dateProperty", simpleDateFormat.format(someDate)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest10.xml"); TestAllKindsOfDataTypesBean bean = context.getBean(TestAllKindsOfDataTypesBean.class); assertEquals(someInt, bean.getIntProperty()); assertArrayEquals(someIntArray, bean.getIntArrayProperty()); assertEquals(someLong, bean.getLongProperty()); assertEquals(someShort, bean.getShortProperty()); assertEquals(someFloat, bean.getFloatProperty(), 0.001F); assertEquals(someDouble, bean.getDoubleProperty(), 0.001D); assertEquals(someByte, bean.getByteProperty()); assertEquals(someBoolean, bean.getBooleanProperty()); assertEquals(someString, bean.getStringProperty()); assertEquals(someDate, bean.getDateProperty()); Properties newProperties = new Properties(); newProperties.setProperty("intProperty", String.valueOf(someNewInt)); newProperties.setProperty("intArrayProperty", Ints.join(", ", someNewIntArray)); newProperties.setProperty("longProperty", String.valueOf(someNewLong)); newProperties.setProperty("shortProperty", String.valueOf(someNewShort)); newProperties.setProperty("floatProperty", String.valueOf(someNewFloat)); newProperties.setProperty("doubleProperty", String.valueOf(someNewDouble)); newProperties.setProperty("byteProperty", String.valueOf(someNewByte)); newProperties.setProperty("booleanProperty", String.valueOf(someNewBoolean)); newProperties.setProperty("stringProperty", someNewString); newProperties.setProperty("dateFormat", someDateFormat); newProperties.setProperty("dateProperty", simpleDateFormat.format(someNewDate)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someNewInt, bean.getIntProperty()); assertArrayEquals(someNewIntArray, bean.getIntArrayProperty()); assertEquals(someNewLong, bean.getLongProperty()); assertEquals(someNewShort, bean.getShortProperty()); assertEquals(someNewFloat, bean.getFloatProperty(), 0.001F); assertEquals(someNewDouble, bean.getDoubleProperty(), 0.001D); assertEquals(someNewByte, bean.getByteProperty()); assertEquals(someNewBoolean, bean.getBooleanProperty()); assertEquals(someNewString, bean.getStringProperty()); assertEquals(someNewDate, bean.getDateProperty()); } public static class TestXmlBeanWithConstructorArgs { private final int timeout; private final int batch; public TestXmlBeanWithConstructorArgs(int timeout, int batch) { this.timeout = timeout; this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } public static class TestXmlBeanWithInjectedValue { @Value("${timeout}") private int timeout; private int batch; public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } static class TestAllKindsOfDataTypesBean { private int intProperty; private int[] intArrayProperty; private long longProperty; private short shortProperty; private float floatProperty; private double doubleProperty; private byte byteProperty; private boolean booleanProperty; private String stringProperty; private Date dateProperty; public void setDateProperty(Date dateProperty) { this.dateProperty = dateProperty; } public void setIntProperty(int intProperty) { this.intProperty = intProperty; } public void setIntArrayProperty(int[] intArrayProperty) { this.intArrayProperty = intArrayProperty; } public void setLongProperty(long longProperty) { this.longProperty = longProperty; } public void setShortProperty(short shortProperty) { this.shortProperty = shortProperty; } public void setFloatProperty(float floatProperty) { this.floatProperty = floatProperty; } public void setDoubleProperty(double doubleProperty) { this.doubleProperty = doubleProperty; } public void setByteProperty(byte byteProperty) { this.byteProperty = byteProperty; } public void setBooleanProperty(boolean booleanProperty) { this.booleanProperty = booleanProperty; } public void setStringProperty(String stringProperty) { this.stringProperty = stringProperty; } public int getIntProperty() { return intProperty; } public int[] getIntArrayProperty() { return intArrayProperty; } public long getLongProperty() { return longProperty; } public short getShortProperty() { return shortProperty; } public float getFloatProperty() { return floatProperty; } public double getDoubleProperty() { return doubleProperty; } public byte getByteProperty() { return byteProperty; } public boolean getBooleanProperty() { return booleanProperty; } public String getStringProperty() { return stringProperty; } public Date getDateProperty() { return dateProperty; } } }
package com.ctrip.framework.apollo.spring; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import com.ctrip.framework.apollo.build.MockInjector; import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.internals.SimpleConfig; import com.ctrip.framework.apollo.spring.XmlConfigPlaceholderTest.TestXmlBean; import com.ctrip.framework.apollo.util.ConfigUtil; import com.google.common.primitives.Ints; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.support.ClassPathXmlApplicationContext; public class XmlConfigPlaceholderAutoUpdateTest extends AbstractSpringIntegrationTest { private static final String TIMEOUT_PROPERTY = "timeout"; private static final int DEFAULT_TIMEOUT = 100; private static final String BATCH_PROPERTY = "batch"; private static final int DEFAULT_BATCH = 200; private static final String FX_APOLLO_NAMESPACE = "FX.apollo"; @Test public void testAutoUpdateWithOneNamespace() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateDisabled() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; MockConfigUtil mockConfigUtil = new MockConfigUtil(); mockConfigUtil.setAutoUpdateInjectedSpringProperties(false); MockInjector.setInstance(ConfigUtil.class, mockConfigUtil); Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespaces() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout)); Properties fxApolloProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); SimpleConfig fxApolloConfig = prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout)); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newFxApolloProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(newBatch)); fxApolloConfig.onRepositoryChange(FX_APOLLO_NAMESPACE, newFxApolloProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespacesWithSameProperties() throws Exception { int someTimeout = 1000; int someBatch = 2000; int anotherBatch = 3000; int someNewTimeout = 1001; int someNewBatch = 2001; Properties applicationProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(someBatch)); Properties fxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someTimeout), BATCH_PROPERTY, String.valueOf(anotherBatch)); prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); SimpleConfig fxApolloConfig = prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(someTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); Properties newFxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someNewTimeout), BATCH_PROPERTY, String.valueOf(someNewBatch)); fxApolloConfig.onRepositoryChange(FX_APOLLO_NAMESPACE, newFxApolloProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someNewTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); } @Test public void testAutoUpdateWithNewProperties() throws Exception { int initialTimeout = 1000; int newTimeout = 1001; int newBatch = 2001; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithIrrelevantProperties() throws Exception { int initialTimeout = 1000; String someIrrelevantKey = "someIrrelevantKey"; String someIrrelevantValue = "someIrrelevantValue"; String anotherIrrelevantKey = "anotherIrrelevantKey"; String anotherIrrelevantValue = "anotherIrrelevantValue"; Properties applicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), someIrrelevantKey, someIrrelevantValue); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); Properties newApplicationProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), anotherIrrelevantKey, anotherIrrelevantValue); applicationConfig .onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newApplicationProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); } @Test public void testAutoUpdateWithDeletedProperties() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = new Properties(); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(DEFAULT_TIMEOUT, bean.getTimeout()); assertEquals(DEFAULT_BATCH, bean.getBatch()); } @Test public void testAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted() throws Exception { int someTimeout = 1000; int someBatch = 2000; int anotherBatch = 3000; Properties applicationProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(someBatch)); Properties fxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someTimeout), BATCH_PROPERTY, String.valueOf(anotherBatch)); SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties); prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(someTimeout, bean.getTimeout()); assertEquals(someBatch, bean.getBatch()); Properties newProperties = new Properties(); applicationConfig.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someTimeout, bean.getTimeout()); assertEquals(anotherBatch, bean.getBatch()); } @Test public void testAutoUpdateWithDeletedPropertiesWithNoDefaultValue() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest7.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(300); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithTypeMismatch() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; String newBatch = "newBatch"; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml"); TestXmlBean bean = context.getBean(TestXmlBean.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, newBatch); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(300); assertEquals(newTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithValueInjectedAsConstructorArgs() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest8.xml"); TestXmlBeanWithConstructorArgs bean = context.getBean(TestXmlBeanWithConstructorArgs.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); // Does not support this scenario assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); } @Test public void testAutoUpdateWithValueAndProperty() throws Exception { int initialTimeout = 1000; int initialBatch = 2000; int newTimeout = 1001; int newBatch = 2001; Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest9.xml"); TestXmlBeanWithInjectedValue bean = context.getBean(TestXmlBeanWithInjectedValue.class); assertEquals(initialTimeout, bean.getTimeout()); assertEquals(initialBatch, bean.getBatch()); Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(newTimeout, bean.getTimeout()); assertEquals(newBatch, bean.getBatch()); } @Test public void testAutoUpdateWithAllKindsOfDataTypes() throws Exception { int someInt = 1000; int someNewInt = 1001; int[] someIntArray = {1, 2, 3, 4}; int[] someNewIntArray = {5, 6, 7, 8}; long someLong = 2000L; long someNewLong = 2001L; short someShort = 3000; short someNewShort = 3001; float someFloat = 1.2F; float someNewFloat = 2.2F; double someDouble = 3.10D; double someNewDouble = 4.10D; byte someByte = 123; byte someNewByte = 124; boolean someBoolean = true; boolean someNewBoolean = !someBoolean; String someString = "someString"; String someNewString = "someNewString"; String someDateFormat = "yyyy-MM-dd HH:mm:ss.SSS"; Date someDate = assembleDate(2018, 2, 23, 20, 1, 2, 123); Date someNewDate = assembleDate(2018, 2, 23, 21, 2, 3, 345); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(someDateFormat, Locale.US); Properties properties = new Properties(); properties.setProperty("intProperty", String.valueOf(someInt)); properties.setProperty("intArrayProperty", Ints.join(", ", someIntArray)); properties.setProperty("longProperty", String.valueOf(someLong)); properties.setProperty("shortProperty", String.valueOf(someShort)); properties.setProperty("floatProperty", String.valueOf(someFloat)); properties.setProperty("doubleProperty", String.valueOf(someDouble)); properties.setProperty("byteProperty", String.valueOf(someByte)); properties.setProperty("booleanProperty", String.valueOf(someBoolean)); properties.setProperty("stringProperty", someString); properties.setProperty("dateFormat", someDateFormat); properties.setProperty("dateProperty", simpleDateFormat.format(someDate)); SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest10.xml"); TestAllKindsOfDataTypesBean bean = context.getBean(TestAllKindsOfDataTypesBean.class); assertEquals(someInt, bean.getIntProperty()); assertArrayEquals(someIntArray, bean.getIntArrayProperty()); assertEquals(someLong, bean.getLongProperty()); assertEquals(someShort, bean.getShortProperty()); assertEquals(someFloat, bean.getFloatProperty(), 0.001F); assertEquals(someDouble, bean.getDoubleProperty(), 0.001D); assertEquals(someByte, bean.getByteProperty()); assertEquals(someBoolean, bean.getBooleanProperty()); assertEquals(someString, bean.getStringProperty()); assertEquals(someDate, bean.getDateProperty()); Properties newProperties = new Properties(); newProperties.setProperty("intProperty", String.valueOf(someNewInt)); newProperties.setProperty("intArrayProperty", Ints.join(", ", someNewIntArray)); newProperties.setProperty("longProperty", String.valueOf(someNewLong)); newProperties.setProperty("shortProperty", String.valueOf(someNewShort)); newProperties.setProperty("floatProperty", String.valueOf(someNewFloat)); newProperties.setProperty("doubleProperty", String.valueOf(someNewDouble)); newProperties.setProperty("byteProperty", String.valueOf(someNewByte)); newProperties.setProperty("booleanProperty", String.valueOf(someNewBoolean)); newProperties.setProperty("stringProperty", someNewString); newProperties.setProperty("dateFormat", someDateFormat); newProperties.setProperty("dateProperty", simpleDateFormat.format(someNewDate)); config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties); TimeUnit.MILLISECONDS.sleep(100); assertEquals(someNewInt, bean.getIntProperty()); assertArrayEquals(someNewIntArray, bean.getIntArrayProperty()); assertEquals(someNewLong, bean.getLongProperty()); assertEquals(someNewShort, bean.getShortProperty()); assertEquals(someNewFloat, bean.getFloatProperty(), 0.001F); assertEquals(someNewDouble, bean.getDoubleProperty(), 0.001D); assertEquals(someNewByte, bean.getByteProperty()); assertEquals(someNewBoolean, bean.getBooleanProperty()); assertEquals(someNewString, bean.getStringProperty()); assertEquals(someNewDate, bean.getDateProperty()); } public static class TestXmlBeanWithConstructorArgs { private final int timeout; private final int batch; public TestXmlBeanWithConstructorArgs(int timeout, int batch) { this.timeout = timeout; this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } public static class TestXmlBeanWithInjectedValue { @Value("${timeout}") private int timeout; private int batch; public void setBatch(int batch) { this.batch = batch; } public int getTimeout() { return timeout; } public int getBatch() { return batch; } } static class TestAllKindsOfDataTypesBean { private int intProperty; private int[] intArrayProperty; private long longProperty; private short shortProperty; private float floatProperty; private double doubleProperty; private byte byteProperty; private boolean booleanProperty; private String stringProperty; private Date dateProperty; public void setDateProperty(Date dateProperty) { this.dateProperty = dateProperty; } public void setIntProperty(int intProperty) { this.intProperty = intProperty; } public void setIntArrayProperty(int[] intArrayProperty) { this.intArrayProperty = intArrayProperty; } public void setLongProperty(long longProperty) { this.longProperty = longProperty; } public void setShortProperty(short shortProperty) { this.shortProperty = shortProperty; } public void setFloatProperty(float floatProperty) { this.floatProperty = floatProperty; } public void setDoubleProperty(double doubleProperty) { this.doubleProperty = doubleProperty; } public void setByteProperty(byte byteProperty) { this.byteProperty = byteProperty; } public void setBooleanProperty(boolean booleanProperty) { this.booleanProperty = booleanProperty; } public void setStringProperty(String stringProperty) { this.stringProperty = stringProperty; } public int getIntProperty() { return intProperty; } public int[] getIntArrayProperty() { return intArrayProperty; } public long getLongProperty() { return longProperty; } public short getShortProperty() { return shortProperty; } public float getFloatProperty() { return floatProperty; } public double getDoubleProperty() { return doubleProperty; } public byte getByteProperty() { return byteProperty; } public boolean getBooleanProperty() { return booleanProperty; } public String getStringProperty() { return stringProperty; } public Date getDateProperty() { return dateProperty; } } }
-1
apolloconfig/apollo
3,658
update apolloconfig.com domain
## What's the purpose of this PR update apolloconfig.com domain
nobodyiam
2021-05-02T02:26:41Z
2021-05-02T02:31:15Z
a1b19ace8e6eb73e791f89ad30e2210003ba9d33
e1a6cf9cd40300fad156b6b87835c27b5e378f16
update apolloconfig.com domain. ## What's the purpose of this PR update apolloconfig.com domain
./apollo-configservice/src/assembly/assembly-descriptor.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>apollo-assembly</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <!--scripts --> <fileSet> <directory>src/main/scripts</directory> <outputDirectory>scripts</outputDirectory> <includes> <include>*.sh</include> </includes> <fileMode>0755</fileMode> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>src/main/config</directory> <outputDirectory>config</outputDirectory> <excludes> <exclude>apollo-configservice.conf</exclude> <exclude>application-github.properties</exclude> </excludes> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>src/main/config</directory> <outputDirectory>/</outputDirectory> <includes> <include>apollo-configservice.conf</include> </includes> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>target/classes</directory> <outputDirectory>/config</outputDirectory> <includes> <include>application-github.properties</include> </includes> </fileSet> <!--artifact --> <fileSet> <directory>target</directory> <outputDirectory>/</outputDirectory> <includes> <include>${project.artifactId}-*.jar</include> </includes> <fileMode>0755</fileMode> </fileSet> </fileSets> </assembly>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>apollo-assembly</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <!--scripts --> <fileSet> <directory>src/main/scripts</directory> <outputDirectory>scripts</outputDirectory> <includes> <include>*.sh</include> </includes> <fileMode>0755</fileMode> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>src/main/config</directory> <outputDirectory>config</outputDirectory> <excludes> <exclude>apollo-configservice.conf</exclude> <exclude>application-github.properties</exclude> </excludes> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>src/main/config</directory> <outputDirectory>/</outputDirectory> <includes> <include>apollo-configservice.conf</include> </includes> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>target/classes</directory> <outputDirectory>/config</outputDirectory> <includes> <include>application-github.properties</include> </includes> </fileSet> <!--artifact --> <fileSet> <directory>target</directory> <outputDirectory>/</outputDirectory> <includes> <include>${project.artifactId}-*.jar</include> </includes> <fileMode>0755</fileMode> </fileSet> </fileSets> </assembly>
-1