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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/spi/configuration/LdapExtendProperties.java | /*
* Copyright (c) 2019 www.ceair.com Inc. All rights reserved.
*/
package com.ctrip.framework.apollo.portal.spi.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* the LdapExtendProperties description.
*
* @author wuzishu
*/
@ConfigurationProperties(prefix = "ldap")
public class LdapExtendProperties {
private LdapMappingProperties mapping;
private LdapGroupProperties group;
public LdapMappingProperties getMapping() {
return mapping;
}
public void setMapping(LdapMappingProperties mapping) {
this.mapping = mapping;
}
public LdapGroupProperties getGroup() {
return group;
}
public void setGroup(LdapGroupProperties group) {
this.group = group;
}
}
| /*
* Copyright (c) 2019 www.ceair.com Inc. All rights reserved.
*/
package com.ctrip.framework.apollo.portal.spi.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* the LdapExtendProperties description.
*
* @author wuzishu
*/
@ConfigurationProperties(prefix = "ldap")
public class LdapExtendProperties {
private LdapMappingProperties mapping;
private LdapGroupProperties group;
public LdapMappingProperties getMapping() {
return mapping;
}
public void setMapping(LdapMappingProperties mapping) {
this.mapping = mapping;
}
public LdapGroupProperties getGroup() {
return group;
}
public void setGroup(LdapGroupProperties group) {
this.group = group;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java | package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.web.client.RestTemplate;
import java.util.List;
public class ItemSetControllerTest extends AbstractControllerTest {
@Autowired
ItemRepository itemRepository;
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetCreated() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets itemSet = new ItemChangeSets();
itemSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
itemSet.addCreateItem(item);
}
ResponseEntity<Void> response =
createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
itemSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> items = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize, items.size());
Item item0 = items.get(0);
Assert.assertEquals("key_0", item0.getKey());
Assert.assertEquals("created_value_0", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
}
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetUpdated() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdRestTemplate = (new TestRestTemplate()).getRestTemplate();
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
createChangeSet.addCreateItem(item);
}
ResponseEntity<Void> response = createdRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ItemDTO[] items =
createdRestTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class);
ItemChangeSets updateChangeSet = new ItemChangeSets();
updateChangeSet.setDataChangeLastModifiedBy("updated");
RestTemplate updatedRestTemplate = (new TestRestTemplate()).getRestTemplate();
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int updatedSize = 2;
for (int i = 0; i < updatedSize; i++) {
items[i].setValue("updated_value_" + i);
updateChangeSet.addUpdateItem(items[i]);
}
response = updatedRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
updateChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> savedItems = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize, savedItems.size());
Item item0 = savedItems.get(0);
Assert.assertEquals("key_0", item0.getKey());
Assert.assertEquals("updated_value_0", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertEquals("updated", item0.getDataChangeLastModifiedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
Assert.assertNotNull(item0.getDataChangeLastModifiedTime());
}
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetDeleted() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
createChangeSet.addCreateItem(item);
}
ResponseEntity<Void> response = createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ItemDTO[] items =
restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class);
ItemChangeSets deleteChangeSet = new ItemChangeSets();
deleteChangeSet.setDataChangeLastModifiedBy("deleted");
RestTemplate deletedTemplate = (new TestRestTemplate()).getRestTemplate();
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
int deletedSize = 1;
for (int i = 0; i < deletedSize; i++) {
items[i].setValue("deleted_value_" + i);
deleteChangeSet.addDeleteItem(items[i]);
}
response = deletedTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
deleteChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> savedItems = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize - deletedSize, savedItems.size());
Item item0 = savedItems.get(0);
Assert.assertEquals("key_1", item0.getKey());
Assert.assertEquals("created_value_1", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
}
}
| package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.web.client.RestTemplate;
import java.util.List;
public class ItemSetControllerTest extends AbstractControllerTest {
@Autowired
ItemRepository itemRepository;
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetCreated() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets itemSet = new ItemChangeSets();
itemSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
itemSet.addCreateItem(item);
}
ResponseEntity<Void> response =
createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/itemset",
itemSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> items = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize, items.size());
Item item0 = items.get(0);
Assert.assertEquals("key_0", item0.getKey());
Assert.assertEquals("created_value_0", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
}
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetUpdated() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdRestTemplate = (new TestRestTemplate()).getRestTemplate();
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
createChangeSet.addCreateItem(item);
}
ResponseEntity<Void> response = createdRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ItemDTO[] items =
createdRestTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class);
ItemChangeSets updateChangeSet = new ItemChangeSets();
updateChangeSet.setDataChangeLastModifiedBy("updated");
RestTemplate updatedRestTemplate = (new TestRestTemplate()).getRestTemplate();
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int updatedSize = 2;
for (int i = 0; i < updatedSize; i++) {
items[i].setValue("updated_value_" + i);
updateChangeSet.addUpdateItem(items[i]);
}
response = updatedRestTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
updateChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> savedItems = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize, savedItems.size());
Item item0 = savedItems.get(0);
Assert.assertEquals("key_0", item0.getKey());
Assert.assertEquals("updated_value_0", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertEquals("updated", item0.getDataChangeLastModifiedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
Assert.assertNotNull(item0.getDataChangeLastModifiedTime());
}
@Test
@Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testItemSetDeleted() {
String appId = "someAppId";
AppDTO app =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default",
ClusterDTO.class);
NamespaceDTO namespace =
restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId()
+ "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
for (int i = 0; i < createdSize; i++) {
ItemDTO item = new ItemDTO();
item.setNamespaceId(namespace.getId());
item.setKey("key_" + i);
item.setValue("created_value_" + i);
createChangeSet.addCreateItem(item);
}
ResponseEntity<Void> response = createdTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
createChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ItemDTO[] items =
restTemplate.getForObject(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/"
+ cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items",
ItemDTO[].class);
ItemChangeSets deleteChangeSet = new ItemChangeSets();
deleteChangeSet.setDataChangeLastModifiedBy("deleted");
RestTemplate deletedTemplate = (new TestRestTemplate()).getRestTemplate();
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
int deletedSize = 1;
for (int i = 0; i < deletedSize; i++) {
items[i].setValue("deleted_value_" + i);
deleteChangeSet.addDeleteItem(items[i]);
}
response = deletedTemplate.postForEntity(
"http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName()
+ "/namespaces/" + namespace.getNamespaceName() + "/itemset",
deleteChangeSet, Void.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
List<Item> savedItems = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Assert.assertEquals(createdSize - deletedSize, savedItems.size());
Item item0 = savedItems.get(0);
Assert.assertEquals("key_1", item0.getKey());
Assert.assertEquals("created_value_1", item0.getValue());
Assert.assertEquals("created", item0.getDataChangeCreatedBy());
Assert.assertNotNull(item0.getDataChangeCreatedTime());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/biz/service/AccessKeyServiceTest.java | package com.ctrip.framework.apollo.biz.service;
import static org.junit.Assert.assertNotNull;
import com.ctrip.framework.apollo.biz.AbstractIntegrationTest;
import com.ctrip.framework.apollo.biz.entity.AccessKey;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author nisiyong
*/
public class AccessKeyServiceTest extends AbstractIntegrationTest {
@Autowired
private AccessKeyService accessKeyService;
@Test
public void testCreate() {
String appId = "someAppId";
String secret = "someSecret";
AccessKey entity = assembleAccessKey(appId, secret);
AccessKey accessKey = accessKeyService.create(appId, entity);
assertNotNull(accessKey);
}
@Test(expected = BadRequestException.class)
public void testCreateWithException() {
String appId = "someAppId";
String secret = "someSecret";
int maxCount = 5;
for (int i = 0; i <= maxCount; i++) {
AccessKey entity = assembleAccessKey(appId, secret);
accessKeyService.create(appId, entity);
}
}
private AccessKey assembleAccessKey(String appId, String secret) {
AccessKey accessKey = new AccessKey();
accessKey.setAppId(appId);
accessKey.setSecret(secret);
return accessKey;
}
} | package com.ctrip.framework.apollo.biz.service;
import static org.junit.Assert.assertNotNull;
import com.ctrip.framework.apollo.biz.AbstractIntegrationTest;
import com.ctrip.framework.apollo.biz.entity.AccessKey;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author nisiyong
*/
public class AccessKeyServiceTest extends AbstractIntegrationTest {
@Autowired
private AccessKeyService accessKeyService;
@Test
public void testCreate() {
String appId = "someAppId";
String secret = "someSecret";
AccessKey entity = assembleAccessKey(appId, secret);
AccessKey accessKey = accessKeyService.create(appId, entity);
assertNotNull(accessKey);
}
@Test(expected = BadRequestException.class)
public void testCreateWithException() {
String appId = "someAppId";
String secret = "someSecret";
int maxCount = 5;
for (int i = 0; i <= maxCount; i++) {
AccessKey entity = assembleAccessKey(appId, secret);
accessKeyService.create(appId, entity);
}
}
private AccessKey assembleAccessKey(String appId, String secret) {
AccessKey accessKey = new AccessKey();
accessKey.setAppId(appId);
accessKey.setSecret(secret);
return accessKey;
}
} | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/entity/vo/EnvironmentInfo.java | package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.portal.environment.Env;
public class EnvironmentInfo {
private String env;
private boolean active;
private String metaServerAddress;
private ServiceDTO[] configServices;
private ServiceDTO[] adminServices;
private String errorMessage;
public Env getEnv() {
return Env.valueOf(env);
}
public void setEnv(Env env) {
this.env = env.toString();
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getMetaServerAddress() {
return metaServerAddress;
}
public void setMetaServerAddress(String metaServerAddress) {
this.metaServerAddress = metaServerAddress;
}
public ServiceDTO[] getConfigServices() {
return configServices;
}
public void setConfigServices(ServiceDTO[] configServices) {
this.configServices = configServices;
}
public ServiceDTO[] getAdminServices() {
return adminServices;
}
public void setAdminServices(ServiceDTO[] adminServices) {
this.adminServices = adminServices;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
| package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.portal.environment.Env;
public class EnvironmentInfo {
private String env;
private boolean active;
private String metaServerAddress;
private ServiceDTO[] configServices;
private ServiceDTO[] adminServices;
private String errorMessage;
public Env getEnv() {
return Env.valueOf(env);
}
public void setEnv(Env env) {
this.env = env.toString();
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getMetaServerAddress() {
return metaServerAddress;
}
public void setMetaServerAddress(String metaServerAddress) {
this.metaServerAddress = metaServerAddress;
}
public ServiceDTO[] getConfigServices() {
return configServices;
}
public void setConfigServices(ServiceDTO[] configServices) {
this.configServices = configServices;
}
public ServiceDTO[] getAdminServices() {
return adminServices;
}
public void setAdminServices(ServiceDTO[] adminServices) {
this.adminServices = adminServices;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/entity/vo/SystemInfo.java | package com.ctrip.framework.apollo.portal.entity.vo;
import com.google.common.collect.Lists;
import java.util.List;
public class SystemInfo {
private String version;
private List<EnvironmentInfo> environments = Lists.newLinkedList();
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public List<EnvironmentInfo> getEnvironments() {
return environments;
}
public void addEnvironment(EnvironmentInfo environment) {
this.environments.add(environment);
}
}
| package com.ctrip.framework.apollo.portal.entity.vo;
import com.google.common.collect.Lists;
import java.util.List;
public class SystemInfo {
private String version;
private List<EnvironmentInfo> environments = Lists.newLinkedList();
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public List<EnvironmentInfo> getEnvironments() {
return environments;
}
public void addEnvironment(EnvironmentInfo environment) {
this.environments.add(environment);
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/component/ItemsComparator.java | package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Component
public class ItemsComparator {
public ItemChangeSets compareIgnoreBlankAndCommentItem(long baseNamespaceId, List<ItemDTO> baseItems, List<ItemDTO> targetItems){
List<ItemDTO> filteredSourceItems = filterBlankAndCommentItem(baseItems);
List<ItemDTO> filteredTargetItems = filterBlankAndCommentItem(targetItems);
Map<String, ItemDTO> sourceItemMap = BeanUtils.mapByKey("key", filteredSourceItems);
Map<String, ItemDTO> targetItemMap = BeanUtils.mapByKey("key", filteredTargetItems);
ItemChangeSets changeSets = new ItemChangeSets();
for (ItemDTO item: targetItems){
String key = item.getKey();
ItemDTO sourceItem = sourceItemMap.get(key);
if (sourceItem == null){//add
ItemDTO copiedItem = copyItem(item);
copiedItem.setNamespaceId(baseNamespaceId);
changeSets.addCreateItem(copiedItem);
}else if (!Objects.equals(sourceItem.getValue(), item.getValue())){//update
//only value & comment can be update
sourceItem.setValue(item.getValue());
sourceItem.setComment(item.getComment());
changeSets.addUpdateItem(sourceItem);
}
}
for (ItemDTO item: baseItems){
String key = item.getKey();
ItemDTO targetItem = targetItemMap.get(key);
if(targetItem == null){//delete
changeSets.addDeleteItem(item);
}
}
return changeSets;
}
private List<ItemDTO> filterBlankAndCommentItem(List<ItemDTO> items){
List<ItemDTO> result = new LinkedList<>();
if (CollectionUtils.isEmpty(items)){
return result;
}
for (ItemDTO item: items){
if (!StringUtils.isEmpty(item.getKey())){
result.add(item);
}
}
return result;
}
private ItemDTO copyItem(ItemDTO sourceItem){
ItemDTO copiedItem = new ItemDTO();
copiedItem.setKey(sourceItem.getKey());
copiedItem.setValue(sourceItem.getValue());
copiedItem.setComment(sourceItem.getComment());
return copiedItem;
}
}
| package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Component
public class ItemsComparator {
public ItemChangeSets compareIgnoreBlankAndCommentItem(long baseNamespaceId, List<ItemDTO> baseItems, List<ItemDTO> targetItems){
List<ItemDTO> filteredSourceItems = filterBlankAndCommentItem(baseItems);
List<ItemDTO> filteredTargetItems = filterBlankAndCommentItem(targetItems);
Map<String, ItemDTO> sourceItemMap = BeanUtils.mapByKey("key", filteredSourceItems);
Map<String, ItemDTO> targetItemMap = BeanUtils.mapByKey("key", filteredTargetItems);
ItemChangeSets changeSets = new ItemChangeSets();
for (ItemDTO item: targetItems){
String key = item.getKey();
ItemDTO sourceItem = sourceItemMap.get(key);
if (sourceItem == null){//add
ItemDTO copiedItem = copyItem(item);
copiedItem.setNamespaceId(baseNamespaceId);
changeSets.addCreateItem(copiedItem);
}else if (!Objects.equals(sourceItem.getValue(), item.getValue())){//update
//only value & comment can be update
sourceItem.setValue(item.getValue());
sourceItem.setComment(item.getComment());
changeSets.addUpdateItem(sourceItem);
}
}
for (ItemDTO item: baseItems){
String key = item.getKey();
ItemDTO targetItem = targetItemMap.get(key);
if(targetItem == null){//delete
changeSets.addDeleteItem(item);
}
}
return changeSets;
}
private List<ItemDTO> filterBlankAndCommentItem(List<ItemDTO> items){
List<ItemDTO> result = new LinkedList<>();
if (CollectionUtils.isEmpty(items)){
return result;
}
for (ItemDTO item: items){
if (!StringUtils.isEmpty(item.getKey())){
result.add(item);
}
}
return result;
}
private ItemDTO copyItem(ItemDTO sourceItem){
ItemDTO copiedItem = new ItemDTO();
copiedItem.setKey(sourceItem.getKey());
copiedItem.setValue(sourceItem.getValue());
copiedItem.setComment(sourceItem.getComment());
return copiedItem;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/spring/boot/ApolloApplicationContextInitializerTest.java | package com.ctrip.framework.apollo.spring.boot;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.core.ConfigConsts;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
public class ApolloApplicationContextInitializerTest {
private ApolloApplicationContextInitializer apolloApplicationContextInitializer;
@Before
public void setUp() throws Exception {
apolloApplicationContextInitializer = new ApolloApplicationContextInitializer();
}
@After
public void tearDown() throws Exception {
System.clearProperty("app.id");
System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY);
System.clearProperty("apollo.cacheDir");
System.clearProperty(ConfigConsts.APOLLO_META_KEY);
}
@Test
public void testFillFromEnvironment() throws Exception {
String someAppId = "someAppId";
String someCluster = "someCluster";
String someCacheDir = "someCacheDir";
String someApolloMeta = "someApolloMeta";
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
when(environment.getProperty("app.id")).thenReturn(someAppId);
when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(someCluster);
when(environment.getProperty("apollo.cacheDir")).thenReturn(someCacheDir);
when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(someApolloMeta);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertEquals(someAppId, System.getProperty("app.id"));
assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertEquals(someCacheDir, System.getProperty("apollo.cacheDir"));
assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
@Test
public void testFillFromEnvironmentWithSystemPropertyAlreadyFilled() throws Exception {
String someAppId = "someAppId";
String someCluster = "someCluster";
String someCacheDir = "someCacheDir";
String someApolloMeta = "someApolloMeta";
System.setProperty("app.id", someAppId);
System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster);
System.setProperty("apollo.cacheDir", someCacheDir);
System.setProperty(ConfigConsts.APOLLO_META_KEY, someApolloMeta);
String anotherAppId = "anotherAppId";
String anotherCluster = "anotherCluster";
String anotherCacheDir = "anotherCacheDir";
String anotherApolloMeta = "anotherApolloMeta";
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
when(environment.getProperty("app.id")).thenReturn(anotherAppId);
when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(anotherCluster);
when(environment.getProperty("apollo.cacheDir")).thenReturn(anotherCacheDir);
when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(anotherApolloMeta);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertEquals(someAppId, System.getProperty("app.id"));
assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertEquals(someCacheDir, System.getProperty("apollo.cacheDir"));
assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
@Test
public void testFillFromEnvironmentWithNoPropertyFromEnvironment() throws Exception {
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertNull(System.getProperty("app.id"));
assertNull(System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertNull(System.getProperty("apollo.cacheDir"));
assertNull(System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
}
| package com.ctrip.framework.apollo.spring.boot;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.core.ConfigConsts;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
public class ApolloApplicationContextInitializerTest {
private ApolloApplicationContextInitializer apolloApplicationContextInitializer;
@Before
public void setUp() throws Exception {
apolloApplicationContextInitializer = new ApolloApplicationContextInitializer();
}
@After
public void tearDown() throws Exception {
System.clearProperty("app.id");
System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY);
System.clearProperty("apollo.cacheDir");
System.clearProperty(ConfigConsts.APOLLO_META_KEY);
}
@Test
public void testFillFromEnvironment() throws Exception {
String someAppId = "someAppId";
String someCluster = "someCluster";
String someCacheDir = "someCacheDir";
String someApolloMeta = "someApolloMeta";
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
when(environment.getProperty("app.id")).thenReturn(someAppId);
when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(someCluster);
when(environment.getProperty("apollo.cacheDir")).thenReturn(someCacheDir);
when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(someApolloMeta);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertEquals(someAppId, System.getProperty("app.id"));
assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertEquals(someCacheDir, System.getProperty("apollo.cacheDir"));
assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
@Test
public void testFillFromEnvironmentWithSystemPropertyAlreadyFilled() throws Exception {
String someAppId = "someAppId";
String someCluster = "someCluster";
String someCacheDir = "someCacheDir";
String someApolloMeta = "someApolloMeta";
System.setProperty("app.id", someAppId);
System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster);
System.setProperty("apollo.cacheDir", someCacheDir);
System.setProperty(ConfigConsts.APOLLO_META_KEY, someApolloMeta);
String anotherAppId = "anotherAppId";
String anotherCluster = "anotherCluster";
String anotherCacheDir = "anotherCacheDir";
String anotherApolloMeta = "anotherApolloMeta";
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
when(environment.getProperty("app.id")).thenReturn(anotherAppId);
when(environment.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY)).thenReturn(anotherCluster);
when(environment.getProperty("apollo.cacheDir")).thenReturn(anotherCacheDir);
when(environment.getProperty(ConfigConsts.APOLLO_META_KEY)).thenReturn(anotherApolloMeta);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertEquals(someAppId, System.getProperty("app.id"));
assertEquals(someCluster, System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertEquals(someCacheDir, System.getProperty("apollo.cacheDir"));
assertEquals(someApolloMeta, System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
@Test
public void testFillFromEnvironmentWithNoPropertyFromEnvironment() throws Exception {
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
apolloApplicationContextInitializer.initializeSystemProperty(environment);
assertNull(System.getProperty("app.id"));
assertNull(System.getProperty(ConfigConsts.APOLLO_CLUSTER_KEY));
assertNull(System.getProperty("apollo.cacheDir"));
assertNull(System.getProperty(ConfigConsts.APOLLO_META_KEY));
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/util/parser/Parsers.java | package com.ctrip.framework.apollo.util.parser;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Parsers {
public static DateParser forDate() {
return DateParser.INSTANCE;
}
public static DurationParser forDuration() {
return DurationParser.INSTANCE;
}
public enum DateParser {
INSTANCE;
private static final String LONG_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
private static final String MEDIUM_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static final String SHORT_DATE_FORMAT = "yyyy-MM-dd";
/**
* Will try to parse the date with Locale.US and formats as follows:
* yyyy-MM-dd HH:mm:ss.SSS, yyyy-MM-dd HH:mm:ss and yyyy-MM-dd
*
* @param text the text to parse
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text) throws ParserException {
text = text.trim();
int length = text.length();
if (length == LONG_DATE_FORMAT.length()) {
return parse(text, LONG_DATE_FORMAT);
}
if (length == MEDIUM_DATE_FORMAT.length()) {
return parse(text, MEDIUM_DATE_FORMAT);
}
return parse(text, SHORT_DATE_FORMAT);
}
/**
* Parse the text with the format specified and Locale.US
*
* @param text the text to parse
* @param format the date format, see {@link java.text.SimpleDateFormat} for more information
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text, String format) throws ParserException {
return parse(text, format, Locale.US);
}
/**
* Parse the text with the format and locale specified
*
* @param text the text to parse
* @param format the date format, see {@link java.text.SimpleDateFormat} for more information
* @param locale the locale
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text, String format, Locale locale) throws ParserException {
SimpleDateFormat dateFormat = getDateFormat(format, locale);
try {
return dateFormat.parse(text.trim());
} catch (ParseException e) {
throw new ParserException("Error when parsing date(" + dateFormat.toPattern() + ") from " + text, e);
}
}
private SimpleDateFormat getDateFormat(String format, Locale locale) {
return new SimpleDateFormat(format, locale);
}
}
public enum DurationParser {
INSTANCE;
private static final Pattern PATTERN =
Pattern.compile("(?:([0-9]+)D)?(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+)S)?(?:([0-9]+)(?:MS)?)?",
Pattern.CASE_INSENSITIVE);
private static final int HOURS_PER_DAY = 24;
private static final int MINUTES_PER_HOUR = 60;
private static final int SECONDS_PER_MINUTE = 60;
private static final int MILLIS_PER_SECOND = 1000;
private static final int MILLIS_PER_MINUTE = MILLIS_PER_SECOND * SECONDS_PER_MINUTE;
private static final int MILLIS_PER_HOUR = MILLIS_PER_MINUTE * MINUTES_PER_HOUR;
private static final int MILLIS_PER_DAY = MILLIS_PER_HOUR * HOURS_PER_DAY;
public long parseToMillis(String text) throws ParserException {
Matcher matcher = PATTERN.matcher(text);
if (matcher.matches()) {
String dayMatch = matcher.group(1);
String hourMatch = matcher.group(2);
String minuteMatch = matcher.group(3);
String secondMatch = matcher.group(4);
String fractionMatch = matcher.group(5);
if (dayMatch != null || hourMatch != null || minuteMatch != null || secondMatch != null || fractionMatch != null) {
int daysAsMilliSecs = parseNumber(dayMatch, MILLIS_PER_DAY);
int hoursAsMilliSecs = parseNumber(hourMatch, MILLIS_PER_HOUR);
int minutesAsMilliSecs = parseNumber(minuteMatch, MILLIS_PER_MINUTE);
int secondsAsMilliSecs = parseNumber(secondMatch, MILLIS_PER_SECOND);
int milliseconds = parseNumber(fractionMatch, 1);
return daysAsMilliSecs + hoursAsMilliSecs + minutesAsMilliSecs + secondsAsMilliSecs + milliseconds;
}
}
throw new ParserException(String.format("Text %s cannot be parsed to duration)", text));
}
private static int parseNumber(String parsed, int multiplier) {
// regex limits to [0-9]+
if (parsed == null || parsed.trim().isEmpty()) {
return 0;
}
return Integer.parseInt(parsed) * multiplier;
}
}
}
| package com.ctrip.framework.apollo.util.parser;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Parsers {
public static DateParser forDate() {
return DateParser.INSTANCE;
}
public static DurationParser forDuration() {
return DurationParser.INSTANCE;
}
public enum DateParser {
INSTANCE;
private static final String LONG_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
private static final String MEDIUM_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static final String SHORT_DATE_FORMAT = "yyyy-MM-dd";
/**
* Will try to parse the date with Locale.US and formats as follows:
* yyyy-MM-dd HH:mm:ss.SSS, yyyy-MM-dd HH:mm:ss and yyyy-MM-dd
*
* @param text the text to parse
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text) throws ParserException {
text = text.trim();
int length = text.length();
if (length == LONG_DATE_FORMAT.length()) {
return parse(text, LONG_DATE_FORMAT);
}
if (length == MEDIUM_DATE_FORMAT.length()) {
return parse(text, MEDIUM_DATE_FORMAT);
}
return parse(text, SHORT_DATE_FORMAT);
}
/**
* Parse the text with the format specified and Locale.US
*
* @param text the text to parse
* @param format the date format, see {@link java.text.SimpleDateFormat} for more information
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text, String format) throws ParserException {
return parse(text, format, Locale.US);
}
/**
* Parse the text with the format and locale specified
*
* @param text the text to parse
* @param format the date format, see {@link java.text.SimpleDateFormat} for more information
* @param locale the locale
* @return the parsed date
* @throws ParserException if the text cannot be parsed
*/
public Date parse(String text, String format, Locale locale) throws ParserException {
SimpleDateFormat dateFormat = getDateFormat(format, locale);
try {
return dateFormat.parse(text.trim());
} catch (ParseException e) {
throw new ParserException("Error when parsing date(" + dateFormat.toPattern() + ") from " + text, e);
}
}
private SimpleDateFormat getDateFormat(String format, Locale locale) {
return new SimpleDateFormat(format, locale);
}
}
public enum DurationParser {
INSTANCE;
private static final Pattern PATTERN =
Pattern.compile("(?:([0-9]+)D)?(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+)S)?(?:([0-9]+)(?:MS)?)?",
Pattern.CASE_INSENSITIVE);
private static final int HOURS_PER_DAY = 24;
private static final int MINUTES_PER_HOUR = 60;
private static final int SECONDS_PER_MINUTE = 60;
private static final int MILLIS_PER_SECOND = 1000;
private static final int MILLIS_PER_MINUTE = MILLIS_PER_SECOND * SECONDS_PER_MINUTE;
private static final int MILLIS_PER_HOUR = MILLIS_PER_MINUTE * MINUTES_PER_HOUR;
private static final int MILLIS_PER_DAY = MILLIS_PER_HOUR * HOURS_PER_DAY;
public long parseToMillis(String text) throws ParserException {
Matcher matcher = PATTERN.matcher(text);
if (matcher.matches()) {
String dayMatch = matcher.group(1);
String hourMatch = matcher.group(2);
String minuteMatch = matcher.group(3);
String secondMatch = matcher.group(4);
String fractionMatch = matcher.group(5);
if (dayMatch != null || hourMatch != null || minuteMatch != null || secondMatch != null || fractionMatch != null) {
int daysAsMilliSecs = parseNumber(dayMatch, MILLIS_PER_DAY);
int hoursAsMilliSecs = parseNumber(hourMatch, MILLIS_PER_HOUR);
int minutesAsMilliSecs = parseNumber(minuteMatch, MILLIS_PER_MINUTE);
int secondsAsMilliSecs = parseNumber(secondMatch, MILLIS_PER_SECOND);
int milliseconds = parseNumber(fractionMatch, 1);
return daysAsMilliSecs + hoursAsMilliSecs + minutesAsMilliSecs + secondsAsMilliSecs + milliseconds;
}
}
throw new ParserException(String.format("Text %s cannot be parsed to duration)", text));
}
private static int parseNumber(String parsed, int multiplier) {
// regex limits to [0-9]+
if (parsed == null || parsed.trim().isEmpty()) {
return 0;
}
return Integer.parseInt(parsed) * multiplier;
}
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/util/RelativeDateFormat.java | package com.ctrip.framework.apollo.portal.util;
import org.apache.commons.lang.time.FastDateFormat;
import java.util.Calendar;
import java.util.Date;
public class RelativeDateFormat {
private static final FastDateFormat TIMESTAMP_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd");
private static final long ONE_MINUTE = 60000L;
private static final long ONE_HOUR = 3600000L;
private static final long ONE_DAY = 86400000L;
private static final String ONE_SECOND_AGO = " seconds ago";
private static final String ONE_MINUTE_AGO = " minutes ago";
private static final String ONE_HOUR_AGO = " hours ago";
private static final String ONE_DAY_AGO = " days ago";
private static final String ONE_MONTH_AGO = " months ago";
public static String format(Date date) {
if (date.after(new Date())) {
return "now";
}
long delta = new Date().getTime() - date.getTime();
if (delta < ONE_MINUTE) {
long seconds = toSeconds(delta);
return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO;
}
if (delta < 45L * ONE_MINUTE) {
long minutes = toMinutes(delta);
return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO;
}
if (delta < 24L * ONE_HOUR) {
long hours = toHours(delta);
return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
}
Date lastDayBeginTime = getDateOffset(-1);
if (date.after(lastDayBeginTime)) {
return "yesterday";
}
Date lastTwoDaysBeginTime = getDateOffset(-2);
if (date.after(lastTwoDaysBeginTime)) {
return "the day before yesterday";
}
if (delta < 30L * ONE_DAY) {
long days = toDays(delta);
return (days <= 0 ? 1 : days) + ONE_DAY_AGO;
}
long months = toMonths(delta);
if (months <= 3) {
return (months <= 0 ? 1 : months) + ONE_MONTH_AGO;
}
return TIMESTAMP_FORMAT.format(date);
}
private static long toSeconds(long date) {
return date / 1000L;
}
private static long toMinutes(long date) {
return toSeconds(date) / 60L;
}
private static long toHours(long date) {
return toMinutes(date) / 60L;
}
private static long toDays(long date) {
return toHours(date) / 24L;
}
private static long toMonths(long date) {
return toDays(date) / 30L;
}
public static Date getDateOffset(int offset) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, offset);
return getDayBeginTime(calendar.getTime());
}
private static Date getDayBeginTime(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return new Date(calendar.getTime().getTime());
}
}
| package com.ctrip.framework.apollo.portal.util;
import org.apache.commons.lang.time.FastDateFormat;
import java.util.Calendar;
import java.util.Date;
public class RelativeDateFormat {
private static final FastDateFormat TIMESTAMP_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd");
private static final long ONE_MINUTE = 60000L;
private static final long ONE_HOUR = 3600000L;
private static final long ONE_DAY = 86400000L;
private static final String ONE_SECOND_AGO = " seconds ago";
private static final String ONE_MINUTE_AGO = " minutes ago";
private static final String ONE_HOUR_AGO = " hours ago";
private static final String ONE_DAY_AGO = " days ago";
private static final String ONE_MONTH_AGO = " months ago";
public static String format(Date date) {
if (date.after(new Date())) {
return "now";
}
long delta = new Date().getTime() - date.getTime();
if (delta < ONE_MINUTE) {
long seconds = toSeconds(delta);
return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO;
}
if (delta < 45L * ONE_MINUTE) {
long minutes = toMinutes(delta);
return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO;
}
if (delta < 24L * ONE_HOUR) {
long hours = toHours(delta);
return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
}
Date lastDayBeginTime = getDateOffset(-1);
if (date.after(lastDayBeginTime)) {
return "yesterday";
}
Date lastTwoDaysBeginTime = getDateOffset(-2);
if (date.after(lastTwoDaysBeginTime)) {
return "the day before yesterday";
}
if (delta < 30L * ONE_DAY) {
long days = toDays(delta);
return (days <= 0 ? 1 : days) + ONE_DAY_AGO;
}
long months = toMonths(delta);
if (months <= 3) {
return (months <= 0 ? 1 : months) + ONE_MONTH_AGO;
}
return TIMESTAMP_FORMAT.format(date);
}
private static long toSeconds(long date) {
return date / 1000L;
}
private static long toMinutes(long date) {
return toSeconds(date) / 60L;
}
private static long toHours(long date) {
return toMinutes(date) / 60L;
}
private static long toDays(long date) {
return toHours(date) / 24L;
}
private static long toMonths(long date) {
return toDays(date) / 30L;
}
public static Date getDateOffset(int offset) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, offset);
return getDayBeginTime(calendar.getTime());
}
private static Date getDayBeginTime(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return new Date(calendar.getTime().getTime());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/dto/BaseDTO.java | package com.ctrip.framework.apollo.openapi.dto;
import java.util.Date;
public class BaseDTO {
protected String dataChangeCreatedBy;
protected String dataChangeLastModifiedBy;
protected Date dataChangeCreatedTime;
protected Date dataChangeLastModifiedTime;
public String getDataChangeCreatedBy() {
return dataChangeCreatedBy;
}
public void setDataChangeCreatedBy(String dataChangeCreatedBy) {
this.dataChangeCreatedBy = dataChangeCreatedBy;
}
public String getDataChangeLastModifiedBy() {
return dataChangeLastModifiedBy;
}
public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) {
this.dataChangeLastModifiedBy = dataChangeLastModifiedBy;
}
public Date getDataChangeCreatedTime() {
return dataChangeCreatedTime;
}
public void setDataChangeCreatedTime(Date dataChangeCreatedTime) {
this.dataChangeCreatedTime = dataChangeCreatedTime;
}
public Date getDataChangeLastModifiedTime() {
return dataChangeLastModifiedTime;
}
public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) {
this.dataChangeLastModifiedTime = dataChangeLastModifiedTime;
}
}
| package com.ctrip.framework.apollo.openapi.dto;
import java.util.Date;
public class BaseDTO {
protected String dataChangeCreatedBy;
protected String dataChangeLastModifiedBy;
protected Date dataChangeCreatedTime;
protected Date dataChangeLastModifiedTime;
public String getDataChangeCreatedBy() {
return dataChangeCreatedBy;
}
public void setDataChangeCreatedBy(String dataChangeCreatedBy) {
this.dataChangeCreatedBy = dataChangeCreatedBy;
}
public String getDataChangeLastModifiedBy() {
return dataChangeLastModifiedBy;
}
public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) {
this.dataChangeLastModifiedBy = dataChangeLastModifiedBy;
}
public Date getDataChangeCreatedTime() {
return dataChangeCreatedTime;
}
public void setDataChangeCreatedTime(Date dataChangeCreatedTime) {
this.dataChangeCreatedTime = dataChangeCreatedTime;
}
public Date getDataChangeLastModifiedTime() {
return dataChangeLastModifiedTime;
}
public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) {
this.dataChangeLastModifiedTime = dataChangeLastModifiedTime;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/service/FavoriteService.java | package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.po.Favorite;
import com.ctrip.framework.apollo.portal.repository.FavoriteRepository;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
import java.util.Collections;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Service
public class FavoriteService {
public static final long POSITION_DEFAULT = 10000;
private final UserInfoHolder userInfoHolder;
private final FavoriteRepository favoriteRepository;
private final UserService userService;
public FavoriteService(
final UserInfoHolder userInfoHolder,
final FavoriteRepository favoriteRepository,
final UserService userService) {
this.userInfoHolder = userInfoHolder;
this.favoriteRepository = favoriteRepository;
this.userService = userService;
}
public Favorite addFavorite(Favorite favorite) {
UserInfo user = userService.findByUserId(favorite.getUserId());
if (user == null) {
throw new BadRequestException("user not exist");
}
UserInfo loginUser = userInfoHolder.getUser();
//user can only add himself favorite app
if (!loginUser.equals(user)) {
throw new BadRequestException("add favorite fail. "
+ "because favorite's user is not current login user.");
}
Favorite checkedFavorite = favoriteRepository.findByUserIdAndAppId(loginUser.getUserId(), favorite.getAppId());
if (checkedFavorite != null) {
return checkedFavorite;
}
favorite.setPosition(POSITION_DEFAULT);
favorite.setDataChangeCreatedBy(user.getUserId());
favorite.setDataChangeLastModifiedBy(user.getUserId());
return favoriteRepository.save(favorite);
}
public List<Favorite> search(String userId, String appId, Pageable page) {
boolean isUserIdEmpty = StringUtils.isEmpty(userId);
boolean isAppIdEmpty = StringUtils.isEmpty(appId);
if (isAppIdEmpty && isUserIdEmpty) {
throw new BadRequestException("user id and app id can't be empty at the same time");
}
if (!isUserIdEmpty) {
UserInfo loginUser = userInfoHolder.getUser();
//user can only search his own favorite app
if (!Objects.equals(loginUser.getUserId(), userId)) {
userId = loginUser.getUserId();
}
}
//search by userId
if (isAppIdEmpty && !isUserIdEmpty) {
return favoriteRepository.findByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId, page);
}
//search by appId
if (!isAppIdEmpty && isUserIdEmpty) {
return favoriteRepository.findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc(appId, page);
}
//search by userId and appId
return Collections.singletonList(favoriteRepository.findByUserIdAndAppId(userId, appId));
}
public void deleteFavorite(long favoriteId) {
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
checkUserOperatePermission(favorite);
favoriteRepository.delete(favorite);
}
public void adjustFavoriteToFirst(long favoriteId) {
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
checkUserOperatePermission(favorite);
String userId = favorite.getUserId();
Favorite firstFavorite = favoriteRepository.findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId);
long minPosition = firstFavorite.getPosition();
favorite.setPosition(minPosition - 1);
favoriteRepository.save(favorite);
}
private void checkUserOperatePermission(Favorite favorite) {
if (favorite == null) {
throw new BadRequestException("favorite not exist");
}
if (!Objects.equals(userInfoHolder.getUser().getUserId(), favorite.getUserId())) {
throw new BadRequestException("can not operate other person's favorite");
}
}
public void batchDeleteByAppId(String appId, String operator) {
favoriteRepository.batchDeleteByAppId(appId, operator);
}
}
| package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.po.Favorite;
import com.ctrip.framework.apollo.portal.repository.FavoriteRepository;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
import java.util.Collections;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Service
public class FavoriteService {
public static final long POSITION_DEFAULT = 10000;
private final UserInfoHolder userInfoHolder;
private final FavoriteRepository favoriteRepository;
private final UserService userService;
public FavoriteService(
final UserInfoHolder userInfoHolder,
final FavoriteRepository favoriteRepository,
final UserService userService) {
this.userInfoHolder = userInfoHolder;
this.favoriteRepository = favoriteRepository;
this.userService = userService;
}
public Favorite addFavorite(Favorite favorite) {
UserInfo user = userService.findByUserId(favorite.getUserId());
if (user == null) {
throw new BadRequestException("user not exist");
}
UserInfo loginUser = userInfoHolder.getUser();
//user can only add himself favorite app
if (!loginUser.equals(user)) {
throw new BadRequestException("add favorite fail. "
+ "because favorite's user is not current login user.");
}
Favorite checkedFavorite = favoriteRepository.findByUserIdAndAppId(loginUser.getUserId(), favorite.getAppId());
if (checkedFavorite != null) {
return checkedFavorite;
}
favorite.setPosition(POSITION_DEFAULT);
favorite.setDataChangeCreatedBy(user.getUserId());
favorite.setDataChangeLastModifiedBy(user.getUserId());
return favoriteRepository.save(favorite);
}
public List<Favorite> search(String userId, String appId, Pageable page) {
boolean isUserIdEmpty = StringUtils.isEmpty(userId);
boolean isAppIdEmpty = StringUtils.isEmpty(appId);
if (isAppIdEmpty && isUserIdEmpty) {
throw new BadRequestException("user id and app id can't be empty at the same time");
}
if (!isUserIdEmpty) {
UserInfo loginUser = userInfoHolder.getUser();
//user can only search his own favorite app
if (!Objects.equals(loginUser.getUserId(), userId)) {
userId = loginUser.getUserId();
}
}
//search by userId
if (isAppIdEmpty && !isUserIdEmpty) {
return favoriteRepository.findByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId, page);
}
//search by appId
if (!isAppIdEmpty && isUserIdEmpty) {
return favoriteRepository.findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc(appId, page);
}
//search by userId and appId
return Collections.singletonList(favoriteRepository.findByUserIdAndAppId(userId, appId));
}
public void deleteFavorite(long favoriteId) {
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
checkUserOperatePermission(favorite);
favoriteRepository.delete(favorite);
}
public void adjustFavoriteToFirst(long favoriteId) {
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
checkUserOperatePermission(favorite);
String userId = favorite.getUserId();
Favorite firstFavorite = favoriteRepository.findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId);
long minPosition = firstFavorite.getPosition();
favorite.setPosition(minPosition - 1);
favoriteRepository.save(favorite);
}
private void checkUserOperatePermission(Favorite favorite) {
if (favorite == null) {
throw new BadRequestException("favorite not exist");
}
if (!Objects.equals(userInfoHolder.getUser().getUserId(), favorite.getUserId())) {
throw new BadRequestException("can not operate other person's favorite");
}
}
public void batchDeleteByAppId(String appId, String operator) {
favoriteRepository.batchDeleteByAppId(appId, operator);
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-common/src/main/java/com/ctrip/framework/apollo/common/dto/NamespaceLockDTO.java | package com.ctrip.framework.apollo.common.dto;
public class NamespaceLockDTO extends BaseDTO{
private long namespaceId;
public long getNamespaceId() {
return namespaceId;
}
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
}
}
| package com.ctrip.framework.apollo.common.dto;
public class NamespaceLockDTO extends BaseDTO{
private long namespaceId;
public long getNamespaceId() {
return namespaceId;
}
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-core/src/main/java/com/ctrip/framework/apollo/tracer/internals/NullTransaction.java | package com.ctrip.framework.apollo.tracer.internals;
import com.ctrip.framework.apollo.tracer.spi.Transaction;
/**
* @author Jason Song([email protected])
*/
public class NullTransaction implements Transaction {
@Override
public void setStatus(String status) {
}
@Override
public void setStatus(Throwable e) {
}
@Override
public void addData(String key, Object value) {
}
@Override
public void complete() {
}
}
| package com.ctrip.framework.apollo.tracer.internals;
import com.ctrip.framework.apollo.tracer.spi.Transaction;
/**
* @author Jason Song([email protected])
*/
public class NullTransaction implements Transaction {
@Override
public void setStatus(String status) {
}
@Override
public void setStatus(Throwable e) {
}
@Override
public void addData(String key, Object value) {
}
@Override
public void complete() {
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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 | 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;
}
}
| 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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/metaservice/service/KubernetesDiscoveryService.java | package com.ctrip.framework.apollo.metaservice.service;
import com.ctrip.framework.apollo.biz.config.BizConfig;
import com.ctrip.framework.apollo.core.ServiceNameConsts;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
/**
* This is a simple implementation that skips any service discovery and just return what is configured
*
* <ul>
* <li>getServiceInstances("apollo-configservice") returns ${apollo.config-service.url}</li>
* <li>getServiceInstances("apollo-adminservice") returns ${apollo.admin-service.url}</li>
* </ul>
*/
@Service
@Profile({"kubernetes"})
public class KubernetesDiscoveryService implements DiscoveryService {
private static final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
private static final Map<String, String> SERVICE_ID_TO_CONFIG_NAME = ImmutableMap
.of(ServiceNameConsts.APOLLO_CONFIGSERVICE, "apollo.config-service.url",
ServiceNameConsts.APOLLO_ADMINSERVICE, "apollo.admin-service.url");
private final BizConfig bizConfig;
public KubernetesDiscoveryService(final BizConfig bizConfig) {
this.bizConfig = bizConfig;
}
@Override
public List<ServiceDTO> getServiceInstances(String serviceId) {
String configName = SERVICE_ID_TO_CONFIG_NAME.get(serviceId);
if (configName == null) {
return Collections.emptyList();
}
return assembleServiceDTO(serviceId, bizConfig.getValue(configName));
}
private List<ServiceDTO> assembleServiceDTO(String serviceId, String directUrl) {
if (Strings.isNullOrEmpty(directUrl)) {
return Collections.emptyList();
}
List<ServiceDTO> serviceDTOList = Lists.newLinkedList();
COMMA_SPLITTER.split(directUrl).forEach(url -> {
ServiceDTO service = new ServiceDTO();
service.setAppName(serviceId);
service.setInstanceId(String.format("%s:%s", serviceId, url));
service.setHomepageUrl(url);
serviceDTOList.add(service);
});
return serviceDTOList;
}
}
| package com.ctrip.framework.apollo.metaservice.service;
import com.ctrip.framework.apollo.biz.config.BizConfig;
import com.ctrip.framework.apollo.core.ServiceNameConsts;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
/**
* This is a simple implementation that skips any service discovery and just return what is configured
*
* <ul>
* <li>getServiceInstances("apollo-configservice") returns ${apollo.config-service.url}</li>
* <li>getServiceInstances("apollo-adminservice") returns ${apollo.admin-service.url}</li>
* </ul>
*/
@Service
@Profile({"kubernetes"})
public class KubernetesDiscoveryService implements DiscoveryService {
private static final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
private static final Map<String, String> SERVICE_ID_TO_CONFIG_NAME = ImmutableMap
.of(ServiceNameConsts.APOLLO_CONFIGSERVICE, "apollo.config-service.url",
ServiceNameConsts.APOLLO_ADMINSERVICE, "apollo.admin-service.url");
private final BizConfig bizConfig;
public KubernetesDiscoveryService(final BizConfig bizConfig) {
this.bizConfig = bizConfig;
}
@Override
public List<ServiceDTO> getServiceInstances(String serviceId) {
String configName = SERVICE_ID_TO_CONFIG_NAME.get(serviceId);
if (configName == null) {
return Collections.emptyList();
}
return assembleServiceDTO(serviceId, bizConfig.getValue(configName));
}
private List<ServiceDTO> assembleServiceDTO(String serviceId, String directUrl) {
if (Strings.isNullOrEmpty(directUrl)) {
return Collections.emptyList();
}
List<ServiceDTO> serviceDTOList = Lists.newLinkedList();
COMMA_SPLITTER.split(directUrl).forEach(url -> {
ServiceDTO service = new ServiceDTO();
service.setAppName(serviceId);
service.setInstanceId(String.format("%s:%s", serviceId, url));
service.setHomepageUrl(url);
serviceDTOList.add(service);
});
return serviceDTOList;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/entity/Item.java | package com.ctrip.framework.apollo.biz.entity;
import com.ctrip.framework.apollo.common.entity.BaseEntity;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
@Entity
@Table(name = "Item")
@SQLDelete(sql = "Update Item set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
public class Item extends BaseEntity {
@Column(name = "NamespaceId", nullable = false)
private long namespaceId;
@Column(name = "key", nullable = false)
private String key;
@Column(name = "value")
@Lob
private String value;
@Column(name = "comment")
private String comment;
@Column(name = "LineNum")
private Integer lineNum;
public String getComment() {
return comment;
}
public String getKey() {
return key;
}
public long getNamespaceId() {
return namespaceId;
}
public String getValue() {
return value;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setKey(String key) {
this.key = key;
}
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
}
public void setValue(String value) {
this.value = value;
}
public Integer getLineNum() {
return lineNum;
}
public void setLineNum(Integer lineNum) {
this.lineNum = lineNum;
}
public String toString() {
return toStringHelper().add("namespaceId", namespaceId).add("key", key).add("value", value)
.add("lineNum", lineNum).add("comment", comment).toString();
}
}
| package com.ctrip.framework.apollo.biz.entity;
import com.ctrip.framework.apollo.common.entity.BaseEntity;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
@Entity
@Table(name = "Item")
@SQLDelete(sql = "Update Item set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
public class Item extends BaseEntity {
@Column(name = "NamespaceId", nullable = false)
private long namespaceId;
@Column(name = "key", nullable = false)
private String key;
@Column(name = "value")
@Lob
private String value;
@Column(name = "comment")
private String comment;
@Column(name = "LineNum")
private Integer lineNum;
public String getComment() {
return comment;
}
public String getKey() {
return key;
}
public long getNamespaceId() {
return namespaceId;
}
public String getValue() {
return value;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setKey(String key) {
this.key = key;
}
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
}
public void setValue(String value) {
this.value = value;
}
public Integer getLineNum() {
return lineNum;
}
public void setLineNum(Integer lineNum) {
this.lineNum = lineNum;
}
public String toString() {
return toStringHelper().add("namespaceId", namespaceId).add("key", key).add("value", value)
.add("lineNum", lineNum).add("comment", comment).toString();
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/component/ConfigReleaseWebhookNotifier.java | package com.ctrip.framework.apollo.portal.component;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO;
import com.ctrip.framework.apollo.portal.environment.Env;
/**
* publish webHook
*
* @author HuangSheng
*/
@Component
public class ConfigReleaseWebhookNotifier {
private static final Logger logger = LoggerFactory.getLogger(ConfigReleaseWebhookNotifier.class);
private final RestTemplateFactory restTemplateFactory;
private RestTemplate restTemplate;
public ConfigReleaseWebhookNotifier(RestTemplateFactory restTemplateFactory) {
this.restTemplateFactory = restTemplateFactory;
}
@PostConstruct
public void init() {
// init restTemplate
restTemplate = restTemplateFactory.getObject();
}
public void notify(String[] webHookUrls, Env env, ReleaseHistoryBO releaseHistory) {
if (webHookUrls == null) {
return;
}
for (String webHookUrl : webHookUrls) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity entity = new HttpEntity(releaseHistory, headers);
String url = webHookUrl + "?env={env}";
try {
restTemplate.postForObject(url, entity, String.class, env);
} catch (Exception e) {
logger.error("Notify webHook server failed, env: {}, webHook server url:{}", env, url, e);
}
}
}
}
| package com.ctrip.framework.apollo.portal.component;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO;
import com.ctrip.framework.apollo.portal.environment.Env;
/**
* publish webHook
*
* @author HuangSheng
*/
@Component
public class ConfigReleaseWebhookNotifier {
private static final Logger logger = LoggerFactory.getLogger(ConfigReleaseWebhookNotifier.class);
private final RestTemplateFactory restTemplateFactory;
private RestTemplate restTemplate;
public ConfigReleaseWebhookNotifier(RestTemplateFactory restTemplateFactory) {
this.restTemplateFactory = restTemplateFactory;
}
@PostConstruct
public void init() {
// init restTemplate
restTemplate = restTemplateFactory.getObject();
}
public void notify(String[] webHookUrls, Env env, ReleaseHistoryBO releaseHistory) {
if (webHookUrls == null) {
return;
}
for (String webHookUrl : webHookUrls) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity entity = new HttpEntity(releaseHistory, headers);
String url = webHookUrl + "?env={env}";
try {
restTemplate.postForObject(url, entity, String.class, env);
} catch (Exception e) {
logger.error("Notify webHook server failed, env: {}, webHook server url:{}", env, url, e);
}
}
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java | package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.util.OrderedProperties;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import com.ctrip.framework.apollo.util.yaml.YamlParser;
import java.util.Properties;
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 org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
public class YamlConfigFileTest {
private String someNamespace;
@Mock
private ConfigRepository configRepository;
@Mock
private YamlParser yamlParser;
@Mock
private PropertiesFactory propertiesFactory;
private ConfigSourceType someSourceType;
@Before
public void setUp() throws Exception {
someNamespace = "someName";
MockInjector.setInstance(YamlParser.class, yamlParser);
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();
}
@Test
public void testWhenHasContent() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someContent = "someKey: 'someValue'";
someProperties.setProperty(key, someContent);
someSourceType = ConfigSourceType.LOCAL;
Properties yamlProperties = new Properties();
yamlProperties.setProperty("someKey", "someValue");
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someContent)).thenReturn(yamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someContent, configFile.getContent());
assertSame(yamlProperties, configFile.asProperties());
}
@Test
public void testWhenHasContentWithOrder() throws Exception {
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new OrderedProperties();
}
});
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someContent = "someKey: 'someValue'\nsomeKey2: 'someValue2'";
someProperties.setProperty(key, someContent);
someSourceType = ConfigSourceType.LOCAL;
Properties yamlProperties = new YamlParser().yamlToProperties(someContent);
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someContent)).thenReturn(yamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someContent, configFile.getContent());
assertSame(yamlProperties, configFile.asProperties());
String[] actualArrays = configFile.asProperties().keySet().toArray(new String[]{});
String[] expectedArrays = {"someKey", "someKey2"};
assertArrayEquals(expectedArrays, actualArrays);
}
@Test
public void testWhenHasNoContent() throws Exception {
when(configRepository.getConfig()).thenReturn(null);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
Properties properties = configFile.asProperties();
assertTrue(properties.isEmpty());
}
@Test
public void testWhenInvalidYamlContent() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someInvalidContent = ",";
someProperties.setProperty(key, someInvalidContent);
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someInvalidContent))
.thenThrow(new RuntimeException("some exception"));
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someInvalidContent, configFile.getContent());
Throwable exceptionThrown = null;
try {
configFile.asProperties();
} catch (Throwable ex) {
exceptionThrown = ex;
}
assertTrue(exceptionThrown instanceof ApolloConfigException);
assertNotNull(exceptionThrown.getCause());
}
@Test
public void testWhenConfigRepositoryHasError() throws Exception {
when(configRepository.getConfig()).thenThrow(new RuntimeException("someError"));
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
assertEquals(ConfigSourceType.NONE, configFile.getSourceType());
Properties properties = configFile.asProperties();
assertTrue(properties.isEmpty());
}
@Test
public void testOnRepositoryChange() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someValue = "someKey: 'someValue'";
String anotherValue = "anotherKey: 'anotherValue'";
someProperties.setProperty(key, someValue);
someSourceType = ConfigSourceType.LOCAL;
Properties someYamlProperties = new Properties();
someYamlProperties.setProperty("someKey", "someValue");
Properties anotherYamlProperties = new Properties();
anotherYamlProperties.setProperty("anotherKey", "anotherValue");
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties);
when(yamlParser.yamlToProperties(anotherValue)).thenReturn(anotherYamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertEquals(someValue, configFile.getContent());
assertEquals(someSourceType, configFile.getSourceType());
assertSame(someYamlProperties, configFile.asProperties());
Properties anotherProperties = new Properties();
anotherProperties.setProperty(key, anotherValue);
ConfigSourceType anotherSourceType = ConfigSourceType.REMOTE;
when(configRepository.getSourceType()).thenReturn(anotherSourceType);
configFile.onRepositoryChange(someNamespace, anotherProperties);
assertEquals(anotherValue, configFile.getContent());
assertEquals(anotherSourceType, configFile.getSourceType());
assertSame(anotherYamlProperties, configFile.asProperties());
}
@Test
public void testWhenConfigRepositoryHasErrorAndThenRecovered() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someValue = "someKey: 'someValue'";
someProperties.setProperty(key, someValue);
someSourceType = ConfigSourceType.LOCAL;
Properties someYamlProperties = new Properties();
someYamlProperties.setProperty("someKey", "someValue");
when(configRepository.getConfig()).thenThrow(new RuntimeException("someError"));
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
assertEquals(ConfigSourceType.NONE, configFile.getSourceType());
assertTrue(configFile.asProperties().isEmpty());
configFile.onRepositoryChange(someNamespace, someProperties);
assertTrue(configFile.hasContent());
assertEquals(someValue, configFile.getContent());
assertEquals(someSourceType, configFile.getSourceType());
assertSame(someYamlProperties, configFile.asProperties());
}
}
| package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.util.OrderedProperties;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import com.ctrip.framework.apollo.util.yaml.YamlParser;
import java.util.Properties;
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 org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
public class YamlConfigFileTest {
private String someNamespace;
@Mock
private ConfigRepository configRepository;
@Mock
private YamlParser yamlParser;
@Mock
private PropertiesFactory propertiesFactory;
private ConfigSourceType someSourceType;
@Before
public void setUp() throws Exception {
someNamespace = "someName";
MockInjector.setInstance(YamlParser.class, yamlParser);
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();
}
@Test
public void testWhenHasContent() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someContent = "someKey: 'someValue'";
someProperties.setProperty(key, someContent);
someSourceType = ConfigSourceType.LOCAL;
Properties yamlProperties = new Properties();
yamlProperties.setProperty("someKey", "someValue");
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someContent)).thenReturn(yamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someContent, configFile.getContent());
assertSame(yamlProperties, configFile.asProperties());
}
@Test
public void testWhenHasContentWithOrder() throws Exception {
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new OrderedProperties();
}
});
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someContent = "someKey: 'someValue'\nsomeKey2: 'someValue2'";
someProperties.setProperty(key, someContent);
someSourceType = ConfigSourceType.LOCAL;
Properties yamlProperties = new YamlParser().yamlToProperties(someContent);
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someContent)).thenReturn(yamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someContent, configFile.getContent());
assertSame(yamlProperties, configFile.asProperties());
String[] actualArrays = configFile.asProperties().keySet().toArray(new String[]{});
String[] expectedArrays = {"someKey", "someKey2"};
assertArrayEquals(expectedArrays, actualArrays);
}
@Test
public void testWhenHasNoContent() throws Exception {
when(configRepository.getConfig()).thenReturn(null);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
Properties properties = configFile.asProperties();
assertTrue(properties.isEmpty());
}
@Test
public void testWhenInvalidYamlContent() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someInvalidContent = ",";
someProperties.setProperty(key, someInvalidContent);
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someInvalidContent))
.thenThrow(new RuntimeException("some exception"));
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertSame(someInvalidContent, configFile.getContent());
Throwable exceptionThrown = null;
try {
configFile.asProperties();
} catch (Throwable ex) {
exceptionThrown = ex;
}
assertTrue(exceptionThrown instanceof ApolloConfigException);
assertNotNull(exceptionThrown.getCause());
}
@Test
public void testWhenConfigRepositoryHasError() throws Exception {
when(configRepository.getConfig()).thenThrow(new RuntimeException("someError"));
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
assertEquals(ConfigSourceType.NONE, configFile.getSourceType());
Properties properties = configFile.asProperties();
assertTrue(properties.isEmpty());
}
@Test
public void testOnRepositoryChange() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someValue = "someKey: 'someValue'";
String anotherValue = "anotherKey: 'anotherValue'";
someProperties.setProperty(key, someValue);
someSourceType = ConfigSourceType.LOCAL;
Properties someYamlProperties = new Properties();
someYamlProperties.setProperty("someKey", "someValue");
Properties anotherYamlProperties = new Properties();
anotherYamlProperties.setProperty("anotherKey", "anotherValue");
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties);
when(yamlParser.yamlToProperties(anotherValue)).thenReturn(anotherYamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertEquals(someValue, configFile.getContent());
assertEquals(someSourceType, configFile.getSourceType());
assertSame(someYamlProperties, configFile.asProperties());
Properties anotherProperties = new Properties();
anotherProperties.setProperty(key, anotherValue);
ConfigSourceType anotherSourceType = ConfigSourceType.REMOTE;
when(configRepository.getSourceType()).thenReturn(anotherSourceType);
configFile.onRepositoryChange(someNamespace, anotherProperties);
assertEquals(anotherValue, configFile.getContent());
assertEquals(anotherSourceType, configFile.getSourceType());
assertSame(anotherYamlProperties, configFile.asProperties());
}
@Test
public void testWhenConfigRepositoryHasErrorAndThenRecovered() throws Exception {
Properties someProperties = new Properties();
String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY;
String someValue = "someKey: 'someValue'";
someProperties.setProperty(key, someValue);
someSourceType = ConfigSourceType.LOCAL;
Properties someYamlProperties = new Properties();
someYamlProperties.setProperty("someKey", "someValue");
when(configRepository.getConfig()).thenThrow(new RuntimeException("someError"));
when(configRepository.getSourceType()).thenReturn(someSourceType);
when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties);
YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository);
assertFalse(configFile.hasContent());
assertNull(configFile.getContent());
assertEquals(ConfigSourceType.NONE, configFile.getSourceType());
assertTrue(configFile.asProperties().isEmpty());
configFile.onRepositoryChange(someNamespace, someProperties);
assertTrue(configFile.hasContent());
assertEquals(someValue, configFile.getContent());
assertEquals(someSourceType, configFile.getSourceType());
assertSame(someYamlProperties, configFile.asProperties());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java | package com.ctrip.framework.apollo.common.controller;
import com.ctrip.framework.apollo.common.exception.AbstractApolloHttpException;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpMediaTypeException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.client.HttpStatusCodeException;
import static org.slf4j.event.Level.ERROR;
import static org.slf4j.event.Level.WARN;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
@ControllerAdvice
public class GlobalDefaultExceptionHandler {
private Gson gson = new Gson();
private static Type mapType = new TypeToken<Map<String, Object>>() {
}.getType();
private static final Logger logger = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
//处理系统内置的Exception
@ExceptionHandler(Throwable.class)
public ResponseEntity<Map<String, Object>> exception(HttpServletRequest request, Throwable ex) {
return handleError(request, INTERNAL_SERVER_ERROR, ex);
}
@ExceptionHandler({HttpRequestMethodNotSupportedException.class, HttpMediaTypeException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request,
ServletException ex) {
return handleError(request, BAD_REQUEST, ex, WARN);
}
@ExceptionHandler(HttpStatusCodeException.class)
public ResponseEntity<Map<String, Object>> restTemplateException(HttpServletRequest request,
HttpStatusCodeException ex) {
return handleError(request, ex.getStatusCode(), ex);
}
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<Map<String, Object>> accessDeny(HttpServletRequest request,
AccessDeniedException ex) {
return handleError(request, FORBIDDEN, ex);
}
//处理自定义Exception
@ExceptionHandler({AbstractApolloHttpException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request, AbstractApolloHttpException ex) {
return handleError(request, ex.getHttpStatus(), ex);
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Map<String, Object>> handleMethodArgumentNotValidException(
HttpServletRequest request, MethodArgumentNotValidException ex
) {
final Optional<ObjectError> firstError = ex.getBindingResult().getAllErrors().stream().findFirst();
if (firstError.isPresent()) {
final String firstErrorMessage = firstError.get().getDefaultMessage();
return handleError(request, BAD_REQUEST, new BadRequestException(firstErrorMessage));
}
return handleError(request, BAD_REQUEST, ex);
}
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<Map<String, Object>> handleConstraintViolationException(
HttpServletRequest request, ConstraintViolationException ex
) {
return handleError(request, BAD_REQUEST, new BadRequestException(ex.getMessage()));
}
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex) {
return handleError(request, status, ex, ERROR);
}
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex, Level logLevel) {
String message = ex.getMessage();
printLog(message, ex, logLevel);
Map<String, Object> errorAttributes = new HashMap<>();
boolean errorHandled = false;
if (ex instanceof HttpStatusCodeException) {
try {
//try to extract the original error info if it is thrown from apollo programs, e.g. admin service
errorAttributes = gson.fromJson(((HttpStatusCodeException) ex).getResponseBodyAsString(), mapType);
status = ((HttpStatusCodeException) ex).getStatusCode();
errorHandled = true;
} catch (Throwable th) {
//ignore
}
}
if (!errorHandled) {
errorAttributes.put("status", status.value());
errorAttributes.put("message", message);
errorAttributes.put("timestamp",
LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
errorAttributes.put("exception", ex.getClass().getName());
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<>(errorAttributes, headers, status);
}
//打印日志, 其中logLevel为日志级别: ERROR/WARN/DEBUG/INFO/TRACE
private void printLog(String message, Throwable ex, Level logLevel) {
switch (logLevel) {
case ERROR:
logger.error(message, ex);
break;
case WARN:
logger.warn(message, ex);
break;
case DEBUG:
logger.debug(message, ex);
break;
case INFO:
logger.info(message, ex);
break;
case TRACE:
logger.trace(message, ex);
break;
}
Tracer.logError(ex);
}
}
| package com.ctrip.framework.apollo.common.controller;
import com.ctrip.framework.apollo.common.exception.AbstractApolloHttpException;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpMediaTypeException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.client.HttpStatusCodeException;
import static org.slf4j.event.Level.ERROR;
import static org.slf4j.event.Level.WARN;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
@ControllerAdvice
public class GlobalDefaultExceptionHandler {
private Gson gson = new Gson();
private static Type mapType = new TypeToken<Map<String, Object>>() {
}.getType();
private static final Logger logger = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
//处理系统内置的Exception
@ExceptionHandler(Throwable.class)
public ResponseEntity<Map<String, Object>> exception(HttpServletRequest request, Throwable ex) {
return handleError(request, INTERNAL_SERVER_ERROR, ex);
}
@ExceptionHandler({HttpRequestMethodNotSupportedException.class, HttpMediaTypeException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request,
ServletException ex) {
return handleError(request, BAD_REQUEST, ex, WARN);
}
@ExceptionHandler(HttpStatusCodeException.class)
public ResponseEntity<Map<String, Object>> restTemplateException(HttpServletRequest request,
HttpStatusCodeException ex) {
return handleError(request, ex.getStatusCode(), ex);
}
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<Map<String, Object>> accessDeny(HttpServletRequest request,
AccessDeniedException ex) {
return handleError(request, FORBIDDEN, ex);
}
//处理自定义Exception
@ExceptionHandler({AbstractApolloHttpException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request, AbstractApolloHttpException ex) {
return handleError(request, ex.getHttpStatus(), ex);
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Map<String, Object>> handleMethodArgumentNotValidException(
HttpServletRequest request, MethodArgumentNotValidException ex
) {
final Optional<ObjectError> firstError = ex.getBindingResult().getAllErrors().stream().findFirst();
if (firstError.isPresent()) {
final String firstErrorMessage = firstError.get().getDefaultMessage();
return handleError(request, BAD_REQUEST, new BadRequestException(firstErrorMessage));
}
return handleError(request, BAD_REQUEST, ex);
}
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<Map<String, Object>> handleConstraintViolationException(
HttpServletRequest request, ConstraintViolationException ex
) {
return handleError(request, BAD_REQUEST, new BadRequestException(ex.getMessage()));
}
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex) {
return handleError(request, status, ex, ERROR);
}
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex, Level logLevel) {
String message = ex.getMessage();
printLog(message, ex, logLevel);
Map<String, Object> errorAttributes = new HashMap<>();
boolean errorHandled = false;
if (ex instanceof HttpStatusCodeException) {
try {
//try to extract the original error info if it is thrown from apollo programs, e.g. admin service
errorAttributes = gson.fromJson(((HttpStatusCodeException) ex).getResponseBodyAsString(), mapType);
status = ((HttpStatusCodeException) ex).getStatusCode();
errorHandled = true;
} catch (Throwable th) {
//ignore
}
}
if (!errorHandled) {
errorAttributes.put("status", status.value());
errorAttributes.put("message", message);
errorAttributes.put("timestamp",
LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
errorAttributes.put("exception", ex.getClass().getName());
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<>(errorAttributes, headers, status);
}
//打印日志, 其中logLevel为日志级别: ERROR/WARN/DEBUG/INFO/TRACE
private void printLog(String message, Throwable ex, Level logLevel) {
switch (logLevel) {
case ERROR:
logger.error(message, ex);
break;
case WARN:
logger.warn(message, ex);
break;
case DEBUG:
logger.debug(message, ex);
break;
case INFO:
logger.info(message, ex);
break;
case TRACE:
logger.trace(message, ex);
break;
}
Tracer.logError(ex);
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/spring/annotation/SpringValueProcessor.java | package com.ctrip.framework.apollo.spring.annotation;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.spring.property.PlaceholderHelper;
import com.ctrip.framework.apollo.spring.property.SpringValue;
import com.ctrip.framework.apollo.spring.property.SpringValueDefinition;
import com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor;
import com.ctrip.framework.apollo.spring.property.SpringValueRegistry;
import com.ctrip.framework.apollo.spring.util.SpringInjector;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Bean;
/**
* Spring value processor of field or method which has @Value and xml config placeholders.
*
* @author github.com/zhegexiaohuozi [email protected]
* @since 2017/12/20.
*/
public class SpringValueProcessor extends ApolloProcessor implements BeanFactoryPostProcessor, BeanFactoryAware {
private static final Logger logger = LoggerFactory.getLogger(SpringValueProcessor.class);
private final ConfigUtil configUtil;
private final PlaceholderHelper placeholderHelper;
private final SpringValueRegistry springValueRegistry;
private BeanFactory beanFactory;
private Multimap<String, SpringValueDefinition> beanName2SpringValueDefinitions;
public SpringValueProcessor() {
configUtil = ApolloInjector.getInstance(ConfigUtil.class);
placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class);
springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class);
beanName2SpringValueDefinitions = LinkedListMultimap.create();
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() && beanFactory instanceof BeanDefinitionRegistry) {
beanName2SpringValueDefinitions = SpringValueDefinitionProcessor
.getBeanName2SpringValueDefinitions((BeanDefinitionRegistry) beanFactory);
}
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()) {
super.postProcessBeforeInitialization(bean, beanName);
processBeanPropertyValues(bean, beanName);
}
return bean;
}
@Override
protected void processField(Object bean, String beanName, Field field) {
// register @Value on field
Value value = field.getAnnotation(Value.class);
if (value == null) {
return;
}
Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value());
if (keys.isEmpty()) {
return;
}
for (String key : keys) {
SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false);
springValueRegistry.register(beanFactory, key, springValue);
logger.debug("Monitoring {}", springValue);
}
}
@Override
protected void processMethod(Object bean, String beanName, Method method) {
//register @Value on method
Value value = method.getAnnotation(Value.class);
if (value == null) {
return;
}
//skip Configuration bean methods
if (method.getAnnotation(Bean.class) != null) {
return;
}
if (method.getParameterTypes().length != 1) {
logger.error("Ignore @Value setter {}.{}, expecting 1 parameter, actual {} parameters",
bean.getClass().getName(), method.getName(), method.getParameterTypes().length);
return;
}
Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value());
if (keys.isEmpty()) {
return;
}
for (String key : keys) {
SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, method, false);
springValueRegistry.register(beanFactory, key, springValue);
logger.info("Monitoring {}", springValue);
}
}
private void processBeanPropertyValues(Object bean, String beanName) {
Collection<SpringValueDefinition> propertySpringValues = beanName2SpringValueDefinitions
.get(beanName);
if (propertySpringValues == null || propertySpringValues.isEmpty()) {
return;
}
for (SpringValueDefinition definition : propertySpringValues) {
try {
PropertyDescriptor pd = BeanUtils
.getPropertyDescriptor(bean.getClass(), definition.getPropertyName());
Method method = pd.getWriteMethod();
if (method == null) {
continue;
}
SpringValue springValue = new SpringValue(definition.getKey(), definition.getPlaceholder(),
bean, beanName, method, false);
springValueRegistry.register(beanFactory, definition.getKey(), springValue);
logger.debug("Monitoring {}", springValue);
} catch (Throwable ex) {
logger.error("Failed to enable auto update feature for {}.{}", bean.getClass(),
definition.getPropertyName());
}
}
// clear
beanName2SpringValueDefinitions.removeAll(beanName);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
}
| package com.ctrip.framework.apollo.spring.annotation;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.spring.property.PlaceholderHelper;
import com.ctrip.framework.apollo.spring.property.SpringValue;
import com.ctrip.framework.apollo.spring.property.SpringValueDefinition;
import com.ctrip.framework.apollo.spring.property.SpringValueDefinitionProcessor;
import com.ctrip.framework.apollo.spring.property.SpringValueRegistry;
import com.ctrip.framework.apollo.spring.util.SpringInjector;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Bean;
/**
* Spring value processor of field or method which has @Value and xml config placeholders.
*
* @author github.com/zhegexiaohuozi [email protected]
* @since 2017/12/20.
*/
public class SpringValueProcessor extends ApolloProcessor implements BeanFactoryPostProcessor, BeanFactoryAware {
private static final Logger logger = LoggerFactory.getLogger(SpringValueProcessor.class);
private final ConfigUtil configUtil;
private final PlaceholderHelper placeholderHelper;
private final SpringValueRegistry springValueRegistry;
private BeanFactory beanFactory;
private Multimap<String, SpringValueDefinition> beanName2SpringValueDefinitions;
public SpringValueProcessor() {
configUtil = ApolloInjector.getInstance(ConfigUtil.class);
placeholderHelper = SpringInjector.getInstance(PlaceholderHelper.class);
springValueRegistry = SpringInjector.getInstance(SpringValueRegistry.class);
beanName2SpringValueDefinitions = LinkedListMultimap.create();
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled() && beanFactory instanceof BeanDefinitionRegistry) {
beanName2SpringValueDefinitions = SpringValueDefinitionProcessor
.getBeanName2SpringValueDefinitions((BeanDefinitionRegistry) beanFactory);
}
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (configUtil.isAutoUpdateInjectedSpringPropertiesEnabled()) {
super.postProcessBeforeInitialization(bean, beanName);
processBeanPropertyValues(bean, beanName);
}
return bean;
}
@Override
protected void processField(Object bean, String beanName, Field field) {
// register @Value on field
Value value = field.getAnnotation(Value.class);
if (value == null) {
return;
}
Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value());
if (keys.isEmpty()) {
return;
}
for (String key : keys) {
SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false);
springValueRegistry.register(beanFactory, key, springValue);
logger.debug("Monitoring {}", springValue);
}
}
@Override
protected void processMethod(Object bean, String beanName, Method method) {
//register @Value on method
Value value = method.getAnnotation(Value.class);
if (value == null) {
return;
}
//skip Configuration bean methods
if (method.getAnnotation(Bean.class) != null) {
return;
}
if (method.getParameterTypes().length != 1) {
logger.error("Ignore @Value setter {}.{}, expecting 1 parameter, actual {} parameters",
bean.getClass().getName(), method.getName(), method.getParameterTypes().length);
return;
}
Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value());
if (keys.isEmpty()) {
return;
}
for (String key : keys) {
SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, method, false);
springValueRegistry.register(beanFactory, key, springValue);
logger.info("Monitoring {}", springValue);
}
}
private void processBeanPropertyValues(Object bean, String beanName) {
Collection<SpringValueDefinition> propertySpringValues = beanName2SpringValueDefinitions
.get(beanName);
if (propertySpringValues == null || propertySpringValues.isEmpty()) {
return;
}
for (SpringValueDefinition definition : propertySpringValues) {
try {
PropertyDescriptor pd = BeanUtils
.getPropertyDescriptor(bean.getClass(), definition.getPropertyName());
Method method = pd.getWriteMethod();
if (method == null) {
continue;
}
SpringValue springValue = new SpringValue(definition.getKey(), definition.getPlaceholder(),
bean, beanName, method, false);
springValueRegistry.register(beanFactory, definition.getKey(), springValue);
logger.debug("Monitoring {}", springValue);
} catch (Throwable ex) {
logger.error("Failed to enable auto update feature for {}.{}", bean.getClass(),
definition.getPropertyName());
}
}
// clear
beanName2SpringValueDefinitions.removeAll(beanName);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-core/src/main/java/com/ctrip/framework/apollo/Apollo.java | package com.ctrip.framework.apollo;
/**
* @author Jason Song([email protected])
*/
public class Apollo {
public final static String VERSION =
"java-" + Apollo.class.getPackage().getImplementationVersion();
}
| package com.ctrip.framework.apollo;
/**
* @author Jason Song([email protected])
*/
public class Apollo {
public final static String VERSION =
"java-" + Apollo.class.getPackage().getImplementationVersion();
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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.
| ./docs/zh/usage/apollo-user-guide.md | #
# 名词解释
* 普通应用
* 普通应用指的是独立运行的程序,如
* Web应用程序
* 带有main函数的程序
* 公共组件
* 公共组件指的是发布的类库、客户端程序,不会自己独立运行,如
* Java的jar包
* .Net的dll文件
# 一、普通应用接入指南
## 1.1 创建项目
要使用Apollo,第一步需要创建项目。
1. 打开apollo-portal主页
2. 点击“创建项目”

3. 输入项目信息
* 部门:选择应用所在的部门
* 应用AppId:用来标识应用身份的唯一id,格式为string,需要和客户端app.properties中配置的app.id对应
* 应用名称:应用名,仅用于界面展示
* 应用负责人:选择的人默认会成为该项目的管理员,具备项目权限管理、集群创建、Namespace创建等权限

4. 点击提交
创建成功后,会自动跳转到项目首页

## 1.2 项目权限分配
### 1.2.1 项目管理员权限
项目管理员拥有以下权限:
1. 可以管理项目的权限分配
2. 可以创建集群
3. 可以创建Namespace
创建项目时填写的应用负责人默认会成为项目的管理员之一,如果还需要其他人也成为项目管理员,可以按照下面步骤操作:
1. 点击页面左侧的“管理项目”
* 
2. 搜索需要添加的成员并点击添加
* 
* 
### 1.2.2 配置编辑、发布权限
配置权限分为编辑和发布:
* 编辑权限允许用户在Apollo界面上创建、修改、删除配置
* 配置修改后只在Apollo界面上变化,不会影响到应用实际使用的配置
* 发布权限允许用户在Apollo界面上发布、回滚配置
* 配置只有在发布、回滚动作后才会被应用实际使用到
* Apollo在用户操作发布、回滚动作后实时通知到应用,并使最新配置生效
项目创建完,默认没有分配配置的编辑和发布权限,需要项目管理员进行授权。
1. 点击application这个namespace的授权按钮
* 
2. 分配修改权限
* 
3. 分配发布权限
* 
## 1.3 添加配置项
编辑配置需要拥有这个Namespace的编辑权限,如果发现没有新增配置按钮,可以找项目管理员授权。
### 1.3.1 通过表格模式添加配置
1. 点击新增配置
* 
2. 输入配置项
* 
3. 点击提交
* 
### 1.3.2 通过文本模式编辑
Apollo除了支持表格模式,逐个添加、修改配置外,还提供文本模式批量添加、修改。
这个对于从已有的properties文件迁移尤其有用。
1. 切换到文本编辑模式

2. 点击右侧的修改配置按钮

3. 输入配置项,并点击提交修改

## 1.4 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

## 1.5 应用读取配置
配置发布成功后,应用就可以通过Apollo客户端读取到配置了。
Apollo目前提供Java客户端,具体信息请点击[Java客户端使用文档](zh/usage/java-sdk-user-guide):
如果应用使用了其它语言,也可以通过直接访问Http接口获取配置,具体可以参考[其它语言客户端接入指南](zh/usage/other-language-client-user-guide)
## 1.6 回滚已发布配置
如果发现已发布的配置有问题,可以通过点击『回滚』按钮来将客户端读取到的配置回滚到上一个发布版本。
这里的回滚机制类似于发布系统,发布系统中的回滚操作是将部署到机器上的安装包回滚到上一个部署的版本,但代码仓库中的代码是不会回滚的,从而开发可以在修复代码后重新发布。
Apollo中的回滚也是类似的机制,点击回滚后是将发布到客户端的配置回滚到上一个已发布版本,也就是说客户端读取到的配置会恢复到上一个版本,但页面上编辑状态的配置是不会回滚的,从而开发可以在修复配置后重新发布。
# 二、公共组件接入指南
## 2.1 公共组件和普通应用的区别
公共组件是指那些发布给其它应用使用的客户端代码,比如CAT客户端、Hermes Producer客户端等。
虽然这类组件是由其他团队开发、维护,但是运行时是在业务实际应用内的,所以本质上可以认为是应用的一部分。
通常情况下,这类组件所用到的配置由原始开发团队维护,不过由于实际应用的运行时、环境各不一样,所以我们也允许应用在实际使用时能够覆盖公共组件的部分配置。
## 2.2 公共组件接入步骤
公共组件的接入步骤,和普通应用几乎一致,唯一的区别是公共组件需要创建自己唯一的Namespace。
所以,首先执行普通应用接入文档中的以下几个步骤,然后再按照本章节后面的步骤操作。
1. [创建项目](#_11-%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE)
2. [项目管理员权限](#_121-%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%91%98%E6%9D%83%E9%99%90)
### 2.2.1 创建Namespace
创建Namespace需要项目管理员权限,如果发现没有添加Namespace按钮,可以找项目管理员授权。
1. 点击页面左侧的添加Namespace
* 
2. 点击“创建新的Namespace”
* 
3. 输入公共组件的Namespace名称,需要注意的是Namespace名称全局唯一
* Apollo会默认把部门代号添加在最前面
* 
4. 点击提交后,页面会自动跳转到关联Namespace页面
* 首先,选中所有需要有这个Namespace的环境和集群,一般建议全选
* 其次,选中刚刚创建的namespace
* 最后,点击提交
* 
5. 关联成功后,页面会自动跳转到Namespace权限管理页面
1. 分配修改权限
* 
2. 分配发布权限
* 
6. 点击“返回”回到项目页面
### 2.2.2 添加配置项
编辑配置需要拥有这个Namespace的编辑权限,如果发现没有新增配置按钮,可以找项目管理员授权。
#### 2.2.2.1 通过表格模式添加配置
1. 点击新增配置

2. 输入配置项

3. 点击提交

#### 2.2.2.2 通过文本模式编辑
这部分和普通应用一致,具体步骤请参见[1.3.2 通过文本模式编辑](#_132-%E9%80%9A%E8%BF%87%E6%96%87%E6%9C%AC%E6%A8%A1%E5%BC%8F%E7%BC%96%E8%BE%91)。
### 2.2.3 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

### 2.2.4 应用读取配置
配置发布成功后,应用就可以通过Apollo客户端读取到配置了。
Apollo目前提供Java客户端,具体信息请点击[Java客户端使用文档](zh/usage/java-sdk-user-guide):
如果应用使用了其它语言,也可以通过直接访问Http接口获取配置,具体可以参考[其它语言客户端接入指南](zh/usage/other-language-client-user-guide)
对于公共组件的配置读取,可以参考上述文档中的“获取公共Namespace的配置”部分。
## 2.3 应用覆盖公用组件配置步骤
前面提到,通常情况下,公共组件所用到的配置由原始开发团队维护,不过由于实际应用的运行时、环境各不一样,所以我们也允许应用在实际使用时能够覆盖公共组件的部分配置。
这里就讲一下应用如何覆盖公用组件的配置,简单起见,假设apollo-portal应用使用了hermes producer客户端,并且希望调整hermes的批量发送大小。
### 2.3.1 关联公共组件Namespace
1. 进入使用公共组件的应用项目首页,点击左侧的添加Namespace按钮
* 所以,在这个例子中,我们需要进入apollo-portal的首页。
* (添加Namespace需要项目管理员权限,如果发现没有添加Namespace按钮,可以找项目管理员授权)
* 
2. 找到hermes producer的namespace,并选择需要关联到哪些环境和集群

3. 关联成功后,页面会自动跳转到Namespace权限管理页面
1. 分配修改权限

2. 分配发布权限

4. 点击“返回”回到项目页面
### 2.3.2 覆盖公用组件配置
1. 点击新增配置

2. 输入要覆盖的配置项

3. 点击提交

### 2.3.3 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

3. 配置发布成功后,hermes producer客户端在apollo-portal应用里面运行时读取到的sender.batchSize的值就是1000。
# 三、集群独立配置说明
在有些特殊情况下,应用有需求对不同的集群做不同的配置,比如部署在A机房的应用连接的es服务器地址和部署在B机房的应用连接的es服务器地址不一样。
在这种情况下,可以通过在Apollo创建不同的集群来解决。
## 3.1 创建集群
创建集群需要项目管理员权限,如果发现没有添加集群按钮,可以找项目管理员授权。
1. 点击页面左侧的“添加集群”按钮
* 
2. 输入集群名称,选择环境并提交
* 
3. 切换到对应的集群,修改配置并发布即可
* 
4. 通过上述配置,部署在SHAJQ机房的应用就会读到SHAJQ集群下的配置
5. 如果应用还在其它机房部署了应用,那么在上述的配置下,会读到default集群下的配置。
# 四、多个AppId使用同一份配置
在一些情况下,尽管应用本身不是公共组件,但还是需要在多个AppId之间共用同一份配置,比如同一个产品的不同项目:XX-Web, XX-Service, XX-Job等。
这种情况下如果希望实现多个AppId使用同一份配置的话,基本概念和公共组件的配置是一致的。
具体来说,就是在其中一个AppId下创建一个namespace,写入公共的配置信息,然后在各个项目中读取该namespace的配置即可。
如果某个AppId需要覆盖公共的配置信息,那么在该AppId下关联公共的namespace并写入需要覆盖的配置即可。
具体步骤可以参考[公共组件接入指南](#%e4%ba%8c%e3%80%81%e5%85%ac%e5%85%b1%e7%bb%84%e4%bb%b6%e6%8e%a5%e5%85%a5%e6%8c%87%e5%8d%97)。
# 五、灰度发布使用指南
通过灰度发布功能,可以实现:
1. 对于一些对程序有比较大影响的配置,可以先在一个或者多个实例生效,观察一段时间没问题后再全量发布配置。
2. 对于一些需要调优的配置参数,可以通过灰度发布功能来实现A/B测试。可以在不同的机器上应用不同的配置,不断调整、测评一段时间后找出较优的配置再全量发布配置。
下面将结合一个实际例子来描述如何使用灰度发布功能。
## 5.1 场景介绍
100004458(apollo-demo)项目有两个客户端:
1. 10.32.21.19
2. 10.32.21.22

**灰度目标:**
* 当前有一个配置timeout=2000,我们希望对10.32.21.22灰度发布timeout=3000,对10.32.21.19仍然是timeout=2000。

## 5.2 创建灰度
首先点击application namespace右上角的`创建灰度`按钮。

点击确定后,灰度版本就创建成功了,页面会自动切换到`灰度版本`Tab。

## 5.3 灰度配置
点击`主版本的配置`中,timeout配置最右侧的`对此配置灰度`按钮

在弹出框中填入要灰度的值:3000,点击提交。


## 5.4 配置灰度规则
切换到`灰度规则`Tab,点击`新增规则`按钮

在弹出框中`灰度的IP`下拉框会默认展示当前使用配置的机器列表,选择我们要灰度的IP,点击完成。



如果下拉框中没找到需要的IP,说明机器还没从Apollo取过配置,可以点击手动输入IP来输入,输入完后点击添加按钮


>注:对于公共Namespace的灰度规则,需要先指定要灰度的appId,然后再选择IP。
## 5.5 灰度发布
配置规则已经生效,不过灰度配置还没有发布。切换到`配置`Tab。
再次检查灰度的配置部分,如果没有问题,点击`灰度发布`。

在弹出框中可以看到主版本的值是2000,灰度版本即将发布的值是3000。填入其它信息后,点击发布。

发布后,切换到`灰度实例列表`Tab,就能看到10.32.21.22已经使用了灰度发布的值。

切换到`主版本`的`实例列表`,会看到主版本配置只有10.32.21.19在使用了。

后面可以继续配置的修改或规则的更改。配置的修改需要点击灰度发布后才会生效,规则的修改在规则点击完成后就会实时生效。
## 5.6 全量发布
如果灰度的配置测试下来比较理想,符合预期,那么就可以操作`全量发布`。
全量发布的效果是:
1. 灰度版本的配置会合并回主版本,在这个例子中,就是主版本的timeout会被更新成3000
2. 主版本的配置会自动进行一次发布
3. 在全量发布页面,可以选择是否保留当前灰度版本,默认为不保留。



我选择了不保留灰度版本,所以发布完的效果就是主版本的配置更新、灰度版本删除。点击主版本的实例列表,可以看到10.32.21.22和10.32.21.19都使用了主版本最新的配置。

## 5.7 放弃灰度
如果灰度版本不理想或者不需要了,可以点击`放弃灰度`。

## 5.8 发布历史
点击主版本的`发布历史`按钮,可以看到当前namespace的主版本以及灰度版本的发布历史。


# 六、其它功能配置
## 6.1 配置查看权限
从1.1.0版本开始,apollo-portal增加了查看权限的支持,可以支持配置某个环境只允许项目成员查看私有Namespace的配置。
这里的项目成员是指:
1. 项目的管理员
2. 具备该私有Namespace在该环境下的修改或发布权限
配置方式很简单,用超级管理员账号登录后,进入`管理员工具 - 系统参数`页面新增或修改`configView.memberOnly.envs`配置项即可。

## 6.2 配置访问密钥
Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端需要配置密钥,否则无法获取配置。
1. 项目管理员打开管理密钥页面

2. 为项目的每个环境生成访问密钥,注意默认是禁用的,建议在客户端都配置完成后再开启

3. 客户端侧[配置访问密钥](zh/usage/java-sdk-user-guide#_1244-配置访问密钥)
# 七、最佳实践
## 7.1 安全相关
配置中心作为基础服务,存储着公司非常重要的配置信息,所以安全因素需要大家重点关注,下面列举了一些注意事项供大家参考,也欢迎大家分享自己的实践案例。
### 7.1.1 认证
建议接入公司统一的身份认证系统,如 SSO、LDAP 等,接入方式可以参考[Portal 实现用户登录功能](zh/development/portal-how-to-implement-user-login-function)
> 如果使用Apollo提供的Spring Security简单认证,务必记得要修改超级管理员apollo的密码
### 7.1.2 授权
Apollo 支持细粒度的权限控制,请务必根据实际情况做好权限控制:
1. [项目管理员权限](#_121-项目管理员权限)
* Apollo 默认允许所有登录用户创建项目,如果只允许部分用户创建项目,可以开启[创建项目权限控制](zh/deployment/distributed-deployment-guide?id=_3110-rolecreate-applicationenabled-是否开启创建项目权限控制)
2. [配置编辑、发布权限](#_122-配置编辑、发布权限)
* 配置编辑、发布权限支持按环境配置,比如开发环境开发人员可以自行完成配置编辑和发布的过程,但是生产环境发布权限交由测试或运维人员
* 生产环境建议同时开启[发布审核](zh/deployment/distributed-deployment-guide?id=_322-namespacelockswitch-一次发布只能有一个人修改开关,用于发布审核),从而控制一次配置发布只能由一个人修改,另一个人发布,确保配置修改得到充分检查
3. [配置查看权限](#_61-配置查看权限)
* 可以指定某个环境只允许项目成员查看私有Namespace的配置,从而避免敏感配置泄露,如生产环境
### 7.1.3 系统访问
除了用户权限,在系统访问上也需要加以考虑:
1. `apollo-configservice`和`apollo-adminservice`是基于内网可信网络设计的,所以出于安全考虑,禁止`apollo-configservice`和`apollo-adminservice`直接暴露在公网
2. 对敏感配置可以考虑开启[访问秘钥](#_62-%e9%85%8d%e7%bd%ae%e8%ae%bf%e9%97%ae%e5%af%86%e9%92%a5),从而只有经过身份验证的客户端才能访问敏感配置
3. 1.7.1及以上版本可以考虑为`apollo-adminservice`开启[访问控制](zh/deployment/distributed-deployment-guide?id=_326-admin-serviceaccesscontrolenabled-配置apollo-adminservice是否开启访问控制),从而只有[受控的](zh/deployment/distributed-deployment-guide?id=_3112-admin-serviceaccesstokens-设置apollo-portal访问各环境apollo-adminservice所需的access-token)`apollo-portal`才能访问对应接口,增强安全性
| #
# 名词解释
* 普通应用
* 普通应用指的是独立运行的程序,如
* Web应用程序
* 带有main函数的程序
* 公共组件
* 公共组件指的是发布的类库、客户端程序,不会自己独立运行,如
* Java的jar包
* .Net的dll文件
# 一、普通应用接入指南
## 1.1 创建项目
要使用Apollo,第一步需要创建项目。
1. 打开apollo-portal主页
2. 点击“创建项目”

3. 输入项目信息
* 部门:选择应用所在的部门
* 应用AppId:用来标识应用身份的唯一id,格式为string,需要和客户端app.properties中配置的app.id对应
* 应用名称:应用名,仅用于界面展示
* 应用负责人:选择的人默认会成为该项目的管理员,具备项目权限管理、集群创建、Namespace创建等权限

4. 点击提交
创建成功后,会自动跳转到项目首页

## 1.2 项目权限分配
### 1.2.1 项目管理员权限
项目管理员拥有以下权限:
1. 可以管理项目的权限分配
2. 可以创建集群
3. 可以创建Namespace
创建项目时填写的应用负责人默认会成为项目的管理员之一,如果还需要其他人也成为项目管理员,可以按照下面步骤操作:
1. 点击页面左侧的“管理项目”
* 
2. 搜索需要添加的成员并点击添加
* 
* 
### 1.2.2 配置编辑、发布权限
配置权限分为编辑和发布:
* 编辑权限允许用户在Apollo界面上创建、修改、删除配置
* 配置修改后只在Apollo界面上变化,不会影响到应用实际使用的配置
* 发布权限允许用户在Apollo界面上发布、回滚配置
* 配置只有在发布、回滚动作后才会被应用实际使用到
* Apollo在用户操作发布、回滚动作后实时通知到应用,并使最新配置生效
项目创建完,默认没有分配配置的编辑和发布权限,需要项目管理员进行授权。
1. 点击application这个namespace的授权按钮
* 
2. 分配修改权限
* 
3. 分配发布权限
* 
## 1.3 添加配置项
编辑配置需要拥有这个Namespace的编辑权限,如果发现没有新增配置按钮,可以找项目管理员授权。
### 1.3.1 通过表格模式添加配置
1. 点击新增配置
* 
2. 输入配置项
* 
3. 点击提交
* 
### 1.3.2 通过文本模式编辑
Apollo除了支持表格模式,逐个添加、修改配置外,还提供文本模式批量添加、修改。
这个对于从已有的properties文件迁移尤其有用。
1. 切换到文本编辑模式

2. 点击右侧的修改配置按钮

3. 输入配置项,并点击提交修改

## 1.4 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

## 1.5 应用读取配置
配置发布成功后,应用就可以通过Apollo客户端读取到配置了。
Apollo目前提供Java客户端,具体信息请点击[Java客户端使用文档](zh/usage/java-sdk-user-guide):
如果应用使用了其它语言,也可以通过直接访问Http接口获取配置,具体可以参考[其它语言客户端接入指南](zh/usage/other-language-client-user-guide)
## 1.6 回滚已发布配置
如果发现已发布的配置有问题,可以通过点击『回滚』按钮来将客户端读取到的配置回滚到上一个发布版本。
这里的回滚机制类似于发布系统,发布系统中的回滚操作是将部署到机器上的安装包回滚到上一个部署的版本,但代码仓库中的代码是不会回滚的,从而开发可以在修复代码后重新发布。
Apollo中的回滚也是类似的机制,点击回滚后是将发布到客户端的配置回滚到上一个已发布版本,也就是说客户端读取到的配置会恢复到上一个版本,但页面上编辑状态的配置是不会回滚的,从而开发可以在修复配置后重新发布。
# 二、公共组件接入指南
## 2.1 公共组件和普通应用的区别
公共组件是指那些发布给其它应用使用的客户端代码,比如CAT客户端、Hermes Producer客户端等。
虽然这类组件是由其他团队开发、维护,但是运行时是在业务实际应用内的,所以本质上可以认为是应用的一部分。
通常情况下,这类组件所用到的配置由原始开发团队维护,不过由于实际应用的运行时、环境各不一样,所以我们也允许应用在实际使用时能够覆盖公共组件的部分配置。
## 2.2 公共组件接入步骤
公共组件的接入步骤,和普通应用几乎一致,唯一的区别是公共组件需要创建自己唯一的Namespace。
所以,首先执行普通应用接入文档中的以下几个步骤,然后再按照本章节后面的步骤操作。
1. [创建项目](#_11-%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE)
2. [项目管理员权限](#_121-%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%91%98%E6%9D%83%E9%99%90)
### 2.2.1 创建Namespace
创建Namespace需要项目管理员权限,如果发现没有添加Namespace按钮,可以找项目管理员授权。
1. 点击页面左侧的添加Namespace
* 
2. 点击“创建新的Namespace”
* 
3. 输入公共组件的Namespace名称,需要注意的是Namespace名称全局唯一
* Apollo会默认把部门代号添加在最前面
* 
4. 点击提交后,页面会自动跳转到关联Namespace页面
* 首先,选中所有需要有这个Namespace的环境和集群,一般建议全选
* 其次,选中刚刚创建的namespace
* 最后,点击提交
* 
5. 关联成功后,页面会自动跳转到Namespace权限管理页面
1. 分配修改权限
* 
2. 分配发布权限
* 
6. 点击“返回”回到项目页面
### 2.2.2 添加配置项
编辑配置需要拥有这个Namespace的编辑权限,如果发现没有新增配置按钮,可以找项目管理员授权。
#### 2.2.2.1 通过表格模式添加配置
1. 点击新增配置

2. 输入配置项

3. 点击提交

#### 2.2.2.2 通过文本模式编辑
这部分和普通应用一致,具体步骤请参见[1.3.2 通过文本模式编辑](#_132-%E9%80%9A%E8%BF%87%E6%96%87%E6%9C%AC%E6%A8%A1%E5%BC%8F%E7%BC%96%E8%BE%91)。
### 2.2.3 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

### 2.2.4 应用读取配置
配置发布成功后,应用就可以通过Apollo客户端读取到配置了。
Apollo目前提供Java客户端,具体信息请点击[Java客户端使用文档](zh/usage/java-sdk-user-guide):
如果应用使用了其它语言,也可以通过直接访问Http接口获取配置,具体可以参考[其它语言客户端接入指南](zh/usage/other-language-client-user-guide)
对于公共组件的配置读取,可以参考上述文档中的“获取公共Namespace的配置”部分。
## 2.3 应用覆盖公用组件配置步骤
前面提到,通常情况下,公共组件所用到的配置由原始开发团队维护,不过由于实际应用的运行时、环境各不一样,所以我们也允许应用在实际使用时能够覆盖公共组件的部分配置。
这里就讲一下应用如何覆盖公用组件的配置,简单起见,假设apollo-portal应用使用了hermes producer客户端,并且希望调整hermes的批量发送大小。
### 2.3.1 关联公共组件Namespace
1. 进入使用公共组件的应用项目首页,点击左侧的添加Namespace按钮
* 所以,在这个例子中,我们需要进入apollo-portal的首页。
* (添加Namespace需要项目管理员权限,如果发现没有添加Namespace按钮,可以找项目管理员授权)
* 
2. 找到hermes producer的namespace,并选择需要关联到哪些环境和集群

3. 关联成功后,页面会自动跳转到Namespace权限管理页面
1. 分配修改权限

2. 分配发布权限

4. 点击“返回”回到项目页面
### 2.3.2 覆盖公用组件配置
1. 点击新增配置

2. 输入要覆盖的配置项

3. 点击提交

### 2.3.3 发布配置
配置只有在发布后才会真的被应用使用到,所以在编辑完配置后,需要发布配置。
发布配置需要拥有这个Namespace的发布权限,如果发现没有发布按钮,可以找项目管理员授权。
1. 点击“发布按钮”

2. 填写发布相关信息,点击发布

3. 配置发布成功后,hermes producer客户端在apollo-portal应用里面运行时读取到的sender.batchSize的值就是1000。
# 三、集群独立配置说明
在有些特殊情况下,应用有需求对不同的集群做不同的配置,比如部署在A机房的应用连接的es服务器地址和部署在B机房的应用连接的es服务器地址不一样。
在这种情况下,可以通过在Apollo创建不同的集群来解决。
## 3.1 创建集群
创建集群需要项目管理员权限,如果发现没有添加集群按钮,可以找项目管理员授权。
1. 点击页面左侧的“添加集群”按钮
* 
2. 输入集群名称,选择环境并提交
* 
3. 切换到对应的集群,修改配置并发布即可
* 
4. 通过上述配置,部署在SHAJQ机房的应用就会读到SHAJQ集群下的配置
5. 如果应用还在其它机房部署了应用,那么在上述的配置下,会读到default集群下的配置。
# 四、多个AppId使用同一份配置
在一些情况下,尽管应用本身不是公共组件,但还是需要在多个AppId之间共用同一份配置,比如同一个产品的不同项目:XX-Web, XX-Service, XX-Job等。
这种情况下如果希望实现多个AppId使用同一份配置的话,基本概念和公共组件的配置是一致的。
具体来说,就是在其中一个AppId下创建一个namespace,写入公共的配置信息,然后在各个项目中读取该namespace的配置即可。
如果某个AppId需要覆盖公共的配置信息,那么在该AppId下关联公共的namespace并写入需要覆盖的配置即可。
具体步骤可以参考[公共组件接入指南](#%e4%ba%8c%e3%80%81%e5%85%ac%e5%85%b1%e7%bb%84%e4%bb%b6%e6%8e%a5%e5%85%a5%e6%8c%87%e5%8d%97)。
# 五、灰度发布使用指南
通过灰度发布功能,可以实现:
1. 对于一些对程序有比较大影响的配置,可以先在一个或者多个实例生效,观察一段时间没问题后再全量发布配置。
2. 对于一些需要调优的配置参数,可以通过灰度发布功能来实现A/B测试。可以在不同的机器上应用不同的配置,不断调整、测评一段时间后找出较优的配置再全量发布配置。
下面将结合一个实际例子来描述如何使用灰度发布功能。
## 5.1 场景介绍
100004458(apollo-demo)项目有两个客户端:
1. 10.32.21.19
2. 10.32.21.22

**灰度目标:**
* 当前有一个配置timeout=2000,我们希望对10.32.21.22灰度发布timeout=3000,对10.32.21.19仍然是timeout=2000。

## 5.2 创建灰度
首先点击application namespace右上角的`创建灰度`按钮。

点击确定后,灰度版本就创建成功了,页面会自动切换到`灰度版本`Tab。

## 5.3 灰度配置
点击`主版本的配置`中,timeout配置最右侧的`对此配置灰度`按钮

在弹出框中填入要灰度的值:3000,点击提交。


## 5.4 配置灰度规则
切换到`灰度规则`Tab,点击`新增规则`按钮

在弹出框中`灰度的IP`下拉框会默认展示当前使用配置的机器列表,选择我们要灰度的IP,点击完成。



如果下拉框中没找到需要的IP,说明机器还没从Apollo取过配置,可以点击手动输入IP来输入,输入完后点击添加按钮


>注:对于公共Namespace的灰度规则,需要先指定要灰度的appId,然后再选择IP。
## 5.5 灰度发布
配置规则已经生效,不过灰度配置还没有发布。切换到`配置`Tab。
再次检查灰度的配置部分,如果没有问题,点击`灰度发布`。

在弹出框中可以看到主版本的值是2000,灰度版本即将发布的值是3000。填入其它信息后,点击发布。

发布后,切换到`灰度实例列表`Tab,就能看到10.32.21.22已经使用了灰度发布的值。

切换到`主版本`的`实例列表`,会看到主版本配置只有10.32.21.19在使用了。

后面可以继续配置的修改或规则的更改。配置的修改需要点击灰度发布后才会生效,规则的修改在规则点击完成后就会实时生效。
## 5.6 全量发布
如果灰度的配置测试下来比较理想,符合预期,那么就可以操作`全量发布`。
全量发布的效果是:
1. 灰度版本的配置会合并回主版本,在这个例子中,就是主版本的timeout会被更新成3000
2. 主版本的配置会自动进行一次发布
3. 在全量发布页面,可以选择是否保留当前灰度版本,默认为不保留。



我选择了不保留灰度版本,所以发布完的效果就是主版本的配置更新、灰度版本删除。点击主版本的实例列表,可以看到10.32.21.22和10.32.21.19都使用了主版本最新的配置。

## 5.7 放弃灰度
如果灰度版本不理想或者不需要了,可以点击`放弃灰度`。

## 5.8 发布历史
点击主版本的`发布历史`按钮,可以看到当前namespace的主版本以及灰度版本的发布历史。


# 六、其它功能配置
## 6.1 配置查看权限
从1.1.0版本开始,apollo-portal增加了查看权限的支持,可以支持配置某个环境只允许项目成员查看私有Namespace的配置。
这里的项目成员是指:
1. 项目的管理员
2. 具备该私有Namespace在该环境下的修改或发布权限
配置方式很简单,用超级管理员账号登录后,进入`管理员工具 - 系统参数`页面新增或修改`configView.memberOnly.envs`配置项即可。

## 6.2 配置访问密钥
Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验证的客户端才能访问敏感配置。如果应用开启了访问密钥,客户端需要配置密钥,否则无法获取配置。
1. 项目管理员打开管理密钥页面

2. 为项目的每个环境生成访问密钥,注意默认是禁用的,建议在客户端都配置完成后再开启

3. 客户端侧[配置访问密钥](zh/usage/java-sdk-user-guide#_1244-配置访问密钥)
# 七、最佳实践
## 7.1 安全相关
配置中心作为基础服务,存储着公司非常重要的配置信息,所以安全因素需要大家重点关注,下面列举了一些注意事项供大家参考,也欢迎大家分享自己的实践案例。
### 7.1.1 认证
建议接入公司统一的身份认证系统,如 SSO、LDAP 等,接入方式可以参考[Portal 实现用户登录功能](zh/development/portal-how-to-implement-user-login-function)
> 如果使用Apollo提供的Spring Security简单认证,务必记得要修改超级管理员apollo的密码
### 7.1.2 授权
Apollo 支持细粒度的权限控制,请务必根据实际情况做好权限控制:
1. [项目管理员权限](#_121-项目管理员权限)
* Apollo 默认允许所有登录用户创建项目,如果只允许部分用户创建项目,可以开启[创建项目权限控制](zh/deployment/distributed-deployment-guide?id=_3110-rolecreate-applicationenabled-是否开启创建项目权限控制)
2. [配置编辑、发布权限](#_122-配置编辑、发布权限)
* 配置编辑、发布权限支持按环境配置,比如开发环境开发人员可以自行完成配置编辑和发布的过程,但是生产环境发布权限交由测试或运维人员
* 生产环境建议同时开启[发布审核](zh/deployment/distributed-deployment-guide?id=_322-namespacelockswitch-一次发布只能有一个人修改开关,用于发布审核),从而控制一次配置发布只能由一个人修改,另一个人发布,确保配置修改得到充分检查
3. [配置查看权限](#_61-配置查看权限)
* 可以指定某个环境只允许项目成员查看私有Namespace的配置,从而避免敏感配置泄露,如生产环境
### 7.1.3 系统访问
除了用户权限,在系统访问上也需要加以考虑:
1. `apollo-configservice`和`apollo-adminservice`是基于内网可信网络设计的,所以出于安全考虑,禁止`apollo-configservice`和`apollo-adminservice`直接暴露在公网
2. 对敏感配置可以考虑开启[访问秘钥](#_62-%e9%85%8d%e7%bd%ae%e8%ae%bf%e9%97%ae%e5%af%86%e9%92%a5),从而只有经过身份验证的客户端才能访问敏感配置
3. 1.7.1及以上版本可以考虑为`apollo-adminservice`开启[访问控制](zh/deployment/distributed-deployment-guide?id=_326-admin-serviceaccesscontrolenabled-配置apollo-adminservice是否开启访问控制),从而只有[受控的](zh/deployment/distributed-deployment-guide?id=_3112-admin-serviceaccesstokens-设置apollo-portal访问各环境apollo-adminservice所需的access-token)`apollo-portal`才能访问对应接口,增强安全性
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/util/yaml/YamlParserTest.java | package com.ctrip.framework.apollo.util.yaml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.util.OrderedProperties;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.ByteArrayResource;
import org.yaml.snakeyaml.constructor.ConstructorException;
import org.yaml.snakeyaml.parser.ParserException;
public class YamlParserTest {
private YamlParser parser;
@Before
public void setUp() throws Exception {
parser = new YamlParser();
}
@After
public void tearDown() throws Exception {
MockInjector.reset();
}
@Test
public void testValidCases() throws Exception {
test("case1.yaml");
test("case3.yaml");
test("case4.yaml");
test("case5.yaml");
test("case6.yaml");
test("case7.yaml");
}
@Test(expected = ParserException.class)
public void testcase2() throws Exception {
testInvalid("case2.yaml");
}
@Test(expected = ParserException.class)
public void testcase8() throws Exception {
testInvalid("case8.yaml");
}
@Test(expected = ConstructorException.class)
public void testcase9() throws Exception {
testInvalid("case9.yaml");
}
@Test
public void testOrderProperties() throws IOException {
String yamlContent = loadYaml("orderedcase.yaml");
Properties nonOrderedProperties = parser.yamlToProperties(yamlContent);
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new OrderedProperties();
}
});
MockInjector.setInstance(PropertiesFactory.class, propertiesFactory);
parser = new YamlParser();
Properties orderedProperties = parser.yamlToProperties(yamlContent);
assertTrue(orderedProperties instanceof OrderedProperties);
checkPropertiesEquals(nonOrderedProperties, orderedProperties);
String[] propertyNames = orderedProperties.stringPropertyNames().toArray(new String[0]);
assertEquals("k2", propertyNames[0]);
assertEquals("k4", propertyNames[1]);
assertEquals("k1", propertyNames[2]);
}
private void test(String caseName) throws Exception {
String yamlContent = loadYaml(caseName);
check(yamlContent);
}
private String loadYaml(String caseName) throws IOException {
File file = new File("src/test/resources/yaml/" + caseName);
return Files.toString(file, Charsets.UTF_8);
}
private void testInvalid(String caseName) throws Exception {
File file = new File("src/test/resources/yaml/" + caseName);
String yamlContent = Files.toString(file, Charsets.UTF_8);
parser.yamlToProperties(yamlContent);
}
private void check(String yamlContent) {
YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
yamlPropertiesFactoryBean.setResources(new ByteArrayResource(yamlContent.getBytes()));
Properties expected = yamlPropertiesFactoryBean.getObject();
Properties actual = parser.yamlToProperties(yamlContent);
assertTrue("expected: " + expected + " actual: " + actual, checkPropertiesEquals(expected, actual));
}
private boolean checkPropertiesEquals(Properties expected, Properties actual) {
if (expected == actual)
return true;
if (expected.size() != actual.size())
return false;
for (Object key : expected.keySet()) {
if (!expected.getProperty((String) key).equals(actual.getProperty((String) key))) {
return false;
}
}
return true;
}
}
| package com.ctrip.framework.apollo.util.yaml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.util.OrderedProperties;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.ByteArrayResource;
import org.yaml.snakeyaml.constructor.ConstructorException;
import org.yaml.snakeyaml.parser.ParserException;
public class YamlParserTest {
private YamlParser parser;
@Before
public void setUp() throws Exception {
parser = new YamlParser();
}
@After
public void tearDown() throws Exception {
MockInjector.reset();
}
@Test
public void testValidCases() throws Exception {
test("case1.yaml");
test("case3.yaml");
test("case4.yaml");
test("case5.yaml");
test("case6.yaml");
test("case7.yaml");
}
@Test(expected = ParserException.class)
public void testcase2() throws Exception {
testInvalid("case2.yaml");
}
@Test(expected = ParserException.class)
public void testcase8() throws Exception {
testInvalid("case8.yaml");
}
@Test(expected = ConstructorException.class)
public void testcase9() throws Exception {
testInvalid("case9.yaml");
}
@Test
public void testOrderProperties() throws IOException {
String yamlContent = loadYaml("orderedcase.yaml");
Properties nonOrderedProperties = parser.yamlToProperties(yamlContent);
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new OrderedProperties();
}
});
MockInjector.setInstance(PropertiesFactory.class, propertiesFactory);
parser = new YamlParser();
Properties orderedProperties = parser.yamlToProperties(yamlContent);
assertTrue(orderedProperties instanceof OrderedProperties);
checkPropertiesEquals(nonOrderedProperties, orderedProperties);
String[] propertyNames = orderedProperties.stringPropertyNames().toArray(new String[0]);
assertEquals("k2", propertyNames[0]);
assertEquals("k4", propertyNames[1]);
assertEquals("k1", propertyNames[2]);
}
private void test(String caseName) throws Exception {
String yamlContent = loadYaml(caseName);
check(yamlContent);
}
private String loadYaml(String caseName) throws IOException {
File file = new File("src/test/resources/yaml/" + caseName);
return Files.toString(file, Charsets.UTF_8);
}
private void testInvalid(String caseName) throws Exception {
File file = new File("src/test/resources/yaml/" + caseName);
String yamlContent = Files.toString(file, Charsets.UTF_8);
parser.yamlToProperties(yamlContent);
}
private void check(String yamlContent) {
YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
yamlPropertiesFactoryBean.setResources(new ByteArrayResource(yamlContent.getBytes()));
Properties expected = yamlPropertiesFactoryBean.getObject();
Properties actual = parser.yamlToProperties(yamlContent);
assertTrue("expected: " + expected + " actual: " + actual, checkPropertiesEquals(expected, actual));
}
private boolean checkPropertiesEquals(Properties expected, Properties actual) {
if (expected == actual)
return true;
if (expected.size() != actual.size())
return false;
for (Object key : expected.keySet()) {
if (!expected.getProperty((String) key).equals(actual.getProperty((String) key))) {
return false;
}
}
return true;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/spi/configuration/MQConfiguration.java | package com.ctrip.framework.apollo.portal.spi.configuration;
import com.ctrip.framework.apollo.common.condition.ConditionalOnMissingProfile;
import com.ctrip.framework.apollo.portal.spi.ctrip.CtripMQService;
import com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultMQService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
public class MQConfiguration {
@Configuration
@Profile("ctrip")
public static class CtripMQConfiguration {
@Bean
public CtripMQService mqService() {
return new CtripMQService();
}
}
/**
* spring.profiles.active != ctrip
*/
@Configuration
@ConditionalOnMissingProfile({"ctrip"})
public static class DefaultMQConfiguration {
@Bean
public DefaultMQService mqService() {
return new DefaultMQService();
}
}
}
| package com.ctrip.framework.apollo.portal.spi.configuration;
import com.ctrip.framework.apollo.common.condition.ConditionalOnMissingProfile;
import com.ctrip.framework.apollo.portal.spi.ctrip.CtripMQService;
import com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultMQService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
public class MQConfiguration {
@Configuration
@Profile("ctrip")
public static class CtripMQConfiguration {
@Bean
public CtripMQService mqService() {
return new CtripMQService();
}
}
/**
* spring.profiles.active != ctrip
*/
@Configuration
@ConditionalOnMissingProfile({"ctrip"})
public static class DefaultMQConfiguration {
@Bean
public DefaultMQService mqService() {
return new DefaultMQService();
}
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultNetworkProvider.java | package com.ctrip.framework.foundation.internals.provider;
import com.ctrip.framework.foundation.internals.NetworkInterfaceManager;
import com.ctrip.framework.foundation.spi.provider.NetworkProvider;
import com.ctrip.framework.foundation.spi.provider.Provider;
public class DefaultNetworkProvider implements NetworkProvider {
@Override
public String getProperty(String name, String defaultValue) {
if ("host.address".equalsIgnoreCase(name)) {
String val = getHostAddress();
return val == null ? defaultValue : val;
}
if ("host.name".equalsIgnoreCase(name)) {
String val = getHostName();
return val == null ? defaultValue : val;
}
return defaultValue;
}
@Override
public void initialize() {
}
@Override
public String getHostAddress() {
return NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
}
@Override
public String getHostName() {
return NetworkInterfaceManager.INSTANCE.getLocalHostName();
}
@Override
public Class<? extends Provider> getType() {
return NetworkProvider.class;
}
@Override
public String toString() {
return "hostName [" + getHostName() + "] hostIP [" + getHostAddress() + "] (DefaultNetworkProvider)";
}
}
| package com.ctrip.framework.foundation.internals.provider;
import com.ctrip.framework.foundation.internals.NetworkInterfaceManager;
import com.ctrip.framework.foundation.spi.provider.NetworkProvider;
import com.ctrip.framework.foundation.spi.provider.Provider;
public class DefaultNetworkProvider implements NetworkProvider {
@Override
public String getProperty(String name, String defaultValue) {
if ("host.address".equalsIgnoreCase(name)) {
String val = getHostAddress();
return val == null ? defaultValue : val;
}
if ("host.name".equalsIgnoreCase(name)) {
String val = getHostName();
return val == null ? defaultValue : val;
}
return defaultValue;
}
@Override
public void initialize() {
}
@Override
public String getHostAddress() {
return NetworkInterfaceManager.INSTANCE.getLocalHostAddress();
}
@Override
public String getHostName() {
return NetworkInterfaceManager.INSTANCE.getLocalHostName();
}
@Override
public Class<? extends Provider> getType() {
return NetworkProvider.class;
}
@Override
public String toString() {
return "hostName [" + getHostName() + "] hostIP [" + getHostAddress() + "] (DefaultNetworkProvider)";
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java | package com.ctrip.framework.apollo.internals;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.io.Files;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Created by Jason on 4/9/16.
*/
public class LocalFileConfigRepositoryTest {
private File someBaseDir;
private String someNamespace;
private ConfigRepository upstreamRepo;
private Properties someProperties;
private static String someAppId = "someApp";
private static String someCluster = "someCluster";
private String defaultKey;
private String defaultValue;
private ConfigSourceType someSourceType;
@Before
public void setUp() throws Exception {
someBaseDir = new File("src/test/resources/config-cache");
someBaseDir.mkdir();
someNamespace = "someName";
someProperties = new Properties();
defaultKey = "defaultKey";
defaultValue = "defaultValue";
someProperties.setProperty(defaultKey, defaultValue);
someSourceType = ConfigSourceType.REMOTE;
upstreamRepo = mock(ConfigRepository.class);
when(upstreamRepo.getConfig()).thenReturn(someProperties);
when(upstreamRepo.getSourceType()).thenReturn(someSourceType);
MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil());
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
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();
recursiveDelete(someBaseDir);
}
//helper method to clean created files
private void recursiveDelete(File file) {
if (!file.exists()) {
return;
}
if (file.isDirectory()) {
for (File f : file.listFiles()) {
recursiveDelete(f);
}
}
file.delete();
}
private String assembleLocalCacheFileName() {
return String.format("%s.properties", Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR)
.join(someAppId, someCluster, someNamespace));
}
@Test
public void testLoadConfigWithLocalFile() throws Exception {
String someKey = "someKey";
String someValue = "someValue\nxxx\nyyy";
Properties someProperties = new Properties();
someProperties.setProperty(someKey, someValue);
createLocalCachePropertyFile(someProperties);
LocalFileConfigRepository localRepo = new LocalFileConfigRepository(someNamespace);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties properties = localRepo.getConfig();
assertEquals(someValue, properties.getProperty(someKey));
assertEquals(ConfigSourceType.LOCAL, localRepo.getSourceType());
}
@Test
public void testLoadConfigWithLocalFileAndFallbackRepo() throws Exception {
File file = new File(someBaseDir, assembleLocalCacheFileName());
String someValue = "someValue";
Files.write(defaultKey + "=" + someValue, file, Charsets.UTF_8);
LocalFileConfigRepository localRepo = new LocalFileConfigRepository(someNamespace, upstreamRepo);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties properties = localRepo.getConfig();
assertEquals(defaultValue, properties.getProperty(defaultKey));
assertEquals(someSourceType, localRepo.getSourceType());
}
@Test
public void testLoadConfigWithNoLocalFile() throws Exception {
LocalFileConfigRepository localFileConfigRepository =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
localFileConfigRepository.setLocalCacheDir(someBaseDir, true);
Properties result = localFileConfigRepository.getConfig();
assertThat(
"LocalFileConfigRepository's properties should be the same as fallback repo's when there is no local cache",
result.entrySet(), equalTo(someProperties.entrySet()));
assertEquals(someSourceType, localFileConfigRepository.getSourceType());
}
@Test
public void testLoadConfigWithNoLocalFileMultipleTimes() throws Exception {
LocalFileConfigRepository localRepo =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties someProperties = localRepo.getConfig();
LocalFileConfigRepository
anotherLocalRepoWithNoFallback =
new LocalFileConfigRepository(someNamespace);
anotherLocalRepoWithNoFallback.setLocalCacheDir(someBaseDir, true);
Properties anotherProperties = anotherLocalRepoWithNoFallback.getConfig();
assertThat(
"LocalFileConfigRepository should persist local cache files and return that afterwards",
someProperties.entrySet(), equalTo(anotherProperties.entrySet()));
assertEquals(someSourceType, localRepo.getSourceType());
}
@Test
public void testOnRepositoryChange() throws Exception {
RepositoryChangeListener someListener = mock(RepositoryChangeListener.class);
LocalFileConfigRepository localFileConfigRepository =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
assertEquals(someSourceType, localFileConfigRepository.getSourceType());
localFileConfigRepository.setLocalCacheDir(someBaseDir, true);
localFileConfigRepository.addChangeListener(someListener);
localFileConfigRepository.getConfig();
Properties anotherProperties = new Properties();
anotherProperties.put("anotherKey", "anotherValue");
ConfigSourceType anotherSourceType = ConfigSourceType.NONE;
when(upstreamRepo.getSourceType()).thenReturn(anotherSourceType);
localFileConfigRepository.onRepositoryChange(someNamespace, anotherProperties);
final ArgumentCaptor<Properties> captor = ArgumentCaptor.forClass(Properties.class);
verify(someListener, times(1)).onRepositoryChange(eq(someNamespace), captor.capture());
assertEquals(anotherProperties, captor.getValue());
assertEquals(anotherSourceType, localFileConfigRepository.getSourceType());
}
public static class MockConfigUtil extends ConfigUtil {
@Override
public String getAppId() {
return someAppId;
}
@Override
public String getCluster() {
return someCluster;
}
}
private File createLocalCachePropertyFile(Properties properties) throws IOException {
File file = new File(someBaseDir, assembleLocalCacheFileName());
FileOutputStream in = null;
try {
in = new FileOutputStream(file);
properties.store(in, "Persisted by LocalFileConfigRepositoryTest");
} finally {
if (in != null) {
in.close();
}
}
return file;
}
}
| package com.ctrip.framework.apollo.internals;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.io.Files;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Created by Jason on 4/9/16.
*/
public class LocalFileConfigRepositoryTest {
private File someBaseDir;
private String someNamespace;
private ConfigRepository upstreamRepo;
private Properties someProperties;
private static String someAppId = "someApp";
private static String someCluster = "someCluster";
private String defaultKey;
private String defaultValue;
private ConfigSourceType someSourceType;
@Before
public void setUp() throws Exception {
someBaseDir = new File("src/test/resources/config-cache");
someBaseDir.mkdir();
someNamespace = "someName";
someProperties = new Properties();
defaultKey = "defaultKey";
defaultValue = "defaultValue";
someProperties.setProperty(defaultKey, defaultValue);
someSourceType = ConfigSourceType.REMOTE;
upstreamRepo = mock(ConfigRepository.class);
when(upstreamRepo.getConfig()).thenReturn(someProperties);
when(upstreamRepo.getSourceType()).thenReturn(someSourceType);
MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil());
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
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();
recursiveDelete(someBaseDir);
}
//helper method to clean created files
private void recursiveDelete(File file) {
if (!file.exists()) {
return;
}
if (file.isDirectory()) {
for (File f : file.listFiles()) {
recursiveDelete(f);
}
}
file.delete();
}
private String assembleLocalCacheFileName() {
return String.format("%s.properties", Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR)
.join(someAppId, someCluster, someNamespace));
}
@Test
public void testLoadConfigWithLocalFile() throws Exception {
String someKey = "someKey";
String someValue = "someValue\nxxx\nyyy";
Properties someProperties = new Properties();
someProperties.setProperty(someKey, someValue);
createLocalCachePropertyFile(someProperties);
LocalFileConfigRepository localRepo = new LocalFileConfigRepository(someNamespace);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties properties = localRepo.getConfig();
assertEquals(someValue, properties.getProperty(someKey));
assertEquals(ConfigSourceType.LOCAL, localRepo.getSourceType());
}
@Test
public void testLoadConfigWithLocalFileAndFallbackRepo() throws Exception {
File file = new File(someBaseDir, assembleLocalCacheFileName());
String someValue = "someValue";
Files.write(defaultKey + "=" + someValue, file, Charsets.UTF_8);
LocalFileConfigRepository localRepo = new LocalFileConfigRepository(someNamespace, upstreamRepo);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties properties = localRepo.getConfig();
assertEquals(defaultValue, properties.getProperty(defaultKey));
assertEquals(someSourceType, localRepo.getSourceType());
}
@Test
public void testLoadConfigWithNoLocalFile() throws Exception {
LocalFileConfigRepository localFileConfigRepository =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
localFileConfigRepository.setLocalCacheDir(someBaseDir, true);
Properties result = localFileConfigRepository.getConfig();
assertThat(
"LocalFileConfigRepository's properties should be the same as fallback repo's when there is no local cache",
result.entrySet(), equalTo(someProperties.entrySet()));
assertEquals(someSourceType, localFileConfigRepository.getSourceType());
}
@Test
public void testLoadConfigWithNoLocalFileMultipleTimes() throws Exception {
LocalFileConfigRepository localRepo =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
localRepo.setLocalCacheDir(someBaseDir, true);
Properties someProperties = localRepo.getConfig();
LocalFileConfigRepository
anotherLocalRepoWithNoFallback =
new LocalFileConfigRepository(someNamespace);
anotherLocalRepoWithNoFallback.setLocalCacheDir(someBaseDir, true);
Properties anotherProperties = anotherLocalRepoWithNoFallback.getConfig();
assertThat(
"LocalFileConfigRepository should persist local cache files and return that afterwards",
someProperties.entrySet(), equalTo(anotherProperties.entrySet()));
assertEquals(someSourceType, localRepo.getSourceType());
}
@Test
public void testOnRepositoryChange() throws Exception {
RepositoryChangeListener someListener = mock(RepositoryChangeListener.class);
LocalFileConfigRepository localFileConfigRepository =
new LocalFileConfigRepository(someNamespace, upstreamRepo);
assertEquals(someSourceType, localFileConfigRepository.getSourceType());
localFileConfigRepository.setLocalCacheDir(someBaseDir, true);
localFileConfigRepository.addChangeListener(someListener);
localFileConfigRepository.getConfig();
Properties anotherProperties = new Properties();
anotherProperties.put("anotherKey", "anotherValue");
ConfigSourceType anotherSourceType = ConfigSourceType.NONE;
when(upstreamRepo.getSourceType()).thenReturn(anotherSourceType);
localFileConfigRepository.onRepositoryChange(someNamespace, anotherProperties);
final ArgumentCaptor<Properties> captor = ArgumentCaptor.forClass(Properties.class);
verify(someListener, times(1)).onRepositoryChange(eq(someNamespace), captor.capture());
assertEquals(anotherProperties, captor.getValue());
assertEquals(anotherSourceType, localFileConfigRepository.getSourceType());
}
public static class MockConfigUtil extends ConfigUtil {
@Override
public String getAppId() {
return someAppId;
}
@Override
public String getCluster() {
return someCluster;
}
}
private File createLocalCachePropertyFile(Properties properties) throws IOException {
File file = new File(someBaseDir, assembleLocalCacheFileName());
FileOutputStream in = null;
try {
in = new FileOutputStream(file);
properties.store(in, "Persisted by LocalFileConfigRepositoryTest");
} finally {
if (in != null) {
in.close();
}
}
return file;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/internals/ConfigServiceLocatorTest.java | package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.assertEquals;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import java.util.List;
import org.junit.After;
import org.junit.Test;
public class ConfigServiceLocatorTest {
@After
public void tearDown() throws Exception {
System.clearProperty("apollo.configService");
}
@Test
public void testGetConfigServicesWithSystemProperty() throws Exception {
String someConfigServiceUrl = " someConfigServiceUrl ";
String anotherConfigServiceUrl = " anotherConfigServiceUrl ";
System.setProperty("apollo.configService", someConfigServiceUrl + "," + anotherConfigServiceUrl);
ConfigServiceLocator configServiceLocator = new ConfigServiceLocator();
List<ServiceDTO> result = configServiceLocator.getConfigServices();
assertEquals(2, result.size());
assertEquals(someConfigServiceUrl.trim(), result.get(0).getHomepageUrl());
assertEquals(anotherConfigServiceUrl.trim(), result.get(1).getHomepageUrl());
}
}
| package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.assertEquals;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import java.util.List;
import org.junit.After;
import org.junit.Test;
public class ConfigServiceLocatorTest {
@After
public void tearDown() throws Exception {
System.clearProperty("apollo.configService");
}
@Test
public void testGetConfigServicesWithSystemProperty() throws Exception {
String someConfigServiceUrl = " someConfigServiceUrl ";
String anotherConfigServiceUrl = " anotherConfigServiceUrl ";
System.setProperty("apollo.configService", someConfigServiceUrl + "," + anotherConfigServiceUrl);
ConfigServiceLocator configServiceLocator = new ConfigServiceLocator();
List<ServiceDTO> result = configServiceLocator.getConfigServices();
assertEquals(2, result.size());
assertEquals(someConfigServiceUrl.trim(), result.get(0).getHomepageUrl());
assertEquals(anotherConfigServiceUrl.trim(), result.get(1).getHomepageUrl());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-common/src/main/java/com/ctrip/framework/apollo/common/customize/package-info.java | /**
* 携程内部的日志系统,第三方公司可删除
*/
package com.ctrip.framework.apollo.common.customize;
| /**
* 携程内部的日志系统,第三方公司可删除
*/
package com.ctrip.framework.apollo.common.customize;
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/openapi/service/ConsumerService.java | package com.ctrip.framework.apollo.openapi.service;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.openapi.entity.Consumer;
import com.ctrip.framework.apollo.openapi.entity.ConsumerAudit;
import com.ctrip.framework.apollo.openapi.entity.ConsumerRole;
import com.ctrip.framework.apollo.openapi.entity.ConsumerToken;
import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.po.Role;
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
import com.ctrip.framework.apollo.portal.util.RoleUtils;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.hash.Hashing;
import org.apache.commons.lang.time.FastDateFormat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author Jason Song([email protected])
*/
@Service
public class ConsumerService {
private static final FastDateFormat TIMESTAMP_FORMAT = FastDateFormat.getInstance("yyyyMMddHHmmss");
private static final Joiner KEY_JOINER = Joiner.on("|");
private final UserInfoHolder userInfoHolder;
private final ConsumerTokenRepository consumerTokenRepository;
private final ConsumerRepository consumerRepository;
private final ConsumerAuditRepository consumerAuditRepository;
private final ConsumerRoleRepository consumerRoleRepository;
private final PortalConfig portalConfig;
private final RolePermissionService rolePermissionService;
private final UserService userService;
public ConsumerService(
final UserInfoHolder userInfoHolder,
final ConsumerTokenRepository consumerTokenRepository,
final ConsumerRepository consumerRepository,
final ConsumerAuditRepository consumerAuditRepository,
final ConsumerRoleRepository consumerRoleRepository,
final PortalConfig portalConfig,
final RolePermissionService rolePermissionService,
final UserService userService) {
this.userInfoHolder = userInfoHolder;
this.consumerTokenRepository = consumerTokenRepository;
this.consumerRepository = consumerRepository;
this.consumerAuditRepository = consumerAuditRepository;
this.consumerRoleRepository = consumerRoleRepository;
this.portalConfig = portalConfig;
this.rolePermissionService = rolePermissionService;
this.userService = userService;
}
public Consumer createConsumer(Consumer consumer) {
String appId = consumer.getAppId();
Consumer managedConsumer = consumerRepository.findByAppId(appId);
if (managedConsumer != null) {
throw new BadRequestException("Consumer already exist");
}
String ownerName = consumer.getOwnerName();
UserInfo owner = userService.findByUserId(ownerName);
if (owner == null) {
throw new BadRequestException(String.format("User does not exist. UserId = %s", ownerName));
}
consumer.setOwnerEmail(owner.getEmail());
String operator = userInfoHolder.getUser().getUserId();
consumer.setDataChangeCreatedBy(operator);
consumer.setDataChangeLastModifiedBy(operator);
return consumerRepository.save(consumer);
}
public ConsumerToken generateAndSaveConsumerToken(Consumer consumer, Date expires) {
Preconditions.checkArgument(consumer != null, "Consumer can not be null");
ConsumerToken consumerToken = generateConsumerToken(consumer, expires);
consumerToken.setId(0);
return consumerTokenRepository.save(consumerToken);
}
public ConsumerToken getConsumerTokenByAppId(String appId) {
Consumer consumer = consumerRepository.findByAppId(appId);
if (consumer == null) {
return null;
}
return consumerTokenRepository.findByConsumerId(consumer.getId());
}
public Long getConsumerIdByToken(String token) {
if (Strings.isNullOrEmpty(token)) {
return null;
}
ConsumerToken consumerToken = consumerTokenRepository.findTopByTokenAndExpiresAfter(token,
new Date());
return consumerToken == null ? null : consumerToken.getConsumerId();
}
public Consumer getConsumerByConsumerId(long consumerId) {
return consumerRepository.findById(consumerId).orElse(null);
}
public List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName) {
return assignNamespaceRoleToConsumer(token, appId, namespaceName, null);
}
@Transactional
public List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName, String env) {
Long consumerId = getConsumerIdByToken(token);
if (consumerId == null) {
throw new BadRequestException("Token is Illegal");
}
Role namespaceModifyRole =
rolePermissionService.findRoleByRoleName(RoleUtils.buildModifyNamespaceRoleName(appId, namespaceName, env));
Role namespaceReleaseRole =
rolePermissionService.findRoleByRoleName(RoleUtils.buildReleaseNamespaceRoleName(appId, namespaceName, env));
if (namespaceModifyRole == null || namespaceReleaseRole == null) {
throw new BadRequestException("Namespace's role does not exist. Please check whether namespace has created.");
}
long namespaceModifyRoleId = namespaceModifyRole.getId();
long namespaceReleaseRoleId = namespaceReleaseRole.getId();
ConsumerRole managedModifyRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, namespaceModifyRoleId);
ConsumerRole managedReleaseRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, namespaceReleaseRoleId);
if (managedModifyRole != null && managedReleaseRole != null) {
return Arrays.asList(managedModifyRole, managedReleaseRole);
}
String operator = userInfoHolder.getUser().getUserId();
ConsumerRole namespaceModifyConsumerRole = createConsumerRole(consumerId, namespaceModifyRoleId, operator);
ConsumerRole namespaceReleaseConsumerRole = createConsumerRole(consumerId, namespaceReleaseRoleId, operator);
ConsumerRole createdModifyConsumerRole = consumerRoleRepository.save(namespaceModifyConsumerRole);
ConsumerRole createdReleaseConsumerRole = consumerRoleRepository.save(namespaceReleaseConsumerRole);
return Arrays.asList(createdModifyConsumerRole, createdReleaseConsumerRole);
}
@Transactional
public ConsumerRole assignAppRoleToConsumer(String token, String appId) {
Long consumerId = getConsumerIdByToken(token);
if (consumerId == null) {
throw new BadRequestException("Token is Illegal");
}
Role masterRole = rolePermissionService.findRoleByRoleName(RoleUtils.buildAppMasterRoleName(appId));
if (masterRole == null) {
throw new BadRequestException("App's role does not exist. Please check whether app has created.");
}
long roleId = masterRole.getId();
ConsumerRole managedModifyRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, roleId);
if (managedModifyRole != null) {
return managedModifyRole;
}
String operator = userInfoHolder.getUser().getUserId();
ConsumerRole consumerRole = createConsumerRole(consumerId, roleId, operator);
return consumerRoleRepository.save(consumerRole);
}
@Transactional
public void createConsumerAudits(Iterable<ConsumerAudit> consumerAudits) {
consumerAuditRepository.saveAll(consumerAudits);
}
@Transactional
public ConsumerToken createConsumerToken(ConsumerToken entity) {
entity.setId(0); //for protection
return consumerTokenRepository.save(entity);
}
private ConsumerToken generateConsumerToken(Consumer consumer, Date expires) {
long consumerId = consumer.getId();
String createdBy = userInfoHolder.getUser().getUserId();
Date createdTime = new Date();
ConsumerToken consumerToken = new ConsumerToken();
consumerToken.setConsumerId(consumerId);
consumerToken.setExpires(expires);
consumerToken.setDataChangeCreatedBy(createdBy);
consumerToken.setDataChangeCreatedTime(createdTime);
consumerToken.setDataChangeLastModifiedBy(createdBy);
consumerToken.setDataChangeLastModifiedTime(createdTime);
generateAndEnrichToken(consumer, consumerToken);
return consumerToken;
}
void generateAndEnrichToken(Consumer consumer, ConsumerToken consumerToken) {
Preconditions.checkArgument(consumer != null);
if (consumerToken.getDataChangeCreatedTime() == null) {
consumerToken.setDataChangeCreatedTime(new Date());
}
consumerToken.setToken(generateToken(consumer.getAppId(), consumerToken
.getDataChangeCreatedTime(), portalConfig.consumerTokenSalt()));
}
String generateToken(String consumerAppId, Date generationTime, String
consumerTokenSalt) {
return Hashing.sha1().hashString(KEY_JOINER.join(consumerAppId, TIMESTAMP_FORMAT.format
(generationTime), consumerTokenSalt), Charsets.UTF_8).toString();
}
ConsumerRole createConsumerRole(Long consumerId, Long roleId, String operator) {
ConsumerRole consumerRole = new ConsumerRole();
consumerRole.setConsumerId(consumerId);
consumerRole.setRoleId(roleId);
consumerRole.setDataChangeCreatedBy(operator);
consumerRole.setDataChangeLastModifiedBy(operator);
return consumerRole;
}
}
| package com.ctrip.framework.apollo.openapi.service;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.openapi.entity.Consumer;
import com.ctrip.framework.apollo.openapi.entity.ConsumerAudit;
import com.ctrip.framework.apollo.openapi.entity.ConsumerRole;
import com.ctrip.framework.apollo.openapi.entity.ConsumerToken;
import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.po.Role;
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
import com.ctrip.framework.apollo.portal.util.RoleUtils;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.hash.Hashing;
import org.apache.commons.lang.time.FastDateFormat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author Jason Song([email protected])
*/
@Service
public class ConsumerService {
private static final FastDateFormat TIMESTAMP_FORMAT = FastDateFormat.getInstance("yyyyMMddHHmmss");
private static final Joiner KEY_JOINER = Joiner.on("|");
private final UserInfoHolder userInfoHolder;
private final ConsumerTokenRepository consumerTokenRepository;
private final ConsumerRepository consumerRepository;
private final ConsumerAuditRepository consumerAuditRepository;
private final ConsumerRoleRepository consumerRoleRepository;
private final PortalConfig portalConfig;
private final RolePermissionService rolePermissionService;
private final UserService userService;
public ConsumerService(
final UserInfoHolder userInfoHolder,
final ConsumerTokenRepository consumerTokenRepository,
final ConsumerRepository consumerRepository,
final ConsumerAuditRepository consumerAuditRepository,
final ConsumerRoleRepository consumerRoleRepository,
final PortalConfig portalConfig,
final RolePermissionService rolePermissionService,
final UserService userService) {
this.userInfoHolder = userInfoHolder;
this.consumerTokenRepository = consumerTokenRepository;
this.consumerRepository = consumerRepository;
this.consumerAuditRepository = consumerAuditRepository;
this.consumerRoleRepository = consumerRoleRepository;
this.portalConfig = portalConfig;
this.rolePermissionService = rolePermissionService;
this.userService = userService;
}
public Consumer createConsumer(Consumer consumer) {
String appId = consumer.getAppId();
Consumer managedConsumer = consumerRepository.findByAppId(appId);
if (managedConsumer != null) {
throw new BadRequestException("Consumer already exist");
}
String ownerName = consumer.getOwnerName();
UserInfo owner = userService.findByUserId(ownerName);
if (owner == null) {
throw new BadRequestException(String.format("User does not exist. UserId = %s", ownerName));
}
consumer.setOwnerEmail(owner.getEmail());
String operator = userInfoHolder.getUser().getUserId();
consumer.setDataChangeCreatedBy(operator);
consumer.setDataChangeLastModifiedBy(operator);
return consumerRepository.save(consumer);
}
public ConsumerToken generateAndSaveConsumerToken(Consumer consumer, Date expires) {
Preconditions.checkArgument(consumer != null, "Consumer can not be null");
ConsumerToken consumerToken = generateConsumerToken(consumer, expires);
consumerToken.setId(0);
return consumerTokenRepository.save(consumerToken);
}
public ConsumerToken getConsumerTokenByAppId(String appId) {
Consumer consumer = consumerRepository.findByAppId(appId);
if (consumer == null) {
return null;
}
return consumerTokenRepository.findByConsumerId(consumer.getId());
}
public Long getConsumerIdByToken(String token) {
if (Strings.isNullOrEmpty(token)) {
return null;
}
ConsumerToken consumerToken = consumerTokenRepository.findTopByTokenAndExpiresAfter(token,
new Date());
return consumerToken == null ? null : consumerToken.getConsumerId();
}
public Consumer getConsumerByConsumerId(long consumerId) {
return consumerRepository.findById(consumerId).orElse(null);
}
public List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName) {
return assignNamespaceRoleToConsumer(token, appId, namespaceName, null);
}
@Transactional
public List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName, String env) {
Long consumerId = getConsumerIdByToken(token);
if (consumerId == null) {
throw new BadRequestException("Token is Illegal");
}
Role namespaceModifyRole =
rolePermissionService.findRoleByRoleName(RoleUtils.buildModifyNamespaceRoleName(appId, namespaceName, env));
Role namespaceReleaseRole =
rolePermissionService.findRoleByRoleName(RoleUtils.buildReleaseNamespaceRoleName(appId, namespaceName, env));
if (namespaceModifyRole == null || namespaceReleaseRole == null) {
throw new BadRequestException("Namespace's role does not exist. Please check whether namespace has created.");
}
long namespaceModifyRoleId = namespaceModifyRole.getId();
long namespaceReleaseRoleId = namespaceReleaseRole.getId();
ConsumerRole managedModifyRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, namespaceModifyRoleId);
ConsumerRole managedReleaseRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, namespaceReleaseRoleId);
if (managedModifyRole != null && managedReleaseRole != null) {
return Arrays.asList(managedModifyRole, managedReleaseRole);
}
String operator = userInfoHolder.getUser().getUserId();
ConsumerRole namespaceModifyConsumerRole = createConsumerRole(consumerId, namespaceModifyRoleId, operator);
ConsumerRole namespaceReleaseConsumerRole = createConsumerRole(consumerId, namespaceReleaseRoleId, operator);
ConsumerRole createdModifyConsumerRole = consumerRoleRepository.save(namespaceModifyConsumerRole);
ConsumerRole createdReleaseConsumerRole = consumerRoleRepository.save(namespaceReleaseConsumerRole);
return Arrays.asList(createdModifyConsumerRole, createdReleaseConsumerRole);
}
@Transactional
public ConsumerRole assignAppRoleToConsumer(String token, String appId) {
Long consumerId = getConsumerIdByToken(token);
if (consumerId == null) {
throw new BadRequestException("Token is Illegal");
}
Role masterRole = rolePermissionService.findRoleByRoleName(RoleUtils.buildAppMasterRoleName(appId));
if (masterRole == null) {
throw new BadRequestException("App's role does not exist. Please check whether app has created.");
}
long roleId = masterRole.getId();
ConsumerRole managedModifyRole = consumerRoleRepository.findByConsumerIdAndRoleId(consumerId, roleId);
if (managedModifyRole != null) {
return managedModifyRole;
}
String operator = userInfoHolder.getUser().getUserId();
ConsumerRole consumerRole = createConsumerRole(consumerId, roleId, operator);
return consumerRoleRepository.save(consumerRole);
}
@Transactional
public void createConsumerAudits(Iterable<ConsumerAudit> consumerAudits) {
consumerAuditRepository.saveAll(consumerAudits);
}
@Transactional
public ConsumerToken createConsumerToken(ConsumerToken entity) {
entity.setId(0); //for protection
return consumerTokenRepository.save(entity);
}
private ConsumerToken generateConsumerToken(Consumer consumer, Date expires) {
long consumerId = consumer.getId();
String createdBy = userInfoHolder.getUser().getUserId();
Date createdTime = new Date();
ConsumerToken consumerToken = new ConsumerToken();
consumerToken.setConsumerId(consumerId);
consumerToken.setExpires(expires);
consumerToken.setDataChangeCreatedBy(createdBy);
consumerToken.setDataChangeCreatedTime(createdTime);
consumerToken.setDataChangeLastModifiedBy(createdBy);
consumerToken.setDataChangeLastModifiedTime(createdTime);
generateAndEnrichToken(consumer, consumerToken);
return consumerToken;
}
void generateAndEnrichToken(Consumer consumer, ConsumerToken consumerToken) {
Preconditions.checkArgument(consumer != null);
if (consumerToken.getDataChangeCreatedTime() == null) {
consumerToken.setDataChangeCreatedTime(new Date());
}
consumerToken.setToken(generateToken(consumer.getAppId(), consumerToken
.getDataChangeCreatedTime(), portalConfig.consumerTokenSalt()));
}
String generateToken(String consumerAppId, Date generationTime, String
consumerTokenSalt) {
return Hashing.sha1().hashString(KEY_JOINER.join(consumerAppId, TIMESTAMP_FORMAT.format
(generationTime), consumerTokenSalt), Charsets.UTF_8).toString();
}
ConsumerRole createConsumerRole(Long consumerId, Long roleId, String operator) {
ConsumerRole consumerRole = new ConsumerRole();
consumerRole.setConsumerId(consumerId);
consumerRole.setRoleId(roleId);
consumerRole.setDataChangeCreatedBy(operator);
consumerRole.setDataChangeLastModifiedBy(operator);
return consumerRole;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/ConfigsImportController.java | package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.portal.service.ConfigsImportService;
import com.ctrip.framework.apollo.portal.util.ConfigFileUtils;
import java.io.IOException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
* Import the configs from file.
* First version: move code from {@link ConfigsExportController}
* @author wxq
*/
@RestController
public class ConfigsImportController {
private final ConfigsImportService configsImportService;
public ConfigsImportController(
final ConfigsImportService configsImportService
) {
this.configsImportService = configsImportService;
}
/**
* copy from old {@link ConfigsExportController}.
* @param file Yml file's name must ends with {@code .yml}.
* Properties file's name must ends with {@code .properties}.
* etc.
* @throws IOException
*/
@PreAuthorize(value = "@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)")
@PostMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/import")
public void importConfigFile(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam("file") MultipartFile file) throws IOException {
// check file
ConfigFileUtils.check(file);
final String format = ConfigFileUtils.getFormat(file.getOriginalFilename());
final String standardFilename = ConfigFileUtils.toFilename(appId, clusterName, namespaceName, ConfigFileFormat.fromString(format));
configsImportService.importOneConfigFromFile(env, standardFilename, file.getInputStream());
}
}
| package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.portal.service.ConfigsImportService;
import com.ctrip.framework.apollo.portal.util.ConfigFileUtils;
import java.io.IOException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
* Import the configs from file.
* First version: move code from {@link ConfigsExportController}
* @author wxq
*/
@RestController
public class ConfigsImportController {
private final ConfigsImportService configsImportService;
public ConfigsImportController(
final ConfigsImportService configsImportService
) {
this.configsImportService = configsImportService;
}
/**
* copy from old {@link ConfigsExportController}.
* @param file Yml file's name must ends with {@code .yml}.
* Properties file's name must ends with {@code .properties}.
* etc.
* @throws IOException
*/
@PreAuthorize(value = "@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)")
@PostMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/import")
public void importConfigFile(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam("file") MultipartFile file) throws IOException {
// check file
ConfigFileUtils.check(file);
final String format = ConfigFileUtils.getFormat(file.getOriginalFilename());
final String standardFilename = ConfigFileUtils.toFilename(appId, clusterName, namespaceName, ConfigFileFormat.fromString(format));
configsImportService.importOneConfigFromFile(env, standardFilename, file.getInputStream());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/application-kubernetes.properties | apollo.eureka.server.enabled=false
eureka.client.enabled=false
spring.cloud.discovery.enabled=false | apollo.eureka.server.enabled=false
eureka.client.enabled=false
spring.cloud.discovery.enabled=false | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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-buildtools/src/main/resources/LICENSE-2.0.txt |
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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. |
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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. | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/secret.png | PNG
IHDR X IDATx^
\eyϹ$#4Q$u
ݳ$Bɘ={A\
II퐀ɞ
4ZHm) S"cɞ!`͞s38{?Ϟ{%KI B`r:~H@@dǭ],khʱk:!fJ:DA_K=D0퐃p}ƞ H@zFmI]6W~k?IDǂ :&]<Š,lQ}/
T='3@O^ YC{ HGO8<g |(\BAbܾH Hm`ylΤ5 ߗ"\̢^v Y|1'5emZ!?⻧MA 8*.D6l*LҥR@4^{27Rp $P3% *_x釬߯L \lRx
q觔jD anV2]%p RB&8"KНnWkVh!+]T1Ĩ/ċF!b-&\<ܽZ\.: Sy A߈xy ^7Eސ۩hN8KFjij:U}\sF>veRpܥݵNܨmL>ہ
#5*lԷV2D``Rt/2d-oyʟgȤj3-6:ƽ?WwhAh3r%빟ȹ]r]8sT7%[7qڦ/;k2m@f/p;܉M `Aszv_xq^s_ArNp. jy 3:Eo}Y=' YߺrBQh]#ڹ.hܰR4dπkɄH=>FൿC1gBīS@gX?@;?ksW$ܻ0_^dҺM-+ t97T Z~7X?Lw?xMK
@;zدv|tݺވN,+s۩=b-"s ݶڷtFZ50Fi'훛.Dž$
(^nR]D=u9kd5SM@[e`y*( A{$IL%w!VQ:/ߐwҞ M vҀMm]}v=7dܫݛye0^_Wa.R<z5'kd*Ca_{ns۩|
+!Z4j4{5kw~"}~CV繻'S)+aM
HwN\kPr/"*"<4c)22> vnoPgY/IIjOݦ<#]~*|H]:^R;,`SK ލT}a*;>v?وxdZ-Qdbt@"6)l{GkRfS,/t
|诮3: gt!\|{Ra;nǫY|YRR"Uw_oRRpܕ,T:
1ͻORat@N
_;TEqO,<^۩hF^+ڎ$&8ʠ%,ۗ[ڎ{O55}T*8o2pa./Qoz@p*8oYl6yϮ0{N+/;5AThyR͍뷪jBj TkU;ͫXW} &|:aU`5]1^"o6"t'(hnW&HeD';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v'HqF+
]k# VD 1_#^]c=C=ox|ڄ"t#$Yj$ 4KO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@yO3 60g2L_d6*d`<DVf3<udѬ]ִs>\eA$SqÆ]J ٽz H8vxes͊c穒qKMt$Q'IVd`.IͬkI@ޡ~#Z4jJ[
)j2cYkܻFe ˕!]*=-J'MIkPI$ /%}gV'ϻjP~iyH@"/3_~%w!V%M\sXhجH~2YY WDjF:L*m; .J[De|KRN|w:<% :( 4D6+L[D9b kOwvܗ L_D%]Mڻg=ڨnqิUJ@Tդ=IݤʳFp>?+I*IQ :7쒻W&!>1Mvw;W.mF5Mz._|uq{Q)AY ڈr l]4uxJ@tP1)][;,
%w>WDi>6}Y)%M\ߏ/yqo'@GXYR?3Z>Y[p.N,&A]'`ܻRE:hȊ$+H]kJ` Oy9r3-%t{/ YX0z$
;A80/ H[O꧙hwhUШ}61[Ëa^ ^u]}o.a^O Upܥ̈́9x8%8ۺH9թzH'YtR̯0u2s~!Yі?pxZ&[email protected]ۄˋmb'Qv
y6CfEk$%""t7P/ 9nExIѣVtZFi1]=^?15 T% wpis
IvIjf]KbeC}G`}nF} 7.I
ʒܠQ?ɒ#g+|$Ik[̷1sc}G>d`^2A{e!0NSIM lKܢ*:k_&)N"٨}-9`Zye}pʑ˞Sq2})ϫΤ$mU>Ŋu)fp3ѣAvlRhJhK@҉_$&7Pq?KUzdF[be8cjo}"bh#Yі N$T˴ G%Tvvedd7VFKM{OY_t~GbTW(^.[$h0>߮t:I?aoߗ -9y~ĩF
oԫ E"/O`]^N@*̶7-W튷z'DnNձvI % Zq+3}!y* kVf4zfH[AY`cAmg 'FїC-c{{Ib*G9-VJ̆Z36Z.sc- ǧS&jZyМkPPLPE27d䦕r$ *fnH@rJ9r愀L4RLE`E6d䢍red(C+y CH@{4QLpE|{('PH@HO@Ao@) J$ wPWJ@N` A?`h+=K Ƞu\\2ѓ IENDB` | PNG
IHDR X IDATx^
\eyϹ$#4Q$u
ݳ$Bɘ={A\
II퐀ɞ
4ZHm) S"cɞ!`͞s38{?Ϟ{%KI B`r:~H@@dǭ],khʱk:!fJ:DA_K=D0퐃p}ƞ H@zFmI]6W~k?IDǂ :&]<Š,lQ}/
T='3@O^ YC{ HGO8<g |(\BAbܾH Hm`ylΤ5 ߗ"\̢^v Y|1'5emZ!?⻧MA 8*.D6l*LҥR@4^{27Rp $P3% *_x釬߯L \lRx
q觔jD anV2]%p RB&8"KНnWkVh!+]T1Ĩ/ċF!b-&\<ܽZ\.: Sy A߈xy ^7Eސ۩hN8KFjij:U}\sF>veRpܥݵNܨmL>ہ
#5*lԷV2D``Rt/2d-oyʟgȤj3-6:ƽ?WwhAh3r%빟ȹ]r]8sT7%[7qڦ/;k2m@f/p;܉M `Aszv_xq^s_ArNp. jy 3:Eo}Y=' YߺrBQh]#ڹ.hܰR4dπkɄH=>FൿC1gBīS@gX?@;?ksW$ܻ0_^dҺM-+ t97T Z~7X?Lw?xMK
@;zدv|tݺވN,+s۩=b-"s ݶڷtFZ50Fi'훛.Dž$
(^nR]D=u9kd5SM@[e`y*( A{$IL%w!VQ:/ߐwҞ M vҀMm]}v=7dܫݛye0^_Wa.R<z5'kd*Ca_{ns۩|
+!Z4j4{5kw~"}~CV繻'S)+aM
HwN\kPr/"*"<4c)22> vnoPgY/IIjOݦ<#]~*|H]:^R;,`SK ލT}a*;>v?وxdZ-Qdbt@"6)l{GkRfS,/t
|诮3: gt!\|{Ra;nǫY|YRR"Uw_oRRpܕ,T:
1ͻORat@N
_;TEqO,<^۩hF^+ڎ$&8ʠ%,ۗ[ڎ{O55}T*8o2pa./Qoz@p*8oYl6yϮ0{N+/;5AThyR͍뷪jBj TkU;ͫXW} &|:aU`5]1^"o6"t'(hnW&HeD';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v2As ҝLm ?Z I&HwF2Ab0RU&HheDc';' HV Ldtg$$#e[eV&H4v'HqF+
]k# VD 1_#^]c=C=ox|ڄ"t#$Yj$ 4KO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@8D@bPT$ A$ 5KJO@yO3 60g2L_d6*d`<DVf3<udѬ]ִs>\eA$SqÆ]J ٽz H8vxes͊c穒qKMt$Q'IVd`.IͬkI@ޡ~#Z4jJ[
)j2cYkܻFe ˕!]*=-J'MIkPI$ /%}gV'ϻjP~iyH@"/3_~%w!V%M\sXhجH~2YY WDjF:L*m; .J[De|KRN|w:<% :( 4D6+L[D9b kOwvܗ L_D%]Mڻg=ڨnqิUJ@Tդ=IݤʳFp>?+I*IQ :7쒻W&!>1Mvw;W.mF5Mz._|uq{Q)AY ڈr l]4uxJ@tP1)][;,
%w>WDi>6}Y)%M\ߏ/yqo'@GXYR?3Z>Y[p.N,&A]'`ܻRE:hȊ$+H]kJ` Oy9r3-%t{/ YX0z$
;A80/ H[O꧙hwhUШ}61[Ëa^ ^u]}o.a^O Upܥ̈́9x8%8ۺH9թzH'YtR̯0u2s~!Yі?pxZ&[email protected]ۄˋmb'Qv
y6CfEk$%""t7P/ 9nExIѣVtZFi1]=^?15 T% wpis
IvIjf]KbeC}G`}nF} 7.I
ʒܠQ?ɒ#g+|$Ik[̷1sc}G>d`^2A{e!0NSIM lKܢ*:k_&)N"٨}-9`Zye}pʑ˞Sq2})ϫΤ$mU>Ŋu)fp3ѣAvlRhJhK@҉_$&7Pq?KUzdF[be8cjo}"bh#Yі N$T˴ G%Tvvedd7VFKM{OY_t~GbTW(^.[$h0>߮t:I?aoߗ -9y~ĩF
oԫ E"/O`]^N@*̶7-W튷z'DnNձvI % Zq+3}!y* kVf4zfH[AY`cAmg 'FїC-c{{Ib*G9-VJ̆Z36Z.sc- ǧS&jZyМkPPLPE27d䦕r$ *fnH@rJ9r愀L4RLE`E6d䢍red(C+y CH@{4QLpE|{('PH@HO@Ao@) J$ wPWJ@N` A?`h+=K Ƞu\\2ѓ IENDB` | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/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,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/XmlConfigPlaceholderTest2.xml | <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:apollo="http://www.ctrip.com/schema/apollo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd">
<apollo:config namespaces="application"/>
<bean class="com.ctrip.framework.apollo.spring.XmlConfigPlaceholderTest.TestXmlBean">
<property name="timeout" value="${timeout:100}"/>
<property name="batch" value="${batch:200}"/>
</bean>
</beans>
| <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:apollo="http://www.ctrip.com/schema/apollo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd">
<apollo:config namespaces="application"/>
<bean class="com.ctrip.framework.apollo.spring.XmlConfigPlaceholderTest.TestXmlBean">
<property name="timeout" value="${timeout:100}"/>
<property name="batch" value="${batch:200}"/>
</bean>
</beans>
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/ConfigServiceLocator.java | package com.ctrip.framework.apollo.internals;
import com.ctrip.framework.apollo.core.ServiceNameConsts;
import com.ctrip.framework.foundation.Foundation;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.tracer.spi.Transaction;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.ExceptionUtil;
import com.ctrip.framework.apollo.util.http.HttpRequest;
import com.ctrip.framework.apollo.util.http.HttpResponse;
import com.ctrip.framework.apollo.util.http.HttpUtil;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.escape.Escaper;
import com.google.common.net.UrlEscapers;
import com.google.gson.reflect.TypeToken;
public class ConfigServiceLocator {
private static final Logger logger = LoggerFactory.getLogger(ConfigServiceLocator.class);
private HttpUtil m_httpUtil;
private ConfigUtil m_configUtil;
private AtomicReference<List<ServiceDTO>> m_configServices;
private Type m_responseType;
private ScheduledExecutorService m_executorService;
private static final Joiner.MapJoiner MAP_JOINER = Joiner.on("&").withKeyValueSeparator("=");
private static final Escaper queryParamEscaper = UrlEscapers.urlFormParameterEscaper();
/**
* Create a config service locator.
*/
public ConfigServiceLocator() {
List<ServiceDTO> initial = Lists.newArrayList();
m_configServices = new AtomicReference<>(initial);
m_responseType = new TypeToken<List<ServiceDTO>>() {
}.getType();
m_httpUtil = ApolloInjector.getInstance(HttpUtil.class);
m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
this.m_executorService = Executors.newScheduledThreadPool(1,
ApolloThreadFactory.create("ConfigServiceLocator", true));
initConfigServices();
}
private void initConfigServices() {
// get from run time configurations
List<ServiceDTO> customizedConfigServices = getCustomizedConfigService();
if (customizedConfigServices != null) {
setConfigServices(customizedConfigServices);
return;
}
// update from meta service
this.tryUpdateConfigServices();
this.schedulePeriodicRefresh();
}
private List<ServiceDTO> getCustomizedConfigService() {
// 1. Get from System Property
String configServices = System.getProperty("apollo.configService");
if (Strings.isNullOrEmpty(configServices)) {
// 2. Get from OS environment variable
configServices = System.getenv("APOLLO_CONFIGSERVICE");
}
if (Strings.isNullOrEmpty(configServices)) {
// 3. Get from server.properties
configServices = Foundation.server().getProperty("apollo.configService", null);
}
if (Strings.isNullOrEmpty(configServices)) {
return null;
}
logger.warn("Located config services from apollo.configService configuration: {}, will not refresh config services from remote meta service!", configServices);
// mock service dto list
String[] configServiceUrls = configServices.split(",");
List<ServiceDTO> serviceDTOS = Lists.newArrayList();
for (String configServiceUrl : configServiceUrls) {
configServiceUrl = configServiceUrl.trim();
ServiceDTO serviceDTO = new ServiceDTO();
serviceDTO.setHomepageUrl(configServiceUrl);
serviceDTO.setAppName(ServiceNameConsts.APOLLO_CONFIGSERVICE);
serviceDTO.setInstanceId(configServiceUrl);
serviceDTOS.add(serviceDTO);
}
return serviceDTOS;
}
/**
* Get the config service info from remote meta server.
*
* @return the services dto
*/
public List<ServiceDTO> getConfigServices() {
if (m_configServices.get().isEmpty()) {
updateConfigServices();
}
return m_configServices.get();
}
private boolean tryUpdateConfigServices() {
try {
updateConfigServices();
return true;
} catch (Throwable ex) {
//ignore
}
return false;
}
private void schedulePeriodicRefresh() {
this.m_executorService.scheduleAtFixedRate(
new Runnable() {
@Override
public void run() {
logger.debug("refresh config services");
Tracer.logEvent("Apollo.MetaService", "periodicRefresh");
tryUpdateConfigServices();
}
}, m_configUtil.getRefreshInterval(), m_configUtil.getRefreshInterval(),
m_configUtil.getRefreshIntervalTimeUnit());
}
private synchronized void updateConfigServices() {
String url = assembleMetaServiceUrl();
HttpRequest request = new HttpRequest(url);
int maxRetries = 2;
Throwable exception = null;
for (int i = 0; i < maxRetries; i++) {
Transaction transaction = Tracer.newTransaction("Apollo.MetaService", "getConfigService");
transaction.addData("Url", url);
try {
HttpResponse<List<ServiceDTO>> response = m_httpUtil.doGet(request, m_responseType);
transaction.setStatus(Transaction.SUCCESS);
List<ServiceDTO> services = response.getBody();
if (services == null || services.isEmpty()) {
logConfigService("Empty response!");
continue;
}
setConfigServices(services);
return;
} catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex);
exception = ex;
} finally {
transaction.complete();
}
try {
m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) {
//ignore
}
}
throw new ApolloConfigException(
String.format("Get config services failed from %s", url), exception);
}
private void setConfigServices(List<ServiceDTO> services) {
m_configServices.set(services);
logConfigServices(services);
}
private String assembleMetaServiceUrl() {
String domainName = m_configUtil.getMetaServerDomainName();
String appId = m_configUtil.getAppId();
String localIp = m_configUtil.getLocalIp();
Map<String, String> queryParams = Maps.newHashMap();
queryParams.put("appId", queryParamEscaper.escape(appId));
if (!Strings.isNullOrEmpty(localIp)) {
queryParams.put("ip", queryParamEscaper.escape(localIp));
}
return domainName + "/services/config?" + MAP_JOINER.join(queryParams);
}
private void logConfigServices(List<ServiceDTO> serviceDtos) {
for (ServiceDTO serviceDto : serviceDtos) {
logConfigService(serviceDto.getHomepageUrl());
}
}
private void logConfigService(String serviceUrl) {
Tracer.logEvent("Apollo.Config.Services", serviceUrl);
}
}
| package com.ctrip.framework.apollo.internals;
import com.ctrip.framework.apollo.core.ServiceNameConsts;
import com.ctrip.framework.foundation.Foundation;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.tracer.spi.Transaction;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.ExceptionUtil;
import com.ctrip.framework.apollo.util.http.HttpRequest;
import com.ctrip.framework.apollo.util.http.HttpResponse;
import com.ctrip.framework.apollo.util.http.HttpUtil;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.escape.Escaper;
import com.google.common.net.UrlEscapers;
import com.google.gson.reflect.TypeToken;
public class ConfigServiceLocator {
private static final Logger logger = LoggerFactory.getLogger(ConfigServiceLocator.class);
private HttpUtil m_httpUtil;
private ConfigUtil m_configUtil;
private AtomicReference<List<ServiceDTO>> m_configServices;
private Type m_responseType;
private ScheduledExecutorService m_executorService;
private static final Joiner.MapJoiner MAP_JOINER = Joiner.on("&").withKeyValueSeparator("=");
private static final Escaper queryParamEscaper = UrlEscapers.urlFormParameterEscaper();
/**
* Create a config service locator.
*/
public ConfigServiceLocator() {
List<ServiceDTO> initial = Lists.newArrayList();
m_configServices = new AtomicReference<>(initial);
m_responseType = new TypeToken<List<ServiceDTO>>() {
}.getType();
m_httpUtil = ApolloInjector.getInstance(HttpUtil.class);
m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
this.m_executorService = Executors.newScheduledThreadPool(1,
ApolloThreadFactory.create("ConfigServiceLocator", true));
initConfigServices();
}
private void initConfigServices() {
// get from run time configurations
List<ServiceDTO> customizedConfigServices = getCustomizedConfigService();
if (customizedConfigServices != null) {
setConfigServices(customizedConfigServices);
return;
}
// update from meta service
this.tryUpdateConfigServices();
this.schedulePeriodicRefresh();
}
private List<ServiceDTO> getCustomizedConfigService() {
// 1. Get from System Property
String configServices = System.getProperty("apollo.configService");
if (Strings.isNullOrEmpty(configServices)) {
// 2. Get from OS environment variable
configServices = System.getenv("APOLLO_CONFIGSERVICE");
}
if (Strings.isNullOrEmpty(configServices)) {
// 3. Get from server.properties
configServices = Foundation.server().getProperty("apollo.configService", null);
}
if (Strings.isNullOrEmpty(configServices)) {
return null;
}
logger.warn("Located config services from apollo.configService configuration: {}, will not refresh config services from remote meta service!", configServices);
// mock service dto list
String[] configServiceUrls = configServices.split(",");
List<ServiceDTO> serviceDTOS = Lists.newArrayList();
for (String configServiceUrl : configServiceUrls) {
configServiceUrl = configServiceUrl.trim();
ServiceDTO serviceDTO = new ServiceDTO();
serviceDTO.setHomepageUrl(configServiceUrl);
serviceDTO.setAppName(ServiceNameConsts.APOLLO_CONFIGSERVICE);
serviceDTO.setInstanceId(configServiceUrl);
serviceDTOS.add(serviceDTO);
}
return serviceDTOS;
}
/**
* Get the config service info from remote meta server.
*
* @return the services dto
*/
public List<ServiceDTO> getConfigServices() {
if (m_configServices.get().isEmpty()) {
updateConfigServices();
}
return m_configServices.get();
}
private boolean tryUpdateConfigServices() {
try {
updateConfigServices();
return true;
} catch (Throwable ex) {
//ignore
}
return false;
}
private void schedulePeriodicRefresh() {
this.m_executorService.scheduleAtFixedRate(
new Runnable() {
@Override
public void run() {
logger.debug("refresh config services");
Tracer.logEvent("Apollo.MetaService", "periodicRefresh");
tryUpdateConfigServices();
}
}, m_configUtil.getRefreshInterval(), m_configUtil.getRefreshInterval(),
m_configUtil.getRefreshIntervalTimeUnit());
}
private synchronized void updateConfigServices() {
String url = assembleMetaServiceUrl();
HttpRequest request = new HttpRequest(url);
int maxRetries = 2;
Throwable exception = null;
for (int i = 0; i < maxRetries; i++) {
Transaction transaction = Tracer.newTransaction("Apollo.MetaService", "getConfigService");
transaction.addData("Url", url);
try {
HttpResponse<List<ServiceDTO>> response = m_httpUtil.doGet(request, m_responseType);
transaction.setStatus(Transaction.SUCCESS);
List<ServiceDTO> services = response.getBody();
if (services == null || services.isEmpty()) {
logConfigService("Empty response!");
continue;
}
setConfigServices(services);
return;
} catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex);
exception = ex;
} finally {
transaction.complete();
}
try {
m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) {
//ignore
}
}
throw new ApolloConfigException(
String.format("Get config services failed from %s", url), exception);
}
private void setConfigServices(List<ServiceDTO> services) {
m_configServices.set(services);
logConfigServices(services);
}
private String assembleMetaServiceUrl() {
String domainName = m_configUtil.getMetaServerDomainName();
String appId = m_configUtil.getAppId();
String localIp = m_configUtil.getLocalIp();
Map<String, String> queryParams = Maps.newHashMap();
queryParams.put("appId", queryParamEscaper.escape(appId));
if (!Strings.isNullOrEmpty(localIp)) {
queryParams.put("ip", queryParamEscaper.escape(localIp));
}
return domainName + "/services/config?" + MAP_JOINER.join(queryParams);
}
private void logConfigServices(List<ServiceDTO> serviceDtos) {
for (ServiceDTO serviceDto : serviceDtos) {
logConfigService(serviceDto.getHomepageUrl());
}
}
private void logConfigService(String serviceUrl) {
Tracer.logEvent("Apollo.Config.Services", serviceUrl);
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/apollo-portal.conf | MODE=service
PID_FOLDER=.
# console appender log file folder
LOG_FOLDER=/opt/logs/100003173/
# console appender log file name
LOG_FILENAME=console.log
# write application logs only to file appender
export LOG_APPENDERS=FILE | MODE=service
PID_FOLDER=.
# console appender log file folder
LOG_FOLDER=/opt/logs/100003173/
# console appender log file name
LOG_FILENAME=console.log
# write application logs only to file appender
export LOG_APPENDERS=FILE | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/test/resources/data.sql | INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('fxhermesproducer','fx-hermes-producer','梁锦华','[email protected]');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'cluster1');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'cluster2');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'fx.apollo.config');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'fx.apollo.admin');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'fx.apollo.portal');
INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx.hermes.producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (1, '100003171', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'cluster1', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxhermesproducer', 'default', 'fx.hermes.producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'application');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment, LineNum) VALUES (5, 'k1', 'v4', 'comment4',1);
INSERT INTO RELEASE (ReleaseKey, Name, Comment, AppId, ClusterName, NamespaceName, Configurations) VALUES ('TEST-RELEASE-KEY', 'REV1','First Release','100003171', 'default', 'application', '{"k1":"v1"}');
| INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','[email protected]');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('fxhermesproducer','fx-hermes-producer','梁锦华','[email protected]');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'cluster1');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'cluster2');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'fx.apollo.config');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'fx.apollo.admin');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'fx.apollo.portal');
INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx.hermes.producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (1, '100003171', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'cluster1', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxhermesproducer', 'default', 'fx.hermes.producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'application');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment, LineNum) VALUES (5, 'k1', 'v4', 'comment4',1);
INSERT INTO RELEASE (ReleaseKey, Name, Comment, AppId, ClusterName, NamespaceName, Configurations) VALUES ('TEST-RELEASE-KEY', 'REV1','First Release','100003171', 'default', 'application', '{"k1":"v1"}');
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java | package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.common.exception.ServiceException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class ControllerExceptionTest {
private AppController appController;
@Mock
private AppService appService;
@Mock
private AdminService adminService;
@Before
public void setUp() {
appController = new AppController(appService, adminService);
}
@Test(expected = NotFoundException.class)
public void testFindNotExists() {
when(appService.findOne(any(String.class))).thenReturn(null);
appController.get("unexist");
}
@Test(expected = NotFoundException.class)
public void testDeleteNotExists() {
when(appService.findOne(any(String.class))).thenReturn(null);
appController.delete("unexist", null);
}
@Test
public void testFindEmpty() {
when(appService.findAll(any(Pageable.class))).thenReturn(new ArrayList<>());
Pageable pageable = PageRequest.of(0, 10);
List<AppDTO> appDTOs = appController.find(null, pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
appDTOs = appController.find("", pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
}
@Test
public void testFindByName() {
Pageable pageable = PageRequest.of(0, 10);
List<AppDTO> appDTOs = appController.find("unexist", pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
}
@Test(expected = ServiceException.class)
public void createFailed() {
AppDTO dto = generateSampleDTOData();
when(appService.findOne(any(String.class))).thenReturn(null);
when(adminService.createNewApp(any(App.class)))
.thenThrow(new ServiceException("create app failed"));
appController.create(dto);
}
private AppDTO generateSampleDTOData() {
AppDTO dto = new AppDTO();
dto.setAppId("someAppId");
dto.setName("someName");
dto.setOwnerName("someOwner");
dto.setOwnerEmail("[email protected]");
dto.setDataChangeLastModifiedBy("test");
dto.setDataChangeCreatedBy("test");
return dto;
}
}
| package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.common.exception.ServiceException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class ControllerExceptionTest {
private AppController appController;
@Mock
private AppService appService;
@Mock
private AdminService adminService;
@Before
public void setUp() {
appController = new AppController(appService, adminService);
}
@Test(expected = NotFoundException.class)
public void testFindNotExists() {
when(appService.findOne(any(String.class))).thenReturn(null);
appController.get("unexist");
}
@Test(expected = NotFoundException.class)
public void testDeleteNotExists() {
when(appService.findOne(any(String.class))).thenReturn(null);
appController.delete("unexist", null);
}
@Test
public void testFindEmpty() {
when(appService.findAll(any(Pageable.class))).thenReturn(new ArrayList<>());
Pageable pageable = PageRequest.of(0, 10);
List<AppDTO> appDTOs = appController.find(null, pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
appDTOs = appController.find("", pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
}
@Test
public void testFindByName() {
Pageable pageable = PageRequest.of(0, 10);
List<AppDTO> appDTOs = appController.find("unexist", pageable);
Assert.assertNotNull(appDTOs);
Assert.assertEquals(0, appDTOs.size());
}
@Test(expected = ServiceException.class)
public void createFailed() {
AppDTO dto = generateSampleDTOData();
when(appService.findOne(any(String.class))).thenReturn(null);
when(adminService.createNewApp(any(App.class)))
.thenThrow(new ServiceException("create app failed"));
appController.create(dto);
}
private AppDTO generateSampleDTOData() {
AppDTO dto = new AppDTO();
dto.setAppId("someAppId");
dto.setName("someName");
dto.setOwnerName("someOwner");
dto.setOwnerEmail("[email protected]");
dto.setDataChangeLastModifiedBy("test");
dto.setDataChangeCreatedBy("test");
return dto;
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/resources/META-INF/spring.handlers | http\://www.ctrip.com/schema/apollo=com.ctrip.framework.apollo.spring.config.NamespaceHandler | http\://www.ctrip.com/schema/apollo=com.ctrip.framework.apollo.spring.config.NamespaceHandler | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/apollo-on-kubernetes/kubernetes/apollo-env-test-alpha/service-mysql-for-apollo-test-alpha-env.yaml | ---
kind: Service
apiVersion: v1
metadata:
namespace: sre
name: service-mysql-for-apollo-test-alpha-env
labels:
app: service-mysql-for-apollo-test-alpha-env
spec:
ports:
- protocol: TCP
port: 3306
targetPort: 3306
type: ClusterIP
sessionAffinity: None
---
kind: Endpoints
apiVersion: v1
metadata:
namespace: sre
name: service-mysql-for-apollo-test-alpha-env
subsets:
- addresses:
- ip: your-mysql-addresses
ports:
- protocol: TCP
port: 3306 | ---
kind: Service
apiVersion: v1
metadata:
namespace: sre
name: service-mysql-for-apollo-test-alpha-env
labels:
app: service-mysql-for-apollo-test-alpha-env
spec:
ports:
- protocol: TCP
port: 3306
targetPort: 3306
type: ClusterIP
sessionAffinity: None
---
kind: Endpoints
apiVersion: v1
metadata:
namespace: sre
name: service-mysql-for-apollo-test-alpha-env
subsets:
- addresses:
- ip: your-mysql-addresses
ports:
- protocol: TCP
port: 3306 | -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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.
| ./CONTRIBUTING.md | ## Contributing to apollo
Apollo is released under the non-restrictive Apache 2.0 license, and follows a very standard Github development process, using Github tracker for issues and merging pull requests into master. If you want to contribute even something trivial please do not hesitate, but follow the guidelines below.
### Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to sign the Contributor License Agreement. Signing the contributor’s agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
### Code Conventions
Our code style is in line with [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
We provide template files [intellij-java-google-style.xml](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) for IntelliJ IDEA and [eclipse-java-google-style.xml](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) for Eclipse. If you use other IDEs, then you may config manually by referencing the template files.
* Make sure all new .java files have a simple Javadoc class comment with at least an `@author` tag identifying you, and preferably at least a paragraph on what the class is for.
* Add yourself as an @author to the .java files that you modify substantially (more than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests should be added for a new feature or an important bug fix.
* If no-one else is using your branch, please rebase it against the current master (or other target branch in the main project).
* Normally, we would squash commits for one feature into one commit. There are 2 ways to do this:
1. To rebase and squash based on the remote branch
* `git rebase -i <remote>/master`
* merge commits via `fixup`, etc
2. Create a new branch and merge these commits into one
* `git checkout -b <some-branch-name> <remote>/master`
* `git merge --squash <current-feature-branch>`
* When writing a commit message please follow these conventions: if you are fixing an existing issue, please add Fixes #XXX at the end of the commit message (where XXX is the issue number).
| ## Contributing to apollo
Apollo is released under the non-restrictive Apache 2.0 license, and follows a very standard Github development process, using Github tracker for issues and merging pull requests into master. If you want to contribute even something trivial please do not hesitate, but follow the guidelines below.
### Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to sign the Contributor License Agreement. Signing the contributor’s agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
### Code Conventions
Our code style is in line with [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
We provide template files [intellij-java-google-style.xml](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/intellij-java-google-style.xml) for IntelliJ IDEA and [eclipse-java-google-style.xml](https://github.com/ctripcorp/apollo/blob/master/apollo-buildtools/style/eclipse-java-google-style.xml) for Eclipse. If you use other IDEs, then you may config manually by referencing the template files.
* Make sure all new .java files have a simple Javadoc class comment with at least an `@author` tag identifying you, and preferably at least a paragraph on what the class is for.
* Add yourself as an @author to the .java files that you modify substantially (more than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests should be added for a new feature or an important bug fix.
* If no-one else is using your branch, please rebase it against the current master (or other target branch in the main project).
* Normally, we would squash commits for one feature into one commit. There are 2 ways to do this:
1. To rebase and squash based on the remote branch
* `git rebase -i <remote>/master`
* merge commits via `fixup`, etc
2. Create a new branch and merge these commits into one
* `git checkout -b <some-branch-name> <remote>/master`
* `git merge --squash <current-feature-branch>`
* When writing a commit message please follow these conventions: if you are fixing an existing issue, please add Fixes #XXX at the end of the commit message (where XXX is the issue number).
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/i18n/zh-CN.json | {
"Common.Title": "Apollo配置中心",
"Common.Ctrip": "携程",
"Common.CtripDepartment": "框架研发部",
"Common.Nav.ShowNavBar": "显示导航栏",
"Common.Nav.HideNavBar": "隐藏导航栏",
"Common.Nav.Help": "帮助",
"Common.Nav.AdminTools": "管理员工具",
"Common.Nav.NonAdminTools": "工具",
"Common.Nav.UserManage": "用户管理",
"Common.Nav.SystemRoleManage": "系统权限管理",
"Common.Nav.OpenMange": "开放平台授权管理",
"Common.Nav.SystemConfig": "系统参数",
"Common.Nav.DeleteApp-Cluster-Namespace": "删除应用、集群、AppNamespace",
"Common.Nav.SystemInfo": "系统信息",
"Common.Nav.ConfigExport": "配置导出",
"Common.Nav.Logout": "退出",
"Common.Department": "部门",
"Common.Cluster": "集群",
"Common.Environment": "环境",
"Common.Email": "邮箱",
"Common.AppId": "AppId",
"Common.Namespace": "Namespace",
"Common.AppName": "应用名称",
"Common.AppOwner": "负责人",
"Common.AppOwnerLong": "应用负责人",
"Common.AppAdmin": "项目管理员",
"Common.ClusterName": "集群名称",
"Common.Submit": "提交",
"Common.Save": "保存",
"Common.Created": "创建成功",
"Common.CreateFailed": "创建失败",
"Common.Deleted": "删除成功",
"Common.DeleteFailed": "删除失败",
"Common.ReturnToIndex": "返回到项目首页",
"Common.Cancel": "取消",
"Common.Ok": "确定",
"Common.Search": "查询",
"Common.IsRootUser": "当前页面只对Apollo管理员开放",
"Common.PleaseChooseDepartment": "请选择部门",
"Common.PleaseChooseOwner": "请选择应用负责人",
"Common.LoginExpiredTips": "您的登录信息已过期,请刷新页面后重试",
"Component.DeleteNamespace.Title": "删除Namespace",
"Component.DeleteNamespace.PublicContent": "删除Namespace将导致实例获取不到此Namespace的配置,确定要删除吗?",
"Component.DeleteNamespace.PrivateContent": "删除私有Namespace将导致实例获取不到此Namespace的配置,且页面会提示缺失Namespace(除非使用管理员工具删除AppNamespace),确定要删除吗?",
"Component.GrayscalePublishRule.Title": "编辑灰度规则",
"Component.GrayscalePublishRule.AppId": "灰度的AppId",
"Component.GrayscalePublishRule.AcceptRule": "灰度应用规则",
"Component.GrayscalePublishRule.AcceptPartInstance": "应用到部分实例",
"Component.GrayscalePublishRule.AcceptAllInstance": "应用到所有的实例",
"Component.GrayscalePublishRule.IP": "灰度的IP",
"Component.GrayscalePublishRule.AppIdFilterTips": "(实例列表会根据输入的AppId自动过滤)",
"Component.GrayscalePublishRule.IpTips": "没找到你想要的IP?可以",
"Component.GrayscalePublishRule.EnterIp": "手动输入IP",
"Component.GrayscalePublishRule.EnterIpTips": "输入IP列表,英文逗号隔开,输入完后点击添加按钮",
"Component.GrayscalePublishRule.Add": "添加",
"Component.ConfigItem.Title": "添加配置项",
"Component.ConfigItem.TitleTips": "(温馨提示: 可以通过文本模式批量添加配置)",
"Component.ConfigItem.AddGrayscaleItem": "添加灰度配置项",
"Component.ConfigItem.ModifyItem": "修改配置项",
"Component.ConfigItem.ItemKey": "Key",
"Component.ConfigItem.ItemValue": "Value",
"Component.ConfigItem.ItemValueTips": "注意: 隐藏字符(空格、换行符、制表符Tab)容易导致配置出错,如果需要检测Value中隐藏字符,请点击",
"Component.ConfigItem.ItemValueShowDetection": "检测隐藏字符",
"Component.ConfigItem.ItemValueNotHiddenChars": "无隐藏字符",
"Component.ConfigItem.ItemComment": "Comment",
"Component.ConfigItem.ChooseCluster": "选择集群",
"Component.MergePublish.Title": "全量发布",
"Component.MergePublish.Tips": "全量发布将会把灰度版本的配置合并到主分支,并发布。",
"Component.MergePublish.NextStep": "全量发布后,您希望",
"Component.MergePublish.DeleteGrayscale": "删除灰度版本",
"Component.MergePublish.ReservedGrayscale": "保留灰度版本",
"Component.Namespace.Branch.IsChanged": "有修改",
"Component.Namespace.Branch.ChangeUser": "当前修改者",
"Component.Namespace.Branch.ContinueGrayscalePublish": "继续灰度发布",
"Component.Namespace.Branch.GrayscalePublish": "灰度发布",
"Component.Namespace.Branch.MergeToMasterAndPublish": "合并到主版本并发布主版本配置",
"Component.Namespace.Branch.AllPublish": "全量发布",
"Component.Namespace.Branch.DiscardGrayscaleVersion": "废弃灰度版本",
"Component.Namespace.Branch.DiscardGrayscale": "放弃灰度",
"Component.Namespace.Branch.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看配置信息。",
"Component.Namespace.Branch.Tab.Configuration": "配置",
"Component.Namespace.Branch.Tab.GrayscaleRule": "灰度规则",
"Component.Namespace.Branch.Tab.GrayscaleInstance": "灰度实例列表",
"Component.Namespace.Branch.Tab.ChangeHistory": "更改历史",
"Component.Namespace.Branch.Body.Item": "灰度的配置",
"Component.Namespace.Branch.Body.AddedItem": "新增灰度配置",
"Component.Namespace.Branch.Body.PublishState": "发布状态",
"Component.Namespace.Branch.Body.ItemSort": "排序",
"Component.Namespace.Branch.Body.ItemKey": "Key",
"Component.Namespace.Branch.Body.ItemMasterValue": "主版本的值",
"Component.Namespace.Branch.Body.ItemGrayscaleValue": "灰度的值",
"Component.Namespace.Branch.Body.ItemComment": "备注",
"Component.Namespace.Branch.Body.ItemLastModify": "最后修改人",
"Component.Namespace.Branch.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.Branch.Body.ItemOperator": "操作",
"Component.Namespace.Branch.Body.ClickToSeeItemValue": "点击查看已发布的值",
"Component.Namespace.Branch.Body.ItemNoPublish": "未发布",
"Component.Namespace.Branch.Body.ItemPublished": "已发布",
"Component.Namespace.Branch.Body.ItemEffective": "已生效的配置",
"Component.Namespace.Branch.Body.ClickToSee": "点击查看",
"Component.Namespace.Branch.Body.DeletedItem": "删除的配置",
"Component.Namespace.Branch.Body.Delete": "删",
"Component.Namespace.Branch.Body.ChangedFromMaster": "修改主版本的配置",
"Component.Namespace.Branch.Body.ModifiedItem": "修改的配置",
"Component.Namespace.Branch.Body.Modify": "改",
"Component.Namespace.Branch.Body.AddedByGrayscale": "灰度版本特有的配置",
"Component.Namespace.Branch.Body.Added": "新",
"Component.Namespace.Branch.Body.Op.Modify": "修改",
"Component.Namespace.Branch.Body.Op.Delete": "删除",
"Component.Namespace.MasterBranch.Body.Title": "主版本的配置",
"Component.Namespace.MasterBranch.Body.PublishState": "发布状态",
"Component.Namespace.MasterBranch.Body.ItemKey": "Key",
"Component.Namespace.MasterBranch.Body.ItemValue": "Value",
"Component.Namespace.MasterBranch.Body.ItemComment": "备注",
"Component.Namespace.MasterBranch.Body.ItemLastModify": "最后修改人",
"Component.Namespace.MasterBranch.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.MasterBranch.Body.ItemOperator": "操作",
"Component.Namespace.MasterBranch.Body.ClickToSeeItemValue": "点击查看已发布的值",
"Component.Namespace.MasterBranch.Body.ItemNoPublish": "未发布",
"Component.Namespace.MasterBranch.Body.ItemEffective": "已生效的配置",
"Component.Namespace.MasterBranch.Body.ItemPublished": "已发布",
"Component.Namespace.MasterBranch.Body.AddedItem": "新增的配置",
"Component.Namespace.MasterBranch.Body.ModifyItem": "修改此灰度配置",
"Component.Namespace.Branch.GrayScaleRule.NoPermissionTips": "您没有权限编辑灰度规则, 具有namespace修改权或者发布权的人员才可以编辑灰度规则. 如需要编辑灰度规则,请找项目管理员申请权限.",
"Component.Namespace.Branch.GrayScaleRule.AppId": "灰度的AppId",
"Component.Namespace.Branch.GrayScaleRule.IpList": "灰度的IP列表",
"Component.Namespace.Branch.GrayScaleRule.Operator": "操作",
"Component.Namespace.Branch.GrayScaleRule.ApplyToAllInstances": "ALL",
"Component.Namespace.Branch.GrayScaleRule.Modify": "修改",
"Component.Namespace.Branch.GrayScaleRule.Delete": "删除",
"Component.Namespace.Branch.GrayScaleRule.AddNewRule": "新增规则",
"Component.Namespace.Branch.Instance.RefreshList": "刷新列表",
"Component.Namespace.Branch.Instance.ItemToSee": "查看配置",
"Component.Namespace.Branch.Instance.InstanceAppId": "App ID",
"Component.Namespace.Branch.Instance.InstanceClusterName": "Cluster Name",
"Component.Namespace.Branch.Instance.InstanceDataCenter": "Data Center",
"Component.Namespace.Branch.Instance.InstanceIp": "IP",
"Component.Namespace.Branch.Instance.InstanceGetItemTime": "配置获取时间",
"Component.Namespace.Branch.Instance.LoadMore": "刷新列表",
"Component.Namespace.Branch.Instance.NoInstance": "无实例信息",
"Component.Namespace.Branch.History.ItemType": "Type",
"Component.Namespace.Branch.History.ItemKey": "Key",
"Component.Namespace.Branch.History.ItemOldValue": "Old Value",
"Component.Namespace.Branch.History.ItemNewValue": "New Value",
"Component.Namespace.Branch.History.ItemComment": "Comment",
"Component.Namespace.Branch.History.NewAdded": "新增",
"Component.Namespace.Branch.History.Modified": "更新",
"Component.Namespace.Branch.History.Deleted": "删除",
"Component.Namespace.Branch.History.LoadMore": "加载更多",
"Component.Namespace.Branch.History.NoHistory": "无更改历史",
"Component.Namespace.Header.Title.Private": "私有",
"Component.Namespace.Header.Title.PrivateTips": "私有namespace({{namespace.baseInfo.namespaceName}})的配置只能被AppId为{{appId}}的客户端读取到",
"Component.Namespace.Header.Title.Public": "公共",
"Component.Namespace.Header.Title.PublicTips": "namespace({{namespace.baseInfo.namespaceName}})的配置能被任何客户端读取到",
"Component.Namespace.Header.Title.Extend": "关联",
"Component.Namespace.Header.Title.ExtendTips": "namespace({{namespace.baseInfo.namespaceName}})的配置将会覆盖公共namespace的配置, 且合并之后的配置只能被AppId为{{appId}}的客户端读取到",
"Component.Namespace.Header.Title.ExpandAndCollapse": "[展开/收缩]",
"Component.Namespace.Header.Title.Master": "主版本",
"Component.Namespace.Header.Title.Grayscale": "灰度版本",
"Component.Namespace.Master.LoadNamespace": "加载Namespace",
"Component.Namespace.Master.LoadNamespaceTips": "加载Namespace",
"Component.Namespace.Master.Items.Changed": "有修改",
"Component.Namespace.Master.Items.ChangedUser": "当前修改者",
"Component.Namespace.Master.Items.Publish": "发布",
"Component.Namespace.Master.Items.PublishTips": "发布配置",
"Component.Namespace.Master.Items.Rollback": "回滚",
"Component.Namespace.Master.Items.RollbackTips": "回滚已发布配置",
"Component.Namespace.Master.Items.PublishHistory": "发布历史",
"Component.Namespace.Master.Items.PublishHistoryTips": "查看发布历史",
"Component.Namespace.Master.Items.Grant": "授权",
"Component.Namespace.Master.Items.GrantTips": "配置修改、发布权限",
"Component.Namespace.Master.Items.Grayscale": "灰度",
"Component.Namespace.Master.Items.GrayscaleTips": "创建测试版本",
"Component.Namespace.Master.Items.RequestPermission": "申请配置权限",
"Component.Namespace.Master.Items.RequestPermissionTips": "您没有任何配置权限,请申请",
"Component.Namespace.Master.Items.DeleteNamespace": "删除Namespace",
"Component.Namespace.Master.Items.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看配置信息。",
"Component.Namespace.Master.Items.ItemList": "表格",
"Component.Namespace.Master.Items.ItemListByText": "文本",
"Component.Namespace.Master.Items.ItemHistory": "更改历史",
"Component.Namespace.Master.Items.ItemInstance": "实例列表",
"Component.Namespace.Master.Items.CopyText": "复制文本",
"Component.Namespace.Master.Items.GrammarCheck": "语法检查",
"Component.Namespace.Master.Items.CancelChanged": "取消修改",
"Component.Namespace.Master.Items.Change": "修改配置",
"Component.Namespace.Master.Items.SummitChanged": "提交修改",
"Component.Namespace.Master.Items.SortByKey": "按Key过滤配置",
"Component.Namespace.Master.Items.FilterItem": "过滤配置",
"Component.Namespace.Master.Items.SyncItemTips": "同步各环境间配置",
"Component.Namespace.Master.Items.SyncItem": "同步配置",
"Component.Namespace.Master.Items.RevokeItemTips": "撤销配置的修改",
"Component.Namespace.Master.Items.RevokeItem": "撤销配置",
"Component.Namespace.Master.Items.DiffItemTips": "比较各环境间配置",
"Component.Namespace.Master.Items.DiffItem": "比较配置",
"Component.Namespace.Master.Items.AddItem": "新增配置",
"Component.Namespace.Master.Items.Body.ItemsNoPublishedTips": "Tips: 此namespace从来没有发布过,Apollo客户端将获取不到配置并记录404日志信息,请及时发布。",
"Component.Namespace.Master.Items.Body.FilterByKey": "输入key过滤",
"Component.Namespace.Master.Items.Body.PublishState": "发布状态",
"Component.Namespace.Master.Items.Body.Sort": "排序",
"Component.Namespace.Master.Items.Body.ItemKey": "Key",
"Component.Namespace.Master.Items.Body.ItemValue": "Value",
"Component.Namespace.Master.Items.Body.ItemComment": "备注",
"Component.Namespace.Master.Items.Body.ItemLastModify": "最后修改人",
"Component.Namespace.Master.Items.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.Master.Items.Body.ItemOperator": "操作",
"Component.Namespace.Master.Items.Body.NoPublish": "未发布",
"Component.Namespace.Master.Items.Body.NoPublishTitle": "点击查看已发布的值",
"Component.Namespace.Master.Items.Body.NoPublishTips": "新增的配置,无发布的值",
"Component.Namespace.Master.Items.Body.Published": "已发布",
"Component.Namespace.Master.Items.Body.PublishedTitle": "已生效的配置",
"Component.Namespace.Master.Items.Body.ClickToSee": "点击查看",
"Component.Namespace.Master.Items.Body.Grayscale": "灰",
"Component.Namespace.Master.Items.Body.HaveGrayscale": "该配置有灰度配置,点击查看灰度的值",
"Component.Namespace.Master.Items.Body.NewAdded": "新",
"Component.Namespace.Master.Items.Body.NewAddedTips": "新增的配置",
"Component.Namespace.Master.Items.Body.Modified": "改",
"Component.Namespace.Master.Items.Body.ModifiedTips": "修改的配置",
"Component.Namespace.Master.Items.Body.Deleted": "删",
"Component.Namespace.Master.Items.Body.DeletedTips": "删除的配置",
"Component.Namespace.Master.Items.Body.ModifyTips": "修改",
"Component.Namespace.Master.Items.Body.DeleteTips": "删除",
"Component.Namespace.Master.Items.Body.Link.Title": "覆盖的配置",
"Component.Namespace.Master.Items.Body.Link.NoCoverLinkItem": "无覆盖的配置",
"Component.Namespace.Master.Items.Body.Public.Title": "公共的配置",
"Component.Namespace.Master.Items.Body.Public.Published": "已发布的配置",
"Component.Namespace.Master.Items.Body.Public.NoPublish": "未发布的配置",
"Component.Namespace.Master.Items.Body.Public.NoPublicNamespaceTips1": "当前公共namespace的所有者",
"Component.Namespace.Master.Items.Body.Public.NoPublicNamespaceTips2": "没有关联此namespace,请联系{{namespace.parentAppId}}的所有者在{{namespace.parentAppId}}项目里关联此namespace",
"Component.Namespace.Master.Items.Body.Public.NoPublished": "无发布的配置",
"Component.Namespace.Master.Items.Body.Public.PublishedAndCover": "覆盖此配置",
"Component.Namespace.Master.Items.Body.NoPublished.Title": "无公共的配置",
"Component.Namespace.Master.Items.Body.NoPublished.PublishedValue": "已发布的值",
"Component.Namespace.Master.Items.Body.NoPublished.NoPublishedValue": "未发布的值",
"Component.Namespace.Master.Items.Body.HistoryView.ItemType": "Type",
"Component.Namespace.Master.Items.Body.HistoryView.ItemKey": "Key",
"Component.Namespace.Master.Items.Body.HistoryView.ItemOldValue": "Old Value",
"Component.Namespace.Master.Items.Body.HistoryView.ItemNewValue": " New Value",
"Component.Namespace.Master.Items.Body.HistoryView.ItemComment": "Comment",
"Component.Namespace.Master.Items.Body.HistoryView.NewAdded": "新增",
"Component.Namespace.Master.Items.Body.HistoryView.Updated": "更新",
"Component.Namespace.Master.Items.Body.HistoryView.Deleted": "删除",
"Component.Namespace.Master.Items.Body.HistoryView.LoadMore": "加载更多",
"Component.Namespace.Master.Items.Body.HistoryView.NoHistory": "无更改历史",
"Component.Namespace.Master.Items.Body.Instance.Tips": "实例说明:只展示最近一天访问过Apollo的实例",
"Component.Namespace.Master.Items.Body.Instance.UsedNewItem": "使用最新配置的实例",
"Component.Namespace.Master.Items.Body.Instance.NoUsedNewItem": "使用非最新配置的实例",
"Component.Namespace.Master.Items.Body.Instance.AllInstance": "所有实例",
"Component.Namespace.Master.Items.Body.Instance.RefreshList": "刷新列表",
"Component.Namespace.Master.Items.Body.Instance.ToSeeItem": "查看配置",
"Component.Namespace.Master.Items.Body.Instance.LoadMore": "加载更多",
"Component.Namespace.Master.Items.Body.Instance.ItemAppId": "App ID",
"Component.Namespace.Master.Items.Body.Instance.ItemCluster": "Cluster Name",
"Component.Namespace.Master.Items.Body.Instance.ItemDataCenter": "Data Center",
"Component.Namespace.Master.Items.Body.Instance.ItemIp": "IP",
"Component.Namespace.Master.Items.Body.Instance.ItemGetTime": "配置获取时间",
"Component.Namespace.Master.Items.Body.Instance.NoInstanceTips": "无实例信息",
"Component.PublishDeny.Title": "发布受限",
"Component.PublishDeny.Tips1": "您不能发布哟~{{env}}环境配置的编辑和发布必须为不同的人,请找另一个具有当前namespace发布权的人操作发布~",
"Component.PublishDeny.Tips2": "(如果是非工作时间或者特殊情况,您可以通过点击'紧急发布'按钮进行发布)",
"Component.PublishDeny.EmergencyPublish": "紧急发布",
"Component.PublishDeny.Close": "关闭",
"Component.Publish.Title": "发布",
"Component.Publish.Tips": "(只有发布过的配置才会被客户端获取到,此次发布只会作用于当前环境:{{env}})",
"Component.Publish.Grayscale": "灰度发布",
"Component.Publish.GrayscaleTips": "(灰度发布的配置只会作用于在灰度规则中配置的实例)",
"Component.Publish.AllPublish": "全量发布",
"Component.Publish.AllPublishTips": "(全量发布的配置会作用于全部的实例)",
"Component.Publish.ToSeeChange": "查看变更",
"Component.Publish.PublishedValue": "发布的值",
"Component.Publish.Changes": "Changes",
"Component.Publish.Key": "Key",
"Component.Publish.NoPublishedValue": "未发布的值",
"Component.Publish.ModifyUser": "修改人",
"Component.Publish.ModifyTime": "修改时间",
"Component.Publish.NewAdded": "新",
"Component.Publish.NewAddedTips": "新增的配置",
"Component.Publish.Modified": "改",
"Component.Publish.ModifiedTips": "修改的配置",
"Component.Publish.Deleted": "删",
"Component.Publish.DeletedTips": "删除的配置",
"Component.Publish.MasterValue": "主版本值",
"Component.Publish.GrayValue": "灰度版本的值",
"Component.Publish.GrayPublishedValue": "灰度版本发布的值",
"Component.Publish.GrayNoPublishedValue": "灰度版本未发布的值",
"Component.Publish.ItemNoChange": "配置没有变化",
"Component.Publish.GrayItemNoChange": "灰度配置没有变化",
"Component.Publish.NoGrayItems": "没有灰度的配置项",
"Component.Publish.Release": "Release Name",
"Component.Publish.ReleaseComment": "Comment",
"Component.Publish.OpPublish": "发布",
"Component.Rollback.To": "回滚到",
"Component.Rollback.Tips": "此操作将会回滚到上一个发布版本,且当前版本作废,但不影响正在修改的配置。可在发布历史页面查看当前生效的版本",
"Component.RollbackTo.Tips":"此操作将会回滚到此发布版本,且当前版本作废,但不影响正在修改的配置",
"Component.Rollback.ClickToView": "点击查看",
"Component.Rollback.ItemType": "Type",
"Component.Rollback.ItemKey": "Key",
"Component.Rollback.RollbackBeforeValue": "回滚前",
"Component.Rollback.RollbackAfterValue": "回滚后",
"Component.Rollback.Added": "新增",
"Component.Rollback.Modified": "更新",
"Component.Rollback.Deleted": "删除",
"Component.Rollback.NoChange": "配置没有变化",
"Component.Rollback.OpRollback": "回滚",
"Component.ShowText.Title": "查看",
"Login.Login": "登录",
"Login.UserNameOrPasswordIncorrect": "用户名或密码错误",
"Login.LogoutSuccessfully": "登出成功",
"Index.MyProject": "我的项目",
"Index.CreateProject": "创建项目",
"Index.LoadMore": "加载更多",
"Index.FavoriteItems": "收藏的项目",
"Index.Topping": "置顶",
"Index.FavoriteTip": "您还没有收藏过任何项目,在项目主页可以收藏项目哟~",
"Index.RecentlyViewedItems": "最近浏览的项目",
"Index.GetCreateAppRoleFailed": "获取创建应用权限信息失败",
"Index.Topped": "置顶成功",
"Index.CancelledFavorite": "取消收藏成功",
"Cluster.CreateCluster": "新建集群",
"Cluster.Tips.1": "通过添加集群,可以使同一份程序在不同的集群(如不同的数据中心)使用不同的配置",
"Cluster.Tips.2": "如果不同集群使用一样的配置,则没有必要创建集群",
"Cluster.Tips.3": "Apollo默认会读取机器上/opt/settings/server.properties(linux)或C:\\opt\\settings\\server.properties(windows)文件中的idc属性作为集群名字, 如SHAJQ(金桥数据中心)、SHAOY(欧阳数据中心)",
"Cluster.Tips.4": "在这里创建的集群名字需要和机器上server.properties中的idc属性一致",
"Cluster.CreateNameTips": "(部署集群如:SHAJQ,SHAOY 或自定义集群如:SHAJQ-xx,SHAJQ-yy)",
"Cluster.ChooseEnvironment": "选择环境",
"Cluster.LoadingEnvironmentError": "加载环境信息出错",
"Cluster.ClusterCreated": "集群创建成功",
"Cluster.ClusterCreateFailed": "集群创建失败",
"Cluster.PleaseChooseEnvironment": "请选择环境",
"Config.Title": "Apollo配置中心",
"Config.AppIdNotFound": "不存在,",
"Config.ClickByCreate": "点击创建",
"Config.EnvList": "环境列表",
"Config.EnvListTips": "通过切换环境、集群来管理不同环境、集群的配置",
"Config.ProjectInfo": "项目信息",
"Config.ModifyBasicProjectInfo": "修改项目基本信息",
"Config.Favorite": "收藏",
"Config.CancelFavorite": "取消收藏",
"Config.MissEnv": "缺失的环境",
"Config.MissNamespace": "缺失的Namespace",
"Config.ProjectManage": "管理项目",
"Config.AccessKeyManage": "管理密钥",
"Config.CreateAppMissEnv": "补缺环境",
"Config.CreateAppMissNamespace": "补缺Namespace",
"Config.AddCluster": "添加集群",
"Config.AddNamespace": "添加Namespace",
"Config.CurrentlyOperatorEnv": "当前操作环境",
"Config.DoNotRemindAgain": "不再提示",
"Config.Note": "注意",
"Config.ClusterIsDefaultTipContent": "所有不属于 '{{name}}' 集群的实例会使用default集群(当前页面)的配置,属于 '{{name}}' 的实例会使用对应集群的配置!",
"Config.ClusterIsCustomTipContent": "属于 '{{name}}' 集群的实例只会使用 '{{name}}' 集群(当前页面)的配置,只有当对应namespace在当前集群没有发布过配置时,才会使用default集群的配置。",
"Config.HasNotPublishNamespace": "以下环境/集群有未发布的配置,客户端获取不到未发布的配置,请及时发布。",
"Config.RevokeItem.DialogTitle": "撤销配置",
"Config.RevokeItem.DialogContent": "当前命名空间下已修改但尚未发布的配置将被撤销,确定要撤销么?",
"Config.DeleteItem.DialogTitle": "删除配置",
"Config.DeleteItem.DialogContent": "您正在删除 Key 为 <b> '{{config.key}}' </b> Value 为 <b> '{{config.value}}' </b> 的配置.<br>确定要删除配置吗?",
"Config.PublishNoPermission.DialogTitle": "发布",
"Config.PublishNoPermission.DialogContent": "您没有发布权限哦~ 请找项目管理员 '{{masterUsers}}' 分配发布权限",
"Config.ModifyNoPermission.DialogTitle": "申请配置权限",
"Config.ModifyNoPermission.DialogContent": "请找项目管理员 '{{masterUsers}}' 分配编辑或发布权限",
"Config.MasterNoPermission.DialogTitle": "申请配置权限",
"Config.MasterNoPermission.DialogContent": "您不是项目管理员, 只有项目管理员才有添加集群、namespace的权限。如需管理员权限,请找项目管理员 '{{masterUsers}}' 分配管理员权限",
"Config.NamespaceLocked.DialogTitle": "编辑受限",
"Config.NamespaceLocked.DialogContent": "当前namespace正在被 '{{lockOwner}}' 编辑,一次发布只能被一个人修改.",
"Config.RollbackAlert.DialogTitle": "回滚",
"Config.RollbackAlert.DialogContent": "确定要回滚吗?",
"Config.EmergencyPublishAlert.DialogTitle": "紧急发布",
"Config.EmergencyPublishAlert.DialogContent": "确定要紧急发布吗?",
"Config.DeleteBranch.DialogTitle": "删除灰度",
"Config.DeleteBranch.DialogContent": "删除灰度会丢失灰度的配置,确定要删除吗?",
"Config.UpdateRuleTips.DialogTitle": "更新灰度规则提示",
"Config.UpdateRuleTips.DialogContent": "灰度规则已生效,但发现灰度版本有未发布的配置,这些配置需要手动灰度发布才会生效",
"Config.MergeAndReleaseDeny.DialogTitle": "全量发布",
"Config.MergeAndReleaseDeny.DialogContent": "namespace主版本有未发布的配置,请先发布主版本配置",
"Config.GrayReleaseWithoutRulesTips.DialogTitle": "缺失灰度规则提示",
"Config.GrayReleaseWithoutRulesTips.DialogContent": "灰度版本还没有配置任何灰度规则,请配置灰度规则",
"Config.DeleteNamespaceDenyForMasterInstance.DialogTitle": "删除Namespace警告信息",
"Config.DeleteNamespaceDenyForMasterInstance.DialogContent": "发现有 <b>'{{deleteNamespaceContext.namespace.instancesCount}}'</b> 个实例正在使用Namespace('{{deleteNamespaceContext.namespace.baseInfo.namespaceName}}'),删除Namespace将导致实例获取不到配置。<br>请到 <ins>“实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。",
"Config.DeleteNamespaceDenyForBranchInstance.DialogTitle": "删除Namespace警告信息",
"Config.DeleteNamespaceDenyForBranchInstance.DialogContent": "发现有 <b>'{{deleteNamespaceContext.namespace.branch.latestReleaseInstances.total}}'</b> 个实例正在使用Namespace('{{deleteNamespaceContext.namespace.baseInfo.namespaceName}}')灰度版本的配置,删除Namespace将导致实例获取不到配置。<br> 请到 <ins>“灰度版本” => “实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。",
"Config.DeleteNamespaceDenyForPublicNamespace.DialogTitle": "删除Namespace失败提示",
"Config.DeleteNamespaceDenyForPublicNamespace.DialogContent": "删除Namespace失败提示",
"Config.DeleteNamespaceDenyForPublicNamespace.PleaseEnterAppId": "请输入appId",
"Config.SyntaxCheckFailed.DialogTitle": "语法检查错误",
"Config.SyntaxCheckFailed.DialogContent": "删除Namespace失败提示",
"Config.CreateBranchTips.DialogTitle": "创建灰度须知",
"Config.CreateBranchTips.DialogContent": "通过创建灰度版本,您可以对某些配置做灰度测试<br>灰度流程为:<br> 1.创建灰度版本 <br> 2.配置灰度配置项<br> 3.配置灰度规则.如果是私有的namespace可以按照客户端的IP进行灰度,如果是公共的namespace则可以同时按AppId和客户端的IP进行灰度<br> 4.灰度发布<br>灰度版本最终有两种结果:<b>全量发布和放弃灰度</b><br><b>全量发布</b>:灰度的配置合到主版本并发布,所有的客户端都会使用合并后的配置<br><b>放弃灰度</b>:删除灰度版本,所有的客户端都会使用回主版本的配置<br>注意事项:<br> 1.如果灰度版本已经有灰度发布过,那么修改灰度规则后,无需再次灰度发布就立即生效",
"Config.ProjectMissEnvInfos": "当前项目有环境缺失,请点击页面左侧『补缺环境』补齐数据",
"Config.ProjectMissNamespaceInfos": "当前环境有Namespace缺失,请点击页面左侧『补缺Namespace』补齐数据",
"Config.SystemError": "系统出错,请重试或联系系统负责人",
"Config.FavoriteSuccessfully": "收藏成功",
"Config.FavoriteFailed": "收藏失败",
"Config.CancelledFavorite": "取消收藏成功",
"Config.CancelFavoriteFailed": "取消收藏失败",
"Config.GetUserInfoFailed": "获取用户登录信息失败",
"Config.LoadingAllNamespaceError": "加载配置信息出错",
"Config.CancelFavoriteError": "取消收藏失败",
"Config.Deleted": "删除成功",
"Config.DeleteFailed": "删除失败",
"Config.GrayscaleCreated": "创建灰度成功",
"Config.GrayscaleCreateFailed": "创建灰度失败",
"Config.BranchDeleted": "分支删除成功",
"Config.BranchDeleteFailed": "分支删除失败",
"Config.DeleteNamespaceFailedTips": "以下应用已关联此公共Namespace,必须先删除全部已关联的Namespace才能删除公共Namespace",
"Config.DeleteNamespaceNoPermissionFailedTitle": "删除失败",
"Config.DeleteNamespaceNoPermissionFailedTips": "您没有项目管理员权限,只有管理员才能删除Namespace,请找项目管理员 [{{users}}] 删除Namespace",
"Delete.Title": "删除应用、集群、AppNamespace",
"Delete.DeleteApp": "删除应用",
"Delete.DeleteAppTips": "(由于删除应用影响面较大,所以现在暂时只允许系统管理员删除,请确保没有客户端读取该应用的配置后再做删除动作)",
"Delete.AppIdTips": "(删除前请先查询应用信息)",
"Delete.AppInfo": "应用信息",
"Delete.DeleteCluster": "删除集群",
"Delete.DeleteClusterTips": "(由于删除集群影响面较大,所以现在暂时只允许系统管理员删除,请确保没有客户端读取该集群的配置后再做删除动作)",
"Delete.EnvName": "环境名称",
"Delete.ClusterNameTips": "(删除前请先查询应用集群信息)",
"Delete.ClusterInfo": "集群信息",
"Delete.DeleteNamespace": "删除AppNamespace",
"Delete.DeleteNamespaceTips": "(注意,所有环境的Namespace和AppNamespace都会被删除!如果只是要删除某个环境的Namespace,让用户到项目页面中自行删除!)",
"Delete.DeleteNamespaceTips2": "目前用户可以自行删除关联的Namespace和私有的Namespace,不过无法删除AppNamespace元信息,因为删除AppNamespace影响面较大,所以现在暂时只允许系统管理员删除,对于公共Namespace需要确保没有应用关联了该AppNamespace。",
"Delete.AppNamespaceName": "AppNamespace名称",
"Delete.AppNamespaceNameTips": "(非properties类型的namespace请加上类型后缀,例如apollo.xml)",
"Delete.AppNamespaceInfo": "AppNamespace信息",
"Delete.IsRootUserTips": "当前页面只对Apollo管理员开放",
"Delete.PleaseEnterAppId": "请输入appId",
"Delete.AppIdNotFound": "AppId: '{{appId}}'不存在!",
"Delete.AppInfoContent": "应用名:'{{appName}}' 部门:'{{departmentName}}({{departmentId}})' 负责人:'{{ownerName}}'",
"Delete.ConfirmDeleteAppId": "确认删除AppId:'{{appId}}'?",
"Delete.Deleted": "删除成功",
"Delete.PleaseEnterAppIdAndEnvAndCluster": "请输入appId、环境和集群名称",
"Delete.ClusterInfoContent": "AppId:'{{appId}}' 环境:'{{env}}' 集群名称:'{{clusterName}}'",
"Delete.ConfirmDeleteCluster": "确认删除集群?AppId:'{{appId}}' 环境:'{{env}}' 集群名称:'{{clusterName}}'",
"Delete.PleaseEnterAppIdAndNamespace": "请输入appId和AppNamespace名称",
"Delete.AppNamespaceInfoContent": "AppId:'{{appId}}' AppNamespace名称:'{{namespace}}' isPublic:'{{isPublic}}'",
"Delete.ConfirmDeleteNamespace": "确认删除所有环境的AppNamespace和Namespace?appId: '{{appId}}' 环境:'所有环境' AppNamespace名称:'{{namespace}}'",
"Namespace.Title": "新建Namespace",
"Namespace.UnderstandMore": "(点击了解更多Namespace相关知识)",
"Namespace.Link.Tips1": "应用可以通过关联公共namespace来覆盖公共Namespace的配置",
"Namespace.Link.Tips2": "如果应用不需要覆盖公共Namespace的配置,那么无需关联公共Namespace",
"Namespace.CreatePublic.Tips1": "公共的Namespace的配置能被任何项目读取",
"Namespace.CreatePublic.Tips2": "通过创建公共Namespace可以实现公共组件的配置,或多个应用共享同一份配置的需求",
"Namespace.CreatePublic.Tips3": "如果其它应用需要覆盖公共部分的配置,可以在其它应用那里关联公共Namespace,然后在关联的Namespace里面配置需要覆盖的配置即可",
"Namespace.CreatePublic.Tips4": "如果其它应用不需要覆盖公共部分的配置,那么就不需要在其它应用那里关联公共Namespace",
"Namespace.CreatePrivate.Tips1": "私有Namespace的配置只能被所属的应用获取到",
"Namespace.CreatePrivate.Tips2": "通过创建一个私有的Namespace可以实现分组管理配置",
"Namespace.CreatePrivate.Tips3": "私有Namespace的格式可以是xml、yml、yaml、json、txt. 您可以通过apollo-client中ConfigFile接口来获取非properties格式Namespace的内容",
"Namespace.CreatePrivate.Tips4": "1.3.0及以上版本的apollo-client针对yaml/yml提供了更好的支持,可以通过ConfigService.getConfig(\"someNamespace.yml\")直接获取Config对象,也可以通过@EnableApolloConfig(\"someNamespace.yml\")或apollo.bootstrap.namespaces=someNamespace.yml注入yml配置到Spring/SpringBoot中去",
"Namespace.CreateNamespace": "创建Namespace",
"Namespace.AssociationPublicNamespace": "关联公共Namespace",
"Namespace.ChooseCluster": "选择集群",
"Namespace.NamespaceName": "名称",
"Namespace.AutoAddDepartmentPrefix": "自动添加部门前缀",
"Namespace.AutoAddDepartmentPrefixTips": "(公共Namespace的名称需要全局唯一,添加部门前缀有助于保证全局唯一性)",
"Namespace.NamespaceType": "类型",
"Namespace.NamespaceType.Public": "public",
"Namespace.NamespaceType.Private": "private",
"Namespace.Remark": "备注",
"Namespace.Namespace": "namespace",
"Namespace.PleaseChooseNamespace": "请选择Namespace",
"Namespace.LoadingPublicNamespaceError": "加载公共namespace错误",
"Namespace.LoadingAppInfoError": "加载App信息出错",
"Namespace.PleaseChooseCluster": "请选择集群",
"Namespace.CheckNamespaceNameLengthTip": "namespace名称不能大于32个字符. 部门前缀:'{{departmentLength}}'个字符, 名称{{namespaceLength}}个字符",
"ServiceConfig.Title": "应用配置",
"ServiceConfig.Tips": "(维护ApolloPortalDB.ServerConfig表数据,如果已存在配置项则会覆盖,否则会创建配置项。配置更新后,一分钟后自动生效)",
"ServiceConfig.Key": "key",
"ServiceConfig.KeyTips": "(修改配置前请先查询该配置信息)",
"ServiceConfig.Value": "value",
"ServiceConfig.Comment": "comment",
"ServiceConfig.Saved": "保存成功",
"ServiceConfig.SaveFailed": "保存失败",
"ServiceConfig.PleaseEnterKey": "请输入key",
"ServiceConfig.KeyNotExistsAndCreateTip": "Key: '{{key}}' 不存在,点击保存后会创建该配置项",
"ServiceConfig.KeyExistsAndSaveTip": "Key: '{{key}}' 已存在,点击保存后会覆盖该配置项",
"AccessKey.Tips.1": "每个环境最多可添加5个访问密钥",
"AccessKey.Tips.2": "一旦该环境有启用的访问密钥,客户端将被要求配置密钥,否则无法获取配置",
"AccessKey.Tips.3": "配置访问密钥防止非法客户端获取该应用配置,配置方式如下(需要apollo-client 1.6.0+版本):",
"AccessKey.Tips.3.1": "通过jvm参数-Dapollo.accesskey.secret",
"AccessKey.Tips.3.2": "通过操作系统环境变量APOLLO_ACCESSKEY_SECRET",
"AccessKey.Tips.3.3": "通过META-INF/app.properties或application.properties配置apollo.accesskey.secret(注意多环境secret不一样)",
"AccessKey.NoAccessKeyServiceTips": "该环境没有配置访问密钥",
"AccessKey.ConfigAccessKeys.Secret": "访问密钥",
"AccessKey.ConfigAccessKeys.Status": "状态",
"AccessKey.ConfigAccessKeys.LastModify": "最后修改人",
"AccessKey.ConfigAccessKeys.LastModifyTime": "最后修改时间",
"AccessKey.ConfigAccessKeys.Operator": "操作",
"AccessKey.Operator.Disable": "禁用",
"AccessKey.Operator.Enable": "启用",
"AccessKey.Operator.Disabled": "已禁用",
"AccessKey.Operator.Enabled": "已启用",
"AccessKey.Operator.Remove": "删除",
"AccessKey.Operator.CreateSuccess": "访问密钥创建成功",
"AccessKey.Operator.DisabledSuccess": "访问密钥禁用成功",
"AccessKey.Operator.EnabledSuccess": "访问密钥启用成功",
"AccessKey.Operator.RemoveSuccess": "访问密钥删除成功",
"AccessKey.Operator.CreateError": "访问密钥创建失败",
"AccessKey.Operator.DisabledError": "访问密钥禁用失败",
"AccessKey.Operator.EnabledError": "访问密钥启用失败",
"AccessKey.Operator.RemoveError": "访问密钥删除失败",
"AccessKey.Operator.DisabledTips": "是否确定禁用该访问密钥?",
"AccessKey.Operator.EnabledTips": " 是否确定启用该访问密钥?",
"AccessKey.Operator.RemoveTips": " 是否确定删除该访问密钥?",
"AccessKey.LoadError": "加载访问密钥出错",
"SystemInfo.Title": "系统信息",
"SystemInfo.SystemVersion": "系统版本",
"SystemInfo.Tips1": "环境列表来自于ApolloPortalDB.ServerConfig中的<strong>apollo.portal.envs</strong>配置,可以到<a href=\"{{serverConfigUrl}}\">系统参数</a>页面配置,更多信息可以参考<a href=\"{{wikiUrl}}\">分布式部署指南</a>中的<strong>apollo.portal.envs - 可支持的环境列表</strong>章节。",
"SystemInfo.Tips2": "Meta server地址展示了该环境配置的meta server信息,更多信息可以参考<a href=\"{{wikiUrl}}\">分布式部署指南</a>中的<strong>配置apollo-portal的meta service信息</strong>章节。",
"SystemInfo.Active": "Active",
"SystemInfo.ActiveTips": "(当前环境状态异常,请结合下方系统信息和AdminService的Check Health结果排查)",
"SystemInfo.MetaServerAddress": "Meta server地址",
"SystemInfo.ConfigServices": "Config Services",
"SystemInfo.ConfigServices.Name": "Name",
"SystemInfo.ConfigServices.InstanceId": "Instance Id",
"SystemInfo.ConfigServices.HomePageUrl": "Home Page Url",
"SystemInfo.ConfigServices.CheckHealth": "Check Health",
"SystemInfo.NoConfigServiceTips": "No config service found!",
"SystemInfo.Check": "check",
"SystemInfo.AdminServices": "Admin Services",
"SystemInfo.AdminServices.Name": "Name",
"SystemInfo.AdminServices.InstanceId": "Instance Id",
"SystemInfo.AdminServices.HomePageUrl": "Home Page Url",
"SystemInfo.AdminServices.CheckHealth": "Check Health",
"SystemInfo.NoAdminServiceTips": "No admin service found!",
"SystemInfo.IsRootUser": "当前页面只对Apollo管理员开放",
"SystemRole.Title": "系统权限管理",
"SystemRole.AddCreateAppRoleToUser": "为用户添加创建应用权限",
"SystemRole.AddCreateAppRoleToUserTips": "(系统参数中设置 role.create-application.enabled=true 会限制只有超级管理员和拥有创建应用权限的帐号可以创建项目)",
"SystemRole.ChooseUser": "用户选择",
"SystemRole.Add": "添加",
"SystemRole.AuthorizedUser": "已拥有权限用户",
"SystemRole.ModifyAppAdminUser": "修改应用管理员分配权限",
"SystemRole.ModifyAppAdminUserTips": "(系统参数中设置 role.manage-app-master.enabled=true 会限制只有超级管理员和拥有管理员分配权限的帐号可以修改项目管理员)",
"SystemRole.AppIdTips": "(请先查询应用信息)",
"SystemRole.AppInfo": "应用信息",
"SystemRole.AllowAppMasterAssignRole": "允许此用户作为管理员时添加Master",
"SystemRole.DeleteAppMasterAssignRole": "禁止此用户作为管理员时添加Master",
"SystemRole.IsRootUser": "当前页面只对Apollo管理员开放",
"SystemRole.PleaseChooseUser": "请选择用户名",
"SystemRole.Added": "添加成功",
"SystemRole.AddFailed": "添加失败",
"SystemRole.Deleted": "删除成功",
"SystemRole.DeleteFailed": "删除失败",
"SystemRole.GetCanCreateProjectUsersError": "获取拥有创建项目权限的用户列表出错",
"SystemRole.PleaseEnterAppId": "请输入appId",
"SystemRole.AppIdNotFound": "AppId: '{{appId}}' 不存在!",
"SystemRole.AppInfoContent": "应用名:'{{appName}}' 部门:'{{departmentName}}({{departmentId}})' 负责人:'{{ownerName}}",
"SystemRole.DeleteMasterAssignRoleTips": "确认删除AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限?",
"SystemRole.DeletedMasterAssignRoleTips": "删除AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限成功",
"SystemRole.AllowAppMasterAssignRoleTips": "确认添加AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限?",
"SystemRole.AllowedAppMasterAssignRoleTips": "添加AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限成功",
"UserMange.Title": "用户管理",
"UserMange.TitleTips": "(仅对默认的Spring Security简单认证方式有效: -Dapollo_profile=github,auth)",
"UserMange.UserName": "用户名",
"UserMange.UserNameTips": "输入的用户名如果不存在,则新建。若已存在,则更新。",
"UserMange.Pwd": "密码",
"UserMange.Email": "邮箱",
"UserMange.Created": "创建用户成功",
"UserMange.CreateFailed": "创建用户失败",
"Open.Manage.Title": "开放平台",
"Open.Manage.CreateThirdApp": "创建第三方应用",
"Open.Manage.CreateThirdAppTips": "(说明: 第三方应用可以通过Apollo开放平台来对配置进行管理)",
"Open.Manage.ThirdAppId": "第三方应用ID",
"Open.Manage.ThirdAppIdTips": "(创建前请先查询第三方应用是否已经申请过)",
"Open.Manage.ThirdAppName": "第三方应用名称",
"Open.Manage.ThirdAppNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"Open.Manage.ProjectOwner": "项目负责人",
"Open.Manage.Create": "创建",
"Open.Manage.GrantPermission": "赋权",
"Open.Manage.GrantPermissionTips": "(Namespace级别权限包括: 修改、发布Namespace。应用级别权限包括: 创建Namespace、修改或发布应用下任何Namespace)",
"Open.Manage.Token": "Token",
"Open.Manage.ManagedAppId": "被管理的AppId",
"Open.Manage.ManagedNamespace": "被管理的Namespace",
"Open.Manage.ManagedNamespaceTips": "(非properties类型的namespace请加上类型后缀,例如apollo.xml)",
"Open.Manage.GrantType": "授权类型",
"Open.Manage.GrantType.Namespace": "Namespace",
"Open.Manage.GrantType.App": "App",
"Open.Manage.GrantEnv": "环境",
"Open.Manage.GrantEnvTips": "(不选择则所有环境都有权限,如果提示Namespace's role does not exist,请先打开该Namespace的授权页面触发一下权限的初始化动作)",
"Open.Manage.PleaseEnterAppId": "请输入appId",
"Open.Manage.AppNotCreated": "App('{{appId}}')未创建,请先创建",
"Open.Manage.GrantSuccessfully": "赋权成功",
"Open.Manage.GrantFailed": "赋权失败",
"Namespace.Role.Title": "权限管理",
"Namespace.Role.GrantModifyTo": "修改权",
"Namespace.Role.GrantModifyTo2": "(可以修改配置)",
"Namespace.Role.AllEnv": "所有环境",
"Namespace.Role.GrantPublishTo": "发布权",
"Namespace.Role.GrantPublishTo2": "(可以发布配置)",
"Namespace.Role.Add": "添加",
"Namespace.Role.NoPermission": "您没有权限哟!",
"Namespace.Role.InitNamespacePermissionError": "初始化授权出错",
"Namespace.Role.GetEnvGrantUserError": "加载 '{{env}}' 授权用户出错",
"Namespace.Role.GetGrantUserError": "加载授权用户出错",
"Namespace.Role.PleaseChooseUser": "请选择用户",
"Namespace.Role.Added": "添加成功",
"Namespace.Role.AddFailed": "添加失败",
"Namespace.Role.Deleted": "删除成功",
"Namespace.Role.DeleteFailed": "删除失败",
"Config.Sync.Title": "同步配置",
"Config.Sync.FistStep": "(第一步:选择同步信息)",
"Config.Sync.SecondStep": "(第二步:检查Diff)",
"Config.Sync.PreviousStep": "上一步",
"Config.Sync.NextStep": "下一步",
"Config.Sync.Sync": "同步",
"Config.Sync.Tips": "Tips",
"Config.Sync.Tips1": "通过同步配置功能,可以使多个环境、集群间的配置保持一致",
"Config.Sync.Tips2": "需要注意的是,同步完之后需要发布后才会对应用生效",
"Config.Sync.SyncNamespace": "同步的Namespace",
"Config.Sync.SyncToCluster": "同步到哪个集群",
"Config.Sync.NeedToSyncItem": "需要同步的配置",
"Config.Sync.SortByLastModifyTime": "按最后更新时间过滤",
"Config.Sync.BeginTime": "开始时间",
"Config.Sync.EndTime": "结束时间",
"Config.Sync.Filter": "过滤",
"Config.Sync.Rest": "重置",
"Config.Sync.ItemKey": "Key",
"Config.Sync.ItemValue": "Value",
"Config.Sync.ItemCreateTime": "Create Time",
"Config.Sync.ItemUpdateTime": "Update Time",
"Config.Sync.NoNeedSyncItem": "没有更新的配置",
"Config.Sync.IgnoreSync": "忽略同步",
"Config.Sync.Step2Type": "Type",
"Config.Sync.Step2Key": "Key",
"Config.Sync.Step2SyncBefore": "同步前",
"Config.Sync.Step2SyncAfter": "同步后",
"Config.Sync.Step2Comment": "Comment",
"Config.Sync.Step2Operator": "操作",
"Config.Sync.NewAdd": "新增",
"Config.Sync.NoSyncItem": "不同步该配置",
"Config.Sync.Delete": "删除",
"Config.Sync.Update": "更新",
"Config.Sync.SyncSuccessfully": "同步成功!",
"Config.Sync.SyncFailed": "同步失败!",
"Config.Sync.LoadingItemsError": "加载配置出错",
"Config.Sync.PleaseChooseNeedSyncItems": "请选择需要同步的配置",
"Config.Sync.PleaseChooseCluster": "请选择集群",
"Config.History.Title": "发布历史",
"Config.History.MasterVersionPublish": "主版本发布",
"Config.History.MasterVersionRollback": "主版本回滚",
"Config.History.GrayscaleOperator": "灰度操作",
"Config.History.PublishHistory": "发布历史",
"Config.History.OperationType0": "普通发布",
"Config.History.OperationType1": "回滚",
"Config.History.OperationType2": "灰度发布",
"Config.History.OperationType3": "更新灰度规则",
"Config.History.OperationType4": "灰度全量发布",
"Config.History.OperationType5": "灰度发布(主版本发布)",
"Config.History.OperationType6": "灰度发布(主版本回滚)",
"Config.History.OperationType7": "放弃灰度",
"Config.History.OperationType8": "删除灰度(全量发布)",
"Config.History.UrgentPublish": "紧急发布",
"Config.History.LoadMore": "加载更多",
"Config.History.Abandoned": "已废弃",
"Config.History.RollbackTo": "回滚到此版本",
"Config.History.RollbackToTips": "回滚已发布的配置到此版本",
"Config.History.ChangedItem": "变更的配置",
"Config.History.ChangedItemTips": "查看此次发布与上次版本的变更",
"Config.History.AllItem": "全部配置",
"Config.History.AllItemTips": "查看此次发布的所有配置信息",
"Config.History.ChangeType": "Type",
"Config.History.ChangeKey": "Key",
"Config.History.ChangeValue": "Value",
"Config.History.ChangeOldValue": "Old Value",
"Config.History.ChangeNewValue": "New Value",
"Config.History.ChangeTypeNew": "新增",
"Config.History.ChangeTypeModify": "修改",
"Config.History.ChangeTypeDelete": "删除",
"Config.History.NoChange": "无配置更改",
"Config.History.NoItem": "无配置",
"Config.History.GrayscaleRule": "灰度规则",
"Config.History.GrayscaleAppId": "灰度的AppId",
"Config.History.GrayscaleIp": "灰度的IP",
"Config.History.NoGrayscaleRule": "无灰度规则",
"Config.History.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看发布历史",
"Config.History.NoPublishHistory": "无发布历史信息",
"Config.History.LoadingHistoryError": "无发布历史信息",
"Config.Diff.Title": "比较配置",
"Config.Diff.FirstStep": "(第一步:选择比较信息)",
"Config.Diff.SecondStep": "(第二步:查看差异配置)",
"Config.Diff.PreviousStep": "上一步",
"Config.Diff.NextStep": "下一步",
"Config.Diff.TipsTitle": "Tips",
"Config.Diff.Tips": "通过比较配置功能,可以查看多个环境、集群间的配置差异",
"Config.Diff.DiffCluster": "要比较的集群",
"Config.Diff.HasDiffComment": "是否比较注释",
"Config.Diff.PleaseChooseTwoCluster": "请至少选择两个集群",
"ConfigExport.Title": "配置导出",
"ConfigExport.TitleTips" : "超级管理员会下载所有项目的配置,普通用户只会下载自己项目的配置",
"ConfigExport.Download": "下载",
"App.CreateProject": "创建项目",
"App.AppIdTips": "(应用唯一标识)",
"App.AppNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"App.AppOwnerTips": "(开启项目管理员分配权限控制后,应用负责人和项目管理员默认为本账号,不可选择)",
"App.AppAdminTips1": "(应用负责人默认具有项目管理员权限,",
"App.AppAdminTips2": "项目管理员可以创建Namespace和集群、分配用户权限)",
"App.AccessKey.NoPermissionTips": "您没有权限操作,请找 [{{users}}] 开通权限",
"App.Setting.Title": "项目管理",
"App.Setting.Admin": "管理员",
"App.Setting.AdminTips": "(项目管理员具有以下权限: 1. 创建Namespace 2. 创建集群 3. 管理项目、Namespace权限)",
"App.Setting.Add": "添加",
"App.Setting.BasicInfo": "基本信息",
"App.Setting.ProjectName": "项目名称",
"App.Setting.ProjectNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"App.Setting.ProjectOwner": "项目负责人",
"App.Setting.Modify": "修改项目信息",
"App.Setting.Cancel": "取消修改",
"App.Setting.NoPermissionTips": "您没有权限操作,请找 [{{users}}] 开通权限",
"App.Setting.DeleteAdmin": "删除管理员",
"App.Setting.CanNotDeleteAllAdmin": "不能删除所有的管理员",
"App.Setting.PleaseChooseUser": "请选择用户",
"App.Setting.Added": "添加成功",
"App.Setting.AddFailed": "添加失败",
"App.Setting.Deleted": "删除成功",
"App.Setting.DeleteFailed": "删除失败",
"App.Setting.Modified": "修改成功",
"Valdr.App.AppId.Size": "AppId长度不能多于64个字符",
"Valdr.App.AppId.Required": "AppId不能为空",
"Valdr.App.appName.Size": "应用名称长度不能多于128个字符",
"Valdr.App.appName.Required": "应用名称不能为空",
"Valdr.Cluster.ClusterName.Size": "集群名称长度不能多于32个字符",
"Valdr.Cluster.ClusterName.Required": "集群名称不能为空",
"Valdr.AppNamespace.NamespaceName.Size": "Namespace名称长度不能多于32个字符",
"Valdr.AppNamespace.NamespaceName.Required": "Namespace名称不能为空",
"Valdr.AppNamespace.Comment.Size": "备注长度不能多于64个字符",
"Valdr.Item.Key.Size": "Key长度不能多于128个字符",
"Valdr.Item.Key.Required": "Key不能为空",
"Valdr.Item.Comment.Size": "备注长度不能多于64个字符",
"Valdr.Release.ReleaseName.Size": "Release Name长度不能多于64个字符",
"Valdr.Release.ReleaseName.Required": "Release Name不能为空",
"Valdr.Release.Comment.Size": "备注长度不能多于64个字符",
"ApolloConfirmDialog.DefaultConfirmBtnName": "确认",
"ApolloConfirmDialog.SearchPlaceHolder": "搜索项目(AppId、项目名)",
"RulesModal.ChooseInstances": "从实例列表中选择",
"RulesModal.InvalidIp": "不合法的IP地址: '{{ip}}'",
"RulesModal.GrayscaleAppIdCanNotBeNull": "灰度的AppId不能为空",
"RulesModal.AppIdExistsRule": "已经存在AppId='{{appId}}'的规则",
"RulesModal.IpListCanNotBeNull": "IP列表不能为空",
"ItemModal.KeyExists": "key='{{key}}' 已存在",
"ItemModal.AddedTips": "添加成功,如需生效请发布",
"ItemModal.AddFailed": "添加失败",
"ItemModal.PleaseChooseCluster": "请选择集群",
"ItemModal.ModifiedTips": "更新成功, 如需生效请发布",
"ItemModal.ModifyFailed": "更新失败",
"ItemModal.Tabs": "制表符",
"ItemModal.NewLine": "换行符",
"ItemModal.Space": "空格",
"ApolloNsPanel.LoadingHistoryError": "加载修改历史记录出错",
"ApolloNsPanel.LoadingGrayscaleError": "加载修改历史记录出错",
"ApolloNsPanel.Deleted": "删除成功",
"ApolloNsPanel.GrayscaleModified": "灰度规则更新成功",
"ApolloNsPanel.GrayscaleModifyFailed": "灰度规则更新失败",
"ApolloNsPanel.ModifiedTips": "更新成功, 如需生效请发布",
"ApolloNsPanel.ModifyFailed": "更新失败",
"ApolloNsPanel.GrammarIsRight": "语法正确!",
"ReleaseModal.Published": "发布成功",
"ReleaseModal.PublishFailed": "发布失败",
"ReleaseModal.GrayscalePublished": "灰度发布成功",
"ReleaseModal.GrayscalePublishFailed": "灰度发布失败",
"ReleaseModal.AllPublished": "全量发布成功",
"ReleaseModal.AllPublishFailed": "全量发布失败",
"Rollback.NoRollbackList": "没有可以回滚的发布历史",
"Rollback.SameAsCurrentRelease": "该版本与当前版本相同",
"Rollback.RollbackSuccessfully": "回滚成功",
"Rollback.RollbackFailed": "回滚失败",
"Revoke.RevokeFailed": "撤销失败",
"Revoke.RevokeSuccessfully": "撤销成功"
}
| {
"Common.Title": "Apollo配置中心",
"Common.Ctrip": "携程",
"Common.CtripDepartment": "框架研发部",
"Common.Nav.ShowNavBar": "显示导航栏",
"Common.Nav.HideNavBar": "隐藏导航栏",
"Common.Nav.Help": "帮助",
"Common.Nav.AdminTools": "管理员工具",
"Common.Nav.NonAdminTools": "工具",
"Common.Nav.UserManage": "用户管理",
"Common.Nav.SystemRoleManage": "系统权限管理",
"Common.Nav.OpenMange": "开放平台授权管理",
"Common.Nav.SystemConfig": "系统参数",
"Common.Nav.DeleteApp-Cluster-Namespace": "删除应用、集群、AppNamespace",
"Common.Nav.SystemInfo": "系统信息",
"Common.Nav.ConfigExport": "配置导出",
"Common.Nav.Logout": "退出",
"Common.Department": "部门",
"Common.Cluster": "集群",
"Common.Environment": "环境",
"Common.Email": "邮箱",
"Common.AppId": "AppId",
"Common.Namespace": "Namespace",
"Common.AppName": "应用名称",
"Common.AppOwner": "负责人",
"Common.AppOwnerLong": "应用负责人",
"Common.AppAdmin": "项目管理员",
"Common.ClusterName": "集群名称",
"Common.Submit": "提交",
"Common.Save": "保存",
"Common.Created": "创建成功",
"Common.CreateFailed": "创建失败",
"Common.Deleted": "删除成功",
"Common.DeleteFailed": "删除失败",
"Common.ReturnToIndex": "返回到项目首页",
"Common.Cancel": "取消",
"Common.Ok": "确定",
"Common.Search": "查询",
"Common.IsRootUser": "当前页面只对Apollo管理员开放",
"Common.PleaseChooseDepartment": "请选择部门",
"Common.PleaseChooseOwner": "请选择应用负责人",
"Common.LoginExpiredTips": "您的登录信息已过期,请刷新页面后重试",
"Component.DeleteNamespace.Title": "删除Namespace",
"Component.DeleteNamespace.PublicContent": "删除Namespace将导致实例获取不到此Namespace的配置,确定要删除吗?",
"Component.DeleteNamespace.PrivateContent": "删除私有Namespace将导致实例获取不到此Namespace的配置,且页面会提示缺失Namespace(除非使用管理员工具删除AppNamespace),确定要删除吗?",
"Component.GrayscalePublishRule.Title": "编辑灰度规则",
"Component.GrayscalePublishRule.AppId": "灰度的AppId",
"Component.GrayscalePublishRule.AcceptRule": "灰度应用规则",
"Component.GrayscalePublishRule.AcceptPartInstance": "应用到部分实例",
"Component.GrayscalePublishRule.AcceptAllInstance": "应用到所有的实例",
"Component.GrayscalePublishRule.IP": "灰度的IP",
"Component.GrayscalePublishRule.AppIdFilterTips": "(实例列表会根据输入的AppId自动过滤)",
"Component.GrayscalePublishRule.IpTips": "没找到你想要的IP?可以",
"Component.GrayscalePublishRule.EnterIp": "手动输入IP",
"Component.GrayscalePublishRule.EnterIpTips": "输入IP列表,英文逗号隔开,输入完后点击添加按钮",
"Component.GrayscalePublishRule.Add": "添加",
"Component.ConfigItem.Title": "添加配置项",
"Component.ConfigItem.TitleTips": "(温馨提示: 可以通过文本模式批量添加配置)",
"Component.ConfigItem.AddGrayscaleItem": "添加灰度配置项",
"Component.ConfigItem.ModifyItem": "修改配置项",
"Component.ConfigItem.ItemKey": "Key",
"Component.ConfigItem.ItemValue": "Value",
"Component.ConfigItem.ItemValueTips": "注意: 隐藏字符(空格、换行符、制表符Tab)容易导致配置出错,如果需要检测Value中隐藏字符,请点击",
"Component.ConfigItem.ItemValueShowDetection": "检测隐藏字符",
"Component.ConfigItem.ItemValueNotHiddenChars": "无隐藏字符",
"Component.ConfigItem.ItemComment": "Comment",
"Component.ConfigItem.ChooseCluster": "选择集群",
"Component.MergePublish.Title": "全量发布",
"Component.MergePublish.Tips": "全量发布将会把灰度版本的配置合并到主分支,并发布。",
"Component.MergePublish.NextStep": "全量发布后,您希望",
"Component.MergePublish.DeleteGrayscale": "删除灰度版本",
"Component.MergePublish.ReservedGrayscale": "保留灰度版本",
"Component.Namespace.Branch.IsChanged": "有修改",
"Component.Namespace.Branch.ChangeUser": "当前修改者",
"Component.Namespace.Branch.ContinueGrayscalePublish": "继续灰度发布",
"Component.Namespace.Branch.GrayscalePublish": "灰度发布",
"Component.Namespace.Branch.MergeToMasterAndPublish": "合并到主版本并发布主版本配置",
"Component.Namespace.Branch.AllPublish": "全量发布",
"Component.Namespace.Branch.DiscardGrayscaleVersion": "废弃灰度版本",
"Component.Namespace.Branch.DiscardGrayscale": "放弃灰度",
"Component.Namespace.Branch.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看配置信息。",
"Component.Namespace.Branch.Tab.Configuration": "配置",
"Component.Namespace.Branch.Tab.GrayscaleRule": "灰度规则",
"Component.Namespace.Branch.Tab.GrayscaleInstance": "灰度实例列表",
"Component.Namespace.Branch.Tab.ChangeHistory": "更改历史",
"Component.Namespace.Branch.Body.Item": "灰度的配置",
"Component.Namespace.Branch.Body.AddedItem": "新增灰度配置",
"Component.Namespace.Branch.Body.PublishState": "发布状态",
"Component.Namespace.Branch.Body.ItemSort": "排序",
"Component.Namespace.Branch.Body.ItemKey": "Key",
"Component.Namespace.Branch.Body.ItemMasterValue": "主版本的值",
"Component.Namespace.Branch.Body.ItemGrayscaleValue": "灰度的值",
"Component.Namespace.Branch.Body.ItemComment": "备注",
"Component.Namespace.Branch.Body.ItemLastModify": "最后修改人",
"Component.Namespace.Branch.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.Branch.Body.ItemOperator": "操作",
"Component.Namespace.Branch.Body.ClickToSeeItemValue": "点击查看已发布的值",
"Component.Namespace.Branch.Body.ItemNoPublish": "未发布",
"Component.Namespace.Branch.Body.ItemPublished": "已发布",
"Component.Namespace.Branch.Body.ItemEffective": "已生效的配置",
"Component.Namespace.Branch.Body.ClickToSee": "点击查看",
"Component.Namespace.Branch.Body.DeletedItem": "删除的配置",
"Component.Namespace.Branch.Body.Delete": "删",
"Component.Namespace.Branch.Body.ChangedFromMaster": "修改主版本的配置",
"Component.Namespace.Branch.Body.ModifiedItem": "修改的配置",
"Component.Namespace.Branch.Body.Modify": "改",
"Component.Namespace.Branch.Body.AddedByGrayscale": "灰度版本特有的配置",
"Component.Namespace.Branch.Body.Added": "新",
"Component.Namespace.Branch.Body.Op.Modify": "修改",
"Component.Namespace.Branch.Body.Op.Delete": "删除",
"Component.Namespace.MasterBranch.Body.Title": "主版本的配置",
"Component.Namespace.MasterBranch.Body.PublishState": "发布状态",
"Component.Namespace.MasterBranch.Body.ItemKey": "Key",
"Component.Namespace.MasterBranch.Body.ItemValue": "Value",
"Component.Namespace.MasterBranch.Body.ItemComment": "备注",
"Component.Namespace.MasterBranch.Body.ItemLastModify": "最后修改人",
"Component.Namespace.MasterBranch.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.MasterBranch.Body.ItemOperator": "操作",
"Component.Namespace.MasterBranch.Body.ClickToSeeItemValue": "点击查看已发布的值",
"Component.Namespace.MasterBranch.Body.ItemNoPublish": "未发布",
"Component.Namespace.MasterBranch.Body.ItemEffective": "已生效的配置",
"Component.Namespace.MasterBranch.Body.ItemPublished": "已发布",
"Component.Namespace.MasterBranch.Body.AddedItem": "新增的配置",
"Component.Namespace.MasterBranch.Body.ModifyItem": "修改此灰度配置",
"Component.Namespace.Branch.GrayScaleRule.NoPermissionTips": "您没有权限编辑灰度规则, 具有namespace修改权或者发布权的人员才可以编辑灰度规则. 如需要编辑灰度规则,请找项目管理员申请权限.",
"Component.Namespace.Branch.GrayScaleRule.AppId": "灰度的AppId",
"Component.Namespace.Branch.GrayScaleRule.IpList": "灰度的IP列表",
"Component.Namespace.Branch.GrayScaleRule.Operator": "操作",
"Component.Namespace.Branch.GrayScaleRule.ApplyToAllInstances": "ALL",
"Component.Namespace.Branch.GrayScaleRule.Modify": "修改",
"Component.Namespace.Branch.GrayScaleRule.Delete": "删除",
"Component.Namespace.Branch.GrayScaleRule.AddNewRule": "新增规则",
"Component.Namespace.Branch.Instance.RefreshList": "刷新列表",
"Component.Namespace.Branch.Instance.ItemToSee": "查看配置",
"Component.Namespace.Branch.Instance.InstanceAppId": "App ID",
"Component.Namespace.Branch.Instance.InstanceClusterName": "Cluster Name",
"Component.Namespace.Branch.Instance.InstanceDataCenter": "Data Center",
"Component.Namespace.Branch.Instance.InstanceIp": "IP",
"Component.Namespace.Branch.Instance.InstanceGetItemTime": "配置获取时间",
"Component.Namespace.Branch.Instance.LoadMore": "刷新列表",
"Component.Namespace.Branch.Instance.NoInstance": "无实例信息",
"Component.Namespace.Branch.History.ItemType": "Type",
"Component.Namespace.Branch.History.ItemKey": "Key",
"Component.Namespace.Branch.History.ItemOldValue": "Old Value",
"Component.Namespace.Branch.History.ItemNewValue": "New Value",
"Component.Namespace.Branch.History.ItemComment": "Comment",
"Component.Namespace.Branch.History.NewAdded": "新增",
"Component.Namespace.Branch.History.Modified": "更新",
"Component.Namespace.Branch.History.Deleted": "删除",
"Component.Namespace.Branch.History.LoadMore": "加载更多",
"Component.Namespace.Branch.History.NoHistory": "无更改历史",
"Component.Namespace.Header.Title.Private": "私有",
"Component.Namespace.Header.Title.PrivateTips": "私有namespace({{namespace.baseInfo.namespaceName}})的配置只能被AppId为{{appId}}的客户端读取到",
"Component.Namespace.Header.Title.Public": "公共",
"Component.Namespace.Header.Title.PublicTips": "namespace({{namespace.baseInfo.namespaceName}})的配置能被任何客户端读取到",
"Component.Namespace.Header.Title.Extend": "关联",
"Component.Namespace.Header.Title.ExtendTips": "namespace({{namespace.baseInfo.namespaceName}})的配置将会覆盖公共namespace的配置, 且合并之后的配置只能被AppId为{{appId}}的客户端读取到",
"Component.Namespace.Header.Title.ExpandAndCollapse": "[展开/收缩]",
"Component.Namespace.Header.Title.Master": "主版本",
"Component.Namespace.Header.Title.Grayscale": "灰度版本",
"Component.Namespace.Master.LoadNamespace": "加载Namespace",
"Component.Namespace.Master.LoadNamespaceTips": "加载Namespace",
"Component.Namespace.Master.Items.Changed": "有修改",
"Component.Namespace.Master.Items.ChangedUser": "当前修改者",
"Component.Namespace.Master.Items.Publish": "发布",
"Component.Namespace.Master.Items.PublishTips": "发布配置",
"Component.Namespace.Master.Items.Rollback": "回滚",
"Component.Namespace.Master.Items.RollbackTips": "回滚已发布配置",
"Component.Namespace.Master.Items.PublishHistory": "发布历史",
"Component.Namespace.Master.Items.PublishHistoryTips": "查看发布历史",
"Component.Namespace.Master.Items.Grant": "授权",
"Component.Namespace.Master.Items.GrantTips": "配置修改、发布权限",
"Component.Namespace.Master.Items.Grayscale": "灰度",
"Component.Namespace.Master.Items.GrayscaleTips": "创建测试版本",
"Component.Namespace.Master.Items.RequestPermission": "申请配置权限",
"Component.Namespace.Master.Items.RequestPermissionTips": "您没有任何配置权限,请申请",
"Component.Namespace.Master.Items.DeleteNamespace": "删除Namespace",
"Component.Namespace.Master.Items.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看配置信息。",
"Component.Namespace.Master.Items.ItemList": "表格",
"Component.Namespace.Master.Items.ItemListByText": "文本",
"Component.Namespace.Master.Items.ItemHistory": "更改历史",
"Component.Namespace.Master.Items.ItemInstance": "实例列表",
"Component.Namespace.Master.Items.CopyText": "复制文本",
"Component.Namespace.Master.Items.GrammarCheck": "语法检查",
"Component.Namespace.Master.Items.CancelChanged": "取消修改",
"Component.Namespace.Master.Items.Change": "修改配置",
"Component.Namespace.Master.Items.SummitChanged": "提交修改",
"Component.Namespace.Master.Items.SortByKey": "按Key过滤配置",
"Component.Namespace.Master.Items.FilterItem": "过滤配置",
"Component.Namespace.Master.Items.SyncItemTips": "同步各环境间配置",
"Component.Namespace.Master.Items.SyncItem": "同步配置",
"Component.Namespace.Master.Items.RevokeItemTips": "撤销配置的修改",
"Component.Namespace.Master.Items.RevokeItem": "撤销配置",
"Component.Namespace.Master.Items.DiffItemTips": "比较各环境间配置",
"Component.Namespace.Master.Items.DiffItem": "比较配置",
"Component.Namespace.Master.Items.AddItem": "新增配置",
"Component.Namespace.Master.Items.Body.ItemsNoPublishedTips": "Tips: 此namespace从来没有发布过,Apollo客户端将获取不到配置并记录404日志信息,请及时发布。",
"Component.Namespace.Master.Items.Body.FilterByKey": "输入key过滤",
"Component.Namespace.Master.Items.Body.PublishState": "发布状态",
"Component.Namespace.Master.Items.Body.Sort": "排序",
"Component.Namespace.Master.Items.Body.ItemKey": "Key",
"Component.Namespace.Master.Items.Body.ItemValue": "Value",
"Component.Namespace.Master.Items.Body.ItemComment": "备注",
"Component.Namespace.Master.Items.Body.ItemLastModify": "最后修改人",
"Component.Namespace.Master.Items.Body.ItemLastModifyTime": "最后修改时间",
"Component.Namespace.Master.Items.Body.ItemOperator": "操作",
"Component.Namespace.Master.Items.Body.NoPublish": "未发布",
"Component.Namespace.Master.Items.Body.NoPublishTitle": "点击查看已发布的值",
"Component.Namespace.Master.Items.Body.NoPublishTips": "新增的配置,无发布的值",
"Component.Namespace.Master.Items.Body.Published": "已发布",
"Component.Namespace.Master.Items.Body.PublishedTitle": "已生效的配置",
"Component.Namespace.Master.Items.Body.ClickToSee": "点击查看",
"Component.Namespace.Master.Items.Body.Grayscale": "灰",
"Component.Namespace.Master.Items.Body.HaveGrayscale": "该配置有灰度配置,点击查看灰度的值",
"Component.Namespace.Master.Items.Body.NewAdded": "新",
"Component.Namespace.Master.Items.Body.NewAddedTips": "新增的配置",
"Component.Namespace.Master.Items.Body.Modified": "改",
"Component.Namespace.Master.Items.Body.ModifiedTips": "修改的配置",
"Component.Namespace.Master.Items.Body.Deleted": "删",
"Component.Namespace.Master.Items.Body.DeletedTips": "删除的配置",
"Component.Namespace.Master.Items.Body.ModifyTips": "修改",
"Component.Namespace.Master.Items.Body.DeleteTips": "删除",
"Component.Namespace.Master.Items.Body.Link.Title": "覆盖的配置",
"Component.Namespace.Master.Items.Body.Link.NoCoverLinkItem": "无覆盖的配置",
"Component.Namespace.Master.Items.Body.Public.Title": "公共的配置",
"Component.Namespace.Master.Items.Body.Public.Published": "已发布的配置",
"Component.Namespace.Master.Items.Body.Public.NoPublish": "未发布的配置",
"Component.Namespace.Master.Items.Body.Public.NoPublicNamespaceTips1": "当前公共namespace的所有者",
"Component.Namespace.Master.Items.Body.Public.NoPublicNamespaceTips2": "没有关联此namespace,请联系{{namespace.parentAppId}}的所有者在{{namespace.parentAppId}}项目里关联此namespace",
"Component.Namespace.Master.Items.Body.Public.NoPublished": "无发布的配置",
"Component.Namespace.Master.Items.Body.Public.PublishedAndCover": "覆盖此配置",
"Component.Namespace.Master.Items.Body.NoPublished.Title": "无公共的配置",
"Component.Namespace.Master.Items.Body.NoPublished.PublishedValue": "已发布的值",
"Component.Namespace.Master.Items.Body.NoPublished.NoPublishedValue": "未发布的值",
"Component.Namespace.Master.Items.Body.HistoryView.ItemType": "Type",
"Component.Namespace.Master.Items.Body.HistoryView.ItemKey": "Key",
"Component.Namespace.Master.Items.Body.HistoryView.ItemOldValue": "Old Value",
"Component.Namespace.Master.Items.Body.HistoryView.ItemNewValue": " New Value",
"Component.Namespace.Master.Items.Body.HistoryView.ItemComment": "Comment",
"Component.Namespace.Master.Items.Body.HistoryView.NewAdded": "新增",
"Component.Namespace.Master.Items.Body.HistoryView.Updated": "更新",
"Component.Namespace.Master.Items.Body.HistoryView.Deleted": "删除",
"Component.Namespace.Master.Items.Body.HistoryView.LoadMore": "加载更多",
"Component.Namespace.Master.Items.Body.HistoryView.NoHistory": "无更改历史",
"Component.Namespace.Master.Items.Body.Instance.Tips": "实例说明:只展示最近一天访问过Apollo的实例",
"Component.Namespace.Master.Items.Body.Instance.UsedNewItem": "使用最新配置的实例",
"Component.Namespace.Master.Items.Body.Instance.NoUsedNewItem": "使用非最新配置的实例",
"Component.Namespace.Master.Items.Body.Instance.AllInstance": "所有实例",
"Component.Namespace.Master.Items.Body.Instance.RefreshList": "刷新列表",
"Component.Namespace.Master.Items.Body.Instance.ToSeeItem": "查看配置",
"Component.Namespace.Master.Items.Body.Instance.LoadMore": "加载更多",
"Component.Namespace.Master.Items.Body.Instance.ItemAppId": "App ID",
"Component.Namespace.Master.Items.Body.Instance.ItemCluster": "Cluster Name",
"Component.Namespace.Master.Items.Body.Instance.ItemDataCenter": "Data Center",
"Component.Namespace.Master.Items.Body.Instance.ItemIp": "IP",
"Component.Namespace.Master.Items.Body.Instance.ItemGetTime": "配置获取时间",
"Component.Namespace.Master.Items.Body.Instance.NoInstanceTips": "无实例信息",
"Component.PublishDeny.Title": "发布受限",
"Component.PublishDeny.Tips1": "您不能发布哟~{{env}}环境配置的编辑和发布必须为不同的人,请找另一个具有当前namespace发布权的人操作发布~",
"Component.PublishDeny.Tips2": "(如果是非工作时间或者特殊情况,您可以通过点击'紧急发布'按钮进行发布)",
"Component.PublishDeny.EmergencyPublish": "紧急发布",
"Component.PublishDeny.Close": "关闭",
"Component.Publish.Title": "发布",
"Component.Publish.Tips": "(只有发布过的配置才会被客户端获取到,此次发布只会作用于当前环境:{{env}})",
"Component.Publish.Grayscale": "灰度发布",
"Component.Publish.GrayscaleTips": "(灰度发布的配置只会作用于在灰度规则中配置的实例)",
"Component.Publish.AllPublish": "全量发布",
"Component.Publish.AllPublishTips": "(全量发布的配置会作用于全部的实例)",
"Component.Publish.ToSeeChange": "查看变更",
"Component.Publish.PublishedValue": "发布的值",
"Component.Publish.Changes": "Changes",
"Component.Publish.Key": "Key",
"Component.Publish.NoPublishedValue": "未发布的值",
"Component.Publish.ModifyUser": "修改人",
"Component.Publish.ModifyTime": "修改时间",
"Component.Publish.NewAdded": "新",
"Component.Publish.NewAddedTips": "新增的配置",
"Component.Publish.Modified": "改",
"Component.Publish.ModifiedTips": "修改的配置",
"Component.Publish.Deleted": "删",
"Component.Publish.DeletedTips": "删除的配置",
"Component.Publish.MasterValue": "主版本值",
"Component.Publish.GrayValue": "灰度版本的值",
"Component.Publish.GrayPublishedValue": "灰度版本发布的值",
"Component.Publish.GrayNoPublishedValue": "灰度版本未发布的值",
"Component.Publish.ItemNoChange": "配置没有变化",
"Component.Publish.GrayItemNoChange": "灰度配置没有变化",
"Component.Publish.NoGrayItems": "没有灰度的配置项",
"Component.Publish.Release": "Release Name",
"Component.Publish.ReleaseComment": "Comment",
"Component.Publish.OpPublish": "发布",
"Component.Rollback.To": "回滚到",
"Component.Rollback.Tips": "此操作将会回滚到上一个发布版本,且当前版本作废,但不影响正在修改的配置。可在发布历史页面查看当前生效的版本",
"Component.RollbackTo.Tips":"此操作将会回滚到此发布版本,且当前版本作废,但不影响正在修改的配置",
"Component.Rollback.ClickToView": "点击查看",
"Component.Rollback.ItemType": "Type",
"Component.Rollback.ItemKey": "Key",
"Component.Rollback.RollbackBeforeValue": "回滚前",
"Component.Rollback.RollbackAfterValue": "回滚后",
"Component.Rollback.Added": "新增",
"Component.Rollback.Modified": "更新",
"Component.Rollback.Deleted": "删除",
"Component.Rollback.NoChange": "配置没有变化",
"Component.Rollback.OpRollback": "回滚",
"Component.ShowText.Title": "查看",
"Login.Login": "登录",
"Login.UserNameOrPasswordIncorrect": "用户名或密码错误",
"Login.LogoutSuccessfully": "登出成功",
"Index.MyProject": "我的项目",
"Index.CreateProject": "创建项目",
"Index.LoadMore": "加载更多",
"Index.FavoriteItems": "收藏的项目",
"Index.Topping": "置顶",
"Index.FavoriteTip": "您还没有收藏过任何项目,在项目主页可以收藏项目哟~",
"Index.RecentlyViewedItems": "最近浏览的项目",
"Index.GetCreateAppRoleFailed": "获取创建应用权限信息失败",
"Index.Topped": "置顶成功",
"Index.CancelledFavorite": "取消收藏成功",
"Cluster.CreateCluster": "新建集群",
"Cluster.Tips.1": "通过添加集群,可以使同一份程序在不同的集群(如不同的数据中心)使用不同的配置",
"Cluster.Tips.2": "如果不同集群使用一样的配置,则没有必要创建集群",
"Cluster.Tips.3": "Apollo默认会读取机器上/opt/settings/server.properties(linux)或C:\\opt\\settings\\server.properties(windows)文件中的idc属性作为集群名字, 如SHAJQ(金桥数据中心)、SHAOY(欧阳数据中心)",
"Cluster.Tips.4": "在这里创建的集群名字需要和机器上server.properties中的idc属性一致",
"Cluster.CreateNameTips": "(部署集群如:SHAJQ,SHAOY 或自定义集群如:SHAJQ-xx,SHAJQ-yy)",
"Cluster.ChooseEnvironment": "选择环境",
"Cluster.LoadingEnvironmentError": "加载环境信息出错",
"Cluster.ClusterCreated": "集群创建成功",
"Cluster.ClusterCreateFailed": "集群创建失败",
"Cluster.PleaseChooseEnvironment": "请选择环境",
"Config.Title": "Apollo配置中心",
"Config.AppIdNotFound": "不存在,",
"Config.ClickByCreate": "点击创建",
"Config.EnvList": "环境列表",
"Config.EnvListTips": "通过切换环境、集群来管理不同环境、集群的配置",
"Config.ProjectInfo": "项目信息",
"Config.ModifyBasicProjectInfo": "修改项目基本信息",
"Config.Favorite": "收藏",
"Config.CancelFavorite": "取消收藏",
"Config.MissEnv": "缺失的环境",
"Config.MissNamespace": "缺失的Namespace",
"Config.ProjectManage": "管理项目",
"Config.AccessKeyManage": "管理密钥",
"Config.CreateAppMissEnv": "补缺环境",
"Config.CreateAppMissNamespace": "补缺Namespace",
"Config.AddCluster": "添加集群",
"Config.AddNamespace": "添加Namespace",
"Config.CurrentlyOperatorEnv": "当前操作环境",
"Config.DoNotRemindAgain": "不再提示",
"Config.Note": "注意",
"Config.ClusterIsDefaultTipContent": "所有不属于 '{{name}}' 集群的实例会使用default集群(当前页面)的配置,属于 '{{name}}' 的实例会使用对应集群的配置!",
"Config.ClusterIsCustomTipContent": "属于 '{{name}}' 集群的实例只会使用 '{{name}}' 集群(当前页面)的配置,只有当对应namespace在当前集群没有发布过配置时,才会使用default集群的配置。",
"Config.HasNotPublishNamespace": "以下环境/集群有未发布的配置,客户端获取不到未发布的配置,请及时发布。",
"Config.RevokeItem.DialogTitle": "撤销配置",
"Config.RevokeItem.DialogContent": "当前命名空间下已修改但尚未发布的配置将被撤销,确定要撤销么?",
"Config.DeleteItem.DialogTitle": "删除配置",
"Config.DeleteItem.DialogContent": "您正在删除 Key 为 <b> '{{config.key}}' </b> Value 为 <b> '{{config.value}}' </b> 的配置.<br>确定要删除配置吗?",
"Config.PublishNoPermission.DialogTitle": "发布",
"Config.PublishNoPermission.DialogContent": "您没有发布权限哦~ 请找项目管理员 '{{masterUsers}}' 分配发布权限",
"Config.ModifyNoPermission.DialogTitle": "申请配置权限",
"Config.ModifyNoPermission.DialogContent": "请找项目管理员 '{{masterUsers}}' 分配编辑或发布权限",
"Config.MasterNoPermission.DialogTitle": "申请配置权限",
"Config.MasterNoPermission.DialogContent": "您不是项目管理员, 只有项目管理员才有添加集群、namespace的权限。如需管理员权限,请找项目管理员 '{{masterUsers}}' 分配管理员权限",
"Config.NamespaceLocked.DialogTitle": "编辑受限",
"Config.NamespaceLocked.DialogContent": "当前namespace正在被 '{{lockOwner}}' 编辑,一次发布只能被一个人修改.",
"Config.RollbackAlert.DialogTitle": "回滚",
"Config.RollbackAlert.DialogContent": "确定要回滚吗?",
"Config.EmergencyPublishAlert.DialogTitle": "紧急发布",
"Config.EmergencyPublishAlert.DialogContent": "确定要紧急发布吗?",
"Config.DeleteBranch.DialogTitle": "删除灰度",
"Config.DeleteBranch.DialogContent": "删除灰度会丢失灰度的配置,确定要删除吗?",
"Config.UpdateRuleTips.DialogTitle": "更新灰度规则提示",
"Config.UpdateRuleTips.DialogContent": "灰度规则已生效,但发现灰度版本有未发布的配置,这些配置需要手动灰度发布才会生效",
"Config.MergeAndReleaseDeny.DialogTitle": "全量发布",
"Config.MergeAndReleaseDeny.DialogContent": "namespace主版本有未发布的配置,请先发布主版本配置",
"Config.GrayReleaseWithoutRulesTips.DialogTitle": "缺失灰度规则提示",
"Config.GrayReleaseWithoutRulesTips.DialogContent": "灰度版本还没有配置任何灰度规则,请配置灰度规则",
"Config.DeleteNamespaceDenyForMasterInstance.DialogTitle": "删除Namespace警告信息",
"Config.DeleteNamespaceDenyForMasterInstance.DialogContent": "发现有 <b>'{{deleteNamespaceContext.namespace.instancesCount}}'</b> 个实例正在使用Namespace('{{deleteNamespaceContext.namespace.baseInfo.namespaceName}}'),删除Namespace将导致实例获取不到配置。<br>请到 <ins>“实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。",
"Config.DeleteNamespaceDenyForBranchInstance.DialogTitle": "删除Namespace警告信息",
"Config.DeleteNamespaceDenyForBranchInstance.DialogContent": "发现有 <b>'{{deleteNamespaceContext.namespace.branch.latestReleaseInstances.total}}'</b> 个实例正在使用Namespace('{{deleteNamespaceContext.namespace.baseInfo.namespaceName}}')灰度版本的配置,删除Namespace将导致实例获取不到配置。<br> 请到 <ins>“灰度版本” => “实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。",
"Config.DeleteNamespaceDenyForPublicNamespace.DialogTitle": "删除Namespace失败提示",
"Config.DeleteNamespaceDenyForPublicNamespace.DialogContent": "删除Namespace失败提示",
"Config.DeleteNamespaceDenyForPublicNamespace.PleaseEnterAppId": "请输入appId",
"Config.SyntaxCheckFailed.DialogTitle": "语法检查错误",
"Config.SyntaxCheckFailed.DialogContent": "删除Namespace失败提示",
"Config.CreateBranchTips.DialogTitle": "创建灰度须知",
"Config.CreateBranchTips.DialogContent": "通过创建灰度版本,您可以对某些配置做灰度测试<br>灰度流程为:<br> 1.创建灰度版本 <br> 2.配置灰度配置项<br> 3.配置灰度规则.如果是私有的namespace可以按照客户端的IP进行灰度,如果是公共的namespace则可以同时按AppId和客户端的IP进行灰度<br> 4.灰度发布<br>灰度版本最终有两种结果:<b>全量发布和放弃灰度</b><br><b>全量发布</b>:灰度的配置合到主版本并发布,所有的客户端都会使用合并后的配置<br><b>放弃灰度</b>:删除灰度版本,所有的客户端都会使用回主版本的配置<br>注意事项:<br> 1.如果灰度版本已经有灰度发布过,那么修改灰度规则后,无需再次灰度发布就立即生效",
"Config.ProjectMissEnvInfos": "当前项目有环境缺失,请点击页面左侧『补缺环境』补齐数据",
"Config.ProjectMissNamespaceInfos": "当前环境有Namespace缺失,请点击页面左侧『补缺Namespace』补齐数据",
"Config.SystemError": "系统出错,请重试或联系系统负责人",
"Config.FavoriteSuccessfully": "收藏成功",
"Config.FavoriteFailed": "收藏失败",
"Config.CancelledFavorite": "取消收藏成功",
"Config.CancelFavoriteFailed": "取消收藏失败",
"Config.GetUserInfoFailed": "获取用户登录信息失败",
"Config.LoadingAllNamespaceError": "加载配置信息出错",
"Config.CancelFavoriteError": "取消收藏失败",
"Config.Deleted": "删除成功",
"Config.DeleteFailed": "删除失败",
"Config.GrayscaleCreated": "创建灰度成功",
"Config.GrayscaleCreateFailed": "创建灰度失败",
"Config.BranchDeleted": "分支删除成功",
"Config.BranchDeleteFailed": "分支删除失败",
"Config.DeleteNamespaceFailedTips": "以下应用已关联此公共Namespace,必须先删除全部已关联的Namespace才能删除公共Namespace",
"Config.DeleteNamespaceNoPermissionFailedTitle": "删除失败",
"Config.DeleteNamespaceNoPermissionFailedTips": "您没有项目管理员权限,只有管理员才能删除Namespace,请找项目管理员 [{{users}}] 删除Namespace",
"Delete.Title": "删除应用、集群、AppNamespace",
"Delete.DeleteApp": "删除应用",
"Delete.DeleteAppTips": "(由于删除应用影响面较大,所以现在暂时只允许系统管理员删除,请确保没有客户端读取该应用的配置后再做删除动作)",
"Delete.AppIdTips": "(删除前请先查询应用信息)",
"Delete.AppInfo": "应用信息",
"Delete.DeleteCluster": "删除集群",
"Delete.DeleteClusterTips": "(由于删除集群影响面较大,所以现在暂时只允许系统管理员删除,请确保没有客户端读取该集群的配置后再做删除动作)",
"Delete.EnvName": "环境名称",
"Delete.ClusterNameTips": "(删除前请先查询应用集群信息)",
"Delete.ClusterInfo": "集群信息",
"Delete.DeleteNamespace": "删除AppNamespace",
"Delete.DeleteNamespaceTips": "(注意,所有环境的Namespace和AppNamespace都会被删除!如果只是要删除某个环境的Namespace,让用户到项目页面中自行删除!)",
"Delete.DeleteNamespaceTips2": "目前用户可以自行删除关联的Namespace和私有的Namespace,不过无法删除AppNamespace元信息,因为删除AppNamespace影响面较大,所以现在暂时只允许系统管理员删除,对于公共Namespace需要确保没有应用关联了该AppNamespace。",
"Delete.AppNamespaceName": "AppNamespace名称",
"Delete.AppNamespaceNameTips": "(非properties类型的namespace请加上类型后缀,例如apollo.xml)",
"Delete.AppNamespaceInfo": "AppNamespace信息",
"Delete.IsRootUserTips": "当前页面只对Apollo管理员开放",
"Delete.PleaseEnterAppId": "请输入appId",
"Delete.AppIdNotFound": "AppId: '{{appId}}'不存在!",
"Delete.AppInfoContent": "应用名:'{{appName}}' 部门:'{{departmentName}}({{departmentId}})' 负责人:'{{ownerName}}'",
"Delete.ConfirmDeleteAppId": "确认删除AppId:'{{appId}}'?",
"Delete.Deleted": "删除成功",
"Delete.PleaseEnterAppIdAndEnvAndCluster": "请输入appId、环境和集群名称",
"Delete.ClusterInfoContent": "AppId:'{{appId}}' 环境:'{{env}}' 集群名称:'{{clusterName}}'",
"Delete.ConfirmDeleteCluster": "确认删除集群?AppId:'{{appId}}' 环境:'{{env}}' 集群名称:'{{clusterName}}'",
"Delete.PleaseEnterAppIdAndNamespace": "请输入appId和AppNamespace名称",
"Delete.AppNamespaceInfoContent": "AppId:'{{appId}}' AppNamespace名称:'{{namespace}}' isPublic:'{{isPublic}}'",
"Delete.ConfirmDeleteNamespace": "确认删除所有环境的AppNamespace和Namespace?appId: '{{appId}}' 环境:'所有环境' AppNamespace名称:'{{namespace}}'",
"Namespace.Title": "新建Namespace",
"Namespace.UnderstandMore": "(点击了解更多Namespace相关知识)",
"Namespace.Link.Tips1": "应用可以通过关联公共namespace来覆盖公共Namespace的配置",
"Namespace.Link.Tips2": "如果应用不需要覆盖公共Namespace的配置,那么无需关联公共Namespace",
"Namespace.CreatePublic.Tips1": "公共的Namespace的配置能被任何项目读取",
"Namespace.CreatePublic.Tips2": "通过创建公共Namespace可以实现公共组件的配置,或多个应用共享同一份配置的需求",
"Namespace.CreatePublic.Tips3": "如果其它应用需要覆盖公共部分的配置,可以在其它应用那里关联公共Namespace,然后在关联的Namespace里面配置需要覆盖的配置即可",
"Namespace.CreatePublic.Tips4": "如果其它应用不需要覆盖公共部分的配置,那么就不需要在其它应用那里关联公共Namespace",
"Namespace.CreatePrivate.Tips1": "私有Namespace的配置只能被所属的应用获取到",
"Namespace.CreatePrivate.Tips2": "通过创建一个私有的Namespace可以实现分组管理配置",
"Namespace.CreatePrivate.Tips3": "私有Namespace的格式可以是xml、yml、yaml、json、txt. 您可以通过apollo-client中ConfigFile接口来获取非properties格式Namespace的内容",
"Namespace.CreatePrivate.Tips4": "1.3.0及以上版本的apollo-client针对yaml/yml提供了更好的支持,可以通过ConfigService.getConfig(\"someNamespace.yml\")直接获取Config对象,也可以通过@EnableApolloConfig(\"someNamespace.yml\")或apollo.bootstrap.namespaces=someNamespace.yml注入yml配置到Spring/SpringBoot中去",
"Namespace.CreateNamespace": "创建Namespace",
"Namespace.AssociationPublicNamespace": "关联公共Namespace",
"Namespace.ChooseCluster": "选择集群",
"Namespace.NamespaceName": "名称",
"Namespace.AutoAddDepartmentPrefix": "自动添加部门前缀",
"Namespace.AutoAddDepartmentPrefixTips": "(公共Namespace的名称需要全局唯一,添加部门前缀有助于保证全局唯一性)",
"Namespace.NamespaceType": "类型",
"Namespace.NamespaceType.Public": "public",
"Namespace.NamespaceType.Private": "private",
"Namespace.Remark": "备注",
"Namespace.Namespace": "namespace",
"Namespace.PleaseChooseNamespace": "请选择Namespace",
"Namespace.LoadingPublicNamespaceError": "加载公共namespace错误",
"Namespace.LoadingAppInfoError": "加载App信息出错",
"Namespace.PleaseChooseCluster": "请选择集群",
"Namespace.CheckNamespaceNameLengthTip": "namespace名称不能大于32个字符. 部门前缀:'{{departmentLength}}'个字符, 名称{{namespaceLength}}个字符",
"ServiceConfig.Title": "应用配置",
"ServiceConfig.Tips": "(维护ApolloPortalDB.ServerConfig表数据,如果已存在配置项则会覆盖,否则会创建配置项。配置更新后,一分钟后自动生效)",
"ServiceConfig.Key": "key",
"ServiceConfig.KeyTips": "(修改配置前请先查询该配置信息)",
"ServiceConfig.Value": "value",
"ServiceConfig.Comment": "comment",
"ServiceConfig.Saved": "保存成功",
"ServiceConfig.SaveFailed": "保存失败",
"ServiceConfig.PleaseEnterKey": "请输入key",
"ServiceConfig.KeyNotExistsAndCreateTip": "Key: '{{key}}' 不存在,点击保存后会创建该配置项",
"ServiceConfig.KeyExistsAndSaveTip": "Key: '{{key}}' 已存在,点击保存后会覆盖该配置项",
"AccessKey.Tips.1": "每个环境最多可添加5个访问密钥",
"AccessKey.Tips.2": "一旦该环境有启用的访问密钥,客户端将被要求配置密钥,否则无法获取配置",
"AccessKey.Tips.3": "配置访问密钥防止非法客户端获取该应用配置,配置方式如下(需要apollo-client 1.6.0+版本):",
"AccessKey.Tips.3.1": "通过jvm参数-Dapollo.accesskey.secret",
"AccessKey.Tips.3.2": "通过操作系统环境变量APOLLO_ACCESSKEY_SECRET",
"AccessKey.Tips.3.3": "通过META-INF/app.properties或application.properties配置apollo.accesskey.secret(注意多环境secret不一样)",
"AccessKey.NoAccessKeyServiceTips": "该环境没有配置访问密钥",
"AccessKey.ConfigAccessKeys.Secret": "访问密钥",
"AccessKey.ConfigAccessKeys.Status": "状态",
"AccessKey.ConfigAccessKeys.LastModify": "最后修改人",
"AccessKey.ConfigAccessKeys.LastModifyTime": "最后修改时间",
"AccessKey.ConfigAccessKeys.Operator": "操作",
"AccessKey.Operator.Disable": "禁用",
"AccessKey.Operator.Enable": "启用",
"AccessKey.Operator.Disabled": "已禁用",
"AccessKey.Operator.Enabled": "已启用",
"AccessKey.Operator.Remove": "删除",
"AccessKey.Operator.CreateSuccess": "访问密钥创建成功",
"AccessKey.Operator.DisabledSuccess": "访问密钥禁用成功",
"AccessKey.Operator.EnabledSuccess": "访问密钥启用成功",
"AccessKey.Operator.RemoveSuccess": "访问密钥删除成功",
"AccessKey.Operator.CreateError": "访问密钥创建失败",
"AccessKey.Operator.DisabledError": "访问密钥禁用失败",
"AccessKey.Operator.EnabledError": "访问密钥启用失败",
"AccessKey.Operator.RemoveError": "访问密钥删除失败",
"AccessKey.Operator.DisabledTips": "是否确定禁用该访问密钥?",
"AccessKey.Operator.EnabledTips": " 是否确定启用该访问密钥?",
"AccessKey.Operator.RemoveTips": " 是否确定删除该访问密钥?",
"AccessKey.LoadError": "加载访问密钥出错",
"SystemInfo.Title": "系统信息",
"SystemInfo.SystemVersion": "系统版本",
"SystemInfo.Tips1": "环境列表来自于ApolloPortalDB.ServerConfig中的<strong>apollo.portal.envs</strong>配置,可以到<a href=\"{{serverConfigUrl}}\">系统参数</a>页面配置,更多信息可以参考<a href=\"{{wikiUrl}}\">分布式部署指南</a>中的<strong>apollo.portal.envs - 可支持的环境列表</strong>章节。",
"SystemInfo.Tips2": "Meta server地址展示了该环境配置的meta server信息,更多信息可以参考<a href=\"{{wikiUrl}}\">分布式部署指南</a>中的<strong>配置apollo-portal的meta service信息</strong>章节。",
"SystemInfo.Active": "Active",
"SystemInfo.ActiveTips": "(当前环境状态异常,请结合下方系统信息和AdminService的Check Health结果排查)",
"SystemInfo.MetaServerAddress": "Meta server地址",
"SystemInfo.ConfigServices": "Config Services",
"SystemInfo.ConfigServices.Name": "Name",
"SystemInfo.ConfigServices.InstanceId": "Instance Id",
"SystemInfo.ConfigServices.HomePageUrl": "Home Page Url",
"SystemInfo.ConfigServices.CheckHealth": "Check Health",
"SystemInfo.NoConfigServiceTips": "No config service found!",
"SystemInfo.Check": "check",
"SystemInfo.AdminServices": "Admin Services",
"SystemInfo.AdminServices.Name": "Name",
"SystemInfo.AdminServices.InstanceId": "Instance Id",
"SystemInfo.AdminServices.HomePageUrl": "Home Page Url",
"SystemInfo.AdminServices.CheckHealth": "Check Health",
"SystemInfo.NoAdminServiceTips": "No admin service found!",
"SystemInfo.IsRootUser": "当前页面只对Apollo管理员开放",
"SystemRole.Title": "系统权限管理",
"SystemRole.AddCreateAppRoleToUser": "为用户添加创建应用权限",
"SystemRole.AddCreateAppRoleToUserTips": "(系统参数中设置 role.create-application.enabled=true 会限制只有超级管理员和拥有创建应用权限的帐号可以创建项目)",
"SystemRole.ChooseUser": "用户选择",
"SystemRole.Add": "添加",
"SystemRole.AuthorizedUser": "已拥有权限用户",
"SystemRole.ModifyAppAdminUser": "修改应用管理员分配权限",
"SystemRole.ModifyAppAdminUserTips": "(系统参数中设置 role.manage-app-master.enabled=true 会限制只有超级管理员和拥有管理员分配权限的帐号可以修改项目管理员)",
"SystemRole.AppIdTips": "(请先查询应用信息)",
"SystemRole.AppInfo": "应用信息",
"SystemRole.AllowAppMasterAssignRole": "允许此用户作为管理员时添加Master",
"SystemRole.DeleteAppMasterAssignRole": "禁止此用户作为管理员时添加Master",
"SystemRole.IsRootUser": "当前页面只对Apollo管理员开放",
"SystemRole.PleaseChooseUser": "请选择用户名",
"SystemRole.Added": "添加成功",
"SystemRole.AddFailed": "添加失败",
"SystemRole.Deleted": "删除成功",
"SystemRole.DeleteFailed": "删除失败",
"SystemRole.GetCanCreateProjectUsersError": "获取拥有创建项目权限的用户列表出错",
"SystemRole.PleaseEnterAppId": "请输入appId",
"SystemRole.AppIdNotFound": "AppId: '{{appId}}' 不存在!",
"SystemRole.AppInfoContent": "应用名:'{{appName}}' 部门:'{{departmentName}}({{departmentId}})' 负责人:'{{ownerName}}",
"SystemRole.DeleteMasterAssignRoleTips": "确认删除AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限?",
"SystemRole.DeletedMasterAssignRoleTips": "删除AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限成功",
"SystemRole.AllowAppMasterAssignRoleTips": "确认添加AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限?",
"SystemRole.AllowedAppMasterAssignRoleTips": "添加AppId: '{{appId}}' 的用户: '{{userId}}' 分配应用管理员的权限成功",
"UserMange.Title": "用户管理",
"UserMange.TitleTips": "(仅对默认的Spring Security简单认证方式有效: -Dapollo_profile=github,auth)",
"UserMange.UserName": "用户名",
"UserMange.UserNameTips": "输入的用户名如果不存在,则新建。若已存在,则更新。",
"UserMange.Pwd": "密码",
"UserMange.Email": "邮箱",
"UserMange.Created": "创建用户成功",
"UserMange.CreateFailed": "创建用户失败",
"Open.Manage.Title": "开放平台",
"Open.Manage.CreateThirdApp": "创建第三方应用",
"Open.Manage.CreateThirdAppTips": "(说明: 第三方应用可以通过Apollo开放平台来对配置进行管理)",
"Open.Manage.ThirdAppId": "第三方应用ID",
"Open.Manage.ThirdAppIdTips": "(创建前请先查询第三方应用是否已经申请过)",
"Open.Manage.ThirdAppName": "第三方应用名称",
"Open.Manage.ThirdAppNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"Open.Manage.ProjectOwner": "项目负责人",
"Open.Manage.Create": "创建",
"Open.Manage.GrantPermission": "赋权",
"Open.Manage.GrantPermissionTips": "(Namespace级别权限包括: 修改、发布Namespace。应用级别权限包括: 创建Namespace、修改或发布应用下任何Namespace)",
"Open.Manage.Token": "Token",
"Open.Manage.ManagedAppId": "被管理的AppId",
"Open.Manage.ManagedNamespace": "被管理的Namespace",
"Open.Manage.ManagedNamespaceTips": "(非properties类型的namespace请加上类型后缀,例如apollo.xml)",
"Open.Manage.GrantType": "授权类型",
"Open.Manage.GrantType.Namespace": "Namespace",
"Open.Manage.GrantType.App": "App",
"Open.Manage.GrantEnv": "环境",
"Open.Manage.GrantEnvTips": "(不选择则所有环境都有权限,如果提示Namespace's role does not exist,请先打开该Namespace的授权页面触发一下权限的初始化动作)",
"Open.Manage.PleaseEnterAppId": "请输入appId",
"Open.Manage.AppNotCreated": "App('{{appId}}')未创建,请先创建",
"Open.Manage.GrantSuccessfully": "赋权成功",
"Open.Manage.GrantFailed": "赋权失败",
"Namespace.Role.Title": "权限管理",
"Namespace.Role.GrantModifyTo": "修改权",
"Namespace.Role.GrantModifyTo2": "(可以修改配置)",
"Namespace.Role.AllEnv": "所有环境",
"Namespace.Role.GrantPublishTo": "发布权",
"Namespace.Role.GrantPublishTo2": "(可以发布配置)",
"Namespace.Role.Add": "添加",
"Namespace.Role.NoPermission": "您没有权限哟!",
"Namespace.Role.InitNamespacePermissionError": "初始化授权出错",
"Namespace.Role.GetEnvGrantUserError": "加载 '{{env}}' 授权用户出错",
"Namespace.Role.GetGrantUserError": "加载授权用户出错",
"Namespace.Role.PleaseChooseUser": "请选择用户",
"Namespace.Role.Added": "添加成功",
"Namespace.Role.AddFailed": "添加失败",
"Namespace.Role.Deleted": "删除成功",
"Namespace.Role.DeleteFailed": "删除失败",
"Config.Sync.Title": "同步配置",
"Config.Sync.FistStep": "(第一步:选择同步信息)",
"Config.Sync.SecondStep": "(第二步:检查Diff)",
"Config.Sync.PreviousStep": "上一步",
"Config.Sync.NextStep": "下一步",
"Config.Sync.Sync": "同步",
"Config.Sync.Tips": "Tips",
"Config.Sync.Tips1": "通过同步配置功能,可以使多个环境、集群间的配置保持一致",
"Config.Sync.Tips2": "需要注意的是,同步完之后需要发布后才会对应用生效",
"Config.Sync.SyncNamespace": "同步的Namespace",
"Config.Sync.SyncToCluster": "同步到哪个集群",
"Config.Sync.NeedToSyncItem": "需要同步的配置",
"Config.Sync.SortByLastModifyTime": "按最后更新时间过滤",
"Config.Sync.BeginTime": "开始时间",
"Config.Sync.EndTime": "结束时间",
"Config.Sync.Filter": "过滤",
"Config.Sync.Rest": "重置",
"Config.Sync.ItemKey": "Key",
"Config.Sync.ItemValue": "Value",
"Config.Sync.ItemCreateTime": "Create Time",
"Config.Sync.ItemUpdateTime": "Update Time",
"Config.Sync.NoNeedSyncItem": "没有更新的配置",
"Config.Sync.IgnoreSync": "忽略同步",
"Config.Sync.Step2Type": "Type",
"Config.Sync.Step2Key": "Key",
"Config.Sync.Step2SyncBefore": "同步前",
"Config.Sync.Step2SyncAfter": "同步后",
"Config.Sync.Step2Comment": "Comment",
"Config.Sync.Step2Operator": "操作",
"Config.Sync.NewAdd": "新增",
"Config.Sync.NoSyncItem": "不同步该配置",
"Config.Sync.Delete": "删除",
"Config.Sync.Update": "更新",
"Config.Sync.SyncSuccessfully": "同步成功!",
"Config.Sync.SyncFailed": "同步失败!",
"Config.Sync.LoadingItemsError": "加载配置出错",
"Config.Sync.PleaseChooseNeedSyncItems": "请选择需要同步的配置",
"Config.Sync.PleaseChooseCluster": "请选择集群",
"Config.History.Title": "发布历史",
"Config.History.MasterVersionPublish": "主版本发布",
"Config.History.MasterVersionRollback": "主版本回滚",
"Config.History.GrayscaleOperator": "灰度操作",
"Config.History.PublishHistory": "发布历史",
"Config.History.OperationType0": "普通发布",
"Config.History.OperationType1": "回滚",
"Config.History.OperationType2": "灰度发布",
"Config.History.OperationType3": "更新灰度规则",
"Config.History.OperationType4": "灰度全量发布",
"Config.History.OperationType5": "灰度发布(主版本发布)",
"Config.History.OperationType6": "灰度发布(主版本回滚)",
"Config.History.OperationType7": "放弃灰度",
"Config.History.OperationType8": "删除灰度(全量发布)",
"Config.History.UrgentPublish": "紧急发布",
"Config.History.LoadMore": "加载更多",
"Config.History.Abandoned": "已废弃",
"Config.History.RollbackTo": "回滚到此版本",
"Config.History.RollbackToTips": "回滚已发布的配置到此版本",
"Config.History.ChangedItem": "变更的配置",
"Config.History.ChangedItemTips": "查看此次发布与上次版本的变更",
"Config.History.AllItem": "全部配置",
"Config.History.AllItemTips": "查看此次发布的所有配置信息",
"Config.History.ChangeType": "Type",
"Config.History.ChangeKey": "Key",
"Config.History.ChangeValue": "Value",
"Config.History.ChangeOldValue": "Old Value",
"Config.History.ChangeNewValue": "New Value",
"Config.History.ChangeTypeNew": "新增",
"Config.History.ChangeTypeModify": "修改",
"Config.History.ChangeTypeDelete": "删除",
"Config.History.NoChange": "无配置更改",
"Config.History.NoItem": "无配置",
"Config.History.GrayscaleRule": "灰度规则",
"Config.History.GrayscaleAppId": "灰度的AppId",
"Config.History.GrayscaleIp": "灰度的IP",
"Config.History.NoGrayscaleRule": "无灰度规则",
"Config.History.NoPermissionTips": "您不是该项目的管理员,也没有该Namespace的编辑或发布权限,无法查看发布历史",
"Config.History.NoPublishHistory": "无发布历史信息",
"Config.History.LoadingHistoryError": "无发布历史信息",
"Config.Diff.Title": "比较配置",
"Config.Diff.FirstStep": "(第一步:选择比较信息)",
"Config.Diff.SecondStep": "(第二步:查看差异配置)",
"Config.Diff.PreviousStep": "上一步",
"Config.Diff.NextStep": "下一步",
"Config.Diff.TipsTitle": "Tips",
"Config.Diff.Tips": "通过比较配置功能,可以查看多个环境、集群间的配置差异",
"Config.Diff.DiffCluster": "要比较的集群",
"Config.Diff.HasDiffComment": "是否比较注释",
"Config.Diff.PleaseChooseTwoCluster": "请至少选择两个集群",
"ConfigExport.Title": "配置导出",
"ConfigExport.TitleTips" : "超级管理员会下载所有项目的配置,普通用户只会下载自己项目的配置",
"ConfigExport.Download": "下载",
"App.CreateProject": "创建项目",
"App.AppIdTips": "(应用唯一标识)",
"App.AppNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"App.AppOwnerTips": "(开启项目管理员分配权限控制后,应用负责人和项目管理员默认为本账号,不可选择)",
"App.AppAdminTips1": "(应用负责人默认具有项目管理员权限,",
"App.AppAdminTips2": "项目管理员可以创建Namespace和集群、分配用户权限)",
"App.AccessKey.NoPermissionTips": "您没有权限操作,请找 [{{users}}] 开通权限",
"App.Setting.Title": "项目管理",
"App.Setting.Admin": "管理员",
"App.Setting.AdminTips": "(项目管理员具有以下权限: 1. 创建Namespace 2. 创建集群 3. 管理项目、Namespace权限)",
"App.Setting.Add": "添加",
"App.Setting.BasicInfo": "基本信息",
"App.Setting.ProjectName": "项目名称",
"App.Setting.ProjectNameTips": "(建议格式 xx-yy-zz 例:apollo-server)",
"App.Setting.ProjectOwner": "项目负责人",
"App.Setting.Modify": "修改项目信息",
"App.Setting.Cancel": "取消修改",
"App.Setting.NoPermissionTips": "您没有权限操作,请找 [{{users}}] 开通权限",
"App.Setting.DeleteAdmin": "删除管理员",
"App.Setting.CanNotDeleteAllAdmin": "不能删除所有的管理员",
"App.Setting.PleaseChooseUser": "请选择用户",
"App.Setting.Added": "添加成功",
"App.Setting.AddFailed": "添加失败",
"App.Setting.Deleted": "删除成功",
"App.Setting.DeleteFailed": "删除失败",
"App.Setting.Modified": "修改成功",
"Valdr.App.AppId.Size": "AppId长度不能多于64个字符",
"Valdr.App.AppId.Required": "AppId不能为空",
"Valdr.App.appName.Size": "应用名称长度不能多于128个字符",
"Valdr.App.appName.Required": "应用名称不能为空",
"Valdr.Cluster.ClusterName.Size": "集群名称长度不能多于32个字符",
"Valdr.Cluster.ClusterName.Required": "集群名称不能为空",
"Valdr.AppNamespace.NamespaceName.Size": "Namespace名称长度不能多于32个字符",
"Valdr.AppNamespace.NamespaceName.Required": "Namespace名称不能为空",
"Valdr.AppNamespace.Comment.Size": "备注长度不能多于64个字符",
"Valdr.Item.Key.Size": "Key长度不能多于128个字符",
"Valdr.Item.Key.Required": "Key不能为空",
"Valdr.Item.Comment.Size": "备注长度不能多于64个字符",
"Valdr.Release.ReleaseName.Size": "Release Name长度不能多于64个字符",
"Valdr.Release.ReleaseName.Required": "Release Name不能为空",
"Valdr.Release.Comment.Size": "备注长度不能多于64个字符",
"ApolloConfirmDialog.DefaultConfirmBtnName": "确认",
"ApolloConfirmDialog.SearchPlaceHolder": "搜索项目(AppId、项目名)",
"RulesModal.ChooseInstances": "从实例列表中选择",
"RulesModal.InvalidIp": "不合法的IP地址: '{{ip}}'",
"RulesModal.GrayscaleAppIdCanNotBeNull": "灰度的AppId不能为空",
"RulesModal.AppIdExistsRule": "已经存在AppId='{{appId}}'的规则",
"RulesModal.IpListCanNotBeNull": "IP列表不能为空",
"ItemModal.KeyExists": "key='{{key}}' 已存在",
"ItemModal.AddedTips": "添加成功,如需生效请发布",
"ItemModal.AddFailed": "添加失败",
"ItemModal.PleaseChooseCluster": "请选择集群",
"ItemModal.ModifiedTips": "更新成功, 如需生效请发布",
"ItemModal.ModifyFailed": "更新失败",
"ItemModal.Tabs": "制表符",
"ItemModal.NewLine": "换行符",
"ItemModal.Space": "空格",
"ApolloNsPanel.LoadingHistoryError": "加载修改历史记录出错",
"ApolloNsPanel.LoadingGrayscaleError": "加载修改历史记录出错",
"ApolloNsPanel.Deleted": "删除成功",
"ApolloNsPanel.GrayscaleModified": "灰度规则更新成功",
"ApolloNsPanel.GrayscaleModifyFailed": "灰度规则更新失败",
"ApolloNsPanel.ModifiedTips": "更新成功, 如需生效请发布",
"ApolloNsPanel.ModifyFailed": "更新失败",
"ApolloNsPanel.GrammarIsRight": "语法正确!",
"ReleaseModal.Published": "发布成功",
"ReleaseModal.PublishFailed": "发布失败",
"ReleaseModal.GrayscalePublished": "灰度发布成功",
"ReleaseModal.GrayscalePublishFailed": "灰度发布失败",
"ReleaseModal.AllPublished": "全量发布成功",
"ReleaseModal.AllPublishFailed": "全量发布失败",
"Rollback.NoRollbackList": "没有可以回滚的发布历史",
"Rollback.SameAsCurrentRelease": "该版本与当前版本相同",
"Rollback.RollbackSuccessfully": "回滚成功",
"Rollback.RollbackFailed": "回滚失败",
"Revoke.RevokeFailed": "撤销失败",
"Revoke.RevokeSuccessfully": "撤销成功"
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java | package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
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.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.enums.PropertyChangeType;
import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.SettableFuture;
import org.mockito.stubbing.Answer;
/**
* @author Jason Song([email protected])
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleConfigTest {
private String someNamespace;
@Mock
private ConfigRepository configRepository;
@Mock
private PropertiesFactory propertiesFactory;
private ConfigSourceType someSourceType;
@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();
}
@Test
public void testGetProperty() throws Exception {
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
someProperties.setProperty(someKey, someValue);
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
SimpleConfig config = new SimpleConfig(someNamespace, configRepository);
assertEquals(someValue, config.getProperty(someKey, null));
assertEquals(someSourceType, config.getSourceType());
}
@Test
public void testLoadConfigFromConfigRepositoryError() throws Exception {
String someKey = "someKey";
String anyValue = "anyValue" + Math.random();
when(configRepository.getConfig()).thenThrow(mock(RuntimeException.class));
Config config = new SimpleConfig(someNamespace, configRepository);
assertEquals(anyValue, config.getProperty(someKey, anyValue));
assertEquals(ConfigSourceType.NONE, config.getSourceType());
}
@Test
public void testOnRepositoryChange() throws Exception {
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
String anotherKey = "anotherKey";
String anotherValue = "anotherValue";
someProperties.putAll(ImmutableMap.of(someKey, someValue, anotherKey, anotherValue));
Properties anotherProperties = new Properties();
String newKey = "newKey";
String newValue = "newValue";
String someValueNew = "someValueNew";
anotherProperties.putAll(ImmutableMap.of(someKey, someValueNew, newKey, newValue));
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
final SettableFuture<ConfigChangeEvent> configChangeFuture = SettableFuture.create();
ConfigChangeListener someListener = new ConfigChangeListener() {
@Override
public void onChange(ConfigChangeEvent changeEvent) {
configChangeFuture.set(changeEvent);
}
};
SimpleConfig config = new SimpleConfig(someNamespace, configRepository);
assertEquals(someSourceType, config.getSourceType());
config.addChangeListener(someListener);
ConfigSourceType anotherSourceType = ConfigSourceType.REMOTE;
when(configRepository.getSourceType()).thenReturn(anotherSourceType);
config.onRepositoryChange(someNamespace, anotherProperties);
ConfigChangeEvent changeEvent = configChangeFuture.get(500, TimeUnit.MILLISECONDS);
assertEquals(someNamespace, changeEvent.getNamespace());
assertEquals(3, changeEvent.changedKeys().size());
ConfigChange someKeyChange = changeEvent.getChange(someKey);
assertEquals(someValue, someKeyChange.getOldValue());
assertEquals(someValueNew, someKeyChange.getNewValue());
assertEquals(PropertyChangeType.MODIFIED, someKeyChange.getChangeType());
ConfigChange anotherKeyChange = changeEvent.getChange(anotherKey);
assertEquals(anotherValue, anotherKeyChange.getOldValue());
assertEquals(null, anotherKeyChange.getNewValue());
assertEquals(PropertyChangeType.DELETED, anotherKeyChange.getChangeType());
ConfigChange newKeyChange = changeEvent.getChange(newKey);
assertEquals(null, newKeyChange.getOldValue());
assertEquals(newValue, newKeyChange.getNewValue());
assertEquals(PropertyChangeType.ADDED, newKeyChange.getChangeType());
assertEquals(anotherSourceType, config.getSourceType());
}
}
| package com.ctrip.framework.apollo.internals;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.enums.ConfigSourceType;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
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.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.enums.PropertyChangeType;
import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.SettableFuture;
import org.mockito.stubbing.Answer;
/**
* @author Jason Song([email protected])
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleConfigTest {
private String someNamespace;
@Mock
private ConfigRepository configRepository;
@Mock
private PropertiesFactory propertiesFactory;
private ConfigSourceType someSourceType;
@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();
}
@Test
public void testGetProperty() throws Exception {
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
someProperties.setProperty(someKey, someValue);
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
SimpleConfig config = new SimpleConfig(someNamespace, configRepository);
assertEquals(someValue, config.getProperty(someKey, null));
assertEquals(someSourceType, config.getSourceType());
}
@Test
public void testLoadConfigFromConfigRepositoryError() throws Exception {
String someKey = "someKey";
String anyValue = "anyValue" + Math.random();
when(configRepository.getConfig()).thenThrow(mock(RuntimeException.class));
Config config = new SimpleConfig(someNamespace, configRepository);
assertEquals(anyValue, config.getProperty(someKey, anyValue));
assertEquals(ConfigSourceType.NONE, config.getSourceType());
}
@Test
public void testOnRepositoryChange() throws Exception {
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
String anotherKey = "anotherKey";
String anotherValue = "anotherValue";
someProperties.putAll(ImmutableMap.of(someKey, someValue, anotherKey, anotherValue));
Properties anotherProperties = new Properties();
String newKey = "newKey";
String newValue = "newValue";
String someValueNew = "someValueNew";
anotherProperties.putAll(ImmutableMap.of(someKey, someValueNew, newKey, newValue));
someSourceType = ConfigSourceType.LOCAL;
when(configRepository.getConfig()).thenReturn(someProperties);
when(configRepository.getSourceType()).thenReturn(someSourceType);
final SettableFuture<ConfigChangeEvent> configChangeFuture = SettableFuture.create();
ConfigChangeListener someListener = new ConfigChangeListener() {
@Override
public void onChange(ConfigChangeEvent changeEvent) {
configChangeFuture.set(changeEvent);
}
};
SimpleConfig config = new SimpleConfig(someNamespace, configRepository);
assertEquals(someSourceType, config.getSourceType());
config.addChangeListener(someListener);
ConfigSourceType anotherSourceType = ConfigSourceType.REMOTE;
when(configRepository.getSourceType()).thenReturn(anotherSourceType);
config.onRepositoryChange(someNamespace, anotherProperties);
ConfigChangeEvent changeEvent = configChangeFuture.get(500, TimeUnit.MILLISECONDS);
assertEquals(someNamespace, changeEvent.getNamespace());
assertEquals(3, changeEvent.changedKeys().size());
ConfigChange someKeyChange = changeEvent.getChange(someKey);
assertEquals(someValue, someKeyChange.getOldValue());
assertEquals(someValueNew, someKeyChange.getNewValue());
assertEquals(PropertyChangeType.MODIFIED, someKeyChange.getChangeType());
ConfigChange anotherKeyChange = changeEvent.getChange(anotherKey);
assertEquals(anotherValue, anotherKeyChange.getOldValue());
assertEquals(null, anotherKeyChange.getNewValue());
assertEquals(PropertyChangeType.DELETED, anotherKeyChange.getChangeType());
ConfigChange newKeyChange = changeEvent.getChange(newKey);
assertEquals(null, newKeyChange.getOldValue());
assertEquals(newValue, newKeyChange.getNewValue());
assertEquals(PropertyChangeType.ADDED, newKeyChange.getChangeType());
assertEquals(anotherSourceType, config.getSourceType());
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySourceTest.java | package com.ctrip.framework.apollo.spring.config;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.List;
import java.util.Set;
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 org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
public class ConfigPropertySourceTest {
private ConfigPropertySource configPropertySource;
@Mock
private Config someConfig;
@Before
public void setUp() throws Exception {
String someName = "someName";
configPropertySource = new ConfigPropertySource(someName, someConfig);
}
@Test
public void testGetPropertyNames() throws Exception {
String somePropertyName = "somePropertyName";
String anotherPropertyName = "anotherPropertyName";
Set<String> somePropertyNames = Sets.newHashSet(somePropertyName, anotherPropertyName);
when(someConfig.getPropertyNames()).thenReturn(somePropertyNames);
String[] result = configPropertySource.getPropertyNames();
verify(someConfig, times(1)).getPropertyNames();
assertArrayEquals(somePropertyNames.toArray(), result);
}
@Test
public void testGetEmptyPropertyNames() throws Exception {
when(someConfig.getPropertyNames()).thenReturn(Sets.<String>newHashSet());
assertEquals(0, configPropertySource.getPropertyNames().length);
}
@Test
public void testGetProperty() throws Exception {
String somePropertyName = "somePropertyName";
String someValue = "someValue";
when(someConfig.getProperty(somePropertyName, null)).thenReturn(someValue);
assertEquals(someValue, configPropertySource.getProperty(somePropertyName));
verify(someConfig, times(1)).getProperty(somePropertyName, null);
}
@Test
public void testAddChangeListener() throws Exception {
ConfigChangeListener someListener = mock(ConfigChangeListener.class);
ConfigChangeListener anotherListener = mock(ConfigChangeListener.class);
final List<ConfigChangeListener> listeners = Lists.newArrayList();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
listeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class));
return Void.class;
}
}).when(someConfig).addChangeListener(any(ConfigChangeListener.class));
configPropertySource.addChangeListener(someListener);
configPropertySource.addChangeListener(anotherListener);
assertEquals(2, listeners.size());
assertTrue(listeners.containsAll(Lists.newArrayList(someListener, anotherListener)));
}
}
| package com.ctrip.framework.apollo.spring.config;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.List;
import java.util.Set;
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 org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
public class ConfigPropertySourceTest {
private ConfigPropertySource configPropertySource;
@Mock
private Config someConfig;
@Before
public void setUp() throws Exception {
String someName = "someName";
configPropertySource = new ConfigPropertySource(someName, someConfig);
}
@Test
public void testGetPropertyNames() throws Exception {
String somePropertyName = "somePropertyName";
String anotherPropertyName = "anotherPropertyName";
Set<String> somePropertyNames = Sets.newHashSet(somePropertyName, anotherPropertyName);
when(someConfig.getPropertyNames()).thenReturn(somePropertyNames);
String[] result = configPropertySource.getPropertyNames();
verify(someConfig, times(1)).getPropertyNames();
assertArrayEquals(somePropertyNames.toArray(), result);
}
@Test
public void testGetEmptyPropertyNames() throws Exception {
when(someConfig.getPropertyNames()).thenReturn(Sets.<String>newHashSet());
assertEquals(0, configPropertySource.getPropertyNames().length);
}
@Test
public void testGetProperty() throws Exception {
String somePropertyName = "somePropertyName";
String someValue = "someValue";
when(someConfig.getProperty(somePropertyName, null)).thenReturn(someValue);
assertEquals(someValue, configPropertySource.getProperty(somePropertyName));
verify(someConfig, times(1)).getProperty(somePropertyName, null);
}
@Test
public void testAddChangeListener() throws Exception {
ConfigChangeListener someListener = mock(ConfigChangeListener.class);
ConfigChangeListener anotherListener = mock(ConfigChangeListener.class);
final List<ConfigChangeListener> listeners = Lists.newArrayList();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
listeners.add(invocation.getArgumentAt(0, ConfigChangeListener.class));
return Void.class;
}
}).when(someConfig).addChangeListener(any(ConfigChangeListener.class));
configPropertySource.addChangeListener(someListener);
configPropertySource.addChangeListener(anotherListener);
assertEquals(2, listeners.size());
assertTrue(listeners.containsAll(Lists.newArrayList(someListener, anotherListener)));
}
}
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/build.sh | #!/bin/sh
# apollo config db info
apollo_config_db_url='jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8'
apollo_config_db_username='FillInCorrectUser'
apollo_config_db_password='FillInCorrectPassword'
# apollo portal db info
apollo_portal_db_url='jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8'
apollo_portal_db_username='FillInCorrectUser'
apollo_portal_db_password='FillInCorrectPassword'
# meta server url, different environments should have different meta server addresses
dev_meta=http://fill-in-dev-meta-server:8080
fat_meta=http://fill-in-fat-meta-server:8080
uat_meta=http://fill-in-uat-meta-server:8080
pro_meta=http://fill-in-pro-meta-server:8080
META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta"
# =============== Please do not modify the following content =============== #
# go to script directory
cd "${0%/*}" || exit
cd ..
# package config-service and admin-service
echo "==== starting to build config-service and admin-service ===="
mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password
echo "==== building config-service and admin-service finished ===="
echo "==== starting to build portal ===="
mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=github,auth -Dspring_datasource_url=$apollo_portal_db_url -Dspring_datasource_username=$apollo_portal_db_username -Dspring_datasource_password=$apollo_portal_db_password $META_SERVERS_OPTS
echo "==== building portal finished ===="
| #!/bin/sh
# apollo config db info
apollo_config_db_url='jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8'
apollo_config_db_username='FillInCorrectUser'
apollo_config_db_password='FillInCorrectPassword'
# apollo portal db info
apollo_portal_db_url='jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8'
apollo_portal_db_username='FillInCorrectUser'
apollo_portal_db_password='FillInCorrectPassword'
# meta server url, different environments should have different meta server addresses
dev_meta=http://fill-in-dev-meta-server:8080
fat_meta=http://fill-in-fat-meta-server:8080
uat_meta=http://fill-in-uat-meta-server:8080
pro_meta=http://fill-in-pro-meta-server:8080
META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta"
# =============== Please do not modify the following content =============== #
# go to script directory
cd "${0%/*}" || exit
cd ..
# package config-service and admin-service
echo "==== starting to build config-service and admin-service ===="
mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password
echo "==== building config-service and admin-service finished ===="
echo "==== starting to build portal ===="
mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=github,auth -Dspring_datasource_url=$apollo_portal_db_url -Dspring_datasource_username=$apollo_portal_db_username -Dspring_datasource_password=$apollo_portal_db_password $META_SERVERS_OPTS
echo "==== building portal finished ===="
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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.
| ./.git/packed-refs | # pack-refs with: peeled fully-peeled sorted
be40a4bc28db310eb2a7d670e55337b5c2eedc1a refs/remotes/origin/0.x
3a8e92c9c2d0abefa89a8e693c0bfa58ccf2d675 refs/remotes/origin/1.1.2
c9eae5410524957ebca97d85eb00eb38fa266125 refs/remotes/origin/1.5.1
f28d0d5a300070795fba5b61f0bee624ab6f814d refs/remotes/origin/1.7.1
204a43779246dfb661da737cb6dffec94ac0c3bb refs/remotes/origin/1.7.2
08754ff73c849763f703a3dfb416393c3ccd147e refs/remotes/origin/1.8.1
7c486fa11e146d4bad65c69611614211bf56c42a refs/remotes/origin/1.8.2
b7acfbef9596e7fe5f6498776ae53be7be3aadb9 refs/remotes/origin/1.9.1
c0cfd647f5844fad470e4ae7278994c1279feb76 refs/remotes/origin/1.x
e3369e5d553f0295e019fbbaaeef2165d543467f refs/remotes/origin/dependabot/maven/com.google.guava-guava-32.0.0-jre
0b15683ae036e4c98dae80de04c4b3e7c2c3c5f5 refs/remotes/origin/gh-pages
2eee86c4ecff61dff5930a6ed276b1fd30b68656 refs/remotes/origin/license
6657a58831a544606f78177b61d92bb959ccce94 refs/remotes/origin/master
e30679add187115bbdc812b6d6ec8398c98e0150 refs/remotes/origin/mvn-repo
f34231b223bdabb4ffcb232c3703129f71cbaad8 refs/remotes/origin/v1.6.1
a4ee45b3db9fd3176f67508648684a617b2254bf refs/remotes/origin/v1.6.2
d327f0703f690457220fb355e969562b75e6aee0 refs/tags/0.6.2
16f4e06379e78e1f03b9b89b5e491bf92fd71d45 refs/tags/tag-oidc-debug-log
af85fa7cde33706fcae6b5c07ce4fd11cdbb3ce6 refs/tags/tag-oidc-debug-log-2
37b6485c7605ccc4b8620d27d1414736369af291 refs/tags/v0.10.0
6b2467df6aa3c286102219e1c5b50efeeb68f747 refs/tags/v0.10.1
03825fa89b799a19be7f3bf0570f4e0c09b92cef refs/tags/v0.10.2
be40a4bc28db310eb2a7d670e55337b5c2eedc1a refs/tags/v0.11.0
2219b0a23544b06a138fdfbc34a4320b2d9e00b5 refs/tags/v0.4.0
f5373b19100766c136aa4980edcf17e41975ee76 refs/tags/v0.5.0
d0fdd72846a0b2530ca9bc1743b3f52e864ab6ed refs/tags/v0.6.0
8372040f85896a93b60ccb14610c2bee2dcc9683 refs/tags/v0.6.3
aeb9230b228b641db443d0d0a9b64bca1ceed9fc refs/tags/v0.7.0
5bcb4095bbfdbdfbe4e176e00d3ce9bdc1a099d7 refs/tags/v0.8.0
2f3204d4181f5d35d7ee2ac5dc3b2c632be7f05a refs/tags/v0.9.0
ac10768ee2e11c488523ca0e845984f6f71499ac refs/tags/v0.9.1
a3cf5b2b6d8462e37dc90f327e064964323d2a80 refs/tags/v1.0.0
7b8ccbe13c2902ebdd3dcffd5d6dd43dd824ce80 refs/tags/v1.1.0
c22ac5637432c3c557bd857314401a3983e704d2 refs/tags/v1.1.1
3a8e92c9c2d0abefa89a8e693c0bfa58ccf2d675 refs/tags/v1.1.2
dcc49834f2e3b12738c83078d19acebd2e336dc1 refs/tags/v1.2.0
d1ae147711af31ea522f988acb36a5c1bf3a4456 refs/tags/v1.3.0
6b0a06a4682e8171cc17f5f61ccc8d87f6871b6d refs/tags/v1.4.0
0d824bb9085c66d3e1bcb8e09f53cf16a978715c refs/tags/v1.5.0
c9eae5410524957ebca97d85eb00eb38fa266125 refs/tags/v1.5.1
a2ae4ad8a8442c7f7842803b50b7783997d2b984 refs/tags/v1.6.0
f34231b223bdabb4ffcb232c3703129f71cbaad8 refs/tags/v1.6.1
a4ee45b3db9fd3176f67508648684a617b2254bf refs/tags/v1.6.2
27aa832c8dba550aa12184fc106790bbe10791e8 refs/tags/v1.7.0
f28d0d5a300070795fba5b61f0bee624ab6f814d refs/tags/v1.7.1
b2cb90e93dbb2eea3b94783a1a922afbd1fb6063 refs/tags/v1.7.2
891010618214b8e826b3c124f5572988135ade58 refs/tags/v1.8.0
08754ff73c849763f703a3dfb416393c3ccd147e refs/tags/v1.8.1
7c486fa11e146d4bad65c69611614211bf56c42a refs/tags/v1.8.2
772d2fa862b6622bbeb31b50437680887a35e749 refs/tags/v1.9.0
501e4b95db4f37fba411266ff24e7d7f460649b8 refs/tags/v1.9.1
e4516e38226b28d321135311f5fe23723ea63bc6 refs/tags/v1.9.2
cb308cb7a9b08178046f747c1f02c8385eeca28c refs/tags/v2.0.0
a882f3e8a0fec0e36d2cfcbc1ca44f0818d7b1cd refs/tags/v2.0.0-RC1
e04028dfe9ca3e5792be89b96a6fbd2ee80355b7 refs/tags/v2.0.1
60bd514df37a8cb2268a5e945a862dc86bd81445 refs/tags/v2.1.0
ee1517be717283ae5bbb990fd2c5a809bd841b4b refs/tags/v2.2.0
| # pack-refs with: peeled fully-peeled sorted
be40a4bc28db310eb2a7d670e55337b5c2eedc1a refs/remotes/origin/0.x
3a8e92c9c2d0abefa89a8e693c0bfa58ccf2d675 refs/remotes/origin/1.1.2
c9eae5410524957ebca97d85eb00eb38fa266125 refs/remotes/origin/1.5.1
f28d0d5a300070795fba5b61f0bee624ab6f814d refs/remotes/origin/1.7.1
204a43779246dfb661da737cb6dffec94ac0c3bb refs/remotes/origin/1.7.2
08754ff73c849763f703a3dfb416393c3ccd147e refs/remotes/origin/1.8.1
7c486fa11e146d4bad65c69611614211bf56c42a refs/remotes/origin/1.8.2
b7acfbef9596e7fe5f6498776ae53be7be3aadb9 refs/remotes/origin/1.9.1
c0cfd647f5844fad470e4ae7278994c1279feb76 refs/remotes/origin/1.x
e3369e5d553f0295e019fbbaaeef2165d543467f refs/remotes/origin/dependabot/maven/com.google.guava-guava-32.0.0-jre
0b15683ae036e4c98dae80de04c4b3e7c2c3c5f5 refs/remotes/origin/gh-pages
2eee86c4ecff61dff5930a6ed276b1fd30b68656 refs/remotes/origin/license
6657a58831a544606f78177b61d92bb959ccce94 refs/remotes/origin/master
e30679add187115bbdc812b6d6ec8398c98e0150 refs/remotes/origin/mvn-repo
f34231b223bdabb4ffcb232c3703129f71cbaad8 refs/remotes/origin/v1.6.1
a4ee45b3db9fd3176f67508648684a617b2254bf refs/remotes/origin/v1.6.2
d327f0703f690457220fb355e969562b75e6aee0 refs/tags/0.6.2
16f4e06379e78e1f03b9b89b5e491bf92fd71d45 refs/tags/tag-oidc-debug-log
af85fa7cde33706fcae6b5c07ce4fd11cdbb3ce6 refs/tags/tag-oidc-debug-log-2
37b6485c7605ccc4b8620d27d1414736369af291 refs/tags/v0.10.0
6b2467df6aa3c286102219e1c5b50efeeb68f747 refs/tags/v0.10.1
03825fa89b799a19be7f3bf0570f4e0c09b92cef refs/tags/v0.10.2
be40a4bc28db310eb2a7d670e55337b5c2eedc1a refs/tags/v0.11.0
2219b0a23544b06a138fdfbc34a4320b2d9e00b5 refs/tags/v0.4.0
f5373b19100766c136aa4980edcf17e41975ee76 refs/tags/v0.5.0
d0fdd72846a0b2530ca9bc1743b3f52e864ab6ed refs/tags/v0.6.0
8372040f85896a93b60ccb14610c2bee2dcc9683 refs/tags/v0.6.3
aeb9230b228b641db443d0d0a9b64bca1ceed9fc refs/tags/v0.7.0
5bcb4095bbfdbdfbe4e176e00d3ce9bdc1a099d7 refs/tags/v0.8.0
2f3204d4181f5d35d7ee2ac5dc3b2c632be7f05a refs/tags/v0.9.0
ac10768ee2e11c488523ca0e845984f6f71499ac refs/tags/v0.9.1
a3cf5b2b6d8462e37dc90f327e064964323d2a80 refs/tags/v1.0.0
7b8ccbe13c2902ebdd3dcffd5d6dd43dd824ce80 refs/tags/v1.1.0
c22ac5637432c3c557bd857314401a3983e704d2 refs/tags/v1.1.1
3a8e92c9c2d0abefa89a8e693c0bfa58ccf2d675 refs/tags/v1.1.2
dcc49834f2e3b12738c83078d19acebd2e336dc1 refs/tags/v1.2.0
d1ae147711af31ea522f988acb36a5c1bf3a4456 refs/tags/v1.3.0
6b0a06a4682e8171cc17f5f61ccc8d87f6871b6d refs/tags/v1.4.0
0d824bb9085c66d3e1bcb8e09f53cf16a978715c refs/tags/v1.5.0
c9eae5410524957ebca97d85eb00eb38fa266125 refs/tags/v1.5.1
a2ae4ad8a8442c7f7842803b50b7783997d2b984 refs/tags/v1.6.0
f34231b223bdabb4ffcb232c3703129f71cbaad8 refs/tags/v1.6.1
a4ee45b3db9fd3176f67508648684a617b2254bf refs/tags/v1.6.2
27aa832c8dba550aa12184fc106790bbe10791e8 refs/tags/v1.7.0
f28d0d5a300070795fba5b61f0bee624ab6f814d refs/tags/v1.7.1
b2cb90e93dbb2eea3b94783a1a922afbd1fb6063 refs/tags/v1.7.2
891010618214b8e826b3c124f5572988135ade58 refs/tags/v1.8.0
08754ff73c849763f703a3dfb416393c3ccd147e refs/tags/v1.8.1
7c486fa11e146d4bad65c69611614211bf56c42a refs/tags/v1.8.2
772d2fa862b6622bbeb31b50437680887a35e749 refs/tags/v1.9.0
501e4b95db4f37fba411266ff24e7d7f460649b8 refs/tags/v1.9.1
e4516e38226b28d321135311f5fe23723ea63bc6 refs/tags/v1.9.2
cb308cb7a9b08178046f747c1f02c8385eeca28c refs/tags/v2.0.0
a882f3e8a0fec0e36d2cfcbc1ca44f0818d7b1cd refs/tags/v2.0.0-RC1
e04028dfe9ca3e5792be89b96a6fbd2ee80355b7 refs/tags/v2.0.1
60bd514df37a8cb2268a5e945a862dc86bd81445 refs/tags/v2.1.0
ee1517be717283ae5bbb990fd2c5a809bd841b4b refs/tags/v2.2.0
| -1 |
apolloconfig/apollo | 3,563 | update wiki url and refine documentation | ## What's the purpose of this PR
update wiki url and refine documentation
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.
| nobodyiam | 2021-02-21T12:19:55Z | 2021-02-21T12:25:34Z | 2fdca1f79afb12c1ed8064bb94da7bd4155545ef | c7da6409ca9f0fd8204a16831dff5149a1d2bb91 | update wiki url and refine documentation. ## What's the purpose of this PR
update wiki url and refine documentation
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/local-development/PortalApplication-Home.png | PNG
IHDR * n G
iCCPICC Profile HT[̤ZB{5A:JHc Pೠ"6!ERDEĂPPׇ*;=o|͝g ,Q'3&6 2z,@LGhh@53Uhrm:Y߯Ws29 @('r39(B#es\2]6ININ;Ss"¼P@aE) ?yf6'Cl!({ᱹ(ltlOuRR3QZNL.y?դ-
q~S'aNWsށ3,Nah^~+bEKäXRN d/kx3͏?Ùiၳsy8LsWqسE#퇛#"YҚpY6é:+`,@JʝRr?@wM%0,, ܃ӟ1 C9^7 g:3H@$ pĢf$toӁ2P gv B@@l@9p -, (!CT)C.dYA+AaP, @HCP Tj_=F`
L`=v=@8^< |