forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
880 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.ctrip.framework.apollo.biz.config; | ||
|
||
import com.google.common.base.Strings; | ||
import com.google.common.collect.Maps; | ||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
import com.ctrip.framework.apollo.biz.service.BizDBPropertySource; | ||
import com.ctrip.framework.apollo.common.config.RefreshableConfig; | ||
import com.ctrip.framework.apollo.common.config.RefreshablePropertySource; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Component | ||
public class BizConfig extends RefreshableConfig { | ||
|
||
private Gson gson = new Gson(); | ||
private static final Type namespaceValueLengthOverrideTypeReference = | ||
new TypeToken<Map<Long, Integer>>() { | ||
}.getType(); | ||
|
||
@Autowired | ||
private BizDBPropertySource propertySource; | ||
|
||
@Override | ||
protected List<RefreshablePropertySource> getRefreshablePropertySources() { | ||
return Collections.singletonList(propertySource); | ||
} | ||
|
||
public List<String> eurekaServiceUrls() { | ||
String configuration = getValue("eureka.service.url", ""); | ||
if (Strings.isNullOrEmpty(configuration)) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
return splitter.splitToList(configuration); | ||
} | ||
|
||
public int grayReleaseRuleScanInterval() { | ||
return getIntProperty("apollo.gray-release-rule-scan.interval", 60); | ||
} | ||
|
||
public int itemKeyLengthLimit() { | ||
return getIntProperty("item.key.length.limit", 128); | ||
} | ||
|
||
public int itemValueLengthLimit() { | ||
return getIntProperty("item.value.length.limit", 20000); | ||
} | ||
|
||
public Map<Long, Integer> namespaceValueLengthLimitOverride() { | ||
String namespaceValueLengthOverrideString = getValue("namespace.value.length.limit.override"); | ||
Map<Long, Integer> namespaceValueLengthOverride = Maps.newHashMap(); | ||
if (!Strings.isNullOrEmpty(namespaceValueLengthOverrideString)) { | ||
namespaceValueLengthOverride = | ||
gson.fromJson(namespaceValueLengthOverrideString, namespaceValueLengthOverrideTypeReference); | ||
} | ||
|
||
return namespaceValueLengthOverride; | ||
} | ||
|
||
public boolean isNamespaceLockSwitchOff() { | ||
return !getBooleanProperty("namespace.lock.switch", false); | ||
} | ||
|
||
/** | ||
* ctrip config | ||
**/ | ||
public String cloggingUrl() { | ||
return getValue("clogging.server.url"); | ||
} | ||
|
||
public String cloggingPort() { | ||
return getValue("clogging.server.port"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 5 additions & 25 deletions
30
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/eureka/ApolloEurekaClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.